pptx-angular-viewer 1.1.64 → 1.1.66

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.
@@ -49662,8 +49662,14 @@ class InspectorPanelComponent {
49662
49662
  * identically.
49663
49663
  */
49664
49664
  onSmartArtDataChange(smartArtData) {
49665
- this.editor.updateElement(this.slideIndex(), this.el().id, {
49666
- smartArtData,
49665
+ // Reflow `drawingShapes` back from the layout engine when the edit cleared
49666
+ // them (every structural/text/style op does) -- otherwise the renderer
49667
+ // falls back to the generic SVG layout for every node, not just the one
49668
+ // just edited.
49669
+ const el = this.el();
49670
+ const reflowed = rebuildDrawingShapesIfCleared(smartArtData, smartArtData.layout, resolvePalette(smartArtData), smartArtData.style ?? 'flat', el.id, { width: el.width, height: el.height });
49671
+ this.editor.updateElement(this.slideIndex(), el.id, {
49672
+ smartArtData: reflowed,
49667
49673
  });
49668
49674
  }
49669
49675
  /** Toggle element lock (noMove + noResize + noSelect). */
@@ -54948,6 +54954,15 @@ class SmartArtRendererComponent {
54948
54954
  /** Container div ref used to project hover rects into local coordinates. */
54949
54955
  smartartContainer = viewChild('smartartContainer', /* @ts-ignore */
54950
54956
  ...(ngDevMode ? [{ debugName: "smartartContainer" }] : /* istanbul ignore next */ []));
54957
+ /**
54958
+ * The mounted style-bar popover, if any. Mousemove events landing inside it
54959
+ * must not clear hover state, or the popover would unmount as soon as the
54960
+ * pointer reaches the swatches it needs to be clicked.
54961
+ */
54962
+ styleBar = viewChild('styleBar', /* @ts-ignore */
54963
+ ...(ngDevMode ? [{ debugName: "styleBar" }] : /* istanbul ignore next */ []));
54964
+ /** Pending "leave" timeout: grace period for the pointer to reach the style bar. */
54965
+ hideTimeout = null;
54951
54966
  /**
54952
54967
  * Guards against a cancel-triggered DOM-removal blur committing the edit.
54953
54968
  * Set to true before programmatic cancellation; reset to false on each new edit.
@@ -54957,6 +54972,7 @@ class SmartArtRendererComponent {
54957
54972
  canEditNodes = computed(() => this.editable() && this.editor !== null, /* @ts-ignore */
54958
54973
  ...(ngDevMode ? [{ debugName: "canEditNodes" }] : /* istanbul ignore next */ []));
54959
54974
  constructor() {
54975
+ inject(DestroyRef).onDestroy(() => this.cancelPendingHide());
54960
54976
  // Focus + select-all the editor as soon as it mounts (mirrors the table
54961
54977
  // renderer's cell-input effect).
54962
54978
  effect(() => {
@@ -55154,7 +55170,7 @@ class SmartArtRendererComponent {
55154
55170
  return;
55155
55171
  }
55156
55172
  editor.updateElement(slideIndex, this.element().id, {
55157
- smartArtData: next,
55173
+ smartArtData: this.reflow(next),
55158
55174
  });
55159
55175
  // Announce the commit to assistive technology via the polite live region.
55160
55176
  this.liveMessage.set(text.trim().length > 0
@@ -55162,15 +55178,24 @@ class SmartArtRendererComponent {
55162
55178
  : this.translate.instant('pptx.smartart.nodeCleared'));
55163
55179
  }
55164
55180
  // ── Style bar & hover tracking ────────────────────────────────────────
55181
+ /** Approximate rendered size of the style bar (6 swatches + padding/border). */
55182
+ static STYLE_BAR_WIDTH = 168;
55183
+ static STYLE_BAR_HEIGHT = 40;
55184
+ /** Grace period (ms) before clearing hover state once the pointer leaves the
55185
+ * node, so it can cross the small visual gap to the style bar. */
55186
+ static HIDE_GRACE_MS = 150;
55165
55187
  styleBarStyle = computed(() => {
55166
55188
  const rect = this.hoveredNodeRect();
55167
- if (!rect) {
55189
+ const cnt = this.smartartContainer()?.nativeElement;
55190
+ if (!rect || !cnt) {
55168
55191
  return null;
55169
55192
  }
55193
+ const maxLeft = Math.max(0, cnt.clientWidth - SmartArtRendererComponent.STYLE_BAR_WIDTH);
55194
+ const maxTop = Math.max(0, cnt.clientHeight - SmartArtRendererComponent.STYLE_BAR_HEIGHT);
55170
55195
  return {
55171
55196
  position: 'absolute',
55172
- left: `${Math.max(0, rect.left + rect.width - 120)}px`,
55173
- top: `${Math.max(0, rect.top - 22)}px`,
55197
+ left: `${Math.min(maxLeft, Math.max(0, rect.left + rect.width - SmartArtRendererComponent.STYLE_BAR_WIDTH))}px`,
55198
+ top: `${Math.min(maxTop, Math.max(0, rect.top - 22))}px`,
55174
55199
  'z-index': '25',
55175
55200
  };
55176
55201
  }, /* @ts-ignore */
@@ -55181,16 +55206,41 @@ class SmartArtRendererComponent {
55181
55206
  }
55182
55207
  const nodeEl = this.findNodeEl(event.target);
55183
55208
  const cnt = this.smartartContainer()?.nativeElement;
55184
- const id = nodeEl?.getAttribute('data-smartart-node-id') ?? null;
55185
- this.hoveredNodeId.set(id);
55186
- this.hoveredNodeRect.set(id && nodeEl && cnt
55187
- ? computeInlineEditorRect(nodeEl.getBoundingClientRect(), cnt.getBoundingClientRect())
55188
- : null);
55209
+ if (nodeEl && cnt) {
55210
+ this.cancelPendingHide();
55211
+ const id = nodeEl.getAttribute('data-smartart-node-id');
55212
+ this.hoveredNodeId.set(id);
55213
+ this.hoveredNodeRect.set(id
55214
+ ? computeInlineEditorRect(nodeEl.getBoundingClientRect(), cnt.getBoundingClientRect())
55215
+ : null);
55216
+ return;
55217
+ }
55218
+ // Pointer may be over the style-bar popover anchored to the currently
55219
+ // hovered node (not the node itself) - keep the hover state so the
55220
+ // popover doesn't unmount out from under the pointer.
55221
+ const styleBarEl = this.styleBar()?.nativeElement;
55222
+ if (styleBarEl && event.target instanceof Node && styleBarEl.contains(event.target)) {
55223
+ this.cancelPendingHide();
55224
+ return;
55225
+ }
55226
+ this.cancelPendingHide();
55227
+ this.hideTimeout = setTimeout(() => {
55228
+ this.hoveredNodeId.set(null);
55229
+ this.hoveredNodeRect.set(null);
55230
+ this.hideTimeout = null;
55231
+ }, SmartArtRendererComponent.HIDE_GRACE_MS);
55189
55232
  }
55190
55233
  onMouseLeave() {
55234
+ this.cancelPendingHide();
55191
55235
  this.hoveredNodeId.set(null);
55192
55236
  this.hoveredNodeRect.set(null);
55193
55237
  }
55238
+ cancelPendingHide() {
55239
+ if (this.hideTimeout !== null) {
55240
+ clearTimeout(this.hideTimeout);
55241
+ this.hideTimeout = null;
55242
+ }
55243
+ }
55194
55244
  findNodeEl(target) {
55195
55245
  let el = target instanceof Element ? target : null;
55196
55246
  while (el) {
@@ -55215,14 +55265,23 @@ class SmartArtRendererComponent {
55215
55265
  return;
55216
55266
  }
55217
55267
  this.editor.updateElement(slideIndex, this.element().id, {
55218
- smartArtData: next,
55268
+ smartArtData: this.reflow(next),
55219
55269
  });
55220
55270
  }
55271
+ /**
55272
+ * Reflow `drawingShapes` back from the shared layout engine when an edit op
55273
+ * cleared them (every text/style edit does) -- otherwise the renderer falls
55274
+ * back to the generic SVG layout for every node, not just the edited one.
55275
+ */
55276
+ reflow(data) {
55277
+ const el = this.element();
55278
+ return rebuildDrawingShapesIfCleared(data, data.layout, resolvePalette(data), data.style ?? 'flat', el.id, { width: el.width, height: el.height });
55279
+ }
55221
55280
  // ── Empty / no-data state ──────────────────────────────────────────────
55222
55281
  isEmpty = computed(() => this.nodes().length === 0 && !this.hasDrawingShapes(), /* @ts-ignore */
55223
55282
  ...(ngDevMode ? [{ debugName: "isEmpty" }] : /* istanbul ignore next */ []));
55224
55283
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SmartArtRendererComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
55225
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: SmartArtRendererComponent, isStandalone: true, selector: "pptx-smart-art-renderer", inputs: { element: { classPropertyName: "element", publicName: "element", isSignal: true, isRequired: true, transformFunction: null }, zIndex: { classPropertyName: "zIndex", publicName: "zIndex", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "nodeEditor", first: true, predicate: ["nodeEditor"], descendants: true, isSignal: true }, { propertyName: "smartartContainer", first: true, predicate: ["smartartContainer"], descendants: true, isSignal: true }], ngImport: i0, template: `
55284
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: SmartArtRendererComponent, isStandalone: true, selector: "pptx-smart-art-renderer", inputs: { element: { classPropertyName: "element", publicName: "element", isSignal: true, isRequired: true, transformFunction: null }, zIndex: { classPropertyName: "zIndex", publicName: "zIndex", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null } }, viewQueries: [{ propertyName: "nodeEditor", first: true, predicate: ["nodeEditor"], descendants: true, isSignal: true }, { propertyName: "smartartContainer", first: true, predicate: ["smartartContainer"], descendants: true, isSignal: true }, { propertyName: "styleBar", first: true, predicate: ["styleBar"], descendants: true, isSignal: true }], ngImport: i0, template: `
55226
55285
  <div
55227
55286
  class="pptx-ng-element pptx-ng-smartart"
55228
55287
  [ngStyle]="containerStyle()"
@@ -55406,6 +55465,7 @@ class SmartArtRendererComponent {
55406
55465
 
55407
55466
  @if (canEditNodes() && hoveredNodeId() && !editState() && styleBarStyle()) {
55408
55467
  <div
55468
+ #styleBar
55409
55469
  class="pptx-ng-smartart-style-bar"
55410
55470
  [ngStyle]="styleBarStyle()!"
55411
55471
  (mousedown)="$event.stopPropagation()"
@@ -55451,7 +55511,7 @@ class SmartArtRendererComponent {
55451
55511
  <span class="pptx-ng-sr-only" aria-live="polite" role="status">{{ liveMessage() }}</span>
55452
55512
  </div>
55453
55513
  </div>
55454
- `, isInline: true, styles: [".pptx-ng-smartart-chrome{box-sizing:border-box;overflow:hidden;position:relative}.pptx-ng-smartart-svg{width:100%;height:100%;pointer-events:none}.pptx-ng-smartart-node--editable{pointer-events:auto;cursor:text}.pptx-ng-smartart-node--editable:hover{filter:drop-shadow(0 0 2px rgba(96,165,250,.8))}.pptx-ng-smartart-node-editor{position:absolute;box-sizing:border-box;margin:0;padding:1px 2px;border:1px solid var(--pptx-inspector-active, #0078d4);border-radius:2px;background:#fff;color:#111;font-size:11px;line-height:1.1;text-align:center;resize:none;overflow:hidden;z-index:2}.pptx-ng-smartart-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:11px;color:#fffc;pointer-events:none}.pptx-ng-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.pptx-ng-smartart-style-bar{position:absolute;pointer-events:auto}.pptx-ng-smartart-swatch{width:14px;height:14px;border-radius:50%;border:1px solid rgba(0,0,0,.1);cursor:pointer;transition:transform .1s}.pptx-ng-smartart-swatch:hover{transform:scale(1.25)}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
55514
+ `, isInline: true, styles: [".pptx-ng-smartart-chrome{box-sizing:border-box;overflow:hidden;position:relative}.pptx-ng-smartart-svg{width:100%;height:100%;pointer-events:none}.pptx-ng-smartart-node--editable{pointer-events:auto;cursor:text}.pptx-ng-smartart-node--editable:hover{filter:drop-shadow(0 0 2px rgba(96,165,250,.8))}.pptx-ng-smartart-node-editor{position:absolute;box-sizing:border-box;margin:0;padding:1px 2px;border:1px solid var(--pptx-inspector-active, #0078d4);border-radius:2px;background:#fff;color:#111;font-size:11px;line-height:1.1;text-align:center;resize:none;overflow:hidden;z-index:2}.pptx-ng-smartart-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:11px;color:#fffc;pointer-events:none}.pptx-ng-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.pptx-ng-smartart-style-bar{position:absolute;pointer-events:auto;display:flex;gap:6px;padding:6px 8px;background:#ffffffe6;border:1px solid var(--border, #e2e8f0);border-radius:9999px;box-shadow:0 1px 2px #0000001a}.pptx-ng-smartart-swatch{width:20px;height:20px;border-radius:50%;border:1px solid rgba(0,0,0,.1);cursor:pointer;transition:transform .1s}.pptx-ng-smartart-swatch:hover{transform:scale(1.25)}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
55455
55515
  }
55456
55516
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SmartArtRendererComponent, decorators: [{
55457
55517
  type: Component,
@@ -55639,6 +55699,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
55639
55699
 
55640
55700
  @if (canEditNodes() && hoveredNodeId() && !editState() && styleBarStyle()) {
55641
55701
  <div
55702
+ #styleBar
55642
55703
  class="pptx-ng-smartart-style-bar"
55643
55704
  [ngStyle]="styleBarStyle()!"
55644
55705
  (mousedown)="$event.stopPropagation()"
@@ -55684,8 +55745,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
55684
55745
  <span class="pptx-ng-sr-only" aria-live="polite" role="status">{{ liveMessage() }}</span>
55685
55746
  </div>
55686
55747
  </div>
55687
- `, styles: [".pptx-ng-smartart-chrome{box-sizing:border-box;overflow:hidden;position:relative}.pptx-ng-smartart-svg{width:100%;height:100%;pointer-events:none}.pptx-ng-smartart-node--editable{pointer-events:auto;cursor:text}.pptx-ng-smartart-node--editable:hover{filter:drop-shadow(0 0 2px rgba(96,165,250,.8))}.pptx-ng-smartart-node-editor{position:absolute;box-sizing:border-box;margin:0;padding:1px 2px;border:1px solid var(--pptx-inspector-active, #0078d4);border-radius:2px;background:#fff;color:#111;font-size:11px;line-height:1.1;text-align:center;resize:none;overflow:hidden;z-index:2}.pptx-ng-smartart-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:11px;color:#fffc;pointer-events:none}.pptx-ng-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.pptx-ng-smartart-style-bar{position:absolute;pointer-events:auto}.pptx-ng-smartart-swatch{width:14px;height:14px;border-radius:50%;border:1px solid rgba(0,0,0,.1);cursor:pointer;transition:transform .1s}.pptx-ng-smartart-swatch:hover{transform:scale(1.25)}\n"] }]
55688
- }], ctorParameters: () => [], propDecorators: { element: [{ type: i0.Input, args: [{ isSignal: true, alias: "element", required: true }] }], zIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "zIndex", required: false }] }], editable: [{ type: i0.Input, args: [{ isSignal: true, alias: "editable", required: false }] }], nodeEditor: [{ type: i0.ViewChild, args: ['nodeEditor', { isSignal: true }] }], smartartContainer: [{ type: i0.ViewChild, args: ['smartartContainer', { isSignal: true }] }] } });
55748
+ `, styles: [".pptx-ng-smartart-chrome{box-sizing:border-box;overflow:hidden;position:relative}.pptx-ng-smartart-svg{width:100%;height:100%;pointer-events:none}.pptx-ng-smartart-node--editable{pointer-events:auto;cursor:text}.pptx-ng-smartart-node--editable:hover{filter:drop-shadow(0 0 2px rgba(96,165,250,.8))}.pptx-ng-smartart-node-editor{position:absolute;box-sizing:border-box;margin:0;padding:1px 2px;border:1px solid var(--pptx-inspector-active, #0078d4);border-radius:2px;background:#fff;color:#111;font-size:11px;line-height:1.1;text-align:center;resize:none;overflow:hidden;z-index:2}.pptx-ng-smartart-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;font-size:11px;color:#fffc;pointer-events:none}.pptx-ng-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.pptx-ng-smartart-style-bar{position:absolute;pointer-events:auto;display:flex;gap:6px;padding:6px 8px;background:#ffffffe6;border:1px solid var(--border, #e2e8f0);border-radius:9999px;box-shadow:0 1px 2px #0000001a}.pptx-ng-smartart-swatch{width:20px;height:20px;border-radius:50%;border:1px solid rgba(0,0,0,.1);cursor:pointer;transition:transform .1s}.pptx-ng-smartart-swatch:hover{transform:scale(1.25)}\n"] }]
55749
+ }], ctorParameters: () => [], propDecorators: { element: [{ type: i0.Input, args: [{ isSignal: true, alias: "element", required: true }] }], zIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "zIndex", required: false }] }], editable: [{ type: i0.Input, args: [{ isSignal: true, alias: "editable", required: false }] }], nodeEditor: [{ type: i0.ViewChild, args: ['nodeEditor', { isSignal: true }] }], smartartContainer: [{ type: i0.ViewChild, args: ['smartartContainer', { isSignal: true }] }], styleBar: [{ type: i0.ViewChild, args: ['styleBar', { isSignal: true }] }] } });
55689
55750
 
55690
55751
  const PALETTES = {
55691
55752
  colorful1: ['#3b82f6', '#22c55e', '#f97316', '#eab308', '#a855f7', '#ec4899'],