From 8f7f80bc726b58d71033d3fe67029005a97ebbcd Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 12 Oct 2017 00:26:48 +0200 Subject: [PATCH] Make text children not editable --- src/dom_components/view/ComponentTextView.js | 1 + src/rich_text_editor/index.js | 7 ++++++- src/rich_text_editor/model/RichTextEditor.js | 6 +++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index d48d7192a..491a990e9 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -65,6 +65,7 @@ module.exports = ComponentView.extend({ } else { const clean = model => { model.set({ + editable: 0, highlightable: 0, removable: 0, draggable: 0, diff --git a/src/rich_text_editor/index.js b/src/rich_text_editor/index.js index 0478e413c..08267d12d 100644 --- a/src/rich_text_editor/index.js +++ b/src/rich_text_editor/index.js @@ -164,6 +164,7 @@ module.exports = () => { const pfx = this.pfx; const el = view.getChildrenContainer(); const customRte = this.customRte; + const actionbar = this.actionbar; const actionbarContainer = toolbar; const classes = { actionbar: `${pfx}actionbar`, @@ -172,7 +173,11 @@ module.exports = () => { toolbar.style.display = ''; rte = customRte ? customRte.enable(el, rte) : - new RichTextEditor({el, actionbarContainer, classes}).enable(); + new RichTextEditor({el, actionbarContainer, classes, actionbar}).enable(); + + if (rte.actionbar) { + this.actionbar = rte.actionbar; + } if (em) { setTimeout(this.udpatePosition.bind(this), 0); diff --git a/src/rich_text_editor/model/RichTextEditor.js b/src/rich_text_editor/model/RichTextEditor.js index cb67d9dd8..4fb97a8a6 100644 --- a/src/rich_text_editor/model/RichTextEditor.js +++ b/src/rich_text_editor/model/RichTextEditor.js @@ -25,7 +25,7 @@ const actions = { result: (rte) => rte.exec('strikeThrough') }, link: { - icon: '🔗', + icon: 'Link', title: 'Link', result: (rte) => { const url = window.prompt('Enter the link URL') @@ -43,8 +43,8 @@ export default class RichTextEditor { return el[RTE_KEY]; } - el.oninput = e => settings.onChange && settings.onChange(e.target.innerHTML); - el.onkeydown = e => (e.which === 9 && e.preventDefault()); + //el.oninput = e => settings.onChange && settings.onChange(e.target.innerHTML); + //el.onkeydown = e => (e.which === 9 && e.preventDefault()); el[RTE_KEY] = this; this.el = el; this.doc = el.ownerDocument;