From b414d4c8edf78c4f49eeb589166e502f712543db Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Fri, 8 Jul 2016 23:44:53 +0200 Subject: [PATCH] Update RTE components --- src/commands/view/SelectComponent.js | 5 ++++- src/rich_text_editor/main.js | 18 +----------------- .../view/CommandButtonsView.js | 11 ----------- src/rich_text_editor/view/TextEditorView.js | 4 ++-- 4 files changed, 7 insertions(+), 31 deletions(-) diff --git a/src/commands/view/SelectComponent.js b/src/commands/view/SelectComponent.js index d1ffc4203..d5ac9b577 100644 --- a/src/commands/view/SelectComponent.js +++ b/src/commands/view/SelectComponent.js @@ -117,7 +117,10 @@ define(function() { * @private */ onClick: function(e) { - var s = $(e.target).data('model').get('stylable'); + var m = $(e.target).data('model'); + if(!m) + return; + var s = m.get('stylable'); if(!(s instanceof Array) && !s) return; this.onSelect(e, e.target); diff --git a/src/rich_text_editor/main.js b/src/rich_text_editor/main.js index 63dce4335..57b217772 100644 --- a/src/rich_text_editor/main.js +++ b/src/rich_text_editor/main.js @@ -36,7 +36,7 @@ define(function(require) { toolS.top = (dims.top - toolbar.$el.outerHeight()) + u; toolS.left = dims.left + u; } - this.bindToolbar(view).show(); + this.show(); //Avoid closing edit mode clicking on toolbar toolbar.$el.on('mousedown', this.disableProp); }, @@ -52,22 +52,6 @@ define(function(require) { toolbar.$el.off('mousedown', this.disableProp); }, - /** - * Bind toolbar to element - * @param {Object} view - * @return {this} - * */ - bindToolbar: function(view){ - var id = tlbPfx + view.model.cid, - dId = tlbPfx + 'inited'; - if(!view.$el.data(dId)){ - view.$el.data(dId, 1); - view.$el.attr('id',id); - } - toolbar.updateTarget('#' + id); - return this; - }, - /** * Show toolbar * diff --git a/src/rich_text_editor/view/CommandButtonsView.js b/src/rich_text_editor/view/CommandButtonsView.js index b48cb5eb7..ecdd7b9c1 100644 --- a/src/rich_text_editor/view/CommandButtonsView.js +++ b/src/rich_text_editor/view/CommandButtonsView.js @@ -15,17 +15,6 @@ define(['backbone','./CommandButtonView'], this.$el.data('helper',1); }, - /** - * Update RTE target pointer - * @param {String} target - * - * @return this - * */ - updateTarget: function(target){ - this.$el.attr('data-target', target); - return this; - }, - render: function() { var fragment = document.createDocumentFragment(); this.$el.empty(); diff --git a/src/rich_text_editor/view/TextEditorView.js b/src/rich_text_editor/view/TextEditorView.js index 15dfe440f..636e09c3d 100644 --- a/src/rich_text_editor/view/TextEditorView.js +++ b/src/rich_text_editor/view/TextEditorView.js @@ -102,10 +102,10 @@ define(['jquery'], input.data(options.selectionMarker, color); }, bindToolbar = function (toolbar, options) { - toolbar.find(toolbarBtnSelector).click(function () { + toolbar.find(toolbarBtnSelector).unbind().click(function () { restoreSelection(); editor.focus(); - execCommand($(this).data(options.commandRole)); + editor.get(0).ownerDocument.execCommand($(this).data(options.commandRole)); saveSelection(); }); toolbar.find('[data-toggle=dropdown]').click(restoreSelection);