@@ -101,7 +101,7 @@ import { extensionHighlight } from '../helpers/mappings.js'
101
101
import { createEditor, serializePlainText, loadSyntaxHighlight } from './../EditorFactory.js'
102
102
import { createMarkdownSerializer } from './../extensions/Markdown.js'
103
103
import markdownit from './../markdownit/index.js'
104
-
104
+ import { exposeForDebugging, removeFromDebugging } from '../helpers/debug.js'
105
105
import { CollaborationCursor } from '../extensions/index.js'
106
106
import DocumentStatus from './Editor/DocumentStatus.vue'
107
107
import isMobile from './../mixins/isMobile.js'
@@ -338,7 +338,7 @@ export default {
338
338
subscribe('text:image-node:delete', this.onDeleteImageNode)
339
339
this.emit('update:loaded', true)
340
340
subscribe('text:translate-modal:show', this.showTranslateModal)
341
- this.setupEditorDebug( )
341
+ exposeForDebugging(this )
342
342
},
343
343
created() {
344
344
this.$ydoc = new Doc()
@@ -365,7 +365,8 @@ export default {
365
365
const timeout = new Promise((resolve) => setTimeout(resolve, 2000))
366
366
await Promise.any([timeout, this.$syncService.save()])
367
367
}
368
- this.close()
368
+ await this.close()
369
+ removeFromDebugging(this)
369
370
},
370
371
methods: {
371
372
initSession() {
@@ -750,46 +751,17 @@ export default {
750
751
console.debug(editor.getHTML())
751
752
},
752
753
753
- /**
754
- * Setup OCA.Text.debugYjs() and expose editor component in OCA.Text.editorComponents
755
- */
756
- setupEditorDebug() {
757
- if (!window.OCA.Text) {
758
- window.OCA.Text = {}
759
- }
760
- if (!window.OCA.Text.editorComponents) {
761
- window.OCA.Text.editorComponents = []
762
- }
763
- window.OCA.Text.editorComponents.push(this)
764
-
765
- if (!window.OCA.Text.debugYjs) {
766
- window.OCA.Text.debugYjs = () => {
767
- const intro = 'Editor Yjs debug data. Copy the objects above that start with "fileId".'
768
- const introChrome = '- In Chrome, select "Copy" at the end of the line.'
769
- const introFirefox = '- In Firefox, right-click on the object and select "Copy object".'
770
- const styleBold = 'font-weight: bold;'
771
- const styleItalic = 'font-weight: normal; font-style: italic;'
772
-
773
- for (const editorComponent of window.OCA.Text.editorComponents) {
774
- console.warn(JSON.stringify(editorComponent.debugYjsData(), null, ' '))
775
- }
776
-
777
- console.warn('%c%s\n%c%s\n%s', styleBold, intro, styleItalic, introChrome, introFirefox)
778
- }
779
- }
780
- },
781
-
782
754
/**
783
755
* Helper method to debug yjs issues
784
756
*/
785
- debugYjsData () {
757
+ debugData () {
786
758
const yjsData = {
787
759
fileId: this.fileId,
788
760
filePath: this.relativePath,
789
761
clientId: this.$ydoc.clientID,
790
762
pendingStructs: this.$ydoc.store.pendingStructs,
791
763
clientVectors: [],
792
- documentState: this.$syncService.getDocumentState(),
764
+ documentState: this.$syncService? .getDocumentState(),
793
765
}
794
766
for (const client of this.$ydoc.store.clients.values()) {
795
767
yjsData.clientVectors.push(client.at(-1).id)
0 commit comments