Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix: Adapt to review feedback
Signed-off-by: Julius Härtl <[email protected]>
  • Loading branch information
juliusknorr authored and backportbot[bot] committed Apr 2, 2024
commit 4900fa2c903a1136d9f0829dec772b915b91a5a7
2 changes: 1 addition & 1 deletion src/components/CollisionResolveDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default {
const { outsideChange } = this.syncError.data
this.clicked = true
this.$editor.setEditable(!this.readOnly)
this.setContent(outsideChange, { isRich: this.$isRichEditor })
this.setContent(outsideChange, { isRichEditor: this.$isRichEditor })
this.$syncService.forceSave().then(() => this.$syncService.syncUp())
},
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ export default {
this.$queue.push(updateMessage)
}
} else {
this.setInitialYjsState(documentSource, { isRich: this.isRichEditor })
this.setInitialYjsState(documentSource, { isRichEditor: this.isRichEditor })
}

this.hasConnectionIssue = false
Expand Down
15 changes: 8 additions & 7 deletions src/mixins/setContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import { createEditor } from '../EditorFactory.js'

export default {
methods: {
setContent(content, { isRich, addToHistory = true } = {}) {
const html = isRich
setContent(content, { isRichEditor, addToHistory = true } = {}) {
const html = isRichEditor
? markdownit.render(content) + '<p/>'
: `<pre>${escapeHtml(content)}</pre>`
this.$editor.chain()
Expand All @@ -43,13 +43,13 @@ export default {
.run()
},

setInitialYjsState(content, { isRich }) {
const html = isRich
setInitialYjsState(content, { isRichEditor }) {
const html = isRichEditor
? markdownit.render(content) + '<p/>'
: `<pre>${escapeHtml(content)}</pre>`

const editor = createEditor({
enableRichEditing: isRich,
enableRichEditing: isRichEditor,
})
const json = generateJSON(html, editor.extensionManager.extensions)

Expand All @@ -58,14 +58,15 @@ export default {
const ydoc = new Doc()
// In order to make the initial document state idempotent, we need to reset the clientID
// While this is not recommended, we cannot avoid it here as we lack another mechanism
// generate the initial state on the server side
// to generate the initial state on the server side
// The only other option to avoid this could be to generate the initial state once and push
// it to the server immediately, however this would require read only sessions to be able
// to still push a state
ydoc.clientID = 0
const type = /** @type {XmlFragment} */ (ydoc.get('default', XmlFragment))
if (!type.doc) {
prosemirrorToYXmlFragment(doc, ydoc)
// This should not happen but is aligned with the upstream implementation
// https://github.com/yjs/y-prosemirror/blob/8db24263770c2baaccb08e08ea9ef92dbcf8a9da/src/lib.js#L209
return ydoc
}

Expand Down