-
Notifications
You must be signed in to change notification settings - Fork 93
SD-2261 - fix(types): expand definitions and exports to pass compilation #2463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
98f33d3
756b12c
3860e18
93d952a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,7 +77,20 @@ export type Command = (props: CommandProps) => boolean; | |
| * Chainable command object returned by editor.chain() | ||
| */ | ||
| export interface ChainableCommandObject { | ||
| run: () => boolean; | ||
| /** Execute the chained commands */ | ||
| run(): boolean; | ||
| /** Chain any command - returns self for further chaining */ | ||
| toggleBold(): ChainableCommandObject; | ||
| toggleItalic(): ChainableCommandObject; | ||
| toggleUnderline(): ChainableCommandObject; | ||
| toggleStrike(): ChainableCommandObject; | ||
| setFontSize(size: string | number): ChainableCommandObject; | ||
| setFontFamily(family: string): ChainableCommandObject; | ||
| setTextColor(color: string): ChainableCommandObject; | ||
| setTextAlign(alignment: 'left' | 'center' | 'right' | 'justify'): ChainableCommandObject; | ||
| insertContent(content: any): ChainableCommandObject; | ||
| focus(position?: 'start' | 'end' | 'all' | number | boolean | null): ChainableCommandObject; | ||
| /** Allow any other command */ | ||
| [commandName: string]: ((...args: any[]) => ChainableCommandObject) | (() => boolean); | ||
| } | ||
|
|
||
|
|
@@ -199,6 +212,67 @@ export interface OpenOptions { | |
| fonts?: Record<string, unknown>; | ||
| } | ||
|
|
||
| // ============================================ | ||
| // COMMENT TYPES | ||
| // ============================================ | ||
|
|
||
| /** A comment element (paragraph, text run, etc.) */ | ||
| export interface CommentElement { | ||
| type: string; | ||
| content?: CommentElement[]; | ||
| text?: string; | ||
| } | ||
|
|
||
| /** A comment in the document */ | ||
| export interface Comment { | ||
| /** Unique comment identifier */ | ||
| commentId: string; | ||
| /** Timestamp when comment was created */ | ||
| createdTime: number; | ||
| /** Email of the comment author */ | ||
| creatorEmail: string; | ||
| /** Display name of the comment author */ | ||
| creatorName: string; | ||
| /** Comment content elements */ | ||
| elements: CommentElement[]; | ||
| /** Original ID from imported document */ | ||
| importedId?: string; | ||
| /** Whether the comment is resolved */ | ||
| isDone: boolean; | ||
| /** Parent comment ID for replies */ | ||
| parentCommentId?: string; | ||
| /** Raw JSON representation */ | ||
| commentJSON?: unknown; | ||
| } | ||
|
|
||
| /** Event data for comments loaded event */ | ||
| export interface CommentsLoadedEventData { | ||
| comments: Comment[]; | ||
| } | ||
|
|
||
| /** Event data for content error event */ | ||
| export interface ContentErrorEventData { | ||
| error: Error; | ||
| } | ||
|
|
||
| /** Font configuration */ | ||
| export interface FontConfig { | ||
| key: string; | ||
| label: string; | ||
| fontWeight?: number; | ||
| props?: { | ||
| style?: { | ||
| fontFamily?: string; | ||
| }; | ||
| }; | ||
| } | ||
|
|
||
| /** Font support information */ | ||
| export interface FontSupportInfo { | ||
| documentFonts: string[]; | ||
| unsupportedFonts: string[]; | ||
| } | ||
|
|
||
| // ============================================ | ||
| // PRESENTATION EDITOR TYPES | ||
| // ============================================ | ||
|
|
@@ -586,6 +660,131 @@ export declare class Editor { | |
| */ | ||
| isEmpty: boolean; | ||
|
|
||
| // ============================================ | ||
| // EVENT METHODS | ||
| // ============================================ | ||
|
|
||
| /** | ||
| * Register an event listener. | ||
| * @param event - Event name ('update', 'create', 'transaction', etc.) | ||
| * @param handler - Event handler function | ||
| */ | ||
| on(event: string, handler: (...args: any[]) => void): void; | ||
|
|
||
| /** | ||
| * Remove an event listener. | ||
| * @param event - Event name | ||
| * @param handler - Event handler function to remove | ||
| */ | ||
| off(event: string, handler: (...args: any[]) => void): void; | ||
|
|
||
| /** | ||
| * Emit an event. | ||
| * @param event - Event name | ||
| * @param args - Arguments to pass to handlers | ||
| */ | ||
| emit(event: string, ...args: any[]): void; | ||
|
|
||
| // ============================================ | ||
| // DOCUMENT EXPORT METHODS | ||
| // ============================================ | ||
|
|
||
| /** | ||
| * Export the document to DOCX format. | ||
| * @param options - Export options | ||
| * @returns Promise resolving to Blob (browser) or Buffer (Node.js) | ||
| */ | ||
| exportDocx(options?: { | ||
| isFinalDoc?: boolean; | ||
| commentsType?: string; | ||
| comments?: Comment[]; | ||
| fieldsHighlightColor?: string | null; | ||
| compression?: 'DEFLATE' | 'STORE'; | ||
| }): Promise<Blob | ArrayBuffer>; | ||
|
|
||
| /** | ||
| * Export the document (alias for exportDocx). | ||
| */ | ||
| exportDocument(options?: { | ||
| isFinalDoc?: boolean; | ||
| commentsType?: string; | ||
| comments?: Comment[]; | ||
| }): Promise<Blob | ArrayBuffer>; | ||
|
|
||
| /** | ||
| * Save the document to the original source path (Node.js only). | ||
| */ | ||
| save(options?: { isFinalDoc?: boolean; commentsType?: string; comments?: Comment[] }): Promise<void>; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
|
|
||
| /** | ||
| * Save the document to a specific path (Node.js only). | ||
| */ | ||
| saveTo( | ||
| path: string, | ||
| options?: { | ||
| isFinalDoc?: boolean; | ||
| commentsType?: string; | ||
| comments?: Comment[]; | ||
| }, | ||
| ): Promise<void>; | ||
|
|
||
| // ============================================ | ||
| // TOOLBAR & UI METHODS | ||
| // ============================================ | ||
|
|
||
| /** | ||
| * Set the toolbar for this editor. | ||
| */ | ||
| setToolbar(toolbar: any): void; | ||
|
|
||
| /** | ||
| * Set whether the editor is editable. | ||
| */ | ||
| setEditable(editable: boolean, emitUpdate?: boolean): void; | ||
|
|
||
| /** | ||
| * Set the document mode. | ||
| */ | ||
| setDocumentMode(mode: 'editing' | 'viewing' | 'suggesting'): void; | ||
|
|
||
| /** | ||
| * Focus the editor. | ||
| */ | ||
| focus(): void; | ||
|
|
||
| /** | ||
| * Blur the editor. | ||
| */ | ||
| blur(): void; | ||
|
|
||
| // ============================================ | ||
| // DOCUMENT METHODS | ||
| // ============================================ | ||
|
|
||
| /** | ||
| * Open a document. | ||
| */ | ||
| open(source?: string | File | Blob | BinaryData, options?: OpenOptions): Promise<void>; | ||
|
|
||
| /** | ||
| * Close the current document. | ||
| */ | ||
| close(): void; | ||
|
|
||
| /** | ||
| * Replace the current file. | ||
| */ | ||
| replaceFile(newFile: File | Blob | BinaryData): Promise<void>; | ||
|
|
||
| /** | ||
| * Get the document as Markdown. | ||
| */ | ||
| getMarkdown(): Promise<string>; | ||
|
|
||
| /** | ||
| * Check if the editor is currently active/focused. | ||
| */ | ||
| isFocused: boolean; | ||
| // --- Tracked selection handle API --- | ||
|
|
||
| /** Capture the live PM selection as a tracked handle. Local-only. */ | ||
|
|
@@ -997,8 +1196,15 @@ export declare class PresentationEditor { | |
| */ | ||
| emit(event: string, ...args: any[]): void; | ||
|
|
||
| /** Allow additional properties */ | ||
| [key: string]: any; | ||
| /** | ||
| * Replace the current file. | ||
| */ | ||
| replaceFile(newFile: File | Blob | BinaryData): Promise<void>; | ||
|
|
||
|
Comment on lines
+1112
to
+1113
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The public Useful? React with 👍 / 👎. |
||
| /** | ||
| * Set the toolbar for the editor. | ||
| */ | ||
| setToolbar(toolbar: any): void; | ||
| } | ||
|
|
||
| // ============================================ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "name": "consumer-typecheck", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "superdoc": "file:../../packages/superdoc/superdoc.tgz" | ||
| }, | ||
| "devDependencies": { | ||
| "typescript": "^5.0.0" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For headless/Node consumers,
Editor.exportDocument()still resolves to aBuffer(Editor.tsreturnsPromise<Blob | Buffer>, and the Node export tests assertBuffer.isBuffer(exported)). Narrowing the declaration toBlob | ArrayBufferbreaks the commonfs.writeFile(await editor.exportDocument())flow at compile time even though runtime behavior is unchanged;exportDocx()immediately above has the same regression.Useful? React with 👍 / 👎.