Hide settings when clicked on another block

[MAILPOET-1974]
This commit is contained in:
Ján Mikláš
2019-05-02 13:36:59 +02:00
committed by M. Shull
parent abbd7873fc
commit 5663b1f745
2 changed files with 11 additions and 0 deletions

View File

@@ -71,6 +71,9 @@ BL.TextEditorBehavior = Marionette.Behavior.extend({
});
editor.on('click', function onClick(e) {
if (App.getShowedSettingsId()) {
App.getChannel().trigger('hideSettings');
}
// if caret not in editor, place it there (triggers focus on editor)
if (document.activeElement !== editor.targetElm) {
editor.selection.placeCaretAt(e.clientX, e.clientY);

View File

@@ -226,6 +226,14 @@ Module.BlockToolsView = AugmentedView.extend({
},
changeSettings: function changeSettings(options) {
var ViewType = this.getSettingsView();
var showedSettingsId = App.getShowedSettingsId();
if (showedSettingsId) {
if (showedSettingsId === this.model.cid) {
return;
}
App.getChannel().trigger('hideSettings');
return;
}
App.getChannel().trigger('settingsShowed', this.model.cid);
(new ViewType(_.extend({ model: this.model }, options || {}))).render();
},