@productcloudos/editor 1.0.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 (166) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/LICENSE +21 -0
  3. package/README.md +377 -0
  4. package/dist/pc-editor.esm.js +24820 -0
  5. package/dist/pc-editor.esm.js.map +1 -0
  6. package/dist/pc-editor.js +24877 -0
  7. package/dist/pc-editor.js.map +1 -0
  8. package/dist/pc-editor.min.js +2 -0
  9. package/dist/pc-editor.min.js.map +1 -0
  10. package/dist/types/lib/clipboard/ClipboardManager.d.ts +77 -0
  11. package/dist/types/lib/clipboard/ClipboardManager.d.ts.map +1 -0
  12. package/dist/types/lib/clipboard/HtmlConverter.d.ts +43 -0
  13. package/dist/types/lib/clipboard/HtmlConverter.d.ts.map +1 -0
  14. package/dist/types/lib/clipboard/index.d.ts +9 -0
  15. package/dist/types/lib/clipboard/index.d.ts.map +1 -0
  16. package/dist/types/lib/clipboard/types.d.ts +76 -0
  17. package/dist/types/lib/clipboard/types.d.ts.map +1 -0
  18. package/dist/types/lib/controls/BaseControl.d.ts +72 -0
  19. package/dist/types/lib/controls/BaseControl.d.ts.map +1 -0
  20. package/dist/types/lib/controls/index.d.ts +11 -0
  21. package/dist/types/lib/controls/index.d.ts.map +1 -0
  22. package/dist/types/lib/controls/rulers/HorizontalRuler.d.ts +55 -0
  23. package/dist/types/lib/controls/rulers/HorizontalRuler.d.ts.map +1 -0
  24. package/dist/types/lib/controls/rulers/RulerControl.d.ts +98 -0
  25. package/dist/types/lib/controls/rulers/RulerControl.d.ts.map +1 -0
  26. package/dist/types/lib/controls/rulers/VerticalRuler.d.ts +65 -0
  27. package/dist/types/lib/controls/rulers/VerticalRuler.d.ts.map +1 -0
  28. package/dist/types/lib/controls/rulers/index.d.ts +8 -0
  29. package/dist/types/lib/controls/rulers/index.d.ts.map +1 -0
  30. package/dist/types/lib/controls/rulers/types.d.ts +62 -0
  31. package/dist/types/lib/controls/rulers/types.d.ts.map +1 -0
  32. package/dist/types/lib/controls/types.d.ts +51 -0
  33. package/dist/types/lib/controls/types.d.ts.map +1 -0
  34. package/dist/types/lib/core/Document.d.ts +34 -0
  35. package/dist/types/lib/core/Document.d.ts.map +1 -0
  36. package/dist/types/lib/core/PCEditor.d.ts +761 -0
  37. package/dist/types/lib/core/PCEditor.d.ts.map +1 -0
  38. package/dist/types/lib/core/Page.d.ts +40 -0
  39. package/dist/types/lib/core/Page.d.ts.map +1 -0
  40. package/dist/types/lib/data/DataBinder.d.ts +11 -0
  41. package/dist/types/lib/data/DataBinder.d.ts.map +1 -0
  42. package/dist/types/lib/events/EventEmitter.d.ts +11 -0
  43. package/dist/types/lib/events/EventEmitter.d.ts.map +1 -0
  44. package/dist/types/lib/hit-test/HitTestManager.d.ts +81 -0
  45. package/dist/types/lib/hit-test/HitTestManager.d.ts.map +1 -0
  46. package/dist/types/lib/hit-test/index.d.ts +32 -0
  47. package/dist/types/lib/hit-test/index.d.ts.map +1 -0
  48. package/dist/types/lib/hit-test/types.d.ts +113 -0
  49. package/dist/types/lib/hit-test/types.d.ts.map +1 -0
  50. package/dist/types/lib/import/ContentAnalyzer.d.ts +76 -0
  51. package/dist/types/lib/import/ContentAnalyzer.d.ts.map +1 -0
  52. package/dist/types/lib/import/DocumentBuilder.d.ts +44 -0
  53. package/dist/types/lib/import/DocumentBuilder.d.ts.map +1 -0
  54. package/dist/types/lib/import/PDFImporter.d.ts +65 -0
  55. package/dist/types/lib/import/PDFImporter.d.ts.map +1 -0
  56. package/dist/types/lib/import/PDFParser.d.ts +46 -0
  57. package/dist/types/lib/import/PDFParser.d.ts.map +1 -0
  58. package/dist/types/lib/import/index.d.ts +9 -0
  59. package/dist/types/lib/import/index.d.ts.map +1 -0
  60. package/dist/types/lib/import/types.d.ts +182 -0
  61. package/dist/types/lib/import/types.d.ts.map +1 -0
  62. package/dist/types/lib/index.d.ts +16 -0
  63. package/dist/types/lib/index.d.ts.map +1 -0
  64. package/dist/types/lib/layout/FlowManager.d.ts +29 -0
  65. package/dist/types/lib/layout/FlowManager.d.ts.map +1 -0
  66. package/dist/types/lib/layout/LayoutEngine.d.ts +39 -0
  67. package/dist/types/lib/layout/LayoutEngine.d.ts.map +1 -0
  68. package/dist/types/lib/objects/BaseEmbeddedObject.d.ts +133 -0
  69. package/dist/types/lib/objects/BaseEmbeddedObject.d.ts.map +1 -0
  70. package/dist/types/lib/objects/EmbeddedObjectFactory.d.ts +57 -0
  71. package/dist/types/lib/objects/EmbeddedObjectFactory.d.ts.map +1 -0
  72. package/dist/types/lib/objects/ImageObject.d.ts +60 -0
  73. package/dist/types/lib/objects/ImageObject.d.ts.map +1 -0
  74. package/dist/types/lib/objects/TextBoxObject.d.ts +208 -0
  75. package/dist/types/lib/objects/TextBoxObject.d.ts.map +1 -0
  76. package/dist/types/lib/objects/index.d.ts +9 -0
  77. package/dist/types/lib/objects/index.d.ts.map +1 -0
  78. package/dist/types/lib/objects/table/TableCell.d.ts +165 -0
  79. package/dist/types/lib/objects/table/TableCell.d.ts.map +1 -0
  80. package/dist/types/lib/objects/table/TableCellMerger.d.ts +66 -0
  81. package/dist/types/lib/objects/table/TableCellMerger.d.ts.map +1 -0
  82. package/dist/types/lib/objects/table/TableObject.d.ts +434 -0
  83. package/dist/types/lib/objects/table/TableObject.d.ts.map +1 -0
  84. package/dist/types/lib/objects/table/TableResizeHandler.d.ts +80 -0
  85. package/dist/types/lib/objects/table/TableResizeHandler.d.ts.map +1 -0
  86. package/dist/types/lib/objects/table/TableRow.d.ts +65 -0
  87. package/dist/types/lib/objects/table/TableRow.d.ts.map +1 -0
  88. package/dist/types/lib/objects/table/index.d.ts +12 -0
  89. package/dist/types/lib/objects/table/index.d.ts.map +1 -0
  90. package/dist/types/lib/objects/table/types.d.ts +239 -0
  91. package/dist/types/lib/objects/table/types.d.ts.map +1 -0
  92. package/dist/types/lib/objects/types.d.ts +135 -0
  93. package/dist/types/lib/objects/types.d.ts.map +1 -0
  94. package/dist/types/lib/rendering/CanvasManager.d.ts +282 -0
  95. package/dist/types/lib/rendering/CanvasManager.d.ts.map +1 -0
  96. package/dist/types/lib/rendering/FlowingTextRenderer.d.ts +348 -0
  97. package/dist/types/lib/rendering/FlowingTextRenderer.d.ts.map +1 -0
  98. package/dist/types/lib/rendering/PDFGenerator.d.ts +103 -0
  99. package/dist/types/lib/rendering/PDFGenerator.d.ts.map +1 -0
  100. package/dist/types/lib/rendering/pdf-utils.d.ts +54 -0
  101. package/dist/types/lib/rendering/pdf-utils.d.ts.map +1 -0
  102. package/dist/types/lib/text/EditableTextRegion.d.ts +105 -0
  103. package/dist/types/lib/text/EditableTextRegion.d.ts.map +1 -0
  104. package/dist/types/lib/text/EmbeddedObjectManager.d.ts +97 -0
  105. package/dist/types/lib/text/EmbeddedObjectManager.d.ts.map +1 -0
  106. package/dist/types/lib/text/FieldFormatter.d.ts +26 -0
  107. package/dist/types/lib/text/FieldFormatter.d.ts.map +1 -0
  108. package/dist/types/lib/text/FlowingTextContent.d.ts +571 -0
  109. package/dist/types/lib/text/FlowingTextContent.d.ts.map +1 -0
  110. package/dist/types/lib/text/HyperlinkManager.d.ts +110 -0
  111. package/dist/types/lib/text/HyperlinkManager.d.ts.map +1 -0
  112. package/dist/types/lib/text/MarkdownParser.d.ts +55 -0
  113. package/dist/types/lib/text/MarkdownParser.d.ts.map +1 -0
  114. package/dist/types/lib/text/ParagraphFormatting.d.ts +123 -0
  115. package/dist/types/lib/text/ParagraphFormatting.d.ts.map +1 -0
  116. package/dist/types/lib/text/RegionManager.d.ts +75 -0
  117. package/dist/types/lib/text/RegionManager.d.ts.map +1 -0
  118. package/dist/types/lib/text/RepeatingSectionManager.d.ts +99 -0
  119. package/dist/types/lib/text/RepeatingSectionManager.d.ts.map +1 -0
  120. package/dist/types/lib/text/SubstitutionFieldManager.d.ts +153 -0
  121. package/dist/types/lib/text/SubstitutionFieldManager.d.ts.map +1 -0
  122. package/dist/types/lib/text/TextFormatting.d.ts +85 -0
  123. package/dist/types/lib/text/TextFormatting.d.ts.map +1 -0
  124. package/dist/types/lib/text/TextLayout.d.ts +126 -0
  125. package/dist/types/lib/text/TextLayout.d.ts.map +1 -0
  126. package/dist/types/lib/text/TextMeasurer.d.ts +107 -0
  127. package/dist/types/lib/text/TextMeasurer.d.ts.map +1 -0
  128. package/dist/types/lib/text/TextPositionCalculator.d.ts +72 -0
  129. package/dist/types/lib/text/TextPositionCalculator.d.ts.map +1 -0
  130. package/dist/types/lib/text/TextState.d.ts +236 -0
  131. package/dist/types/lib/text/TextState.d.ts.map +1 -0
  132. package/dist/types/lib/text/index.d.ts +27 -0
  133. package/dist/types/lib/text/index.d.ts.map +1 -0
  134. package/dist/types/lib/text/regions/BodyTextRegion.d.ts +68 -0
  135. package/dist/types/lib/text/regions/BodyTextRegion.d.ts.map +1 -0
  136. package/dist/types/lib/text/regions/FooterTextRegion.d.ts +68 -0
  137. package/dist/types/lib/text/regions/FooterTextRegion.d.ts.map +1 -0
  138. package/dist/types/lib/text/regions/HeaderTextRegion.d.ts +68 -0
  139. package/dist/types/lib/text/regions/HeaderTextRegion.d.ts.map +1 -0
  140. package/dist/types/lib/text/regions/index.d.ts +7 -0
  141. package/dist/types/lib/text/regions/index.d.ts.map +1 -0
  142. package/dist/types/lib/text/types.d.ts +268 -0
  143. package/dist/types/lib/text/types.d.ts.map +1 -0
  144. package/dist/types/lib/types/index.d.ts +206 -0
  145. package/dist/types/lib/types/index.d.ts.map +1 -0
  146. package/dist/types/lib/undo/index.d.ts +8 -0
  147. package/dist/types/lib/undo/index.d.ts.map +1 -0
  148. package/dist/types/lib/undo/transaction/ContentDiscovery.d.ts +101 -0
  149. package/dist/types/lib/undo/transaction/ContentDiscovery.d.ts.map +1 -0
  150. package/dist/types/lib/undo/transaction/FocusTracker.d.ts +49 -0
  151. package/dist/types/lib/undo/transaction/FocusTracker.d.ts.map +1 -0
  152. package/dist/types/lib/undo/transaction/MutationUndo.d.ts +57 -0
  153. package/dist/types/lib/undo/transaction/MutationUndo.d.ts.map +1 -0
  154. package/dist/types/lib/undo/transaction/ObjectMutationObserver.d.ts +79 -0
  155. package/dist/types/lib/undo/transaction/ObjectMutationObserver.d.ts.map +1 -0
  156. package/dist/types/lib/undo/transaction/TextMutationObserver.d.ts +60 -0
  157. package/dist/types/lib/undo/transaction/TextMutationObserver.d.ts.map +1 -0
  158. package/dist/types/lib/undo/transaction/TransactionManager.d.ts +148 -0
  159. package/dist/types/lib/undo/transaction/TransactionManager.d.ts.map +1 -0
  160. package/dist/types/lib/undo/transaction/index.d.ts +17 -0
  161. package/dist/types/lib/undo/transaction/index.d.ts.map +1 -0
  162. package/dist/types/lib/undo/transaction/types.d.ts +269 -0
  163. package/dist/types/lib/undo/transaction/types.d.ts.map +1 -0
  164. package/dist/types/lib/utils/blob-utils.d.ts +2 -0
  165. package/dist/types/lib/utils/blob-utils.d.ts.map +1 -0
  166. package/package.json +88 -0
@@ -0,0 +1,761 @@
1
+ import { EditorOptions, DocumentData, DataBindingContext, PDFExportOptions, EditorSelection, EditingSection } from '../types';
2
+ import { EventEmitter } from '../events/EventEmitter';
3
+ import { BaseEmbeddedObject, ObjectPosition, TextBoxObject, TableObject, ImageObject, TableRowConfig } from '../objects';
4
+ import { SubstitutionFieldConfig, TextFormattingStyle, SubstitutionField, RepeatingSection, FlowingTextContent, TextAlignment } from '../text';
5
+ import { PDFImportProgress, PDFImportResult } from '../import';
6
+ import { PDFImportOptions } from '../import/types';
7
+ export declare class PCEditor extends EventEmitter {
8
+ private container;
9
+ private options;
10
+ private document;
11
+ private canvasManager;
12
+ private dataBinder;
13
+ private pdfGenerator;
14
+ private layoutEngine;
15
+ private transactionManager;
16
+ private textMutationObserver;
17
+ private objectMutationObserver;
18
+ private _contentDiscovery;
19
+ private mutationUndo;
20
+ private _isReady;
21
+ private keyboardListenerActive;
22
+ private currentSelection;
23
+ private _activeEditingSection;
24
+ private _wasTextEditing;
25
+ private _textEditingSource;
26
+ private clipboardManager;
27
+ constructor(container: HTMLElement, options?: EditorOptions);
28
+ private mergeOptions;
29
+ private initialize;
30
+ private setupContainer;
31
+ private setupEventListeners;
32
+ /**
33
+ * Get the FlowingTextContent for a specific section.
34
+ */
35
+ private getFlowingContentForSection;
36
+ /**
37
+ * Set up the new transaction-based undo system.
38
+ */
39
+ private setupTransactionUndo;
40
+ /**
41
+ * Find an embedded object by ID across all content sources.
42
+ */
43
+ private findObjectById;
44
+ /**
45
+ * Observe all embedded objects for undo/redo tracking.
46
+ */
47
+ private observeAllEmbeddedObjects;
48
+ /**
49
+ * Observe a single embedded object for undo/redo tracking.
50
+ */
51
+ private observeEmbeddedObject;
52
+ get isReady(): boolean;
53
+ /**
54
+ * Get the current selection state.
55
+ * Returns a union type indicating text selection, element selection, or no selection.
56
+ */
57
+ getSelection(): EditorSelection;
58
+ /**
59
+ * Get the text selection directly from the active FlowingTextContent.
60
+ * This is a more direct query than getSelection() which relies on event tracking.
61
+ * Returns null if no text is selected.
62
+ */
63
+ getTextSelection(): {
64
+ start: number;
65
+ end: number;
66
+ } | null;
67
+ /**
68
+ * Get the currently active editing section (header, body, or footer).
69
+ */
70
+ getActiveSection(): EditingSection;
71
+ /**
72
+ * Set the active editing section.
73
+ * This changes which section receives keyboard input and cursor positioning.
74
+ */
75
+ setActiveSection(section: EditingSection): void;
76
+ /**
77
+ * Get the FlowingTextContent for the currently active section.
78
+ */
79
+ private getActiveFlowingContent;
80
+ /**
81
+ * Emit the unified selection-change event.
82
+ */
83
+ private emitSelectionChange;
84
+ /**
85
+ * Emit a cursor changed event for the focused table cell.
86
+ */
87
+ private emitTableCellCursorChanged;
88
+ /**
89
+ * Get the current text editing source type.
90
+ * Returns null if no text is being edited.
91
+ */
92
+ private getTextEditingSource;
93
+ /**
94
+ * Check if text editing state changed and emit appropriate events.
95
+ */
96
+ private checkAndEmitTextEditingEvents;
97
+ loadDocument(documentData: DocumentData): void;
98
+ getDocument(): DocumentData;
99
+ bindData(data: DataBindingContext): void;
100
+ exportPDF(options?: PDFExportOptions): Promise<Blob>;
101
+ /**
102
+ * Save the current document state to a JSON string.
103
+ * @returns JSON string representation of the document
104
+ */
105
+ saveDocument(): string;
106
+ /**
107
+ * Save the current document state to a downloadable file.
108
+ * @param filename Optional filename (defaults to 'document.pceditor.json')
109
+ */
110
+ saveDocumentToFile(filename?: string): void;
111
+ /**
112
+ * Load a document from a JSON string.
113
+ * @param jsonString JSON string representation of the document
114
+ */
115
+ loadDocumentFromJSON(jsonString: string): void;
116
+ /**
117
+ * Load a document from a File object.
118
+ * @param file File object to load
119
+ * @returns Promise that resolves when loading is complete
120
+ */
121
+ loadDocumentFromFile(file: File): Promise<void>;
122
+ /**
123
+ * Import a PDF document and load it into the editor.
124
+ * @param source - PDF file as File, ArrayBuffer, or URL string
125
+ * @param options - Import options
126
+ * @param onProgress - Optional progress callback
127
+ * @returns Promise with import result including warnings and metadata
128
+ */
129
+ importPDF(source: File | ArrayBuffer | string, options?: PDFImportOptions, onProgress?: (progress: PDFImportProgress) => void): Promise<PDFImportResult>;
130
+ /**
131
+ * Validate document data structure before loading.
132
+ * @throws Error if validation fails
133
+ */
134
+ private validateDocumentData;
135
+ selectElement(elementId: string): void;
136
+ clearSelection(): void;
137
+ removeEmbeddedObject(objectId: string): void;
138
+ /**
139
+ * Undo the last operation.
140
+ */
141
+ undo(): void;
142
+ /**
143
+ * Redo the last undone operation.
144
+ */
145
+ redo(): void;
146
+ /**
147
+ * Check if undo is available.
148
+ */
149
+ canUndo(): boolean;
150
+ /**
151
+ * Check if redo is available.
152
+ */
153
+ canRedo(): boolean;
154
+ /**
155
+ * Clear undo/redo history.
156
+ */
157
+ clearUndoHistory(): void;
158
+ /**
159
+ * Set the maximum number of undo entries.
160
+ */
161
+ setMaxUndoHistory(count: number): void;
162
+ zoomIn(): void;
163
+ zoomOut(): void;
164
+ setZoom(level: number): void;
165
+ /**
166
+ * Get the current zoom level.
167
+ */
168
+ getZoomLevel(): number;
169
+ /**
170
+ * Get the container element for the editor.
171
+ */
172
+ getContainer(): HTMLElement;
173
+ /**
174
+ * Get the current scroll position of the editor viewport.
175
+ */
176
+ getScrollPosition(): {
177
+ x: number;
178
+ y: number;
179
+ };
180
+ /**
181
+ * Get the offset of the document content within the viewport.
182
+ * This is where the first page starts relative to the scroll viewport origin.
183
+ */
184
+ getContentOffset(): {
185
+ x: number;
186
+ y: number;
187
+ };
188
+ fitToWidth(): void;
189
+ /**
190
+ * Force a re-render of the canvas.
191
+ */
192
+ render(): void;
193
+ fitToPage(): void;
194
+ setAutoFlow(enabled: boolean): void;
195
+ reflowDocument(): void;
196
+ setSnapToGrid(enabled: boolean): void;
197
+ getDocumentMetrics(): {
198
+ pageWidth: number;
199
+ pageHeight: number;
200
+ margins: {
201
+ top: number;
202
+ right: number;
203
+ bottom: number;
204
+ left: number;
205
+ };
206
+ totalPages: number;
207
+ } | null;
208
+ addPage(): void;
209
+ removePage(pageId: string): void;
210
+ private setupKeyboardListeners;
211
+ private handleKeyDown;
212
+ /**
213
+ * Handle Escape key when there are selected elements (not in editing mode).
214
+ * Clears selection and returns cursor focus to the flowing text.
215
+ */
216
+ private handleEscapeForSelectedElements;
217
+ /**
218
+ * Find embedded object info by ID across all flowing content sources.
219
+ */
220
+ private findEmbeddedObjectInfo;
221
+ /**
222
+ * Find the parent FlowingTextContent for an embedded object and return focus to it.
223
+ */
224
+ private returnFocusToParentFlowingContent;
225
+ /**
226
+ * Handle vertical navigation for the focused control.
227
+ * This needs special handling because it requires layout context.
228
+ */
229
+ private handleVerticalNavigation;
230
+ enableTextInput(): void;
231
+ disableTextInput(): void;
232
+ /**
233
+ * Check if a text box is currently being edited.
234
+ */
235
+ isEditingTextBox(): boolean;
236
+ /**
237
+ * Check if any text content is being edited (body, header, footer, text box, or table cell).
238
+ * This is a unified check for determining if the formatting pane should be shown.
239
+ */
240
+ isTextEditing(): boolean;
241
+ private _savedEditingContext;
242
+ /**
243
+ * Get the FlowingTextContent currently being edited, regardless of context.
244
+ * Works for body text, text boxes, and table cells.
245
+ * Returns null if no text is being edited.
246
+ */
247
+ getEditingFlowingContent(): FlowingTextContent | null;
248
+ /**
249
+ * Save the current editing context (FlowingTextContent and selection).
250
+ * Call this before UI elements steal focus (e.g., dropdown opens).
251
+ */
252
+ saveEditingContext(): void;
253
+ /**
254
+ * Get the saved editing context selection, or the current selection if available.
255
+ */
256
+ getSavedOrCurrentSelection(): {
257
+ start: number;
258
+ end: number;
259
+ } | null;
260
+ /**
261
+ * Apply formatting using the saved context if current context is not available.
262
+ * This is useful when UI controls have stolen focus.
263
+ */
264
+ applyFormattingWithFallback(start: number, end: number, formatting: Partial<TextFormattingStyle>): void;
265
+ /**
266
+ * Set pending formatting to apply to the next inserted character.
267
+ * Used when formatting is applied with just a cursor (no selection).
268
+ */
269
+ setPendingFormatting(formatting: Partial<TextFormattingStyle>): void;
270
+ /**
271
+ * Get the current pending formatting, if any.
272
+ */
273
+ getPendingFormatting(): Partial<TextFormattingStyle> | null;
274
+ /**
275
+ * Check if there is pending formatting.
276
+ */
277
+ hasPendingFormatting(): boolean;
278
+ /**
279
+ * Clear pending formatting.
280
+ */
281
+ clearPendingFormatting(): void;
282
+ /**
283
+ * Clear the saved editing context.
284
+ */
285
+ clearSavedEditingContext(): void;
286
+ /**
287
+ * Get the currently editing text box, if any.
288
+ */
289
+ getEditingTextBox(): TextBoxObject | null;
290
+ /**
291
+ * Get the selection from the currently editing text box.
292
+ * Returns null if no text box is being edited or no selection.
293
+ */
294
+ getTextBoxSelection(): {
295
+ start: number;
296
+ end: number;
297
+ } | null;
298
+ /**
299
+ * Apply formatting to the selection in the currently editing text box.
300
+ */
301
+ applyTextBoxFormatting(start: number, end: number, formatting: Partial<TextFormattingStyle>): void;
302
+ /**
303
+ * Get the formatting at the cursor position in the editing text box.
304
+ */
305
+ getTextBoxFormattingAtCursor(): TextFormattingStyle | null;
306
+ /**
307
+ * Set the alignment for the current paragraph or selection in the editing text box.
308
+ * If there's a text selection, applies to all paragraphs in the selection.
309
+ * Otherwise applies to the paragraph at cursor.
310
+ */
311
+ setTextBoxAlignment(alignment: TextAlignment): void;
312
+ /**
313
+ * Get the alignment at the cursor position in the editing text box.
314
+ */
315
+ getTextBoxAlignmentAtCursor(): TextAlignment;
316
+ /**
317
+ * Get the formatting at the cursor position in whatever text is being edited.
318
+ * Works for body text, text boxes, and table cells.
319
+ * Considers pending formatting if present.
320
+ */
321
+ getUnifiedFormattingAtCursor(): TextFormattingStyle | null;
322
+ /**
323
+ * Apply formatting to the current selection in whatever text is being edited.
324
+ * Works for body text, text boxes, and table cells.
325
+ */
326
+ applyUnifiedFormatting(start: number, end: number, formatting: Partial<TextFormattingStyle>): void;
327
+ /**
328
+ * Get the selection from whatever text is being edited.
329
+ * Works for body text, text boxes, and table cells.
330
+ */
331
+ getUnifiedSelection(): {
332
+ start: number;
333
+ end: number;
334
+ } | null;
335
+ /**
336
+ * Get the alignment at the cursor position in whatever text is being edited.
337
+ * Works for body text, text boxes, and table cells.
338
+ */
339
+ getUnifiedAlignmentAtCursor(): TextAlignment;
340
+ /**
341
+ * Set the alignment for the current paragraph or selection in whatever text is being edited.
342
+ * Works for body text, text boxes, and table cells.
343
+ */
344
+ setUnifiedAlignment(alignment: TextAlignment): void;
345
+ insertText(text: string): void;
346
+ getFlowingText(): string;
347
+ setFlowingText(text: string): void;
348
+ /**
349
+ * Set the cursor position in the active flowing content.
350
+ * Works for body, header, footer, text boxes, and table cells.
351
+ */
352
+ setCursorPosition(position: number): void;
353
+ /**
354
+ * Get the current cursor position in the active flowing content.
355
+ * Returns the position for cursor selections, start position for text selections,
356
+ * or 0 if no text content is selected.
357
+ */
358
+ getCursorPosition(): number;
359
+ /**
360
+ * Insert an embedded object at the current cursor position.
361
+ * Works for body, header, footer, text boxes, and table cells.
362
+ */
363
+ insertEmbeddedObject(object: BaseEmbeddedObject, position?: ObjectPosition): void;
364
+ /**
365
+ * Insert a substitution field at the current cursor position.
366
+ * Works for body, header, footer, text boxes, and table cells.
367
+ */
368
+ insertSubstitutionField(fieldName: string, config?: SubstitutionFieldConfig): void;
369
+ /**
370
+ * Insert a page number field at the current cursor position.
371
+ * The field displays the current page number during rendering.
372
+ * Works for body, header, footer, text boxes, and table cells.
373
+ * @param displayFormat Optional format string (e.g., "Page %d" where %d is replaced by page number)
374
+ */
375
+ insertPageNumberField(displayFormat?: string): void;
376
+ /**
377
+ * Insert a page count field at the current cursor position.
378
+ * The field displays the total page count during rendering.
379
+ * Works for body, header, footer, text boxes, and table cells.
380
+ * @param displayFormat Optional format string (e.g., "of %d" where %d is replaced by page count)
381
+ */
382
+ insertPageCountField(displayFormat?: string): void;
383
+ /**
384
+ * Insert a page break at the current cursor position.
385
+ * Forces subsequent content to start on a new page.
386
+ * Works for body content. Note: Page breaks in headers, footers, text boxes,
387
+ * or table cells are not recommended as these don't span pages.
388
+ */
389
+ insertPageBreak(): void;
390
+ /**
391
+ * Get a substitution field at a specific text position in the active section.
392
+ * @param position The text index to check
393
+ * @returns The substitution field at that position, or null if none
394
+ */
395
+ getFieldAt(position: number): SubstitutionField | null;
396
+ /**
397
+ * Get the substitution field at the current selection/cursor position.
398
+ * @returns The substitution field if the cursor/selection is on a field, or null
399
+ */
400
+ getSelectedField(): SubstitutionField | null;
401
+ /**
402
+ * Get the currently selected text box if one is selected.
403
+ * @returns The selected TextBoxObject or null if no text box is selected
404
+ */
405
+ getSelectedTextBox(): TextBoxObject | null;
406
+ /**
407
+ * Get the currently selected table if one is selected.
408
+ * @returns The selected TableObject or null if no table is selected
409
+ */
410
+ getSelectedTable(): TableObject | null;
411
+ /**
412
+ * Get the currently selected image if one is selected.
413
+ * @returns The selected ImageObject or null if no image is selected
414
+ */
415
+ getSelectedImage(): ImageObject | null;
416
+ /**
417
+ * Get the currently focused table (table being edited).
418
+ * @returns The focused TableObject or null
419
+ */
420
+ getFocusedTable(): TableObject | null;
421
+ /**
422
+ * Insert a row into a table.
423
+ * Undo is automatically tracked via ObjectMutationObserver.
424
+ * @param table The table to modify
425
+ * @param rowIndex The index at which to insert the row
426
+ * @param config Optional row configuration
427
+ */
428
+ tableInsertRow(table: TableObject, rowIndex: number, config?: TableRowConfig): void;
429
+ /**
430
+ * Remove a row from a table.
431
+ * Undo is automatically tracked via ObjectMutationObserver.
432
+ * @param table The table to modify
433
+ * @param rowIndex The index of the row to remove
434
+ */
435
+ tableRemoveRow(table: TableObject, rowIndex: number): void;
436
+ /**
437
+ * Insert a column into a table.
438
+ * Undo is automatically tracked via ObjectMutationObserver.
439
+ * @param table The table to modify
440
+ * @param colIndex The index at which to insert the column
441
+ * @param width Optional column width
442
+ */
443
+ tableInsertColumn(table: TableObject, colIndex: number, width?: number): void;
444
+ /**
445
+ * Remove a column from a table.
446
+ * Undo is automatically tracked via ObjectMutationObserver.
447
+ * @param table The table to modify
448
+ * @param colIndex The index of the column to remove
449
+ */
450
+ tableRemoveColumn(table: TableObject, colIndex: number): void;
451
+ /**
452
+ * Begin a compound operation. Groups multiple mutations into a single undo entry.
453
+ * Call endCompoundOperation after making changes.
454
+ * @param description Description of the change for undo/redo
455
+ */
456
+ beginCompoundOperation(description?: string): void;
457
+ /**
458
+ * End a compound operation.
459
+ * @param description Description of the change for undo/redo (overrides begin description)
460
+ */
461
+ endCompoundOperation(description?: string): void;
462
+ /**
463
+ * Update a substitution field's properties in the active section.
464
+ * @param textIndex The text index of the field to update
465
+ * @param updates The properties to update
466
+ * @returns true if the field was updated, false if not found
467
+ */
468
+ updateField(textIndex: number, updates: {
469
+ fieldName?: string;
470
+ defaultValue?: string;
471
+ displayFormat?: string;
472
+ formatConfig?: import('../text/types').FieldFormatConfig;
473
+ }): boolean;
474
+ /**
475
+ * @deprecated Use insertEmbeddedObject instead
476
+ */
477
+ insertInlineElement(_elementData: unknown, _position?: ObjectPosition): void;
478
+ /**
479
+ * Apply merge data to substitute all substitution fields with their values.
480
+ * First expands repeating sections (body only), then replaces fields in body, header, and footer.
481
+ * Field names can use dot-notation to access nested properties (e.g., "contact.address.street").
482
+ * For arrays, the 0th element is used by default (e.g., "items.item" resolves to items[0].item).
483
+ * Fields inside loops resolve relative to their iteration index.
484
+ * @param data Object containing merge data (can be nested)
485
+ */
486
+ applyMergeData(data: Record<string, unknown>): void;
487
+ /**
488
+ * Substitute all fields in a FlowingTextContent with values from data.
489
+ * @returns The number of fields substituted
490
+ */
491
+ private substituteFieldsInContent;
492
+ /**
493
+ * Substitute all fields in embedded objects (text boxes and tables) within a FlowingTextContent.
494
+ * @returns The number of fields substituted
495
+ */
496
+ private substituteFieldsInEmbeddedObjects;
497
+ /**
498
+ * Expand table row loops in embedded tables within a FlowingTextContent.
499
+ * For each table with row loops, duplicates template rows for each array element.
500
+ * Must be called before substituteFieldsInEmbeddedObjects().
501
+ */
502
+ private expandTableRowLoops;
503
+ /**
504
+ * Expand row loops in a single table.
505
+ * Processes loops from end to start to preserve row indices.
506
+ */
507
+ private expandTableRowLoopsInTable;
508
+ /**
509
+ * Rewrite field names in a FlowingTextContent to include array index.
510
+ * Fields that start with fieldPath will have the index inserted.
511
+ * E.g., "items.name" with fieldPath "items" and index 1 -> "items[1].name"
512
+ */
513
+ private rewriteFieldsInContent;
514
+ /**
515
+ * Expand repeating sections by duplicating content for each array element.
516
+ * Processes sections from end to start to preserve text indices.
517
+ */
518
+ private expandRepeatingSections;
519
+ /**
520
+ * Get a value at a path without array defaulting.
521
+ * Used to get the array itself rather than its first element.
522
+ */
523
+ private getValueAtPath;
524
+ /**
525
+ * Rewrite a field name to use an explicit array index.
526
+ * E.g., if fieldPath is "items" and the field name is "items.name",
527
+ * this returns "items[index].name".
528
+ */
529
+ private rewriteFieldNameWithIndex;
530
+ /**
531
+ * Resolve a dot-notation field path to a value in the data object.
532
+ * Supports nested objects, arrays (default to 0th element), and explicit indices.
533
+ * @param path Dot-notation path (e.g., "contact.address.street", "items.item", or "items[0].item")
534
+ * @param data The data object to resolve against
535
+ * @returns The resolved value or undefined if not found
536
+ */
537
+ private resolveFieldPath;
538
+ /**
539
+ * Parse a field path into segments, separating dot notation and array indices.
540
+ * E.g., "items[0].name" -> ["items", "[0]", "name"]
541
+ * E.g., "items.name" -> ["items", "name"]
542
+ */
543
+ private parseFieldPath;
544
+ applyTextFormatting(start: number, end: number, formatting: any): void;
545
+ /**
546
+ * Get the text formatting at a specific position in the active section.
547
+ * @param position The text index to get formatting at
548
+ * @returns The formatting style at that position
549
+ */
550
+ getFormattingAt(position: number): TextFormattingStyle | null;
551
+ /**
552
+ * Get the text formatting for the current selection or cursor position.
553
+ * Returns the formatting at the start of the selection or at the cursor position.
554
+ * @returns The formatting style, or null if no text selection/cursor
555
+ */
556
+ getSelectionFormatting(): TextFormattingStyle | null;
557
+ /**
558
+ * Set the alignment for the paragraph at the current cursor position.
559
+ * @param alignment The alignment to apply ('left', 'center', 'right', or 'justify')
560
+ */
561
+ setAlignment(alignment: TextAlignment): void;
562
+ /**
563
+ * Set the alignment for all paragraphs within the current text selection.
564
+ * If there's no selection, applies to the paragraph at cursor.
565
+ * @param alignment The alignment to apply ('left', 'center', 'right', or 'justify')
566
+ */
567
+ setAlignmentForSelection(alignment: TextAlignment): void;
568
+ /**
569
+ * Get the alignment at the current cursor position.
570
+ * @returns The alignment at cursor, or 'left' as default
571
+ */
572
+ getAlignmentAtCursor(): TextAlignment;
573
+ /**
574
+ * Toggle bullet list for the current paragraph.
575
+ */
576
+ toggleBulletList(): void;
577
+ /**
578
+ * Toggle numbered list for the current paragraph.
579
+ */
580
+ toggleNumberedList(): void;
581
+ /**
582
+ * Indent the current paragraph (increase list nesting level).
583
+ */
584
+ indentParagraph(): void;
585
+ /**
586
+ * Outdent the current paragraph (decrease list nesting level).
587
+ */
588
+ outdentParagraph(): void;
589
+ /**
590
+ * Get list formatting for the current paragraph.
591
+ */
592
+ getListFormatting(): import('../text').ListFormatting | undefined;
593
+ /**
594
+ * Insert a hyperlink for the current selection.
595
+ * @returns The created hyperlink, or null if no selection
596
+ */
597
+ insertHyperlink(url: string, options?: import('../text').HyperlinkOptions): import('../text').Hyperlink | null;
598
+ /**
599
+ * Insert a hyperlink at a specific range.
600
+ */
601
+ insertHyperlinkAt(url: string, startIndex: number, endIndex: number, options?: import('../text').HyperlinkOptions): import('../text').Hyperlink | null;
602
+ /**
603
+ * Remove a hyperlink by ID.
604
+ */
605
+ removeHyperlink(id: string): void;
606
+ /**
607
+ * Update a hyperlink's properties.
608
+ */
609
+ updateHyperlink(id: string, updates: import('../text').HyperlinkUpdate): void;
610
+ /**
611
+ * Get the hyperlink at a specific text index.
612
+ */
613
+ getHyperlinkAt(textIndex: number): import('../text').Hyperlink | undefined;
614
+ /**
615
+ * Get a hyperlink by ID.
616
+ */
617
+ getHyperlinkById(id: string): import('../text').Hyperlink | undefined;
618
+ /**
619
+ * Get all hyperlinks overlapping a range.
620
+ */
621
+ getHyperlinksInRange(startIndex: number, endIndex: number): import('../text').Hyperlink[];
622
+ /**
623
+ * Get all hyperlinks.
624
+ */
625
+ getAllHyperlinks(): import('../text').Hyperlink[];
626
+ updateDocumentSettings(settings: Partial<any>): void;
627
+ getDocumentSettings(): any;
628
+ /**
629
+ * Set whether control characters (spaces, tabs, newlines) are shown.
630
+ * @param show true to show control characters, false to hide
631
+ */
632
+ setShowControlCharacters(show: boolean): void;
633
+ /**
634
+ * Get whether control characters are currently shown.
635
+ */
636
+ getShowControlCharacters(): boolean;
637
+ /**
638
+ * Set whether the grid is shown.
639
+ * @param show true to show the grid, false to hide
640
+ */
641
+ setShowGrid(show: boolean): void;
642
+ /**
643
+ * Get whether the grid is currently shown.
644
+ */
645
+ getShowGrid(): boolean;
646
+ /**
647
+ * Set whether margin lines are shown.
648
+ * @param show true to show margin lines, false to hide
649
+ */
650
+ setShowMarginLines(show: boolean): void;
651
+ /**
652
+ * Get whether margin lines are currently shown.
653
+ */
654
+ getShowMarginLines(): boolean;
655
+ /**
656
+ * Get all paragraph boundaries in the body content.
657
+ * Returns indices that are valid start/end points for repeating sections.
658
+ * Note: Repeating sections are only supported in the body, not in header/footer.
659
+ */
660
+ getParagraphBoundaries(): number[];
661
+ /**
662
+ * Create a repeating section in the body content.
663
+ * Note: Repeating sections are only supported in the body, not in header/footer.
664
+ * @param startIndex Text index at paragraph start (must be at a paragraph boundary)
665
+ * @param endIndex Text index at closing paragraph start (must be at a paragraph boundary)
666
+ * @param fieldPath The field path to the array to loop over (e.g., "items")
667
+ * @returns The created section, or null if boundaries are invalid
668
+ */
669
+ createRepeatingSection(startIndex: number, endIndex: number, fieldPath: string): RepeatingSection | null;
670
+ /**
671
+ * Get a repeating section by ID.
672
+ */
673
+ getRepeatingSection(id: string): RepeatingSection | null;
674
+ /**
675
+ * Get all repeating sections.
676
+ */
677
+ getRepeatingSections(): RepeatingSection[];
678
+ /**
679
+ * Update a repeating section's field path.
680
+ */
681
+ updateRepeatingSectionFieldPath(id: string, fieldPath: string): boolean;
682
+ /**
683
+ * Remove a repeating section by ID.
684
+ */
685
+ removeRepeatingSection(id: string): boolean;
686
+ /**
687
+ * Find a repeating section that has a boundary at the given text index.
688
+ */
689
+ getRepeatingSectionAtBoundary(textIndex: number): RepeatingSection | null;
690
+ /**
691
+ * Get the header text content.
692
+ */
693
+ getHeaderText(): string;
694
+ /**
695
+ * Set the header text content.
696
+ */
697
+ setHeaderText(text: string): void;
698
+ /**
699
+ * Get the footer text content.
700
+ */
701
+ getFooterText(): string;
702
+ /**
703
+ * Set the footer text content.
704
+ */
705
+ setFooterText(text: string): void;
706
+ /**
707
+ * Insert a substitution field in the header at the current cursor position.
708
+ * Temporarily switches to header section, inserts, then restores previous section.
709
+ */
710
+ insertHeaderSubstitutionField(fieldName: string, config?: SubstitutionFieldConfig): void;
711
+ /**
712
+ * Insert a substitution field in the footer at the current cursor position.
713
+ * Temporarily switches to footer section, inserts, then restores previous section.
714
+ */
715
+ insertFooterSubstitutionField(fieldName: string, config?: SubstitutionFieldConfig): void;
716
+ /**
717
+ * Insert an embedded object in the header.
718
+ */
719
+ insertHeaderEmbeddedObject(object: BaseEmbeddedObject, position?: ObjectPosition): void;
720
+ /**
721
+ * Insert an embedded object in the footer.
722
+ */
723
+ insertFooterEmbeddedObject(object: BaseEmbeddedObject, position?: ObjectPosition): void;
724
+ /**
725
+ * Copy the current selection to the clipboard.
726
+ * Returns true if content was copied.
727
+ */
728
+ copy(): Promise<boolean>;
729
+ /**
730
+ * Cut the current selection to the clipboard (copy + delete).
731
+ * Returns true if content was cut.
732
+ */
733
+ cut(): Promise<boolean>;
734
+ /**
735
+ * Paste content from the clipboard at the current cursor position.
736
+ * Returns true if content was pasted.
737
+ */
738
+ paste(): Promise<boolean>;
739
+ /**
740
+ * Select all text in the currently focused content.
741
+ */
742
+ selectAll(): void;
743
+ /**
744
+ * Paste proprietary clipboard content.
745
+ */
746
+ private pasteProprietaryContent;
747
+ /**
748
+ * Paste clipboard content into FlowingTextContent.
749
+ */
750
+ private pasteClipboardContent;
751
+ /**
752
+ * Create an embedded object from serialized data.
753
+ */
754
+ private createEmbeddedObjectFromData;
755
+ /**
756
+ * Paste an image blob as an embedded ImageObject.
757
+ */
758
+ private pasteImage;
759
+ destroy(): void;
760
+ }
761
+ //# sourceMappingURL=PCEditor.d.ts.map