@coco-vexel/coco-office-editor 1.0.1 → 1.0.2

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 (51) hide show
  1. package/README.md +33 -1
  2. package/dist/index.cjs +352 -99
  3. package/dist/index.cjs.map +1 -1
  4. package/dist/index.d.cts +5 -4
  5. package/dist/index.d.ts +5 -4
  6. package/dist/index.js +353 -101
  7. package/dist/index.js.map +1 -1
  8. package/dist/{model-DB6aN6uJ.d.cts → model-DNNBhhCB.d.cts} +4 -3
  9. package/dist/{model-DB6aN6uJ.d.ts → model-DNNBhhCB.d.ts} +4 -3
  10. package/dist/{native-B6B649CC.d.ts → native-OrEUvS8p.d.ts} +5 -1
  11. package/dist/native-TMv552dv.d.cts +317 -0
  12. package/dist/native-TMv552dv.d.ts +317 -0
  13. package/dist/{native-Ct9nN06K.d.cts → native-f2y3N8N5.d.cts} +5 -1
  14. package/dist/ppt-native.cjs +129 -59
  15. package/dist/ppt-native.cjs.map +1 -1
  16. package/dist/ppt-native.d.cts +1 -1
  17. package/dist/ppt-native.d.ts +1 -1
  18. package/dist/ppt-native.js +130 -60
  19. package/dist/ppt-native.js.map +1 -1
  20. package/dist/ppt.cjs +129 -58
  21. package/dist/ppt.cjs.map +1 -1
  22. package/dist/ppt.d.cts +3 -306
  23. package/dist/ppt.d.ts +3 -306
  24. package/dist/ppt.js +130 -60
  25. package/dist/ppt.js.map +1 -1
  26. package/dist/read-only-1_LQCO1d.d.cts +7 -0
  27. package/dist/read-only-1_LQCO1d.d.ts +7 -0
  28. package/dist/spreadsheet.cjs +114 -17
  29. package/dist/spreadsheet.cjs.map +1 -1
  30. package/dist/spreadsheet.d.cts +15 -3
  31. package/dist/spreadsheet.d.ts +15 -3
  32. package/dist/spreadsheet.js +114 -18
  33. package/dist/spreadsheet.js.map +1 -1
  34. package/dist/word-editing.d.cts +1 -1
  35. package/dist/word-editing.d.ts +1 -1
  36. package/dist/word-native.cjs +132 -23
  37. package/dist/word-native.cjs.map +1 -1
  38. package/dist/word-native.d.cts +2 -2
  39. package/dist/word-native.d.ts +2 -2
  40. package/dist/word-native.js +132 -23
  41. package/dist/word-native.js.map +1 -1
  42. package/dist/word-prosemirror.d.cts +1 -1
  43. package/dist/word-prosemirror.d.ts +1 -1
  44. package/dist/word.cjs +145 -23
  45. package/dist/word.cjs.map +1 -1
  46. package/dist/word.d.cts +5 -4
  47. package/dist/word.d.ts +5 -4
  48. package/dist/word.js +145 -24
  49. package/dist/word.js.map +1 -1
  50. package/package.json +3 -3
  51. package/src/styles/editor.css +1 -0
@@ -35,8 +35,6 @@ var __objRest = (source, exclude) => {
35
35
  return target;
36
36
  };
37
37
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
38
-
39
- // src/ppt/scene.ts
40
38
  var DEFAULT_PPT_SLIDE_SIZE = {
41
39
  width: 9144e3,
42
40
  height: 5143500
@@ -68,7 +66,7 @@ function buildPptSlideScene(slide, fallbackSize) {
68
66
  ].filter(shouldRenderInheritedShape);
69
67
  const shapes = [
70
68
  ...inheritedShapes,
71
- ...slide.shapes.map((shape) => applyPlaceholderInheritance(shape, layoutShapes))
69
+ ...slide.shapes.map((shape) => applyPlaceholderInheritance(shape, slide.layout))
72
70
  ];
73
71
  const renderShapes = shapes.flatMap(flattenRenderableShape);
74
72
  const background = (_j = (_g = slide.background) != null ? _g : (_f = slide.layout) == null ? void 0 : _f.background) != null ? _j : (_i = (_h = slide.layout) == null ? void 0 : _h.master) == null ? void 0 : _i.background;
@@ -209,28 +207,21 @@ function normalizeRotation(rotation) {
209
207
  return normalized === 0 ? void 0 : normalized;
210
208
  }
211
209
  __name(normalizeRotation, "normalizeRotation");
212
- function applyPlaceholderInheritance(shape, layoutShapes) {
213
- var _a;
214
- if (!shape.placeholder || !shape.text) return shape;
215
- const layoutShape = layoutShapes.find((candidate) => samePlaceholder(shape, candidate));
216
- const inheritedStyle = (_a = layoutShape == null ? void 0 : layoutShape.text) == null ? void 0 : _a.style;
217
- if (!inheritedStyle && !layoutShape) return shape;
218
- return __spreadProps(__spreadValues({}, shape), {
219
- geometry: __spreadValues(__spreadValues({}, layoutShape == null ? void 0 : layoutShape.geometry), shape.geometry),
210
+ function applyPlaceholderInheritance(shape, layout) {
211
+ if (!shape.placeholder) return shape;
212
+ const effective = ppt.resolvePptEffectivePlaceholderProperties(shape, layout);
213
+ return __spreadValues(__spreadProps(__spreadValues({}, shape), {
214
+ placeholder: effective.placeholder,
215
+ geometry: effective.geometry,
216
+ style: effective.style
217
+ }), shape.text ? {
220
218
  text: __spreadProps(__spreadValues({}, shape.text), {
221
- style: __spreadValues(__spreadValues({}, inheritedStyle), shape.text.style)
219
+ style: effective.textStyle,
220
+ body: effective.textBody
222
221
  })
223
- });
222
+ } : {});
224
223
  }
225
224
  __name(applyPlaceholderInheritance, "applyPlaceholderInheritance");
226
- function samePlaceholder(shape, candidate) {
227
- var _a, _b;
228
- if (!candidate.placeholder) return false;
229
- if (((_a = shape.placeholder) == null ? void 0 : _a.index) && candidate.placeholder.index === shape.placeholder.index)
230
- return true;
231
- return Boolean(((_b = shape.placeholder) == null ? void 0 : _b.type) && candidate.placeholder.type === shape.placeholder.type);
232
- }
233
- __name(samePlaceholder, "samePlaceholder");
234
225
  function buildPptSceneNode(shape, options = {}) {
235
226
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
236
227
  const capabilities = pptSceneNodeCapabilities(shape);
@@ -588,6 +579,17 @@ function findPptSceneNode(slide, shapeIdOrName) {
588
579
  }
589
580
  __name(findPptSceneNode, "findPptSceneNode");
590
581
 
582
+ // src/read-only.ts
583
+ var _EditorReadOnlyError = class _EditorReadOnlyError extends Error {
584
+ constructor(editor) {
585
+ super(`${editor} editor is read-only`);
586
+ __publicField(this, "code", "EDITOR_READ_ONLY");
587
+ this.name = "EditorReadOnlyError";
588
+ }
589
+ };
590
+ __name(_EditorReadOnlyError, "EditorReadOnlyError");
591
+ var EditorReadOnlyError = _EditorReadOnlyError;
592
+
591
593
  // src/ppt/session.ts
592
594
  var _PptEditorSession = class _PptEditorSession {
593
595
  constructor(view, options = {}) {
@@ -600,6 +602,7 @@ var _PptEditorSession = class _PptEditorSession {
600
602
  __publicField(this, "redoStack", []);
601
603
  __publicField(this, "textBodyOverrides", /* @__PURE__ */ new Map());
602
604
  __publicField(this, "maxHistory");
605
+ __publicField(this, "readOnlyValue");
603
606
  __publicField(this, "changeListeners", /* @__PURE__ */ new Set());
604
607
  __publicField(this, "selectionListeners", /* @__PURE__ */ new Set());
605
608
  var _a;
@@ -607,9 +610,11 @@ var _PptEditorSession = class _PptEditorSession {
607
610
  this.modelValue = view.model;
608
611
  this.sceneValue = view.scene;
609
612
  this.maxHistory = (_a = options.maxHistory) != null ? _a : 50;
613
+ this.readOnlyValue = options.readOnly === true;
610
614
  this.selectionValue = view.scene.slides[0] ? { kind: "slide", slideId: view.scene.slides[0].id } : null;
611
615
  }
612
616
  presentation() {
617
+ this.assertWritable();
613
618
  return this.presentationValue;
614
619
  }
615
620
  model() {
@@ -624,11 +629,17 @@ var _PptEditorSession = class _PptEditorSession {
624
629
  revision() {
625
630
  return this.revisionValue;
626
631
  }
632
+ isReadOnly() {
633
+ return this.readOnlyValue;
634
+ }
635
+ setReadOnly(readOnly) {
636
+ this.readOnlyValue = readOnly;
637
+ }
627
638
  canUndo() {
628
- return this.undoStack.length > 0;
639
+ return !this.readOnlyValue && this.undoStack.length > 0;
629
640
  }
630
641
  canRedo() {
631
- return this.redoStack.length > 0;
642
+ return !this.readOnlyValue && this.redoStack.length > 0;
632
643
  }
633
644
  subscribe(event, listener) {
634
645
  const listeners = event === "change" ? this.changeListeners : this.selectionListeners;
@@ -644,6 +655,7 @@ var _PptEditorSession = class _PptEditorSession {
644
655
  await this.applySelectionCommand(command);
645
656
  return;
646
657
  }
658
+ this.assertWritable();
647
659
  const before = await this.presentationValue.toZip();
648
660
  const nextSelection = await this.applyEditCommand(command);
649
661
  this.pushUndo(before);
@@ -652,6 +664,7 @@ var _PptEditorSession = class _PptEditorSession {
652
664
  if (nextSelection !== void 0) this.setSelection(nextSelection);
653
665
  }
654
666
  async undo() {
667
+ this.assertWritable();
655
668
  const entry = this.undoStack.pop();
656
669
  if (!entry) return;
657
670
  const selection = this.selectionValue;
@@ -660,6 +673,7 @@ var _PptEditorSession = class _PptEditorSession {
660
673
  await this.replacePresentation(entry.bytes, selection);
661
674
  }
662
675
  async redo() {
676
+ this.assertWritable();
663
677
  const entry = this.redoStack.pop();
664
678
  if (!entry) return;
665
679
  const selection = this.selectionValue;
@@ -692,6 +706,9 @@ var _PptEditorSession = class _PptEditorSession {
692
706
  this.changeListeners.clear();
693
707
  this.selectionListeners.clear();
694
708
  }
709
+ assertWritable() {
710
+ if (this.readOnlyValue) throw new EditorReadOnlyError("ppt");
711
+ }
695
712
  async applySelectionCommand(command) {
696
713
  const slide = findPptSceneSlide(this.sceneValue, command.slideIdOrIndex);
697
714
  if (!slide) throw new Error(`PPT slide not found: ${String(command.slideIdOrIndex)}`);
@@ -915,6 +932,7 @@ var PPT_THUMB_WIDTH_PX = 128;
915
932
  var PPT_THUMB_MARGIN_BOTTOM_PX = 8;
916
933
  var PPT_THUMB_OVERSCAN = 2;
917
934
  var PPT_THUMB_RASTER_SCALE = 2;
935
+ var PPT_THUMB_LAYOUT_SCALE = 4;
918
936
  function renderNativePptEditor(host, view, options = {}) {
919
937
  return new NativePptEditorController(host, view, options);
920
938
  }
@@ -1076,7 +1094,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1076
1094
  __publicField(this, "pendingCommands", /* @__PURE__ */ new Set());
1077
1095
  this.options = options;
1078
1096
  this.root = options.styleIsolation === "none" ? host : host.attachShadow({ mode: "open" });
1079
- this.sessionValue = new PptEditorSession(view);
1097
+ this.sessionValue = new PptEditorSession(view, { readOnly: options.readOnly });
1080
1098
  this.imageResources = view.images;
1081
1099
  this.fontResources = view.fonts;
1082
1100
  this.referencedFontFamilies = usedFontFamiliesInView(view);
@@ -1101,6 +1119,23 @@ var _NativePptEditorController = class _NativePptEditorController {
1101
1119
  selection() {
1102
1120
  return this.sessionValue.selection();
1103
1121
  }
1122
+ isReadOnly() {
1123
+ return this.sessionValue.isReadOnly();
1124
+ }
1125
+ setReadOnly(readOnly) {
1126
+ if (this.isReadOnly() === readOnly) return;
1127
+ const editable = this.root.querySelector('[contenteditable="true"]');
1128
+ editable == null ? void 0 : editable.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
1129
+ if (this.dragState) {
1130
+ this.restoreDragElementBounds(this.dragState);
1131
+ this.clearDragVisualState(this.dragState.element, true);
1132
+ this.dragState = null;
1133
+ this.hideSnapGuides();
1134
+ }
1135
+ this.hideContextMenu();
1136
+ this.sessionValue.setReadOnly(readOnly);
1137
+ this.render();
1138
+ }
1104
1139
  async dispatch(command) {
1105
1140
  const pending = this.dispatchAndRender(command);
1106
1141
  this.pendingCommands.add(pending);
@@ -1170,6 +1205,8 @@ var _NativePptEditorController = class _NativePptEditorController {
1170
1205
  ${fontFaceCss(this.fontResources)}
1171
1206
  :host, .coco-ppt-editor { box-sizing: border-box; width: 100%; height: 100%; min-height: 360px; }
1172
1207
  .coco-ppt-editor { display: grid; grid-template-columns: 160px minmax(0, 1fr); background: #f4f6f8; color: #17202a; font: 13px/1.4 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
1208
+ .coco-ppt-editor[data-show-slide-list="false"] { grid-template-columns: minmax(0, 1fr); }
1209
+ .coco-ppt-editor[data-show-slide-list="false"] .coco-ppt-slides { display: none; }
1173
1210
  .coco-ppt-slides { overflow: auto; border-right: 1px solid #d7dde5; background: #edf1f5; padding: 8px; }
1174
1211
  .coco-ppt-thumb { width: 128px; aspect-ratio: 16 / 9; margin: 0 0 8px; border: 1px solid #c7d0dc; background: #fff; display: block; position: relative; overflow: hidden; cursor: pointer; padding: 0; }
1175
1212
  .coco-ppt-thumb[data-selected="true"] { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18); }
@@ -1199,6 +1236,11 @@ var _NativePptEditorController = class _NativePptEditorController {
1199
1236
  .coco-ppt-table td[contenteditable="true"] { cursor: text; outline: 2px solid #2563eb; outline-offset: -2px; }
1200
1237
  .coco-ppt-node[contenteditable="true"] { cursor: text; outline: 2px solid rgba(37, 99, 235, 0.3); user-select: text; }
1201
1238
  .coco-ppt-text-layer[contenteditable="true"] { cursor: text; outline: 2px solid rgba(37, 99, 235, 0.3); user-select: text; }
1239
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-node,
1240
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-text-layer,
1241
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-rich-text,
1242
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-paragraph { user-select: text; cursor: text; }
1243
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-resize-handle { display: none !important; }
1202
1244
  .coco-ppt-node[data-kind="picture"] { background: transparent; }
1203
1245
  .coco-ppt-unsupported-image { position: absolute; inset: 0; display: grid; place-items: center; box-sizing: border-box; border: 1px dashed rgba(100, 116, 139, 0.48); background: repeating-linear-gradient(135deg, rgba(148, 163, 184, 0.12) 0 8px, rgba(248, 250, 252, 0.1) 8px 16px); color: rgba(51, 65, 85, 0.72); font: 11px/1.2 "Segoe UI", sans-serif; pointer-events: none; }
1204
1246
  .coco-ppt-thumb-node .coco-ppt-unsupported-image { font-size: 8px; border-width: 0.5px; }
@@ -1235,6 +1277,8 @@ var _NativePptEditorController = class _NativePptEditorController {
1235
1277
  `;
1236
1278
  const shell = document.createElement("div");
1237
1279
  shell.className = "coco-ppt-editor";
1280
+ shell.dataset.showSlideList = String(this.options.showSlideList !== false);
1281
+ shell.dataset.readOnly = String(this.isReadOnly());
1238
1282
  this.slideList.className = "coco-ppt-slides";
1239
1283
  const stage = document.createElement("div");
1240
1284
  stage.className = "coco-ppt-stage";
@@ -1273,9 +1317,11 @@ var _NativePptEditorController = class _NativePptEditorController {
1273
1317
  });
1274
1318
  }
1275
1319
  render() {
1320
+ const shell = this.root.querySelector(".coco-ppt-editor");
1321
+ if (shell) shell.dataset.readOnly = String(this.isReadOnly());
1276
1322
  const scene = this.sessionValue.scene();
1277
1323
  this.slideList.replaceChildren(
1278
- ...scene.slides.map((slide) => {
1324
+ ...this.options.showSlideList === false ? [] : scene.slides.map((slide) => {
1279
1325
  var _a;
1280
1326
  const thumb = document.createElement("button");
1281
1327
  thumb.className = "coco-ppt-thumb";
@@ -1298,7 +1344,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1298
1344
  return thumb;
1299
1345
  })
1300
1346
  );
1301
- this.renderVisibleThumbnails(scene.slides);
1347
+ if (this.options.showSlideList !== false) this.renderVisibleThumbnails(scene.slides);
1302
1348
  const selected = this.currentSlide();
1303
1349
  if (!selected) {
1304
1350
  this.canvas.replaceChildren();
@@ -1367,9 +1413,11 @@ var _NativePptEditorController = class _NativePptEditorController {
1367
1413
  renderThumbnailSlide(slide) {
1368
1414
  const wrapper = document.createElement("div");
1369
1415
  wrapper.className = "coco-ppt-thumb-slide";
1370
- const scale = PPT_THUMB_WIDTH_PX / slide.size.width;
1416
+ const layoutWidth = PPT_THUMB_WIDTH_PX * PPT_THUMB_LAYOUT_SCALE;
1417
+ const scale = layoutWidth / slide.size.width;
1371
1418
  wrapper.style.width = `${slide.size.width * scale}px`;
1372
1419
  wrapper.style.height = `${slide.size.height * scale}px`;
1420
+ wrapper.style.transform = `scale(${1 / PPT_THUMB_LAYOUT_SCALE})`;
1373
1421
  wrapper.style.background = cssBackground(slide.background, this.imageResources);
1374
1422
  wrapper.replaceChildren(
1375
1423
  ...slide.nodes.map((node) => this.renderNode(node, scale, slide, false))
@@ -1391,7 +1439,9 @@ var _NativePptEditorController = class _NativePptEditorController {
1391
1439
  PPT_THUMB_WIDTH_PX,
1392
1440
  PPT_THUMB_WIDTH_PX * (slide.size.height / slide.size.width),
1393
1441
  PPT_THUMB_RASTER_SCALE,
1394
- (_b = (_a = this.root.querySelector("style")) == null ? void 0 : _a.textContent) != null ? _b : ""
1442
+ (_b = (_a = this.root.querySelector("style")) == null ? void 0 : _a.textContent) != null ? _b : "",
1443
+ PPT_THUMB_WIDTH_PX * PPT_THUMB_LAYOUT_SCALE,
1444
+ PPT_THUMB_WIDTH_PX * PPT_THUMB_LAYOUT_SCALE * (slide.size.height / slide.size.width)
1395
1445
  );
1396
1446
  if (!canvas) return;
1397
1447
  if (epoch !== this.thumbnailRasterEpoch || !thumb.isConnected) return;
@@ -1426,8 +1476,8 @@ var _NativePptEditorController = class _NativePptEditorController {
1426
1476
  element.dataset.kind = node.kind;
1427
1477
  element.dataset.locked = String(node.locked);
1428
1478
  if (interactive) {
1429
- element.dataset.draggable = String(node.capabilities.editGeometry);
1430
- element.dataset.resizable = String(node.capabilities.editGeometry);
1479
+ element.dataset.draggable = String(!this.isReadOnly() && node.capabilities.editGeometry);
1480
+ element.dataset.resizable = String(!this.isReadOnly() && node.capabilities.editGeometry);
1431
1481
  element.dataset.shapeId = node.id;
1432
1482
  }
1433
1483
  element.style.left = `${node.bounds.left * scale - (lineNode && lineAxis === "vertical" ? nodeWidth / 2 : 0)}px`;
@@ -1507,6 +1557,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1507
1557
  });
1508
1558
  });
1509
1559
  table.addEventListener("dblclick", (event) => {
1560
+ if (this.isReadOnly()) return;
1510
1561
  const cell = tableCellFromEvent(event);
1511
1562
  if (!cell || !node.capabilities.editTableCells) return;
1512
1563
  event.stopPropagation();
@@ -1560,7 +1611,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1560
1611
  const handle = document.createElement("div");
1561
1612
  handle.className = "coco-ppt-resize-handle";
1562
1613
  handle.addEventListener("mousedown", (event) => {
1563
- if (!node.capabilities.editGeometry) return;
1614
+ if (this.isReadOnly() || !node.capabilities.editGeometry) return;
1564
1615
  event.preventDefault();
1565
1616
  event.stopPropagation();
1566
1617
  this.startDrag(event, "resize", slide, node, scale, element);
@@ -1615,6 +1666,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1615
1666
  });
1616
1667
  element.addEventListener("contextmenu", (event) => {
1617
1668
  var _a2;
1669
+ if (this.isReadOnly()) return;
1618
1670
  event.preventDefault();
1619
1671
  event.stopPropagation();
1620
1672
  const targetNode = (_a2 = this.pointerOperationNode(slide, node, event, scale)) != null ? _a2 : node;
@@ -1628,7 +1680,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1628
1680
  var _a2, _b2;
1629
1681
  const targetNode = (_a2 = this.pointerOperationNode(slide, node, event, scale)) != null ? _a2 : node;
1630
1682
  const targetElement = (_b2 = elementForShape(this.canvas, targetNode.id)) != null ? _b2 : element;
1631
- if (isEditingText(targetElement, event.target) || event.button !== 0 || !targetNode.capabilities.editGeometry)
1683
+ if (isEditingText(targetElement, event.target) || this.isReadOnly() || event.button !== 0 || !targetNode.capabilities.editGeometry)
1632
1684
  return;
1633
1685
  event.preventDefault();
1634
1686
  event.stopPropagation();
@@ -1636,6 +1688,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1636
1688
  });
1637
1689
  element.addEventListener("dblclick", (event) => {
1638
1690
  var _a2, _b2, _c2;
1691
+ if (this.isReadOnly()) return;
1639
1692
  event.stopPropagation();
1640
1693
  const redirectedNode = redirectedEditableTextHit(slide, node, event, scale);
1641
1694
  if (redirectedNode) {
@@ -1714,6 +1767,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1714
1767
  }
1715
1768
  startTextEdit(element, slide, node) {
1716
1769
  var _a, _b, _c, _d;
1770
+ if (this.isReadOnly()) return;
1717
1771
  const originalText = (_a = node.text) != null ? _a : "";
1718
1772
  const editableTarget = editableTextTarget(element);
1719
1773
  let finished = false;
@@ -1806,6 +1860,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1806
1860
  }
1807
1861
  startTableCellEdit(cell, slide, node, row, column) {
1808
1862
  var _a, _b, _c;
1863
+ if (this.isReadOnly()) return;
1809
1864
  const originalText = tableCellRawText(cell, node, row, column);
1810
1865
  let finished = false;
1811
1866
  void this.sessionValue.dispatch({ kind: "select-shape", slideIdOrIndex: slide.id, shapeIdOrName: node.id }).then(() => this.renderSelection());
@@ -1886,6 +1941,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1886
1941
  cell.addEventListener("paste", handlePaste);
1887
1942
  }
1888
1943
  startDrag(event, mode, slide, node, scale, element) {
1944
+ if (this.isReadOnly()) return;
1889
1945
  if (mode === "resize") prepareTextResizePreview(element, node);
1890
1946
  this.dragState = {
1891
1947
  mode,
@@ -2191,6 +2247,7 @@ var _NativePptEditorController = class _NativePptEditorController {
2191
2247
  const node = slide == null ? void 0 : slide.nodes.find((item) => item.id === selection.shapeId);
2192
2248
  if (!slide || !node) return;
2193
2249
  const commandKey = event.ctrlKey || event.metaKey;
2250
+ if (this.isReadOnly()) return;
2194
2251
  if (commandKey && event.key.toLowerCase() === "c") {
2195
2252
  event.preventDefault();
2196
2253
  this.copySelectedShape(slide, node);
@@ -2249,6 +2306,7 @@ var _NativePptEditorController = class _NativePptEditorController {
2249
2306
  });
2250
2307
  }
2251
2308
  handleSelectStart(event) {
2309
+ if (this.isReadOnly()) return;
2252
2310
  if (isTypingTarget(event.target)) return;
2253
2311
  if (event.target instanceof HTMLElement && event.target.closest('[contenteditable="true"]'))
2254
2312
  return;
@@ -2343,6 +2401,7 @@ var _NativePptEditorController = class _NativePptEditorController {
2343
2401
  });
2344
2402
  }
2345
2403
  showContextMenu(event, slide, node) {
2404
+ if (this.isReadOnly()) return;
2346
2405
  const editable = isShapeCollectionEditable(node);
2347
2406
  const hasClipboard = Boolean(this.clipboardShape);
2348
2407
  const run = /* @__PURE__ */ __name((action) => () => {
@@ -2542,7 +2601,7 @@ function nextAnimationFrame() {
2542
2601
  return new Promise((resolve) => requestAnimationFrame(() => resolve()));
2543
2602
  }
2544
2603
  __name(nextAnimationFrame, "nextAnimationFrame");
2545
- async function rasterizeThumbnailElement(element, width, height, scale, cssText) {
2604
+ async function rasterizeThumbnailElement(element, width, height, scale, cssText, layoutWidth = width, layoutHeight = height) {
2546
2605
  if (typeof XMLSerializer === "undefined" || typeof Blob === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function")
2547
2606
  return null;
2548
2607
  await waitForThumbnailImages(element);
@@ -2553,8 +2612,8 @@ async function rasterizeThumbnailElement(element, width, height, scale, cssText)
2553
2612
  if (!context) return null;
2554
2613
  const wrapper = document.createElement("div");
2555
2614
  wrapper.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
2556
- wrapper.style.width = `${width}px`;
2557
- wrapper.style.height = `${height}px`;
2615
+ wrapper.style.width = `${layoutWidth}px`;
2616
+ wrapper.style.height = `${layoutHeight}px`;
2558
2617
  wrapper.style.position = "relative";
2559
2618
  wrapper.style.overflow = "hidden";
2560
2619
  wrapper.style.background = "#fff";
@@ -2565,9 +2624,10 @@ async function rasterizeThumbnailElement(element, width, height, scale, cssText)
2565
2624
  clone.style.position = "relative";
2566
2625
  clone.style.left = "0";
2567
2626
  clone.style.top = "0";
2627
+ clone.style.transform = "none";
2568
2628
  wrapper.append(style, clone);
2569
2629
  const serialized = new XMLSerializer().serializeToString(wrapper);
2570
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${canvas.width}" height="${canvas.height}" viewBox="0 0 ${width} ${height}"><foreignObject width="100%" height="100%">${serialized}</foreignObject></svg>`;
2630
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${canvas.width}" height="${canvas.height}" viewBox="0 0 ${layoutWidth} ${layoutHeight}"><foreignObject width="100%" height="100%">${serialized}</foreignObject></svg>`;
2571
2631
  const url = URL.createObjectURL(new Blob([svg], { type: "image/svg+xml;charset=utf-8" }));
2572
2632
  try {
2573
2633
  const image = await loadRasterImage(url);
@@ -2937,13 +2997,9 @@ function googleFontCssUrl(family) {
2937
2997
  }
2938
2998
  __name(googleFontCssUrl, "googleFontCssUrl");
2939
2999
  function cssFontFamilyStack(family) {
2940
- return [
2941
- cssString(family),
2942
- '"Calibri"',
2943
- '"Microsoft YaHei"',
2944
- '"Segoe UI"',
2945
- "sans-serif"
2946
- ].join(", ");
3000
+ return [cssString(family), '"Calibri"', '"Microsoft YaHei"', '"Segoe UI"', "sans-serif"].join(
3001
+ ", "
3002
+ );
2947
3003
  }
2948
3004
  __name(cssFontFamilyStack, "cssFontFamilyStack");
2949
3005
  function cssString(value) {
@@ -3446,8 +3502,7 @@ __name(firstExplicitFontSize, "firstExplicitFontSize");
3446
3502
  function applyTextStyleToElement(element, style, scale) {
3447
3503
  var _a, _b, _c;
3448
3504
  if (style.fontSize) element.style.fontSize = `${Math.max(1, style.fontSize * 12700 * scale)}px`;
3449
- if (style.fontFamily)
3450
- element.style.fontFamily = cssFontFamilyStack(style.fontFamily);
3505
+ if (style.fontFamily) element.style.fontFamily = cssFontFamilyStack(style.fontFamily);
3451
3506
  if (style.lineHeight) element.style.lineHeight = String(style.lineHeight);
3452
3507
  if (style.characterSpacing !== void 0)
3453
3508
  element.style.letterSpacing = `${style.characterSpacing * 12700 * scale}px`;
@@ -3742,7 +3797,10 @@ function renderPresetGeometry(node, scale) {
3742
3797
  const fillOpacity = effectiveFillOpacity(node);
3743
3798
  if (fillOpacity !== void 0 && node.presetGeometry !== "arc")
3744
3799
  path.setAttribute("fill-opacity", String(fillOpacity));
3745
- path.setAttribute("stroke", lineGradientId ? `url(#${lineGradientId})` : (_c = node.lineColor) != null ? _c : "none");
3800
+ path.setAttribute(
3801
+ "stroke",
3802
+ lineGradientId ? `url(#${lineGradientId})` : (_c = node.lineColor) != null ? _c : "none"
3803
+ );
3746
3804
  path.setAttribute("stroke-width", String(strokeWidth));
3747
3805
  if (node.lineOpacity !== void 0)
3748
3806
  path.setAttribute("stroke-opacity", String(Math.max(0, Math.min(1, node.lineOpacity))));
@@ -3956,14 +4014,18 @@ function customGeometryIsRectangular(geometry) {
3956
4014
  { x: 0, y: height }
3957
4015
  ];
3958
4016
  return corners.every(
3959
- (corner) => unique.some((point) => geometryPointNear(point.x, corner.x) && geometryPointNear(point.y, corner.y))
4017
+ (corner) => unique.some(
4018
+ (point) => geometryPointNear(point.x, corner.x) && geometryPointNear(point.y, corner.y)
4019
+ )
3960
4020
  );
3961
4021
  }
3962
4022
  __name(customGeometryIsRectangular, "customGeometryIsRectangular");
3963
4023
  function dedupeGeometryPoints(points) {
3964
4024
  const result = [];
3965
4025
  for (const point of points) {
3966
- if (!result.some((existing) => geometryPointNear(existing.x, point.x) && geometryPointNear(existing.y, point.y))) {
4026
+ if (!result.some(
4027
+ (existing) => geometryPointNear(existing.x, point.x) && geometryPointNear(existing.y, point.y)
4028
+ )) {
3967
4029
  result.push(point);
3968
4030
  }
3969
4031
  }
@@ -3989,7 +4051,8 @@ function renderCustomGeometryPicture(node, url) {
3989
4051
  for (const path of (_h = (_g = node.customGeometry) == null ? void 0 : _g.paths) != null ? _h : []) {
3990
4052
  const clipShape = document.createElementNS("http://www.w3.org/2000/svg", "path");
3991
4053
  clipShape.setAttribute("d", customGeometryPathData(path.commands));
3992
- if (customGeometryNeedsEvenOddFill(path.commands)) clipShape.setAttribute("fill-rule", "evenodd");
4054
+ if (customGeometryNeedsEvenOddFill(path.commands))
4055
+ clipShape.setAttribute("fill-rule", "evenodd");
3993
4056
  clipPath.append(clipShape);
3994
4057
  }
3995
4058
  defs.append(clipPath);
@@ -4074,7 +4137,10 @@ function renderCustomGeometry(node, scale) {
4074
4137
  const fillOpacity = effectiveFillOpacity(node);
4075
4138
  if (hasFill && fillOpacity !== void 0)
4076
4139
  shape.setAttribute("fill-opacity", String(fillOpacity));
4077
- shape.setAttribute("stroke", lineGradientId ? `url(#${lineGradientId})` : (_j = node.lineColor) != null ? _j : "none");
4140
+ shape.setAttribute(
4141
+ "stroke",
4142
+ lineGradientId ? `url(#${lineGradientId})` : (_j = node.lineColor) != null ? _j : "none"
4143
+ );
4078
4144
  shape.setAttribute("stroke-width", String(strokeWidth));
4079
4145
  if (node.lineOpacity !== void 0)
4080
4146
  shape.setAttribute("stroke-opacity", String(Math.max(0, Math.min(1, node.lineOpacity))));
@@ -4098,13 +4164,7 @@ function customGeometryEllipse(path) {
4098
4164
  }
4099
4165
  const cx = width / 2;
4100
4166
  const cy = height / 2;
4101
- const endpoints = [
4102
- commands[0],
4103
- commands[1],
4104
- commands[2],
4105
- commands[3],
4106
- commands[4]
4107
- ];
4167
+ const endpoints = [commands[0], commands[1], commands[2], commands[3], commands[4]];
4108
4168
  const expected = [
4109
4169
  { x: width, y: cy },
4110
4170
  { x: cx, y: height },
@@ -4278,7 +4338,9 @@ function customGeometryPathData(commands) {
4278
4338
  parts.push(`L ${command.x} ${command.y}`);
4279
4339
  current = { x: command.x, y: command.y };
4280
4340
  } else if (command.kind === "cubicBezierTo") {
4281
- parts.push(`C ${command.x1} ${command.y1} ${command.x2} ${command.y2} ${command.x} ${command.y}`);
4341
+ parts.push(
4342
+ `C ${command.x1} ${command.y1} ${command.x2} ${command.y2} ${command.x} ${command.y}`
4343
+ );
4282
4344
  current = { x: command.x, y: command.y };
4283
4345
  } else if (command.kind === "arcTo") {
4284
4346
  const arc = svgArcCommandForCustomGeometry(command, current);
@@ -5022,7 +5084,15 @@ function renderLineValueLabels(svg, seriesList, plot, min, max) {
5022
5084
  series.values.forEach((value, pointIndex) => {
5023
5085
  const x = plot.left + (series.values.length === 1 ? plot.width / 2 : plot.width * pointIndex / (series.values.length - 1));
5024
5086
  const y = plot.top + plot.height - (value - min) / Math.max(1, max - min) * plot.height;
5025
- appendSvgText(svg, String(value), x, Math.max(plot.top + 2, y - 2.2), 2.6, "#374151", "middle");
5087
+ appendSvgText(
5088
+ svg,
5089
+ String(value),
5090
+ x,
5091
+ Math.max(plot.top + 2, y - 2.2),
5092
+ 2.6,
5093
+ "#374151",
5094
+ "middle"
5095
+ );
5026
5096
  });
5027
5097
  });
5028
5098
  }