1
0
mirror of https://github.com/heyman/heynote.git synced 2025-03-08 20:11:38 +01:00

Listen for REDO_EVENT from main process and issue redo command when received ( )

This commit is contained in:
Jonatan Heyman 2025-01-06 16:29:12 +01:00 committed by GitHub
parent ff980d240e
commit 574dcfdc24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 0 deletions
src
components
editor

View File

@ -48,6 +48,7 @@
syntaxTreeDebugContent: null,
editor: null,
onWindowClose: null,
onRedo: null,
}
},
@ -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
@ -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)
},

View File

@ -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"
@ -364,6 +365,10 @@ export class HeynoteEditor {
this.view.dom.style.setProperty("display", "")
triggerCursorChange(this.view)
}
redo() {
redo(this.view)
}
}