@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
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-jWLMl8Ts.cjs");
4
- const superdoc = require("./index-CIyFPdjr.cjs");
4
+ const superdoc = require("./index-DA6_gKCn.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  import { y as defineComponent, z as h, O as Transition, a0 as process$1, J as watchEffect, a as computed, r as ref, j as onMounted, W as onUnmounted, b as createElementBlock, o as openBlock, f as createBaseVNode, e as createCommentVNode, u as createVNode, v as unref } from "./vue-Dysv_7z5.es.js";
2
- import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-D1G3HZnw.es.js";
2
+ import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-D_AIVJix.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-CZ_EMz2h.cjs");
2
+ const superEditor_es = require("./super-editor.es-DLfNMkAR.cjs");
3
3
  const blankDocx = require("./blank-docx-DfW3Eeh2.cjs");
4
4
  const eventemitter3 = require("./eventemitter3-DQmQUge-.cjs");
5
5
  const provider = require("@hocuspocus/provider");
@@ -17268,7 +17268,7 @@ const _sfc_main = {
17268
17268
  __name: "SuperDoc",
17269
17269
  emits: ["selection-update"],
17270
17270
  setup(__props, { emit: __emit }) {
17271
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-DbMCgjlc.cjs")));
17271
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer--l9mxuw6.cjs")));
17272
17272
  const superdocStore = useSuperdocStore();
17273
17273
  const commentsStore = useCommentsStore();
17274
17274
  const {
@@ -18157,7 +18157,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
18157
18157
  this.config.colors = shuffleArray(this.config.colors);
18158
18158
  this.userColorMap = /* @__PURE__ */ new Map();
18159
18159
  this.colorIndex = 0;
18160
- this.version = "1.0.0-beta.93";
18160
+ this.version = "1.0.0-beta.95";
18161
18161
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
18162
18162
  this.superdocId = config.superdocId || uuid.v4();
18163
18163
  this.colors = this.config.colors;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./super-editor.es-CZ_EMz2h.cjs");
3
+ const superEditor_es = require("./super-editor.es-DLfNMkAR.cjs");
4
4
  const indexCvBqQJbG = require("./index-CvBqQJbG-Dwm0THD7.cjs");
5
5
  function bail(error) {
6
6
  if (error) {
@@ -1,4 +1,4 @@
1
- import { s as getDefaultExportFromCjs$2 } from "./super-editor.es-BLW0IRfr.es.js";
1
+ import { s as getDefaultExportFromCjs$2 } from "./super-editor.es-L0F8-awY.es.js";
2
2
  import { V as VFile } from "./index-CvBqQJbG-CvBqQJbG.es.js";
3
3
  function bail(error) {
4
4
  if (error) {
@@ -1,4 +1,4 @@
1
- import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, P as PresentationEditor, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-BLW0IRfr.es.js";
1
+ import { q as index, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, P as PresentationEditor, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-L0F8-awY.es.js";
2
2
  import { B as BlankDOCX } from "./blank-docx-ABm6XYAA.es.js";
3
3
  import { E as EventEmitter } from "./eventemitter3-CcXAdeql.es.js";
4
4
  import { HocuspocusProvider, HocuspocusProviderWebsocket } from "@hocuspocus/provider";
@@ -17251,7 +17251,7 @@ const _sfc_main = {
17251
17251
  __name: "SuperDoc",
17252
17252
  emits: ["selection-update"],
17253
17253
  setup(__props, { emit: __emit }) {
17254
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-DDlUqq8s.es.js"));
17254
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-DC5ZtOHL.es.js"));
17255
17255
  const superdocStore = useSuperdocStore();
17256
17256
  const commentsStore = useCommentsStore();
17257
17257
  const {
@@ -18140,7 +18140,7 @@ class SuperDoc extends EventEmitter {
18140
18140
  this.config.colors = shuffleArray(this.config.colors);
18141
18141
  this.userColorMap = /* @__PURE__ */ new Map();
18142
18142
  this.colorIndex = 0;
18143
- this.version = "1.0.0-beta.93";
18143
+ this.version = "1.0.0-beta.95";
18144
18144
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
18145
18145
  this.superdocId = config.superdocId || v4();
18146
18146
  this.colors = this.config.colors;
@@ -42235,6 +42235,24 @@ const _SuperConverter = class _SuperConverter2 {
42235
42235
  }
42236
42236
  return false;
42237
42237
  }
42238
+ /**
42239
+ * Extracts the namespace prefix from an element name.
42240
+ *
42241
+ * @private
42242
+ * @static
42243
+ * @param {string} elementName - The element name (may include namespace prefix, e.g., 'op:Properties')
42244
+ * @returns {string} The namespace prefix (e.g., 'op') or empty string if no prefix
42245
+ *
42246
+ * @example
42247
+ * _extractNamespacePrefix('op:Properties') // => 'op'
42248
+ * _extractNamespacePrefix('Properties') // => ''
42249
+ * _extractNamespacePrefix('custom:property') // => 'custom'
42250
+ */
42251
+ static _extractNamespacePrefix(elementName) {
42252
+ if (!elementName || typeof elementName !== "string") return "";
42253
+ const colonIndex = elementName.indexOf(":");
42254
+ return colonIndex > 0 ? elementName.slice(0, colonIndex) : "";
42255
+ }
42238
42256
  /**
42239
42257
  * Generic method to get a stored custom property from docx.
42240
42258
  * Supports both standard and custom namespace prefixes (e.g., 'op:Properties', 'custom:property').
@@ -42333,6 +42351,8 @@ const _SuperConverter = class _SuperConverter2 {
42333
42351
  const properties = customXml.elements?.find((el) => _SuperConverter2._matchesElementName(el.name, "Properties"));
42334
42352
  if (!properties) return null;
42335
42353
  if (!properties.elements) properties.elements = [];
42354
+ const namespacePrefix = _SuperConverter2._extractNamespacePrefix(properties.name);
42355
+ const propertyElementName = namespacePrefix ? `${namespacePrefix}:property` : "property";
42336
42356
  let property2 = properties.elements.find(
42337
42357
  (el) => _SuperConverter2._matchesElementName(el.name, "property") && el.attributes?.name === propertyName
42338
42358
  );
@@ -42349,7 +42369,7 @@ const _SuperConverter = class _SuperConverter2 {
42349
42369
  const pid = existingPids.length > 0 ? Math.max(...existingPids) + 1 : 2;
42350
42370
  property2 = {
42351
42371
  type: "element",
42352
- name: "property",
42372
+ name: propertyElementName,
42353
42373
  attributes: {
42354
42374
  name: propertyName,
42355
42375
  fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
@@ -42370,6 +42390,10 @@ const _SuperConverter = class _SuperConverter2 {
42370
42390
  };
42371
42391
  properties.elements.push(property2);
42372
42392
  } else {
42393
+ const existingPropertyPrefix = _SuperConverter2._extractNamespacePrefix(property2.name);
42394
+ if (existingPropertyPrefix !== namespacePrefix) {
42395
+ property2.name = propertyElementName;
42396
+ }
42373
42397
  if (!property2.elements?.[0]?.elements?.[0]) {
42374
42398
  console.warn(`Malformed property structure for "${propertyName}", recreating structure`);
42375
42399
  property2.elements = [
@@ -42397,7 +42421,7 @@ const _SuperConverter = class _SuperConverter2 {
42397
42421
  static getStoredSuperdocVersion(docx) {
42398
42422
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42399
42423
  }
42400
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.93") {
42424
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.95") {
42401
42425
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42402
42426
  }
42403
42427
  /**
@@ -56547,12 +56571,12 @@ const findTrackedMarkBetween = ({
56547
56571
  const { doc: doc2 } = tr;
56548
56572
  const startPos = Math.max(from2 - offset2, 0);
56549
56573
  const endPos = Math.min(to + offset2, doc2.content.size);
56550
- let markFound;
56551
- doc2.nodesBetween(startPos, endPos, (node, pos) => {
56574
+ let markFound = null;
56575
+ const tryMatch = (node, pos) => {
56552
56576
  if (!node || node?.nodeSize === void 0) {
56553
56577
  return;
56554
56578
  }
56555
- const mark = node.marks.find(
56579
+ const mark = node.marks?.find(
56556
56580
  (mark2) => mark2.type.name === markName && Object.keys(attrs).every((attr) => mark2.attrs[attr] === attrs[attr])
56557
56581
  );
56558
56582
  if (mark && !markFound) {
@@ -56561,24 +56585,36 @@ const findTrackedMarkBetween = ({
56561
56585
  to: pos + node.nodeSize,
56562
56586
  mark
56563
56587
  };
56588
+ return false;
56564
56589
  }
56590
+ };
56591
+ doc2.nodesBetween(startPos, endPos, (node, pos) => {
56592
+ return tryMatch(node, pos);
56565
56593
  });
56566
- const nodeAtEndPosition = doc2.nodeAt(endPos);
56567
- if (nodeAtEndPosition?.type?.name === "run") {
56568
- const node = nodeAtEndPosition.content?.content?.[0];
56569
- const isTextNode = node?.type?.name === "text";
56570
- if (isTextNode) {
56571
- const mark = node.marks.find(
56572
- (mark2) => mark2.type.name === markName && Object.keys(attrs).every((attr) => mark2.attrs[attr] === attrs[attr])
56573
- );
56574
- if (mark && !markFound) {
56575
- markFound = {
56576
- from: endPos,
56577
- to: endPos + node.nodeSize,
56578
- mark
56579
- };
56594
+ const inspectAroundPosition = (pos) => {
56595
+ if (pos < 0 || pos > doc2.content.size) {
56596
+ return;
56597
+ }
56598
+ const resolved = doc2.resolve(pos);
56599
+ const before = resolved.nodeBefore;
56600
+ if (before?.type?.name === "run") {
56601
+ const beforeStart = Math.max(pos - before.nodeSize, 0);
56602
+ const node = before.content?.content?.[0];
56603
+ if (node?.type?.name === "text") {
56604
+ tryMatch(node, beforeStart);
56580
56605
  }
56581
56606
  }
56607
+ const after = resolved.nodeAfter;
56608
+ if (after?.type?.name === "run") {
56609
+ const node = after.content?.content?.[0];
56610
+ if (node?.type?.name === "text") {
56611
+ tryMatch(node, pos);
56612
+ }
56613
+ }
56614
+ };
56615
+ if (!markFound) {
56616
+ inspectAroundPosition(startPos);
56617
+ inspectAroundPosition(endPos);
56582
56618
  }
56583
56619
  return markFound;
56584
56620
  };
@@ -59603,7 +59639,7 @@ const isHeadless = (editor) => {
59603
59639
  const shouldSkipNodeView = (editor) => {
59604
59640
  return isHeadless(editor);
59605
59641
  };
59606
- const summaryVersion = "1.0.0-beta.93";
59642
+ const summaryVersion = "1.0.0-beta.95";
59607
59643
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59608
59644
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59609
59645
  function mapAttributes(attrs) {
@@ -60392,7 +60428,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60392
60428
  { default: remarkStringify },
60393
60429
  { default: remarkGfm }
60394
60430
  ] = await Promise.all([
60395
- Promise.resolve().then(() => require("./index-Cyp2JwAE-BDSzsvVr.cjs")),
60431
+ Promise.resolve().then(() => require("./index-DJD7xO_i-CVT8OSh8.cjs")),
60396
60432
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
60397
60433
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
60398
60434
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60597,7 +60633,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60597
60633
  * Process collaboration migrations
60598
60634
  */
60599
60635
  processCollaborationMigrations() {
60600
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.93");
60636
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.95");
60601
60637
  if (!this.options.ydoc) return;
60602
60638
  const metaMap = this.options.ydoc.getMap("meta");
60603
60639
  let docVersion = metaMap.get("version");
@@ -77474,7 +77510,9 @@ const deriveBlockVersion = (block) => {
77474
77510
  textRun.letterSpacing != null ? textRun.letterSpacing : "",
77475
77511
  textRun.pmStart ?? "",
77476
77512
  textRun.pmEnd ?? "",
77477
- textRun.token ?? ""
77513
+ textRun.token ?? "",
77514
+ // Tracked changes - force re-render when added or removed tracked change
77515
+ textRun.trackedChange ? 1 : 0
77478
77516
  ].join(",");
77479
77517
  }).join("|");
77480
77518
  const attrs = block.attrs;
@@ -85024,6 +85062,104 @@ async function measureParagraphBlock(block, maxWidth) {
85024
85062
  const wordStartChar = charPosInRun;
85025
85063
  const wordEndNoSpace = charPosInRun + word.length;
85026
85064
  const wordEndWithSpace = charPosInRun + (isLastWord ? word.length : word.length + 1);
85065
+ const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85066
+ if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
85067
+ if (currentLine && currentLine.width > 0 && currentLine.segments.length > 0) {
85068
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85069
+ const { spaceCount: _sc, ...lineBase } = currentLine;
85070
+ const completedLine = { ...lineBase, ...metrics };
85071
+ addBarTabsToLine(completedLine);
85072
+ lines.push(completedLine);
85073
+ tabStopCursor = 0;
85074
+ pendingTabAlignment = null;
85075
+ currentLine = null;
85076
+ }
85077
+ const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85078
+ const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
85079
+ const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
85080
+ const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
85081
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run2);
85082
+ let chunkCharOffset = wordStartChar;
85083
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
85084
+ const chunk = chunks[chunkIndex];
85085
+ const chunkStartChar = chunkCharOffset;
85086
+ const chunkEndChar = chunkCharOffset + chunk.text.length;
85087
+ const isLastChunk = chunkIndex === chunks.length - 1;
85088
+ const isFirstChunk = chunkIndex === 0;
85089
+ if (isFirstChunk && hasTabOnlyLine && currentLine) {
85090
+ currentLine.toRun = runIndex;
85091
+ currentLine.toChar = chunkEndChar;
85092
+ currentLine.width = roundValue(currentLine.width + chunk.width);
85093
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
85094
+ currentLine.maxFontInfo = getFontInfoFromRun(run2);
85095
+ currentLine.segments.push({
85096
+ runIndex,
85097
+ fromChar: chunkStartChar,
85098
+ toChar: chunkEndChar,
85099
+ width: chunk.width
85100
+ });
85101
+ if (isLastChunk) {
85102
+ const ls = run2.letterSpacing ?? 0;
85103
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85104
+ currentLine.toChar = wordEndWithSpace;
85105
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85106
+ charPosInRun = wordEndWithSpace;
85107
+ currentLine.spaceCount += 1;
85108
+ } else {
85109
+ charPosInRun = wordEndWithSpace;
85110
+ }
85111
+ } else {
85112
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85113
+ const { spaceCount: _sc, ...lineBase } = currentLine;
85114
+ const completedLine = { ...lineBase, ...metrics };
85115
+ addBarTabsToLine(completedLine);
85116
+ lines.push(completedLine);
85117
+ tabStopCursor = 0;
85118
+ pendingTabAlignment = null;
85119
+ currentLine = null;
85120
+ }
85121
+ } else if (isLastChunk) {
85122
+ currentLine = {
85123
+ fromRun: runIndex,
85124
+ fromChar: chunkStartChar,
85125
+ toRun: runIndex,
85126
+ toChar: chunkEndChar,
85127
+ width: chunk.width,
85128
+ maxFontSize: run2.fontSize,
85129
+ maxFontInfo: getFontInfoFromRun(run2),
85130
+ maxWidth: getEffectiveWidth(contentWidth),
85131
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
85132
+ spaceCount: 0
85133
+ };
85134
+ const ls = run2.letterSpacing ?? 0;
85135
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85136
+ currentLine.toChar = wordEndWithSpace;
85137
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85138
+ charPosInRun = wordEndWithSpace;
85139
+ currentLine.spaceCount += 1;
85140
+ } else {
85141
+ charPosInRun = wordEndWithSpace;
85142
+ }
85143
+ } else {
85144
+ const chunkLineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85145
+ const metrics = calculateTypographyMetrics(run2.fontSize, spacing, getFontInfoFromRun(run2));
85146
+ const chunkLine = {
85147
+ fromRun: runIndex,
85148
+ fromChar: chunkStartChar,
85149
+ toRun: runIndex,
85150
+ toChar: chunkEndChar,
85151
+ width: chunk.width,
85152
+ maxWidth: chunkLineMaxWidth,
85153
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
85154
+ ...metrics
85155
+ };
85156
+ addBarTabsToLine(chunkLine);
85157
+ lines.push(chunkLine);
85158
+ }
85159
+ chunkCharOffset = chunkEndChar;
85160
+ }
85161
+ continue;
85162
+ }
85027
85163
  if (!currentLine) {
85028
85164
  currentLine = {
85029
85165
  fromRun: runIndex,
@@ -85602,6 +85738,35 @@ const measureRunWidth = (text, font, ctx2, run2) => {
85602
85738
  const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
85603
85739
  return roundValue(width);
85604
85740
  };
85741
+ const breakWordIntoChunks = (word, maxWidth, font, ctx2, run2) => {
85742
+ const chunks = [];
85743
+ if (maxWidth <= 0) {
85744
+ for (const char of word) {
85745
+ const charWidth = measureRunWidth(char, font, ctx2, run2);
85746
+ chunks.push({ text: char, width: charWidth });
85747
+ }
85748
+ return chunks;
85749
+ }
85750
+ let currentChunk = "";
85751
+ let currentWidth = 0;
85752
+ for (let i = 0; i < word.length; i++) {
85753
+ const char = word[i];
85754
+ const testChunk = currentChunk + char;
85755
+ const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
85756
+ if (testWidth > maxWidth && currentChunk.length > 0) {
85757
+ chunks.push({ text: currentChunk, width: currentWidth });
85758
+ currentChunk = char;
85759
+ currentWidth = measureRunWidth(char, font, ctx2, run2);
85760
+ } else {
85761
+ currentChunk = testChunk;
85762
+ currentWidth = testWidth;
85763
+ }
85764
+ }
85765
+ if (currentChunk.length > 0) {
85766
+ chunks.push({ text: currentChunk, width: currentWidth });
85767
+ }
85768
+ return chunks;
85769
+ };
85605
85770
  const appendSegment = (segments, runIndex, fromChar, toChar, width, x2) => {
85606
85771
  if (!segments) return;
85607
85772
  const last = segments[segments.length - 1];