diff --git a/apps/editor/src/editorCore.ts b/apps/editor/src/editorCore.ts index 84d86ef812..6f16285201 100644 --- a/apps/editor/src/editorCore.ts +++ b/apps/editor/src/editorCore.ts @@ -42,6 +42,7 @@ import { cls, replaceBRWithEmptyBlock } from './utils/dom'; import { sanitizeHTML } from './sanitizer/htmlSanitizer'; import { createHTMLSchemaMap } from './wysiwyg/nodes/html'; import { getHTMLRenderConvertors } from './markdown/htmlRenderConvertors'; +import { buildQuery } from './queries/queryManager'; /** * ToastUIEditorCore @@ -273,6 +274,7 @@ class ToastUIEditorCore { this.scrollSync = new ScrollSync(this.mdEditor, this.preview, this.eventEmitter); this.addInitEvent(); this.addInitCommand(mdCommands, wwCommands); + buildQuery(this); if (this.options.hooks) { forEachOwnProperties(this.options.hooks, (fn, key) => this.addHook(key, fn)); diff --git a/apps/editor/src/markdown/mdPreview.ts b/apps/editor/src/markdown/mdPreview.ts index d254d4bc78..ebff3edad0 100644 --- a/apps/editor/src/markdown/mdPreview.ts +++ b/apps/editor/src/markdown/mdPreview.ts @@ -220,7 +220,7 @@ class MarkdownPreview { } getElement() { - return this.el; + return this.el!; } getHTML() { diff --git a/apps/editor/src/ui/components/toolbar/toolbarButton.ts b/apps/editor/src/ui/components/toolbar/toolbarButton.ts index fda07e0efc..415ed467a3 100644 --- a/apps/editor/src/ui/components/toolbar/toolbarButton.ts +++ b/apps/editor/src/ui/components/toolbar/toolbarButton.ts @@ -54,17 +54,20 @@ export class ToolbarButtonComp extends Component { }; private execCommand = () => { - const { item, execCommand, setPopupInfo, getBound } = this.props; + const { item, execCommand, setPopupInfo, getBound, eventEmitter } = this.props; const { command, name, popup } = item; if (command) { execCommand(command); } else { const popupName = popup ? 'customPopupBody' : name; + const [initialValues] = eventEmitter.emit('query', 'getPopupInitialValues', { popupName }); + const info = createPopupInfo(popupName, { el: this.refs.el, pos: getBound(this.refs.el), popup, + initialValues, }); if (info) {