diff --git a/src/components/Editor/MarkdownContentEditor.vue b/src/components/Editor/MarkdownContentEditor.vue index 211e2404e34..adc8edb2bd8 100644 --- a/src/components/Editor/MarkdownContentEditor.vue +++ b/src/components/Editor/MarkdownContentEditor.vue @@ -40,8 +40,10 @@ import MenuBar from '../Menu/MenuBar.vue' import { Editor } from '@tiptap/core' /* eslint-disable import/no-named-as-default */ import History from '@tiptap/extension-history' -import { EDITOR, IS_RICH_EDITOR, useLinkClickHook } from '../Editor.provider.js' +import { getCurrentUser } from '@nextcloud/auth' +import { ATTACHMENT_RESOLVER, EDITOR, IS_RICH_EDITOR, useLinkClickHook } from '../Editor.provider.js' import { createMarkdownSerializer } from '../../extensions/Markdown.js' +import AttachmentResolver from '../../services/AttachmentResolver.js' import markdownit from '../../markdownit/index.js' import { RichText } from '../../extensions/index.js' import ReadonlyBar from '../Menu/ReadonlyBar.vue' @@ -55,12 +57,15 @@ export default { const val = {} Object.defineProperties(val, { - [IS_RICH_EDITOR]: { - get: () => true, - }, [EDITOR]: { get: () => this.$editor, }, + [ATTACHMENT_RESOLVER]: { + get: () => this.$attachmentResolver, + }, + [IS_RICH_EDITOR]: { + get: () => true, + }, }) return val @@ -75,6 +80,14 @@ export default { type: Boolean, default: false, }, + relativePath: { + type: String, + default: '', + }, + shareToken: { + type: String, + default: null, + }, showOutlineOutside: { type: Boolean, default: false, @@ -97,6 +110,11 @@ export default { created() { this.$editor = this.createEditor() this.$editor.setEditable(!this.readOnly) + this.$attachmentResolver = new AttachmentResolver({ + currentDirectory: this.relativePath?.match(/.*\//), + user: getCurrentUser(), + shareToken: this.shareToken, + }) }, beforeDestroy() { diff --git a/src/editor.js b/src/editor.js index b9c7c42bb6a..4ee1ef9a25e 100644 --- a/src/editor.js +++ b/src/editor.js @@ -212,6 +212,8 @@ window.OCA.Text.createEditor = async function({ : h(MarkdownContentEditor, { props: { content: data.content, + relativePath: filePath, + shareToken, readOnly: data.readOnly, showOutlineOutside: data.showOutlineOutside, },