Skip to content

Commit 40b4250

Browse files
codebykatmokagio
authored andcommitted
Cherry-pick changes react-monaco-editor from #3201
Author: Gio Lodi <[email protected]> Date: Fri May 31 13:41:40 2024 +1000 Co-authored-by: Kat Hagan <[email protected]>
1 parent 2bf1dd6 commit 40b4250

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

lib/note-content-editor.tsx

+13-17
Original file line numberDiff line numberDiff line change
@@ -186,23 +186,6 @@ class NoteContentEditor extends Component<Props> {
186186

187187
componentDidMount() {
188188
const { noteId } = this.props;
189-
this.bootTimer = setTimeout(() => {
190-
if (noteId === this.props.noteId) {
191-
this.setState({
192-
editor: 'full',
193-
content: withCheckboxCharacters(this.props.note.content),
194-
});
195-
const position = getNotePosition(noteId);
196-
if (position) {
197-
this.editor?.setScrollPosition({
198-
scrollTop: position,
199-
});
200-
}
201-
}
202-
}, SPEED_DELAY);
203-
this.focusEditor();
204-
this.props.storeFocusEditor(this.focusEditor);
205-
this.props.storeHasFocus(this.hasFocus);
206189
window.addEventListener('resize', clearNotePositions);
207190
window.addEventListener('toggleChecklist', this.handleChecklist, true);
208191
this.toggleShortcuts(true);
@@ -613,6 +596,19 @@ class NoteContentEditor extends Component<Props> {
613596
editorReady: EditorDidMount = (editor, monaco) => {
614597
this.editor = editor;
615598

599+
this.focusEditor();
600+
this.props.storeFocusEditor(this.focusEditor);
601+
this.props.storeHasFocus(this.hasFocus);
602+
603+
this.bootTimer = setTimeout(() => {
604+
const position = getNotePosition(this.props.noteId);
605+
if (position) {
606+
this.editor?.setScrollPosition({
607+
scrollTop: position,
608+
});
609+
}
610+
}, SPEED_DELAY);
611+
616612
monaco.languages.registerLinkProvider('plaintext', {
617613
provideLinks: (model) => {
618614
const matches = model.findMatches(

package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
"react-dom": "17.0.2",
148148
"react-dropzone": "11.7.1",
149149
"react-modal": "3.16.1",
150-
"react-monaco-editor": "0.50.1",
150+
"react-monaco-editor": "0.55.0",
151151
"react-overlays": "5.2.1",
152152
"react-redux": "8.1.3",
153153
"react-sortable-hoc": "2.0.0",

0 commit comments

Comments
 (0)