Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
881ce5b
chore(migrate): useEditorMixin to useEditor composable
max-nextcloud Jun 16, 2025
8d998f0
chore(migrate): setContent mixin...
max-nextcloud Jun 17, 2025
13a5ce1
chore(migrate): to useEditorFlags composable
max-nextcloud Jun 18, 2025
d958a4d
chore(cleanup): fix small review remarks
max-nextcloud Jun 18, 2025
b0790dc
chore(migrate): use.find instead of deprecated .contains
max-nextcloud Jun 19, 2025
8b4e635
enh(editor): store session in separate extension
max-nextcloud Jun 20, 2025
9d3cc87
chore(refactor): configure mention in rich text extension
max-nextcloud Jun 20, 2025
c4f863f
chore(types): collaborationCursor extension to typescript
max-nextcloud Jun 20, 2025
354ad41
chore(simplify): rely on updateUser command
max-nextcloud Jun 20, 2025
022e483
chore(simplify): replace computed fileExtension with temp
max-nextcloud Jun 20, 2025
0809c8e
enh(code): start to load syntax highlighting during setup
max-nextcloud Jun 20, 2025
b326875
chore(refactor): load editor in mounted
max-nextcloud Jun 20, 2025
3e5cfd8
chore(refactor): create editor in created instead of mounted
max-nextcloud Jun 26, 2025
ab26032
chore(refactor): create ydoc in setup
max-nextcloud Jun 26, 2025
2831462
fix(character-count): always provide the current editors doc
max-nextcloud Jun 26, 2025
d7df4c0
fix(character-count): use the NcActionTexts name prop
max-nextcloud Jun 26, 2025
e24d90a
fix(loading): only show main container when content loaded
max-nextcloud Jun 26, 2025
0d5f4f7
fix(mention): use shallowRef for connection
max-nextcloud Jun 27, 2025
057a682
fix(load): create initial YjsState with dir
max-nextcloud Jun 27, 2025
fae62fc
chore(refactor): extract useEditor into its own file
max-nextcloud Jun 28, 2025
17f0d62
chore(refactor): extract useEditorFlags into its own file
max-nextcloud Jun 28, 2025
90b1d84
test(RichTextReader): basic test
max-nextcloud Jun 28, 2025
fabc79e
test(RichTextReader): update content
max-nextcloud Jun 28, 2025
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
Prev Previous commit
Next Next commit
chore(refactor): load editor in mounted
Cannot load it in setup yet as it requires the yjs provider,
which in turn requires the sync service,
which is only initialized in mounted.

Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Jun 28, 2025
commit b326875654dd16429a810a10c8573161fc65e128
55 changes: 23 additions & 32 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,20 @@ export default {
mounted() {
if (this.active && this.hasDocumentParameters) {
this.initSession()
const extensions = [
Autofocus.configure({ fileId: this.fileId }),
Collaboration.configure({ document: this.$ydoc }),
CollaborationCursor.configure({ provider: this.$providers[0] }),
Session,
]
this.editor = this.isRichEditor
? createRichEditor({
relativePath: this.relativePath,
extensions,
isEmbedded: this.isEmbedded,
})
: createPlainEditor({ language: this.language, extensions })
this.listenEditorEvents()
}
if (!this.richWorkspace) {
/* If the editor is shown in the viewer we need to hide the content,
Expand Down Expand Up @@ -489,7 +503,9 @@ export default {
reconnect() {
this.contentLoaded = false
this.hasConnectionIssue = false
this.disconnect().then(this.initSession)
this.disconnect().then(() => {
this.initSession()
})
this.idle = false
},

Expand Down Expand Up @@ -571,14 +587,15 @@ export default {
},

onLoaded({ document, documentSource, documentState }) {
if (!documentState) {
this.lowlightLoaded.then(() => {
// only add the content once the syntax highlighting is ready
// Fetch the document state after syntax highlights are loaded
this.lowlightLoaded.then(() => {
this.$syncService.startSync()
if (!documentState) {
setInitialYjsState(this.$ydoc, documentSource, {
isRichEditor: this.isRichEditor,
})
})
}
}
})

this.$baseVersionEtag = document.baseVersionEtag
this.hasConnectionIssue = false
Expand All @@ -591,28 +608,6 @@ export default {
color: session?.color,
clientId: this.$ydoc.clientID,
}

if (this.editor) {
// editor already existed. So this is a reconnect.
this.$syncService.startSync()
this.editor.commands.setSession(this.currentSession)
this.editor.commands.updateUser(user)
return
}
const extensions = [
Autofocus.configure({ fileId: this.fileId }),
Collaboration.configure({ document: this.$ydoc }),
CollaborationCursor.configure({ provider: this.$providers[0] }),
Session,
]
this.editor = this.isRichEditor
? createRichEditor({
relativePath: this.relativePath,
extensions,
isEmbedded: this.isEmbedded,
})
: createPlainEditor({ language: this.language, extensions })
this.listenEditorEvents()
this.editor.commands.setSession(this.currentSession)
this.editor.commands.updateUser(user)
},
Expand All @@ -626,10 +621,6 @@ export default {
},

onCreate({ editor }) {
// Fetch the document state after syntax highlights are loaded.
this.lowlightLoaded.then(() => {
this.$syncService.startSync()
})
const proseMirrorMarkdown = this.$syncService.serialize(editor.state.doc)
this.emit('create:content', {
markdown: proseMirrorMarkdown,
Expand Down