pptx-vanilla-viewer 0.4.0 → 0.5.1

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.cts CHANGED
@@ -1520,6 +1520,56 @@ type ChangeCaseMode = 'sentence' | 'lower' | 'upper' | 'capitalize' | 'toggle';
1520
1520
 
1521
1521
  /** Connection lifecycle states for the Yjs WebSocket provider. */
1522
1522
  type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
1523
+ /** A single remote collaborator's cursor, in unscaled slide coordinates. */
1524
+ interface RemoteCursor {
1525
+ /** Stable id for the remote client (awareness clientId or peer id). */
1526
+ clientId: number | string;
1527
+ /** Display name shown in the label chip. */
1528
+ userName: string;
1529
+ /** Cursor + chip colour (any CSS colour string). */
1530
+ color: string;
1531
+ /** Unscaled slide-space X coordinate (px). */
1532
+ x: number;
1533
+ /** Unscaled slide-space Y coordinate (px). */
1534
+ y: number;
1535
+ /** Optional ids of elements this user has selected. */
1536
+ selectionIds?: string[];
1537
+ }
1538
+ /**
1539
+ * Presence data for a remote collaborator, sanitised from the awareness
1540
+ * protocol. Returned by {@link sanitizePresence}; coordinates are in unscaled
1541
+ * slide pixels, clamped to the supplied canvas bounds.
1542
+ */
1543
+ interface SanitizedPresence {
1544
+ clientId: number;
1545
+ userName: string;
1546
+ userAvatar?: string;
1547
+ userColor: string;
1548
+ activeSlideIndex: number;
1549
+ cursorX: number;
1550
+ cursorY: number;
1551
+ lastUpdated: string;
1552
+ selectedElementId?: string;
1553
+ role?: CollaborationRole;
1554
+ }
1555
+
1556
+ /**
1557
+ * Pure, framework-agnostic helpers for freehand ink drawing, shared by every
1558
+ * binding. No framework imports, so these can be unit-tested without TestBed.
1559
+ */
1560
+
1561
+ /** A 2D point in stage-local coordinates. */
1562
+ interface InkPoint {
1563
+ x: number;
1564
+ y: number;
1565
+ }
1566
+ /** Options for {@link strokeToInkElement}. */
1567
+ interface StrokeToInkElementOpts {
1568
+ points: InkPoint[];
1569
+ color: string;
1570
+ width: number;
1571
+ tool: 'pen' | 'highlighter' | 'freeform';
1572
+ }
1523
1573
 
1524
1574
  /**
1525
1575
  * Pure helpers for the gradient picker editor control, shared by every binding.
@@ -1640,6 +1690,13 @@ interface Store<T extends object> {
1640
1690
 
1641
1691
  /** `zoom` is either an explicit scale factor (1 = 100%) or fit-to-viewport. */
1642
1692
  type ZoomLevel = number | 'fit';
1693
+ /**
1694
+ * The Draw ribbon tab's active tool. `'select'` means normal editing gestures
1695
+ * (move/resize/rotate/inline-edit) apply on the stage; every other value
1696
+ * routes stage pointer events to the ink-drawing gesture controller instead
1697
+ * (see `editor-draw-gestures.ts`).
1698
+ */
1699
+ type DrawTool = 'select' | 'pen' | 'highlighter' | 'eraser';
1643
1700
  /**
1644
1701
  * The vanilla viewer's reactive view state. Kept intentionally flat and small;
1645
1702
  * everything here is what the DOM render layer consumes.
@@ -1677,8 +1734,20 @@ interface ViewerState {
1677
1734
  * navigation for the life of the viewer instance (in-memory only).
1678
1735
  */
1679
1736
  notesExpanded: boolean;
1737
+ /** Remote collaborators currently in the session (empty when not collaborating). */
1738
+ remotePresences: SanitizedPresence[];
1739
+ /** Remote cursors visible on the current slide, projected from `remotePresences`. */
1740
+ cursors: RemoteCursor[];
1741
+ /** Client id of the peer the local user is following, or null when free. */
1742
+ followedClientId: number | null;
1680
1743
  /** In-memory clipboard payload from the last copy/cut, or null. */
1681
1744
  clipboardPayload: ElementClipboardPayload | null;
1745
+ /** Active Draw ribbon tool; `'select'` disables the ink-drawing gesture controller. */
1746
+ drawTool: DrawTool;
1747
+ /** Stroke colour for the pen/highlighter tools. */
1748
+ drawColor: string;
1749
+ /** Stroke width (px) for the pen/highlighter tools. */
1750
+ drawWidth: number;
1682
1751
  }
1683
1752
 
1684
1753
  /**
@@ -1754,6 +1823,32 @@ interface ClipboardActions {
1754
1823
  paste(): void;
1755
1824
  }
1756
1825
 
1826
+ /**
1827
+ * Ink stroke actions for the Draw ribbon tab: commit a freehand pen/
1828
+ * highlighter stroke as a new `InkPptxElement`, or erase an existing one.
1829
+ * Both mutations are history-integrated (push -> mutate -> commit), mirroring
1830
+ * `editor-background-actions.ts` and the `insertElement` helper in
1831
+ * `editor-edit-ops.ts`. The pointer-event lifecycle that accumulates a
1832
+ * stroke's points lives separately in `editor-draw-gestures.ts`; this module
1833
+ * only owns the resulting slide/history mutation.
1834
+ */
1835
+ interface InkActions {
1836
+ /**
1837
+ * Build an `InkPptxElement` from a completed stroke (via the shared
1838
+ * `strokeToInkElement`) and append it to the current slide, selected.
1839
+ * A no-op when not editable, there is no current slide, or the stroke has
1840
+ * fewer than 2 points (shared helper returns `null`, matching a plain tap).
1841
+ */
1842
+ commitStroke(stroke: StrokeToInkElementOpts): void;
1843
+ /**
1844
+ * Remove the ink element with `id` from the current slide (Draw tab's
1845
+ * eraser tool). Returns `true` when an ink element was found and removed;
1846
+ * `false` for a missing id, a non-ink element, or a read-only viewer (safe
1847
+ * to call from a generic stage hit-test without a pre-check).
1848
+ */
1849
+ eraseInkElement(id: string): boolean;
1850
+ }
1851
+
1757
1852
  /**
1758
1853
  * Insert-element factories for the vanilla editor.
1759
1854
  *
@@ -1873,7 +1968,7 @@ interface GeometryPatch {
1873
1968
  * directly here. Every mutating action is history-integrated (push -> mutate
1874
1969
  * -> commit) via the shared {@link EditorOps}.
1875
1970
  */
1876
- interface EditActions extends TextActions, ArrangeActions, ClipboardActions, SlideActions, SlideBackgroundActions, TransitionActions, AnimationActions, InspectorActions {
1971
+ interface EditActions extends TextActions, ArrangeActions, ClipboardActions, SlideActions, SlideBackgroundActions, TransitionActions, AnimationActions, InspectorActions, InkActions {
1877
1972
  setShapeFill(color: string): void;
1878
1973
  setShapeStroke(color: string): void;
1879
1974
  setShapeStrokeWidth(width: number): void;
@@ -1988,6 +2083,12 @@ interface NotesPanel {
1988
2083
  setExpanded(expanded: boolean): void;
1989
2084
  }
1990
2085
 
2086
+ /** Draw tab state to reflect (current tool/colour/width). */
2087
+ interface RibbonDrawState {
2088
+ tool: DrawTool;
2089
+ color: string;
2090
+ width: number;
2091
+ }
1991
2092
  /** Nav-row state (prev/next/counter/zoom label). */
1992
2093
  interface RibbonNavState {
1993
2094
  current: number;
@@ -2016,6 +2117,8 @@ interface Ribbon {
2016
2117
  setEditable(editable: boolean): void;
2017
2118
  /** Reflect the current selection across the Home tab's Font/Paragraph/Arrange groups. */
2018
2119
  updateSelection(selectedElement: a | undefined, extra: RibbonSelectionState): void;
2120
+ /** Reflect the current Draw tab tool/colour/width (store-driven). */
2121
+ setDrawState(state: RibbonDrawState): void;
2019
2122
  }
2020
2123
 
2021
2124
  interface ThumbnailRail {
@@ -2078,6 +2181,12 @@ interface EditorController {
2078
2181
  deleteSelected(): void;
2079
2182
  duplicateSelected(): string | null;
2080
2183
  getSelectedElementId(): string | null;
2184
+ /** Switch the Draw ribbon tab's active tool (also clears selection when leaving `'select'`). */
2185
+ setDrawTool(tool: DrawTool): void;
2186
+ /** Set the pen/highlighter stroke colour used by the next committed stroke. */
2187
+ setDrawColor(color: string): void;
2188
+ /** Set the pen/highlighter stroke width used by the next committed stroke. */
2189
+ setDrawWidth(width: number): void;
2081
2190
  /** The formatting / insert / arrange actions for the editing chrome. */
2082
2191
  getEditActions(): EditActions;
2083
2192
  /** The Find & Replace actions for the ribbon's docked panel. */
@@ -2315,6 +2424,21 @@ interface RenderController {
2315
2424
  */
2316
2425
  type AutosaveStatus = 'idle' | 'saving' | 'saved' | 'error';
2317
2426
 
2427
+ /**
2428
+ * share-helpers.ts: pure (framework-free) helpers for the Share dialog.
2429
+ *
2430
+ * Mirrors the Vue `ShareDialog.vue` / Angular `share-helpers.ts` form
2431
+ * validation and config-assembly logic (see `useCollaborationWiring.onShareStart`
2432
+ * for the `role: 'collaborator'` config this produces). No DOM here so it is
2433
+ * trivially unit-testable; the DOM builder lives in `ui/share-dialog.ts`.
2434
+ */
2435
+ /** Prefilled values for the Share form fields. */
2436
+ interface ShareDefaults {
2437
+ roomId?: string;
2438
+ userName?: string;
2439
+ serverUrl?: string;
2440
+ }
2441
+
2318
2442
  /** Per-slide progress callback: `(currentSlideIndex, totalSlides)`. */
2319
2443
  type ExportProgress = (current: number, total: number) => void;
2320
2444
 
@@ -2540,6 +2664,13 @@ interface PptxViewerOptions extends PptxViewerCallbacks {
2540
2664
  * slide array, so a joiner's host-provided media can degrade.
2541
2665
  */
2542
2666
  collaboration?: CollaborationConfig;
2667
+ /**
2668
+ * Prefilled values for the built-in Share/Broadcast dialogs' form fields
2669
+ * (e.g. a host-generated display name), mirroring the Vue binding's
2670
+ * `shareDefaults` prop. The broadcast dialog uses `userName` as the
2671
+ * presenter's display name.
2672
+ */
2673
+ shareDefaults?: ShareDefaults;
2543
2674
  }
2544
2675
  /** The viewer handle returned by `createPptxViewer`. */
2545
2676
  interface PptxViewerInstance {
@@ -2664,6 +2795,9 @@ interface ChromeHost {
2664
2795
  commitNotes(notes: string): void;
2665
2796
  getEditActions(): EditActions;
2666
2797
  getFindReplaceActions(): FindReplaceActions;
2798
+ setDrawTool(tool: DrawTool): void;
2799
+ setDrawColor(color: string): void;
2800
+ setDrawWidth(width: number): void;
2667
2801
  };
2668
2802
  prev(): void;
2669
2803
  next(): void;
package/dist/index.d.ts CHANGED
@@ -1520,6 +1520,56 @@ type ChangeCaseMode = 'sentence' | 'lower' | 'upper' | 'capitalize' | 'toggle';
1520
1520
 
1521
1521
  /** Connection lifecycle states for the Yjs WebSocket provider. */
1522
1522
  type ConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
1523
+ /** A single remote collaborator's cursor, in unscaled slide coordinates. */
1524
+ interface RemoteCursor {
1525
+ /** Stable id for the remote client (awareness clientId or peer id). */
1526
+ clientId: number | string;
1527
+ /** Display name shown in the label chip. */
1528
+ userName: string;
1529
+ /** Cursor + chip colour (any CSS colour string). */
1530
+ color: string;
1531
+ /** Unscaled slide-space X coordinate (px). */
1532
+ x: number;
1533
+ /** Unscaled slide-space Y coordinate (px). */
1534
+ y: number;
1535
+ /** Optional ids of elements this user has selected. */
1536
+ selectionIds?: string[];
1537
+ }
1538
+ /**
1539
+ * Presence data for a remote collaborator, sanitised from the awareness
1540
+ * protocol. Returned by {@link sanitizePresence}; coordinates are in unscaled
1541
+ * slide pixels, clamped to the supplied canvas bounds.
1542
+ */
1543
+ interface SanitizedPresence {
1544
+ clientId: number;
1545
+ userName: string;
1546
+ userAvatar?: string;
1547
+ userColor: string;
1548
+ activeSlideIndex: number;
1549
+ cursorX: number;
1550
+ cursorY: number;
1551
+ lastUpdated: string;
1552
+ selectedElementId?: string;
1553
+ role?: CollaborationRole;
1554
+ }
1555
+
1556
+ /**
1557
+ * Pure, framework-agnostic helpers for freehand ink drawing, shared by every
1558
+ * binding. No framework imports, so these can be unit-tested without TestBed.
1559
+ */
1560
+
1561
+ /** A 2D point in stage-local coordinates. */
1562
+ interface InkPoint {
1563
+ x: number;
1564
+ y: number;
1565
+ }
1566
+ /** Options for {@link strokeToInkElement}. */
1567
+ interface StrokeToInkElementOpts {
1568
+ points: InkPoint[];
1569
+ color: string;
1570
+ width: number;
1571
+ tool: 'pen' | 'highlighter' | 'freeform';
1572
+ }
1523
1573
 
1524
1574
  /**
1525
1575
  * Pure helpers for the gradient picker editor control, shared by every binding.
@@ -1640,6 +1690,13 @@ interface Store<T extends object> {
1640
1690
 
1641
1691
  /** `zoom` is either an explicit scale factor (1 = 100%) or fit-to-viewport. */
1642
1692
  type ZoomLevel = number | 'fit';
1693
+ /**
1694
+ * The Draw ribbon tab's active tool. `'select'` means normal editing gestures
1695
+ * (move/resize/rotate/inline-edit) apply on the stage; every other value
1696
+ * routes stage pointer events to the ink-drawing gesture controller instead
1697
+ * (see `editor-draw-gestures.ts`).
1698
+ */
1699
+ type DrawTool = 'select' | 'pen' | 'highlighter' | 'eraser';
1643
1700
  /**
1644
1701
  * The vanilla viewer's reactive view state. Kept intentionally flat and small;
1645
1702
  * everything here is what the DOM render layer consumes.
@@ -1677,8 +1734,20 @@ interface ViewerState {
1677
1734
  * navigation for the life of the viewer instance (in-memory only).
1678
1735
  */
1679
1736
  notesExpanded: boolean;
1737
+ /** Remote collaborators currently in the session (empty when not collaborating). */
1738
+ remotePresences: SanitizedPresence[];
1739
+ /** Remote cursors visible on the current slide, projected from `remotePresences`. */
1740
+ cursors: RemoteCursor[];
1741
+ /** Client id of the peer the local user is following, or null when free. */
1742
+ followedClientId: number | null;
1680
1743
  /** In-memory clipboard payload from the last copy/cut, or null. */
1681
1744
  clipboardPayload: ElementClipboardPayload | null;
1745
+ /** Active Draw ribbon tool; `'select'` disables the ink-drawing gesture controller. */
1746
+ drawTool: DrawTool;
1747
+ /** Stroke colour for the pen/highlighter tools. */
1748
+ drawColor: string;
1749
+ /** Stroke width (px) for the pen/highlighter tools. */
1750
+ drawWidth: number;
1682
1751
  }
1683
1752
 
1684
1753
  /**
@@ -1754,6 +1823,32 @@ interface ClipboardActions {
1754
1823
  paste(): void;
1755
1824
  }
1756
1825
 
1826
+ /**
1827
+ * Ink stroke actions for the Draw ribbon tab: commit a freehand pen/
1828
+ * highlighter stroke as a new `InkPptxElement`, or erase an existing one.
1829
+ * Both mutations are history-integrated (push -> mutate -> commit), mirroring
1830
+ * `editor-background-actions.ts` and the `insertElement` helper in
1831
+ * `editor-edit-ops.ts`. The pointer-event lifecycle that accumulates a
1832
+ * stroke's points lives separately in `editor-draw-gestures.ts`; this module
1833
+ * only owns the resulting slide/history mutation.
1834
+ */
1835
+ interface InkActions {
1836
+ /**
1837
+ * Build an `InkPptxElement` from a completed stroke (via the shared
1838
+ * `strokeToInkElement`) and append it to the current slide, selected.
1839
+ * A no-op when not editable, there is no current slide, or the stroke has
1840
+ * fewer than 2 points (shared helper returns `null`, matching a plain tap).
1841
+ */
1842
+ commitStroke(stroke: StrokeToInkElementOpts): void;
1843
+ /**
1844
+ * Remove the ink element with `id` from the current slide (Draw tab's
1845
+ * eraser tool). Returns `true` when an ink element was found and removed;
1846
+ * `false` for a missing id, a non-ink element, or a read-only viewer (safe
1847
+ * to call from a generic stage hit-test without a pre-check).
1848
+ */
1849
+ eraseInkElement(id: string): boolean;
1850
+ }
1851
+
1757
1852
  /**
1758
1853
  * Insert-element factories for the vanilla editor.
1759
1854
  *
@@ -1873,7 +1968,7 @@ interface GeometryPatch {
1873
1968
  * directly here. Every mutating action is history-integrated (push -> mutate
1874
1969
  * -> commit) via the shared {@link EditorOps}.
1875
1970
  */
1876
- interface EditActions extends TextActions, ArrangeActions, ClipboardActions, SlideActions, SlideBackgroundActions, TransitionActions, AnimationActions, InspectorActions {
1971
+ interface EditActions extends TextActions, ArrangeActions, ClipboardActions, SlideActions, SlideBackgroundActions, TransitionActions, AnimationActions, InspectorActions, InkActions {
1877
1972
  setShapeFill(color: string): void;
1878
1973
  setShapeStroke(color: string): void;
1879
1974
  setShapeStrokeWidth(width: number): void;
@@ -1988,6 +2083,12 @@ interface NotesPanel {
1988
2083
  setExpanded(expanded: boolean): void;
1989
2084
  }
1990
2085
 
2086
+ /** Draw tab state to reflect (current tool/colour/width). */
2087
+ interface RibbonDrawState {
2088
+ tool: DrawTool;
2089
+ color: string;
2090
+ width: number;
2091
+ }
1991
2092
  /** Nav-row state (prev/next/counter/zoom label). */
1992
2093
  interface RibbonNavState {
1993
2094
  current: number;
@@ -2016,6 +2117,8 @@ interface Ribbon {
2016
2117
  setEditable(editable: boolean): void;
2017
2118
  /** Reflect the current selection across the Home tab's Font/Paragraph/Arrange groups. */
2018
2119
  updateSelection(selectedElement: a | undefined, extra: RibbonSelectionState): void;
2120
+ /** Reflect the current Draw tab tool/colour/width (store-driven). */
2121
+ setDrawState(state: RibbonDrawState): void;
2019
2122
  }
2020
2123
 
2021
2124
  interface ThumbnailRail {
@@ -2078,6 +2181,12 @@ interface EditorController {
2078
2181
  deleteSelected(): void;
2079
2182
  duplicateSelected(): string | null;
2080
2183
  getSelectedElementId(): string | null;
2184
+ /** Switch the Draw ribbon tab's active tool (also clears selection when leaving `'select'`). */
2185
+ setDrawTool(tool: DrawTool): void;
2186
+ /** Set the pen/highlighter stroke colour used by the next committed stroke. */
2187
+ setDrawColor(color: string): void;
2188
+ /** Set the pen/highlighter stroke width used by the next committed stroke. */
2189
+ setDrawWidth(width: number): void;
2081
2190
  /** The formatting / insert / arrange actions for the editing chrome. */
2082
2191
  getEditActions(): EditActions;
2083
2192
  /** The Find & Replace actions for the ribbon's docked panel. */
@@ -2315,6 +2424,21 @@ interface RenderController {
2315
2424
  */
2316
2425
  type AutosaveStatus = 'idle' | 'saving' | 'saved' | 'error';
2317
2426
 
2427
+ /**
2428
+ * share-helpers.ts: pure (framework-free) helpers for the Share dialog.
2429
+ *
2430
+ * Mirrors the Vue `ShareDialog.vue` / Angular `share-helpers.ts` form
2431
+ * validation and config-assembly logic (see `useCollaborationWiring.onShareStart`
2432
+ * for the `role: 'collaborator'` config this produces). No DOM here so it is
2433
+ * trivially unit-testable; the DOM builder lives in `ui/share-dialog.ts`.
2434
+ */
2435
+ /** Prefilled values for the Share form fields. */
2436
+ interface ShareDefaults {
2437
+ roomId?: string;
2438
+ userName?: string;
2439
+ serverUrl?: string;
2440
+ }
2441
+
2318
2442
  /** Per-slide progress callback: `(currentSlideIndex, totalSlides)`. */
2319
2443
  type ExportProgress = (current: number, total: number) => void;
2320
2444
 
@@ -2540,6 +2664,13 @@ interface PptxViewerOptions extends PptxViewerCallbacks {
2540
2664
  * slide array, so a joiner's host-provided media can degrade.
2541
2665
  */
2542
2666
  collaboration?: CollaborationConfig;
2667
+ /**
2668
+ * Prefilled values for the built-in Share/Broadcast dialogs' form fields
2669
+ * (e.g. a host-generated display name), mirroring the Vue binding's
2670
+ * `shareDefaults` prop. The broadcast dialog uses `userName` as the
2671
+ * presenter's display name.
2672
+ */
2673
+ shareDefaults?: ShareDefaults;
2543
2674
  }
2544
2675
  /** The viewer handle returned by `createPptxViewer`. */
2545
2676
  interface PptxViewerInstance {
@@ -2664,6 +2795,9 @@ interface ChromeHost {
2664
2795
  commitNotes(notes: string): void;
2665
2796
  getEditActions(): EditActions;
2666
2797
  getFindReplaceActions(): FindReplaceActions;
2798
+ setDrawTool(tool: DrawTool): void;
2799
+ setDrawColor(color: string): void;
2800
+ setDrawWidth(width: number): void;
2667
2801
  };
2668
2802
  prev(): void;
2669
2803
  next(): void;