feat: 收口 mindmap Phase 6 Leptos UI shell
This commit is contained in:
@@ -39,8 +39,21 @@ type IslandRuntimeModule = {
|
||||
default: (input?: RequestInfo | URL | Response | BufferSource | WebAssembly.Module) => Promise<unknown>;
|
||||
mount: (container: Element, options: unknown) => number;
|
||||
unmount: (mountId: number) => void;
|
||||
mount_mindmap_shell?: (container: Element, options: unknown) => number;
|
||||
unmount_mindmap_shell?: (mountId: number) => void;
|
||||
};
|
||||
|
||||
type MindmapRustShellBridge = {
|
||||
mount: (container: Element, options: unknown) => number;
|
||||
unmount: (mountId: number) => void;
|
||||
};
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
__MNOTE_MINDMAP_RUST_SHELL__?: MindmapRustShellBridge;
|
||||
}
|
||||
}
|
||||
|
||||
type RuntimeEnvelope<T = unknown> = {
|
||||
protocol?: string;
|
||||
runtime?: string;
|
||||
@@ -251,6 +264,15 @@ async function loadIslandRuntime(): Promise<{
|
||||
throw new Error("island entry 缺少 unmount 导出");
|
||||
}
|
||||
await runtimeModule.default(wasmAssetUrl ?? undefined);
|
||||
if (
|
||||
typeof runtimeModule.mount_mindmap_shell === "function" &&
|
||||
typeof runtimeModule.unmount_mindmap_shell === "function"
|
||||
) {
|
||||
window.__MNOTE_MINDMAP_RUST_SHELL__ = {
|
||||
mount: runtimeModule.mount_mindmap_shell,
|
||||
unmount: runtimeModule.unmount_mindmap_shell,
|
||||
};
|
||||
}
|
||||
return {
|
||||
runtimeModule,
|
||||
entryAssetUrl,
|
||||
@@ -778,9 +800,6 @@ export function LeptosTiptapIslandEditorHost(props: DocumentEditorHostProps) {
|
||||
);
|
||||
}
|
||||
},
|
||||
requestFallbackToBlockNote: () => {
|
||||
requestFallback("explicit_fallback", "通过页面壳显式切回 BlockNote");
|
||||
},
|
||||
};
|
||||
useEditorBridgeStore.getState().registerBridge(editorBridge);
|
||||
return () => {
|
||||
|
||||
Reference in New Issue
Block a user