Skip to content

Commit

Permalink
Listen for REDO_EVENT from main process and issue redo command when r…
Browse files Browse the repository at this point in the history
…eceived (#292 #291)
  • Loading branch information
heyman authored Jan 6, 2025
1 parent ff980d2 commit 574dcfd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
syntaxTreeDebugContent: null,
editor: null,
onWindowClose: null,
onRedo: null,
}
},
Expand All @@ -61,7 +62,14 @@
])
}
this.onRedo = () => {
if (this.editor) {
toRaw(this.editor).redo()
}
}
window.heynote.mainProcess.on(WINDOW_CLOSE_EVENT, this.onWindowClose)
window.heynote.mainProcess.on(REDO_EVENT, this.onRedo)
window.document.addEventListener("currenciesLoaded", this.onCurrenciesLoaded)
// if debugSyntaxTree prop is set, display syntax tree for debugging
Expand All @@ -86,6 +94,7 @@
beforeUnmount() {
window.heynote.mainProcess.off(WINDOW_CLOSE_EVENT, this.onWindowClose)
window.heynote.mainProcess.off(REDO_EVENT, this.onRedo)
window.document.removeEventListener("currenciesLoaded", this.onCurrenciesLoaded)
},
Expand Down
5 changes: 5 additions & 0 deletions src/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EditorView, keymap, drawSelection, ViewPlugin, lineNumbers } from "@cod
import { indentUnit, forceParsing, foldGutter, ensureSyntaxTree } from "@codemirror/language"
import { markdown } from "@codemirror/lang-markdown"
import { closeBrackets } from "@codemirror/autocomplete";
import { redo } from "@codemirror/commands"

import { heynoteLight } from "./theme/light.js"
import { heynoteDark } from "./theme/dark.js"
Expand Down Expand Up @@ -364,6 +365,10 @@ export class HeynoteEditor {
this.view.dom.style.setProperty("display", "")
triggerCursorChange(this.view)
}

redo() {
redo(this.view)
}
}


Expand Down

0 comments on commit 574dcfd

Please sign in to comment.