oasis-editor 0.0.139 → 0.0.141

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,7 +1,7 @@
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 { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as parseNumber, aE as createStore, aF as reconcile, aG as RadioGroup, aH as Radio$1, aI as TextAreaField, aJ as Text, aK as SurfaceButton, aL as delegateEvents, aM as onMount, aN as onCleanup, aO as CheckIcon, aP as use, aQ as PluginUiHost, aR as OasisEditorEditor, aS as OasisBrandMark, aT as setPreciseFontPreference, aU as setWelcomeSeen, aV as enablePreciseFontMode, aW as TWIPS_PER_POINT, aX as PX_PER_INCH, aY as TWIPS_PER_INCH, aZ as normalizeHex6, a_ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, a$ as TABLE_BORDER_EDGE_KEYS, b0 as resolveEffectiveParagraphStyle, b1 as resolveEffectiveTextStyleForParagraph, b2 as EMU_PER_PT, b3 as OOXML_ROTATION_UNITS, b4 as OOXML_PERCENT_DENOMINATOR, b5 as parseHexColorToRgb255, b6 as EMU_PER_PX, b7 as getRunEndnoteReference, b8 as iterateFootnoteReferenceRuns, b9 as iterateEndnoteReferenceRuns, ba as imageContentTypeDefaults, bb as getRunFieldChar, bc as getRunFieldInstruction, bd as createEditorRun, be as JSZip, bf as imageExtensionFromMime, bg as pxToPt$1, bh as resolveFloatingObjectRect, bi as getTextBoxFloatingGeometry, bj as getPresetPathSegments, bk as buildListLabels, bl as lineDashPatternPt, bm as DEFAULT_FONT_SIZE_PX, bn as resolveGradientAxis, bo as isDoubleUnderlineStyle, bp as isWavyUnderlineStyle, bq as underlineStyleLineWidthPx, br as WAVY_UNDERLINE_WAVELENGTH_PX, bs as WAVY_UNDERLINE_AMPLITUDE_PX, bt as DOUBLE_UNDERLINE_OFFSET_PX, bu as underlineStyleDashArray, bv as EMPHASIS_GLYPH, bw as rgb255ToHex, bx as getImageFloatingGeometry, by as textStyleToFontSizePt, bz as resolveTextAlignmentBaselineOffset, bA as TEXT_BASELINE_RATIO, bB as resolveRenderedTextChar, bC as resolveOpenTypeFeatureTags, bD as isLowercaseSmallCapsChar, bE as resolveDecorationLineY, bF as DOUBLE_STRIKE_OFFSET_PX, bG as resolveListLabel, bH as getListLabelInset, bI as getAlignedListLabelInset, bJ as getParagraphBorderInsets, bK as buildSegmentTable, bL as buildCanvasTableLayout, bM as resolveCanvasTableWidth, bN as resolveFloatingTableRect, bO as paragraphBetweenBorderMatches, bP as normalizeFamily, bQ as ROBOTO_FONT_FILES, bR as loadFontAsset, bS as getRemotePdfFontFaces, bT as OFFICE_COMPAT_FONT_FAMILIES, bU as BinaryReader, bV as buildSfnt, bW as defaultFontDecoderRegistry, bX as SfntFontProgram, bY as zlibSync, bZ as collectPdfFontFamilies, b_ as outlineFrom, b$ as getPageHeaderZoneTop, c0 as getPageColumnRects, c1 as findFootnoteReference, c2 as resolveImporterForFile, c3 as roundTo, c4 as getDocumentSectionsCanonical, c5 as getDocumentParagraphsCanonical, c6 as getDocumentParagraphs, c7 as PX_PER_CM, c8 as getDocumentPageSettings, c9 as getTableCellContentWidthForParagraph, ca as layoutMetricsEpoch, cb as bumpLayoutMetricsEpoch, cc as createCanvasLayoutSnapshotProvider, cd as on, ce as debounce, cf as unwrap, cg as perfTimer, ch as prepareDocumentFonts, ci as getRunTextBox, cj as createEditorDocument, ck as resolveResizedDimensions, cl as axisSignForDirection, cm as clamp$1, cn as MIN_RESIZE_SIZE_PX, co as resolveTextBoxRenderHeight, cp as getToolbarStyleState, cq as VERTICAL_HIT_WEIGHT, cr as getCachedCanvasImage, cs as measureParagraphMinContentWidthPx, ct as getEditableBlocksForZone, cu as findParagraphLocation, cv as createSectionBoundaryParagraph, cw as normalizePageSettings, cx as DEFAULT_EDITOR_PAGE_SETTINGS, cy as markStart, cz as markEnd, cA as getParagraphEntries, cB as getParagraphById, cC as createEditorFootnote, cD as createFootnoteReferenceRun, cE as renumberFootnotes, cF as preciseFontModeVersion, cG as isPreciseFontModeEnabled, cH as getHeadingLevel, cI as togglePreciseFontMode, cJ as nextFontSizePt, cK as previousFontSizePt, cL as fontSizePtToPx, cM as resolveNamedTextStyle, cN as resolveNamedTableStyle, cO as resolveEffectiveTableStyle, cP as createDefaultToolbarPreset, cQ as MenuRegistry, cR as createToolbarRegistry, cS as Editor, cT as resolveCommandRef, cU as commandRefName, cV as createOasisEditorClient, cW as createEditorZoom, cX as startLongTaskObserver, cY as installGlobalReport, cZ as applyStoredPreciseFontPreference, c_ as getWelcomeSeen, c$ as isLocalFontAccessSupported, d0 as EDITOR_SCROLL_PADDING_PX, d1 as Toolbar, d2 as OasisEditorLoading, d3 as I18nProvider, d4 as createTranslator, d5 as registerDomStatsSurface, d6 as createEditorLogger } from "./index-BVWzLonI.js";
4
+ import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as findParagraphIndex, K as createCollapsedSelection, L as isSelectionCollapsed, M as parseFontSizePtToPx, N as formatFontSizePt, O as createEditorParagraph, P as resolveDefaultParagraphStyleId, Q as findParagraphTableLocation, R as buildTableCellLayout, T as PT_PER_PX, U as createEditorTableCell, V as createEditorTableRow, W as createEditorTable, X as clampPosition, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as parseNumber, aE as createStore, aF as reconcile, aG as RadioGroup, aH as Radio$1, aI as TextAreaField, aJ as Text, aK as SurfaceButton, aL as delegateEvents, aM as onMount, aN as onCleanup, aO as CheckIcon, aP as use, aQ as PluginUiHost, aR as OasisEditorEditor, aS as OasisBrandMark, aT as setPreciseFontPreference, aU as setWelcomeSeen, aV as enablePreciseFontMode, aW as TWIPS_PER_POINT, aX as PX_PER_INCH, aY as TWIPS_PER_INCH, aZ as normalizeHex6, a_ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, a$ as TABLE_BORDER_EDGE_KEYS, b0 as resolveEffectiveParagraphStyle, b1 as resolveEffectiveTextStyleForParagraph, b2 as EMU_PER_PT, b3 as OOXML_ROTATION_UNITS, b4 as OOXML_PERCENT_DENOMINATOR, b5 as parseHexColorToRgb255, b6 as EMU_PER_PX, b7 as getRunEndnoteReference, b8 as iterateFootnoteReferenceRuns, b9 as iterateEndnoteReferenceRuns, ba as imageContentTypeDefaults, bb as getRunFieldChar, bc as getRunFieldInstruction, bd as createEditorRun, be as JSZip, bf as imageExtensionFromMime, bg as pxToPt$1, bh as resolveFloatingObjectRect, bi as getTextBoxFloatingGeometry, bj as getPresetPathSegments, bk as buildListLabels, bl as lineDashPatternPt, bm as DEFAULT_FONT_SIZE_PX, bn as resolveGradientAxis, bo as isDoubleUnderlineStyle, bp as isWavyUnderlineStyle, bq as underlineStyleLineWidthPx, br as WAVY_UNDERLINE_WAVELENGTH_PX, bs as WAVY_UNDERLINE_AMPLITUDE_PX, bt as DOUBLE_UNDERLINE_OFFSET_PX, bu as underlineStyleDashArray, bv as EMPHASIS_GLYPH, bw as rgb255ToHex, bx as getImageFloatingGeometry, by as textStyleToFontSizePt, bz as resolveTextAlignmentBaselineOffset, bA as TEXT_BASELINE_RATIO, bB as resolveRenderedTextChar, bC as resolveOpenTypeFeatureTags, bD as isLowercaseSmallCapsChar, bE as resolveDecorationLineY, bF as DOUBLE_STRIKE_OFFSET_PX, bG as resolveListLabel, bH as getListLabelInset, bI as getAlignedListLabelInset, bJ as getParagraphBorderInsets, bK as buildSegmentTable, bL as buildCanvasTableLayout, bM as resolveCanvasTableWidth, bN as resolveFloatingTableRect, bO as paragraphBetweenBorderMatches, bP as normalizeFamily, bQ as ROBOTO_FONT_FILES, bR as loadFontAsset, bS as getRemotePdfFontFaces, bT as OFFICE_COMPAT_FONT_FAMILIES, bU as BinaryReader, bV as buildSfnt, bW as defaultFontDecoderRegistry, bX as SfntFontProgram, bY as zlibSync, bZ as collectPdfFontFamilies, b_ as outlineFrom, b$ as getPageHeaderZoneTop, c0 as getPageColumnRects, c1 as findFootnoteReference, c2 as resolveImporterForFile, c3 as roundTo, c4 as getDocumentSectionsCanonical, c5 as getDocumentParagraphsCanonical, c6 as getDocumentParagraphs, c7 as PX_PER_CM, c8 as getDocumentPageSettings, c9 as getTableCellContentWidthForParagraph, ca as layoutMetricsEpoch, cb as bumpLayoutMetricsEpoch, cc as createCanvasLayoutSnapshotProvider, cd as on, ce as debounce, cf as unwrap, cg as perfTimer, ch as prepareDocumentFonts, ci as getRunTextBox, cj as createEditorDocument, ck as resolveResizedDimensions, cl as axisSignForDirection, cm as clamp$1, cn as MIN_RESIZE_SIZE_PX, co as resolveTextBoxRenderHeight, cp as getToolbarStyleState, cq as VERTICAL_HIT_WEIGHT, cr as getCachedCanvasImage, cs as measureParagraphMinContentWidthPx, ct as getEditableBlocksForZone, cu as findParagraphLocation, cv as createSectionBoundaryParagraph, cw as normalizePageSettings, cx as DEFAULT_EDITOR_PAGE_SETTINGS, cy as markStart, cz as markEnd, cA as getParagraphEntries, cB as getParagraphById, cC as createEditorFootnote, cD as createFootnoteReferenceRun, cE as renumberFootnotes, cF as preciseFontModeVersion, cG as isPreciseFontModeEnabled, cH as getHeadingLevel, cI as togglePreciseFontMode, cJ as nextFontSizePt, cK as previousFontSizePt, cL as fontSizePtToPx, cM as resolveNamedTextStyle, cN as resolveNamedTableStyle, cO as resolveEffectiveTableStyle, cP as createDefaultToolbarPreset, cQ as MenuRegistry, cR as createToolbarRegistry, cS as Editor, cT as resolveCommandRef, cU as commandRefName, cV as createOasisEditorClient, cW as createEditorZoom, cX as startLongTaskObserver, cY as installGlobalReport, cZ as applyStoredPreciseFontPreference, c_ as getWelcomeSeen, c$ as isLocalFontAccessSupported, d0 as EDITOR_SCROLL_PADDING_PX, d1 as Toolbar, d2 as OasisEditorLoading, d3 as I18nProvider, d4 as createTranslator, d5 as registerDomStatsSurface, d6 as createEditorLogger } from "./index-PWJQT9bT.js";
5
5
  function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
6
6
  const {
7
7
  pageIndex,
@@ -27958,21 +27958,28 @@ function withSelection(position) {
27958
27958
  }
27959
27959
  function getFocusParagraph(state) {
27960
27960
  const paragraphs = getParagraphs(state);
27961
- const focus = clampPosition(state, state.selection.focus);
27962
- const index = findParagraphIndex(paragraphs, focus.paragraphId);
27961
+ const index = findParagraphIndex(
27962
+ paragraphs,
27963
+ state.selection.focus.paragraphId
27964
+ );
27963
27965
  const paragraph = paragraphs[index];
27966
+ const focus = paragraphOffsetToPosition(
27967
+ paragraph,
27968
+ positionToParagraphOffset(paragraph, state.selection.focus)
27969
+ );
27964
27970
  return {
27965
27971
  paragraph,
27972
+ paragraphs,
27966
27973
  index,
27967
27974
  offset: positionToParagraphOffset(paragraph, focus)
27968
27975
  };
27969
27976
  }
27970
27977
  function deleteSelectionRange(state) {
27971
- const normalized = normalizeSelection(state);
27978
+ const paragraphs = getParagraphs(state);
27979
+ const normalized = normalizeSelection(state, paragraphs);
27972
27980
  if (normalized.isCollapsed) {
27973
27981
  return state;
27974
27982
  }
27975
- const paragraphs = getParagraphs(state);
27976
27983
  if (state.trackChangesEnabled) {
27977
27984
  const revisionId = `rev:${Math.random().toString(36).slice(2, 9)}`;
27978
27985
  const author = "User";
@@ -30979,8 +30986,7 @@ function moveVertical(state, delta) {
30979
30986
  if (!isSelectionCollapsed(state.selection)) {
30980
30987
  return collapseToBoundary(state, delta < 0 ? "start" : "end");
30981
30988
  }
30982
- const { index, offset } = getFocusParagraph(state);
30983
- const paragraphs = getParagraphs(state);
30989
+ const { paragraphs, index, offset } = getFocusParagraph(state);
30984
30990
  const nextIndex = index + delta;
30985
30991
  if (nextIndex < 0 || nextIndex >= paragraphs.length) {
30986
30992
  return state;
@@ -30997,11 +31003,12 @@ function moveVertical(state, delta) {
30997
31003
  );
30998
31004
  }
30999
31005
  function moveFocusHorizontally(state, delta) {
31000
- const focus = clampPosition(state, state.selection.focus);
31001
- const paragraphs = getParagraphs(state);
31002
- const index = findParagraphIndex(paragraphs, focus.paragraphId);
31003
- const paragraph = paragraphs[index];
31004
- const paragraphOffset = positionToParagraphOffset(paragraph, focus);
31006
+ const {
31007
+ paragraphs,
31008
+ paragraph,
31009
+ index,
31010
+ offset: paragraphOffset
31011
+ } = getFocusParagraph(state);
31005
31012
  const paragraphLength = getParagraphLength(paragraph);
31006
31013
  if (delta < 0 && paragraphOffset > 0) {
31007
31014
  return setStateSelection(state, {
@@ -31035,11 +31042,11 @@ function moveFocusHorizontally(state, delta) {
31035
31042
  return state;
31036
31043
  }
31037
31044
  function moveFocusVertical(state, delta) {
31038
- const focus = clampPosition(state, state.selection.focus);
31039
- const paragraphs = getParagraphs(state);
31040
- const index = findParagraphIndex(paragraphs, focus.paragraphId);
31041
- const paragraph = paragraphs[index];
31042
- const paragraphOffset = positionToParagraphOffset(paragraph, focus);
31045
+ const {
31046
+ paragraphs,
31047
+ index,
31048
+ offset: paragraphOffset
31049
+ } = getFocusParagraph(state);
31043
31050
  const nextIndex = index + delta;
31044
31051
  if (nextIndex < 0 || nextIndex >= paragraphs.length) {
31045
31052
  return state;
@@ -55846,7 +55853,7 @@ var _tmpl$ = /* @__PURE__ */ template(`<div class="oasis-editor-shell oasis-edit
55846
55853
  function OasisEditorApp(props = {}) {
55847
55854
  var _a;
55848
55855
  const runtimeClient = ((_a = props.runtime) == null ? void 0 : _a.client) ?? createOasisEditorClient();
55849
- const [uiOverrides] = createSignal({});
55856
+ const [uiOverrides, setUiOverrides] = createSignal({});
55850
55857
  const ui = () => {
55851
55858
  var _a2;
55852
55859
  return {
@@ -55864,6 +55871,24 @@ function OasisEditorApp(props = {}) {
55864
55871
  readOnly: uiOverrides().readOnly
55865
55872
  }
55866
55873
  });
55874
+ const getUiState = () => ({
55875
+ ...ui(),
55876
+ readOnly: documentOptions().readOnly
55877
+ });
55878
+ const updateUiState = (patch) => {
55879
+ setUiOverrides((current) => ({
55880
+ ...current,
55881
+ ...patch,
55882
+ toolbar: {
55883
+ ...current.toolbar ?? {},
55884
+ ...patch.toolbar ?? {}
55885
+ }
55886
+ }));
55887
+ return {
55888
+ ...getUiState(),
55889
+ ...patch
55890
+ };
55891
+ };
55867
55892
  const runtimeOptions = () => props.runtime ?? {};
55868
55893
  syncCanvasDebugApiVisibility();
55869
55894
  const translator = createTranslator(() => ui().locale ?? "pt-BR");
@@ -56032,6 +56057,9 @@ function OasisEditorApp(props = {}) {
56032
56057
  runtimeClient,
56033
56058
  runtimeOptions,
56034
56059
  documentOptions,
56060
+ getUiState,
56061
+ updateUiState,
56062
+ zoom,
56035
56063
  importInputRef,
56036
56064
  imageInputRef,
56037
56065
  setLinkDialog,
@@ -4,6 +4,7 @@ import { normalizeSelection } from '../selection.js';
4
4
  export declare function withSelection(position: EditorPosition): EditorSelection;
5
5
  export declare function getFocusParagraph(state: EditorState): {
6
6
  paragraph: EditorParagraphNode;
7
+ paragraphs: EditorParagraphNode[];
7
8
  index: number;
8
9
  offset: number;
9
10
  };
@@ -2731,7 +2731,7 @@ function OasisEditorAppLazy(props = {}) {
2731
2731
  onCleanup(() => {
2732
2732
  cancelled = true;
2733
2733
  });
2734
- import("./OasisEditorApp-B1x9P0Ua.js").then((m) => {
2734
+ import("./OasisEditorApp-DNiy9Yze.js").then((m) => {
2735
2735
  cancelled = true;
2736
2736
  setProgress(1);
2737
2737
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -3448,7 +3448,10 @@ function getParagraphText(paragraph) {
3448
3448
  return paragraph.runs.map((run) => run.text).join("");
3449
3449
  }
3450
3450
  function getParagraphLength(paragraph) {
3451
- return getParagraphText(paragraph).length;
3451
+ return paragraph.runs.reduce(
3452
+ (length, run) => length + run.text.length,
3453
+ 0
3454
+ );
3452
3455
  }
3453
3456
  function getRunIndex(paragraph, runId) {
3454
3457
  const index = paragraph.runs.findIndex((run) => run.id === runId);
@@ -4381,8 +4384,12 @@ function cloneDocument(document2) {
4381
4384
  return structuredClone(document2);
4382
4385
  }
4383
4386
  function normalizeDocument(document2) {
4387
+ var _a2;
4384
4388
  const next = cloneDocument(document2);
4385
4389
  next.schemaVersion = next.schemaVersion ?? EDITOR_SCHEMA_VERSION;
4390
+ if (!((_a2 = next.sections) == null ? void 0 : _a2.length)) {
4391
+ next.sections = getDocumentSectionsCanonical(next);
4392
+ }
4386
4393
  return next;
4387
4394
  }
4388
4395
  function validateDocument(document2) {
@@ -4428,7 +4435,9 @@ function allNodes(document2) {
4428
4435
  });
4429
4436
  });
4430
4437
  });
4431
- document2.sections.forEach((section) => visitBlocks(section.blocks));
4438
+ getDocumentSectionsCanonical(document2).forEach(
4439
+ (section) => visitBlocks(section.blocks)
4440
+ );
4432
4441
  return result;
4433
4442
  }
4434
4443
  function resolveParagraph(document2, selector) {
@@ -4487,7 +4496,7 @@ function replaceParagraph(document2, id, update) {
4487
4496
  }
4488
4497
  return false;
4489
4498
  };
4490
- document2.sections.some((section) => visit(section.blocks));
4499
+ getDocumentSectionsCanonical(document2).some((section) => visit(section.blocks));
4491
4500
  }
4492
4501
  function queryDocument(document2) {
4493
4502
  const outline = () => getDocumentParagraphsCanonical(document2).flatMap((p) => {
@@ -4525,6 +4534,7 @@ function applyDocumentOperations(document2, operations) {
4525
4534
  const next = normalizeDocument(document2);
4526
4535
  const changedNodeIds = [];
4527
4536
  const createdNodeIds = [];
4537
+ const sections = next.sections;
4528
4538
  for (const operation of operations) {
4529
4539
  if (operation.op === "insertText" || operation.op === "replaceText") {
4530
4540
  const paragraph = resolveParagraph(next, operation.target);
@@ -4555,7 +4565,7 @@ function applyDocumentOperations(document2, operations) {
4555
4565
  changedNodeIds.push(paragraph.id);
4556
4566
  } else if (operation.op === "insertParagraph" || operation.op === "insertBlocks" || operation.op === "insertTable") {
4557
4567
  const blocks = operation.op === "insertParagraph" ? [createEditorParagraph(operation.text ?? "")] : operation.op === "insertTable" ? [createTable(operation.rows)] : operation.blocks;
4558
- next.sections[0].blocks.push(...blocks);
4568
+ sections[0].blocks.push(...blocks);
4559
4569
  blocks.forEach((b) => {
4560
4570
  createdNodeIds.push(b.id);
4561
4571
  changedNodeIds.push(b.id);
@@ -4577,7 +4587,7 @@ function applyDocumentOperations(document2, operations) {
4577
4587
  }
4578
4588
  return blocks.some((b) => b.type === "table" && b.rows.some((r) => r.cells.some((c) => remove(c.blocks))));
4579
4589
  };
4580
- if (!next.sections.some((section) => remove(section.blocks))) throw new Error("NODE_NOT_FOUND");
4590
+ if (!sections.some((section) => remove(section.blocks))) throw new Error("NODE_NOT_FOUND");
4581
4591
  changedNodeIds.push(target);
4582
4592
  } else throw new Error("UNSUPPORTED_OPERATION");
4583
4593
  }
@@ -4837,7 +4847,9 @@ function createOasisEditorClient() {
4837
4847
  var _a2, _b2;
4838
4848
  if ((_a2 = request.signal) == null ? void 0 : _a2.aborted) return { ok: false, error: { code: "ABORTED", message: "Import aborted" } };
4839
4849
  try {
4840
- const data = request.data instanceof Blob ? request.data : new Blob([request.data]);
4850
+ const data = request.data instanceof Blob ? request.data : new Blob([
4851
+ request.data instanceof Uint8Array ? Uint8Array.from(request.data).buffer : request.data
4852
+ ]);
4841
4853
  const file = new File([data], request.filename ?? "document.docx", { type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document" });
4842
4854
  await requireHost().importDocx(file);
4843
4855
  version2 += 1;
@@ -17882,9 +17894,9 @@ function sliceFragmentToRange(fragment, startOffset, endOffset) {
17882
17894
  if (start >= end) {
17883
17895
  return null;
17884
17896
  }
17885
- const chars2 = fragment.chars.filter(
17886
- (char) => char.paragraphOffset >= start && char.paragraphOffset < end
17887
- );
17897
+ const firstCharIndex = findFirstCharAtOrAfter(fragment.chars, start);
17898
+ const lastCharIndex = findFirstCharAtOrAfter(fragment.chars, end);
17899
+ const chars2 = fragment.chars.slice(firstCharIndex, lastCharIndex);
17888
17900
  return {
17889
17901
  paragraphId: fragment.paragraphId,
17890
17902
  runId: fragment.runId,
@@ -17898,6 +17910,54 @@ function sliceFragmentToRange(fragment, startOffset, endOffset) {
17898
17910
  chars: chars2
17899
17911
  };
17900
17912
  }
17913
+ function findFirstCharAtOrAfter(chars2, offset) {
17914
+ let low = 0;
17915
+ let high = chars2.length;
17916
+ while (low < high) {
17917
+ const middle = low + Math.floor((high - low) / 2);
17918
+ if (chars2[middle].paragraphOffset < offset) {
17919
+ low = middle + 1;
17920
+ } else {
17921
+ high = middle;
17922
+ }
17923
+ }
17924
+ return low;
17925
+ }
17926
+ function sliceFragmentsToRanges(fragments, ranges) {
17927
+ const rangesAreOrdered = ranges.every(
17928
+ (range, index) => index === 0 || range.startOffset >= ranges[index - 1].startOffset
17929
+ );
17930
+ const fragmentsAreOrdered = fragments.every(
17931
+ (fragment, index) => index === 0 || fragment.startOffset >= fragments[index - 1].startOffset
17932
+ );
17933
+ if (!rangesAreOrdered || !fragmentsAreOrdered) {
17934
+ return ranges.map(
17935
+ (range) => fragments.map(
17936
+ (fragment) => sliceFragmentToRange(fragment, range.startOffset, range.endOffset)
17937
+ ).filter(
17938
+ (fragment) => fragment !== null
17939
+ )
17940
+ );
17941
+ }
17942
+ let firstCandidateIndex = 0;
17943
+ return ranges.map((range) => {
17944
+ while (firstCandidateIndex < fragments.length && fragments[firstCandidateIndex].endOffset <= range.startOffset) {
17945
+ firstCandidateIndex += 1;
17946
+ }
17947
+ const sliced = [];
17948
+ for (let index = firstCandidateIndex; index < fragments.length && fragments[index].startOffset < range.endOffset; index += 1) {
17949
+ const fragment = sliceFragmentToRange(
17950
+ fragments[index],
17951
+ range.startOffset,
17952
+ range.endOffset
17953
+ );
17954
+ if (fragment) {
17955
+ sliced.push(fragment);
17956
+ }
17957
+ }
17958
+ return sliced;
17959
+ });
17960
+ }
17901
17961
  let paragraphLayoutCache = /* @__PURE__ */ new WeakMap();
17902
17962
  const paragraphFieldDependenceCache = /* @__PURE__ */ new WeakMap();
17903
17963
  function clearProjectedParagraphLayoutCache() {
@@ -17976,21 +18036,19 @@ function projectParagraphLayout(paragraph, pageIndex, totalPages, styles, conten
17976
18036
  fontSize,
17977
18037
  styles
17978
18038
  );
17979
- const lines = measurer.composeMeasuredParagraphLines({
18039
+ const composedLines = measurer.composeMeasuredParagraphLines({
17980
18040
  paragraph,
17981
18041
  fragments,
17982
18042
  styles,
17983
18043
  contentWidth,
17984
18044
  defaultTabStop,
17985
18045
  hyphenation: context2.hyphenation
17986
- }).map((line) => ({
18046
+ });
18047
+ const fragmentsByLine = sliceFragmentsToRanges(fragments, composedLines);
18048
+ const lines = composedLines.map((line, index) => ({
17987
18049
  ...line,
17988
18050
  height: line.height || lineHeight,
17989
- fragments: fragments.map(
17990
- (fragment) => sliceFragmentToRange(fragment, line.startOffset, line.endOffset)
17991
- ).filter(
17992
- (fragment) => fragment !== null
17993
- )
18051
+ fragments: fragmentsByLine[index]
17994
18052
  }));
17995
18053
  return {
17996
18054
  paragraphId: paragraph.id,
@@ -18056,21 +18114,22 @@ function projectParagraphLayoutWithExclusions(paragraph, pageSettings, contentWi
18056
18114
  if (exclusions.length === 0) {
18057
18115
  return preliminary;
18058
18116
  }
18059
- const lines = measurer.composeMeasuredParagraphLines({
18117
+ const composedLines = measurer.composeMeasuredParagraphLines({
18060
18118
  paragraph,
18061
18119
  fragments: preliminary.fragments,
18062
18120
  styles,
18063
18121
  contentWidth,
18064
18122
  defaultTabStop,
18065
18123
  exclusions
18066
- }).map((line) => ({
18124
+ });
18125
+ const fragmentsByLine = sliceFragmentsToRanges(
18126
+ preliminary.fragments,
18127
+ composedLines
18128
+ );
18129
+ const lines = composedLines.map((line, index) => ({
18067
18130
  ...line,
18068
18131
  height: line.height || lineHeight,
18069
- fragments: preliminary.fragments.map(
18070
- (fragment) => sliceFragmentToRange(fragment, line.startOffset, line.endOffset)
18071
- ).filter(
18072
- (fragment) => fragment !== null
18073
- )
18132
+ fragments: fragmentsByLine[index]
18074
18133
  }));
18075
18134
  return {
18076
18135
  paragraphId: paragraph.id,
@@ -18083,11 +18142,15 @@ function projectParagraphLayoutWithExclusions(paragraph, pageSettings, contentWi
18083
18142
  };
18084
18143
  }
18085
18144
  function applyMeasuredLineGeometry(projected, measured) {
18145
+ const fragmentsByLine = sliceFragmentsToRanges(
18146
+ projected.fragments,
18147
+ measured.lines
18148
+ );
18086
18149
  return {
18087
18150
  ...projected,
18088
18151
  startOffset: measured.startOffset ?? projected.startOffset,
18089
18152
  endOffset: measured.endOffset ?? projected.endOffset,
18090
- lines: measured.lines.map((line) => ({
18153
+ lines: measured.lines.map((line, index) => ({
18091
18154
  paragraphId: projected.paragraphId,
18092
18155
  index: line.index,
18093
18156
  startOffset: line.startOffset,
@@ -18103,11 +18166,7 @@ function applyMeasuredLineGeometry(projected, measured) {
18103
18166
  height: slot.height
18104
18167
  })
18105
18168
  ),
18106
- fragments: projected.fragments.map(
18107
- (fragment) => sliceFragmentToRange(fragment, line.startOffset, line.endOffset)
18108
- ).filter(
18109
- (fragment) => fragment !== null
18110
- )
18169
+ fragments: fragmentsByLine[index]
18111
18170
  }))
18112
18171
  };
18113
18172
  }
@@ -47331,21 +47390,21 @@ export {
47331
47390
  normalizeSelection as G,
47332
47391
  positionToParagraphOffset as H,
47333
47392
  paragraphOffsetToPosition as I,
47334
- clampPosition as J,
47335
- findParagraphIndex as K,
47336
- createCollapsedSelection as L,
47337
- isSelectionCollapsed as M,
47338
- parseFontSizePtToPx as N,
47339
- formatFontSizePt as O,
47340
- createEditorParagraph as P,
47341
- resolveDefaultParagraphStyleId as Q,
47342
- findParagraphTableLocation as R,
47393
+ findParagraphIndex as J,
47394
+ createCollapsedSelection as K,
47395
+ isSelectionCollapsed as L,
47396
+ parseFontSizePtToPx as M,
47397
+ formatFontSizePt as N,
47398
+ createEditorParagraph as O,
47399
+ resolveDefaultParagraphStyleId as P,
47400
+ findParagraphTableLocation as Q,
47401
+ buildTableCellLayout as R,
47343
47402
  STANDARD_FONT_SIZES_PT as S,
47344
- buildTableCellLayout as T,
47345
- PT_PER_PX as U,
47346
- createEditorTableCell as V,
47347
- createEditorTableRow as W,
47348
- createEditorTable as X,
47403
+ PT_PER_PX as T,
47404
+ createEditorTableCell as U,
47405
+ createEditorTableRow as V,
47406
+ createEditorTable as W,
47407
+ clampPosition as X,
47349
47408
  PX_PER_POINT as Y,
47350
47409
  underlineStyleToCssDecorationStyle as Z,
47351
47410
  resolveImageSrc as _,
@@ -1,4 +1,4 @@
1
- import { d7, a5, aj, az, at, d8, d9, da, an, db, a6, dc, cS, aA, dd, de, ay, aq, df, dg, dh, a4, di, cQ, aC, dj, dk, dl, dm, dn, d2, dp, dq, dr, aH, aG, ds, ar, dt, du, dv, dw, dx, dy, av, as, dz, aK, aB, aJ, aI, am, ax, d1, dA, d8 as d82, df as df2, di as di2, ds as ds2, dt as dt2, dy as dy2, dB, dC, cU, cP, dD, dE, dF, dG, dH, dI, dJ, cR, dK, dL, dM, cT, dN } from "./index-BVWzLonI.js";
1
+ import { d7, a5, aj, az, at, d8, d9, da, an, db, a6, dc, cS, aA, dd, de, ay, aq, df, dg, dh, a4, di, cQ, aC, dj, dk, dl, dm, dn, d2, dp, dq, dr, aH, aG, ds, ar, dt, du, dv, dw, dx, dy, av, as, dz, aK, aB, aJ, aI, am, ax, d1, dA, d8 as d82, df as df2, di as di2, ds as ds2, dt as dt2, dy as dy2, dB, dC, cU, cP, dD, dE, dF, dG, dH, dI, dJ, cR, dK, dL, dM, cT, dN } from "./index-PWJQT9bT.js";
2
2
  export {
3
3
  d7 as ActionRow,
4
4
  a5 as BalloonShell,