@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
@@ -1,2 +1,2 @@
1
- export { NativePptEditor, NativePptEditorOptions, renderNativePptEditor } from './ppt.cjs';
1
+ export { N as NativePptEditor, a as NativePptEditorOptions, I as renderNativePptEditor } from './native-TMv552dv.cjs';
2
2
  import '@coco-vexel/coco-office/ppt';
@@ -1,2 +1,2 @@
1
- export { NativePptEditor, NativePptEditorOptions, renderNativePptEditor } from './ppt.js';
1
+ export { N as NativePptEditor, a as NativePptEditorOptions, I as renderNativePptEditor } from './native-TMv552dv.js';
2
2
  import '@coco-vexel/coco-office/ppt';
@@ -1,4 +1,4 @@
1
- import { Presentation } from '@coco-vexel/coco-office/ppt';
1
+ import { resolvePptEffectivePlaceholderProperties, Presentation } from '@coco-vexel/coco-office/ppt';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __defProps = Object.defineProperties;
@@ -33,8 +33,6 @@ var __objRest = (source, exclude) => {
33
33
  return target;
34
34
  };
35
35
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
-
37
- // src/ppt/scene.ts
38
36
  var DEFAULT_PPT_SLIDE_SIZE = {
39
37
  width: 9144e3,
40
38
  height: 5143500
@@ -66,7 +64,7 @@ function buildPptSlideScene(slide, fallbackSize) {
66
64
  ].filter(shouldRenderInheritedShape);
67
65
  const shapes = [
68
66
  ...inheritedShapes,
69
- ...slide.shapes.map((shape) => applyPlaceholderInheritance(shape, layoutShapes))
67
+ ...slide.shapes.map((shape) => applyPlaceholderInheritance(shape, slide.layout))
70
68
  ];
71
69
  const renderShapes = shapes.flatMap(flattenRenderableShape);
72
70
  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;
@@ -207,28 +205,21 @@ function normalizeRotation(rotation) {
207
205
  return normalized === 0 ? void 0 : normalized;
208
206
  }
209
207
  __name(normalizeRotation, "normalizeRotation");
210
- function applyPlaceholderInheritance(shape, layoutShapes) {
211
- var _a;
212
- if (!shape.placeholder || !shape.text) return shape;
213
- const layoutShape = layoutShapes.find((candidate) => samePlaceholder(shape, candidate));
214
- const inheritedStyle = (_a = layoutShape == null ? void 0 : layoutShape.text) == null ? void 0 : _a.style;
215
- if (!inheritedStyle && !layoutShape) return shape;
216
- return __spreadProps(__spreadValues({}, shape), {
217
- geometry: __spreadValues(__spreadValues({}, layoutShape == null ? void 0 : layoutShape.geometry), shape.geometry),
208
+ function applyPlaceholderInheritance(shape, layout) {
209
+ if (!shape.placeholder) return shape;
210
+ const effective = resolvePptEffectivePlaceholderProperties(shape, layout);
211
+ return __spreadValues(__spreadProps(__spreadValues({}, shape), {
212
+ placeholder: effective.placeholder,
213
+ geometry: effective.geometry,
214
+ style: effective.style
215
+ }), shape.text ? {
218
216
  text: __spreadProps(__spreadValues({}, shape.text), {
219
- style: __spreadValues(__spreadValues({}, inheritedStyle), shape.text.style)
217
+ style: effective.textStyle,
218
+ body: effective.textBody
220
219
  })
221
- });
220
+ } : {});
222
221
  }
223
222
  __name(applyPlaceholderInheritance, "applyPlaceholderInheritance");
224
- function samePlaceholder(shape, candidate) {
225
- var _a, _b;
226
- if (!candidate.placeholder) return false;
227
- if (((_a = shape.placeholder) == null ? void 0 : _a.index) && candidate.placeholder.index === shape.placeholder.index)
228
- return true;
229
- return Boolean(((_b = shape.placeholder) == null ? void 0 : _b.type) && candidate.placeholder.type === shape.placeholder.type);
230
- }
231
- __name(samePlaceholder, "samePlaceholder");
232
223
  function buildPptSceneNode(shape, options = {}) {
233
224
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
234
225
  const capabilities = pptSceneNodeCapabilities(shape);
@@ -586,6 +577,17 @@ function findPptSceneNode(slide, shapeIdOrName) {
586
577
  }
587
578
  __name(findPptSceneNode, "findPptSceneNode");
588
579
 
580
+ // src/read-only.ts
581
+ var _EditorReadOnlyError = class _EditorReadOnlyError extends Error {
582
+ constructor(editor) {
583
+ super(`${editor} editor is read-only`);
584
+ __publicField(this, "code", "EDITOR_READ_ONLY");
585
+ this.name = "EditorReadOnlyError";
586
+ }
587
+ };
588
+ __name(_EditorReadOnlyError, "EditorReadOnlyError");
589
+ var EditorReadOnlyError = _EditorReadOnlyError;
590
+
589
591
  // src/ppt/session.ts
590
592
  var _PptEditorSession = class _PptEditorSession {
591
593
  constructor(view, options = {}) {
@@ -598,6 +600,7 @@ var _PptEditorSession = class _PptEditorSession {
598
600
  __publicField(this, "redoStack", []);
599
601
  __publicField(this, "textBodyOverrides", /* @__PURE__ */ new Map());
600
602
  __publicField(this, "maxHistory");
603
+ __publicField(this, "readOnlyValue");
601
604
  __publicField(this, "changeListeners", /* @__PURE__ */ new Set());
602
605
  __publicField(this, "selectionListeners", /* @__PURE__ */ new Set());
603
606
  var _a;
@@ -605,9 +608,11 @@ var _PptEditorSession = class _PptEditorSession {
605
608
  this.modelValue = view.model;
606
609
  this.sceneValue = view.scene;
607
610
  this.maxHistory = (_a = options.maxHistory) != null ? _a : 50;
611
+ this.readOnlyValue = options.readOnly === true;
608
612
  this.selectionValue = view.scene.slides[0] ? { kind: "slide", slideId: view.scene.slides[0].id } : null;
609
613
  }
610
614
  presentation() {
615
+ this.assertWritable();
611
616
  return this.presentationValue;
612
617
  }
613
618
  model() {
@@ -622,11 +627,17 @@ var _PptEditorSession = class _PptEditorSession {
622
627
  revision() {
623
628
  return this.revisionValue;
624
629
  }
630
+ isReadOnly() {
631
+ return this.readOnlyValue;
632
+ }
633
+ setReadOnly(readOnly) {
634
+ this.readOnlyValue = readOnly;
635
+ }
625
636
  canUndo() {
626
- return this.undoStack.length > 0;
637
+ return !this.readOnlyValue && this.undoStack.length > 0;
627
638
  }
628
639
  canRedo() {
629
- return this.redoStack.length > 0;
640
+ return !this.readOnlyValue && this.redoStack.length > 0;
630
641
  }
631
642
  subscribe(event, listener) {
632
643
  const listeners = event === "change" ? this.changeListeners : this.selectionListeners;
@@ -642,6 +653,7 @@ var _PptEditorSession = class _PptEditorSession {
642
653
  await this.applySelectionCommand(command);
643
654
  return;
644
655
  }
656
+ this.assertWritable();
645
657
  const before = await this.presentationValue.toZip();
646
658
  const nextSelection = await this.applyEditCommand(command);
647
659
  this.pushUndo(before);
@@ -650,6 +662,7 @@ var _PptEditorSession = class _PptEditorSession {
650
662
  if (nextSelection !== void 0) this.setSelection(nextSelection);
651
663
  }
652
664
  async undo() {
665
+ this.assertWritable();
653
666
  const entry = this.undoStack.pop();
654
667
  if (!entry) return;
655
668
  const selection = this.selectionValue;
@@ -658,6 +671,7 @@ var _PptEditorSession = class _PptEditorSession {
658
671
  await this.replacePresentation(entry.bytes, selection);
659
672
  }
660
673
  async redo() {
674
+ this.assertWritable();
661
675
  const entry = this.redoStack.pop();
662
676
  if (!entry) return;
663
677
  const selection = this.selectionValue;
@@ -690,6 +704,9 @@ var _PptEditorSession = class _PptEditorSession {
690
704
  this.changeListeners.clear();
691
705
  this.selectionListeners.clear();
692
706
  }
707
+ assertWritable() {
708
+ if (this.readOnlyValue) throw new EditorReadOnlyError("ppt");
709
+ }
693
710
  async applySelectionCommand(command) {
694
711
  const slide = findPptSceneSlide(this.sceneValue, command.slideIdOrIndex);
695
712
  if (!slide) throw new Error(`PPT slide not found: ${String(command.slideIdOrIndex)}`);
@@ -913,6 +930,7 @@ var PPT_THUMB_WIDTH_PX = 128;
913
930
  var PPT_THUMB_MARGIN_BOTTOM_PX = 8;
914
931
  var PPT_THUMB_OVERSCAN = 2;
915
932
  var PPT_THUMB_RASTER_SCALE = 2;
933
+ var PPT_THUMB_LAYOUT_SCALE = 4;
916
934
  function renderNativePptEditor(host, view, options = {}) {
917
935
  return new NativePptEditorController(host, view, options);
918
936
  }
@@ -1074,7 +1092,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1074
1092
  __publicField(this, "pendingCommands", /* @__PURE__ */ new Set());
1075
1093
  this.options = options;
1076
1094
  this.root = options.styleIsolation === "none" ? host : host.attachShadow({ mode: "open" });
1077
- this.sessionValue = new PptEditorSession(view);
1095
+ this.sessionValue = new PptEditorSession(view, { readOnly: options.readOnly });
1078
1096
  this.imageResources = view.images;
1079
1097
  this.fontResources = view.fonts;
1080
1098
  this.referencedFontFamilies = usedFontFamiliesInView(view);
@@ -1099,6 +1117,23 @@ var _NativePptEditorController = class _NativePptEditorController {
1099
1117
  selection() {
1100
1118
  return this.sessionValue.selection();
1101
1119
  }
1120
+ isReadOnly() {
1121
+ return this.sessionValue.isReadOnly();
1122
+ }
1123
+ setReadOnly(readOnly) {
1124
+ if (this.isReadOnly() === readOnly) return;
1125
+ const editable = this.root.querySelector('[contenteditable="true"]');
1126
+ editable == null ? void 0 : editable.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape", bubbles: true, cancelable: true }));
1127
+ if (this.dragState) {
1128
+ this.restoreDragElementBounds(this.dragState);
1129
+ this.clearDragVisualState(this.dragState.element, true);
1130
+ this.dragState = null;
1131
+ this.hideSnapGuides();
1132
+ }
1133
+ this.hideContextMenu();
1134
+ this.sessionValue.setReadOnly(readOnly);
1135
+ this.render();
1136
+ }
1102
1137
  async dispatch(command) {
1103
1138
  const pending = this.dispatchAndRender(command);
1104
1139
  this.pendingCommands.add(pending);
@@ -1168,6 +1203,8 @@ var _NativePptEditorController = class _NativePptEditorController {
1168
1203
  ${fontFaceCss(this.fontResources)}
1169
1204
  :host, .coco-ppt-editor { box-sizing: border-box; width: 100%; height: 100%; min-height: 360px; }
1170
1205
  .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; }
1206
+ .coco-ppt-editor[data-show-slide-list="false"] { grid-template-columns: minmax(0, 1fr); }
1207
+ .coco-ppt-editor[data-show-slide-list="false"] .coco-ppt-slides { display: none; }
1171
1208
  .coco-ppt-slides { overflow: auto; border-right: 1px solid #d7dde5; background: #edf1f5; padding: 8px; }
1172
1209
  .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; }
1173
1210
  .coco-ppt-thumb[data-selected="true"] { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.18); }
@@ -1197,6 +1234,11 @@ var _NativePptEditorController = class _NativePptEditorController {
1197
1234
  .coco-ppt-table td[contenteditable="true"] { cursor: text; outline: 2px solid #2563eb; outline-offset: -2px; }
1198
1235
  .coco-ppt-node[contenteditable="true"] { cursor: text; outline: 2px solid rgba(37, 99, 235, 0.3); user-select: text; }
1199
1236
  .coco-ppt-text-layer[contenteditable="true"] { cursor: text; outline: 2px solid rgba(37, 99, 235, 0.3); user-select: text; }
1237
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-node,
1238
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-text-layer,
1239
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-rich-text,
1240
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-paragraph { user-select: text; cursor: text; }
1241
+ .coco-ppt-editor[data-read-only="true"] .coco-ppt-resize-handle { display: none !important; }
1200
1242
  .coco-ppt-node[data-kind="picture"] { background: transparent; }
1201
1243
  .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; }
1202
1244
  .coco-ppt-thumb-node .coco-ppt-unsupported-image { font-size: 8px; border-width: 0.5px; }
@@ -1233,6 +1275,8 @@ var _NativePptEditorController = class _NativePptEditorController {
1233
1275
  `;
1234
1276
  const shell = document.createElement("div");
1235
1277
  shell.className = "coco-ppt-editor";
1278
+ shell.dataset.showSlideList = String(this.options.showSlideList !== false);
1279
+ shell.dataset.readOnly = String(this.isReadOnly());
1236
1280
  this.slideList.className = "coco-ppt-slides";
1237
1281
  const stage = document.createElement("div");
1238
1282
  stage.className = "coco-ppt-stage";
@@ -1271,9 +1315,11 @@ var _NativePptEditorController = class _NativePptEditorController {
1271
1315
  });
1272
1316
  }
1273
1317
  render() {
1318
+ const shell = this.root.querySelector(".coco-ppt-editor");
1319
+ if (shell) shell.dataset.readOnly = String(this.isReadOnly());
1274
1320
  const scene = this.sessionValue.scene();
1275
1321
  this.slideList.replaceChildren(
1276
- ...scene.slides.map((slide) => {
1322
+ ...this.options.showSlideList === false ? [] : scene.slides.map((slide) => {
1277
1323
  var _a;
1278
1324
  const thumb = document.createElement("button");
1279
1325
  thumb.className = "coco-ppt-thumb";
@@ -1296,7 +1342,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1296
1342
  return thumb;
1297
1343
  })
1298
1344
  );
1299
- this.renderVisibleThumbnails(scene.slides);
1345
+ if (this.options.showSlideList !== false) this.renderVisibleThumbnails(scene.slides);
1300
1346
  const selected = this.currentSlide();
1301
1347
  if (!selected) {
1302
1348
  this.canvas.replaceChildren();
@@ -1365,9 +1411,11 @@ var _NativePptEditorController = class _NativePptEditorController {
1365
1411
  renderThumbnailSlide(slide) {
1366
1412
  const wrapper = document.createElement("div");
1367
1413
  wrapper.className = "coco-ppt-thumb-slide";
1368
- const scale = PPT_THUMB_WIDTH_PX / slide.size.width;
1414
+ const layoutWidth = PPT_THUMB_WIDTH_PX * PPT_THUMB_LAYOUT_SCALE;
1415
+ const scale = layoutWidth / slide.size.width;
1369
1416
  wrapper.style.width = `${slide.size.width * scale}px`;
1370
1417
  wrapper.style.height = `${slide.size.height * scale}px`;
1418
+ wrapper.style.transform = `scale(${1 / PPT_THUMB_LAYOUT_SCALE})`;
1371
1419
  wrapper.style.background = cssBackground(slide.background, this.imageResources);
1372
1420
  wrapper.replaceChildren(
1373
1421
  ...slide.nodes.map((node) => this.renderNode(node, scale, slide, false))
@@ -1389,7 +1437,9 @@ var _NativePptEditorController = class _NativePptEditorController {
1389
1437
  PPT_THUMB_WIDTH_PX,
1390
1438
  PPT_THUMB_WIDTH_PX * (slide.size.height / slide.size.width),
1391
1439
  PPT_THUMB_RASTER_SCALE,
1392
- (_b = (_a = this.root.querySelector("style")) == null ? void 0 : _a.textContent) != null ? _b : ""
1440
+ (_b = (_a = this.root.querySelector("style")) == null ? void 0 : _a.textContent) != null ? _b : "",
1441
+ PPT_THUMB_WIDTH_PX * PPT_THUMB_LAYOUT_SCALE,
1442
+ PPT_THUMB_WIDTH_PX * PPT_THUMB_LAYOUT_SCALE * (slide.size.height / slide.size.width)
1393
1443
  );
1394
1444
  if (!canvas) return;
1395
1445
  if (epoch !== this.thumbnailRasterEpoch || !thumb.isConnected) return;
@@ -1424,8 +1474,8 @@ var _NativePptEditorController = class _NativePptEditorController {
1424
1474
  element.dataset.kind = node.kind;
1425
1475
  element.dataset.locked = String(node.locked);
1426
1476
  if (interactive) {
1427
- element.dataset.draggable = String(node.capabilities.editGeometry);
1428
- element.dataset.resizable = String(node.capabilities.editGeometry);
1477
+ element.dataset.draggable = String(!this.isReadOnly() && node.capabilities.editGeometry);
1478
+ element.dataset.resizable = String(!this.isReadOnly() && node.capabilities.editGeometry);
1429
1479
  element.dataset.shapeId = node.id;
1430
1480
  }
1431
1481
  element.style.left = `${node.bounds.left * scale - (lineNode && lineAxis === "vertical" ? nodeWidth / 2 : 0)}px`;
@@ -1505,6 +1555,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1505
1555
  });
1506
1556
  });
1507
1557
  table.addEventListener("dblclick", (event) => {
1558
+ if (this.isReadOnly()) return;
1508
1559
  const cell = tableCellFromEvent(event);
1509
1560
  if (!cell || !node.capabilities.editTableCells) return;
1510
1561
  event.stopPropagation();
@@ -1558,7 +1609,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1558
1609
  const handle = document.createElement("div");
1559
1610
  handle.className = "coco-ppt-resize-handle";
1560
1611
  handle.addEventListener("mousedown", (event) => {
1561
- if (!node.capabilities.editGeometry) return;
1612
+ if (this.isReadOnly() || !node.capabilities.editGeometry) return;
1562
1613
  event.preventDefault();
1563
1614
  event.stopPropagation();
1564
1615
  this.startDrag(event, "resize", slide, node, scale, element);
@@ -1613,6 +1664,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1613
1664
  });
1614
1665
  element.addEventListener("contextmenu", (event) => {
1615
1666
  var _a2;
1667
+ if (this.isReadOnly()) return;
1616
1668
  event.preventDefault();
1617
1669
  event.stopPropagation();
1618
1670
  const targetNode = (_a2 = this.pointerOperationNode(slide, node, event, scale)) != null ? _a2 : node;
@@ -1626,7 +1678,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1626
1678
  var _a2, _b2;
1627
1679
  const targetNode = (_a2 = this.pointerOperationNode(slide, node, event, scale)) != null ? _a2 : node;
1628
1680
  const targetElement = (_b2 = elementForShape(this.canvas, targetNode.id)) != null ? _b2 : element;
1629
- if (isEditingText(targetElement, event.target) || event.button !== 0 || !targetNode.capabilities.editGeometry)
1681
+ if (isEditingText(targetElement, event.target) || this.isReadOnly() || event.button !== 0 || !targetNode.capabilities.editGeometry)
1630
1682
  return;
1631
1683
  event.preventDefault();
1632
1684
  event.stopPropagation();
@@ -1634,6 +1686,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1634
1686
  });
1635
1687
  element.addEventListener("dblclick", (event) => {
1636
1688
  var _a2, _b2, _c2;
1689
+ if (this.isReadOnly()) return;
1637
1690
  event.stopPropagation();
1638
1691
  const redirectedNode = redirectedEditableTextHit(slide, node, event, scale);
1639
1692
  if (redirectedNode) {
@@ -1712,6 +1765,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1712
1765
  }
1713
1766
  startTextEdit(element, slide, node) {
1714
1767
  var _a, _b, _c, _d;
1768
+ if (this.isReadOnly()) return;
1715
1769
  const originalText = (_a = node.text) != null ? _a : "";
1716
1770
  const editableTarget = editableTextTarget(element);
1717
1771
  let finished = false;
@@ -1804,6 +1858,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1804
1858
  }
1805
1859
  startTableCellEdit(cell, slide, node, row, column) {
1806
1860
  var _a, _b, _c;
1861
+ if (this.isReadOnly()) return;
1807
1862
  const originalText = tableCellRawText(cell, node, row, column);
1808
1863
  let finished = false;
1809
1864
  void this.sessionValue.dispatch({ kind: "select-shape", slideIdOrIndex: slide.id, shapeIdOrName: node.id }).then(() => this.renderSelection());
@@ -1884,6 +1939,7 @@ var _NativePptEditorController = class _NativePptEditorController {
1884
1939
  cell.addEventListener("paste", handlePaste);
1885
1940
  }
1886
1941
  startDrag(event, mode, slide, node, scale, element) {
1942
+ if (this.isReadOnly()) return;
1887
1943
  if (mode === "resize") prepareTextResizePreview(element, node);
1888
1944
  this.dragState = {
1889
1945
  mode,
@@ -2189,6 +2245,7 @@ var _NativePptEditorController = class _NativePptEditorController {
2189
2245
  const node = slide == null ? void 0 : slide.nodes.find((item) => item.id === selection.shapeId);
2190
2246
  if (!slide || !node) return;
2191
2247
  const commandKey = event.ctrlKey || event.metaKey;
2248
+ if (this.isReadOnly()) return;
2192
2249
  if (commandKey && event.key.toLowerCase() === "c") {
2193
2250
  event.preventDefault();
2194
2251
  this.copySelectedShape(slide, node);
@@ -2247,6 +2304,7 @@ var _NativePptEditorController = class _NativePptEditorController {
2247
2304
  });
2248
2305
  }
2249
2306
  handleSelectStart(event) {
2307
+ if (this.isReadOnly()) return;
2250
2308
  if (isTypingTarget(event.target)) return;
2251
2309
  if (event.target instanceof HTMLElement && event.target.closest('[contenteditable="true"]'))
2252
2310
  return;
@@ -2341,6 +2399,7 @@ var _NativePptEditorController = class _NativePptEditorController {
2341
2399
  });
2342
2400
  }
2343
2401
  showContextMenu(event, slide, node) {
2402
+ if (this.isReadOnly()) return;
2344
2403
  const editable = isShapeCollectionEditable(node);
2345
2404
  const hasClipboard = Boolean(this.clipboardShape);
2346
2405
  const run = /* @__PURE__ */ __name((action) => () => {
@@ -2540,7 +2599,7 @@ function nextAnimationFrame() {
2540
2599
  return new Promise((resolve) => requestAnimationFrame(() => resolve()));
2541
2600
  }
2542
2601
  __name(nextAnimationFrame, "nextAnimationFrame");
2543
- async function rasterizeThumbnailElement(element, width, height, scale, cssText) {
2602
+ async function rasterizeThumbnailElement(element, width, height, scale, cssText, layoutWidth = width, layoutHeight = height) {
2544
2603
  if (typeof XMLSerializer === "undefined" || typeof Blob === "undefined" || typeof URL === "undefined" || typeof URL.createObjectURL !== "function")
2545
2604
  return null;
2546
2605
  await waitForThumbnailImages(element);
@@ -2551,8 +2610,8 @@ async function rasterizeThumbnailElement(element, width, height, scale, cssText)
2551
2610
  if (!context) return null;
2552
2611
  const wrapper = document.createElement("div");
2553
2612
  wrapper.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
2554
- wrapper.style.width = `${width}px`;
2555
- wrapper.style.height = `${height}px`;
2613
+ wrapper.style.width = `${layoutWidth}px`;
2614
+ wrapper.style.height = `${layoutHeight}px`;
2556
2615
  wrapper.style.position = "relative";
2557
2616
  wrapper.style.overflow = "hidden";
2558
2617
  wrapper.style.background = "#fff";
@@ -2563,9 +2622,10 @@ async function rasterizeThumbnailElement(element, width, height, scale, cssText)
2563
2622
  clone.style.position = "relative";
2564
2623
  clone.style.left = "0";
2565
2624
  clone.style.top = "0";
2625
+ clone.style.transform = "none";
2566
2626
  wrapper.append(style, clone);
2567
2627
  const serialized = new XMLSerializer().serializeToString(wrapper);
2568
- 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>`;
2628
+ 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>`;
2569
2629
  const url = URL.createObjectURL(new Blob([svg], { type: "image/svg+xml;charset=utf-8" }));
2570
2630
  try {
2571
2631
  const image = await loadRasterImage(url);
@@ -2935,13 +2995,9 @@ function googleFontCssUrl(family) {
2935
2995
  }
2936
2996
  __name(googleFontCssUrl, "googleFontCssUrl");
2937
2997
  function cssFontFamilyStack(family) {
2938
- return [
2939
- cssString(family),
2940
- '"Calibri"',
2941
- '"Microsoft YaHei"',
2942
- '"Segoe UI"',
2943
- "sans-serif"
2944
- ].join(", ");
2998
+ return [cssString(family), '"Calibri"', '"Microsoft YaHei"', '"Segoe UI"', "sans-serif"].join(
2999
+ ", "
3000
+ );
2945
3001
  }
2946
3002
  __name(cssFontFamilyStack, "cssFontFamilyStack");
2947
3003
  function cssString(value) {
@@ -3444,8 +3500,7 @@ __name(firstExplicitFontSize, "firstExplicitFontSize");
3444
3500
  function applyTextStyleToElement(element, style, scale) {
3445
3501
  var _a, _b, _c;
3446
3502
  if (style.fontSize) element.style.fontSize = `${Math.max(1, style.fontSize * 12700 * scale)}px`;
3447
- if (style.fontFamily)
3448
- element.style.fontFamily = cssFontFamilyStack(style.fontFamily);
3503
+ if (style.fontFamily) element.style.fontFamily = cssFontFamilyStack(style.fontFamily);
3449
3504
  if (style.lineHeight) element.style.lineHeight = String(style.lineHeight);
3450
3505
  if (style.characterSpacing !== void 0)
3451
3506
  element.style.letterSpacing = `${style.characterSpacing * 12700 * scale}px`;
@@ -3740,7 +3795,10 @@ function renderPresetGeometry(node, scale) {
3740
3795
  const fillOpacity = effectiveFillOpacity(node);
3741
3796
  if (fillOpacity !== void 0 && node.presetGeometry !== "arc")
3742
3797
  path.setAttribute("fill-opacity", String(fillOpacity));
3743
- path.setAttribute("stroke", lineGradientId ? `url(#${lineGradientId})` : (_c = node.lineColor) != null ? _c : "none");
3798
+ path.setAttribute(
3799
+ "stroke",
3800
+ lineGradientId ? `url(#${lineGradientId})` : (_c = node.lineColor) != null ? _c : "none"
3801
+ );
3744
3802
  path.setAttribute("stroke-width", String(strokeWidth));
3745
3803
  if (node.lineOpacity !== void 0)
3746
3804
  path.setAttribute("stroke-opacity", String(Math.max(0, Math.min(1, node.lineOpacity))));
@@ -3954,14 +4012,18 @@ function customGeometryIsRectangular(geometry) {
3954
4012
  { x: 0, y: height }
3955
4013
  ];
3956
4014
  return corners.every(
3957
- (corner) => unique.some((point) => geometryPointNear(point.x, corner.x) && geometryPointNear(point.y, corner.y))
4015
+ (corner) => unique.some(
4016
+ (point) => geometryPointNear(point.x, corner.x) && geometryPointNear(point.y, corner.y)
4017
+ )
3958
4018
  );
3959
4019
  }
3960
4020
  __name(customGeometryIsRectangular, "customGeometryIsRectangular");
3961
4021
  function dedupeGeometryPoints(points) {
3962
4022
  const result = [];
3963
4023
  for (const point of points) {
3964
- if (!result.some((existing) => geometryPointNear(existing.x, point.x) && geometryPointNear(existing.y, point.y))) {
4024
+ if (!result.some(
4025
+ (existing) => geometryPointNear(existing.x, point.x) && geometryPointNear(existing.y, point.y)
4026
+ )) {
3965
4027
  result.push(point);
3966
4028
  }
3967
4029
  }
@@ -3987,7 +4049,8 @@ function renderCustomGeometryPicture(node, url) {
3987
4049
  for (const path of (_h = (_g = node.customGeometry) == null ? void 0 : _g.paths) != null ? _h : []) {
3988
4050
  const clipShape = document.createElementNS("http://www.w3.org/2000/svg", "path");
3989
4051
  clipShape.setAttribute("d", customGeometryPathData(path.commands));
3990
- if (customGeometryNeedsEvenOddFill(path.commands)) clipShape.setAttribute("fill-rule", "evenodd");
4052
+ if (customGeometryNeedsEvenOddFill(path.commands))
4053
+ clipShape.setAttribute("fill-rule", "evenodd");
3991
4054
  clipPath.append(clipShape);
3992
4055
  }
3993
4056
  defs.append(clipPath);
@@ -4072,7 +4135,10 @@ function renderCustomGeometry(node, scale) {
4072
4135
  const fillOpacity = effectiveFillOpacity(node);
4073
4136
  if (hasFill && fillOpacity !== void 0)
4074
4137
  shape.setAttribute("fill-opacity", String(fillOpacity));
4075
- shape.setAttribute("stroke", lineGradientId ? `url(#${lineGradientId})` : (_j = node.lineColor) != null ? _j : "none");
4138
+ shape.setAttribute(
4139
+ "stroke",
4140
+ lineGradientId ? `url(#${lineGradientId})` : (_j = node.lineColor) != null ? _j : "none"
4141
+ );
4076
4142
  shape.setAttribute("stroke-width", String(strokeWidth));
4077
4143
  if (node.lineOpacity !== void 0)
4078
4144
  shape.setAttribute("stroke-opacity", String(Math.max(0, Math.min(1, node.lineOpacity))));
@@ -4096,13 +4162,7 @@ function customGeometryEllipse(path) {
4096
4162
  }
4097
4163
  const cx = width / 2;
4098
4164
  const cy = height / 2;
4099
- const endpoints = [
4100
- commands[0],
4101
- commands[1],
4102
- commands[2],
4103
- commands[3],
4104
- commands[4]
4105
- ];
4165
+ const endpoints = [commands[0], commands[1], commands[2], commands[3], commands[4]];
4106
4166
  const expected = [
4107
4167
  { x: width, y: cy },
4108
4168
  { x: cx, y: height },
@@ -4276,7 +4336,9 @@ function customGeometryPathData(commands) {
4276
4336
  parts.push(`L ${command.x} ${command.y}`);
4277
4337
  current = { x: command.x, y: command.y };
4278
4338
  } else if (command.kind === "cubicBezierTo") {
4279
- parts.push(`C ${command.x1} ${command.y1} ${command.x2} ${command.y2} ${command.x} ${command.y}`);
4339
+ parts.push(
4340
+ `C ${command.x1} ${command.y1} ${command.x2} ${command.y2} ${command.x} ${command.y}`
4341
+ );
4280
4342
  current = { x: command.x, y: command.y };
4281
4343
  } else if (command.kind === "arcTo") {
4282
4344
  const arc = svgArcCommandForCustomGeometry(command, current);
@@ -5020,7 +5082,15 @@ function renderLineValueLabels(svg, seriesList, plot, min, max) {
5020
5082
  series.values.forEach((value, pointIndex) => {
5021
5083
  const x = plot.left + (series.values.length === 1 ? plot.width / 2 : plot.width * pointIndex / (series.values.length - 1));
5022
5084
  const y = plot.top + plot.height - (value - min) / Math.max(1, max - min) * plot.height;
5023
- appendSvgText(svg, String(value), x, Math.max(plot.top + 2, y - 2.2), 2.6, "#374151", "middle");
5085
+ appendSvgText(
5086
+ svg,
5087
+ String(value),
5088
+ x,
5089
+ Math.max(plot.top + 2, y - 2.2),
5090
+ 2.6,
5091
+ "#374151",
5092
+ "middle"
5093
+ );
5024
5094
  });
5025
5095
  });
5026
5096
  }