diff --git a/src/components/Editor/PreviewOptions.vue b/src/components/Editor/PreviewOptions.vue index 58013854b9..d2b02556eb 100644 --- a/src/components/Editor/PreviewOptions.vue +++ b/src/components/Editor/PreviewOptions.vue @@ -68,7 +68,7 @@ export default { type: Number, required: true, }, - editor: { + $editor: { type: Object, required: true, }, @@ -82,11 +82,11 @@ export default { methods: { onOpen() { - this.editor.commands.hideLinkBubble() + this.$editor.commands.hideLinkBubble() }, toggle(type) { this.open = false - const chain = this.editor.chain().focus() + const chain = this.$editor.chain().focus() .setTextSelection(this.offset + 1) if (type === 'text-only') { chain.unsetPreview().run() @@ -95,7 +95,7 @@ export default { chain.setPreview().run() }, deleteNode() { - this.editor.commands.deleteRange({ + this.$editor.commands.deleteRange({ from: this.offset, to: this.offset + this.nodeSize, }) diff --git a/src/plugins/headingAnchor.js b/src/plugins/headingAnchor.js index 000b4c4ad2..e1925ad3a4 100644 --- a/src/plugins/headingAnchor.js +++ b/src/plugins/headingAnchor.js @@ -22,7 +22,6 @@ export default function headingAnchor() { state: { init(_, { doc }) { - console.debug('headingAnchor init') const headings = extractHeadings(doc) return { headings, diff --git a/src/plugins/previewOptions.js b/src/plugins/previewOptions.js index 99f1af5f07..c967ab6fba 100644 --- a/src/plugins/previewOptions.js +++ b/src/plugins/previewOptions.js @@ -26,6 +26,9 @@ export default function previewOptions({ editor }) { state: { init(_, { doc }) { + if (!editor.options.editable) { + return { decorations: DecorationSet.create() } + } const linkParagraphs = extractLinkParagraphs(doc) return { linkParagraphs, @@ -36,6 +39,9 @@ export default function previewOptions({ editor }) { if (!tr.docChanged) { return value } + if (!editor.options.editable) { + return value + } const linkParagraphs = extractLinkParagraphs(newState.doc) const decorations = mapDecorations(value, tr, linkParagraphs) || linkParagraphDecorations(newState.doc, linkParagraphs, editor) return { linkParagraphs, decorations } @@ -96,6 +102,7 @@ function linkParagraphsChanged(current, prev) { */ const isDifferentFrom = (other) => (linkParagraph, i) => { return linkParagraph.type !== other[i].type + || linkParagraph.nodeSize !== other[i].nodeSize } /** @@ -138,7 +145,7 @@ function decorationForLinkParagraph(linkParagraph, editor) { */ function previewOptionForLinkParagraph(linkParagraph, editor) { const propsData = { - editor, + $editor: editor, ...linkParagraph, } const el = document.createElement('div')