|
|
|
@ -1,6 +1,6 @@ |
|
|
|
import { bindAll } from 'underscore'; |
|
|
|
import { AddOptions, DisableOptions, ObjectAny, WithHTMLParserOptions } from '../../common'; |
|
|
|
import RichTextEditorModule from '../../rich_text_editor'; |
|
|
|
import RichTextEditorModule, { RteDisableResult } from '../../rich_text_editor'; |
|
|
|
import RichTextEditor from '../../rich_text_editor/model/RichTextEditor'; |
|
|
|
import { off, on } from '../../utils/dom'; |
|
|
|
import { getComponentModel } from '../../utils/mixins'; |
|
|
|
@ -115,14 +115,17 @@ export default class ComponentTextView<TComp extends ComponentText = ComponentTe |
|
|
|
const editable = model && model.get('editable'); |
|
|
|
|
|
|
|
if (rte) { |
|
|
|
let disableRes: RteDisableResult = {}; |
|
|
|
const content = await this.getContent(); |
|
|
|
|
|
|
|
try { |
|
|
|
await rte.disable(this, activeRte, opts); |
|
|
|
disableRes = await rte.disable(this, activeRte, opts); |
|
|
|
} catch (err) { |
|
|
|
em.logError(err as any); |
|
|
|
} |
|
|
|
|
|
|
|
if (editable && (await this.getContent()) !== this.lastContent) { |
|
|
|
await this.syncContent(opts); |
|
|
|
if (editable && (content !== this.lastContent || disableRes.forceSync)) { |
|
|
|
await this.syncContent({ ...opts, content }); |
|
|
|
this.lastContent = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -151,7 +154,7 @@ export default class ComponentTextView<TComp extends ComponentText = ComponentTe |
|
|
|
async syncContent(opts: ObjectAny = {}) { |
|
|
|
const { model, rte, rteEnabled } = this; |
|
|
|
if (!rteEnabled && !opts.force) return; |
|
|
|
const content = await this.getContent(); |
|
|
|
const content = opts.content ?? (await this.getContent()); |
|
|
|
const comps = model.components(); |
|
|
|
const contentOpt: ObjectAny = { fromDisable: 1, ...opts }; |
|
|
|
model.set('content', '', contentOpt); |
|
|
|
@ -213,12 +216,11 @@ export default class ComponentTextView<TComp extends ComponentText = ComponentTe |
|
|
|
* @param {Event} e |
|
|
|
*/ |
|
|
|
onInput() { |
|
|
|
const { em } = this; |
|
|
|
const evPfx = 'component'; |
|
|
|
const ev = [`${evPfx}:update`, `${evPfx}:input`].join(' '); |
|
|
|
|
|
|
|
// Update toolbars
|
|
|
|
em && em.trigger(ev, this.model); |
|
|
|
this.em?.trigger(ev, this.model); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|