mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 03:58:12 +08:00
Break out helper functions from the frontend's managers and stores (#3920)
* Move destructor call to each manager/store constructor for safety * Break out utility functions
This commit is contained in:
@@ -3,6 +3,8 @@ import type { Editor } from "@graphite/editor";
|
||||
let editorRef: Editor | undefined = undefined;
|
||||
|
||||
export function createHyperlinkManager(editor: Editor) {
|
||||
destroyHyperlinkManager();
|
||||
|
||||
editorRef = editor;
|
||||
|
||||
editor.subscriptions.subscribeFrontendMessage("TriggerVisitLink", async (data) => {
|
||||
@@ -19,6 +21,5 @@ export function destroyHyperlinkManager() {
|
||||
|
||||
// Self-accepting HMR: tear down the old instance and re-create with the new module's code
|
||||
import.meta.hot?.accept((newModule) => {
|
||||
destroyHyperlinkManager();
|
||||
if (editorRef) newModule?.createHyperlinkManager(editorRef);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user