From eb1e2d6970211d543644ea7dd4e4c90dc7199150 Mon Sep 17 00:00:00 2001 From: Caio Pizzol Date: Fri, 21 Nov 2025 14:43:11 -0300 Subject: [PATCH] feat: add getSuperDoc method for accessing SuperDoc API --- src/index.tsx | 3 ++- src/types.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/index.tsx b/src/index.tsx index 5a5c79a..b951089 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -414,7 +414,7 @@ const SuperDocTemplateBuilder = forwardRef< if (!editor) return; const currentPos = editor.state.selection.from; const tr = editor.state.tr.delete(triggerStart, currentPos); - editor.view.dispatch(tr); + (editor as any).view.dispatch(tr); }; triggerCleanupRef.current = cleanup; @@ -628,6 +628,7 @@ const SuperDocTemplateBuilder = forwardRef< previousField, getFields: () => templateFields, exportTemplate, + getSuperDoc: () => superdocRef.current, })); // Components diff --git a/src/types.ts b/src/types.ts index d457a52..cab16ad 100644 --- a/src/types.ts +++ b/src/types.ts @@ -135,4 +135,14 @@ export interface SuperDocTemplateBuilderHandle { previousField: () => void; getFields: () => TemplateField[]; exportTemplate: (config?: ExportConfig) => Promise; + /** + * Returns the SuperDoc instance. + * Use this to access the full SuperDoc API, including: + * - The active editor: `getSuperDoc()?.activeEditor` + * - Editor commands: `getSuperDoc()?.activeEditor?.commands.*` + * - Editor state and helpers: `getSuperDoc()?.activeEditor?.state` + * + * Note: Full TypeScript types for SuperDoc will be available in a future update. + */ + getSuperDoc: () => SuperDoc | null; }