@harbour-enterprises/superdoc 1.0.0-beta.7 → 1.0.0-beta.8

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 (27) hide show
  1. package/dist/chunks/{PdfViewer-hAYAlKzI.es.js → PdfViewer-BfEwF25T.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-T4fTm1XF.cjs → PdfViewer-DJ7BWUbW.cjs} +1 -1
  3. package/dist/chunks/{index-DGYP5Xod.es.js → index-BCZ82zY5.es.js} +3 -3
  4. package/dist/chunks/{index-DV613LhK-CqFLIBmd.cjs → index-DJrRlj1_-E5dmStMF.cjs} +1 -1
  5. package/dist/chunks/{index-DV613LhK-BY095UD2.es.js → index-DJrRlj1_-HA-nVwDO.es.js} +1 -1
  6. package/dist/chunks/{index-CYQjWGo5.cjs → index-DMwWcmrk.cjs} +3 -3
  7. package/dist/chunks/{super-editor.es-DmhQckCV.cjs → super-editor.es-Bo_fWMy6.cjs} +150 -39
  8. package/dist/chunks/{super-editor.es-CcaD69pQ.es.js → super-editor.es-MRWI4sfo.es.js} +150 -39
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-BM6gXTRC.js → converter-CflxlFnM.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-fwXPJGKu.js → docx-zipper-DKWL4mo2.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-RPTrfArg.js → editor-B9V7oJbW.js} +164 -53
  13. package/dist/super-editor/chunks/{index-DV613LhK.js → index-DJrRlj1_.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DacKXz_n.js → toolbar-B5WlPN4s.js} +2 -2
  15. package/dist/super-editor/converter.es.js +1 -1
  16. package/dist/super-editor/docx-zipper.es.js +2 -2
  17. package/dist/super-editor/editor.es.js +3 -3
  18. package/dist/super-editor/file-zipper.es.js +1 -1
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +152 -41
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -35581,7 +35581,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35581
35581
  static getStoredSuperdocVersion(docx) {
35582
35582
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35583
35583
  }
35584
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.7") {
35584
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.8") {
35585
35585
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35586
35586
  }
35587
35587
  /**
@@ -60069,7 +60069,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60069
60069
  const shouldSkipNodeView = (editor) => {
60070
60070
  return isHeadless(editor);
60071
60071
  };
60072
- const summaryVersion = "1.0.0-beta.7";
60072
+ const summaryVersion = "1.0.0-beta.8";
60073
60073
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
60074
60074
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
60075
60075
  function mapAttributes(attrs) {
@@ -60848,7 +60848,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60848
60848
  { default: remarkStringify2 },
60849
60849
  { default: remarkGfm2 }
60850
60850
  ] = await Promise.all([
60851
- Promise.resolve().then(() => indexDV613LhK),
60851
+ Promise.resolve().then(() => indexDJrRlj1_),
60852
60852
  Promise.resolve().then(() => indexDRCvimau),
60853
60853
  Promise.resolve().then(() => indexC_x_N6Uh),
60854
60854
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -61053,7 +61053,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61053
61053
  * Process collaboration migrations
61054
61054
  */
61055
61055
  processCollaborationMigrations() {
61056
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.7");
61056
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.8");
61057
61057
  if (!this.options.ydoc) return;
61058
61058
  const metaMap = this.options.ydoc.getMap("meta");
61059
61059
  let docVersion = metaMap.get("version");
@@ -64605,8 +64605,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64605
64605
  const beforeWidth = measureText2 ? measureText2(before) : 0;
64606
64606
  width -= beforeWidth;
64607
64607
  }
64608
- } else if (alignment2 === "bar") {
64609
- width = 0;
64610
64608
  }
64611
64609
  if (width < 1) {
64612
64610
  return fallbackWidth();
@@ -69649,14 +69647,14 @@ Please report this to https://github.com/markedjs/marked.`, e) {
69649
69647
  return metrics.width;
69650
69648
  }
69651
69649
  function lineHeightForRuns(runs2, fromRun, toRun) {
69652
- let maxSize = 0;
69650
+ let maxSize2 = 0;
69653
69651
  for (let i2 = fromRun; i2 <= toRun; i2 += 1) {
69654
69652
  const run2 = runs2[i2];
69655
69653
  const textRun = run2 && isTextRun(run2) ? run2 : null;
69656
69654
  const size2 = textRun?.fontSize ?? 16;
69657
- if (size2 > maxSize) maxSize = size2;
69655
+ if (size2 > maxSize2) maxSize2 = size2;
69658
69656
  }
69659
- return maxSize * 1.2;
69657
+ return maxSize2 * 1.2;
69660
69658
  }
69661
69659
  function remeasureParagraph(block, maxWidth) {
69662
69660
  const runs2 = block.runs ?? [];
@@ -75259,6 +75257,45 @@ ${l}
75259
75257
  function degToRad(degrees) {
75260
75258
  return degrees * Math.PI / 180;
75261
75259
  }
75260
+ const defaultMaxSize = 5e3;
75261
+ let maxSize = defaultMaxSize;
75262
+ const cache$1$1 = /* @__PURE__ */ new Map();
75263
+ const makeKey = (text2, font, letterSpacing) => {
75264
+ return `${text2}|${font}|${letterSpacing || 0}`;
75265
+ };
75266
+ function getMeasuredTextWidth(text2, font, letterSpacing, ctx2) {
75267
+ if (text2.length > 32e3) {
75268
+ text2 = text2.substring(0, 32e3);
75269
+ }
75270
+ const key2 = makeKey(text2, font, letterSpacing);
75271
+ const hit = cache$1$1.get(key2);
75272
+ if (hit !== void 0) {
75273
+ cache$1$1.delete(key2);
75274
+ cache$1$1.set(key2, hit);
75275
+ return hit.width;
75276
+ }
75277
+ try {
75278
+ ctx2.font = font;
75279
+ const metrics = ctx2.measureText(text2);
75280
+ const advanceWidth = metrics.width;
75281
+ const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
75282
+ const baseWidth = Math.max(advanceWidth, paintedWidth);
75283
+ const extra = letterSpacing ? Math.max(0, text2.length - 1) * letterSpacing : 0;
75284
+ const width = baseWidth + extra;
75285
+ cache$1$1.set(key2, { width });
75286
+ evictIfNeeded();
75287
+ return width;
75288
+ } catch {
75289
+ return 0;
75290
+ }
75291
+ }
75292
+ function evictIfNeeded() {
75293
+ while (cache$1$1.size > maxSize) {
75294
+ const oldestKey = cache$1$1.keys().next().value;
75295
+ if (oldestKey === void 0) break;
75296
+ cache$1$1.delete(oldestKey);
75297
+ }
75298
+ }
75262
75299
  const { computeTabStops } = Engines;
75263
75300
  let canvasContext = null;
75264
75301
  const DEFAULT_TAB_INTERVAL_TWIPS = 720;
@@ -75303,8 +75340,7 @@ ${l}
75303
75340
  const metrics = ctx2.measureText(text2);
75304
75341
  const advanceWidth = metrics.width;
75305
75342
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
75306
- const baseWidth = Math.max(advanceWidth, paintedWidth);
75307
- return baseWidth;
75343
+ return Math.max(advanceWidth, paintedWidth);
75308
75344
  }
75309
75345
  const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
75310
75346
  function calculateTypographyMetrics(fontSize2, spacing) {
@@ -75885,13 +75921,9 @@ ${l}
75885
75921
  };
75886
75922
  };
75887
75923
  const measureRunWidth = (text2, font, ctx2, run2) => {
75888
- const baseWidth = measureText(text2, font, ctx2);
75889
- const letterSpacing = run2.kind !== "tab" ? run2.letterSpacing : void 0;
75890
- if (!letterSpacing) {
75891
- return baseWidth;
75892
- }
75893
- const extra = Math.max(0, text2.length - 1) * letterSpacing;
75894
- return roundValue(baseWidth + extra);
75924
+ const letterSpacing = run2.kind !== "tab" ? run2.letterSpacing || 0 : 0;
75925
+ const width = getMeasuredTextWidth(text2, font, letterSpacing, ctx2);
75926
+ return roundValue(width);
75895
75927
  };
75896
75928
  const appendSegment = (segments, runIndex, fromChar, toChar, width, x2) => {
75897
75929
  if (!segments) return;
@@ -82640,7 +82672,7 @@ ${l}
82640
82672
  const tabHeight = paragraphContext.tabHeight;
82641
82673
  paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
82642
82674
  return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
82643
- } catch (error) {
82675
+ } catch {
82644
82676
  return null;
82645
82677
  }
82646
82678
  }
@@ -83734,6 +83766,19 @@ ${l}
83734
83766
  return [CommentMarkName, Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
83735
83767
  }
83736
83768
  });
83769
+ let cache$2 = /* @__PURE__ */ new WeakMap();
83770
+ function getParagraphContext(paragraph2, startPos, helpers2, revision, compute) {
83771
+ const cached = cache$2.get(paragraph2);
83772
+ if (cached && cached.revision === revision) {
83773
+ return cached.context;
83774
+ }
83775
+ const context = compute(paragraph2, startPos, helpers2);
83776
+ cache$2.set(paragraph2, { revision, context });
83777
+ return context;
83778
+ }
83779
+ function clearAllParagraphContexts() {
83780
+ cache$2 = /* @__PURE__ */ new WeakMap();
83781
+ }
83737
83782
  const leaderStyles = {
83738
83783
  dot: "border-bottom: 1px dotted black;",
83739
83784
  heavy: "border-bottom: 2px solid black;",
@@ -83750,6 +83795,14 @@ ${l}
83750
83795
  if (!paragraphContext) return null;
83751
83796
  const paragraphId = paragraphIdFromPos(paragraphContext.startPos);
83752
83797
  const paragraphNode = paragraphContext.paragraph;
83798
+ const cachedContext = getParagraphContext(
83799
+ paragraphNode,
83800
+ paragraphContext.startPos,
83801
+ helpers2,
83802
+ revision,
83803
+ () => extractParagraphContext(paragraphNode, paragraphContext.startPos, helpers2, paragraphContext.paragraphDepth)
83804
+ );
83805
+ const effectiveContext = cachedContext || paragraphContext;
83753
83806
  const { entries } = flattenParagraph(paragraphNode, paragraphContext.startPos);
83754
83807
  const spans = [];
83755
83808
  let tabIndex = 0;
@@ -83777,13 +83830,13 @@ ${l}
83777
83830
  });
83778
83831
  }
83779
83832
  });
83780
- const tabStops = Array.isArray(paragraphContext.tabStops) ? [...paragraphContext.tabStops] : [];
83781
- const hangingPx = twipsToPixels(Number(paragraphContext.indent?.hanging) || 0);
83782
- if (hangingPx > 0 && paragraphContext.indentWidth != null) {
83783
- tabStops.unshift({ val: "start", pos: paragraphContext.indentWidth + hangingPx, leader: "none" });
83833
+ const tabStops = Array.isArray(effectiveContext.tabStops) ? [...effectiveContext.tabStops] : [];
83834
+ const hangingPx = twipsToPixels(Number(effectiveContext.indent?.hanging) || 0);
83835
+ if (hangingPx > 0 && effectiveContext.indentWidth != null) {
83836
+ tabStops.unshift({ val: "start", pos: effectiveContext.indentWidth + hangingPx, leader: "none" });
83784
83837
  }
83785
- const paragraphWidth = getBlockNodeWidth(view, paragraphContext.startPos) ?? defaultLineLength;
83786
- const indentWidth = paragraphContext.indentWidth ?? getIndentWidth(view, paragraphContext.startPos, paragraphContext.indent);
83838
+ const paragraphWidth = getBlockNodeWidth(view, effectiveContext.startPos) ?? defaultLineLength;
83839
+ const indentWidth = effectiveContext.indentWidth ?? getIndentWidth(view, effectiveContext.startPos, effectiveContext.indent);
83787
83840
  return {
83788
83841
  paragraphId,
83789
83842
  revision,
@@ -83791,9 +83844,9 @@ ${l}
83791
83844
  defaultTabDistance,
83792
83845
  defaultLineLength,
83793
83846
  indents: {
83794
- left: twipsToPixels(Number(paragraphContext.indent?.left) || 0),
83795
- right: twipsToPixels(Number(paragraphContext.indent?.right) || 0),
83796
- firstLine: twipsToPixels(Number(paragraphContext.indent?.firstLine) || 0),
83847
+ left: twipsToPixels(Number(effectiveContext.indent?.left) || 0),
83848
+ right: twipsToPixels(Number(effectiveContext.indent?.right) || 0),
83849
+ firstLine: twipsToPixels(Number(effectiveContext.indent?.firstLine) || 0),
83797
83850
  hanging: hangingPx
83798
83851
  },
83799
83852
  tabStops,
@@ -83958,31 +84011,58 @@ ${l}
83958
84011
  key: new PluginKey("tabPlugin"),
83959
84012
  state: {
83960
84013
  init() {
83961
- return { decorations: false, revision: 0 };
84014
+ const initialDecorations = buildInitialDecorations(view.state.doc, view, helpers2, 0);
84015
+ return { decorations: initialDecorations, revision: 0 };
83962
84016
  },
83963
84017
  apply(tr, { decorations, revision }, _oldState, newState) {
83964
- if (!decorations) {
83965
- const newDecorations2 = buildDecorations(newState.doc, view, helpers2, 0);
83966
- return { decorations: newDecorations2, revision: 0 };
83967
- }
84018
+ const currentDecorations = decorations && decorations.map ? decorations.map(tr.mapping, tr.doc) : DecorationSet.empty;
83968
84019
  if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
83969
- return { decorations, revision };
83970
- }
83971
- const nextRevision = revision + 1;
83972
- const newDecorations = buildDecorations(newState.doc, view, helpers2, nextRevision);
83973
- return { decorations: newDecorations, revision: nextRevision };
84020
+ return { decorations: currentDecorations, revision };
84021
+ }
84022
+ const affectedParagraphs = getAffectedParagraphStarts(tr, newState);
84023
+ if (affectedParagraphs.size === 0) {
84024
+ return { decorations: currentDecorations, revision };
84025
+ }
84026
+ let nextDecorations = currentDecorations;
84027
+ affectedParagraphs.forEach((pos) => {
84028
+ const paragraph2 = newState.doc.nodeAt(pos);
84029
+ if (!paragraph2 || paragraph2.type.name !== "paragraph") return;
84030
+ const from2 = pos;
84031
+ const to = pos + paragraph2.nodeSize;
84032
+ const existing = nextDecorations.find(from2, to);
84033
+ if (existing?.length) {
84034
+ nextDecorations = nextDecorations.remove(existing);
84035
+ }
84036
+ const paragraphDecorations = buildParagraphDecorations(
84037
+ newState.doc,
84038
+ pos + 1,
84039
+ paragraph2,
84040
+ view,
84041
+ helpers2,
84042
+ revision + 1
84043
+ );
84044
+ nextDecorations = nextDecorations.add(newState.doc, paragraphDecorations);
84045
+ });
84046
+ return { decorations: nextDecorations, revision: revision + 1 };
83974
84047
  }
83975
84048
  },
83976
84049
  props: {
83977
84050
  decorations(state2) {
83978
84051
  return this.getState(state2).decorations;
83979
84052
  }
84053
+ },
84054
+ view() {
84055
+ return {
84056
+ destroy() {
84057
+ clearAllParagraphContexts();
84058
+ }
84059
+ };
83980
84060
  }
83981
84061
  });
83982
84062
  return [tabPlugin];
83983
84063
  }
83984
84064
  });
83985
- function buildDecorations(doc2, view, helpers2, revision) {
84065
+ function buildInitialDecorations(doc2, view, helpers2, revision) {
83986
84066
  const decorations = [];
83987
84067
  doc2.descendants((node2, pos) => {
83988
84068
  if (node2.type.name !== "paragraph") return;
@@ -84003,6 +84083,37 @@ ${l}
84003
84083
  });
84004
84084
  return DecorationSet.create(doc2, decorations);
84005
84085
  }
84086
+ function buildParagraphDecorations(doc2, paragraphContentPos, paragraphNode, view, helpers2, revision) {
84087
+ const request = createLayoutRequest(doc2, paragraphContentPos, view, helpers2, revision);
84088
+ if (!request) return [];
84089
+ const result = calculateTabLayout(request, void 0, view);
84090
+ return applyLayoutResult(result, paragraphNode, paragraphContentPos - 1);
84091
+ }
84092
+ function getAffectedParagraphStarts(tr, newState) {
84093
+ const affected = /* @__PURE__ */ new Set();
84094
+ tr.steps.forEach((step, index2) => {
84095
+ if (step.from == null && step.to == null) return;
84096
+ let fromPos = step.from;
84097
+ let toPos = step.to;
84098
+ if (typeof fromPos !== "number" || typeof toPos !== "number") return;
84099
+ for (let i2 = index2; i2 < tr.steps.length; i2++) {
84100
+ const stepMap = tr.steps[i2].getMap();
84101
+ fromPos = stepMap.map(fromPos, -1);
84102
+ toPos = stepMap.map(toPos, 1);
84103
+ }
84104
+ if (fromPos < 0 || toPos < 0 || fromPos > newState.doc.content.size || toPos > newState.doc.content.size) {
84105
+ return;
84106
+ }
84107
+ newState.doc.nodesBetween(fromPos, toPos, (node2, pos) => {
84108
+ if (node2.type.name === "paragraph") {
84109
+ affected.add(pos);
84110
+ return false;
84111
+ }
84112
+ return true;
84113
+ });
84114
+ });
84115
+ return affected;
84116
+ }
84006
84117
  const LineBreak = Node$1.create({
84007
84118
  name: "lineBreak",
84008
84119
  group: "inline",
@@ -131530,7 +131641,7 @@ ${style2}
131530
131641
  this.config.colors = shuffleArray(this.config.colors);
131531
131642
  this.userColorMap = /* @__PURE__ */ new Map();
131532
131643
  this.colorIndex = 0;
131533
- this.version = "1.0.0-beta.7";
131644
+ this.version = "1.0.0-beta.8";
131534
131645
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
131535
131646
  this.superdocId = config2.superdocId || v4();
131536
131647
  this.colors = this.config.colors;
@@ -133973,7 +134084,7 @@ ${style2}
133973
134084
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
133974
134085
  );
133975
134086
  }
133976
- const indexDV613LhK = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
134087
+ const indexDJrRlj1_ = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
133977
134088
  __proto__: null,
133978
134089
  unified
133979
134090
  }, Symbol.toStringTag, { value: "Module" }));