@@ -115,7 +115,7 @@ import { extensionHighlight } from '../helpers/mappings.js'
115115import { createEditor , serializePlainText , loadSyntaxHighlight } from ' ./../EditorFactory.js'
116116import { createMarkdownSerializer } from ' ./../extensions/Markdown.js'
117117import markdownit from ' ./../markdownit/index.js'
118-
118+ import { exposeForDebugging , removeFromDebugging } from ' ../helpers/debug.js '
119119import { CollaborationCursor } from ' ../extensions/index.js'
120120import DocumentStatus from ' ./Editor/DocumentStatus.vue'
121121import isMobile from ' ./../mixins/isMobile.js'
@@ -351,7 +351,7 @@ export default {
351351 subscribe (' text:image-node:add' , this .onAddImageNode )
352352 subscribe (' text:image-node:delete' , this .onDeleteImageNode )
353353 this .emit (' update:loaded' , true )
354- this . setupEditorDebug ( )
354+ exposeForDebugging ( this )
355355 },
356356 created () {
357357 this .$ydoc = new Doc ()
@@ -377,7 +377,8 @@ export default {
377377 const timeout = new Promise ((resolve ) => setTimeout (resolve, 2000 ))
378378 await Promise .any ([timeout, this .$syncService .save ()])
379379 }
380- this .close ()
380+ await this .close ()
381+ removeFromDebugging (this )
381382 },
382383 methods: {
383384 initSession () {
@@ -762,46 +763,17 @@ export default {
762763 console .debug (editor .getHTML ())
763764 },
764765
765- /**
766- * Setup OCA.Text.debugYjs() and expose editor component in OCA.Text.editorComponents
767- */
768- setupEditorDebug () {
769- if (! window .OCA .Text ) {
770- window .OCA .Text = {}
771- }
772- if (! window .OCA .Text .editorComponents ) {
773- window .OCA .Text .editorComponents = []
774- }
775- window .OCA .Text .editorComponents .push (this )
776-
777- if (! window .OCA .Text .debugYjs ) {
778- window .OCA .Text .debugYjs = () => {
779- const intro = ' Editor Yjs debug data. Copy the objects above that start with "fileId".'
780- const introChrome = ' - In Chrome, select "Copy" at the end of the line.'
781- const introFirefox = ' - In Firefox, right-click on the object and select "Copy object".'
782- const styleBold = ' font-weight: bold;'
783- const styleItalic = ' font-weight: normal; font-style: italic;'
784-
785- for (const editorComponent of window .OCA .Text .editorComponents ) {
786- console .warn (JSON .stringify (editorComponent .debugYjsData (), null , ' ' ))
787- }
788-
789- console .warn (' %c%s\n %c%s\n %s' , styleBold, intro, styleItalic, introChrome, introFirefox)
790- }
791- }
792- },
793-
794766 /**
795767 * Helper method to debug yjs issues
796768 */
797- debugYjsData () {
769+ debugData () {
798770 const yjsData = {
799771 fileId: this .fileId ,
800772 filePath: this .relativePath ,
801773 clientId: this .$ydoc .clientID ,
802774 pendingStructs: this .$ydoc .store .pendingStructs ,
803775 clientVectors: [],
804- documentState: this .$syncService .getDocumentState (),
776+ documentState: this .$syncService ? .getDocumentState (),
805777 }
806778 for (const client of this .$ydoc .store .clients .values ()) {
807779 yjsData .clientVectors .push (client .at (- 1 ).id )
0 commit comments