oasis-editor 0.0.81 → 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.
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
2483
2483
  onCleanup(() => {
2484
2484
  cancelled = true;
2485
2485
  });
2486
- import("./OasisEditorApp-DmrINFOV.js").then((m) => {
2486
+ import("./OasisEditorApp-BI74x5qK.js").then((m) => {
2487
2487
  cancelled = true;
2488
2488
  setProgress(1);
2489
2489
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -3005,20 +3005,53 @@ function assertNever(value, label = "value") {
3005
3005
  const tag = value && typeof value === "object" && "type" in value ? value.type : value;
3006
3006
  throw new Error(`Unhandled ${label}: ${String(tag)}`);
3007
3007
  }
3008
- function getRunKind(run) {
3009
- if (run.footnoteReference) return "footnoteReference";
3010
- if (run.endnoteReference) return "endnoteReference";
3011
- if (run.fieldChar) return "fieldChar";
3012
- if (run.fieldInstruction !== void 0) return "fieldInstruction";
3013
- if (run.field) return "field";
3014
- if (run.textBox) return "textBox";
3015
- if (run.image) return "image";
3016
- if (run.sym) return "sym";
3017
- return "text";
3018
- }
3019
3008
  function isInlineObjectRun(run) {
3020
- const kind = getRunKind(run);
3021
- return kind === "image" || kind === "textBox";
3009
+ return run.kind === "image" || run.kind === "textBox";
3010
+ }
3011
+ function getRunImage(run) {
3012
+ return run.kind === "image" ? run.image : void 0;
3013
+ }
3014
+ function getRunTextBox(run) {
3015
+ return run.kind === "textBox" ? run.textBox : void 0;
3016
+ }
3017
+ function getRunField(run) {
3018
+ return run.kind === "field" ? run.field : void 0;
3019
+ }
3020
+ function getRunFieldChar(run) {
3021
+ return run.kind === "fieldChar" ? run.fieldChar : void 0;
3022
+ }
3023
+ function getRunFieldInstruction(run) {
3024
+ return run.kind === "fieldInstruction" ? run.fieldInstruction : void 0;
3025
+ }
3026
+ function getRunFootnoteReference(run) {
3027
+ return run.kind === "footnoteReference" ? run.footnoteReference : void 0;
3028
+ }
3029
+ function getRunEndnoteReference(run) {
3030
+ return run.kind === "endnoteReference" ? run.endnoteReference : void 0;
3031
+ }
3032
+ function visitRun(run, visitor) {
3033
+ switch (run.kind) {
3034
+ case "footnoteReference":
3035
+ return visitor.footnoteReference(run);
3036
+ case "endnoteReference":
3037
+ return visitor.endnoteReference(run);
3038
+ case "fieldChar":
3039
+ return visitor.fieldChar(run);
3040
+ case "fieldInstruction":
3041
+ return visitor.fieldInstruction(run);
3042
+ case "field":
3043
+ return visitor.field(run);
3044
+ case "textBox":
3045
+ return visitor.textBox(run);
3046
+ case "image":
3047
+ return visitor.image(run);
3048
+ case "sym":
3049
+ return visitor.sym(run);
3050
+ case "text":
3051
+ return visitor.text(run);
3052
+ default:
3053
+ return assertNever(run, "run kind");
3054
+ }
3022
3055
  }
3023
3056
  const EDITOR_ASSET_REF_PREFIX = "asset:";
3024
3057
  function asRequired(value) {
@@ -3639,7 +3672,7 @@ function collectNumberingParagraphs(document2) {
3639
3672
  const result = [];
3640
3673
  const collectTextBoxes = (paragraph) => {
3641
3674
  for (const run of paragraph.runs) {
3642
- if (run.textBox) collectBlocks2(run.textBox.blocks);
3675
+ if (run.kind === "textBox") collectBlocks2(run.textBox.blocks);
3643
3676
  }
3644
3677
  };
3645
3678
  const collectBlocks2 = (blocks) => {
@@ -3812,24 +3845,27 @@ function createEditorCommentId() {
3812
3845
  return createEditorNodeId("comment");
3813
3846
  }
3814
3847
  function createEditorRun(text = "") {
3815
- const run = {
3848
+ return {
3816
3849
  id: createEditorNodeId("run"),
3817
- text
3850
+ text,
3851
+ kind: "text"
3818
3852
  };
3819
- return run;
3820
3853
  }
3821
3854
  function createEditorStyledRun(text = "", styles, image, textBox) {
3822
- const run = createEditorRun(text);
3855
+ const base = {
3856
+ id: createEditorNodeId("run"),
3857
+ text
3858
+ };
3823
3859
  if (styles) {
3824
- run.styles = { ...styles };
3860
+ base.styles = { ...styles };
3825
3861
  }
3826
3862
  if (image) {
3827
- run.image = { ...image };
3863
+ return { ...base, kind: "image", image: { ...image } };
3828
3864
  }
3829
3865
  if (textBox) {
3830
- run.textBox = textBox;
3866
+ return { ...base, kind: "textBox", textBox };
3831
3867
  }
3832
- return run;
3868
+ return { ...base, kind: "text" };
3833
3869
  }
3834
3870
  function createEditorParagraph(text = "") {
3835
3871
  const paragraph = {
@@ -3907,10 +3943,14 @@ function createFootnoteReferenceRun(footnoteId, marker, options) {
3907
3943
  superscript: true,
3908
3944
  ...{}
3909
3945
  };
3910
- const run = createEditorStyledRun(marker, styles);
3911
3946
  const reference = { footnoteId };
3912
- run.footnoteReference = reference;
3913
- return run;
3947
+ return {
3948
+ id: createEditorNodeId("run"),
3949
+ text: marker,
3950
+ styles,
3951
+ kind: "footnoteReference",
3952
+ footnoteReference: reference
3953
+ };
3914
3954
  }
3915
3955
  const DEFAULT_EDITOR_STYLES = {
3916
3956
  normal: {
@@ -5097,7 +5137,7 @@ function sliceParagraph(paragraph, startOffset, endOffset) {
5097
5137
  });
5098
5138
  return {
5099
5139
  ...paragraph,
5100
- runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "" }]
5140
+ runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "", kind: "text" }]
5101
5141
  };
5102
5142
  }
5103
5143
  const FOOTNOTE_SEPARATOR_HEIGHT = 10;
@@ -5117,8 +5157,9 @@ function collectFootnoteReferencesFromBlock(block) {
5117
5157
  let runStart = 0;
5118
5158
  for (const run of paragraph.runs) {
5119
5159
  const runEnd = runStart + run.text.length;
5120
- if (run.footnoteReference && runEnd > startOffset && runStart < endOffset) {
5121
- result.push(run.footnoteReference.footnoteId);
5160
+ const footnoteReference = getRunFootnoteReference(run);
5161
+ if (footnoteReference && runEnd > startOffset && runStart < endOffset) {
5162
+ result.push(footnoteReference.footnoteId);
5122
5163
  }
5123
5164
  runStart = runEnd;
5124
5165
  }
@@ -10774,6 +10815,8 @@ function buildParagraphFragments(paragraph) {
10774
10815
  paragraphOffset: paragraphOffset + index,
10775
10816
  runOffset: index
10776
10817
  }));
10818
+ const runImage = getRunImage(run);
10819
+ const runTextBox = getRunTextBox(run);
10777
10820
  const fragment = {
10778
10821
  paragraphId: paragraph.id,
10779
10822
  runId: run.id,
@@ -10781,8 +10824,8 @@ function buildParagraphFragments(paragraph) {
10781
10824
  endOffset: paragraphOffset + run.text.length,
10782
10825
  text: run.text,
10783
10826
  styles: run.styles ? { ...run.styles } : void 0,
10784
- image: run.image ? { ...run.image } : void 0,
10785
- textBox: run.textBox ? { ...run.textBox } : void 0,
10827
+ image: runImage ? { ...runImage } : void 0,
10828
+ textBox: runTextBox ? { ...runTextBox } : void 0,
10786
10829
  revision: run.revision ? { ...run.revision } : void 0,
10787
10830
  chars: chars2
10788
10831
  };
@@ -10990,7 +11033,8 @@ function getParagraphLineHeight(paragraph, styles, fallbackFontSize) {
10990
11033
  { ...runTextStyle, fontSize },
10991
11034
  lineHeight
10992
11035
  );
10993
- const imageHeight = run.image && !run.image.floating ? run.image.height : 0;
11036
+ const image = getRunImage(run);
11037
+ const imageHeight = image && !image.floating ? image.height : 0;
10994
11038
  return Math.max(largest, runLineHeight + baselineShiftPx, imageHeight);
10995
11039
  }, 0);
10996
11040
  const renderedLineHeight = Math.max(
@@ -11349,8 +11393,10 @@ function measureParagraphMinContentWidthPx(paragraph, styles) {
11349
11393
  return Math.max(largest, token.width);
11350
11394
  }, 0);
11351
11395
  const largestInlineObject = paragraph.runs.reduce((largest, run) => {
11352
- const imageWidth = run.image && !run.image.floating ? run.image.width : 0;
11353
- const textBoxWidth = run.textBox && !run.textBox.floating ? run.textBox.width : 0;
11396
+ const image = getRunImage(run);
11397
+ const textBox = getRunTextBox(run);
11398
+ const imageWidth = image && !image.floating ? image.width : 0;
11399
+ const textBoxWidth = textBox && !textBox.floating ? textBox.width : 0;
11354
11400
  return Math.max(largest, imageWidth, textBoxWidth);
11355
11401
  }, 0);
11356
11402
  return Math.max(1, inset + largestUnbreakableToken, largestInlineObject);
@@ -12003,14 +12049,14 @@ function clearProjectedParagraphLayoutCache() {
12003
12049
  paragraphLayoutCache = /* @__PURE__ */ new WeakMap();
12004
12050
  }
12005
12051
  function getParagraphFieldDependence(paragraph) {
12006
- var _a, _b;
12007
12052
  const cached = paragraphFieldDependenceCache.get(paragraph);
12008
12053
  if (cached) return cached;
12009
12054
  let dependsOnPageIndex = false;
12010
12055
  let dependsOnTotalPages = false;
12011
12056
  for (const run of paragraph.runs) {
12012
- if (((_a = run.field) == null ? void 0 : _a.type) === "PAGE") dependsOnPageIndex = true;
12013
- else if (((_b = run.field) == null ? void 0 : _b.type) === "NUMPAGES") dependsOnTotalPages = true;
12057
+ const field = getRunField(run);
12058
+ if ((field == null ? void 0 : field.type) === "PAGE") dependsOnPageIndex = true;
12059
+ else if ((field == null ? void 0 : field.type) === "NUMPAGES") dependsOnTotalPages = true;
12014
12060
  if (dependsOnPageIndex && dependsOnTotalPages) break;
12015
12061
  }
12016
12062
  const result = { dependsOnPageIndex, dependsOnTotalPages };
@@ -12033,10 +12079,11 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
12033
12079
  let paragraphOffset = 0;
12034
12080
  const fragments = paragraph.runs.map((run) => {
12035
12081
  let resolvedText = run.text;
12036
- if (run.field) {
12037
- if (run.field.type === "PAGE") {
12082
+ const field = getRunField(run);
12083
+ if (field) {
12084
+ if (field.type === "PAGE") {
12038
12085
  resolvedText = typeof pageIndex === "number" ? String(pageIndex + 1) : "1";
12039
- } else if (run.field.type === "NUMPAGES") {
12086
+ } else if (field.type === "NUMPAGES") {
12040
12087
  resolvedText = typeof totalPages === "number" ? String(totalPages) : "1";
12041
12088
  }
12042
12089
  }
@@ -12047,6 +12094,8 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
12047
12094
  runOffset: index
12048
12095
  })
12049
12096
  );
12097
+ const runImage = getRunImage(run);
12098
+ const runTextBox = getRunTextBox(run);
12050
12099
  const fragment = {
12051
12100
  paragraphId: paragraph.id,
12052
12101
  runId: run.id,
@@ -12054,8 +12103,8 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
12054
12103
  endOffset: paragraphOffset + resolvedText.length,
12055
12104
  text: resolvedText,
12056
12105
  styles: run.styles ? { ...run.styles } : void 0,
12057
- image: run.image ? { ...run.image } : void 0,
12058
- textBox: run.textBox ? { ...run.textBox } : void 0,
12106
+ image: runImage ? { ...runImage } : void 0,
12107
+ textBox: runTextBox ? { ...runTextBox } : void 0,
12059
12108
  revision: run.revision ? { ...run.revision } : void 0,
12060
12109
  chars: chars2
12061
12110
  };
@@ -12604,7 +12653,7 @@ function estimateTableRowHeight(row, styles, measurer, defaultTabStop, contentWi
12604
12653
  let largestImageHeight = 0;
12605
12654
  for (const paragraph of cell.blocks) {
12606
12655
  for (const run of paragraph.runs) {
12607
- if (run.image && run.image.height > largestImageHeight) {
12656
+ if (run.kind === "image" && run.image.height > largestImageHeight) {
12608
12657
  const fitted = cellContentWidth !== void 0 && run.image.width > cellContentWidth ? Math.floor(
12609
12658
  run.image.height * (cellContentWidth / run.image.width)
12610
12659
  ) : run.image.height;
@@ -13234,7 +13283,7 @@ function sliceParagraphForTableSegment(paragraph, startOffset, endOffset) {
13234
13283
  });
13235
13284
  return {
13236
13285
  ...paragraph,
13237
- runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "" }]
13286
+ runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "", kind: "text" }]
13238
13287
  };
13239
13288
  }
13240
13289
  function sliceCellBlocksForTableSegment(blocks, start, end) {
@@ -13967,7 +14016,7 @@ function* iterateFootnoteReferenceRuns(document2) {
13967
14016
  for (const block of blocks) {
13968
14017
  for (const paragraph of getBlockParagraphs(block)) {
13969
14018
  for (const run of paragraph.runs) {
13970
- if (run.footnoteReference) {
14019
+ if (run.kind === "footnoteReference") {
13971
14020
  yield { paragraph, run };
13972
14021
  }
13973
14022
  }
@@ -14039,7 +14088,7 @@ function getFootnoteDisplayMarker(oneBasedIndex, format = "decimal") {
14039
14088
  function findFootnoteReference(document2, footnoteId) {
14040
14089
  var _a;
14041
14090
  for (const entry of iterateFootnoteReferenceRuns(document2)) {
14042
- if (((_a = entry.run.footnoteReference) == null ? void 0 : _a.footnoteId) === footnoteId) {
14091
+ if (((_a = getRunFootnoteReference(entry.run)) == null ? void 0 : _a.footnoteId) === footnoteId) {
14043
14092
  return entry;
14044
14093
  }
14045
14094
  }
@@ -14057,7 +14106,7 @@ function renumberFootnotes(document2) {
14057
14106
  const markerByFootnoteId = /* @__PURE__ */ new Map();
14058
14107
  let autoCounter = startAt - 1;
14059
14108
  for (const { run } of iterateFootnoteReferenceRuns(document2)) {
14060
- const ref = run.footnoteReference;
14109
+ const ref = getRunFootnoteReference(run);
14061
14110
  if (!ref) continue;
14062
14111
  referenced.add(ref.footnoteId);
14063
14112
  if (ref.customMark) {
@@ -14153,8 +14202,9 @@ function renumberFootnotes(document2) {
14153
14202
  function rewriteParagraphMarkers$1(paragraph, markerByFootnoteId) {
14154
14203
  let runChanged = false;
14155
14204
  const nextRuns = paragraph.runs.map((run) => {
14156
- if (!run.footnoteReference) return run;
14157
- const desired = markerByFootnoteId.get(run.footnoteReference.footnoteId);
14205
+ const ref = getRunFootnoteReference(run);
14206
+ if (!ref) return run;
14207
+ const desired = markerByFootnoteId.get(ref.footnoteId);
14158
14208
  if (desired === void 0) return run;
14159
14209
  if (run.text === desired) return run;
14160
14210
  runChanged = true;
@@ -14179,7 +14229,7 @@ function* iterateEndnoteReferenceRuns(document2) {
14179
14229
  for (const block of blocks) {
14180
14230
  for (const paragraph of getBlockParagraphs(block)) {
14181
14231
  for (const run of paragraph.runs) {
14182
- if (run.endnoteReference) {
14232
+ if (run.kind === "endnoteReference") {
14183
14233
  yield { paragraph, run };
14184
14234
  }
14185
14235
  }
@@ -14193,7 +14243,7 @@ function listReferencedEndnotes(document2) {
14193
14243
  const result = [];
14194
14244
  let counter2 = 0;
14195
14245
  for (const { run } of iterateEndnoteReferenceRuns(document2)) {
14196
- const ref = run.endnoteReference;
14246
+ const ref = getRunEndnoteReference(run);
14197
14247
  if (!ref) continue;
14198
14248
  if (seen.has(ref.endnoteId)) continue;
14199
14249
  seen.add(ref.endnoteId);
@@ -14220,7 +14270,7 @@ function renumberEndnotes(document2) {
14220
14270
  const markerByEndnoteId = /* @__PURE__ */ new Map();
14221
14271
  let autoCounter = startAt - 1;
14222
14272
  for (const { run } of iterateEndnoteReferenceRuns(document2)) {
14223
- const ref = run.endnoteReference;
14273
+ const ref = getRunEndnoteReference(run);
14224
14274
  if (!ref) continue;
14225
14275
  referenced.add(ref.endnoteId);
14226
14276
  if (ref.customMark) {
@@ -14313,8 +14363,9 @@ function renumberEndnotes(document2) {
14313
14363
  function rewriteParagraphMarkers(paragraph, markerByEndnoteId) {
14314
14364
  let runChanged = false;
14315
14365
  const nextRuns = paragraph.runs.map((run) => {
14316
- if (!run.endnoteReference) return run;
14317
- const desired = markerByEndnoteId.get(run.endnoteReference.endnoteId);
14366
+ const ref = getRunEndnoteReference(run);
14367
+ if (!ref) return run;
14368
+ const desired = markerByEndnoteId.get(ref.endnoteId);
14318
14369
  if (desired === void 0) return run;
14319
14370
  if (run.text === desired) return run;
14320
14371
  runChanged = true;
@@ -14328,7 +14379,8 @@ function makeMarkerRun(endnoteId, marker) {
14328
14379
  return {
14329
14380
  id: `${FLOW_ID_PREFIX}:marker:${endnoteId}`,
14330
14381
  text: `${marker}. `,
14331
- styles: { superscript: true }
14382
+ styles: { superscript: true },
14383
+ kind: "text"
14332
14384
  };
14333
14385
  }
14334
14386
  function prependMarker(paragraph, endnoteId, marker) {
@@ -14344,7 +14396,7 @@ function emptyMarkerParagraph(endnoteId, marker) {
14344
14396
  type: "paragraph",
14345
14397
  runs: [
14346
14398
  makeMarkerRun(endnoteId, marker),
14347
- { id: `${FLOW_ID_PREFIX}:text:${endnoteId}`, text: "" }
14399
+ { id: `${FLOW_ID_PREFIX}:text:${endnoteId}`, text: "", kind: "text" }
14348
14400
  ]
14349
14401
  };
14350
14402
  }
@@ -14352,7 +14404,7 @@ function spacerParagraph() {
14352
14404
  return {
14353
14405
  id: `${FLOW_ID_PREFIX}:spacer`,
14354
14406
  type: "paragraph",
14355
- runs: [{ id: `${FLOW_ID_PREFIX}:spacer:text`, text: "" }]
14407
+ runs: [{ id: `${FLOW_ID_PREFIX}:spacer:text`, text: "", kind: "text" }]
14356
14408
  };
14357
14409
  }
14358
14410
  function buildEndnoteFlowBlocks(document2) {
@@ -14405,7 +14457,7 @@ function blockContainsNumPagesField(block) {
14405
14457
  if (block.type === "paragraph") {
14406
14458
  return block.runs.some((run) => {
14407
14459
  var _a;
14408
- return ((_a = run.field) == null ? void 0 : _a.type) === "NUMPAGES";
14460
+ return ((_a = getRunField(run)) == null ? void 0 : _a.type) === "NUMPAGES";
14409
14461
  });
14410
14462
  }
14411
14463
  return block.rows.some(
@@ -14764,7 +14816,7 @@ function fitImagesToCellWidth(paragraph, maxImageWidthPx) {
14764
14816
  }
14765
14817
  let changed = false;
14766
14818
  const runs = paragraph.runs.map((run) => {
14767
- if (!run.image) return run;
14819
+ if (run.kind !== "image") return run;
14768
14820
  const { width: w, height: h } = run.image;
14769
14821
  if (w <= maxImageWidthPx) return run;
14770
14822
  const scale = maxImageWidthPx / w;
@@ -15056,7 +15108,7 @@ function buildCanvasTableLayout(options) {
15056
15108
  const anchorPosition = firstParagraph ? paragraphOffsetToPosition(firstParagraph, 0) : paragraphOffsetToPosition(
15057
15109
  {
15058
15110
  id: `table:${table.id}:r${rowIndex}:c${cellIndex}:empty`,
15059
- runs: [{ id: "run:empty", text: "" }]
15111
+ runs: [{ id: "run:empty", text: "", kind: "text" }]
15060
15112
  },
15061
15113
  0
15062
15114
  );
@@ -33731,53 +33783,69 @@ function parseDropCapFrame(paragraphProperties, runs) {
33731
33783
  style: (_a = runs[0]) == null ? void 0 : _a.styles
33732
33784
  };
33733
33785
  }
33786
+ function importedRunToEditorRun(run) {
33787
+ const base = {
33788
+ id: createEditorNodeId("run"),
33789
+ text: run.text
33790
+ };
33791
+ if (run.styles) {
33792
+ base.styles = { ...run.styles };
33793
+ }
33794
+ let editorRun;
33795
+ if (run.fieldChar) {
33796
+ editorRun = { ...base, kind: "fieldChar", fieldChar: { ...run.fieldChar } };
33797
+ } else if (run.fieldInstruction !== void 0) {
33798
+ editorRun = {
33799
+ ...base,
33800
+ kind: "fieldInstruction",
33801
+ fieldInstruction: run.fieldInstruction
33802
+ };
33803
+ } else if (run.field) {
33804
+ editorRun = { ...base, kind: "field", field: { ...run.field } };
33805
+ } else if (run.textBox) {
33806
+ editorRun = { ...base, kind: "textBox", textBox: run.textBox };
33807
+ } else if (run.image) {
33808
+ editorRun = { ...base, kind: "image", image: run.image };
33809
+ } else if (run.sym) {
33810
+ editorRun = { ...base, kind: "sym", sym: { ...run.sym } };
33811
+ } else {
33812
+ editorRun = { ...base, kind: "text" };
33813
+ }
33814
+ const withMarkers = editorRun;
33815
+ if (run.footnoteReference) {
33816
+ withMarkers.__importedFootnoteRef = { ...run.footnoteReference };
33817
+ }
33818
+ if (run.endnoteReference) {
33819
+ withMarkers.__importedEndnoteRef = { ...run.endnoteReference };
33820
+ }
33821
+ if (run.bookmark) {
33822
+ withMarkers.__importedBookmark = { ...run.bookmark };
33823
+ }
33824
+ if (run.comment) {
33825
+ withMarkers.__importedComment = { ...run.comment };
33826
+ }
33827
+ return withMarkers;
33828
+ }
33734
33829
  function createImportedParagraph(runs, paragraphStyle, list, markRunStyle) {
33735
33830
  var _a;
33736
- const paragraph = createEditorParagraphFromRuns(
33737
- runs.length > 0 ? runs.map((run) => ({
33738
- text: run.text,
33739
- styles: run.styles,
33740
- image: run.image
33741
- })) : (
33742
- // An empty paragraph still carries the formatting of its paragraph mark
33743
- // (`w:pPr/w:rPr`), which Word uses to render the blank line's font/size.
33744
- // Apply it so empty lines match Word instead of falling back to defaults.
33745
- [{ text: "", styles: markRunStyle }]
33746
- )
33831
+ const editorRuns = runs.length > 0 ? runs.map(importedRunToEditorRun) : (
33832
+ // An empty paragraph still carries the formatting of its paragraph mark
33833
+ // (`w:pPr/w:rPr`), which Word uses to render the blank line's font/size.
33834
+ // Apply it so empty lines match Word instead of falling back to defaults.
33835
+ [
33836
+ {
33837
+ id: createEditorNodeId("run"),
33838
+ text: "",
33839
+ kind: "text",
33840
+ ...markRunStyle ? { styles: { ...markRunStyle } } : {}
33841
+ }
33842
+ ]
33747
33843
  );
33748
- runs.forEach((run, index) => {
33749
- if (run.field) {
33750
- paragraph.runs[index].field = { ...run.field };
33751
- }
33752
- if (run.fieldChar) {
33753
- paragraph.runs[index].fieldChar = { ...run.fieldChar };
33754
- }
33755
- if (run.fieldInstruction !== void 0) {
33756
- paragraph.runs[index].fieldInstruction = run.fieldInstruction;
33757
- }
33758
- if (run.textBox) {
33759
- paragraph.runs[index].textBox = run.textBox;
33760
- }
33761
- if (run.footnoteReference) {
33762
- paragraph.runs[index].__importedFootnoteRef = {
33763
- ...run.footnoteReference
33764
- };
33765
- }
33766
- if (run.endnoteReference) {
33767
- paragraph.runs[index].__importedEndnoteRef = {
33768
- ...run.endnoteReference
33769
- };
33770
- }
33771
- if (run.bookmark) {
33772
- paragraph.runs[index].__importedBookmark = { ...run.bookmark };
33773
- }
33774
- if (run.comment) {
33775
- paragraph.runs[index].__importedComment = { ...run.comment };
33776
- }
33777
- if (run.sym) {
33778
- paragraph.runs[index].sym = { ...run.sym };
33779
- }
33780
- });
33844
+ const paragraph = {
33845
+ id: createEditorNodeId("paragraph"),
33846
+ type: "paragraph",
33847
+ runs: editorRuns
33848
+ };
33781
33849
  paragraph.style = paragraphStyle ? { ...paragraphStyle } : void 0;
33782
33850
  for (const run of paragraph.runs) {
33783
33851
  run.styles = normalizeImportedRunStyle(
@@ -35541,20 +35609,27 @@ function remapImportedFootnoteRefsInSections(sections, byDocxId) {
35541
35609
  var _a, _b, _c, _d, _e, _f;
35542
35610
  const remapBlock = (block) => {
35543
35611
  if (block.type === "paragraph") {
35544
- for (const run of block.runs) {
35612
+ block.runs.forEach((run, index) => {
35545
35613
  const runWithRef = run;
35546
35614
  const transient = runWithRef.__importedFootnoteRef;
35547
- if (!transient) continue;
35615
+ if (!transient) return;
35548
35616
  delete runWithRef.__importedFootnoteRef;
35549
35617
  const footnote = byDocxId.get(transient.docxId);
35550
35618
  if (!footnote) {
35551
- continue;
35619
+ return;
35552
35620
  }
35553
- run.footnoteReference = {
35554
- footnoteId: footnote.id,
35555
- ...transient.customMark ? { customMark: transient.customMark } : {}
35621
+ block.runs[index] = {
35622
+ id: run.id,
35623
+ text: run.text,
35624
+ styles: run.styles,
35625
+ revision: run.revision,
35626
+ kind: "footnoteReference",
35627
+ footnoteReference: {
35628
+ footnoteId: footnote.id,
35629
+ ...transient.customMark ? { customMark: transient.customMark } : {}
35630
+ }
35556
35631
  };
35557
- }
35632
+ });
35558
35633
  return;
35559
35634
  }
35560
35635
  for (const row of block.rows) {
@@ -35579,20 +35654,27 @@ function remapImportedEndnoteRefsInSections(sections, byDocxId) {
35579
35654
  var _a, _b, _c, _d, _e, _f;
35580
35655
  const remapBlock = (block) => {
35581
35656
  if (block.type === "paragraph") {
35582
- for (const run of block.runs) {
35657
+ block.runs.forEach((run, index) => {
35583
35658
  const runWithRef = run;
35584
35659
  const transient = runWithRef.__importedEndnoteRef;
35585
- if (!transient) continue;
35660
+ if (!transient) return;
35586
35661
  delete runWithRef.__importedEndnoteRef;
35587
35662
  const endnote = byDocxId.get(transient.docxId);
35588
35663
  if (!endnote) {
35589
- continue;
35664
+ return;
35590
35665
  }
35591
- run.endnoteReference = {
35592
- endnoteId: endnote.id,
35593
- ...transient.customMark ? { customMark: transient.customMark } : {}
35666
+ block.runs[index] = {
35667
+ id: run.id,
35668
+ text: run.text,
35669
+ styles: run.styles,
35670
+ revision: run.revision,
35671
+ kind: "endnoteReference",
35672
+ endnoteReference: {
35673
+ endnoteId: endnote.id,
35674
+ ...transient.customMark ? { customMark: transient.customMark } : {}
35675
+ }
35594
35676
  };
35595
- }
35677
+ });
35596
35678
  return;
35597
35679
  }
35598
35680
  for (const row of block.rows) {
@@ -35627,7 +35709,7 @@ function importDocxInWorker(buffer, options = {}) {
35627
35709
  const worker = new Worker(
35628
35710
  new URL(
35629
35711
  /* @vite-ignore */
35630
- "" + new URL("assets/importDocxWorker-CmygfpkG.js", import.meta.url).href,
35712
+ "" + new URL("assets/importDocxWorker-8fivvDCX.js", import.meta.url).href,
35631
35713
  import.meta.url
35632
35714
  ),
35633
35715
  {
@@ -36011,7 +36093,7 @@ function runsToParagraphSpecs(runs) {
36011
36093
  return runs.map((run) => ({
36012
36094
  text: run.text,
36013
36095
  styles: run.styles,
36014
- image: run.image
36096
+ image: getRunImage(run)
36015
36097
  }));
36016
36098
  }
36017
36099
  function buildParagraph(element, list) {
@@ -39963,194 +40045,201 @@ const OASIS_MENU_ITEMS = {
39963
40045
  formatListsNumbered: "format_lists_numbered"
39964
40046
  };
39965
40047
  export {
39966
- memo as $,
39967
- findParagraphTableLocation as A,
39968
- buildTableCellLayout as B,
39969
- createEditorTableCell as C,
39970
- createEditorTableRow as D,
39971
- createEditorTable as E,
39972
- underlineStyleToCssDecorationStyle as F,
39973
- resolveImageSrc as G,
39974
- listKindForTag as H,
39975
- isParagraphTag as I,
39976
- collectInlineRuns as J,
39977
- parseParagraphStyle as K,
39978
- InlineShell as L,
39979
- BalloonShell as M,
39980
- DocumentShell as N,
39981
- createMemo as O,
40048
+ setAttribute as $,
40049
+ getBlockParagraphs as A,
40050
+ findParagraphTableLocation as B,
40051
+ buildTableCellLayout as C,
40052
+ createEditorTableCell as D,
40053
+ createEditorTableRow as E,
40054
+ createEditorTable as F,
40055
+ underlineStyleToCssDecorationStyle as G,
40056
+ resolveImageSrc as H,
40057
+ listKindForTag as I,
40058
+ isParagraphTag as J,
40059
+ collectInlineRuns as K,
40060
+ parseParagraphStyle as L,
40061
+ getRunImage as M,
40062
+ InlineShell as N,
40063
+ BalloonShell as O,
39982
40064
  PT_PER_PX as P,
39983
- buildCanvasLayoutSnapshot as Q,
39984
- getCaretRectFromSnapshot as R,
40065
+ DocumentShell as Q,
40066
+ createMemo as R,
39985
40067
  STANDARD_FONT_SIZES_PT as S,
39986
- getParagraphRectFromSnapshot as T,
39987
- createComponent as U,
39988
- CaretOverlay as V,
39989
- Show as W,
39990
- createRenderEffect as X,
39991
- style as Y,
39992
- setAttribute as Z,
39993
- setStyleProperty as _,
40068
+ buildCanvasLayoutSnapshot as T,
40069
+ getCaretRectFromSnapshot as U,
40070
+ getParagraphRectFromSnapshot as V,
40071
+ createComponent as W,
40072
+ CaretOverlay as X,
40073
+ Show as Y,
40074
+ createRenderEffect as Z,
40075
+ style as _,
39994
40076
  assertNever as a,
39995
- getPageBodyTop as a$,
39996
- template as a0,
39997
- useI18n as a1,
39998
- createEffect as a2,
39999
- insert as a3,
40000
- use as a4,
40001
- addEventListener as a5,
40002
- Dialog as a6,
40003
- delegateEvents as a7,
40004
- className as a8,
40005
- For as a9,
40006
- getPresetPathSegments as aA,
40007
- projectBlocksLayout as aB,
40008
- buildListLabels as aC,
40009
- textStyleToFontSizePt as aD,
40010
- PX_PER_POINT as aE,
40011
- DEFAULT_FONT_SIZE_PX as aF,
40012
- isDoubleUnderlineStyle as aG,
40013
- isWavyUnderlineStyle as aH,
40014
- underlineStyleLineWidthPx as aI,
40015
- underlineStyleDashArray as aJ,
40016
- resolveListLabel as aK,
40017
- getListLabelInset as aL,
40018
- getAlignedListLabelInset as aM,
40019
- getParagraphBorderInsets as aN,
40020
- buildSegmentTable as aO,
40021
- buildCanvasTableLayout as aP,
40022
- normalizeFamily as aQ,
40023
- ROBOTO_FONT_FILES as aR,
40024
- loadFontAsset as aS,
40025
- OFFICE_COMPAT_FONT_FAMILIES as aT,
40026
- buildSfnt as aU,
40027
- defaultFontDecoderRegistry as aV,
40028
- SfntFontProgram as aW,
40029
- collectPdfFontFamilies as aX,
40030
- projectDocumentLayout as aY,
40031
- getPageContentWidth as aZ,
40032
- getPageHeaderZoneTop as a_,
40033
- UNDERLINE_STYLE_OPTIONS as aa,
40034
- Tabs as ab,
40035
- onMount as ac,
40036
- onCleanup as ad,
40037
- PluginUiHost as ae,
40038
- OasisEditorEditor as af,
40039
- OasisBrandMark as ag,
40040
- setPreciseFontPreference as ah,
40041
- setWelcomeSeen as ai,
40042
- enablePreciseFontMode as aj,
40043
- TWIPS_PER_POINT as ak,
40044
- PX_PER_INCH as al,
40045
- TWIPS_PER_INCH as am,
40046
- resolveEffectiveParagraphStyle as an,
40047
- resolveEffectiveTextStyleForParagraph as ao,
40048
- EMU_PER_PX as ap,
40049
- EMU_PER_PT as aq,
40050
- iterateFootnoteReferenceRuns as ar,
40051
- iterateEndnoteReferenceRuns as as,
40052
- imageContentTypeDefaults as at,
40053
- createEditorRun as au,
40054
- JSZip as av,
40055
- imageExtensionFromMime as aw,
40056
- pxToPt as ax,
40057
- resolveFloatingObjectRect as ay,
40058
- getTextBoxFloatingGeometry as az,
40077
+ defaultFontDecoderRegistry as a$,
40078
+ setStyleProperty as a0,
40079
+ memo as a1,
40080
+ template as a2,
40081
+ useI18n as a3,
40082
+ createEffect as a4,
40083
+ insert as a5,
40084
+ use as a6,
40085
+ addEventListener as a7,
40086
+ Dialog as a8,
40087
+ delegateEvents as a9,
40088
+ createEditorRun as aA,
40089
+ JSZip as aB,
40090
+ imageExtensionFromMime as aC,
40091
+ pxToPt as aD,
40092
+ resolveFloatingObjectRect as aE,
40093
+ getTextBoxFloatingGeometry as aF,
40094
+ getPresetPathSegments as aG,
40095
+ projectBlocksLayout as aH,
40096
+ buildListLabels as aI,
40097
+ textStyleToFontSizePt as aJ,
40098
+ PX_PER_POINT as aK,
40099
+ DEFAULT_FONT_SIZE_PX as aL,
40100
+ isDoubleUnderlineStyle as aM,
40101
+ isWavyUnderlineStyle as aN,
40102
+ underlineStyleLineWidthPx as aO,
40103
+ underlineStyleDashArray as aP,
40104
+ resolveListLabel as aQ,
40105
+ getListLabelInset as aR,
40106
+ getAlignedListLabelInset as aS,
40107
+ getParagraphBorderInsets as aT,
40108
+ buildSegmentTable as aU,
40109
+ buildCanvasTableLayout as aV,
40110
+ normalizeFamily as aW,
40111
+ ROBOTO_FONT_FILES as aX,
40112
+ loadFontAsset as aY,
40113
+ OFFICE_COMPAT_FONT_FAMILIES as aZ,
40114
+ buildSfnt as a_,
40115
+ className as aa,
40116
+ For as ab,
40117
+ UNDERLINE_STYLE_OPTIONS as ac,
40118
+ Tabs as ad,
40119
+ onMount as ae,
40120
+ onCleanup as af,
40121
+ PluginUiHost as ag,
40122
+ OasisEditorEditor as ah,
40123
+ OasisBrandMark as ai,
40124
+ setPreciseFontPreference as aj,
40125
+ setWelcomeSeen as ak,
40126
+ enablePreciseFontMode as al,
40127
+ TWIPS_PER_POINT as am,
40128
+ PX_PER_INCH as an,
40129
+ TWIPS_PER_INCH as ao,
40130
+ resolveEffectiveParagraphStyle as ap,
40131
+ resolveEffectiveTextStyleForParagraph as aq,
40132
+ EMU_PER_PX as ar,
40133
+ EMU_PER_PT as as,
40134
+ getRunFootnoteReference as at,
40135
+ getRunEndnoteReference as au,
40136
+ iterateFootnoteReferenceRuns as av,
40137
+ iterateEndnoteReferenceRuns as aw,
40138
+ imageContentTypeDefaults as ax,
40139
+ getRunFieldChar as ay,
40140
+ getRunFieldInstruction as az,
40059
40141
  createEditorStateFromDocument as b,
40060
- DEFAULT_PALETTE as b$,
40061
- getPageColumnRects as b0,
40062
- findFootnoteReference as b1,
40063
- FOOTNOTE_MARKER_GUTTER_PX as b2,
40064
- resolveImporterForFile as b3,
40065
- getDocumentSectionsCanonical as b4,
40066
- getDocumentParagraphsCanonical as b5,
40067
- getDocumentParagraphs as b6,
40068
- getDocumentPageSettings as b7,
40069
- getTableCellContentWidthForParagraph as b8,
40070
- on as b9,
40071
- nextFontSizePt as bA,
40072
- previousFontSizePt as bB,
40073
- fontSizePtToPx as bC,
40074
- createDefaultToolbarPreset as bD,
40075
- MenuRegistry as bE,
40076
- createToolbarRegistry as bF,
40077
- Editor as bG,
40078
- resolveCommandRef as bH,
40079
- commandRefName as bI,
40080
- createOasisEditorClient as bJ,
40081
- createEditorZoom as bK,
40082
- startLongTaskObserver as bL,
40083
- installGlobalReport as bM,
40084
- applyStoredPreciseFontPreference as bN,
40085
- getWelcomeSeen as bO,
40086
- isLocalFontAccessSupported as bP,
40087
- EDITOR_SCROLL_PADDING_PX as bQ,
40088
- Toolbar as bR,
40089
- OasisEditorLoading as bS,
40090
- I18nProvider as bT,
40091
- createTranslator as bU,
40092
- createEditorLogger as bV,
40093
- registerDomStatsSurface as bW,
40094
- Button as bX,
40095
- Checkbox as bY,
40096
- ColorPicker as bZ,
40097
- CommandRegistry as b_,
40098
- debounce as ba,
40099
- unwrap as bb,
40100
- perfTimer as bc,
40101
- createEditorDocument as bd,
40102
- resolveResizedDimensions as be,
40103
- resolveTextBoxRenderHeight as bf,
40104
- getToolbarStyleState as bg,
40105
- getCachedCanvasImage as bh,
40106
- measureParagraphMinContentWidthPx as bi,
40107
- getEditableBlocksForZone as bj,
40108
- findParagraphLocation as bk,
40109
- createSectionBoundaryParagraph as bl,
40110
- normalizePageSettings as bm,
40111
- DEFAULT_EDITOR_PAGE_SETTINGS as bn,
40112
- markStart as bo,
40113
- markEnd as bp,
40114
- getParagraphEntries as bq,
40115
- getParagraphById as br,
40116
- createEditorFootnote as bs,
40117
- createFootnoteReferenceRun as bt,
40118
- renumberFootnotes as bu,
40119
- getFootnoteDisplayMarker as bv,
40120
- getHeadingLevel as bw,
40121
- preciseFontModeVersion as bx,
40122
- isPreciseFontModeEnabled as by,
40123
- togglePreciseFontMode as bz,
40142
+ createTranslator as b$,
40143
+ SfntFontProgram as b0,
40144
+ collectPdfFontFamilies as b1,
40145
+ projectDocumentLayout as b2,
40146
+ getPageContentWidth as b3,
40147
+ getPageHeaderZoneTop as b4,
40148
+ getPageBodyTop as b5,
40149
+ getPageColumnRects as b6,
40150
+ findFootnoteReference as b7,
40151
+ FOOTNOTE_MARKER_GUTTER_PX as b8,
40152
+ resolveImporterForFile as b9,
40153
+ createFootnoteReferenceRun as bA,
40154
+ renumberFootnotes as bB,
40155
+ getFootnoteDisplayMarker as bC,
40156
+ getHeadingLevel as bD,
40157
+ preciseFontModeVersion as bE,
40158
+ isPreciseFontModeEnabled as bF,
40159
+ togglePreciseFontMode as bG,
40160
+ nextFontSizePt as bH,
40161
+ previousFontSizePt as bI,
40162
+ fontSizePtToPx as bJ,
40163
+ createDefaultToolbarPreset as bK,
40164
+ MenuRegistry as bL,
40165
+ createToolbarRegistry as bM,
40166
+ Editor as bN,
40167
+ resolveCommandRef as bO,
40168
+ commandRefName as bP,
40169
+ createOasisEditorClient as bQ,
40170
+ createEditorZoom as bR,
40171
+ startLongTaskObserver as bS,
40172
+ installGlobalReport as bT,
40173
+ applyStoredPreciseFontPreference as bU,
40174
+ getWelcomeSeen as bV,
40175
+ isLocalFontAccessSupported as bW,
40176
+ EDITOR_SCROLL_PADDING_PX as bX,
40177
+ Toolbar as bY,
40178
+ OasisEditorLoading as bZ,
40179
+ I18nProvider as b_,
40180
+ getDocumentSectionsCanonical as ba,
40181
+ getDocumentParagraphsCanonical as bb,
40182
+ getDocumentParagraphs as bc,
40183
+ getDocumentPageSettings as bd,
40184
+ getTableCellContentWidthForParagraph as be,
40185
+ on as bf,
40186
+ debounce as bg,
40187
+ unwrap as bh,
40188
+ perfTimer as bi,
40189
+ getRunTextBox as bj,
40190
+ createEditorDocument as bk,
40191
+ resolveResizedDimensions as bl,
40192
+ resolveTextBoxRenderHeight as bm,
40193
+ getToolbarStyleState as bn,
40194
+ getCachedCanvasImage as bo,
40195
+ measureParagraphMinContentWidthPx as bp,
40196
+ getEditableBlocksForZone as bq,
40197
+ findParagraphLocation as br,
40198
+ createSectionBoundaryParagraph as bs,
40199
+ normalizePageSettings as bt,
40200
+ DEFAULT_EDITOR_PAGE_SETTINGS as bu,
40201
+ markStart as bv,
40202
+ markEnd as bw,
40203
+ getParagraphEntries as bx,
40204
+ getParagraphById as by,
40205
+ createEditorFootnote as bz,
40124
40206
  createSignal as c,
40125
- DialogFooter as c0,
40126
- FloatingActionButton as c1,
40127
- GridPicker as c2,
40128
- IconButton as c3,
40129
- Menu as c4,
40130
- OASIS_BUILTIN_COMMANDS as c5,
40131
- OASIS_MENU_ITEMS as c6,
40132
- OASIS_TOOLBAR_ITEMS as c7,
40133
- OasisEditorAppLazy as c8,
40134
- OasisEditorContainer as c9,
40135
- PluginCollection as ca,
40136
- Popover as cb,
40137
- RIBBON_TABS as cc,
40138
- Select as cd,
40139
- SelectField as ce,
40140
- Separator as cf,
40141
- SidePanel as cg,
40142
- SidePanelBody as ch,
40143
- SidePanelFooter as ci,
40144
- SidePanelHeader as cj,
40145
- SplitButton as ck,
40146
- TextField as cl,
40147
- Button$1 as cm,
40148
- buildRibbonTabDefinitions as cn,
40149
- createEditorCommandBus as co,
40150
- createOasisEditor as cp,
40151
- createOasisEditorContainer as cq,
40152
- mount as cr,
40153
- registerToolbarRenderer as cs,
40207
+ createEditorLogger as c0,
40208
+ registerDomStatsSurface as c1,
40209
+ Button as c2,
40210
+ Checkbox as c3,
40211
+ ColorPicker as c4,
40212
+ CommandRegistry as c5,
40213
+ DEFAULT_PALETTE as c6,
40214
+ DialogFooter as c7,
40215
+ FloatingActionButton as c8,
40216
+ GridPicker as c9,
40217
+ IconButton as ca,
40218
+ Menu as cb,
40219
+ OASIS_BUILTIN_COMMANDS as cc,
40220
+ OASIS_MENU_ITEMS as cd,
40221
+ OASIS_TOOLBAR_ITEMS as ce,
40222
+ OasisEditorAppLazy as cf,
40223
+ OasisEditorContainer as cg,
40224
+ PluginCollection as ch,
40225
+ Popover as ci,
40226
+ RIBBON_TABS as cj,
40227
+ Select as ck,
40228
+ SelectField as cl,
40229
+ Separator as cm,
40230
+ SidePanel as cn,
40231
+ SidePanelBody as co,
40232
+ SidePanelFooter as cp,
40233
+ SidePanelHeader as cq,
40234
+ SplitButton as cr,
40235
+ TextField as cs,
40236
+ Button$1 as ct,
40237
+ buildRibbonTabDefinitions as cu,
40238
+ createEditorCommandBus as cv,
40239
+ createOasisEditor as cw,
40240
+ createOasisEditorContainer as cx,
40241
+ mount as cy,
40242
+ registerToolbarRenderer as cz,
40154
40243
  createInitialEditorState as d,
40155
40244
  createEditorParagraphFromRuns as e,
40156
40245
  fontSizePxToPt as f,
@@ -40169,9 +40258,9 @@ export {
40169
40258
  clampPosition as s,
40170
40259
  findParagraphIndex as t,
40171
40260
  createCollapsedSelection as u,
40172
- isSelectionCollapsed as v,
40173
- parseFontSizePtToPx as w,
40174
- formatFontSizePt as x,
40175
- createEditorParagraph as y,
40176
- getBlockParagraphs as z
40261
+ visitRun as v,
40262
+ isSelectionCollapsed as w,
40263
+ parseFontSizePtToPx as x,
40264
+ formatFontSizePt as y,
40265
+ createEditorParagraph as z
40177
40266
  };