Skip to content
This repository was archived by the owner on Jan 30, 2026. It is now read-only.

Commit ccda4e0

Browse files
authored
feat: add getSuperDoc method for accessing SuperDoc API (#18)
1 parent dc17f23 commit ccda4e0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ const SuperDocTemplateBuilder = forwardRef<
414414
if (!editor) return;
415415
const currentPos = editor.state.selection.from;
416416
const tr = editor.state.tr.delete(triggerStart, currentPos);
417-
editor.view.dispatch(tr);
417+
(editor as any).view.dispatch(tr);
418418
};
419419

420420
triggerCleanupRef.current = cleanup;
@@ -628,6 +628,7 @@ const SuperDocTemplateBuilder = forwardRef<
628628
previousField,
629629
getFields: () => templateFields,
630630
exportTemplate,
631+
getSuperDoc: () => superdocRef.current,
631632
}));
632633

633634
// Components

src/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,14 @@ export interface SuperDocTemplateBuilderHandle {
135135
previousField: () => void;
136136
getFields: () => TemplateField[];
137137
exportTemplate: (config?: ExportConfig) => Promise<void | Blob>;
138+
/**
139+
* Returns the SuperDoc instance.
140+
* Use this to access the full SuperDoc API, including:
141+
* - The active editor: `getSuperDoc()?.activeEditor`
142+
* - Editor commands: `getSuperDoc()?.activeEditor?.commands.*`
143+
* - Editor state and helpers: `getSuperDoc()?.activeEditor?.state`
144+
*
145+
* Note: Full TypeScript types for SuperDoc will be available in a future update.
146+
*/
147+
getSuperDoc: () => SuperDoc | null;
138148
}

0 commit comments

Comments
 (0)