@pixerate/editor-react 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +5 -4
  2. package/dist/canvas/index.cjs +329 -84
  3. package/dist/canvas/index.cjs.map +1 -1
  4. package/dist/canvas/index.d.cts +82 -4
  5. package/dist/canvas/index.d.ts +82 -4
  6. package/dist/canvas/index.js +266 -18
  7. package/dist/canvas/index.js.map +1 -1
  8. package/dist/chunk-4ZC2WCUO.js +196 -0
  9. package/dist/chunk-4ZC2WCUO.js.map +1 -0
  10. package/dist/{chunk-TL27COKM.js → chunk-LPFZMZ3L.js} +45 -2
  11. package/dist/chunk-LPFZMZ3L.js.map +1 -0
  12. package/dist/{chunk-MHTAR3RS.js → chunk-QVQYYHJ5.js} +87 -29
  13. package/dist/chunk-QVQYYHJ5.js.map +1 -0
  14. package/dist/commands/index.cjs +232 -0
  15. package/dist/commands/index.cjs.map +1 -0
  16. package/dist/commands/index.d.cts +69 -0
  17. package/dist/commands/index.d.ts +69 -0
  18. package/dist/commands/index.js +13 -0
  19. package/dist/commands/index.js.map +1 -0
  20. package/dist/image-editor/index.cjs +41 -0
  21. package/dist/image-editor/index.cjs.map +1 -1
  22. package/dist/image-editor/index.d.cts +2 -0
  23. package/dist/image-editor/index.d.ts +2 -0
  24. package/dist/image-editor/index.js +1 -1
  25. package/dist/index.cjs +624 -268
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.cts +57 -9
  28. package/dist/index.d.ts +57 -9
  29. package/dist/index.js +147 -71
  30. package/dist/index.js.map +1 -1
  31. package/dist/spreadsheet/index.cjs +79 -22
  32. package/dist/spreadsheet/index.cjs.map +1 -1
  33. package/dist/spreadsheet/index.d.cts +2 -3
  34. package/dist/spreadsheet/index.d.ts +2 -3
  35. package/dist/spreadsheet/index.js +1 -1
  36. package/package.json +10 -2
  37. package/dist/chunk-MHTAR3RS.js.map +0 -1
  38. package/dist/chunk-TL27COKM.js.map +0 -1
package/dist/index.d.cts CHANGED
@@ -1,15 +1,18 @@
1
1
  import * as _tiptap_core from '@tiptap/core';
2
2
  import { Editor } from '@tiptap/core';
3
- import { Template, ColorGradient, FileImportOptions, RichTextPresetOptions, RichClipboardOptions, HistoryState, HistoryManager, Command, HistoryManagerOptions, FileImportState, FileImportController, FileImportControllerOptions, PromptValues, OutlineSnapshot, OutlineHeading, EditorSlotsMap, CommentStoreSnapshot, CommentStore, TrackChangesSnapshot, TrackedChange, ReviewAuthor } from '@pixerate/editor';
4
- export { ColorGradient, Command, DirtyTracker, DirtyTrackerOptions, HistoryManager, HistoryManagerOptions, HistoryState, OutlineHeading, OutlineSnapshot, OutlineTreeItem, PromptDiagnostic, PromptValues, RichTextPresetOptions, Template, TemplateVersion, Token, TokenType, VariableFormField, createDirtyTracker, createHistoryManager, defaultIsEqual } from '@pixerate/editor';
3
+ import { Template, ColorGradient, FileImportOptions, RichTextPresetOptions, RichClipboardOptions, HistoryState, HistoryManager, HistoryEntry, Command, MergedExecutionOptions, HistoryMark, HistoryManagerOptions, DirtyTrackerOptions, DirtyTracker, FileImportState, FileImportController, FileImportControllerOptions, PromptValues, OutlineSnapshot, OutlineHeading, EditorSlotsMap, CommentStoreSnapshot, CommentStore, TrackChangesSnapshot, TrackedChange, ReviewAuthor } from '@pixerate/editor';
4
+ export { BindDirtyToHistoryOptions, ColorGradient, Command, DirtyTracker, DirtyTrackerOptions, HistoryDirtyBinding, HistoryEntry, HistoryManager, HistoryManagerOptions, HistoryMark, HistoryState, MergedExecutionOptions, OutlineHeading, OutlineSnapshot, OutlineTreeItem, PromptDiagnostic, PromptValues, RichTextPresetOptions, Template, TemplateVersion, Token, TokenType, VariableFormField, bindDirtyToHistory, createDirtyTracker, createHistoryManager, defaultIsEqual, withoutDirty } from '@pixerate/editor';
5
5
  import { UseEditorOptions, EditorContentProps as EditorContentProps$1 } from '@tiptap/react';
6
+ import { HistoryManager as HistoryManager$1 } from '@pixerate/editor/history';
6
7
  import { ToolRegistry, AgentToolProvider } from '@pixerate/editor/agent';
7
8
  import React__default from 'react';
8
9
  import { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
9
10
  export { FormulaHints, FormulaHintsProps, SpreadsheetContextMenu, SpreadsheetContextMenuProps, SpreadsheetEditor, SpreadsheetEditorProps, SpreadsheetGroupRow, SpreadsheetGroupRowProps, useFillHandle, useSpreadsheetClipboard, useSpreadsheetEditor } from './spreadsheet/index.cjs';
10
11
  export { ImageEditor, ImageEditorProps, UseImageEditorReturn, useImageEditor } from './image-editor/index.cjs';
12
+ export { CommandPalette, CommandPaletteProps, UseCommandPaletteOptions, UseCommandPaletteResult, UseCommandShortcutsOptions, useCommandPalette, useCommandShortcuts, useRegisterCommands } from './commands/index.cjs';
11
13
  import '@pixerate/editor/spreadsheet';
12
14
  import '@pixerate/editor/image-editor';
15
+ import '@pixerate/editor/commands';
13
16
 
14
17
  interface UsePromptEditorProps {
15
18
  /**
@@ -144,14 +147,23 @@ declare function useDismissGuard({ isDirty, enabled, onDismiss, }: UseDismissGua
144
147
 
145
148
  interface UseHistoryResult extends HistoryState {
146
149
  manager: HistoryManager;
150
+ /** History panel rows (undo steps, then redo steps). */
151
+ entries: HistoryEntry[];
147
152
  undo: () => boolean;
148
153
  redo: () => boolean;
149
154
  clear: () => void;
150
155
  execute: (command: Command) => void;
151
- executeMerged: (command: Command, options?: {
152
- windowMs?: number;
153
- }) => void;
156
+ executeMerged: (command: Command, options?: MergedExecutionOptions) => void;
154
157
  batch: (name: string, fn: () => void) => void;
158
+ /** Undoes / redoes until the entry at `index` is current (`-1` = before all). */
159
+ goTo: (index: number) => number;
160
+ /** Captures the current point, e.g. when a drag starts. */
161
+ mark: () => HistoryMark;
162
+ /** Takes back every step since `mark` without leaving redo (Escape-cancel). */
163
+ revertTo: (mark: HistoryMark) => number;
164
+ /** Joins every merged execute into one step until `endGesture`. */
165
+ beginGesture: (key: string) => void;
166
+ endGesture: () => void;
155
167
  }
156
168
  /**
157
169
  * React hook that subscribes to a HistoryManager instance.
@@ -160,6 +172,33 @@ interface UseHistoryResult extends HistoryState {
160
172
  */
161
173
  declare function useHistory(managerOrOptions?: HistoryManager | HistoryManagerOptions): UseHistoryResult;
162
174
 
175
+ interface UseHistoryDirtyOptions<T> extends DirtyTrackerOptions<T> {
176
+ /** The history whose changes re-check the document. */
177
+ history: HistoryManager;
178
+ /** Reads the current document value (the latest function is always used). */
179
+ getValue: () => T;
180
+ /** Existing tracker to drive (read on first render only). */
181
+ tracker?: DirtyTracker<T>;
182
+ }
183
+ interface UseHistoryDirtyResult<T> {
184
+ /** Whether the document differs from the saved state. Feed it to `useNavigationGuard`. */
185
+ isDirty: boolean;
186
+ /** Marks the current document as saved. */
187
+ markClean: () => void;
188
+ /** Runs a load / restore without marking the document dirty (re-entrant). */
189
+ suppress: <R>(fn: () => R) => R;
190
+ /** Re-checks after a change made outside the history. */
191
+ refresh: () => boolean;
192
+ tracker: DirtyTracker<T>;
193
+ }
194
+ /**
195
+ * Dirty-vs-saved tracking bound to a HistoryManager: undoing back to the saved
196
+ * state makes the document clean again, selection/viewport changes can be
197
+ * ignored with `normalize`, and programmatic loads can be wrapped in `suppress`.
198
+ * Options other than `getValue` and `history` are read on first render only.
199
+ */
200
+ declare function useHistoryDirty<T>(options: UseHistoryDirtyOptions<T>): UseHistoryDirtyResult<T>;
201
+
163
202
  interface HistoryShortcutsOptions {
164
203
  /**
165
204
  * Whether the keyboard shortcuts are enabled. Defaults to true.
@@ -179,7 +218,7 @@ interface HistoryShortcutsOptions {
179
218
  * Attaches keyboard listeners for Undo (Mod+Z) and Redo (Mod+Shift+Z / Mod+Y).
180
219
  * Automatically guards against active text inputs and contenteditable editors.
181
220
  */
182
- declare function useHistoryShortcuts(manager: HistoryManager, options?: HistoryShortcutsOptions): void;
221
+ declare function useHistoryShortcuts(manager: HistoryManager$1, options?: HistoryShortcutsOptions): void;
183
222
 
184
223
  interface UseFileImportResult extends FileImportState {
185
224
  /** Value for `<input type="file" accept={…}>`. */
@@ -370,10 +409,19 @@ declare const CommentsPanel: React__default.FC<CommentsPanelProps>;
370
409
  interface ReviewToolbarProps {
371
410
  editor: Editor | null;
372
411
  className?: string;
412
+ /**
413
+ * Show the current change's author and description (e.g. "Alice: Formatted:
414
+ * Bold"). Defaults to `true`.
415
+ */
416
+ showDescription?: boolean;
417
+ /** Class of the description label. */
418
+ descriptionClassName?: string;
373
419
  }
374
420
  /**
375
- * Toolbar for tracked changes: toggle tracking, step through changes, and
376
- * accept or reject the current change or all changes.
421
+ * Toolbar for tracked changes: toggle tracking, step through changes
422
+ * (insertions, deletions, formatting and block changes, with a description
423
+ * of the current one), and accept or reject the current change or all
424
+ * changes.
377
425
  */
378
426
  declare const ReviewToolbar: React__default.FC<ReviewToolbarProps>;
379
427
 
@@ -388,4 +436,4 @@ interface CommentButtonProps {
388
436
  */
389
437
  declare const CommentButton: React__default.FC<CommentButtonProps>;
390
438
 
391
- export { BubbleMenu, type BubbleMenuProps, CommentButton, type CommentButtonProps, CommentsPanel, type CommentsPanelProps, EditorContent, type EditorContentProps, EditorSlotsProvider, type EditorSlotsProviderProps, type HistoryShortcutsOptions, OutlinePanel, type OutlinePanelProps, ReviewToolbar, type ReviewToolbarProps, TemplateRenderer, type TemplateRendererProps, type UseCommentsResult, type UseDismissGuardOptions, type UseDismissGuardReturn, type UseFileImportResult, type UseHistoryResult, type UseNavigationGuardOptions, type UseNavigationGuardReturn, type UsePromptEditorProps, type UseRichEditorProps, type UseTrackChangesResult, VariableForm, type VariableFormProps, useAgentToolProvider, useComments, useDismissGuard, useEditor, useEditorSlots, useFileImport, useHistory, useHistoryShortcuts, useNavigationGuard, useOutline, usePromptEditor, useTrackChanges };
439
+ export { BubbleMenu, type BubbleMenuProps, CommentButton, type CommentButtonProps, CommentsPanel, type CommentsPanelProps, EditorContent, type EditorContentProps, EditorSlotsProvider, type EditorSlotsProviderProps, type HistoryShortcutsOptions, OutlinePanel, type OutlinePanelProps, ReviewToolbar, type ReviewToolbarProps, TemplateRenderer, type TemplateRendererProps, type UseCommentsResult, type UseDismissGuardOptions, type UseDismissGuardReturn, type UseFileImportResult, type UseHistoryDirtyOptions, type UseHistoryDirtyResult, type UseHistoryResult, type UseNavigationGuardOptions, type UseNavigationGuardReturn, type UsePromptEditorProps, type UseRichEditorProps, type UseTrackChangesResult, VariableForm, type VariableFormProps, useAgentToolProvider, useComments, useDismissGuard, useEditor, useEditorSlots, useFileImport, useHistory, useHistoryDirty, useHistoryShortcuts, useNavigationGuard, useOutline, usePromptEditor, useTrackChanges };
package/dist/index.d.ts CHANGED
@@ -1,15 +1,18 @@
1
1
  import * as _tiptap_core from '@tiptap/core';
2
2
  import { Editor } from '@tiptap/core';
3
- import { Template, ColorGradient, FileImportOptions, RichTextPresetOptions, RichClipboardOptions, HistoryState, HistoryManager, Command, HistoryManagerOptions, FileImportState, FileImportController, FileImportControllerOptions, PromptValues, OutlineSnapshot, OutlineHeading, EditorSlotsMap, CommentStoreSnapshot, CommentStore, TrackChangesSnapshot, TrackedChange, ReviewAuthor } from '@pixerate/editor';
4
- export { ColorGradient, Command, DirtyTracker, DirtyTrackerOptions, HistoryManager, HistoryManagerOptions, HistoryState, OutlineHeading, OutlineSnapshot, OutlineTreeItem, PromptDiagnostic, PromptValues, RichTextPresetOptions, Template, TemplateVersion, Token, TokenType, VariableFormField, createDirtyTracker, createHistoryManager, defaultIsEqual } from '@pixerate/editor';
3
+ import { Template, ColorGradient, FileImportOptions, RichTextPresetOptions, RichClipboardOptions, HistoryState, HistoryManager, HistoryEntry, Command, MergedExecutionOptions, HistoryMark, HistoryManagerOptions, DirtyTrackerOptions, DirtyTracker, FileImportState, FileImportController, FileImportControllerOptions, PromptValues, OutlineSnapshot, OutlineHeading, EditorSlotsMap, CommentStoreSnapshot, CommentStore, TrackChangesSnapshot, TrackedChange, ReviewAuthor } from '@pixerate/editor';
4
+ export { BindDirtyToHistoryOptions, ColorGradient, Command, DirtyTracker, DirtyTrackerOptions, HistoryDirtyBinding, HistoryEntry, HistoryManager, HistoryManagerOptions, HistoryMark, HistoryState, MergedExecutionOptions, OutlineHeading, OutlineSnapshot, OutlineTreeItem, PromptDiagnostic, PromptValues, RichTextPresetOptions, Template, TemplateVersion, Token, TokenType, VariableFormField, bindDirtyToHistory, createDirtyTracker, createHistoryManager, defaultIsEqual, withoutDirty } from '@pixerate/editor';
5
5
  import { UseEditorOptions, EditorContentProps as EditorContentProps$1 } from '@tiptap/react';
6
+ import { HistoryManager as HistoryManager$1 } from '@pixerate/editor/history';
6
7
  import { ToolRegistry, AgentToolProvider } from '@pixerate/editor/agent';
7
8
  import React__default from 'react';
8
9
  import { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
9
10
  export { FormulaHints, FormulaHintsProps, SpreadsheetContextMenu, SpreadsheetContextMenuProps, SpreadsheetEditor, SpreadsheetEditorProps, SpreadsheetGroupRow, SpreadsheetGroupRowProps, useFillHandle, useSpreadsheetClipboard, useSpreadsheetEditor } from './spreadsheet/index.js';
10
11
  export { ImageEditor, ImageEditorProps, UseImageEditorReturn, useImageEditor } from './image-editor/index.js';
12
+ export { CommandPalette, CommandPaletteProps, UseCommandPaletteOptions, UseCommandPaletteResult, UseCommandShortcutsOptions, useCommandPalette, useCommandShortcuts, useRegisterCommands } from './commands/index.js';
11
13
  import '@pixerate/editor/spreadsheet';
12
14
  import '@pixerate/editor/image-editor';
15
+ import '@pixerate/editor/commands';
13
16
 
14
17
  interface UsePromptEditorProps {
15
18
  /**
@@ -144,14 +147,23 @@ declare function useDismissGuard({ isDirty, enabled, onDismiss, }: UseDismissGua
144
147
 
145
148
  interface UseHistoryResult extends HistoryState {
146
149
  manager: HistoryManager;
150
+ /** History panel rows (undo steps, then redo steps). */
151
+ entries: HistoryEntry[];
147
152
  undo: () => boolean;
148
153
  redo: () => boolean;
149
154
  clear: () => void;
150
155
  execute: (command: Command) => void;
151
- executeMerged: (command: Command, options?: {
152
- windowMs?: number;
153
- }) => void;
156
+ executeMerged: (command: Command, options?: MergedExecutionOptions) => void;
154
157
  batch: (name: string, fn: () => void) => void;
158
+ /** Undoes / redoes until the entry at `index` is current (`-1` = before all). */
159
+ goTo: (index: number) => number;
160
+ /** Captures the current point, e.g. when a drag starts. */
161
+ mark: () => HistoryMark;
162
+ /** Takes back every step since `mark` without leaving redo (Escape-cancel). */
163
+ revertTo: (mark: HistoryMark) => number;
164
+ /** Joins every merged execute into one step until `endGesture`. */
165
+ beginGesture: (key: string) => void;
166
+ endGesture: () => void;
155
167
  }
156
168
  /**
157
169
  * React hook that subscribes to a HistoryManager instance.
@@ -160,6 +172,33 @@ interface UseHistoryResult extends HistoryState {
160
172
  */
161
173
  declare function useHistory(managerOrOptions?: HistoryManager | HistoryManagerOptions): UseHistoryResult;
162
174
 
175
+ interface UseHistoryDirtyOptions<T> extends DirtyTrackerOptions<T> {
176
+ /** The history whose changes re-check the document. */
177
+ history: HistoryManager;
178
+ /** Reads the current document value (the latest function is always used). */
179
+ getValue: () => T;
180
+ /** Existing tracker to drive (read on first render only). */
181
+ tracker?: DirtyTracker<T>;
182
+ }
183
+ interface UseHistoryDirtyResult<T> {
184
+ /** Whether the document differs from the saved state. Feed it to `useNavigationGuard`. */
185
+ isDirty: boolean;
186
+ /** Marks the current document as saved. */
187
+ markClean: () => void;
188
+ /** Runs a load / restore without marking the document dirty (re-entrant). */
189
+ suppress: <R>(fn: () => R) => R;
190
+ /** Re-checks after a change made outside the history. */
191
+ refresh: () => boolean;
192
+ tracker: DirtyTracker<T>;
193
+ }
194
+ /**
195
+ * Dirty-vs-saved tracking bound to a HistoryManager: undoing back to the saved
196
+ * state makes the document clean again, selection/viewport changes can be
197
+ * ignored with `normalize`, and programmatic loads can be wrapped in `suppress`.
198
+ * Options other than `getValue` and `history` are read on first render only.
199
+ */
200
+ declare function useHistoryDirty<T>(options: UseHistoryDirtyOptions<T>): UseHistoryDirtyResult<T>;
201
+
163
202
  interface HistoryShortcutsOptions {
164
203
  /**
165
204
  * Whether the keyboard shortcuts are enabled. Defaults to true.
@@ -179,7 +218,7 @@ interface HistoryShortcutsOptions {
179
218
  * Attaches keyboard listeners for Undo (Mod+Z) and Redo (Mod+Shift+Z / Mod+Y).
180
219
  * Automatically guards against active text inputs and contenteditable editors.
181
220
  */
182
- declare function useHistoryShortcuts(manager: HistoryManager, options?: HistoryShortcutsOptions): void;
221
+ declare function useHistoryShortcuts(manager: HistoryManager$1, options?: HistoryShortcutsOptions): void;
183
222
 
184
223
  interface UseFileImportResult extends FileImportState {
185
224
  /** Value for `<input type="file" accept={…}>`. */
@@ -370,10 +409,19 @@ declare const CommentsPanel: React__default.FC<CommentsPanelProps>;
370
409
  interface ReviewToolbarProps {
371
410
  editor: Editor | null;
372
411
  className?: string;
412
+ /**
413
+ * Show the current change's author and description (e.g. "Alice: Formatted:
414
+ * Bold"). Defaults to `true`.
415
+ */
416
+ showDescription?: boolean;
417
+ /** Class of the description label. */
418
+ descriptionClassName?: string;
373
419
  }
374
420
  /**
375
- * Toolbar for tracked changes: toggle tracking, step through changes, and
376
- * accept or reject the current change or all changes.
421
+ * Toolbar for tracked changes: toggle tracking, step through changes
422
+ * (insertions, deletions, formatting and block changes, with a description
423
+ * of the current one), and accept or reject the current change or all
424
+ * changes.
377
425
  */
378
426
  declare const ReviewToolbar: React__default.FC<ReviewToolbarProps>;
379
427
 
@@ -388,4 +436,4 @@ interface CommentButtonProps {
388
436
  */
389
437
  declare const CommentButton: React__default.FC<CommentButtonProps>;
390
438
 
391
- export { BubbleMenu, type BubbleMenuProps, CommentButton, type CommentButtonProps, CommentsPanel, type CommentsPanelProps, EditorContent, type EditorContentProps, EditorSlotsProvider, type EditorSlotsProviderProps, type HistoryShortcutsOptions, OutlinePanel, type OutlinePanelProps, ReviewToolbar, type ReviewToolbarProps, TemplateRenderer, type TemplateRendererProps, type UseCommentsResult, type UseDismissGuardOptions, type UseDismissGuardReturn, type UseFileImportResult, type UseHistoryResult, type UseNavigationGuardOptions, type UseNavigationGuardReturn, type UsePromptEditorProps, type UseRichEditorProps, type UseTrackChangesResult, VariableForm, type VariableFormProps, useAgentToolProvider, useComments, useDismissGuard, useEditor, useEditorSlots, useFileImport, useHistory, useHistoryShortcuts, useNavigationGuard, useOutline, usePromptEditor, useTrackChanges };
439
+ export { BubbleMenu, type BubbleMenuProps, CommentButton, type CommentButtonProps, CommentsPanel, type CommentsPanelProps, EditorContent, type EditorContentProps, EditorSlotsProvider, type EditorSlotsProviderProps, type HistoryShortcutsOptions, OutlinePanel, type OutlinePanelProps, ReviewToolbar, type ReviewToolbarProps, TemplateRenderer, type TemplateRendererProps, type UseCommentsResult, type UseDismissGuardOptions, type UseDismissGuardReturn, type UseFileImportResult, type UseHistoryDirtyOptions, type UseHistoryDirtyResult, type UseHistoryResult, type UseNavigationGuardOptions, type UseNavigationGuardReturn, type UsePromptEditorProps, type UseRichEditorProps, type UseTrackChangesResult, VariableForm, type VariableFormProps, useAgentToolProvider, useComments, useDismissGuard, useEditor, useEditorSlots, useFileImport, useHistory, useHistoryDirty, useHistoryShortcuts, useNavigationGuard, useOutline, usePromptEditor, useTrackChanges };