Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
type Editor = NonNullable<SuperDoc["activeEditor"]>;

const getTemplateFieldsFromEditor = (editor: Editor): Types.TemplateField[] => {
const structuredContentHelpers = (editor.helpers as any)

Check warning on line 19 in src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
?.structuredContentCommands;

if (!structuredContentHelpers?.getStructuredContentTags) {
Expand All @@ -26,7 +26,7 @@
const tags =
structuredContentHelpers.getStructuredContentTags(editor.state) || [];

return tags.map((entry: any) => {

Check warning on line 29 in src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
const node = entry?.node ?? entry;
const attrs = node?.attrs ?? {};
const nodeType = node?.type?.name || "";
Expand Down Expand Up @@ -167,7 +167,7 @@

const trigger = menu.trigger || "{{"; // Default trigger

const availableFields = fieldsRef.current.available || [];

Check warning on line 170 in src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

The 'availableFields' logical expression could make the dependencies of useCallback Hook (at line 183) change on every render. Move it inside the useCallback callback. Alternatively, wrap the initialization of 'availableFields' in its own useMemo() Hook

const computeFilteredFields = useCallback(
(query: string) => {
Expand Down Expand Up @@ -395,7 +395,7 @@
const editor = instance.activeEditor;

// Setup trigger detection
editor.on("update", ({ editor: e }: any) => {

Check warning on line 398 in src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
const { state } = e;
const { from } = state.selection;

Expand All @@ -414,7 +414,7 @@
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);

Check warning on line 417 in src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
};

triggerCleanupRef.current = cleanup;
Expand Down Expand Up @@ -509,7 +509,7 @@

superdocRef.current = null;
};
}, [

Check warning on line 512 in src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

React Hook useEffect has missing dependencies: 'resetMenuFilter', 'toolbarSettings', and 'updateMenuFilter'. Either include them or remove the dependency array
document?.source,
document?.mode,
trigger,
Expand Down Expand Up @@ -628,6 +628,7 @@
previousField,
getFields: () => templateFields,
exportTemplate,
getSuperDoc: () => superdocRef.current,
}));

// Components
Expand Down
10 changes: 10 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,14 @@ export interface SuperDocTemplateBuilderHandle {
previousField: () => void;
getFields: () => TemplateField[];
exportTemplate: (config?: ExportConfig) => Promise<void | Blob>;
/**
* 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;
}
Loading