Skip to content

Commit

Permalink
fix: fill the link popup text field with the selected text
Browse files Browse the repository at this point in the history
  • Loading branch information
js87zz committed Dec 20, 2021
1 parent ec79e4a commit 7e43385
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions apps/editor/src/editorCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion apps/editor/src/markdown/mdPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ class MarkdownPreview {
}

getElement() {
return this.el;
return this.el!;
}

getHTML() {
Expand Down
5 changes: 4 additions & 1 deletion apps/editor/src/ui/components/toolbar/toolbarButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,20 @@ export class ToolbarButtonComp extends Component<Props> {
};

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) {
Expand Down

0 comments on commit 7e43385

Please sign in to comment.