From 35000e507ff4de8e17484045569c1910e6889409 Mon Sep 17 00:00:00 2001 From: Kat Hagan Date: Wed, 8 May 2024 01:07:45 -0400 Subject: [PATCH 1/2] trying to fix different order hooks from react-monaco-editor --- lib/note-content-editor.tsx | 44 +++++++++++++++++++++++-------------- package-lock.json | 14 ++++++------ package.json | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/lib/note-content-editor.tsx b/lib/note-content-editor.tsx index 7f3b320ad..2d2402c5a 100644 --- a/lib/note-content-editor.tsx +++ b/lib/note-content-editor.tsx @@ -186,23 +186,20 @@ class NoteContentEditor extends Component { componentDidMount() { const { noteId } = this.props; - this.bootTimer = setTimeout(() => { - if (noteId === this.props.noteId) { - this.setState({ - editor: 'full', - content: withCheckboxCharacters(this.props.note.content), - }); - const position = getNotePosition(noteId); - if (position) { - this.editor?.setScrollPosition({ - scrollTop: position, - }); - } - } - }, SPEED_DELAY); - this.focusEditor(); - this.props.storeFocusEditor(this.focusEditor); - this.props.storeHasFocus(this.hasFocus); + // this.bootTimer = setTimeout(() => { + // if (noteId === this.props.noteId) { + // this.setState({ + // editor: 'full', + // content: withCheckboxCharacters(this.props.note.content), + // }); + // const position = getNotePosition(noteId); + // if (position) { + // this.editor?.setScrollPosition({ + // scrollTop: position, + // }); + // } + // } + // }, SPEED_DELAY); window.addEventListener('resize', clearNotePositions); window.addEventListener('toggleChecklist', this.handleChecklist, true); this.toggleShortcuts(true); @@ -613,6 +610,19 @@ class NoteContentEditor extends Component { editorReady: EditorDidMount = (editor, monaco) => { this.editor = editor; + this.focusEditor(); + this.props.storeFocusEditor(this.focusEditor); + this.props.storeHasFocus(this.hasFocus); + + this.bootTimer = setTimeout(() => { + const position = getNotePosition(this.props.noteId); + if (position) { + this.editor?.setScrollPosition({ + scrollTop: position, + }); + } + }, SPEED_DELAY); + monaco.languages.registerLinkProvider('plaintext', { provideLinks: (model) => { const matches = model.findMatches( diff --git a/package-lock.json b/package-lock.json index f7242d4c6..810286e0e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,7 +46,7 @@ "react-dom": "17.0.2", "react-dropzone": "11.7.1", "react-modal": "3.16.1", - "react-monaco-editor": "0.50.1", + "react-monaco-editor": "0.55.0", "react-overlays": "5.2.1", "react-redux": "8.1.3", "react-sortable-hoc": "2.0.0", @@ -16872,16 +16872,16 @@ } }, "node_modules/react-monaco-editor": { - "version": "0.50.1", - "resolved": "https://registry.npmjs.org/react-monaco-editor/-/react-monaco-editor-0.50.1.tgz", - "integrity": "sha512-qvYdJhQdkPIrPDMxCrEl0T2x9TfBB+aUbrpFv69FwoTybeyfAjxgJ219MYSsgn3c/g06BgyLX4ENrXM4niZ9ag==", + "version": "0.55.0", + "resolved": "https://registry.npmjs.org/react-monaco-editor/-/react-monaco-editor-0.55.0.tgz", + "integrity": "sha512-GdEP0Q3Rn1dczfKEEyY08Nes5plWwIYU4sWRBQO0+jsQWQsKMHKCC6+hPRwR7G/4aA3V/iU9jSmWPzVJYMVFSQ==", "dependencies": { "prop-types": "^15.8.1" }, "peerDependencies": { - "@types/react": ">=17 <= 18", - "monaco-editor": "^0.34.0", - "react": ">=17 <= 18" + "@types/react": ">=16 <= 18", + "monaco-editor": "^0.44.0", + "react": ">=16 <= 18" } }, "node_modules/react-onclickoutside": { diff --git a/package.json b/package.json index 0e046f2cf..616345cb6 100644 --- a/package.json +++ b/package.json @@ -147,7 +147,7 @@ "react-dom": "17.0.2", "react-dropzone": "11.7.1", "react-modal": "3.16.1", - "react-monaco-editor": "0.50.1", + "react-monaco-editor": "0.55.0", "react-overlays": "5.2.1", "react-redux": "8.1.3", "react-sortable-hoc": "2.0.0", From ba52601e9652d420ad948b113b7eda7b1f756571 Mon Sep 17 00:00:00 2001 From: Kat Hagan Date: Wed, 22 May 2024 17:28:25 -0400 Subject: [PATCH 2/2] remove commented code --- lib/note-content-editor.tsx | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/lib/note-content-editor.tsx b/lib/note-content-editor.tsx index 2d2402c5a..7ef3dd341 100644 --- a/lib/note-content-editor.tsx +++ b/lib/note-content-editor.tsx @@ -186,20 +186,6 @@ class NoteContentEditor extends Component { componentDidMount() { const { noteId } = this.props; - // this.bootTimer = setTimeout(() => { - // if (noteId === this.props.noteId) { - // this.setState({ - // editor: 'full', - // content: withCheckboxCharacters(this.props.note.content), - // }); - // const position = getNotePosition(noteId); - // if (position) { - // this.editor?.setScrollPosition({ - // scrollTop: position, - // }); - // } - // } - // }, SPEED_DELAY); window.addEventListener('resize', clearNotePositions); window.addEventListener('toggleChecklist', this.handleChecklist, true); this.toggleShortcuts(true); @@ -615,12 +601,12 @@ class NoteContentEditor extends Component { this.props.storeHasFocus(this.hasFocus); this.bootTimer = setTimeout(() => { - const position = getNotePosition(this.props.noteId); - if (position) { - this.editor?.setScrollPosition({ - scrollTop: position, - }); - } + const position = getNotePosition(this.props.noteId); + if (position) { + this.editor?.setScrollPosition({ + scrollTop: position, + }); + } }, SPEED_DELAY); monaco.languages.registerLinkProvider('plaintext', {