mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-17 23:38:06 +08:00
* Remove the unused Editor.raw/wasmMemory/wasmImport * Split out Editor.subscriptions * Replace editor.handle.* with editor.* (1 of 2) * Replace editor.handle.* with editor.* (2 of 2) * Replace Editor typedef with EditorHandle import * Pluralize subscription-router and rename subscriptionsRef->subscriptionsRouter and editorRef->editorHandle * Remove editor.ts * Update the readme * Fix demo art loading bug
26 lines
822 B
TypeScript
26 lines
822 B
TypeScript
import type { SubscriptionsRouter } from "/src/subscriptions-router";
|
|
|
|
let subscriptionsRouter: SubscriptionsRouter | undefined = undefined;
|
|
|
|
export function createHyperlinkManager(subscriptions: SubscriptionsRouter) {
|
|
destroyHyperlinkManager();
|
|
|
|
subscriptionsRouter = subscriptions;
|
|
|
|
subscriptions.subscribeFrontendMessage("TriggerVisitLink", async (data) => {
|
|
window.open(data.url, "_blank", "noopener");
|
|
});
|
|
}
|
|
|
|
export function destroyHyperlinkManager() {
|
|
const subscriptions = subscriptionsRouter;
|
|
if (!subscriptions) return;
|
|
|
|
subscriptions.unsubscribeFrontendMessage("TriggerVisitLink");
|
|
}
|
|
|
|
// Self-accepting HMR: tear down the old instance and re-create with the new module's code
|
|
import.meta.hot?.accept((newModule) => {
|
|
if (subscriptionsRouter) newModule?.createHyperlinkManager(subscriptionsRouter);
|
|
});
|