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; }