pptx-angular-viewer 1.1.46 → 1.1.48

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.
@@ -49733,6 +49733,11 @@ class SmartArtRendererComponent {
49733
49733
  /** The mounted `<textarea>` for the active node edit, if any. */
49734
49734
  nodeEditor = viewChild('nodeEditor', /* @ts-ignore */
49735
49735
  ...(ngDevMode ? [{ debugName: "nodeEditor" }] : /* istanbul ignore next */ []));
49736
+ /**
49737
+ * Guards against a cancel-triggered DOM-removal blur committing the edit.
49738
+ * Set to true before programmatic cancellation; reset to false on each new edit.
49739
+ */
49740
+ editSettled = false;
49736
49741
  /** Whether node double-click / Enter enters inline edit (editable + has editor). */
49737
49742
  canEditNodes = computed(() => this.editable() && this.editor !== null, /* @ts-ignore */
49738
49743
  ...(ngDevMode ? [{ debugName: "canEditNodes" }] : /* istanbul ignore next */ []));
@@ -49837,6 +49842,24 @@ class SmartArtRendererComponent {
49837
49842
  asRect(node) {
49838
49843
  return node.kind === 'rect' ? node : undefined;
49839
49844
  }
49845
+ /**
49846
+ * Split node text on `\n` and compute per-line y offsets (in SVG px) that
49847
+ * centre the block around the node centre y (offset 0). Single-line text
49848
+ * produces one entry with offsetY=0, preserving the existing
49849
+ * `dominant-baseline="central"` behaviour exactly.
49850
+ */
49851
+ textLines(text, fontSize) {
49852
+ const raw = (text ?? '').split('\n').filter((l) => l.length > 0);
49853
+ if (raw.length === 0) {
49854
+ return [{ text: '', offsetY: 0 }];
49855
+ }
49856
+ const lh = fontSize * 1.2;
49857
+ const totalH = raw.length * lh;
49858
+ return raw.map((line, i) => ({
49859
+ text: line,
49860
+ offsetY: -totalH / 2 + lh / 2 + i * lh,
49861
+ }));
49862
+ }
49840
49863
  // ── Inline node-text editing ───────────────────────────────────────────
49841
49864
  /** Double-click a node enters inline edit mode (when editable). */
49842
49865
  onNodeDblClick(event, node) {
@@ -49857,6 +49880,10 @@ class SmartArtRendererComponent {
49857
49880
  }
49858
49881
  /** Commit the current edit (called on blur). */
49859
49882
  commitEdit(event) {
49883
+ if (this.editSettled) {
49884
+ this.editSettled = false;
49885
+ return;
49886
+ }
49860
49887
  const edit = this.editState();
49861
49888
  if (!edit) {
49862
49889
  return;
@@ -49875,11 +49902,14 @@ class SmartArtRendererComponent {
49875
49902
  }
49876
49903
  else if (event.key === 'Escape') {
49877
49904
  event.preventDefault();
49905
+ // Mark as settled so the DOM-removal blur does not commit the cancelled edit.
49906
+ this.editSettled = true;
49878
49907
  this.editState.set(null);
49879
49908
  }
49880
49909
  }
49881
49910
  /** Resolve the node id + geometry and open the editor seeded with full text. */
49882
49911
  enterEdit(node) {
49912
+ this.editSettled = false;
49883
49913
  const elementId = this.element().id;
49884
49914
  const seed = beginNodeEdit(node, elementId, this.rawNodeText(node));
49885
49915
  if (seed) {
@@ -49969,13 +49999,16 @@ class SmartArtRendererComponent {
49969
49999
  @if (shape.text) {
49970
50000
  <text
49971
50001
  [attr.x]="shape.textX"
49972
- [attr.y]="shape.textY"
49973
50002
  text-anchor="middle"
49974
50003
  dominant-baseline="central"
49975
50004
  [attr.fill]="shape.fontColor"
49976
50005
  [attr.font-size]="shape.fontSize"
49977
50006
  >
49978
- {{ shape.text }}
50007
+ @for (line of textLines(shape.text, shape.fontSize); track $index) {
50008
+ <tspan [attr.x]="shape.textX" [attr.y]="shape.textY + line.offsetY">
50009
+ {{ line.text }}
50010
+ </tspan>
50011
+ }
49979
50012
  </text>
49980
50013
  }
49981
50014
  </g>
@@ -50022,13 +50055,14 @@ class SmartArtRendererComponent {
50022
50055
  />
50023
50056
  <text
50024
50057
  [attr.x]="c.cx"
50025
- [attr.y]="c.cy"
50026
50058
  text-anchor="middle"
50027
50059
  dominant-baseline="central"
50028
50060
  fill="white"
50029
50061
  [attr.font-size]="c.fontSize"
50030
50062
  >
50031
- {{ c.text }}
50063
+ @for (line of textLines(c.text, c.fontSize); track $index) {
50064
+ <tspan [attr.x]="c.cx" [attr.y]="c.cy + line.offsetY">{{ line.text }}</tspan>
50065
+ }
50032
50066
  </text>
50033
50067
  } @else if (asPolygon(node); as p) {
50034
50068
  <polygon
@@ -50040,13 +50074,16 @@ class SmartArtRendererComponent {
50040
50074
  />
50041
50075
  <text
50042
50076
  [attr.x]="p.textX"
50043
- [attr.y]="p.textY"
50044
50077
  text-anchor="middle"
50045
50078
  dominant-baseline="central"
50046
50079
  fill="white"
50047
50080
  [attr.font-size]="p.fontSize"
50048
50081
  >
50049
- {{ p.text }}
50082
+ @for (line of textLines(p.text, p.fontSize); track $index) {
50083
+ <tspan [attr.x]="p.textX" [attr.y]="p.textY + line.offsetY">
50084
+ {{ line.text }}
50085
+ </tspan>
50086
+ }
50050
50087
  </text>
50051
50088
  } @else if (asRect(node); as r) {
50052
50089
  <rect
@@ -50062,13 +50099,16 @@ class SmartArtRendererComponent {
50062
50099
  />
50063
50100
  <text
50064
50101
  [attr.x]="r.textX"
50065
- [attr.y]="r.textY"
50066
50102
  text-anchor="middle"
50067
50103
  dominant-baseline="central"
50068
50104
  fill="white"
50069
50105
  [attr.font-size]="r.fontSize"
50070
50106
  >
50071
- {{ r.text }}
50107
+ @for (line of textLines(r.text, r.fontSize); track $index) {
50108
+ <tspan [attr.x]="r.textX" [attr.y]="r.textY + line.offsetY">
50109
+ {{ line.text }}
50110
+ </tspan>
50111
+ }
50072
50112
  </text>
50073
50113
  }
50074
50114
  </g>
@@ -50106,7 +50146,7 @@ class SmartArtRendererComponent {
50106
50146
  <span class="pptx-ng-sr-only" aria-live="polite" role="status">{{ liveMessage() }}</span>
50107
50147
  </div>
50108
50148
  </div>
50109
- `, 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-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}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
50149
+ `, 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}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
50110
50150
  }
50111
50151
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImport: i0, type: SmartArtRendererComponent, decorators: [{
50112
50152
  type: Component,
@@ -50159,13 +50199,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
50159
50199
  @if (shape.text) {
50160
50200
  <text
50161
50201
  [attr.x]="shape.textX"
50162
- [attr.y]="shape.textY"
50163
50202
  text-anchor="middle"
50164
50203
  dominant-baseline="central"
50165
50204
  [attr.fill]="shape.fontColor"
50166
50205
  [attr.font-size]="shape.fontSize"
50167
50206
  >
50168
- {{ shape.text }}
50207
+ @for (line of textLines(shape.text, shape.fontSize); track $index) {
50208
+ <tspan [attr.x]="shape.textX" [attr.y]="shape.textY + line.offsetY">
50209
+ {{ line.text }}
50210
+ </tspan>
50211
+ }
50169
50212
  </text>
50170
50213
  }
50171
50214
  </g>
@@ -50212,13 +50255,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
50212
50255
  />
50213
50256
  <text
50214
50257
  [attr.x]="c.cx"
50215
- [attr.y]="c.cy"
50216
50258
  text-anchor="middle"
50217
50259
  dominant-baseline="central"
50218
50260
  fill="white"
50219
50261
  [attr.font-size]="c.fontSize"
50220
50262
  >
50221
- {{ c.text }}
50263
+ @for (line of textLines(c.text, c.fontSize); track $index) {
50264
+ <tspan [attr.x]="c.cx" [attr.y]="c.cy + line.offsetY">{{ line.text }}</tspan>
50265
+ }
50222
50266
  </text>
50223
50267
  } @else if (asPolygon(node); as p) {
50224
50268
  <polygon
@@ -50230,13 +50274,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
50230
50274
  />
50231
50275
  <text
50232
50276
  [attr.x]="p.textX"
50233
- [attr.y]="p.textY"
50234
50277
  text-anchor="middle"
50235
50278
  dominant-baseline="central"
50236
50279
  fill="white"
50237
50280
  [attr.font-size]="p.fontSize"
50238
50281
  >
50239
- {{ p.text }}
50282
+ @for (line of textLines(p.text, p.fontSize); track $index) {
50283
+ <tspan [attr.x]="p.textX" [attr.y]="p.textY + line.offsetY">
50284
+ {{ line.text }}
50285
+ </tspan>
50286
+ }
50240
50287
  </text>
50241
50288
  } @else if (asRect(node); as r) {
50242
50289
  <rect
@@ -50252,13 +50299,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
50252
50299
  />
50253
50300
  <text
50254
50301
  [attr.x]="r.textX"
50255
- [attr.y]="r.textY"
50256
50302
  text-anchor="middle"
50257
50303
  dominant-baseline="central"
50258
50304
  fill="white"
50259
50305
  [attr.font-size]="r.fontSize"
50260
50306
  >
50261
- {{ r.text }}
50307
+ @for (line of textLines(r.text, r.fontSize); track $index) {
50308
+ <tspan [attr.x]="r.textX" [attr.y]="r.textY + line.offsetY">
50309
+ {{ line.text }}
50310
+ </tspan>
50311
+ }
50262
50312
  </text>
50263
50313
  }
50264
50314
  </g>
@@ -50296,7 +50346,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.2", ngImpor
50296
50346
  <span class="pptx-ng-sr-only" aria-live="polite" role="status">{{ liveMessage() }}</span>
50297
50347
  </div>
50298
50348
  </div>
50299
- `, 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-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}\n"] }]
50349
+ `, 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}\n"] }]
50300
50350
  }], 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 }] }] } });
50301
50351
 
50302
50352
  const PALETTES = {