dopecanvas 0.1.2 → 0.1.4

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.
package/dist/index.d.ts CHANGED
@@ -185,6 +185,12 @@ export declare interface DopeCanvasHandle {
185
185
  undo: () => boolean;
186
186
  /** Redo the last undone edit. Returns false if nothing to redo. */
187
187
  redo: () => boolean;
188
+ /** Insert a page break after the block at the cursor (or at end) */
189
+ insertPageBreak: () => void;
190
+ /** Show or hide visual page break indicators */
191
+ setShowPageBreaks: (show: boolean) => void;
192
+ /** Get the current show-page-breaks state */
193
+ getShowPageBreaks: () => boolean;
188
194
  }
189
195
 
190
196
  export declare interface DopeCanvasProps {
@@ -192,6 +198,8 @@ export declare interface DopeCanvasProps {
192
198
  html?: string;
193
199
  /** Optional CSS to inject alongside the HTML */
194
200
  css?: string;
201
+ /** Rendering mode: paginated pages or continuous flow */
202
+ renderMode?: 'paged' | 'flow';
195
203
  /** Page configuration */
196
204
  pageConfig?: PageConfig;
197
205
  /** Callback when content changes */
@@ -254,6 +262,30 @@ export declare class EditableManager {
254
262
  getPlainText(): string;
255
263
  }
256
264
 
265
+ /**
266
+ * Comprehensive formatting state for the current selection.
267
+ * Consumers use this to reflect active states in toolbar UI.
268
+ */
269
+ export declare interface FormattingState {
270
+ bold: boolean;
271
+ italic: boolean;
272
+ underline: boolean;
273
+ strikethrough: boolean;
274
+ justifyLeft: boolean;
275
+ justifyCenter: boolean;
276
+ justifyRight: boolean;
277
+ justifyFull: boolean;
278
+ orderedList: boolean;
279
+ unorderedList: boolean;
280
+ superscript: boolean;
281
+ subscript: boolean;
282
+ fontName: string;
283
+ fontSize: string;
284
+ foreColor: string;
285
+ backColor: string;
286
+ formatBlock: string;
287
+ }
288
+
257
289
  /** Page sizes in pixels at 96 DPI */
258
290
  export declare const PAGE_SIZE_PRESETS: Record<PageSizeName, PageDimensions>;
259
291
 
@@ -330,6 +362,31 @@ export declare interface PaginationResult {
330
362
  pageCount: number;
331
363
  }
332
364
 
365
+ /**
366
+ * Recombine adjacent split blocks back into their original block.
367
+ * Call this before re-measuring / re-paginating so that the
368
+ * splitter can re-evaluate where to split.
369
+ *
370
+ * Takes an array of block HTML strings and returns a new array
371
+ * with split blocks merged.
372
+ */
373
+ export declare function recombineSplitBlocks(blockHTMLs: string[]): string[];
374
+
375
+ export declare interface SelectionSaver {
376
+ /** Call on mouseDown of a toolbar control to snapshot the current selection */
377
+ saveSelection: () => void;
378
+ /** Restore a previously saved selection */
379
+ restoreSelection: () => void;
380
+ /** Restore the selection and then run a callback (convenience) */
381
+ restoreAndExec: (fn: () => void) => void;
382
+ }
383
+
384
+ /** Result of splitting a block */
385
+ export declare interface SplitResult {
386
+ firstHTML: string;
387
+ secondHTML: string;
388
+ }
389
+
333
390
  export declare const TextToolbar: default_2.FC<TextToolbarProps>;
334
391
 
335
392
  declare interface TextToolbarProps {
@@ -348,6 +405,16 @@ declare interface ToolbarProps {
348
405
  onPageConfigChange: (config: Partial<PageConfig>) => void;
349
406
  }
350
407
 
408
+ /**
409
+ * Try to split a block element so that the first piece fits
410
+ * within `availableHeight` pixels. Returns null if the block
411
+ * cannot be split (too small, unsplittable tag, etc.).
412
+ *
413
+ * The element must be in the DOM (attached to a measurement
414
+ * container) so that getBoundingClientRect / Range work.
415
+ */
416
+ export declare function trySplitBlock(element: HTMLElement, availableHeight: number): SplitResult | null;
417
+
351
418
  /** Unsubscribe function returned by event listeners */
352
419
  export declare type Unsubscribe = () => void;
353
420
 
@@ -371,20 +438,23 @@ declare interface UseDocumentEngineReturn {
371
438
  }
372
439
 
373
440
  /**
374
- * Hook to query the current formatting state (bold, italic, etc.)
375
- * from the browser's selection.
441
+ * Hook to query the current formatting state (bold, italic, font, etc.)
442
+ * from the browser's selection. Updates reactively on every
443
+ * `selectionchange` event.
444
+ *
445
+ * Returns the full `FormattingState` object — consumers can use any
446
+ * fields they need for their own toolbar UI.
376
447
  */
377
- export declare function useFormattingState(): {
378
- bold: boolean;
379
- italic: boolean;
380
- underline: boolean;
381
- strikethrough: boolean;
382
- justifyLeft: boolean;
383
- justifyCenter: boolean;
384
- justifyRight: boolean;
385
- justifyFull: boolean;
386
- };
448
+ export declare function useFormattingState(): FormattingState;
387
449
 
388
450
  export declare function useSelectionContext(editableManager: EditableManager | null): ToolbarContext;
389
451
 
452
+ /**
453
+ * Hook that provides save/restore helpers for the browser selection.
454
+ * Use `saveSelection` as the `onMouseDown` handler on toolbar controls,
455
+ * then call `restoreAndExec(fn)` inside the control's `onChange` /
456
+ * `onClick` to restore the selection before running the format command.
457
+ */
458
+ export declare function useSelectionSaver(): SelectionSaver;
459
+
390
460
  export { }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dopecanvas",
3
- "version": "0.1.2",
4
- "description": "The office suite built for the AI era — a drop-in React component that renders LLM-generated HTML as paginated, editable documents.",
3
+ "version": "0.1.4",
4
+ "description": "The office editor built for the AI era — a drop-in React component that renders LLM-generated HTML as paginated, editable documents.",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "author": "DopeOffice",