Skip to content

Commit 4a49f73

Browse files
committed
chore(refactor): move editor creation into setup function
Signed-off-by: Max <max@nextcloud.com>
1 parent 0dd33bd commit 4a49f73

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

src/components/Editor.vue

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,20 @@ export default {
274274
}
275275
const syncProvider = shallowRef(null)
276276
277+
const extensions = [
278+
Autofocus.configure({ fileId: props.fileId }),
279+
Collaboration.configure({ document: ydoc }),
280+
CollaborationCursor.configure({ provider: { awareness } }),
281+
]
282+
editor.value = isRichEditor
283+
? createRichEditor({
284+
...wrappedConnection,
285+
relativePath: props.relativePath,
286+
extensions,
287+
isEmbedded: props.isEmbedded,
288+
})
289+
: createPlainEditor({ language, extensions })
290+
277291
return {
278292
awareness,
279293
baseVersionEtag,
@@ -422,21 +436,6 @@ export default {
422436
this.$attachmentResolver = null
423437
if (this.active && this.hasDocumentParameters) {
424438
this.initSession()
425-
const extensions = [
426-
Autofocus.configure({ fileId: this.fileId }),
427-
Collaboration.configure({ document: this.ydoc }),
428-
CollaborationCursor.configure({
429-
provider: { awareness: this.awareness },
430-
}),
431-
]
432-
this.editor = this.isRichEditor
433-
? createRichEditor({
434-
...this.wrappedConnection,
435-
relativePath: this.relativePath,
436-
extensions,
437-
isEmbedded: this.isEmbedded,
438-
})
439-
: createPlainEditor({ language: this.language, extensions })
440439
this.listenEditorEvents()
441440
}
442441
},

0 commit comments

Comments
 (0)