Skip to content

Commit

Permalink
Closing HTML Assistant on loose element focus
Browse files Browse the repository at this point in the history
Issue: Samsung#269
Problem: HTML Assistant cannot close when focus is lost
Solution: When focus lost HTML Assistant close by itself

Signed-off-by: Kornelia Kobiela <k.kobiela@samsung.com>
  • Loading branch information
Kornelia Kobiela committed Aug 23, 2019
1 parent 0d1f568 commit 050a910
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
13 changes: 10 additions & 3 deletions design-editor/src/pane/select-layer/html-assistant.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-console */
'use babel';
import {HTMLAssistantEditorElement} from 'html-assistant-editor';
import {EVENTS, eventEmitter} from '../../events-emitter';
Expand Down Expand Up @@ -54,26 +55,32 @@ class HTMLAssistant {
.then(() => {
this.element = this._model.getElementWithoutId(this.selectedElementId);
this._htmlAssistantEditor.clean();
eventEmitter.emit(EVENTS.CloseInstantTextEditor);
})
.catch(error => console.error(error));

} else {
this._htmlAssistantEditor.open(this.getSelectedContent(this.element));
eventEmitter.emit(EVENTS.OpenInstantTextEditor);
}
callback(opened);
}

_bindEvents () {
eventEmitter.on(EVENTS.ElementSelected, (elementId) => {
console.log("element selected", elementId);
console.log('element selected', elementId);
this._model = appManager.getActiveDesignEditor().getModel();
this.selectedElementId = elementId;
this.element = this._model.getElementWithoutId(this.selectedElementId);
});

eventEmitter.on(EVENTS.ElementDeselected, () => {
console.log("element deselected");
this.selectedElementId = null;
if (this._htmlAssistantEditor.isOpened()) {
console.log('element deselected');
this.toggle(() => {
this.selectedElementId = null;
});
}
});
}
}
Expand Down
10 changes: 10 additions & 0 deletions design-editor/src/panel/toolbar-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Toolbar extends DressElement {
*/
onCreated() {
this._allButtonsDisabled = false;
this.htmlAssistantOpen = false;
this._initialize();
this._create();
this.events = {
Expand All @@ -40,6 +41,14 @@ class Toolbar extends DressElement {
'click .save-file': EVENTS.DocumentSave
};

eventEmitter.on(EVENTS.OpenInstantTextEditor, () => {
this.htmlAssistantOpen = true;
});

eventEmitter.on(EVENTS.OpenInstantTextEditor, () => {
this.htmlAssistantOpen = false;
});

eventEmitter.on(EVENTS.ElementSelected, (elementId) => {
this.setEnable(this.Controls.INSTANT_EDIT);
if (this._assistantViewState) {
Expand All @@ -48,6 +57,7 @@ class Toolbar extends DressElement {
this._selectedElement = elementId;
});
eventEmitter.on(EVENTS.ElementDeselected, () => {
this.turnOffControl(this.Controls.INSTANT_EDIT);
this.setDisable(this.Controls.INSTANT_EDIT);
this.setDisable(this.Controls.INSERT_CODE);
this._selectedElement = null;
Expand Down
2 changes: 1 addition & 1 deletion design-editor/src/system/stage-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class StageManager {

this._infoElement = new InfoElement();

this._htmlAssistant = new HTMLAssistant();
this._toolbarContainerElement = new ToolbarElement();
this._toolbarContainerElementPanel = null;

Expand All @@ -45,7 +46,6 @@ class StageManager {
// this._interactionViewElementToolbarPanel = null;
// this._interactionView = new InteractionViewElement();

this._htmlAssistant = new HTMLAssistant();
this._assistantManager = new AssistantManager();
panelManager.openPanel({type: 'left', item: this._toolbarContainerElement, priority: 110});

Expand Down

0 comments on commit 050a910

Please sign in to comment.