oasis-editor 0.0.82 → 0.0.83

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.
@@ -1,21 +1,148 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { a as assertNever, c as createSignal, b as createEditorStateFromDocument, d as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, f as fontSizePxToPt, p as probeLocalFontFamilies, e as createEditorParagraphFromRuns, i as isInlineObjectRun, g as createEditorStyledRun, h as getParagraphLength, j as getParagraphText, k as getActiveZone, l as getDocumentSections, m as getActiveSectionIndex, n as getParagraphs, o as normalizeSelection, q as positionToParagraphOffset, r as paragraphOffsetToPosition, s as clampPosition, t as findParagraphIndex, u as createCollapsedSelection, v as isSelectionCollapsed, w as parseFontSizePtToPx, x as formatFontSizePt, y as createEditorParagraph, z as getBlockParagraphs, A as findParagraphTableLocation, B as buildTableCellLayout, P as PT_PER_PX, C as createEditorTableCell, D as createEditorTableRow, E as createEditorTable, F as underlineStyleToCssDecorationStyle, G as resolveImageSrc, H as listKindForTag, I as isParagraphTag, J as collectInlineRuns, K as parseParagraphStyle, L as InlineShell, M as BalloonShell, N as DocumentShell, O as createMemo, Q as buildCanvasLayoutSnapshot, R as getCaretRectFromSnapshot, T as getParagraphRectFromSnapshot, U as createComponent, V as CaretOverlay, W as Show, X as createRenderEffect, Y as style, Z as setAttribute, _ as setStyleProperty, $ as memo, a0 as template, a1 as useI18n, a2 as createEffect, a3 as insert, a4 as use, a5 as addEventListener, a6 as Dialog, a7 as delegateEvents, a8 as className, a9 as For, aa as UNDERLINE_STYLE_OPTIONS, ab as Tabs, ac as onMount, ad as onCleanup, ae as PluginUiHost, af as OasisEditorEditor, ag as OasisBrandMark, ah as setPreciseFontPreference, ai as setWelcomeSeen, aj as enablePreciseFontMode, ak as TWIPS_PER_POINT, al as PX_PER_INCH, am as TWIPS_PER_INCH, an as resolveEffectiveParagraphStyle, ao as resolveEffectiveTextStyleForParagraph, ap as EMU_PER_PX, aq as EMU_PER_PT, ar as visitRun, as as iterateFootnoteReferenceRuns, at as iterateEndnoteReferenceRuns, au as imageContentTypeDefaults, av as createEditorRun, aw as JSZip, ax as imageExtensionFromMime, ay as pxToPt$1, az as resolveFloatingObjectRect, aA as getTextBoxFloatingGeometry, aB as getPresetPathSegments, aC as projectBlocksLayout, aD as buildListLabels, aE as textStyleToFontSizePt, aF as PX_PER_POINT, aG as DEFAULT_FONT_SIZE_PX, aH as isDoubleUnderlineStyle, aI as isWavyUnderlineStyle, aJ as underlineStyleLineWidthPx, aK as underlineStyleDashArray, aL as resolveListLabel, aM as getListLabelInset, aN as getAlignedListLabelInset, aO as getParagraphBorderInsets, aP as buildSegmentTable, aQ as buildCanvasTableLayout, aR as normalizeFamily, aS as ROBOTO_FONT_FILES, aT as loadFontAsset, aU as OFFICE_COMPAT_FONT_FAMILIES, aV as buildSfnt, aW as defaultFontDecoderRegistry, aX as SfntFontProgram, aY as collectPdfFontFamilies, aZ as projectDocumentLayout, a_ as getPageContentWidth, a$ as getPageHeaderZoneTop, b0 as getPageBodyTop, b1 as getPageColumnRects, b2 as findFootnoteReference, b3 as FOOTNOTE_MARKER_GUTTER_PX, b4 as resolveImporterForFile, b5 as getDocumentSectionsCanonical, b6 as getDocumentParagraphsCanonical, b7 as getDocumentParagraphs, b8 as getDocumentPageSettings, b9 as getTableCellContentWidthForParagraph, ba as on, bb as debounce, bc as unwrap, bd as perfTimer, be as createEditorDocument, bf as resolveResizedDimensions, bg as resolveTextBoxRenderHeight, bh as getToolbarStyleState, bi as getCachedCanvasImage, bj as measureParagraphMinContentWidthPx, bk as getEditableBlocksForZone, bl as findParagraphLocation, bm as createSectionBoundaryParagraph, bn as normalizePageSettings, bo as DEFAULT_EDITOR_PAGE_SETTINGS, bp as markStart, bq as markEnd, br as getParagraphEntries, bs as getParagraphById, bt as createEditorFootnote, bu as createFootnoteReferenceRun, bv as renumberFootnotes, bw as getFootnoteDisplayMarker, bx as getHeadingLevel, by as preciseFontModeVersion, bz as isPreciseFontModeEnabled, bA as togglePreciseFontMode, bB as nextFontSizePt, bC as previousFontSizePt, bD as fontSizePtToPx, bE as createDefaultToolbarPreset, bF as MenuRegistry, bG as createToolbarRegistry, bH as Editor, bI as resolveCommandRef, bJ as commandRefName, bK as createOasisEditorClient, bL as createEditorZoom, bM as startLongTaskObserver, bN as installGlobalReport, bO as applyStoredPreciseFontPreference, bP as getWelcomeSeen, bQ as isLocalFontAccessSupported, bR as EDITOR_SCROLL_PADDING_PX, bS as Toolbar, bT as OasisEditorLoading, bU as I18nProvider, bV as createTranslator, bW as createEditorLogger, bX as registerDomStatsSurface } from "./index-BNz5Hsd-.js";
4
+ import { v as visitRun, a as assertNever, c as createSignal, b as createEditorStateFromDocument, d as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, f as fontSizePxToPt, p as probeLocalFontFamilies, e as createEditorParagraphFromRuns, i as isInlineObjectRun, g as createEditorStyledRun, h as getParagraphLength, j as getParagraphText, k as getActiveZone, l as getDocumentSections, m as getActiveSectionIndex, n as getParagraphs, o as normalizeSelection, q as positionToParagraphOffset, r as paragraphOffsetToPosition, s as clampPosition, t as findParagraphIndex, u as createCollapsedSelection, w as isSelectionCollapsed, x as parseFontSizePtToPx, y as formatFontSizePt, z as createEditorParagraph, A as getBlockParagraphs, B as findParagraphTableLocation, C as buildTableCellLayout, P as PT_PER_PX, D as createEditorTableCell, E as createEditorTableRow, F as createEditorTable, G as underlineStyleToCssDecorationStyle, H as resolveImageSrc, I as listKindForTag, J as isParagraphTag, K as collectInlineRuns, L as parseParagraphStyle, M as getRunImage, N as InlineShell, O as BalloonShell, Q as DocumentShell, R as createMemo, T as buildCanvasLayoutSnapshot, U as getCaretRectFromSnapshot, V as getParagraphRectFromSnapshot, W as createComponent, X as CaretOverlay, Y as Show, Z as createRenderEffect, _ as style, $ as setAttribute, a0 as setStyleProperty, a1 as memo, a2 as template, a3 as useI18n, a4 as createEffect, a5 as insert, a6 as use, a7 as addEventListener, a8 as Dialog, a9 as delegateEvents, aa as className, ab as For, ac as UNDERLINE_STYLE_OPTIONS, ad as Tabs, ae as onMount, af as onCleanup, ag as PluginUiHost, ah as OasisEditorEditor, ai as OasisBrandMark, aj as setPreciseFontPreference, ak as setWelcomeSeen, al as enablePreciseFontMode, am as TWIPS_PER_POINT, an as PX_PER_INCH, ao as TWIPS_PER_INCH, ap as resolveEffectiveParagraphStyle, aq as resolveEffectiveTextStyleForParagraph, ar as EMU_PER_PX, as as EMU_PER_PT, at as getRunFootnoteReference, au as getRunEndnoteReference, av as iterateFootnoteReferenceRuns, aw as iterateEndnoteReferenceRuns, ax as imageContentTypeDefaults, ay as getRunFieldChar, az as getRunFieldInstruction, aA as createEditorRun, aB as JSZip, aC as imageExtensionFromMime, aD as pxToPt$1, aE as resolveFloatingObjectRect, aF as getTextBoxFloatingGeometry, aG as getPresetPathSegments, aH as projectBlocksLayout, aI as buildListLabels, aJ as textStyleToFontSizePt, aK as PX_PER_POINT, aL as DEFAULT_FONT_SIZE_PX, aM as isDoubleUnderlineStyle, aN as isWavyUnderlineStyle, aO as underlineStyleLineWidthPx, aP as underlineStyleDashArray, aQ as resolveListLabel, aR as getListLabelInset, aS as getAlignedListLabelInset, aT as getParagraphBorderInsets, aU as buildSegmentTable, aV as buildCanvasTableLayout, aW as normalizeFamily, aX as ROBOTO_FONT_FILES, aY as loadFontAsset, aZ as OFFICE_COMPAT_FONT_FAMILIES, a_ as buildSfnt, a$ as defaultFontDecoderRegistry, b0 as SfntFontProgram, b1 as collectPdfFontFamilies, b2 as projectDocumentLayout, b3 as getPageContentWidth, b4 as getPageHeaderZoneTop, b5 as getPageBodyTop, b6 as getPageColumnRects, b7 as findFootnoteReference, b8 as FOOTNOTE_MARKER_GUTTER_PX, b9 as resolveImporterForFile, ba as getDocumentSectionsCanonical, bb as getDocumentParagraphsCanonical, bc as getDocumentParagraphs, bd as getDocumentPageSettings, be as getTableCellContentWidthForParagraph, bf as on, bg as debounce, bh as unwrap, bi as perfTimer, bj as getRunTextBox, bk as createEditorDocument, bl as resolveResizedDimensions, bm as resolveTextBoxRenderHeight, bn as getToolbarStyleState, bo as getCachedCanvasImage, bp as measureParagraphMinContentWidthPx, bq as getEditableBlocksForZone, br as findParagraphLocation, bs as createSectionBoundaryParagraph, bt as normalizePageSettings, bu as DEFAULT_EDITOR_PAGE_SETTINGS, bv as markStart, bw as markEnd, bx as getParagraphEntries, by as getParagraphById, bz as createEditorFootnote, bA as createFootnoteReferenceRun, bB as renumberFootnotes, bC as getFootnoteDisplayMarker, bD as getHeadingLevel, bE as preciseFontModeVersion, bF as isPreciseFontModeEnabled, bG as togglePreciseFontMode, bH as nextFontSizePt, bI as previousFontSizePt, bJ as fontSizePtToPx, bK as createDefaultToolbarPreset, bL as MenuRegistry, bM as createToolbarRegistry, bN as Editor, bO as resolveCommandRef, bP as commandRefName, bQ as createOasisEditorClient, bR as createEditorZoom, bS as startLongTaskObserver, bT as installGlobalReport, bU as applyStoredPreciseFontPreference, bV as getWelcomeSeen, bW as isLocalFontAccessSupported, bX as EDITOR_SCROLL_PADDING_PX, bY as Toolbar, bZ as OasisEditorLoading, b_ as I18nProvider, b$ as createTranslator, c0 as createEditorLogger, c1 as registerDomStatsSurface } from "./index-CF99ClZS.js";
5
+ function cloneStyle(style2) {
6
+ return style2 ? { ...style2 } : void 0;
7
+ }
8
+ function stylesEqual(left, right) {
9
+ return JSON.stringify(left ?? null) === JSON.stringify(right ?? null);
10
+ }
11
+ function setBooleanStyle(style2, key, enabled) {
12
+ const next = { ...style2 ?? {} };
13
+ if (enabled) {
14
+ next[key] = true;
15
+ } else {
16
+ delete next[key];
17
+ }
18
+ return Object.keys(next).length > 0 ? next : void 0;
19
+ }
20
+ function setValueStyle(style2, key, value) {
21
+ const next = { ...style2 ?? {} };
22
+ if (value === null || value === void 0 || value === "") {
23
+ delete next[key];
24
+ } else {
25
+ next[key] = value;
26
+ }
27
+ return Object.keys(next).length > 0 ? next : void 0;
28
+ }
29
+ function setParagraphStyleValue(style2, key, value) {
30
+ const next = { ...style2 ?? {} };
31
+ if (value === null || value === void 0) {
32
+ delete next[key];
33
+ } else {
34
+ next[key] = value;
35
+ }
36
+ return Object.keys(next).length > 0 ? next : void 0;
37
+ }
38
+ function cloneTextBox(textBox) {
39
+ return {
40
+ ...textBox,
41
+ floating: textBox.floating ? {
42
+ ...textBox.floating,
43
+ positionH: textBox.floating.positionH ? { ...textBox.floating.positionH } : void 0,
44
+ positionV: textBox.floating.positionV ? { ...textBox.floating.positionV } : void 0
45
+ } : void 0,
46
+ shape: textBox.shape ? { ...textBox.shape } : void 0,
47
+ body: textBox.body ? { ...textBox.body } : void 0,
48
+ blocks: cloneBlocks(textBox.blocks)
49
+ };
50
+ }
51
+ function cloneRun(run) {
52
+ const base = {
53
+ id: run.id,
54
+ text: run.text,
55
+ styles: cloneStyle(run.styles),
56
+ revision: run.revision ? { ...run.revision } : void 0
57
+ };
58
+ return visitRun(run, {
59
+ text: () => ({ ...base, kind: "text" }),
60
+ image: (r) => ({ ...base, kind: "image", image: { ...r.image } }),
61
+ textBox: (r) => ({
62
+ ...base,
63
+ kind: "textBox",
64
+ textBox: cloneTextBox(r.textBox)
65
+ }),
66
+ field: (r) => ({ ...base, kind: "field", field: { ...r.field } }),
67
+ fieldChar: (r) => ({
68
+ ...base,
69
+ kind: "fieldChar",
70
+ fieldChar: { ...r.fieldChar }
71
+ }),
72
+ fieldInstruction: (r) => ({
73
+ ...base,
74
+ kind: "fieldInstruction",
75
+ fieldInstruction: r.fieldInstruction
76
+ }),
77
+ footnoteReference: (r) => ({
78
+ ...base,
79
+ kind: "footnoteReference",
80
+ footnoteReference: { ...r.footnoteReference }
81
+ }),
82
+ endnoteReference: (r) => ({
83
+ ...base,
84
+ kind: "endnoteReference",
85
+ endnoteReference: { ...r.endnoteReference }
86
+ }),
87
+ sym: (r) => ({ ...base, kind: "sym", sym: { ...r.sym } })
88
+ });
89
+ }
90
+ function cloneParagraph(paragraph) {
91
+ return {
92
+ ...paragraph,
93
+ runs: paragraph.runs.map(cloneRun),
94
+ style: paragraph.style ? { ...paragraph.style } : void 0,
95
+ list: paragraph.list ? { ...paragraph.list } : void 0
96
+ };
97
+ }
98
+ function cloneParagraphList(list) {
99
+ return list ? { ...list } : void 0;
100
+ }
101
+ function cloneParagraphs(paragraphs) {
102
+ return paragraphs.map(cloneParagraph);
103
+ }
104
+ function cloneBlocks(blocks) {
105
+ return blocks.map((block) => {
106
+ switch (block.type) {
107
+ case "paragraph":
108
+ return cloneParagraph(block);
109
+ case "table":
110
+ return {
111
+ ...block,
112
+ style: block.style ? {
113
+ ...block.style,
114
+ defaultCellMargins: block.style.defaultCellMargins ? { ...block.style.defaultCellMargins } : void 0,
115
+ floating: block.style.floating ? { ...block.style.floating } : void 0,
116
+ revisionXml: block.style.revisionXml ? [...block.style.revisionXml] : void 0
117
+ } : void 0,
118
+ tblGridChangeXml: block.tblGridChangeXml,
119
+ rows: block.rows.map((row) => ({
120
+ ...row,
121
+ style: row.style ? {
122
+ ...row.style,
123
+ revisionXml: row.style.revisionXml ? [...row.style.revisionXml] : void 0
124
+ } : void 0,
125
+ cells: row.cells.map((cell) => ({
126
+ ...cell,
127
+ style: cell.style ? {
128
+ ...cell.style,
129
+ revisionXml: cell.style.revisionXml ? [...cell.style.revisionXml] : void 0
130
+ } : void 0,
131
+ blocks: cloneParagraphs(cell.blocks)
132
+ }))
133
+ }))
134
+ };
135
+ default:
136
+ return assertNever(block, "block");
137
+ }
138
+ });
139
+ }
5
140
  function cloneBlock(block) {
6
141
  switch (block.type) {
7
142
  case "paragraph":
8
143
  return {
9
144
  ...block,
10
- runs: block.runs.map((run) => ({
11
- ...run,
12
- styles: run.styles ? { ...run.styles } : void 0,
13
- image: run.image ? { ...run.image } : void 0,
14
- field: run.field ? { ...run.field } : void 0,
15
- revision: run.revision ? { ...run.revision } : void 0,
16
- footnoteReference: run.footnoteReference ? { ...run.footnoteReference } : void 0,
17
- endnoteReference: run.endnoteReference ? { ...run.endnoteReference } : void 0
18
- })),
145
+ runs: block.runs.map(cloneRun),
19
146
  style: block.style ? { ...block.style } : void 0,
20
147
  list: block.list ? { ...block.list } : void 0
21
148
  };
@@ -46,15 +173,7 @@ function cloneBlock(block) {
46
173
  } : void 0,
47
174
  blocks: cell.blocks.map((paragraph) => ({
48
175
  ...paragraph,
49
- runs: paragraph.runs.map((run) => ({
50
- ...run,
51
- styles: run.styles ? { ...run.styles } : void 0,
52
- image: run.image ? { ...run.image } : void 0,
53
- field: run.field ? { ...run.field } : void 0,
54
- revision: run.revision ? { ...run.revision } : void 0,
55
- footnoteReference: run.footnoteReference ? { ...run.footnoteReference } : void 0,
56
- endnoteReference: run.endnoteReference ? { ...run.endnoteReference } : void 0
57
- })),
176
+ runs: paragraph.runs.map(cloneRun),
58
177
  style: paragraph.style ? { ...paragraph.style } : void 0,
59
178
  list: paragraph.list ? { ...paragraph.list } : void 0
60
179
  }))
@@ -26643,115 +26762,6 @@ function createEditorFontOptions(ctx) {
26643
26762
  loadLocalFontFamilyOptions
26644
26763
  };
26645
26764
  }
26646
- function cloneStyle(style2) {
26647
- return style2 ? { ...style2 } : void 0;
26648
- }
26649
- function stylesEqual(left, right) {
26650
- return JSON.stringify(left ?? null) === JSON.stringify(right ?? null);
26651
- }
26652
- function setBooleanStyle(style2, key, enabled) {
26653
- const next = { ...style2 ?? {} };
26654
- if (enabled) {
26655
- next[key] = true;
26656
- } else {
26657
- delete next[key];
26658
- }
26659
- return Object.keys(next).length > 0 ? next : void 0;
26660
- }
26661
- function setValueStyle(style2, key, value) {
26662
- const next = { ...style2 ?? {} };
26663
- if (value === null || value === void 0 || value === "") {
26664
- delete next[key];
26665
- } else {
26666
- next[key] = value;
26667
- }
26668
- return Object.keys(next).length > 0 ? next : void 0;
26669
- }
26670
- function setParagraphStyleValue(style2, key, value) {
26671
- const next = { ...style2 ?? {} };
26672
- if (value === null || value === void 0) {
26673
- delete next[key];
26674
- } else {
26675
- next[key] = value;
26676
- }
26677
- return Object.keys(next).length > 0 ? next : void 0;
26678
- }
26679
- function cloneTextBox(textBox) {
26680
- return {
26681
- ...textBox,
26682
- floating: textBox.floating ? {
26683
- ...textBox.floating,
26684
- positionH: textBox.floating.positionH ? { ...textBox.floating.positionH } : void 0,
26685
- positionV: textBox.floating.positionV ? { ...textBox.floating.positionV } : void 0
26686
- } : void 0,
26687
- shape: textBox.shape ? { ...textBox.shape } : void 0,
26688
- body: textBox.body ? { ...textBox.body } : void 0,
26689
- blocks: cloneBlocks(textBox.blocks)
26690
- };
26691
- }
26692
- function cloneRun(run) {
26693
- return {
26694
- ...run,
26695
- styles: cloneStyle(run.styles),
26696
- image: run.image ? { ...run.image } : void 0,
26697
- textBox: run.textBox ? cloneTextBox(run.textBox) : void 0,
26698
- field: run.field ? { ...run.field } : void 0,
26699
- fieldChar: run.fieldChar ? { ...run.fieldChar } : void 0,
26700
- revision: run.revision ? { ...run.revision } : void 0,
26701
- footnoteReference: run.footnoteReference ? { ...run.footnoteReference } : void 0,
26702
- endnoteReference: run.endnoteReference ? { ...run.endnoteReference } : void 0
26703
- };
26704
- }
26705
- function cloneParagraph(paragraph) {
26706
- return {
26707
- ...paragraph,
26708
- runs: paragraph.runs.map(cloneRun),
26709
- style: paragraph.style ? { ...paragraph.style } : void 0,
26710
- list: paragraph.list ? { ...paragraph.list } : void 0
26711
- };
26712
- }
26713
- function cloneParagraphList(list) {
26714
- return list ? { ...list } : void 0;
26715
- }
26716
- function cloneParagraphs(paragraphs) {
26717
- return paragraphs.map(cloneParagraph);
26718
- }
26719
- function cloneBlocks(blocks) {
26720
- return blocks.map((block) => {
26721
- switch (block.type) {
26722
- case "paragraph":
26723
- return cloneParagraph(block);
26724
- case "table":
26725
- return {
26726
- ...block,
26727
- style: block.style ? {
26728
- ...block.style,
26729
- defaultCellMargins: block.style.defaultCellMargins ? { ...block.style.defaultCellMargins } : void 0,
26730
- floating: block.style.floating ? { ...block.style.floating } : void 0,
26731
- revisionXml: block.style.revisionXml ? [...block.style.revisionXml] : void 0
26732
- } : void 0,
26733
- tblGridChangeXml: block.tblGridChangeXml,
26734
- rows: block.rows.map((row) => ({
26735
- ...row,
26736
- style: row.style ? {
26737
- ...row.style,
26738
- revisionXml: row.style.revisionXml ? [...row.style.revisionXml] : void 0
26739
- } : void 0,
26740
- cells: row.cells.map((cell) => ({
26741
- ...cell,
26742
- style: cell.style ? {
26743
- ...cell.style,
26744
- revisionXml: cell.style.revisionXml ? [...cell.style.revisionXml] : void 0
26745
- } : void 0,
26746
- blocks: cloneParagraphs(cell.blocks)
26747
- }))
26748
- }))
26749
- };
26750
- default:
26751
- return assertNever(block, "block");
26752
- }
26753
- });
26754
- }
26755
26765
  function normalizeRuns(runs, fallbackStyles) {
26756
26766
  const merged = [];
26757
26767
  for (const run of runs) {
@@ -26859,7 +26869,7 @@ function expandLinkRangeInParagraph(paragraph, offset) {
26859
26869
  var _a, _b, _c;
26860
26870
  const resolved = getRunAtOffset(paragraph, offset);
26861
26871
  const href = (_a = resolved == null ? void 0 : resolved.run.styles) == null ? void 0 : _a.link;
26862
- if (!resolved || !href || resolved.run.image) {
26872
+ if (!resolved || !href || resolved.run.kind === "image") {
26863
26873
  return null;
26864
26874
  }
26865
26875
  let startOffset = resolved.startOffset;
@@ -26877,14 +26887,14 @@ function expandLinkRangeInParagraph(paragraph, offset) {
26877
26887
  endOffset = consumed + resolved.run.text.length;
26878
26888
  for (let index = runIndex - 1; index >= 0; index -= 1) {
26879
26889
  const run = runs[index];
26880
- if (run.image || ((_b = run.styles) == null ? void 0 : _b.link) !== href) {
26890
+ if (run.kind === "image" || ((_b = run.styles) == null ? void 0 : _b.link) !== href) {
26881
26891
  break;
26882
26892
  }
26883
26893
  startOffset -= run.text.length;
26884
26894
  }
26885
26895
  for (let index = runIndex + 1; index < runs.length; index += 1) {
26886
26896
  const run = runs[index];
26887
- if (run.image || ((_c = run.styles) == null ? void 0 : _c.link) !== href) {
26897
+ if (run.kind === "image" || ((_c = run.styles) == null ? void 0 : _c.link) !== href) {
26888
26898
  break;
26889
26899
  }
26890
26900
  endOffset += run.text.length;
@@ -26908,31 +26918,13 @@ function sliceRuns(paragraph, startOffset, endOffset) {
26908
26918
  const overlapStart = Math.max(start, runStart);
26909
26919
  const overlapEnd = Math.min(end, runEnd);
26910
26920
  if (overlapStart < overlapEnd) {
26911
- const isObjectRun = isInlineObjectRun(run);
26912
- const piece = {
26913
- id: `run:${Math.random().toString(36).slice(2, 9)}`,
26914
- text: isObjectRun ? "" : run.text.slice(overlapStart - runStart, overlapEnd - runStart)
26915
- };
26916
- if (run.styles) {
26917
- piece.styles = { ...run.styles };
26918
- }
26919
- if (run.image) {
26920
- piece.image = { ...run.image };
26921
- }
26922
- if (run.textBox) {
26923
- piece.textBox = cloneTextBox(run.textBox);
26924
- }
26925
- if (run.revision) {
26926
- piece.revision = { ...run.revision };
26927
- }
26928
- if (run.field) {
26929
- piece.field = { ...run.field };
26930
- }
26931
- if (run.footnoteReference) {
26932
- piece.footnoteReference = { ...run.footnoteReference };
26933
- }
26934
- if (run.endnoteReference) {
26935
- piece.endnoteReference = { ...run.endnoteReference };
26921
+ const piece = cloneRun(run);
26922
+ piece.id = `run:${Math.random().toString(36).slice(2, 9)}`;
26923
+ if (!isInlineObjectRun(run)) {
26924
+ piece.text = run.text.slice(
26925
+ overlapStart - runStart,
26926
+ overlapEnd - runStart
26927
+ );
26936
26928
  }
26937
26929
  pieces.push(piece);
26938
26930
  }
@@ -27503,7 +27495,8 @@ function insertTextAtSelection(state, text, styleOverride) {
27503
27495
  const insertedRun = {
27504
27496
  id: `run:${Math.random().toString(36).slice(2, 9)}`,
27505
27497
  text,
27506
- styles
27498
+ styles,
27499
+ kind: "text"
27507
27500
  };
27508
27501
  if (collapsedState.trackChangesEnabled) {
27509
27502
  insertedRun.revision = {
@@ -27611,6 +27604,7 @@ function deleteBackward(state) {
27611
27604
  const deletionRun = {
27612
27605
  id: `run:${Math.random().toString(36).slice(2, 9)}`,
27613
27606
  text: charToDelete,
27607
+ kind: "text",
27614
27608
  styles: { ...targetRun.styles },
27615
27609
  revision: {
27616
27610
  id: `rev:${Math.random().toString(36).slice(2, 9)}`,
@@ -27719,6 +27713,7 @@ function deleteForward(state) {
27719
27713
  const deletionRun = {
27720
27714
  id: `run:${Math.random().toString(36).slice(2, 9)}`,
27721
27715
  text: charToDelete,
27716
+ kind: "text",
27722
27717
  styles: { ...targetRun.styles },
27723
27718
  revision: {
27724
27719
  id: `rev:${Math.random().toString(36).slice(2, 9)}`,
@@ -29406,7 +29401,7 @@ function textLanguageToHtmlAttributes(language) {
29406
29401
  }
29407
29402
  function serializeImageRunToHtml(run, document2) {
29408
29403
  var _a;
29409
- if (!run.image) {
29404
+ if (run.kind !== "image") {
29410
29405
  return "";
29411
29406
  }
29412
29407
  const resolvedSrc = resolveImageSrc(document2, run.image.src);
@@ -29418,7 +29413,7 @@ function serializeImageRunToHtml(run, document2) {
29418
29413
  return img;
29419
29414
  }
29420
29415
  function serializeTextRunToHtml(run, document2) {
29421
- if (run.image) {
29416
+ if (run.kind === "image") {
29422
29417
  return serializeImageRunToHtml(run, document2);
29423
29418
  }
29424
29419
  const text = escapeHtml(run.text).replace(/\n/g, "<br>");
@@ -29786,11 +29781,14 @@ function parseEditorClipboardHtmlWithDom(html) {
29786
29781
  const appendParagraph = (element, runs, list) => {
29787
29782
  const fallbackRuns = runs.length > 0 ? runs : [createEditorStyledRun("")];
29788
29783
  paragraphs.push({
29789
- runs: fallbackRuns.map((run) => ({
29790
- text: run.text,
29791
- styles: cloneStyle(run.styles),
29792
- image: run.image ? { ...run.image } : void 0
29793
- })),
29784
+ runs: fallbackRuns.map((run) => {
29785
+ const image = getRunImage(run);
29786
+ return {
29787
+ text: run.text,
29788
+ styles: cloneStyle(run.styles),
29789
+ image: image ? { ...image } : void 0
29790
+ };
29791
+ }),
29794
29792
  style: element ? parseParagraphStyle(element) : void 0,
29795
29793
  list
29796
29794
  });
@@ -33086,7 +33084,7 @@ function serializeTableXml(table, serializeParagraphXml2) {
33086
33084
  {
33087
33085
  id: "",
33088
33086
  type: "paragraph",
33089
- runs: [{ id: "", text: "" }]
33087
+ runs: [{ id: "", text: "", kind: "text" }]
33090
33088
  }
33091
33089
  ];
33092
33090
  const paragraphsXml = paragraphs.map((paragraph) => serializeParagraphXml2(paragraph, cell)).join("");
@@ -33817,7 +33815,7 @@ function serializeFootnoteRefMarker() {
33817
33815
  return serializeNoteRefMarker("footnote");
33818
33816
  }
33819
33817
  function serializeFootnoteReference(run, materializedRunStyle, context) {
33820
- const ref = run.footnoteReference;
33818
+ const ref = getRunFootnoteReference(run);
33821
33819
  return serializeNoteReference(
33822
33820
  "footnote",
33823
33821
  ref ? { noteId: ref.footnoteId, customMark: ref.customMark } : void 0,
@@ -33829,7 +33827,7 @@ function serializeEndnoteRefMarker() {
33829
33827
  return serializeNoteRefMarker("endnote");
33830
33828
  }
33831
33829
  function serializeEndnoteReference(run, materializedRunStyle, context) {
33832
- const ref = run.endnoteReference;
33830
+ const ref = getRunEndnoteReference(run);
33833
33831
  return serializeNoteReference(
33834
33832
  "endnote",
33835
33833
  ref ? { noteId: ref.endnoteId, customMark: ref.customMark } : void 0,
@@ -33914,7 +33912,7 @@ function stripRpr(rPr) {
33914
33912
  return rPr.replace(/^<w:rPr>/, "").replace(/<\/w:rPr>$/, "");
33915
33913
  }
33916
33914
  function isSplittableTextRun(run) {
33917
- return !run.image && !run.textBox && !run.field && !run.fieldChar && run.fieldInstruction === void 0 && !run.footnoteReference && !run.endnoteReference;
33915
+ return run.kind === "text" || run.kind === "sym";
33918
33916
  }
33919
33917
  function serializeRunsWithBoundaries(runs, tokens, context, paragraphStyleId, styles) {
33920
33918
  const sorted = [...tokens].sort(
@@ -34001,7 +33999,7 @@ function serializeBlocksXml(blocks, context, styles) {
34001
33999
  }
34002
34000
  function serializeParagraphXml(paragraph, context, styles, overrides) {
34003
34001
  var _a, _b, _c;
34004
- const runs = paragraph.runs.length > 0 ? paragraph.runs : [{ id: "", text: "" }];
34002
+ const runs = paragraph.runs.length > 0 ? paragraph.runs : [{ id: "", text: "", kind: "text" }];
34005
34003
  const dropCapFrame = paragraph.dropCap ? serializeDropCapFrameParagraph(paragraph.dropCap) : "";
34006
34004
  const bookmarkEvents = (_a = context.bookmarkEventsByParagraph) == null ? void 0 : _a.get(paragraph.id);
34007
34005
  const commentEvents = (_b = context.commentEventsByParagraph) == null ? void 0 : _b.get(paragraph.id);
@@ -34050,7 +34048,7 @@ function collectReferencedFootnotesForExport(document2) {
34050
34048
  const seen = /* @__PURE__ */ new Map();
34051
34049
  let nextDocxId = FIRST_FOOTNOTE_DOCX_ID;
34052
34050
  for (const { run } of iterateFootnoteReferenceRuns(document2)) {
34053
- const ref = run.footnoteReference;
34051
+ const ref = getRunFootnoteReference(run);
34054
34052
  if (!ref) continue;
34055
34053
  if (seen.has(ref.footnoteId)) continue;
34056
34054
  const footnote = items[ref.footnoteId];
@@ -34087,7 +34085,7 @@ function createEmptyFootnoteBodyParagraph(withMarker = true) {
34087
34085
  type: "paragraph",
34088
34086
  runs: [
34089
34087
  ...withMarker ? [makeFootnoteRefMarkerRun()] : [],
34090
- { id: "synthetic:footnote-body-empty-text", text: "" }
34088
+ { id: "synthetic:footnote-body-empty-text", text: "", kind: "text" }
34091
34089
  ],
34092
34090
  style: { styleId: "FootnoteText" }
34093
34091
  };
@@ -34104,6 +34102,7 @@ function makeFootnoteRefMarkerRun() {
34104
34102
  return {
34105
34103
  id: "synthetic:footnoteRef",
34106
34104
  text: "",
34105
+ kind: "text",
34107
34106
  styles: { styleId: "FootnoteReference", superscript: true },
34108
34107
  // Tag the run so the special serializer below can intercept it.
34109
34108
  __isFootnoteRefMarker: true
@@ -34145,7 +34144,7 @@ function collectReferencedEndnotesForExport(document2) {
34145
34144
  const seen = /* @__PURE__ */ new Map();
34146
34145
  let nextDocxId = FIRST_ENDNOTE_DOCX_ID;
34147
34146
  for (const { run } of iterateEndnoteReferenceRuns(document2)) {
34148
- const ref = run.endnoteReference;
34147
+ const ref = getRunEndnoteReference(run);
34149
34148
  if (!ref) continue;
34150
34149
  if (seen.has(ref.endnoteId)) continue;
34151
34150
  const endnote = items[ref.endnoteId];
@@ -34182,7 +34181,7 @@ function createEmptyEndnoteBodyParagraph(withMarker = true) {
34182
34181
  type: "paragraph",
34183
34182
  runs: [
34184
34183
  ...withMarker ? [makeEndnoteRefMarkerRun()] : [],
34185
- { id: "synthetic:endnote-body-empty-text", text: "" }
34184
+ { id: "synthetic:endnote-body-empty-text", text: "", kind: "text" }
34186
34185
  ],
34187
34186
  style: { styleId: "EndnoteText" }
34188
34187
  };
@@ -34199,6 +34198,7 @@ function makeEndnoteRefMarkerRun() {
34199
34198
  return {
34200
34199
  id: "synthetic:endnoteRef",
34201
34200
  text: "",
34201
+ kind: "text",
34202
34202
  styles: { styleId: "EndnoteReference", superscript: true },
34203
34203
  __isEndnoteRefMarker: true
34204
34204
  };
@@ -34446,7 +34446,7 @@ function buildPartRelationshipsXml(images, hyperlinks) {
34446
34446
  function visitParagraphDeep(paragraph, callback) {
34447
34447
  callback(paragraph);
34448
34448
  for (const run of paragraph.runs) {
34449
- if (run.textBox) {
34449
+ if (run.kind === "textBox") {
34450
34450
  visitBlocks(run.textBox.blocks, callback);
34451
34451
  }
34452
34452
  }
@@ -34621,14 +34621,20 @@ const IMAGE_CAPTION_STYLE_ID = "Caption";
34621
34621
  const IMAGE_CAPTION_FIELD_IDENTIFIER = "Figure";
34622
34622
  const IMAGE_CAPTION_FIELD_INSTRUCTION = " SEQ Figure \\* ARABIC ";
34623
34623
  function createFieldCharRun(kind) {
34624
- const run = createEditorRun("");
34625
- run.fieldChar = { kind };
34626
- return run;
34624
+ return {
34625
+ id: createEditorRun("").id,
34626
+ text: "",
34627
+ kind: "fieldChar",
34628
+ fieldChar: { kind }
34629
+ };
34627
34630
  }
34628
34631
  function createFieldInstructionRun(instruction) {
34629
- const run = createEditorRun("");
34630
- run.fieldInstruction = instruction;
34631
- return run;
34632
+ return {
34633
+ id: createEditorRun("").id,
34634
+ text: "",
34635
+ kind: "fieldInstruction",
34636
+ fieldInstruction: instruction
34637
+ };
34632
34638
  }
34633
34639
  function createImageCaptionParagraph(captionText, label, sequenceNumber) {
34634
34640
  const paragraph = createEditorParagraphFromRuns([
@@ -34657,11 +34663,12 @@ function isImageCaptionParagraph(paragraph) {
34657
34663
  if (styleId !== "caption") {
34658
34664
  return false;
34659
34665
  }
34660
- return paragraph.runs.some(
34661
- (run) => run.fieldInstruction !== void 0 && new RegExp(`\\bSEQ\\s+${IMAGE_CAPTION_FIELD_IDENTIFIER}\\b`, "i").test(
34662
- run.fieldInstruction
34663
- )
34664
- );
34666
+ return paragraph.runs.some((run) => {
34667
+ const instruction = getRunFieldInstruction(run);
34668
+ return instruction !== void 0 && new RegExp(`\\bSEQ\\s+${IMAGE_CAPTION_FIELD_IDENTIFIER}\\b`, "i").test(
34669
+ instruction
34670
+ );
34671
+ });
34665
34672
  }
34666
34673
  function getImageCaptionText(paragraph) {
34667
34674
  var _a;
@@ -34675,7 +34682,7 @@ function getImageCaptionText(paragraph) {
34675
34682
  value += run.text;
34676
34683
  continue;
34677
34684
  }
34678
- if (((_a = run.fieldChar) == null ? void 0 : _a.kind) === "end") {
34685
+ if (((_a = getRunFieldChar(run)) == null ? void 0 : _a.kind) === "end") {
34679
34686
  afterField = true;
34680
34687
  }
34681
34688
  }
@@ -34699,12 +34706,11 @@ function renumberCaptionParagraph(paragraph, sequenceNumber) {
34699
34706
  let insideSeqResult = false;
34700
34707
  let changed = false;
34701
34708
  const nextRuns = paragraph.runs.map((run) => {
34702
- var _a, _b;
34703
- if (((_a = run.fieldChar) == null ? void 0 : _a.kind) === "separate") {
34709
+ if (run.kind === "fieldChar" && run.fieldChar.kind === "separate") {
34704
34710
  insideSeqResult = true;
34705
34711
  return { ...run, fieldChar: { ...run.fieldChar } };
34706
34712
  }
34707
- if (((_b = run.fieldChar) == null ? void 0 : _b.kind) === "end") {
34713
+ if (run.kind === "fieldChar" && run.fieldChar.kind === "end") {
34708
34714
  insideSeqResult = false;
34709
34715
  return { ...run, fieldChar: { ...run.fieldChar } };
34710
34716
  }
@@ -34791,11 +34797,11 @@ function buildPartContext(blocks, numberingContext, state, document2) {
34791
34797
  hyperlinkMap.set(link, rId2);
34792
34798
  hyperlinks.push({ rId: rId2, href: link });
34793
34799
  }
34794
- if (run.textBox && !textBoxDocPrIds.has(run.id)) {
34800
+ if (run.kind === "textBox" && !textBoxDocPrIds.has(run.id)) {
34795
34801
  textBoxDocPrIds.set(run.id, state.nextTextBoxDocPrId);
34796
34802
  state.nextTextBoxDocPrId += 1;
34797
34803
  }
34798
- if (!run.image) {
34804
+ if (run.kind !== "image") {
34799
34805
  continue;
34800
34806
  }
34801
34807
  const imageNumber = state.nextImageId;
@@ -37743,7 +37749,7 @@ function isFloatingFixedPosition(floating) {
37743
37749
  return ((_a = floating == null ? void 0 : floating.positionV) == null ? void 0 : _a.relativeFrom) === "page";
37744
37750
  }
37745
37751
  function getSelectedImageRun(state) {
37746
- return getSelectedObjectRun(state, (run) => Boolean(run.image));
37752
+ return getSelectedObjectRun(state, (run) => run.kind === "image");
37747
37753
  }
37748
37754
  function insertImageAtSelection(state, image) {
37749
37755
  const collapsedState = isSelectionCollapsed(state.selection) ? state : deleteSelectionRange(state);
@@ -37778,7 +37784,7 @@ function resizeSelectedImage(state, width, height) {
37778
37784
  return {
37779
37785
  ...cloneParagraph(candidate),
37780
37786
  runs: candidate.runs.map(
37781
- (run) => run.id === targetRun.id && run.image ? {
37787
+ (run) => run.id === targetRun.id && run.kind === "image" ? {
37782
37788
  ...run,
37783
37789
  image: {
37784
37790
  ...run.image,
@@ -37820,7 +37826,7 @@ function rotateSelectedImage(state, rotation) {
37820
37826
  return {
37821
37827
  ...cloneParagraph(candidate),
37822
37828
  runs: candidate.runs.map(
37823
- (run) => run.id === targetRun.id && run.image ? {
37829
+ (run) => run.id === targetRun.id && run.kind === "image" ? {
37824
37830
  ...run,
37825
37831
  image: {
37826
37832
  ...run.image,
@@ -37841,19 +37847,20 @@ function rotateSelectedImage(state, rotation) {
37841
37847
  }
37842
37848
  function getSelectedImageWrapPreset(state) {
37843
37849
  const selectedImage = getSelectedImageRun(state);
37844
- if (!(selectedImage == null ? void 0 : selectedImage.run.image)) {
37850
+ const image = selectedImage && getRunImage(selectedImage.run);
37851
+ if (!image) {
37845
37852
  return null;
37846
37853
  }
37847
- return floatingToWrapPreset(selectedImage.run.image.floating);
37854
+ return floatingToWrapPreset(image.floating);
37848
37855
  }
37849
37856
  function isSelectedImageFixedPosition(state) {
37850
- var _a;
37851
37857
  const selectedImage = getSelectedImageRun(state);
37852
- return isFloatingFixedPosition((_a = selectedImage == null ? void 0 : selectedImage.run.image) == null ? void 0 : _a.floating);
37858
+ const image = selectedImage && getRunImage(selectedImage.run);
37859
+ return isFloatingFixedPosition(image == null ? void 0 : image.floating);
37853
37860
  }
37854
37861
  function patchSelectedImageFloating(state, next) {
37855
37862
  const selectedImage = getSelectedImageRun(state);
37856
- if (!(selectedImage == null ? void 0 : selectedImage.run.image)) {
37863
+ if (!selectedImage || !getRunImage(selectedImage.run)) {
37857
37864
  return state;
37858
37865
  }
37859
37866
  const paragraphs = getParagraphs(state);
@@ -37865,7 +37872,7 @@ function patchSelectedImageFloating(state, next) {
37865
37872
  return {
37866
37873
  ...cloneParagraph(candidate),
37867
37874
  runs: candidate.runs.map((run) => {
37868
- if (run.id !== targetRun.id || !run.image) {
37875
+ if (run.id !== targetRun.id || run.kind !== "image") {
37869
37876
  return cloneRun(run);
37870
37877
  }
37871
37878
  const floating = next(run.image.floating);
@@ -37904,13 +37911,13 @@ function setImageWrapPolygon(state, runId, polygon) {
37904
37911
  const paragraphs = getParagraphs(state);
37905
37912
  let matched = false;
37906
37913
  const nextParagraphs = paragraphs.map((candidate) => {
37907
- if (!candidate.runs.some((run) => run.id === runId && run.image)) {
37914
+ if (!candidate.runs.some((run) => run.id === runId && run.kind === "image")) {
37908
37915
  return cloneParagraph(candidate);
37909
37916
  }
37910
37917
  return {
37911
37918
  ...cloneParagraph(candidate),
37912
37919
  runs: candidate.runs.map((run) => {
37913
- if (run.id !== runId || !run.image) {
37920
+ if (run.id !== runId || run.kind !== "image") {
37914
37921
  return cloneRun(run);
37915
37922
  }
37916
37923
  matched = true;
@@ -37938,7 +37945,7 @@ function setImageWrapPolygon(state, runId, polygon) {
37938
37945
  }
37939
37946
  function setSelectedImageAlt(state, alt) {
37940
37947
  const selectedImage = getSelectedImageRun(state);
37941
- if (!(selectedImage == null ? void 0 : selectedImage.run.image)) {
37948
+ if (!selectedImage || !getRunImage(selectedImage.run)) {
37942
37949
  return state;
37943
37950
  }
37944
37951
  const paragraphs = getParagraphs(state);
@@ -37949,7 +37956,7 @@ function setSelectedImageAlt(state, alt) {
37949
37956
  return {
37950
37957
  ...cloneParagraph(candidate),
37951
37958
  runs: candidate.runs.map(
37952
- (run) => run.id === selectedImage.run.id && run.image ? {
37959
+ (run) => run.id === selectedImage.run.id && run.kind === "image" ? {
37953
37960
  ...run,
37954
37961
  image: {
37955
37962
  ...run.image,
@@ -37970,7 +37977,7 @@ function setSelectedImageAlt(state, alt) {
37970
37977
  }
37971
37978
  function getSelectedImageCaption(state) {
37972
37979
  const selectedImage = getSelectedImageRun(state);
37973
- if (!(selectedImage == null ? void 0 : selectedImage.run.image)) {
37980
+ if (!selectedImage || !getRunImage(selectedImage.run)) {
37974
37981
  return null;
37975
37982
  }
37976
37983
  const paragraphs = getParagraphs(state);
@@ -37978,7 +37985,7 @@ function getSelectedImageCaption(state) {
37978
37985
  }
37979
37986
  function setSelectedImageCaption(state, captionText, label) {
37980
37987
  const selectedImage = getSelectedImageRun(state);
37981
- if (!(selectedImage == null ? void 0 : selectedImage.run.image)) {
37988
+ if (!selectedImage || !getRunImage(selectedImage.run)) {
37982
37989
  return state;
37983
37990
  }
37984
37991
  const paragraphs = getParagraphs(state);
@@ -38048,7 +38055,7 @@ function moveSelectedImageToPosition(state, targetPosition) {
38048
38055
  createEditorStyledRun(
38049
38056
  "",
38050
38057
  getStyleAtOffset(paragraph, offset),
38051
- imageRun.image
38058
+ getRunImage(imageRun)
38052
38059
  )
38053
38060
  ]
38054
38061
  );
@@ -39105,7 +39112,7 @@ function createIndexedDbPersistence(options = {}) {
39105
39112
  };
39106
39113
  }
39107
39114
  function computeLayoutInvalidationFromTransaction(prev, next) {
39108
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
39115
+ var _a, _b, _c, _d, _e, _f;
39109
39116
  if (prev === next || prev.document === next.document) {
39110
39117
  return {};
39111
39118
  }
@@ -39147,7 +39154,9 @@ function computeLayoutInvalidationFromTransaction(prev, next) {
39147
39154
  changed = true;
39148
39155
  break;
39149
39156
  }
39150
- if (Boolean(a.image) !== Boolean(b.image) || (((_a = a.image) == null ? void 0 : _a.width) ?? -1) !== (((_b = b.image) == null ? void 0 : _b.width) ?? -1) || (((_c = a.image) == null ? void 0 : _c.height) ?? -1) !== (((_d = b.image) == null ? void 0 : _d.height) ?? -1) || (((_f = (_e = a.image) == null ? void 0 : _e.floating) == null ? void 0 : _f.wrap) ?? "") !== (((_h = (_g = b.image) == null ? void 0 : _g.floating) == null ? void 0 : _h.wrap) ?? "") || Boolean((_j = (_i = a.image) == null ? void 0 : _i.floating) == null ? void 0 : _j.behindDoc) !== Boolean((_l = (_k = b.image) == null ? void 0 : _k.floating) == null ? void 0 : _l.behindDoc) || (((_n = (_m = a.image) == null ? void 0 : _m.wrapPolygon) == null ? void 0 : _n.length) ?? -1) !== (((_p = (_o = b.image) == null ? void 0 : _o.wrapPolygon) == null ? void 0 : _p.length) ?? -1)) {
39157
+ const aImage = getRunImage(a);
39158
+ const bImage = getRunImage(b);
39159
+ if (Boolean(aImage) !== Boolean(bImage) || ((aImage == null ? void 0 : aImage.width) ?? -1) !== ((bImage == null ? void 0 : bImage.width) ?? -1) || ((aImage == null ? void 0 : aImage.height) ?? -1) !== ((bImage == null ? void 0 : bImage.height) ?? -1) || (((_a = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _a.wrap) ?? "") !== (((_b = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _b.wrap) ?? "") || Boolean((_c = aImage == null ? void 0 : aImage.floating) == null ? void 0 : _c.behindDoc) !== Boolean((_d = bImage == null ? void 0 : bImage.floating) == null ? void 0 : _d.behindDoc) || (((_e = aImage == null ? void 0 : aImage.wrapPolygon) == null ? void 0 : _e.length) ?? -1) !== (((_f = bImage == null ? void 0 : bImage.wrapPolygon) == null ? void 0 : _f.length) ?? -1)) {
39151
39160
  changed = true;
39152
39161
  break;
39153
39162
  }
@@ -39381,7 +39390,7 @@ function createEditorDocumentRuntime(deps) {
39381
39390
  }
39382
39391
  const MIN_TEXT_BOX_SIZE_PX = 24;
39383
39392
  function getSelectedTextBoxRun(state) {
39384
- return getSelectedObjectRun(state, (run) => Boolean(run.textBox));
39393
+ return getSelectedObjectRun(state, (run) => run.kind === "textBox");
39385
39394
  }
39386
39395
  function shiftFloatingForResize(floating, widthDelta, heightDelta, growsFromWest, growsFromNorth) {
39387
39396
  let next = floating;
@@ -39420,7 +39429,7 @@ function normalizeRotation(rotation) {
39420
39429
  }
39421
39430
  function rotateSelectedTextBox(state, rotation) {
39422
39431
  const selected = getSelectedTextBoxRun(state);
39423
- if (!selected || !selected.run.textBox) {
39432
+ if (!selected || !getRunTextBox(selected.run)) {
39424
39433
  return state;
39425
39434
  }
39426
39435
  const nextRotation = normalizeRotation(rotation);
@@ -39433,7 +39442,7 @@ function rotateSelectedTextBox(state, rotation) {
39433
39442
  return {
39434
39443
  ...cloneParagraph(candidate),
39435
39444
  runs: candidate.runs.map(
39436
- (run) => run.id === targetRun.id && run.textBox ? {
39445
+ (run) => run.id === targetRun.id && run.kind === "textBox" ? {
39437
39446
  ...run,
39438
39447
  textBox: { ...run.textBox, rotation: nextRotation }
39439
39448
  } : cloneRun(run)
@@ -39451,19 +39460,20 @@ function rotateSelectedTextBox(state, rotation) {
39451
39460
  }
39452
39461
  function getSelectedTextBoxWrapPreset(state) {
39453
39462
  const selected = getSelectedTextBoxRun(state);
39454
- if (!(selected == null ? void 0 : selected.run.textBox)) {
39463
+ const textBox = selected && getRunTextBox(selected.run);
39464
+ if (!textBox) {
39455
39465
  return null;
39456
39466
  }
39457
- return floatingToWrapPreset(selected.run.textBox.floating);
39467
+ return floatingToWrapPreset(textBox.floating);
39458
39468
  }
39459
39469
  function isSelectedTextBoxFixedPosition(state) {
39460
- var _a;
39461
39470
  const selected = getSelectedTextBoxRun(state);
39462
- return isFloatingFixedPosition((_a = selected == null ? void 0 : selected.run.textBox) == null ? void 0 : _a.floating);
39471
+ const textBox = selected && getRunTextBox(selected.run);
39472
+ return isFloatingFixedPosition(textBox == null ? void 0 : textBox.floating);
39463
39473
  }
39464
39474
  function patchSelectedTextBoxFloating(state, next) {
39465
39475
  const selected = getSelectedTextBoxRun(state);
39466
- if (!(selected == null ? void 0 : selected.run.textBox)) {
39476
+ if (!selected || !getRunTextBox(selected.run)) {
39467
39477
  return state;
39468
39478
  }
39469
39479
  const { paragraphIndex, run: targetRun } = selected;
@@ -39475,7 +39485,7 @@ function patchSelectedTextBoxFloating(state, next) {
39475
39485
  return {
39476
39486
  ...cloneParagraph(candidate),
39477
39487
  runs: candidate.runs.map((run) => {
39478
- if (run.id !== targetRun.id || !run.textBox) {
39488
+ if (run.id !== targetRun.id || run.kind !== "textBox") {
39479
39489
  return cloneRun(run);
39480
39490
  }
39481
39491
  const floating = next(run.textBox.floating);
@@ -39512,7 +39522,8 @@ function setSelectedTextBoxFixedPosition(state, fixed) {
39512
39522
  }
39513
39523
  function resizeSelectedTextBox(state, width, height, options = {}) {
39514
39524
  const selected = getSelectedTextBoxRun(state);
39515
- if (!selected || !selected.run.textBox) {
39525
+ const selectedTextBox = selected && getRunTextBox(selected.run);
39526
+ if (!selected || !selectedTextBox) {
39516
39527
  return state;
39517
39528
  }
39518
39529
  const direction = options.handleDirection ?? "se";
@@ -39522,8 +39533,8 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
39522
39533
  const nextWidth = Math.max(MIN_TEXT_BOX_SIZE_PX, Math.round(width));
39523
39534
  const nextHeight = Math.max(MIN_TEXT_BOX_SIZE_PX, Math.round(height));
39524
39535
  const { paragraphIndex, run: targetRun } = selected;
39525
- const widthDelta = nextWidth - selected.run.textBox.width;
39526
- const heightDelta = nextHeight - selected.run.textBox.height;
39536
+ const widthDelta = nextWidth - selectedTextBox.width;
39537
+ const heightDelta = nextHeight - selectedTextBox.height;
39527
39538
  const paragraphs = getParagraphs(state);
39528
39539
  const nextParagraphs = paragraphs.map((candidate, candidateIndex) => {
39529
39540
  if (candidateIndex !== paragraphIndex) {
@@ -39533,7 +39544,7 @@ function resizeSelectedTextBox(state, width, height, options = {}) {
39533
39544
  ...cloneParagraph(candidate),
39534
39545
  runs: candidate.runs.map((run) => {
39535
39546
  var _a;
39536
- if (run.id !== targetRun.id || !run.textBox) {
39547
+ if (run.id !== targetRun.id || run.kind !== "textBox") {
39537
39548
  return cloneRun(run);
39538
39549
  }
39539
39550
  const textBox = run.textBox;
@@ -41054,7 +41065,7 @@ function createEditorImageOperations(deps) {
41054
41065
  for (const run of paragraph.runs) {
41055
41066
  const startOffset = offset;
41056
41067
  offset += run.text.length;
41057
- if (run.image && run.text.length === 1 && startOffset === normalized.startParagraphOffset) {
41068
+ if (run.kind === "image" && run.text.length === 1 && startOffset === normalized.startParagraphOffset) {
41058
41069
  return {
41059
41070
  paragraph,
41060
41071
  run,
@@ -41281,15 +41292,16 @@ function createEditorImageOperations(deps) {
41281
41292
  function createEditorTextBoxOperations(deps) {
41282
41293
  const getSelectedTextBoxSize = (current) => {
41283
41294
  const selected = getSelectedTextBoxRun(current);
41284
- if (!(selected == null ? void 0 : selected.run.textBox)) {
41295
+ const textBox = selected && getRunTextBox(selected.run);
41296
+ if (!textBox) {
41285
41297
  return null;
41286
41298
  }
41287
41299
  return {
41288
- width: selected.run.textBox.width,
41300
+ width: textBox.width,
41289
41301
  // Start the drag from the height actually painted on screen. For an
41290
41302
  // auto-fit box that is its content height, not the stored height, so the
41291
41303
  // box doesn't jump on the first pointer move.
41292
- height: resolveTextBoxRenderHeight(selected.run.textBox, current, 0)
41304
+ height: resolveTextBoxRenderHeight(textBox, current, 0)
41293
41305
  };
41294
41306
  };
41295
41307
  const resizeSession = createResizeSession(
@@ -42214,7 +42226,7 @@ function createEditorLayoutOptionsController(deps) {
42214
42226
  );
42215
42227
  if (preset === "tight" || preset === "through") {
42216
42228
  const selected = getSelectedImageRun(state());
42217
- const image = selected == null ? void 0 : selected.run.image;
42229
+ const image = selected && getRunImage(selected.run);
42218
42230
  if (image && !image.wrapPolygon) {
42219
42231
  ensureImageWrapContour(selected.run.id, image.src);
42220
42232
  }
@@ -44411,7 +44423,7 @@ function nextAutoMarker(document2) {
44411
44423
  let autoCount = startAt - 1;
44412
44424
  const seen = /* @__PURE__ */ new Set();
44413
44425
  for (const { run } of iterateFootnoteReferenceRuns(document2)) {
44414
- const ref = run.footnoteReference;
44426
+ const ref = getRunFootnoteReference(run);
44415
44427
  if (!ref || ref.customMark) continue;
44416
44428
  if (seen.has(ref.footnoteId)) continue;
44417
44429
  seen.add(ref.footnoteId);
@@ -44602,7 +44614,7 @@ function getLinkAtSelection(state) {
44602
44614
  const startOffset = paragraphIndex === normalized.startIndex ? normalized.startParagraphOffset : 0;
44603
44615
  const endOffset = paragraphIndex === normalized.endIndex ? normalized.endParagraphOffset : getParagraphLength(paragraph);
44604
44616
  return sliceRuns(paragraph, startOffset, endOffset);
44605
- }).filter((run) => run.text.length > 0 && !run.image);
44617
+ }).filter((run) => run.text.length > 0 && run.kind !== "image");
44606
44618
  if (touchedRuns.length === 0) {
44607
44619
  return null;
44608
44620
  }
@@ -45129,7 +45141,7 @@ function createEditorCommandsController(deps) {
45129
45141
  if (!run) {
45130
45142
  return;
45131
45143
  }
45132
- const currentAlt = ((_a = run.run.image) == null ? void 0 : _a.alt) ?? "";
45144
+ const currentAlt = ((_a = getRunImage(run.run)) == null ? void 0 : _a.alt) ?? "";
45133
45145
  deps.openImageAltDialog(currentAlt);
45134
45146
  };
45135
45147
  const applyImageCaptionCommand = (caption) => {
@@ -45929,8 +45941,19 @@ function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
45929
45941
  return headings;
45930
45942
  }
45931
45943
  function makeRun(partial) {
45932
- const run = createEditorRun(partial.text ?? "");
45933
- return { ...run, ...partial, id: run.id };
45944
+ const id = createEditorRun(partial.text).id;
45945
+ if (partial.fieldChar) {
45946
+ return { id, text: partial.text, kind: "fieldChar", fieldChar: partial.fieldChar };
45947
+ }
45948
+ if (partial.fieldInstruction !== void 0) {
45949
+ return {
45950
+ id,
45951
+ text: partial.text,
45952
+ kind: "fieldInstruction",
45953
+ fieldInstruction: partial.fieldInstruction
45954
+ };
45955
+ }
45956
+ return { id, text: partial.text, kind: "text" };
45934
45957
  }
45935
45958
  function makeParagraph(runs, style2) {
45936
45959
  const paragraph = createEditorParagraph("");
@@ -46009,7 +46032,6 @@ function insertTableOfContents(state, resolvePage = () => void 0, maxLevel = DEF
46009
46032
  return replaceSectionBlocks(state, sectionIndex, nextBlocks, tocBlocks[0]);
46010
46033
  }
46011
46034
  function findTocRegion(blocks) {
46012
- var _a, _b, _c;
46013
46035
  let depth = 0;
46014
46036
  let instruction = "";
46015
46037
  let separateBlockIndex = -1;
@@ -46019,7 +46041,9 @@ function findTocRegion(blocks) {
46019
46041
  const block = blocks[i];
46020
46042
  if (block.type !== "paragraph") continue;
46021
46043
  for (const run of block.runs) {
46022
- if (((_a = run.fieldChar) == null ? void 0 : _a.kind) === "begin") {
46044
+ const fieldChar = getRunFieldChar(run);
46045
+ const fieldInstruction = getRunFieldInstruction(run);
46046
+ if ((fieldChar == null ? void 0 : fieldChar.kind) === "begin") {
46023
46047
  depth += 1;
46024
46048
  if (depth === 1) {
46025
46049
  beginBlockIndex = i;
@@ -46027,12 +46051,12 @@ function findTocRegion(blocks) {
46027
46051
  isToc = false;
46028
46052
  separateBlockIndex = -1;
46029
46053
  }
46030
- } else if (depth === 1 && run.fieldInstruction !== void 0) {
46031
- instruction += run.fieldInstruction;
46054
+ } else if (depth === 1 && fieldInstruction !== void 0) {
46055
+ instruction += fieldInstruction;
46032
46056
  if (/\bTOC\b/i.test(instruction)) isToc = true;
46033
- } else if (((_b = run.fieldChar) == null ? void 0 : _b.kind) === "separate") {
46057
+ } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "separate") {
46034
46058
  if (depth === 1) separateBlockIndex = i;
46035
- } else if (((_c = run.fieldChar) == null ? void 0 : _c.kind) === "end") {
46059
+ } else if ((fieldChar == null ? void 0 : fieldChar.kind) === "end") {
46036
46060
  if (depth === 1) {
46037
46061
  if (isToc) {
46038
46062
  return {