Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(editorApi): Use attachment resolver in MarkdownContentEditor #4844

Merged
merged 1 commit into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions src/components/Editor/MarkdownContentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -75,6 +80,14 @@ export default {
type: Boolean,
default: false,
},
relativePath: {
type: String,
default: '',
},
shareToken: {
type: String,
default: null,
},
showOutlineOutside: {
type: Boolean,
default: false,
Expand All @@ -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() {
Expand Down
2 changes: 2 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
Loading