Browse Source

Remove focus from the RTE module

pull/415/head
Artur Arseniev 9 years ago
parent
commit
7394bb42b8
  1. 1
      src/dom_components/view/ComponentTextView.js
  2. 31
      src/rich_text_editor/index.js

1
src/dom_components/view/ComponentTextView.js

@ -29,7 +29,6 @@ module.exports = ComponentView.extend({
if (rte && editable) { if (rte && editable) {
try { try {
this.activeRte = rte.enable(this, this.activeRte); this.activeRte = rte.enable(this, this.activeRte);
rte.focus(this, this.activeRte);
} catch (err) { } catch (err) {
console.error(err); console.error(err);
} }

31
src/rich_text_editor/index.js

@ -157,7 +157,7 @@ module.exports = () => {
/** /**
* Enable rich text editor on the element * Enable rich text editor on the element
* @param {View} view * @param {View} view Component view
* @param {Object} rte The instance of already defined RTE * @param {Object} rte The instance of already defined RTE
* @private * @private
* */ * */
@ -166,17 +166,17 @@ module.exports = () => {
const em = config.em; const em = config.em;
const el = view.getChildrenContainer(); const el = view.getChildrenContainer();
const customRte = this.customRte; const customRte = this.customRte;
const actionbarContainer = toolbar;
rte = customRte ? customRte.enable(el, rte) : new RichTextEditor({el});
toolbar.style.display = ''; toolbar.style.display = '';
rte = customRte ? customRte.enable(el, rte) :
new RichTextEditor({el, actionbarContainer});
if (em) { if (em) {
setTimeout(this.udpatePosition.bind(this), 0); setTimeout(this.udpatePosition.bind(this), 0);
em.off('change:canvasOffset', this.udpatePosition, this); const event = 'change:canvasOffset canvasScroll';
em.on('change:canvasOffset', this.udpatePosition, this); em.off(event, this.udpatePosition, this);
// Update position on scrolling em.on(event, this.udpatePosition, this);
em.off('canvasScroll', this.udpatePosition, this);
em.on('canvasScroll', this.udpatePosition, this);
} }
return rte; return rte;
@ -201,23 +201,6 @@ module.exports = () => {
toolbar.style.display = 'none'; toolbar.style.display = 'none';
}, },
/**
* Unbind rich text editor from the element
* @param {View} view
* @param {Object} rte The instance of already defined RTE
* @private
* */
focus(view, rte) {
var customRte = this.customRte;
var el = view.getChildrenContainer();
if (customRte) {
if(customRte.focus)
customRte.focus(el, rte);
} else {
this.attach(view);
}
},
/** /**
* Return the toolbar element * Return the toolbar element
* @return {HTMLElement} * @return {HTMLElement}

Loading…
Cancel
Save