@harbour-enterprises/superdoc 1.0.0-beta.92 → 1.0.0-beta.94

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-CrMwuKcn.es.js → PdfViewer-BR7hR5hX.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-BYKB8fT_.cjs → PdfViewer-CC_fv7lS.cjs} +1 -1
  3. package/dist/chunks/{index-CqnVFwjL-zbanjw1O.cjs → index-BstIHBcW-6lPNsqaA.cjs} +1 -1
  4. package/dist/chunks/{index-CqnVFwjL-DJT5AqWq.es.js → index-BstIHBcW-BxKvjs-R.es.js} +1 -1
  5. package/dist/chunks/{index-BZloH4nq.cjs → index-DHRt1tCk.cjs} +3 -3
  6. package/dist/chunks/{index-CUUqzJ4M.es.js → index-JAE9iqTX.es.js} +3 -3
  7. package/dist/chunks/{super-editor.es-ALp2ApyE.es.js → super-editor.es-C1RjP_IO.es.js} +333 -24
  8. package/dist/chunks/{super-editor.es-DvpDTsC4.cjs → super-editor.es-DXKgM3JR.cjs} +333 -24
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-CpOA_SSA.js → converter-CIgfC-et.js} +1 -1
  11. package/dist/super-editor/chunks/{docx-zipper-zilXqAq6.js → docx-zipper-AQa91HPZ.js} +1 -1
  12. package/dist/super-editor/chunks/{editor-DvF9Gp0h.js → editor-6Tyu_6Nf.js} +334 -25
  13. package/dist/super-editor/chunks/{index-CqnVFwjL.js → index-BstIHBcW.js} +1 -1
  14. package/dist/super-editor/chunks/{toolbar-BVOTlKFf.js → toolbar-yzD6N9Br.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 +335 -26
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -42397,7 +42397,7 @@ const _SuperConverter = class _SuperConverter2 {
42397
42397
  static getStoredSuperdocVersion(docx) {
42398
42398
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
42399
42399
  }
42400
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.92") {
42400
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.94") {
42401
42401
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
42402
42402
  }
42403
42403
  /**
@@ -56547,12 +56547,12 @@ const findTrackedMarkBetween = ({
56547
56547
  const { doc: doc2 } = tr;
56548
56548
  const startPos = Math.max(from2 - offset2, 0);
56549
56549
  const endPos = Math.min(to + offset2, doc2.content.size);
56550
- let markFound;
56551
- doc2.nodesBetween(startPos, endPos, (node, pos) => {
56550
+ let markFound = null;
56551
+ const tryMatch = (node, pos) => {
56552
56552
  if (!node || node?.nodeSize === void 0) {
56553
56553
  return;
56554
56554
  }
56555
- const mark = node.marks.find(
56555
+ const mark = node.marks?.find(
56556
56556
  (mark2) => mark2.type.name === markName && Object.keys(attrs).every((attr) => mark2.attrs[attr] === attrs[attr])
56557
56557
  );
56558
56558
  if (mark && !markFound) {
@@ -56561,24 +56561,36 @@ const findTrackedMarkBetween = ({
56561
56561
  to: pos + node.nodeSize,
56562
56562
  mark
56563
56563
  };
56564
+ return false;
56564
56565
  }
56566
+ };
56567
+ doc2.nodesBetween(startPos, endPos, (node, pos) => {
56568
+ return tryMatch(node, pos);
56565
56569
  });
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
- };
56570
+ const inspectAroundPosition = (pos) => {
56571
+ if (pos < 0 || pos > doc2.content.size) {
56572
+ return;
56573
+ }
56574
+ const resolved = doc2.resolve(pos);
56575
+ const before = resolved.nodeBefore;
56576
+ if (before?.type?.name === "run") {
56577
+ const beforeStart = Math.max(pos - before.nodeSize, 0);
56578
+ const node = before.content?.content?.[0];
56579
+ if (node?.type?.name === "text") {
56580
+ tryMatch(node, beforeStart);
56581
+ }
56582
+ }
56583
+ const after = resolved.nodeAfter;
56584
+ if (after?.type?.name === "run") {
56585
+ const node = after.content?.content?.[0];
56586
+ if (node?.type?.name === "text") {
56587
+ tryMatch(node, pos);
56580
56588
  }
56581
56589
  }
56590
+ };
56591
+ if (!markFound) {
56592
+ inspectAroundPosition(startPos);
56593
+ inspectAroundPosition(endPos);
56582
56594
  }
56583
56595
  return markFound;
56584
56596
  };
@@ -59603,7 +59615,7 @@ const isHeadless = (editor) => {
59603
59615
  const shouldSkipNodeView = (editor) => {
59604
59616
  return isHeadless(editor);
59605
59617
  };
59606
- const summaryVersion = "1.0.0-beta.92";
59618
+ const summaryVersion = "1.0.0-beta.94";
59607
59619
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
59608
59620
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
59609
59621
  function mapAttributes(attrs) {
@@ -60392,7 +60404,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60392
60404
  { default: remarkStringify },
60393
60405
  { default: remarkGfm }
60394
60406
  ] = await Promise.all([
60395
- Promise.resolve().then(() => require("./index-CqnVFwjL-zbanjw1O.cjs")),
60407
+ Promise.resolve().then(() => require("./index-BstIHBcW-6lPNsqaA.cjs")),
60396
60408
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
60397
60409
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
60398
60410
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -60597,7 +60609,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
60597
60609
  * Process collaboration migrations
60598
60610
  */
60599
60611
  processCollaborationMigrations() {
60600
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.92");
60612
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.94");
60601
60613
  if (!this.options.ydoc) return;
60602
60614
  const metaMap = this.options.ydoc.getMap("meta");
60603
60615
  let docVersion = metaMap.get("version");
@@ -77474,10 +77486,31 @@ const deriveBlockVersion = (block) => {
77474
77486
  textRun.letterSpacing != null ? textRun.letterSpacing : "",
77475
77487
  textRun.pmStart ?? "",
77476
77488
  textRun.pmEnd ?? "",
77477
- textRun.token ?? ""
77489
+ textRun.token ?? "",
77490
+ // Tracked changes - force re-render when added or removed tracked change
77491
+ textRun.trackedChange ? 1 : 0
77478
77492
  ].join(",");
77479
77493
  }).join("|");
77480
- return markerVersion ? `${markerVersion}|${runsVersion}` : runsVersion;
77494
+ const attrs = block.attrs;
77495
+ const paragraphAttrsVersion = attrs ? [
77496
+ attrs.alignment ?? "",
77497
+ attrs.spacing?.before ?? "",
77498
+ attrs.spacing?.after ?? "",
77499
+ attrs.spacing?.line ?? "",
77500
+ attrs.spacing?.lineRule ?? "",
77501
+ attrs.indent?.left ?? "",
77502
+ attrs.indent?.right ?? "",
77503
+ attrs.indent?.firstLine ?? "",
77504
+ attrs.indent?.hanging ?? "",
77505
+ attrs.borders ? JSON.stringify(attrs.borders) : "",
77506
+ attrs.shading?.fill ?? "",
77507
+ attrs.shading?.color ?? "",
77508
+ attrs.direction ?? "",
77509
+ attrs.rtl ? "1" : "",
77510
+ attrs.tabs?.length ? JSON.stringify(attrs.tabs) : ""
77511
+ ].join(":") : "";
77512
+ const parts = [markerVersion, runsVersion, paragraphAttrsVersion].filter(Boolean);
77513
+ return parts.join("|");
77481
77514
  }
77482
77515
  if (block.kind === "list") {
77483
77516
  return block.items.map((item) => `${item.id}:${item.marker.text}:${deriveBlockVersion(item.paragraph)}`).join("|");
@@ -81224,6 +81257,33 @@ const MAX_CACHE_SIZE$1 = 1e4;
81224
81257
  const BYTES_PER_ENTRY_ESTIMATE = 5e3;
81225
81258
  const NORMALIZED_WHITESPACE = /\s+/g;
81226
81259
  const normalizeText = (text) => text.replace(NORMALIZED_WHITESPACE, " ");
81260
+ const hashParagraphBorder = (border) => {
81261
+ const parts = [];
81262
+ if (border.style !== void 0) parts.push(`s:${border.style}`);
81263
+ if (border.width !== void 0) parts.push(`w:${border.width}`);
81264
+ if (border.color !== void 0) parts.push(`c:${border.color}`);
81265
+ if (border.space !== void 0) parts.push(`sp:${border.space}`);
81266
+ return parts.join(",");
81267
+ };
81268
+ const hashParagraphBorders = (borders) => {
81269
+ const parts = [];
81270
+ if (borders.top) parts.push(`t:[${hashParagraphBorder(borders.top)}]`);
81271
+ if (borders.right) parts.push(`r:[${hashParagraphBorder(borders.right)}]`);
81272
+ if (borders.bottom) parts.push(`b:[${hashParagraphBorder(borders.bottom)}]`);
81273
+ if (borders.left) parts.push(`l:[${hashParagraphBorder(borders.left)}]`);
81274
+ return parts.join(";");
81275
+ };
81276
+ const hashParagraphFrame = (frame) => {
81277
+ const parts = [];
81278
+ if (frame.wrap !== void 0) parts.push(`w:${frame.wrap}`);
81279
+ if (frame.x !== void 0) parts.push(`x:${frame.x}`);
81280
+ if (frame.y !== void 0) parts.push(`y:${frame.y}`);
81281
+ if (frame.xAlign !== void 0) parts.push(`xa:${frame.xAlign}`);
81282
+ if (frame.yAlign !== void 0) parts.push(`ya:${frame.yAlign}`);
81283
+ if (frame.hAnchor !== void 0) parts.push(`ha:${frame.hAnchor}`);
81284
+ if (frame.vAnchor !== void 0) parts.push(`va:${frame.vAnchor}`);
81285
+ return parts.join(",");
81286
+ };
81227
81287
  const hashRuns = (block) => {
81228
81288
  if (block.kind === "table") {
81229
81289
  const tableBlock = block;
@@ -81319,7 +81379,59 @@ const hashRuns = (block) => {
81319
81379
  numberingKey = `|num:${np.numId ?? ""}:${np.ilvl ?? 0}:${markerTextKey}`;
81320
81380
  }
81321
81381
  }
81322
- return `${trackedMode}:${trackedEnabled ? "on" : "off"}|${runsHash}${numberingKey}`;
81382
+ let paragraphAttrsKey = "";
81383
+ if (block.attrs) {
81384
+ const attrs = block.attrs;
81385
+ const parts = [];
81386
+ if (attrs.alignment) parts.push(`al:${attrs.alignment}`);
81387
+ if (attrs.spacing) {
81388
+ const s2 = attrs.spacing;
81389
+ if (s2.before !== void 0) parts.push(`sb:${s2.before}`);
81390
+ if (s2.after !== void 0) parts.push(`sa:${s2.after}`);
81391
+ if (s2.line !== void 0) parts.push(`sl:${s2.line}`);
81392
+ if (s2.lineRule) parts.push(`sr:${s2.lineRule}`);
81393
+ }
81394
+ if (attrs.indent) {
81395
+ const ind = attrs.indent;
81396
+ if (ind.left !== void 0) parts.push(`il:${ind.left}`);
81397
+ if (ind.right !== void 0) parts.push(`ir:${ind.right}`);
81398
+ if (ind.firstLine !== void 0) parts.push(`if:${ind.firstLine}`);
81399
+ if (ind.hanging !== void 0) parts.push(`ih:${ind.hanging}`);
81400
+ }
81401
+ if (attrs.borders) {
81402
+ parts.push(`br:${hashParagraphBorders(attrs.borders)}`);
81403
+ }
81404
+ if (attrs.shading) {
81405
+ const sh = attrs.shading;
81406
+ if (sh.fill) parts.push(`shf:${sh.fill}`);
81407
+ if (sh.color) parts.push(`shc:${sh.color}`);
81408
+ }
81409
+ if (attrs.tabs && attrs.tabs.length > 0) {
81410
+ const tabsHash = attrs.tabs.map((t) => `${t.val ?? ""}:${t.pos ?? ""}:${t.leader ?? ""}`).join(",");
81411
+ parts.push(`tb:${tabsHash}`);
81412
+ }
81413
+ if (attrs.direction) parts.push(`dir:${attrs.direction}`);
81414
+ if (attrs.rtl) parts.push("rtl");
81415
+ if (attrs.keepNext) parts.push("kn");
81416
+ if (attrs.keepLines) parts.push("kl");
81417
+ if (attrs.floatAlignment) parts.push(`fa:${attrs.floatAlignment}`);
81418
+ if (attrs.contextualSpacing) parts.push("cs");
81419
+ if (attrs.suppressFirstLineIndent) parts.push("sfi");
81420
+ if (attrs.dropCap) parts.push(`dc:${attrs.dropCap}`);
81421
+ if (attrs.dropCapDescriptor) {
81422
+ const dcd = attrs.dropCapDescriptor;
81423
+ parts.push(`dcd:${dcd.mode ?? ""}:${dcd.lines ?? ""}`);
81424
+ }
81425
+ if (attrs.frame) {
81426
+ parts.push(`fr:${hashParagraphFrame(attrs.frame)}`);
81427
+ }
81428
+ if (attrs.tabIntervalTwips !== void 0) parts.push(`ti:${attrs.tabIntervalTwips}`);
81429
+ if (attrs.decimalSeparator) parts.push(`ds:${attrs.decimalSeparator}`);
81430
+ if (parts.length > 0) {
81431
+ paragraphAttrsKey = `|pa:${parts.join(":")}`;
81432
+ }
81433
+ }
81434
+ return `${trackedMode}:${trackedEnabled ? "on" : "off"}|${runsHash}${numberingKey}${paragraphAttrsKey}`;
81323
81435
  };
81324
81436
  const createStats = () => ({
81325
81437
  hits: 0,
@@ -82204,6 +82316,75 @@ const getTrackedChangeKey = (run2) => {
82204
82316
  }
82205
82317
  return "";
82206
82318
  };
82319
+ const paragraphSpacingEqual = (a, b2) => {
82320
+ if (a === b2) return true;
82321
+ if (!a || !b2) return !a && !b2;
82322
+ return a.before === b2.before && a.after === b2.after && a.line === b2.line && a.lineRule === b2.lineRule && a.beforeAutospacing === b2.beforeAutospacing && a.afterAutospacing === b2.afterAutospacing;
82323
+ };
82324
+ const paragraphIndentEqual = (a, b2) => {
82325
+ if (a === b2) return true;
82326
+ if (!a || !b2) return !a && !b2;
82327
+ return a.left === b2.left && a.right === b2.right && a.firstLine === b2.firstLine && a.hanging === b2.hanging;
82328
+ };
82329
+ const paragraphBorderEqual = (a, b2) => {
82330
+ if (a === b2) return true;
82331
+ if (!a || !b2) return !a && !b2;
82332
+ return a.style === b2.style && a.width === b2.width && a.color === b2.color && a.space === b2.space;
82333
+ };
82334
+ const paragraphBordersEqual = (a, b2) => {
82335
+ if (a === b2) return true;
82336
+ if (!a || !b2) return !a && !b2;
82337
+ return paragraphBorderEqual(a.top, b2.top) && paragraphBorderEqual(a.right, b2.right) && paragraphBorderEqual(a.bottom, b2.bottom) && paragraphBorderEqual(a.left, b2.left);
82338
+ };
82339
+ const paragraphShadingEqual = (a, b2) => {
82340
+ if (a === b2) return true;
82341
+ if (!a || !b2) return !a && !b2;
82342
+ return a.fill === b2.fill && a.color === b2.color && a.val === b2.val && a.themeColor === b2.themeColor && a.themeFill === b2.themeFill && a.themeFillShade === b2.themeFillShade && a.themeFillTint === b2.themeFillTint && a.themeShade === b2.themeShade && a.themeTint === b2.themeTint;
82343
+ };
82344
+ const tabStopEqual = (a, b2) => {
82345
+ return a.val === b2.val && a.pos === b2.pos && a.leader === b2.leader;
82346
+ };
82347
+ const tabStopsEqual = (a, b2) => {
82348
+ if (a === b2) return true;
82349
+ if (!a || !b2) return !a && !b2;
82350
+ if (a.length !== b2.length) return false;
82351
+ for (let i = 0; i < a.length; i += 1) {
82352
+ if (!tabStopEqual(a[i], b2[i])) return false;
82353
+ }
82354
+ return true;
82355
+ };
82356
+ const paragraphFrameEqual = (a, b2) => {
82357
+ if (a === b2) return true;
82358
+ if (!a || !b2) return !a && !b2;
82359
+ return a.wrap === b2.wrap && a.x === b2.x && a.y === b2.y && a.xAlign === b2.xAlign && a.yAlign === b2.yAlign && a.hAnchor === b2.hAnchor && a.vAnchor === b2.vAnchor;
82360
+ };
82361
+ const dropCapDescriptorEqual = (a, b2) => {
82362
+ if (a === b2) return true;
82363
+ if (!a || !b2) return !a && !b2;
82364
+ if (a.mode !== b2.mode || a.lines !== b2.lines) return false;
82365
+ const runA = a.run;
82366
+ const runB = b2.run;
82367
+ if (!runA || !runB) return !runA && !runB;
82368
+ if (runA.text !== runB.text || runA.fontFamily !== runB.fontFamily || runA.fontSize !== runB.fontSize || runA.bold !== runB.bold || runA.italic !== runB.italic || runA.color !== runB.color) {
82369
+ return false;
82370
+ }
82371
+ return true;
82372
+ };
82373
+ const paragraphAttrsEqual = (a, b2) => {
82374
+ if (a === b2) return true;
82375
+ if (!a || !b2) return !a && !b2;
82376
+ if (a.alignment !== b2.alignment || a.contextualSpacing !== b2.contextualSpacing || a.suppressFirstLineIndent !== b2.suppressFirstLineIndent || a.dropCap !== b2.dropCap || a.decimalSeparator !== b2.decimalSeparator || a.tabIntervalTwips !== b2.tabIntervalTwips || a.keepNext !== b2.keepNext || a.keepLines !== b2.keepLines || a.direction !== b2.direction || a.rtl !== b2.rtl || a.floatAlignment !== b2.floatAlignment) {
82377
+ return false;
82378
+ }
82379
+ if (!paragraphSpacingEqual(a.spacing, b2.spacing)) return false;
82380
+ if (!paragraphIndentEqual(a.indent, b2.indent)) return false;
82381
+ if (!paragraphBordersEqual(a.borders, b2.borders)) return false;
82382
+ if (!paragraphShadingEqual(a.shading, b2.shading)) return false;
82383
+ if (!tabStopsEqual(a.tabs, b2.tabs)) return false;
82384
+ if (!paragraphFrameEqual(a.frame, b2.frame)) return false;
82385
+ if (!dropCapDescriptorEqual(a.dropCapDescriptor, b2.dropCapDescriptor)) return false;
82386
+ return true;
82387
+ };
82207
82388
  const paragraphBlocksEqual = (a, b2) => {
82208
82389
  const aMode = a.attrs?.trackedChangesMode ?? "review";
82209
82390
  const bMode = b2.attrs?.trackedChangesMode ?? "review";
@@ -82211,6 +82392,7 @@ const paragraphBlocksEqual = (a, b2) => {
82211
82392
  const aEnabled = resolveTrackedChangesEnabled(a.attrs, true);
82212
82393
  const bEnabled = resolveTrackedChangesEnabled(b2.attrs, true);
82213
82394
  if (aEnabled !== bEnabled) return false;
82395
+ if (!paragraphAttrsEqual(a.attrs, b2.attrs)) return false;
82214
82396
  if (a.runs.length !== b2.runs.length) return false;
82215
82397
  for (let i = 0; i < a.runs.length; i += 1) {
82216
82398
  const runA = a.runs[i];
@@ -84856,6 +85038,104 @@ async function measureParagraphBlock(block, maxWidth) {
84856
85038
  const wordStartChar = charPosInRun;
84857
85039
  const wordEndNoSpace = charPosInRun + word.length;
84858
85040
  const wordEndWithSpace = charPosInRun + (isLastWord ? word.length : word.length + 1);
85041
+ const effectiveMaxWidth = currentLine ? currentLine.maxWidth : getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85042
+ if (wordOnlyWidth > effectiveMaxWidth && word.length > 1) {
85043
+ if (currentLine && currentLine.width > 0 && currentLine.segments.length > 0) {
85044
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85045
+ const { spaceCount: _sc, ...lineBase } = currentLine;
85046
+ const completedLine = { ...lineBase, ...metrics };
85047
+ addBarTabsToLine(completedLine);
85048
+ lines.push(completedLine);
85049
+ tabStopCursor = 0;
85050
+ pendingTabAlignment = null;
85051
+ currentLine = null;
85052
+ }
85053
+ const lineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85054
+ const hasTabOnlyLine = currentLine && currentLine.segments.length === 0 && currentLine.width > 0;
85055
+ const remainingWidthAfterTab = hasTabOnlyLine ? currentLine.maxWidth - currentLine.width : lineMaxWidth;
85056
+ const chunkWidth = hasTabOnlyLine ? Math.max(remainingWidthAfterTab, lineMaxWidth * 0.25) : lineMaxWidth;
85057
+ const chunks = breakWordIntoChunks(word, chunkWidth - WIDTH_FUDGE_PX, font, ctx2, run2);
85058
+ let chunkCharOffset = wordStartChar;
85059
+ for (let chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
85060
+ const chunk = chunks[chunkIndex];
85061
+ const chunkStartChar = chunkCharOffset;
85062
+ const chunkEndChar = chunkCharOffset + chunk.text.length;
85063
+ const isLastChunk = chunkIndex === chunks.length - 1;
85064
+ const isFirstChunk = chunkIndex === 0;
85065
+ if (isFirstChunk && hasTabOnlyLine && currentLine) {
85066
+ currentLine.toRun = runIndex;
85067
+ currentLine.toChar = chunkEndChar;
85068
+ currentLine.width = roundValue(currentLine.width + chunk.width);
85069
+ currentLine.maxFontSize = Math.max(currentLine.maxFontSize, run2.fontSize);
85070
+ currentLine.maxFontInfo = getFontInfoFromRun(run2);
85071
+ currentLine.segments.push({
85072
+ runIndex,
85073
+ fromChar: chunkStartChar,
85074
+ toChar: chunkEndChar,
85075
+ width: chunk.width
85076
+ });
85077
+ if (isLastChunk) {
85078
+ const ls = run2.letterSpacing ?? 0;
85079
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85080
+ currentLine.toChar = wordEndWithSpace;
85081
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85082
+ charPosInRun = wordEndWithSpace;
85083
+ currentLine.spaceCount += 1;
85084
+ } else {
85085
+ charPosInRun = wordEndWithSpace;
85086
+ }
85087
+ } else {
85088
+ const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
85089
+ const { spaceCount: _sc, ...lineBase } = currentLine;
85090
+ const completedLine = { ...lineBase, ...metrics };
85091
+ addBarTabsToLine(completedLine);
85092
+ lines.push(completedLine);
85093
+ tabStopCursor = 0;
85094
+ pendingTabAlignment = null;
85095
+ currentLine = null;
85096
+ }
85097
+ } else if (isLastChunk) {
85098
+ currentLine = {
85099
+ fromRun: runIndex,
85100
+ fromChar: chunkStartChar,
85101
+ toRun: runIndex,
85102
+ toChar: chunkEndChar,
85103
+ width: chunk.width,
85104
+ maxFontSize: run2.fontSize,
85105
+ maxFontInfo: getFontInfoFromRun(run2),
85106
+ maxWidth: getEffectiveWidth(contentWidth),
85107
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
85108
+ spaceCount: 0
85109
+ };
85110
+ const ls = run2.letterSpacing ?? 0;
85111
+ if (!isLastWord && currentLine.width + spaceWidth <= currentLine.maxWidth - WIDTH_FUDGE_PX) {
85112
+ currentLine.toChar = wordEndWithSpace;
85113
+ currentLine.width = roundValue(currentLine.width + spaceWidth + ls);
85114
+ charPosInRun = wordEndWithSpace;
85115
+ currentLine.spaceCount += 1;
85116
+ } else {
85117
+ charPosInRun = wordEndWithSpace;
85118
+ }
85119
+ } else {
85120
+ const chunkLineMaxWidth = getEffectiveWidth(lines.length === 0 ? initialAvailableWidth : contentWidth);
85121
+ const metrics = calculateTypographyMetrics(run2.fontSize, spacing, getFontInfoFromRun(run2));
85122
+ const chunkLine = {
85123
+ fromRun: runIndex,
85124
+ fromChar: chunkStartChar,
85125
+ toRun: runIndex,
85126
+ toChar: chunkEndChar,
85127
+ width: chunk.width,
85128
+ maxWidth: chunkLineMaxWidth,
85129
+ segments: [{ runIndex, fromChar: chunkStartChar, toChar: chunkEndChar, width: chunk.width }],
85130
+ ...metrics
85131
+ };
85132
+ addBarTabsToLine(chunkLine);
85133
+ lines.push(chunkLine);
85134
+ }
85135
+ chunkCharOffset = chunkEndChar;
85136
+ }
85137
+ continue;
85138
+ }
84859
85139
  if (!currentLine) {
84860
85140
  currentLine = {
84861
85141
  fromRun: runIndex,
@@ -85434,6 +85714,35 @@ const measureRunWidth = (text, font, ctx2, run2) => {
85434
85714
  const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
85435
85715
  return roundValue(width);
85436
85716
  };
85717
+ const breakWordIntoChunks = (word, maxWidth, font, ctx2, run2) => {
85718
+ const chunks = [];
85719
+ if (maxWidth <= 0) {
85720
+ for (const char of word) {
85721
+ const charWidth = measureRunWidth(char, font, ctx2, run2);
85722
+ chunks.push({ text: char, width: charWidth });
85723
+ }
85724
+ return chunks;
85725
+ }
85726
+ let currentChunk = "";
85727
+ let currentWidth = 0;
85728
+ for (let i = 0; i < word.length; i++) {
85729
+ const char = word[i];
85730
+ const testChunk = currentChunk + char;
85731
+ const testWidth = measureRunWidth(testChunk, font, ctx2, run2);
85732
+ if (testWidth > maxWidth && currentChunk.length > 0) {
85733
+ chunks.push({ text: currentChunk, width: currentWidth });
85734
+ currentChunk = char;
85735
+ currentWidth = measureRunWidth(char, font, ctx2, run2);
85736
+ } else {
85737
+ currentChunk = testChunk;
85738
+ currentWidth = testWidth;
85739
+ }
85740
+ }
85741
+ if (currentChunk.length > 0) {
85742
+ chunks.push({ text: currentChunk, width: currentWidth });
85743
+ }
85744
+ return chunks;
85745
+ };
85437
85746
  const appendSegment = (segments, runIndex, fromChar, toChar, width, x2) => {
85438
85747
  if (!segments) return;
85439
85748
  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-CpOA_SSA.js";
3
- import { _ as _export_sfc } from "./chunks/editor-DvF9Gp0h.js";
2
+ import { T as TextSelection } from "./chunks/converter-CIgfC-et.js";
3
+ import { _ as _export_sfc } from "./chunks/editor-6Tyu_6Nf.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 = {}) {
@@ -42697,7 +42697,7 @@ const _SuperConverter = class _SuperConverter {
42697
42697
  static getStoredSuperdocVersion(docx) {
42698
42698
  return _SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
42699
42699
  }
42700
- static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.0.0-beta.92") {
42700
+ static setStoredSuperdocVersion(docx = this.convertedXml, version = "1.0.0-beta.94") {
42701
42701
  return _SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version, false);
42702
42702
  }
42703
42703
  /**
@@ -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-CpOA_SSA.js";
1
+ import { p as process$1, aJ as commonjsGlobal, B as Buffer, aK as getDefaultExportFromCjs, aL as getContentTypesFromXml, aM as xmljs } from "./converter-CIgfC-et.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
  }