@harbour-enterprises/superdoc 1.0.0-beta.93 → 1.0.0-beta.95

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-DbMCgjlc.cjs → PdfViewer--l9mxuw6.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-DDlUqq8s.es.js → PdfViewer-DC5ZtOHL.es.js} +1 -1
  3. package/dist/chunks/{index-CIyFPdjr.cjs → index-DA6_gKCn.cjs} +3 -3
  4. package/dist/chunks/{index-Cyp2JwAE-BDSzsvVr.cjs → index-DJD7xO_i-CVT8OSh8.cjs} +1 -1
  5. package/dist/chunks/{index-Cyp2JwAE-C4V2XscX.es.js → index-DJD7xO_i-DlZGZmeW.es.js} +1 -1
  6. package/dist/chunks/{index-D1G3HZnw.es.js → index-D_AIVJix.es.js} +3 -3
  7. package/dist/chunks/{super-editor.es-CZ_EMz2h.cjs → super-editor.es-DLfNMkAR.cjs} +188 -23
  8. package/dist/chunks/{super-editor.es-BLW0IRfr.es.js → super-editor.es-L0F8-awY.es.js} +188 -23
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-CvPb50HR.js → converter-CAiO-oW4.js} +26 -2
  11. package/dist/super-editor/chunks/{docx-zipper-BWUuyGDp.js → docx-zipper-DRP7HhmI.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-CsWOz21v.js → editor-D5oQ83xJ.js} +164 -23
  13. package/dist/super-editor/chunks/{index-Cyp2JwAE.js → index-DJD7xO_i.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-DjWypz4_.js → toolbar-ax2sbcF_.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 +190 -25
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42218,6 +42218,24 @@ const _SuperConverter = class _SuperConverter2 {
42218
42218
  }
42219
42219
  return false;
42220
42220
  }
42221
+ /**
42222
+ * Extracts the namespace prefix from an element name.
42223
+ *
42224
+ * @private
42225
+ * @static
42226
+ * @param {string} elementName - The element name (may include namespace prefix, e.g., 'op:Properties')
42227
+ * @returns {string} The namespace prefix (e.g., 'op') or empty string if no prefix
42228
+ *
42229
+ * @example
42230
+ * _extractNamespacePrefix('op:Properties') // => 'op'
42231
+ * _extractNamespacePrefix('Properties') // => ''
42232
+ * _extractNamespacePrefix('custom:property') // => 'custom'
42233
+ */
42234
+ static _extractNamespacePrefix(elementName) {
42235
+ if (!elementName || typeof elementName !== "string") return "";
42236
+ const colonIndex = elementName.indexOf(":");
42237
+ return colonIndex > 0 ? elementName.slice(0, colonIndex) : "";
42238
+ }
42221
42239
  /**
42222
42240
  * Generic method to get a stored custom property from docx.
42223
42241
  * Supports both standard and custom namespace prefixes (e.g., 'op:Properties', 'custom:property').
@@ -42316,6 +42334,8 @@ const _SuperConverter = class _SuperConverter2 {
42316
42334
  const properties = customXml.elements?.find((el) => _SuperConverter2._matchesElementName(el.name, "Properties"));
42317
42335
  if (!properties) return null;
42318
42336
  if (!properties.elements) properties.elements = [];
42337
+ const namespacePrefix = _SuperConverter2._extractNamespacePrefix(properties.name);
42338
+ const propertyElementName = namespacePrefix ? `${namespacePrefix}:property` : "property";
42319
42339
  let property2 = properties.elements.find(
42320
42340
  (el) => _SuperConverter2._matchesElementName(el.name, "property") && el.attributes?.name === propertyName
42321
42341
  );
@@ -42332,7 +42352,7 @@ const _SuperConverter = class _SuperConverter2 {
42332
42352
  const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
42333
42353
  property2 = {
42334
42354
  type: "element",
42335
- name: "property",
42355
+ name: propertyElementName,
42336
42356
  attributes: {
42337
42357
  name: propertyName,
42338
42358
  fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
@@ -42353,6 +42373,10 @@ const _SuperConverter = class _SuperConverter2 {
42353
42373
  };
42354
42374
  properties.elements.push(property2);
42355
42375
  } else {
42376
+ const existingPropertyPrefix = _SuperConverter2._extractNamespacePrefix(property2.name);
42377
+ if (existingPropertyPrefix !== namespacePrefix) {
42378
+ property2.name = propertyElementName;
42379
+ }
42356
42380
  if (!property2.elements?.[0]?.elements?.[0]) {
42357
42381
  console.warn(`Malformed property structure for "${propertyName}", recreating structure`);
42358
42382
  property2.elements = [
@@ -42380,7 +42404,7 @@ const _SuperConverter = class _SuperConverter2 {
42380
42404
  static getStoredSuperdocVersion(docx) {
42381
42405
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42382
42406
  }
42383
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.93") {
42407
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.95") {
42384
42408
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42385
42409
  }
42386
42410
  /**
@@ -56530,12 +56554,12 @@ const findTrackedMarkBetween = ({
56530
56554
  const { doc: doc2 } = tr;
56531
56555
  const startPos = Math.max(from2 - offset2, 0);
56532
56556
  const endPos = Math.min(to + offset2, doc2.content.size);
56533
- let markFound;
56534
- doc2.nodesBetween(startPos, endPos, (node, pos) => {
56557
+ let markFound = null;
56558
+ const tryMatch = (node, pos) => {
56535
56559
  if (!node || node?.nodeSize === void 0) {
56536
56560
  return;
56537
56561
  }
56538
- const mark = node.marks.find(
56562
+ const mark = node.marks?.find(
56539
56563
  (mark2) => mark2.type.name === markName && Object.keys(attrs).every((attr) => mark2.attrs[attr] === attrs[attr])
56540
56564
  );
56541
56565
  if (mark && !markFound) {
@@ -56544,24 +56568,36 @@ const findTrackedMarkBetween = ({
56544
56568
  to: pos + node.nodeSize,
56545
56569
  mark
56546
56570
  };
56571
+ return false;
56547
56572
  }
56573
+ };
56574
+ doc2.nodesBetween(startPos, endPos, (node, pos) => {
56575
+ return tryMatch(node, pos);
56548
56576
  });
56549
- const nodeAtEndPosition = doc2.nodeAt(endPos);
56550
- if (nodeAtEndPosition?.type?.name === "run") {
56551
- const node = nodeAtEndPosition.content?.content?.[0];
56552
- const isTextNode = node?.type?.name === "text";
56553
- if (isTextNode) {
56554
- const mark = node.marks.find(
56555
- (mark2) => mark2.type.name === markName && Object.keys(attrs).every((attr) => mark2.attrs[attr] === attrs[attr])
56556
- );
56557
- if (mark && !markFound) {
56558
- markFound = {
56559
- from: endPos,
56560
- to: endPos + node.nodeSize,
56561
- mark
56562
- };
56577
+ const inspectAroundPosition = (pos) => {
56578
+ if (pos < 0 || pos > doc2.content.size) {
56579
+ return;
56580
+ }
56581
+ const resolved = doc2.resolve(pos);
56582
+ const before = resolved.nodeBefore;
56583
+ if (before?.type?.name === "run") {
56584
+ const beforeStart = Math.max(pos - before.nodeSize, 0);
56585
+ const node = before.content?.content?.[0];
56586
+ if (node?.type?.name === "text") {
56587
+ tryMatch(node, beforeStart);
56563
56588
  }
56564
56589
  }
56590
+ const after = resolved.nodeAfter;
56591
+ if (after?.type?.name === "run") {
56592
+ const node = after.content?.content?.[0];
56593
+ if (node?.type?.name === "text") {
56594
+ tryMatch(node, pos);
56595
+ }
56596
+ }
56597
+ };
56598
+ if (!markFound) {
56599
+ inspectAroundPosition(startPos);
56600
+ inspectAroundPosition(endPos);
56565
56601
  }
56566
56602
  return markFound;
56567
56603
  };
@@ -59586,7 +59622,7 @@ const isHeadless = (editor) => {
59586
59622
  const shouldSkipNodeView = (editor) => {
59587
59623
  return isHeadless(editor);
59588
59624
  };
59589
- const summaryVersion = "1.0.0-beta.93";
59625
+ const summaryVersion = "1.0.0-beta.95";
59590
59626
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59591
59627
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59592
59628
  function mapAttributes(attrs) {
@@ -60375,7 +60411,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60375
60411
  { default: remarkStringify },
60376
60412
  { default: remarkGfm }
60377
60413
  ] = await Promise.all([
60378
- import("./index-Cyp2JwAE-C4V2XscX.es.js"),
60414
+ import("./index-DJD7xO_i-DlZGZmeW.es.js"),
60379
60415
  import("./index-DRCvimau-Cw339678.es.js"),
60380
60416
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
60381
60417
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -60580,7 +60616,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60580
60616
  * Process collaboration migrations
60581
60617
  */
60582
60618
  processCollaborationMigrations() {
60583
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.93");
60619
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.95");
60584
60620
  if (!this.options.ydoc) return;
60585
60621
  const metaMap = this.options.ydoc.getMap("meta");
60586
60622
  let docVersion = metaMap.get("version");
@@ -77457,7 +77493,9 @@ const deriveBlockVersion = (block) => {
77457
77493
  textRun.letterSpacing != null ? textRun.letterSpacing : "",
77458
77494
  textRun.pmStart ?? "",
77459
77495
  textRun.pmEnd ?? "",
77460
- textRun.token ?? ""
77496
+ textRun.token ?? "",
77497
+ // Tracked changes - force re-render when added or removed tracked change
77498
+ textRun.trackedChange ? 1 : 0
77461
77499
  ].join(",");
77462
77500
  }).join("|");
77463
77501
  const attrs = block.attrs;
@@ -85007,6 +85045,104 @@ async function measureParagraphBlock(block, maxWidth) {
85007
85045
  const wordStartChar = charPosInRun;
85008
85046
  const wordEndNoSpace = charPosInRun + word.length;
85009
85047
  const wordEndWithSpace = charPosInRun + (isLastWord ? word.length : word.length + 1);
85048
+ const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85049
+ if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
85050
+ if (currentLine && currentLine.width > 0 && currentLine.segments.length > 0) {
85051
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85052
+ const { spaceCount: _sc, ...lineBase } = currentLine;
85053
+ const completedLine = { ...lineBase, ...metrics };
85054
+ addBarTabsToLine(completedLine);
85055
+ lines.push(completedLine);
85056
+ tabStopCursor = 0;
85057
+ pendingTabAlignment = null;
85058
+ currentLine = null;
85059
+ }
85060
+ const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85061
+ const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
85062
+ const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
85063
+ const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
85064
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run2);
85065
+ let chunkCharOffset = wordStartChar;
85066
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
85067
+ const chunk = chunks[chunkIndex];
85068
+ const chunkStartChar = chunkCharOffset;
85069
+ const chunkEndChar = chunkCharOffset + chunk.text.length;
85070
+ const isLastChunk = chunkIndex === chunks.length - 1;
85071
+ const isFirstChunk = chunkIndex === 0;
85072
+ if (isFirstChunk && hasTabOnlyLine && currentLine) {
85073
+ currentLine.toRun = runIndex;
85074
+ currentLine.toChar = chunkEndChar;
85075
+ currentLine.width = roundValue(currentLine.width + chunk.width);
85076
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
85077
+ currentLine.maxFontInfo = getFontInfoFromRun(run2);
85078
+ currentLine.segments.push({
85079
+ runIndex,
85080
+ fromChar: chunkStartChar,
85081
+ toChar: chunkEndChar,
85082
+ width: chunk.width
85083
+ });
85084
+ if (isLastChunk) {
85085
+ const ls = run2.letterSpacing ?? 0;
85086
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85087
+ currentLine.toChar = wordEndWithSpace;
85088
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85089
+ charPosInRun = wordEndWithSpace;
85090
+ currentLine.spaceCount += 1;
85091
+ } else {
85092
+ charPosInRun = wordEndWithSpace;
85093
+ }
85094
+ } else {
85095
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85096
+ const { spaceCount: _sc, ...lineBase } = currentLine;
85097
+ const completedLine = { ...lineBase, ...metrics };
85098
+ addBarTabsToLine(completedLine);
85099
+ lines.push(completedLine);
85100
+ tabStopCursor = 0;
85101
+ pendingTabAlignment = null;
85102
+ currentLine = null;
85103
+ }
85104
+ } else if (isLastChunk) {
85105
+ currentLine = {
85106
+ fromRun: runIndex,
85107
+ fromChar: chunkStartChar,
85108
+ toRun: runIndex,
85109
+ toChar: chunkEndChar,
85110
+ width: chunk.width,
85111
+ maxFontSize: run2.fontSize,
85112
+ maxFontInfo: getFontInfoFromRun(run2),
85113
+ maxWidth: getEffectiveWidth(contentWidth),
85114
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
85115
+ spaceCount: 0
85116
+ };
85117
+ const ls = run2.letterSpacing ?? 0;
85118
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85119
+ currentLine.toChar = wordEndWithSpace;
85120
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85121
+ charPosInRun = wordEndWithSpace;
85122
+ currentLine.spaceCount += 1;
85123
+ } else {
85124
+ charPosInRun = wordEndWithSpace;
85125
+ }
85126
+ } else {
85127
+ const chunkLineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85128
+ const metrics = calculateTypographyMetrics(run2.fontSize, spacing, getFontInfoFromRun(run2));
85129
+ const chunkLine = {
85130
+ fromRun: runIndex,
85131
+ fromChar: chunkStartChar,
85132
+ toRun: runIndex,
85133
+ toChar: chunkEndChar,
85134
+ width: chunk.width,
85135
+ maxWidth: chunkLineMaxWidth,
85136
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
85137
+ ...metrics
85138
+ };
85139
+ addBarTabsToLine(chunkLine);
85140
+ lines.push(chunkLine);
85141
+ }
85142
+ chunkCharOffset = chunkEndChar;
85143
+ }
85144
+ continue;
85145
+ }
85010
85146
  if (!currentLine) {
85011
85147
  currentLine = {
85012
85148
  fromRun: runIndex,
@@ -85585,6 +85721,35 @@ const measureRunWidth = (text, font, ctx2, run2) => {
85585
85721
  const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
85586
85722
  return roundValue(width);
85587
85723
  };
85724
+ const breakWordIntoChunks = (word, maxWidth, font, ctx2, run2) => {
85725
+ const chunks = [];
85726
+ if (maxWidth <= 0) {
85727
+ for (const char of word) {
85728
+ const charWidth = measureRunWidth(char, font, ctx2, run2);
85729
+ chunks.push({ text: char, width: charWidth });
85730
+ }
85731
+ return chunks;
85732
+ }
85733
+ let currentChunk = "";
85734
+ let currentWidth = 0;
85735
+ for (let i = 0; i < word.length; i++) {
85736
+ const char = word[i];
85737
+ const testChunk = currentChunk + char;
85738
+ const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
85739
+ if (testWidth > maxWidth && currentChunk.length > 0) {
85740
+ chunks.push({ text: currentChunk, width: currentWidth });
85741
+ currentChunk = char;
85742
+ currentWidth = measureRunWidth(char, font, ctx2, run2);
85743
+ } else {
85744
+ currentChunk = testChunk;
85745
+ currentWidth = testWidth;
85746
+ }
85747
+ }
85748
+ if (currentChunk.length > 0) {
85749
+ chunks.push({ text: currentChunk, width: currentWidth });
85750
+ }
85751
+ return chunks;
85752
+ };
85588
85753
  const appendSegment = (segments, runIndex, fromChar, toChar, width, x2) => {
85589
85754
  if (!segments) return;
85590
85755
  const last = segments[segments.length - 1];
@@ -1,6 +1,6 @@
1
1
  import { ref, onMounted, onUnmounted, computed, createElementBlock, openBlock, withModifiers, createElementVNode, withDirectives, unref, vModelText, createCommentVNode, nextTick } from "vue";
2
- import { T as TextSelection } from "./chunks/converter-CvPb50HR.js";
3
- import { _ as _export_sfc } from "./chunks/editor-CsWOz21v.js";
2
+ import { T as TextSelection } from "./chunks/converter-CAiO-oW4.js";
3
+ import { _ as _export_sfc } from "./chunks/editor-D5oQ83xJ.js";
4
4
  const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
5
5
  const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
6
6
  async function baseInsightsFetch(payload, options = {}) {
@@ -42535,6 +42535,24 @@ const _SuperConverter = class _SuperConverter {
42535
42535
  }
42536
42536
  return false;
42537
42537
  }
42538
+ /**
42539
+ * Extracts the namespace prefix from an element name.
42540
+ *
42541
+ * @private
42542
+ * @static
42543
+ * @param {string} elementName - The element name (may include namespace prefix, e.g., 'op:Properties')
42544
+ * @returns {string} The namespace prefix (e.g., 'op') or empty string if no prefix
42545
+ *
42546
+ * @example
42547
+ * _extractNamespacePrefix('op:Properties') // => 'op'
42548
+ * _extractNamespacePrefix('Properties') // => ''
42549
+ * _extractNamespacePrefix('custom:property') // => 'custom'
42550
+ */
42551
+ static _extractNamespacePrefix(elementName) {
42552
+ if (!elementName || typeof elementName !== "string") return "";
42553
+ const colonIndex = elementName.indexOf(":");
42554
+ return colonIndex > 0 ? elementName.slice(0, colonIndex) : "";
42555
+ }
42538
42556
  /**
42539
42557
  * Generic method to get a stored custom property from docx.
42540
42558
  * Supports both standard and custom namespace prefixes (e.g., 'op:Properties', 'custom:property').
@@ -42633,6 +42651,8 @@ const _SuperConverter = class _SuperConverter {
42633
42651
  const properties = customXml.elements?.find((el) => _SuperConverter._matchesElementName(el.name, "Properties"));
42634
42652
  if (!properties) return null;
42635
42653
  if (!properties.elements) properties.elements = [];
42654
+ const namespacePrefix = _SuperConverter._extractNamespacePrefix(properties.name);
42655
+ const propertyElementName = namespacePrefix ? `${namespacePrefix}:property` : "property";
42636
42656
  let property = properties.elements.find(
42637
42657
  (el) => _SuperConverter._matchesElementName(el.name, "property") && el.attributes?.name === propertyName
42638
42658
  );
@@ -42649,7 +42669,7 @@ const _SuperConverter = class _SuperConverter {
42649
42669
  const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
42650
42670
  property = {
42651
42671
  type: "element",
42652
- name: "property",
42672
+ name: propertyElementName,
42653
42673
  attributes: {
42654
42674
  name: propertyName,
42655
42675
  fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
@@ -42670,6 +42690,10 @@ const _SuperConverter = class _SuperConverter {
42670
42690
  };
42671
42691
  properties.elements.push(property);
42672
42692
  } else {
42693
+ const existingPropertyPrefix = _SuperConverter._extractNamespacePrefix(property.name);
42694
+ if (existingPropertyPrefix !== namespacePrefix) {
42695
+ property.name = propertyElementName;
42696
+ }
42673
42697
  if (!property.elements?.[0]?.elements?.[0]) {
42674
42698
  console.warn(`Malformed property structure for "${propertyName}", recreating structure`);
42675
42699
  property.elements = [
@@ -42697,7 +42721,7 @@ const _SuperConverter = class _SuperConverter {
42697
42721
  static getStoredSuperdocVersion(docx) {
42698
42722
  return _SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
42699
42723
  }
42700
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.0.0-beta.93") {
42724
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.0.0-beta.95") {
42701
42725
  return _SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
42702
42726
  }
42703
42727
  /**
@@ -1,4 +1,4 @@
1
- import { p as process$1, aJ as commonjsGlobal, B as Buffer, aK as getDefaultExportFromCjs, aL as getContentTypesFromXml, aM as xmljs } from "./converter-CvPb50HR.js";
1
+ import { p as process$1, aJ as commonjsGlobal, B as Buffer, aK as getDefaultExportFromCjs, aL as getContentTypesFromXml, aM as xmljs } from "./converter-CAiO-oW4.js";
2
2
  function commonjsRequire(path) {
3
3
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
4
4
  }
@@ -12,8 +12,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _cellAnchor, _cellDragMode, _remoteCursorState, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupDragHandlers_fn, focusEditorAfterImageSelection_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, getCellPosFromTableHit_fn, getTablePosFromHit_fn, shouldUseCellSelection_fn, setCellAnchor_fn, clearCellAnchor_fn, hitTestTable_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_fn, computeDecorationBox_fn, computeExpectedSectionType_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_fn, renderCellSelectionOverlay_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, getPageOffsetX_fn, convertPageLocalToOverlayCoords_fn, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-CvPb50HR.js";
16
- import { D as DocxZipper } from "./docx-zipper-BWUuyGDp.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as SelectionRange, ak as Transform, al as resolveParagraphProperties, am as _getReferencedTableStyles, an as parseSizeUnit, ao as minMax, ap as updateDOMAttributes, aq as findChildren$5, ar as generateRandomSigned32BitIntStrId, as as decodeRPrFromMarks, at as calculateResolvedParagraphProperties, au as resolveRunProperties, av as encodeCSSFromPPr, aw as twipsToPixels$2, ax as encodeCSSFromRPr, ay as generateOrderedListIndex, az as docxNumberingHelpers, aA as InputRule, aB as convertSizeToCSS, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-CAiO-oW4.js";
16
+ import { D as DocxZipper } from "./docx-zipper-DRP7HhmI.js";
17
17
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
@@ -10861,12 +10861,12 @@ const findTrackedMarkBetween = ({
10861
10861
  const { doc: doc2 } = tr;
10862
10862
  const startPos = Math.max(from2 - offset2, 0);
10863
10863
  const endPos = Math.min(to + offset2, doc2.content.size);
10864
- let markFound;
10865
- doc2.nodesBetween(startPos, endPos, (node, pos) => {
10864
+ let markFound = null;
10865
+ const tryMatch = (node, pos) => {
10866
10866
  if (!node || node?.nodeSize === void 0) {
10867
10867
  return;
10868
10868
  }
10869
- const mark = node.marks.find(
10869
+ const mark = node.marks?.find(
10870
10870
  (mark2) => mark2.type.name === markName && Object.keys(attrs).every((attr) => mark2.attrs[attr] === attrs[attr])
10871
10871
  );
10872
10872
  if (mark && !markFound) {
@@ -10875,24 +10875,36 @@ const findTrackedMarkBetween = ({
10875
10875
  to: pos + node.nodeSize,
10876
10876
  mark
10877
10877
  };
10878
+ return false;
10878
10879
  }
10880
+ };
10881
+ doc2.nodesBetween(startPos, endPos, (node, pos) => {
10882
+ return tryMatch(node, pos);
10879
10883
  });
10880
- const nodeAtEndPosition = doc2.nodeAt(endPos);
10881
- if (nodeAtEndPosition?.type?.name === "run") {
10882
- const node = nodeAtEndPosition.content?.content?.[0];
10883
- const isTextNode = node?.type?.name === "text";
10884
- if (isTextNode) {
10885
- const mark = node.marks.find(
10886
- (mark2) => mark2.type.name === markName && Object.keys(attrs).every((attr) => mark2.attrs[attr] === attrs[attr])
10887
- );
10888
- if (mark && !markFound) {
10889
- markFound = {
10890
- from: endPos,
10891
- to: endPos + node.nodeSize,
10892
- mark
10893
- };
10884
+ const inspectAroundPosition = (pos) => {
10885
+ if (pos < 0 || pos > doc2.content.size) {
10886
+ return;
10887
+ }
10888
+ const resolved = doc2.resolve(pos);
10889
+ const before = resolved.nodeBefore;
10890
+ if (before?.type?.name === "run") {
10891
+ const beforeStart = Math.max(pos - before.nodeSize, 0);
10892
+ const node = before.content?.content?.[0];
10893
+ if (node?.type?.name === "text") {
10894
+ tryMatch(node, beforeStart);
10895
+ }
10896
+ }
10897
+ const after = resolved.nodeAfter;
10898
+ if (after?.type?.name === "run") {
10899
+ const node = after.content?.content?.[0];
10900
+ if (node?.type?.name === "text") {
10901
+ tryMatch(node, pos);
10894
10902
  }
10895
10903
  }
10904
+ };
10905
+ if (!markFound) {
10906
+ inspectAroundPosition(startPos);
10907
+ inspectAroundPosition(endPos);
10896
10908
  }
10897
10909
  return markFound;
10898
10910
  };
@@ -13940,7 +13952,7 @@ const isHeadless = (editor) => {
13940
13952
  const shouldSkipNodeView = (editor) => {
13941
13953
  return isHeadless(editor);
13942
13954
  };
13943
- const summaryVersion = "1.0.0-beta.93";
13955
+ const summaryVersion = "1.0.0-beta.95";
13944
13956
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
13945
13957
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
13946
13958
  function mapAttributes(attrs) {
@@ -14732,7 +14744,7 @@ const _Editor = class _Editor extends EventEmitter {
14732
14744
  { default: remarkStringify },
14733
14745
  { default: remarkGfm }
14734
14746
  ] = await Promise.all([
14735
- import("./index-Cyp2JwAE.js"),
14747
+ import("./index-DJD7xO_i.js"),
14736
14748
  import("./index-DRCvimau.js"),
14737
14749
  import("./index-C_x_N6Uh.js"),
14738
14750
  import("./index-D_sWOSiG.js"),
@@ -14937,7 +14949,7 @@ const _Editor = class _Editor extends EventEmitter {
14937
14949
  * Process collaboration migrations
14938
14950
  */
14939
14951
  processCollaborationMigrations() {
14940
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.93");
14952
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.95");
14941
14953
  if (!this.options.ydoc) return;
14942
14954
  const metaMap = this.options.ydoc.getMap("meta");
14943
14955
  let docVersion = metaMap.get("version");
@@ -31902,7 +31914,9 @@ const deriveBlockVersion = (block) => {
31902
31914
  textRun.letterSpacing != null ? textRun.letterSpacing : "",
31903
31915
  textRun.pmStart ?? "",
31904
31916
  textRun.pmEnd ?? "",
31905
- textRun.token ?? ""
31917
+ textRun.token ?? "",
31918
+ // Tracked changes - force re-render when added or removed tracked change
31919
+ textRun.trackedChange ? 1 : 0
31906
31920
  ].join(",");
31907
31921
  }).join("|");
31908
31922
  const attrs = block.attrs;
@@ -39452,6 +39466,104 @@ async function measureParagraphBlock(block, maxWidth) {
39452
39466
  const wordStartChar = charPosInRun;
39453
39467
  const wordEndNoSpace = charPosInRun + word.length;
39454
39468
  const wordEndWithSpace = charPosInRun + (isLastWord ? word.length : word.length + 1);
39469
+ const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
39470
+ if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
39471
+ if (currentLine && currentLine.width > 0 && currentLine.segments.length > 0) {
39472
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39473
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39474
+ const completedLine = { ...lineBase, ...metrics };
39475
+ addBarTabsToLine(completedLine);
39476
+ lines.push(completedLine);
39477
+ tabStopCursor = 0;
39478
+ pendingTabAlignment = null;
39479
+ currentLine = null;
39480
+ }
39481
+ const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
39482
+ const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
39483
+ const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
39484
+ const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
39485
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run);
39486
+ let chunkCharOffset = wordStartChar;
39487
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
39488
+ const chunk = chunks[chunkIndex];
39489
+ const chunkStartChar = chunkCharOffset;
39490
+ const chunkEndChar = chunkCharOffset + chunk.text.length;
39491
+ const isLastChunk = chunkIndex === chunks.length - 1;
39492
+ const isFirstChunk = chunkIndex === 0;
39493
+ if (isFirstChunk && hasTabOnlyLine && currentLine) {
39494
+ currentLine.toRun = runIndex;
39495
+ currentLine.toChar = chunkEndChar;
39496
+ currentLine.width = roundValue(currentLine.width + chunk.width);
39497
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run.fontSize);
39498
+ currentLine.maxFontInfo = getFontInfoFromRun(run);
39499
+ currentLine.segments.push({
39500
+ runIndex,
39501
+ fromChar: chunkStartChar,
39502
+ toChar: chunkEndChar,
39503
+ width: chunk.width
39504
+ });
39505
+ if (isLastChunk) {
39506
+ const ls = run.letterSpacing ?? 0;
39507
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39508
+ currentLine.toChar = wordEndWithSpace;
39509
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
39510
+ charPosInRun = wordEndWithSpace;
39511
+ currentLine.spaceCount += 1;
39512
+ } else {
39513
+ charPosInRun = wordEndWithSpace;
39514
+ }
39515
+ } else {
39516
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
39517
+ const { spaceCount: _sc, ...lineBase } = currentLine;
39518
+ const completedLine = { ...lineBase, ...metrics };
39519
+ addBarTabsToLine(completedLine);
39520
+ lines.push(completedLine);
39521
+ tabStopCursor = 0;
39522
+ pendingTabAlignment = null;
39523
+ currentLine = null;
39524
+ }
39525
+ } else if (isLastChunk) {
39526
+ currentLine = {
39527
+ fromRun: runIndex,
39528
+ fromChar: chunkStartChar,
39529
+ toRun: runIndex,
39530
+ toChar: chunkEndChar,
39531
+ width: chunk.width,
39532
+ maxFontSize: run.fontSize,
39533
+ maxFontInfo: getFontInfoFromRun(run),
39534
+ maxWidth: getEffectiveWidth(contentWidth),
39535
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
39536
+ spaceCount: 0
39537
+ };
39538
+ const ls = run.letterSpacing ?? 0;
39539
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
39540
+ currentLine.toChar = wordEndWithSpace;
39541
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
39542
+ charPosInRun = wordEndWithSpace;
39543
+ currentLine.spaceCount += 1;
39544
+ } else {
39545
+ charPosInRun = wordEndWithSpace;
39546
+ }
39547
+ } else {
39548
+ const chunkLineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
39549
+ const metrics = calculateTypographyMetrics(run.fontSize, spacing, getFontInfoFromRun(run));
39550
+ const chunkLine = {
39551
+ fromRun: runIndex,
39552
+ fromChar: chunkStartChar,
39553
+ toRun: runIndex,
39554
+ toChar: chunkEndChar,
39555
+ width: chunk.width,
39556
+ maxWidth: chunkLineMaxWidth,
39557
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
39558
+ ...metrics
39559
+ };
39560
+ addBarTabsToLine(chunkLine);
39561
+ lines.push(chunkLine);
39562
+ }
39563
+ chunkCharOffset = chunkEndChar;
39564
+ }
39565
+ continue;
39566
+ }
39455
39567
  if (!currentLine) {
39456
39568
  currentLine = {
39457
39569
  fromRun: runIndex,
@@ -40030,6 +40142,35 @@ const measureRunWidth = (text, font, ctx2, run) => {
40030
40142
  const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
40031
40143
  return roundValue(width);
40032
40144
  };
40145
+ const breakWordIntoChunks = (word, maxWidth, font, ctx2, run) => {
40146
+ const chunks = [];
40147
+ if (maxWidth <= 0) {
40148
+ for (const char of word) {
40149
+ const charWidth = measureRunWidth(char, font, ctx2, run);
40150
+ chunks.push({ text: char, width: charWidth });
40151
+ }
40152
+ return chunks;
40153
+ }
40154
+ let currentChunk = "";
40155
+ let currentWidth = 0;
40156
+ for (let i = 0; i < word.length; i++) {
40157
+ const char = word[i];
40158
+ const testChunk = currentChunk + char;
40159
+ const testWidth = measureRunWidth(testChunk, font, ctx2, run);
40160
+ if (testWidth > maxWidth && currentChunk.length > 0) {
40161
+ chunks.push({ text: currentChunk, width: currentWidth });
40162
+ currentChunk = char;
40163
+ currentWidth = measureRunWidth(char, font, ctx2, run);
40164
+ } else {
40165
+ currentChunk = testChunk;
40166
+ currentWidth = testWidth;
40167
+ }
40168
+ }
40169
+ if (currentChunk.length > 0) {
40170
+ chunks.push({ text: currentChunk, width: currentWidth });
40171
+ }
40172
+ return chunks;
40173
+ };
40033
40174
  const appendSegment = (segments, runIndex, fromChar, toChar, width, x) => {
40034
40175
  if (!segments) return;
40035
40176
  const last = segments[segments.length - 1];