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.
@@ -2483,7 +2483,7 @@ function OasisEditorAppLazy(props = {}) {
2483
2483
  onCleanup(() => {
2484
2484
  cancelled = true;
2485
2485
  });
2486
- import("./OasisEditorApp-DnKmTPKR.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,24 +3005,32 @@ 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;
3022
3031
  }
3023
3032
  function visitRun(run, visitor) {
3024
- const kind = getRunKind(run);
3025
- switch (kind) {
3033
+ switch (run.kind) {
3026
3034
  case "footnoteReference":
3027
3035
  return visitor.footnoteReference(run);
3028
3036
  case "endnoteReference":
@@ -3042,7 +3050,7 @@ function visitRun(run, visitor) {
3042
3050
  case "text":
3043
3051
  return visitor.text(run);
3044
3052
  default:
3045
- return assertNever(kind, "run kind");
3053
+ return assertNever(run, "run kind");
3046
3054
  }
3047
3055
  }
3048
3056
  const EDITOR_ASSET_REF_PREFIX = "asset:";
@@ -3664,7 +3672,7 @@ function collectNumberingParagraphs(document2) {
3664
3672
  const result = [];
3665
3673
  const collectTextBoxes = (paragraph) => {
3666
3674
  for (const run of paragraph.runs) {
3667
- if (run.textBox) collectBlocks2(run.textBox.blocks);
3675
+ if (run.kind === "textBox") collectBlocks2(run.textBox.blocks);
3668
3676
  }
3669
3677
  };
3670
3678
  const collectBlocks2 = (blocks) => {
@@ -3837,24 +3845,27 @@ function createEditorCommentId() {
3837
3845
  return createEditorNodeId("comment");
3838
3846
  }
3839
3847
  function createEditorRun(text = "") {
3840
- const run = {
3848
+ return {
3841
3849
  id: createEditorNodeId("run"),
3842
- text
3850
+ text,
3851
+ kind: "text"
3843
3852
  };
3844
- return run;
3845
3853
  }
3846
3854
  function createEditorStyledRun(text = "", styles, image, textBox) {
3847
- const run = createEditorRun(text);
3855
+ const base = {
3856
+ id: createEditorNodeId("run"),
3857
+ text
3858
+ };
3848
3859
  if (styles) {
3849
- run.styles = { ...styles };
3860
+ base.styles = { ...styles };
3850
3861
  }
3851
3862
  if (image) {
3852
- run.image = { ...image };
3863
+ return { ...base, kind: "image", image: { ...image } };
3853
3864
  }
3854
3865
  if (textBox) {
3855
- run.textBox = textBox;
3866
+ return { ...base, kind: "textBox", textBox };
3856
3867
  }
3857
- return run;
3868
+ return { ...base, kind: "text" };
3858
3869
  }
3859
3870
  function createEditorParagraph(text = "") {
3860
3871
  const paragraph = {
@@ -3932,10 +3943,14 @@ function createFootnoteReferenceRun(footnoteId, marker, options) {
3932
3943
  superscript: true,
3933
3944
  ...{}
3934
3945
  };
3935
- const run = createEditorStyledRun(marker, styles);
3936
3946
  const reference = { footnoteId };
3937
- run.footnoteReference = reference;
3938
- return run;
3947
+ return {
3948
+ id: createEditorNodeId("run"),
3949
+ text: marker,
3950
+ styles,
3951
+ kind: "footnoteReference",
3952
+ footnoteReference: reference
3953
+ };
3939
3954
  }
3940
3955
  const DEFAULT_EDITOR_STYLES = {
3941
3956
  normal: {
@@ -5122,7 +5137,7 @@ function sliceParagraph(paragraph, startOffset, endOffset) {
5122
5137
  });
5123
5138
  return {
5124
5139
  ...paragraph,
5125
- runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "" }]
5140
+ runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "", kind: "text" }]
5126
5141
  };
5127
5142
  }
5128
5143
  const FOOTNOTE_SEPARATOR_HEIGHT = 10;
@@ -5142,8 +5157,9 @@ function collectFootnoteReferencesFromBlock(block) {
5142
5157
  let runStart = 0;
5143
5158
  for (const run of paragraph.runs) {
5144
5159
  const runEnd = runStart + run.text.length;
5145
- if (run.footnoteReference && runEnd > startOffset && runStart < endOffset) {
5146
- result.push(run.footnoteReference.footnoteId);
5160
+ const footnoteReference = getRunFootnoteReference(run);
5161
+ if (footnoteReference && runEnd > startOffset && runStart < endOffset) {
5162
+ result.push(footnoteReference.footnoteId);
5147
5163
  }
5148
5164
  runStart = runEnd;
5149
5165
  }
@@ -10799,6 +10815,8 @@ function buildParagraphFragments(paragraph) {
10799
10815
  paragraphOffset: paragraphOffset + index,
10800
10816
  runOffset: index
10801
10817
  }));
10818
+ const runImage = getRunImage(run);
10819
+ const runTextBox = getRunTextBox(run);
10802
10820
  const fragment = {
10803
10821
  paragraphId: paragraph.id,
10804
10822
  runId: run.id,
@@ -10806,8 +10824,8 @@ function buildParagraphFragments(paragraph) {
10806
10824
  endOffset: paragraphOffset + run.text.length,
10807
10825
  text: run.text,
10808
10826
  styles: run.styles ? { ...run.styles } : void 0,
10809
- image: run.image ? { ...run.image } : void 0,
10810
- textBox: run.textBox ? { ...run.textBox } : void 0,
10827
+ image: runImage ? { ...runImage } : void 0,
10828
+ textBox: runTextBox ? { ...runTextBox } : void 0,
10811
10829
  revision: run.revision ? { ...run.revision } : void 0,
10812
10830
  chars: chars2
10813
10831
  };
@@ -11015,7 +11033,8 @@ function getParagraphLineHeight(paragraph, styles, fallbackFontSize) {
11015
11033
  { ...runTextStyle, fontSize },
11016
11034
  lineHeight
11017
11035
  );
11018
- 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;
11019
11038
  return Math.max(largest, runLineHeight + baselineShiftPx, imageHeight);
11020
11039
  }, 0);
11021
11040
  const renderedLineHeight = Math.max(
@@ -11374,8 +11393,10 @@ function measureParagraphMinContentWidthPx(paragraph, styles) {
11374
11393
  return Math.max(largest, token.width);
11375
11394
  }, 0);
11376
11395
  const largestInlineObject = paragraph.runs.reduce((largest, run) => {
11377
- const imageWidth = run.image && !run.image.floating ? run.image.width : 0;
11378
- 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;
11379
11400
  return Math.max(largest, imageWidth, textBoxWidth);
11380
11401
  }, 0);
11381
11402
  return Math.max(1, inset + largestUnbreakableToken, largestInlineObject);
@@ -12028,14 +12049,14 @@ function clearProjectedParagraphLayoutCache() {
12028
12049
  paragraphLayoutCache = /* @__PURE__ */ new WeakMap();
12029
12050
  }
12030
12051
  function getParagraphFieldDependence(paragraph) {
12031
- var _a, _b;
12032
12052
  const cached = paragraphFieldDependenceCache.get(paragraph);
12033
12053
  if (cached) return cached;
12034
12054
  let dependsOnPageIndex = false;
12035
12055
  let dependsOnTotalPages = false;
12036
12056
  for (const run of paragraph.runs) {
12037
- if (((_a = run.field) == null ? void 0 : _a.type) === "PAGE") dependsOnPageIndex = true;
12038
- 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;
12039
12060
  if (dependsOnPageIndex && dependsOnTotalPages) break;
12040
12061
  }
12041
12062
  const result = { dependsOnPageIndex, dependsOnTotalPages };
@@ -12058,10 +12079,11 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
12058
12079
  let paragraphOffset = 0;
12059
12080
  const fragments = paragraph.runs.map((run) => {
12060
12081
  let resolvedText = run.text;
12061
- if (run.field) {
12062
- if (run.field.type === "PAGE") {
12082
+ const field = getRunField(run);
12083
+ if (field) {
12084
+ if (field.type === "PAGE") {
12063
12085
  resolvedText = typeof pageIndex === "number" ? String(pageIndex + 1) : "1";
12064
- } else if (run.field.type === "NUMPAGES") {
12086
+ } else if (field.type === "NUMPAGES") {
12065
12087
  resolvedText = typeof totalPages === "number" ? String(totalPages) : "1";
12066
12088
  }
12067
12089
  }
@@ -12072,6 +12094,8 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
12072
12094
  runOffset: index
12073
12095
  })
12074
12096
  );
12097
+ const runImage = getRunImage(run);
12098
+ const runTextBox = getRunTextBox(run);
12075
12099
  const fragment = {
12076
12100
  paragraphId: paragraph.id,
12077
12101
  runId: run.id,
@@ -12079,8 +12103,8 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
12079
12103
  endOffset: paragraphOffset + resolvedText.length,
12080
12104
  text: resolvedText,
12081
12105
  styles: run.styles ? { ...run.styles } : void 0,
12082
- image: run.image ? { ...run.image } : void 0,
12083
- textBox: run.textBox ? { ...run.textBox } : void 0,
12106
+ image: runImage ? { ...runImage } : void 0,
12107
+ textBox: runTextBox ? { ...runTextBox } : void 0,
12084
12108
  revision: run.revision ? { ...run.revision } : void 0,
12085
12109
  chars: chars2
12086
12110
  };
@@ -12629,7 +12653,7 @@ function estimateTableRowHeight(row, styles, measurer, defaultTabStop, contentWi
12629
12653
  let largestImageHeight = 0;
12630
12654
  for (const paragraph of cell.blocks) {
12631
12655
  for (const run of paragraph.runs) {
12632
- if (run.image && run.image.height > largestImageHeight) {
12656
+ if (run.kind === "image" && run.image.height > largestImageHeight) {
12633
12657
  const fitted = cellContentWidth !== void 0 && run.image.width > cellContentWidth ? Math.floor(
12634
12658
  run.image.height * (cellContentWidth / run.image.width)
12635
12659
  ) : run.image.height;
@@ -13259,7 +13283,7 @@ function sliceParagraphForTableSegment(paragraph, startOffset, endOffset) {
13259
13283
  });
13260
13284
  return {
13261
13285
  ...paragraph,
13262
- runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "" }]
13286
+ runs: runs.length > 0 ? runs : [{ id: `${paragraph.id}:empty`, text: "", kind: "text" }]
13263
13287
  };
13264
13288
  }
13265
13289
  function sliceCellBlocksForTableSegment(blocks, start, end) {
@@ -13992,7 +14016,7 @@ function* iterateFootnoteReferenceRuns(document2) {
13992
14016
  for (const block of blocks) {
13993
14017
  for (const paragraph of getBlockParagraphs(block)) {
13994
14018
  for (const run of paragraph.runs) {
13995
- if (run.footnoteReference) {
14019
+ if (run.kind === "footnoteReference") {
13996
14020
  yield { paragraph, run };
13997
14021
  }
13998
14022
  }
@@ -14064,7 +14088,7 @@ function getFootnoteDisplayMarker(oneBasedIndex, format = "decimal") {
14064
14088
  function findFootnoteReference(document2, footnoteId) {
14065
14089
  var _a;
14066
14090
  for (const entry of iterateFootnoteReferenceRuns(document2)) {
14067
- if (((_a = entry.run.footnoteReference) == null ? void 0 : _a.footnoteId) === footnoteId) {
14091
+ if (((_a = getRunFootnoteReference(entry.run)) == null ? void 0 : _a.footnoteId) === footnoteId) {
14068
14092
  return entry;
14069
14093
  }
14070
14094
  }
@@ -14082,7 +14106,7 @@ function renumberFootnotes(document2) {
14082
14106
  const markerByFootnoteId = /* @__PURE__ */ new Map();
14083
14107
  let autoCounter = startAt - 1;
14084
14108
  for (const { run } of iterateFootnoteReferenceRuns(document2)) {
14085
- const ref = run.footnoteReference;
14109
+ const ref = getRunFootnoteReference(run);
14086
14110
  if (!ref) continue;
14087
14111
  referenced.add(ref.footnoteId);
14088
14112
  if (ref.customMark) {
@@ -14178,8 +14202,9 @@ function renumberFootnotes(document2) {
14178
14202
  function rewriteParagraphMarkers$1(paragraph, markerByFootnoteId) {
14179
14203
  let runChanged = false;
14180
14204
  const nextRuns = paragraph.runs.map((run) => {
14181
- if (!run.footnoteReference) return run;
14182
- const desired = markerByFootnoteId.get(run.footnoteReference.footnoteId);
14205
+ const ref = getRunFootnoteReference(run);
14206
+ if (!ref) return run;
14207
+ const desired = markerByFootnoteId.get(ref.footnoteId);
14183
14208
  if (desired === void 0) return run;
14184
14209
  if (run.text === desired) return run;
14185
14210
  runChanged = true;
@@ -14204,7 +14229,7 @@ function* iterateEndnoteReferenceRuns(document2) {
14204
14229
  for (const block of blocks) {
14205
14230
  for (const paragraph of getBlockParagraphs(block)) {
14206
14231
  for (const run of paragraph.runs) {
14207
- if (run.endnoteReference) {
14232
+ if (run.kind === "endnoteReference") {
14208
14233
  yield { paragraph, run };
14209
14234
  }
14210
14235
  }
@@ -14218,7 +14243,7 @@ function listReferencedEndnotes(document2) {
14218
14243
  const result = [];
14219
14244
  let counter2 = 0;
14220
14245
  for (const { run } of iterateEndnoteReferenceRuns(document2)) {
14221
- const ref = run.endnoteReference;
14246
+ const ref = getRunEndnoteReference(run);
14222
14247
  if (!ref) continue;
14223
14248
  if (seen.has(ref.endnoteId)) continue;
14224
14249
  seen.add(ref.endnoteId);
@@ -14245,7 +14270,7 @@ function renumberEndnotes(document2) {
14245
14270
  const markerByEndnoteId = /* @__PURE__ */ new Map();
14246
14271
  let autoCounter = startAt - 1;
14247
14272
  for (const { run } of iterateEndnoteReferenceRuns(document2)) {
14248
- const ref = run.endnoteReference;
14273
+ const ref = getRunEndnoteReference(run);
14249
14274
  if (!ref) continue;
14250
14275
  referenced.add(ref.endnoteId);
14251
14276
  if (ref.customMark) {
@@ -14338,8 +14363,9 @@ function renumberEndnotes(document2) {
14338
14363
  function rewriteParagraphMarkers(paragraph, markerByEndnoteId) {
14339
14364
  let runChanged = false;
14340
14365
  const nextRuns = paragraph.runs.map((run) => {
14341
- if (!run.endnoteReference) return run;
14342
- const desired = markerByEndnoteId.get(run.endnoteReference.endnoteId);
14366
+ const ref = getRunEndnoteReference(run);
14367
+ if (!ref) return run;
14368
+ const desired = markerByEndnoteId.get(ref.endnoteId);
14343
14369
  if (desired === void 0) return run;
14344
14370
  if (run.text === desired) return run;
14345
14371
  runChanged = true;
@@ -14353,7 +14379,8 @@ function makeMarkerRun(endnoteId, marker) {
14353
14379
  return {
14354
14380
  id: `${FLOW_ID_PREFIX}:marker:${endnoteId}`,
14355
14381
  text: `${marker}. `,
14356
- styles: { superscript: true }
14382
+ styles: { superscript: true },
14383
+ kind: "text"
14357
14384
  };
14358
14385
  }
14359
14386
  function prependMarker(paragraph, endnoteId, marker) {
@@ -14369,7 +14396,7 @@ function emptyMarkerParagraph(endnoteId, marker) {
14369
14396
  type: "paragraph",
14370
14397
  runs: [
14371
14398
  makeMarkerRun(endnoteId, marker),
14372
- { id: `${FLOW_ID_PREFIX}:text:${endnoteId}`, text: "" }
14399
+ { id: `${FLOW_ID_PREFIX}:text:${endnoteId}`, text: "", kind: "text" }
14373
14400
  ]
14374
14401
  };
14375
14402
  }
@@ -14377,7 +14404,7 @@ function spacerParagraph() {
14377
14404
  return {
14378
14405
  id: `${FLOW_ID_PREFIX}:spacer`,
14379
14406
  type: "paragraph",
14380
- runs: [{ id: `${FLOW_ID_PREFIX}:spacer:text`, text: "" }]
14407
+ runs: [{ id: `${FLOW_ID_PREFIX}:spacer:text`, text: "", kind: "text" }]
14381
14408
  };
14382
14409
  }
14383
14410
  function buildEndnoteFlowBlocks(document2) {
@@ -14430,7 +14457,7 @@ function blockContainsNumPagesField(block) {
14430
14457
  if (block.type === "paragraph") {
14431
14458
  return block.runs.some((run) => {
14432
14459
  var _a;
14433
- return ((_a = run.field) == null ? void 0 : _a.type) === "NUMPAGES";
14460
+ return ((_a = getRunField(run)) == null ? void 0 : _a.type) === "NUMPAGES";
14434
14461
  });
14435
14462
  }
14436
14463
  return block.rows.some(
@@ -14789,7 +14816,7 @@ function fitImagesToCellWidth(paragraph, maxImageWidthPx) {
14789
14816
  }
14790
14817
  let changed = false;
14791
14818
  const runs = paragraph.runs.map((run) => {
14792
- if (!run.image) return run;
14819
+ if (run.kind !== "image") return run;
14793
14820
  const { width: w, height: h } = run.image;
14794
14821
  if (w <= maxImageWidthPx) return run;
14795
14822
  const scale = maxImageWidthPx / w;
@@ -15081,7 +15108,7 @@ function buildCanvasTableLayout(options) {
15081
15108
  const anchorPosition = firstParagraph ? paragraphOffsetToPosition(firstParagraph, 0) : paragraphOffsetToPosition(
15082
15109
  {
15083
15110
  id: `table:${table.id}:r${rowIndex}:c${cellIndex}:empty`,
15084
- runs: [{ id: "run:empty", text: "" }]
15111
+ runs: [{ id: "run:empty", text: "", kind: "text" }]
15085
15112
  },
15086
15113
  0
15087
15114
  );
@@ -33756,53 +33783,69 @@ function parseDropCapFrame(paragraphProperties, runs) {
33756
33783
  style: (_a = runs[0]) == null ? void 0 : _a.styles
33757
33784
  };
33758
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
+ }
33759
33829
  function createImportedParagraph(runs, paragraphStyle, list, markRunStyle) {
33760
33830
  var _a;
33761
- const paragraph = createEditorParagraphFromRuns(
33762
- runs.length > 0 ? runs.map((run) => ({
33763
- text: run.text,
33764
- styles: run.styles,
33765
- image: run.image
33766
- })) : (
33767
- // An empty paragraph still carries the formatting of its paragraph mark
33768
- // (`w:pPr/w:rPr`), which Word uses to render the blank line's font/size.
33769
- // Apply it so empty lines match Word instead of falling back to defaults.
33770
- [{ text: "", styles: markRunStyle }]
33771
- )
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
+ ]
33772
33843
  );
33773
- runs.forEach((run, index) => {
33774
- if (run.field) {
33775
- paragraph.runs[index].field = { ...run.field };
33776
- }
33777
- if (run.fieldChar) {
33778
- paragraph.runs[index].fieldChar = { ...run.fieldChar };
33779
- }
33780
- if (run.fieldInstruction !== void 0) {
33781
- paragraph.runs[index].fieldInstruction = run.fieldInstruction;
33782
- }
33783
- if (run.textBox) {
33784
- paragraph.runs[index].textBox = run.textBox;
33785
- }
33786
- if (run.footnoteReference) {
33787
- paragraph.runs[index].__importedFootnoteRef = {
33788
- ...run.footnoteReference
33789
- };
33790
- }
33791
- if (run.endnoteReference) {
33792
- paragraph.runs[index].__importedEndnoteRef = {
33793
- ...run.endnoteReference
33794
- };
33795
- }
33796
- if (run.bookmark) {
33797
- paragraph.runs[index].__importedBookmark = { ...run.bookmark };
33798
- }
33799
- if (run.comment) {
33800
- paragraph.runs[index].__importedComment = { ...run.comment };
33801
- }
33802
- if (run.sym) {
33803
- paragraph.runs[index].sym = { ...run.sym };
33804
- }
33805
- });
33844
+ const paragraph = {
33845
+ id: createEditorNodeId("paragraph"),
33846
+ type: "paragraph",
33847
+ runs: editorRuns
33848
+ };
33806
33849
  paragraph.style = paragraphStyle ? { ...paragraphStyle } : void 0;
33807
33850
  for (const run of paragraph.runs) {
33808
33851
  run.styles = normalizeImportedRunStyle(
@@ -35566,20 +35609,27 @@ function remapImportedFootnoteRefsInSections(sections, byDocxId) {
35566
35609
  var _a, _b, _c, _d, _e, _f;
35567
35610
  const remapBlock = (block) => {
35568
35611
  if (block.type === "paragraph") {
35569
- for (const run of block.runs) {
35612
+ block.runs.forEach((run, index) => {
35570
35613
  const runWithRef = run;
35571
35614
  const transient = runWithRef.__importedFootnoteRef;
35572
- if (!transient) continue;
35615
+ if (!transient) return;
35573
35616
  delete runWithRef.__importedFootnoteRef;
35574
35617
  const footnote = byDocxId.get(transient.docxId);
35575
35618
  if (!footnote) {
35576
- continue;
35619
+ return;
35577
35620
  }
35578
- run.footnoteReference = {
35579
- footnoteId: footnote.id,
35580
- ...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
+ }
35581
35631
  };
35582
- }
35632
+ });
35583
35633
  return;
35584
35634
  }
35585
35635
  for (const row of block.rows) {
@@ -35604,20 +35654,27 @@ function remapImportedEndnoteRefsInSections(sections, byDocxId) {
35604
35654
  var _a, _b, _c, _d, _e, _f;
35605
35655
  const remapBlock = (block) => {
35606
35656
  if (block.type === "paragraph") {
35607
- for (const run of block.runs) {
35657
+ block.runs.forEach((run, index) => {
35608
35658
  const runWithRef = run;
35609
35659
  const transient = runWithRef.__importedEndnoteRef;
35610
- if (!transient) continue;
35660
+ if (!transient) return;
35611
35661
  delete runWithRef.__importedEndnoteRef;
35612
35662
  const endnote = byDocxId.get(transient.docxId);
35613
35663
  if (!endnote) {
35614
- continue;
35664
+ return;
35615
35665
  }
35616
- run.endnoteReference = {
35617
- endnoteId: endnote.id,
35618
- ...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
+ }
35619
35676
  };
35620
- }
35677
+ });
35621
35678
  return;
35622
35679
  }
35623
35680
  for (const row of block.rows) {
@@ -35652,7 +35709,7 @@ function importDocxInWorker(buffer, options = {}) {
35652
35709
  const worker = new Worker(
35653
35710
  new URL(
35654
35711
  /* @vite-ignore */
35655
- "" + new URL("assets/importDocxWorker-CmygfpkG.js", import.meta.url).href,
35712
+ "" + new URL("assets/importDocxWorker-8fivvDCX.js", import.meta.url).href,
35656
35713
  import.meta.url
35657
35714
  ),
35658
35715
  {
@@ -36036,7 +36093,7 @@ function runsToParagraphSpecs(runs) {
36036
36093
  return runs.map((run) => ({
36037
36094
  text: run.text,
36038
36095
  styles: run.styles,
36039
- image: run.image
36096
+ image: getRunImage(run)
36040
36097
  }));
36041
36098
  }
36042
36099
  function buildParagraph(element, list) {
@@ -39988,195 +40045,201 @@ const OASIS_MENU_ITEMS = {
39988
40045
  formatListsNumbered: "format_lists_numbered"
39989
40046
  };
39990
40047
  export {
39991
- memo as $,
39992
- findParagraphTableLocation as A,
39993
- buildTableCellLayout as B,
39994
- createEditorTableCell as C,
39995
- createEditorTableRow as D,
39996
- createEditorTable as E,
39997
- underlineStyleToCssDecorationStyle as F,
39998
- resolveImageSrc as G,
39999
- listKindForTag as H,
40000
- isParagraphTag as I,
40001
- collectInlineRuns as J,
40002
- parseParagraphStyle as K,
40003
- InlineShell as L,
40004
- BalloonShell as M,
40005
- DocumentShell as N,
40006
- 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,
40007
40064
  PT_PER_PX as P,
40008
- buildCanvasLayoutSnapshot as Q,
40009
- getCaretRectFromSnapshot as R,
40065
+ DocumentShell as Q,
40066
+ createMemo as R,
40010
40067
  STANDARD_FONT_SIZES_PT as S,
40011
- getParagraphRectFromSnapshot as T,
40012
- createComponent as U,
40013
- CaretOverlay as V,
40014
- Show as W,
40015
- createRenderEffect as X,
40016
- style as Y,
40017
- setAttribute as Z,
40018
- 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 _,
40019
40076
  assertNever as a,
40020
- getPageHeaderZoneTop as a$,
40021
- template as a0,
40022
- useI18n as a1,
40023
- createEffect as a2,
40024
- insert as a3,
40025
- use as a4,
40026
- addEventListener as a5,
40027
- Dialog as a6,
40028
- delegateEvents as a7,
40029
- className as a8,
40030
- For as a9,
40031
- getTextBoxFloatingGeometry as aA,
40032
- getPresetPathSegments as aB,
40033
- projectBlocksLayout as aC,
40034
- buildListLabels as aD,
40035
- textStyleToFontSizePt as aE,
40036
- PX_PER_POINT as aF,
40037
- DEFAULT_FONT_SIZE_PX as aG,
40038
- isDoubleUnderlineStyle as aH,
40039
- isWavyUnderlineStyle as aI,
40040
- underlineStyleLineWidthPx as aJ,
40041
- underlineStyleDashArray as aK,
40042
- resolveListLabel as aL,
40043
- getListLabelInset as aM,
40044
- getAlignedListLabelInset as aN,
40045
- getParagraphBorderInsets as aO,
40046
- buildSegmentTable as aP,
40047
- buildCanvasTableLayout as aQ,
40048
- normalizeFamily as aR,
40049
- ROBOTO_FONT_FILES as aS,
40050
- loadFontAsset as aT,
40051
- OFFICE_COMPAT_FONT_FAMILIES as aU,
40052
- buildSfnt as aV,
40053
- defaultFontDecoderRegistry as aW,
40054
- SfntFontProgram as aX,
40055
- collectPdfFontFamilies as aY,
40056
- projectDocumentLayout as aZ,
40057
- getPageContentWidth as a_,
40058
- UNDERLINE_STYLE_OPTIONS as aa,
40059
- Tabs as ab,
40060
- onMount as ac,
40061
- onCleanup as ad,
40062
- PluginUiHost as ae,
40063
- OasisEditorEditor as af,
40064
- OasisBrandMark as ag,
40065
- setPreciseFontPreference as ah,
40066
- setWelcomeSeen as ai,
40067
- enablePreciseFontMode as aj,
40068
- TWIPS_PER_POINT as ak,
40069
- PX_PER_INCH as al,
40070
- TWIPS_PER_INCH as am,
40071
- resolveEffectiveParagraphStyle as an,
40072
- resolveEffectiveTextStyleForParagraph as ao,
40073
- EMU_PER_PX as ap,
40074
- EMU_PER_PT as aq,
40075
- visitRun as ar,
40076
- iterateFootnoteReferenceRuns as as,
40077
- iterateEndnoteReferenceRuns as at,
40078
- imageContentTypeDefaults as au,
40079
- createEditorRun as av,
40080
- JSZip as aw,
40081
- imageExtensionFromMime as ax,
40082
- pxToPt as ay,
40083
- resolveFloatingObjectRect 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,
40084
40141
  createEditorStateFromDocument as b,
40085
- CommandRegistry as b$,
40086
- getPageBodyTop as b0,
40087
- getPageColumnRects as b1,
40088
- findFootnoteReference as b2,
40089
- FOOTNOTE_MARKER_GUTTER_PX as b3,
40090
- resolveImporterForFile as b4,
40091
- getDocumentSectionsCanonical as b5,
40092
- getDocumentParagraphsCanonical as b6,
40093
- getDocumentParagraphs as b7,
40094
- getDocumentPageSettings as b8,
40095
- getTableCellContentWidthForParagraph as b9,
40096
- togglePreciseFontMode as bA,
40097
- nextFontSizePt as bB,
40098
- previousFontSizePt as bC,
40099
- fontSizePtToPx as bD,
40100
- createDefaultToolbarPreset as bE,
40101
- MenuRegistry as bF,
40102
- createToolbarRegistry as bG,
40103
- Editor as bH,
40104
- resolveCommandRef as bI,
40105
- commandRefName as bJ,
40106
- createOasisEditorClient as bK,
40107
- createEditorZoom as bL,
40108
- startLongTaskObserver as bM,
40109
- installGlobalReport as bN,
40110
- applyStoredPreciseFontPreference as bO,
40111
- getWelcomeSeen as bP,
40112
- isLocalFontAccessSupported as bQ,
40113
- EDITOR_SCROLL_PADDING_PX as bR,
40114
- Toolbar as bS,
40115
- OasisEditorLoading as bT,
40116
- I18nProvider as bU,
40117
- createTranslator as bV,
40118
- createEditorLogger as bW,
40119
- registerDomStatsSurface as bX,
40120
- Button as bY,
40121
- Checkbox as bZ,
40122
- ColorPicker as b_,
40123
- on as ba,
40124
- debounce as bb,
40125
- unwrap as bc,
40126
- perfTimer as bd,
40127
- createEditorDocument as be,
40128
- resolveResizedDimensions as bf,
40129
- resolveTextBoxRenderHeight as bg,
40130
- getToolbarStyleState as bh,
40131
- getCachedCanvasImage as bi,
40132
- measureParagraphMinContentWidthPx as bj,
40133
- getEditableBlocksForZone as bk,
40134
- findParagraphLocation as bl,
40135
- createSectionBoundaryParagraph as bm,
40136
- normalizePageSettings as bn,
40137
- DEFAULT_EDITOR_PAGE_SETTINGS as bo,
40138
- markStart as bp,
40139
- markEnd as bq,
40140
- getParagraphEntries as br,
40141
- getParagraphById as bs,
40142
- createEditorFootnote as bt,
40143
- createFootnoteReferenceRun as bu,
40144
- renumberFootnotes as bv,
40145
- getFootnoteDisplayMarker as bw,
40146
- getHeadingLevel as bx,
40147
- preciseFontModeVersion as by,
40148
- isPreciseFontModeEnabled 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,
40149
40206
  createSignal as c,
40150
- DEFAULT_PALETTE as c0,
40151
- DialogFooter as c1,
40152
- FloatingActionButton as c2,
40153
- GridPicker as c3,
40154
- IconButton as c4,
40155
- Menu as c5,
40156
- OASIS_BUILTIN_COMMANDS as c6,
40157
- OASIS_MENU_ITEMS as c7,
40158
- OASIS_TOOLBAR_ITEMS as c8,
40159
- OasisEditorAppLazy as c9,
40160
- OasisEditorContainer as ca,
40161
- PluginCollection as cb,
40162
- Popover as cc,
40163
- RIBBON_TABS as cd,
40164
- Select as ce,
40165
- SelectField as cf,
40166
- Separator as cg,
40167
- SidePanel as ch,
40168
- SidePanelBody as ci,
40169
- SidePanelFooter as cj,
40170
- SidePanelHeader as ck,
40171
- SplitButton as cl,
40172
- TextField as cm,
40173
- Button$1 as cn,
40174
- buildRibbonTabDefinitions as co,
40175
- createEditorCommandBus as cp,
40176
- createOasisEditor as cq,
40177
- createOasisEditorContainer as cr,
40178
- mount as cs,
40179
- registerToolbarRenderer as ct,
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,
40180
40243
  createInitialEditorState as d,
40181
40244
  createEditorParagraphFromRuns as e,
40182
40245
  fontSizePxToPt as f,
@@ -40195,9 +40258,9 @@ export {
40195
40258
  clampPosition as s,
40196
40259
  findParagraphIndex as t,
40197
40260
  createCollapsedSelection as u,
40198
- isSelectionCollapsed as v,
40199
- parseFontSizePtToPx as w,
40200
- formatFontSizePt as x,
40201
- createEditorParagraph as y,
40202
- getBlockParagraphs as z
40261
+ visitRun as v,
40262
+ isSelectionCollapsed as w,
40263
+ parseFontSizePtToPx as x,
40264
+ formatFontSizePt as y,
40265
+ createEditorParagraph as z
40203
40266
  };