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
1 change: 1 addition & 0 deletions packages/superdoc/src/core/types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
* @property {string} [markdown] Markdown content to initialize the editor with
* @property {boolean} [isDebug=false] Whether to enable debug mode
* @property {ViewOptions} [viewOptions] Document view options (OOXML ST_View compatible)
* @property {string} [cspNonce] Content Security Policy nonce for dynamically injected styles
*/

export {};
4 changes: 3 additions & 1 deletion packages/template-builder/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
type Editor = NonNullable<SuperDoc['activeEditor']>;

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

Check warning on line 12 in packages/template-builder/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type

if (!structuredContentHelpers?.getStructuredContentTags) {
return [];
Expand All @@ -17,7 +17,7 @@

const tags = structuredContentHelpers.getStructuredContentTags(editor.state) || [];

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

Check warning on line 20 in packages/template-builder/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 @@ -112,6 +112,7 @@
menu = {},
list = {},
toolbar,
cspNonce,
onReady,
onTrigger,
onFieldInsert,
Expand Down Expand Up @@ -391,7 +392,7 @@
if (instance?.activeEditor) {
const editor = instance.activeEditor;

editor.on('update', ({ editor: e }: any) => {

Check warning on line 395 in packages/template-builder/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 @@ -408,7 +409,7 @@
if (!editor) return;
const currentPos = editor.state.selection.from;
const tr = editor.state.tr.delete(triggerStart, currentPos);
(editor as any).view.dispatch(tr);

Check warning on line 412 in packages/template-builder/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 @@ -468,6 +469,7 @@
documentMode: document?.mode || 'editing',
modules,
toolbar: toolbarSettings?.selector,
cspNonce,
onReady: handleReady,
});

Expand All @@ -489,7 +491,7 @@

superdocRef.current = null;
};
}, [document?.source, document?.mode, trigger, discoverFields, onReady, onTrigger, toolbarSettings]);
}, [document?.source, document?.mode, trigger, discoverFields, onReady, onTrigger, toolbarSettings, cspNonce]);

const handleMenuSelect = useCallback(
async (field: Types.FieldDefinition) => {
Expand Down Expand Up @@ -539,7 +541,7 @@
const editor = superdocRef.current?.activeEditor;
if (!editor) return;

const structuredContentHelpers = (editor.helpers as any)?.structuredContentCommands;

Check warning on line 544 in packages/template-builder/src/index.tsx

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type

if (!structuredContentHelpers) return;

Expand Down
3 changes: 3 additions & 0 deletions packages/template-builder/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
id: string;
label: string;
defaultValue?: string;
metadata?: Record<string, any>;

Check warning on line 7 in packages/template-builder/src/types.ts

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
mode?: 'inline' | 'block';
group?: string;
}
Expand Down Expand Up @@ -82,7 +82,7 @@
responsiveToContainer?: boolean;
excludeItems?: string[];
texts?: Record<string, string>;
icons?: Record<string, any>;

Check warning on line 85 in packages/template-builder/src/types.ts

View workflow job for this annotation

GitHub Actions / validate

Unexpected any. Specify a different type
}

/**
Expand Down Expand Up @@ -110,6 +110,9 @@
list?: ListConfig;
toolbar?: boolean | string | ToolbarConfig;

/** Content Security Policy nonce for dynamically injected styles */
cspNonce?: string;

// Events
onReady?: () => void;
onTrigger?: (event: TriggerEvent) => void;
Expand Down
Loading