|
@@ -226,6 +226,14 @@ class StaticNotebook extends Widget {
|
|
super.dispose();
|
|
super.dispose();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Handle `'activate-request'` messages.
|
|
|
|
+ */
|
|
|
|
+ protected onActivateRequest(msg: Message): void {
|
|
|
|
+ this.node.focus();
|
|
|
|
+ this.update();
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Handle a new model.
|
|
* Handle a new model.
|
|
*
|
|
*
|
|
@@ -606,6 +614,13 @@ class Notebook extends StaticNotebook {
|
|
let widget = layout.widgets.at(i) as BaseCellWidget;
|
|
let widget = layout.widgets.at(i) as BaseCellWidget;
|
|
this.deselect(widget);
|
|
this.deselect(widget);
|
|
}
|
|
}
|
|
|
|
+ let activeCell = this.activeCell;
|
|
|
|
+ if (activeCell) {
|
|
|
|
+ activeCell.activate();
|
|
|
|
+ }
|
|
|
|
+ if (activeCell instanceof MarkdownCellWidget) {
|
|
|
|
+ activeCell.rendered = false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
this.stateChanged.emit({ name: 'mode', oldValue, newValue });
|
|
this.stateChanged.emit({ name: 'mode', oldValue, newValue });
|
|
this.update();
|
|
this.update();
|
|
@@ -640,6 +655,9 @@ class Notebook extends StaticNotebook {
|
|
if (newValue === oldValue) {
|
|
if (newValue === oldValue) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ if (this.mode === 'edit' && this.activeCell) {
|
|
|
|
+ this.activeCell.activate();
|
|
|
|
+ }
|
|
this.stateChanged.emit({ name: 'activeCellIndex', oldValue, newValue });
|
|
this.stateChanged.emit({ name: 'activeCellIndex', oldValue, newValue });
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
@@ -765,9 +783,10 @@ class Notebook extends StaticNotebook {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Handle `'activate-request'` messages.
|
|
|
|
|
|
+ * Handle `'deactivate-request'` messages.
|
|
*/
|
|
*/
|
|
- protected onActivateRequest(msg: Message): void {
|
|
|
|
|
|
+ protected onDeactivateRequest(msg: Message): void {
|
|
|
|
+ this.mode = 'command';
|
|
this.update();
|
|
this.update();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -780,20 +799,10 @@ class Notebook extends StaticNotebook {
|
|
if (this.mode === 'edit') {
|
|
if (this.mode === 'edit') {
|
|
this.addClass(EDIT_CLASS);
|
|
this.addClass(EDIT_CLASS);
|
|
this.removeClass(COMMAND_CLASS);
|
|
this.removeClass(COMMAND_CLASS);
|
|
- if (activeCell) {
|
|
|
|
- activeCell.activate();
|
|
|
|
- if (activeCell instanceof MarkdownCellWidget) {
|
|
|
|
- activeCell.rendered = false;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
} else {
|
|
} else {
|
|
- if (!this.node.contains(document.activeElement)) {
|
|
|
|
- this.node.focus();
|
|
|
|
- }
|
|
|
|
this.addClass(COMMAND_CLASS);
|
|
this.addClass(COMMAND_CLASS);
|
|
this.removeClass(EDIT_CLASS);
|
|
this.removeClass(EDIT_CLASS);
|
|
}
|
|
}
|
|
-
|
|
|
|
if (activeCell) {
|
|
if (activeCell) {
|
|
activeCell.addClass(ACTIVE_CLASS);
|
|
activeCell.addClass(ACTIVE_CLASS);
|
|
}
|
|
}
|
|
@@ -943,15 +952,17 @@ class Notebook extends StaticNotebook {
|
|
* Handle `focus` events for the widget.
|
|
* Handle `focus` events for the widget.
|
|
*/
|
|
*/
|
|
private _evtFocus(event: FocusEvent): void {
|
|
private _evtFocus(event: FocusEvent): void {
|
|
- this.mode = 'command';
|
|
|
|
let i = this._findCell(event.target as HTMLElement);
|
|
let i = this._findCell(event.target as HTMLElement);
|
|
if (i === -1) {
|
|
if (i === -1) {
|
|
|
|
+ this.mode = 'command';
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
this.activeCellIndex = i;
|
|
this.activeCellIndex = i;
|
|
let widget = this.childAt(i);
|
|
let widget = this.childAt(i);
|
|
if (widget.editor.node.contains(event.target as HTMLElement)) {
|
|
if (widget.editor.node.contains(event.target as HTMLElement)) {
|
|
this.mode = 'edit';
|
|
this.mode = 'edit';
|
|
|
|
+ } else {
|
|
|
|
+ this.mode = 'command';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|