oasis-editor 0.0.104 → 0.0.105

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 { v as visitRun, a as assertNever, c as createSignal, b as createEditorStateFromDocument, d as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, f as fontSizePxToPt, p as probeLocalFontFamilies, e as createEditorParagraphFromRuns, i as isInlineObjectRun, g as createEditorStyledRun, h as getParagraphLength, j as getParagraphText, k as getActiveZone, l as getDocumentSections, m as getActiveSectionIndex, n as getParagraphs, o as normalizeSelection, q as positionToParagraphOffset, r as paragraphOffsetToPosition, s as clampPosition, t as findParagraphIndex, u as createCollapsedSelection, w as isSelectionCollapsed, x as parseFontSizePtToPx, y as formatFontSizePt, z as createEditorParagraph, A as getBlockParagraphs, B as findParagraphTableLocation, C as buildTableCellLayout, P as PT_PER_PX, D as createEditorTableCell, E as createEditorTableRow, F as createEditorTable, G as underlineStyleToCssDecorationStyle, H as resolveImageSrc, I as listKindForTag, J as isParagraphTag, K as collectInlineRuns, L as parseParagraphStyle, M as getRunImage, N as InlineShell, O as BalloonShell, Q as DocumentShell, R as createMemo, T as buildCanvasLayoutSnapshot, U as getCaretRectFromSnapshot, V as getParagraphRectFromSnapshot, W as createComponent, X as CaretOverlay, Y as Show, Z as createRenderEffect, _ as style, $ as setAttribute, a0 as setStyleProperty, a1 as memo, a2 as template, a3 as useI18n, a4 as createEffect, a5 as insert, a6 as use, a7 as addEventListener, a8 as Dialog, a9 as delegateEvents, aa as className, ab as For, ac as UNDERLINE_STYLE_OPTIONS, ad as Tabs, ae as onMount, af as onCleanup, ag as PluginUiHost, ah as OasisEditorEditor, ai as OasisBrandMark, aj as setPreciseFontPreference, ak as setWelcomeSeen, al as enablePreciseFontMode, am as TWIPS_PER_POINT, an as PX_PER_INCH, ao as TWIPS_PER_INCH, ap as resolveEffectiveParagraphStyle, aq as resolveEffectiveTextStyleForParagraph, ar as EMU_PER_PX, as as EMU_PER_PT, at as getRunFootnoteReference, au as getRunEndnoteReference, av as iterateFootnoteReferenceRuns, aw as iterateEndnoteReferenceRuns, ax as imageContentTypeDefaults, ay as getRunFieldChar, az as getRunFieldInstruction, aA as createEditorRun, aB as JSZip, aC as imageExtensionFromMime, aD as pxToPt$1, aE as resolveFloatingObjectRect, aF as getTextBoxFloatingGeometry, aG as getPresetPathSegments, aH as projectBlocksLayout, aI as buildListLabels, aJ as getImageFloatingGeometry, aK as textStyleToFontSizePt, aL as PX_PER_POINT, aM as resolveOpenTypeFeatureTags, aN as DEFAULT_FONT_SIZE_PX, aO as isDoubleUnderlineStyle, aP as isWavyUnderlineStyle, aQ as underlineStyleLineWidthPx, aR as underlineStyleDashArray, aS as resolveListLabel, aT as getListLabelInset, aU as getAlignedListLabelInset, aV as getParagraphBorderInsets, aW as buildSegmentTable, aX as buildCanvasTableLayout, aY as resolveCanvasTableWidth, aZ as resolveFloatingTableRect, a_ as normalizeFamily, a$ as ROBOTO_FONT_FILES, b0 as loadFontAsset, b1 as OFFICE_COMPAT_FONT_FAMILIES, b2 as BinaryReader, b3 as buildSfnt, b4 as defaultFontDecoderRegistry, b5 as SfntFontProgram, b6 as collectPdfFontFamilies, b7 as projectDocumentLayout, b8 as getPageContentWidth, b9 as getPageHeaderZoneTop, ba as getPageBodyTop, bb as getPageColumnRects, bc as findFootnoteReference, bd as FOOTNOTE_MARKER_GUTTER_PX, be as resolveImporterForFile, bf as getDocumentSectionsCanonical, bg as getDocumentParagraphsCanonical, bh as getDocumentParagraphs, bi as getDocumentPageSettings, bj as getTableCellContentWidthForParagraph, bk as on, bl as debounce, bm as unwrap, bn as perfTimer, bo as getRunTextBox, bp as createEditorDocument, bq as resolveResizedDimensions, br as resolveTextBoxRenderHeight, bs as getToolbarStyleState, bt as getCachedCanvasImage, bu as measureParagraphMinContentWidthPx, bv as getEditableBlocksForZone, bw as findParagraphLocation, bx as createSectionBoundaryParagraph, by as normalizePageSettings, bz as DEFAULT_EDITOR_PAGE_SETTINGS, bA as markStart, bB as markEnd, bC as getParagraphEntries, bD as getParagraphById, bE as createEditorFootnote, bF as createFootnoteReferenceRun, bG as renumberFootnotes, bH as getFootnoteDisplayMarker, bI as getHeadingLevel, bJ as preciseFontModeVersion, bK as isPreciseFontModeEnabled, bL as resolveNamedTextStyle, bM as togglePreciseFontMode, bN as nextFontSizePt, bO as previousFontSizePt, bP as fontSizePtToPx, bQ as createDefaultToolbarPreset, bR as MenuRegistry, bS as createToolbarRegistry, bT as Editor, bU as resolveCommandRef, bV as commandRefName, bW as createOasisEditorClient, bX as createEditorZoom, bY as startLongTaskObserver, bZ as installGlobalReport, b_ as applyStoredPreciseFontPreference, b$ as getWelcomeSeen, c0 as isLocalFontAccessSupported, c1 as EDITOR_SCROLL_PADDING_PX, c2 as Toolbar, c3 as OasisEditorLoading, c4 as I18nProvider, c5 as createTranslator, c6 as createEditorLogger, c7 as registerDomStatsSurface } from "./index-CtMU1BSO.js";
4
+ import { v as visitRun, a as assertNever, c as createSignal, b as createEditorStateFromDocument, d as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, f as fontSizePxToPt, p as probeLocalFontFamilies, e as createEditorParagraphFromRuns, i as isInlineObjectRun, g as createEditorStyledRun, h as getParagraphLength, j as getParagraphText, k as getActiveZone, l as getDocumentSections, m as getActiveSectionIndex, n as getParagraphs, o as normalizeSelection, q as positionToParagraphOffset, r as paragraphOffsetToPosition, s as clampPosition, t as findParagraphIndex, u as createCollapsedSelection, w as isSelectionCollapsed, x as parseFontSizePtToPx, y as formatFontSizePt, z as createEditorParagraph, A as getBlockParagraphs, B as findParagraphTableLocation, C as buildTableCellLayout, P as PT_PER_PX, D as createEditorTableCell, E as createEditorTableRow, F as createEditorTable, G as underlineStyleToCssDecorationStyle, H as resolveImageSrc, I as listKindForTag, J as isParagraphTag, K as collectInlineRuns, L as parseParagraphStyle, M as getRunImage, N as InlineShell, O as BalloonShell, Q as DocumentShell, R as createMemo, T as buildCanvasLayoutSnapshot, U as getCaretRectFromSnapshot, V as getParagraphRectFromSnapshot, W as createComponent, X as CaretOverlay, Y as Show, Z as createRenderEffect, _ as style, $ as setAttribute, a0 as setStyleProperty, a1 as memo, a2 as template, a3 as useI18n, a4 as createEffect, a5 as insert, a6 as use, a7 as addEventListener, a8 as Dialog, a9 as delegateEvents, aa as className, ab as For, ac as UNDERLINE_STYLE_OPTIONS, ad as Tabs, ae as onMount, af as onCleanup, ag as PluginUiHost, ah as OasisEditorEditor, ai as OasisBrandMark, aj as setPreciseFontPreference, ak as setWelcomeSeen, al as enablePreciseFontMode, am as TWIPS_PER_POINT, an as PX_PER_INCH, ao as TWIPS_PER_INCH, ap as resolveEffectiveParagraphStyle, aq as resolveEffectiveTextStyleForParagraph, ar as EMU_PER_PX, as as EMU_PER_PT, at as getRunFootnoteReference, au as getRunEndnoteReference, av as iterateFootnoteReferenceRuns, aw as iterateEndnoteReferenceRuns, ax as imageContentTypeDefaults, ay as getRunFieldChar, az as getRunFieldInstruction, aA as createEditorRun, aB as JSZip, aC as imageExtensionFromMime, aD as pxToPt$1, aE as resolveFloatingObjectRect, aF as getTextBoxFloatingGeometry, aG as getPresetPathSegments, aH as projectBlocksLayout, aI as buildListLabels, aJ as getImageFloatingGeometry, aK as textStyleToFontSizePt, aL as PX_PER_POINT, aM as resolveOpenTypeFeatureTags, aN as DEFAULT_FONT_SIZE_PX, aO as isDoubleUnderlineStyle, aP as isWavyUnderlineStyle, aQ as underlineStyleLineWidthPx, aR as underlineStyleDashArray, aS as resolveListLabel, aT as getListLabelInset, aU as getAlignedListLabelInset, aV as getParagraphBorderInsets, aW as buildSegmentTable, aX as buildCanvasTableLayout, aY as resolveCanvasTableWidth, aZ as resolveFloatingTableRect, a_ as normalizeFamily, a$ as ROBOTO_FONT_FILES, b0 as loadFontAsset, b1 as OFFICE_COMPAT_FONT_FAMILIES, b2 as BinaryReader, b3 as buildSfnt, b4 as defaultFontDecoderRegistry, b5 as SfntFontProgram, b6 as collectPdfFontFamilies, b7 as projectDocumentLayout, b8 as getPageContentWidth, b9 as getPageHeaderZoneTop, ba as getPageBodyTop, bb as getPageColumnRects, bc as findFootnoteReference, bd as FOOTNOTE_MARKER_GUTTER_PX, be as resolveImporterForFile, bf as getDocumentSectionsCanonical, bg as getDocumentParagraphsCanonical, bh as getDocumentParagraphs, bi as getDocumentPageSettings, bj as getTableCellContentWidthForParagraph, bk as on, bl as debounce, bm as unwrap, bn as perfTimer, bo as getRunTextBox, bp as createEditorDocument, bq as resolveResizedDimensions, br as resolveTextBoxRenderHeight, bs as getToolbarStyleState, bt as getCachedCanvasImage, bu as measureParagraphMinContentWidthPx, bv as getEditableBlocksForZone, bw as findParagraphLocation, bx as createSectionBoundaryParagraph, by as normalizePageSettings, bz as DEFAULT_EDITOR_PAGE_SETTINGS, bA as markStart, bB as markEnd, bC as getParagraphEntries, bD as getParagraphById, bE as createEditorFootnote, bF as createFootnoteReferenceRun, bG as renumberFootnotes, bH as getFootnoteDisplayMarker, bI as getHeadingLevel, bJ as preciseFontModeVersion, bK as isPreciseFontModeEnabled, bL as resolveNamedTextStyle, bM as togglePreciseFontMode, bN as nextFontSizePt, bO as previousFontSizePt, bP as fontSizePtToPx, bQ as createDefaultToolbarPreset, bR as MenuRegistry, bS as createToolbarRegistry, bT as Editor, bU as resolveCommandRef, bV as commandRefName, bW as createOasisEditorClient, bX as createEditorZoom, bY as startLongTaskObserver, bZ as installGlobalReport, b_ as applyStoredPreciseFontPreference, b$ as getWelcomeSeen, c0 as isLocalFontAccessSupported, c1 as EDITOR_SCROLL_PADDING_PX, c2 as Toolbar, c3 as OasisEditorLoading, c4 as I18nProvider, c5 as createTranslator, c6 as createEditorLogger, c7 as registerDomStatsSurface } from "./index-DdcPkCmB.js";
5
5
  function cloneStyle(style2) {
6
6
  return style2 ? { ...style2 } : void 0;
7
7
  }
@@ -40957,11 +40957,14 @@ function normalizeParagraphLayouts(current, dirtyParagraphIds) {
40957
40957
  if (dirtyParagraphIds.length === 0) {
40958
40958
  return current;
40959
40959
  }
40960
- const next = { ...current };
40960
+ let next;
40961
40961
  for (const paragraphId of dirtyParagraphIds) {
40962
- delete next[paragraphId];
40962
+ if (Object.prototype.hasOwnProperty.call(current, paragraphId)) {
40963
+ next ?? (next = { ...current });
40964
+ delete next[paragraphId];
40965
+ }
40963
40966
  }
40964
- return next;
40967
+ return next ?? current;
40965
40968
  }
40966
40969
  function useEditorLayout(props) {
40967
40970
  const [measuredBlockHeights, setMeasuredBlockHeights] = createSignal({});
@@ -2519,7 +2519,7 @@ function OasisEditorAppLazy(props = {}) {
2519
2519
  onCleanup(() => {
2520
2520
  cancelled = true;
2521
2521
  });
2522
- import("./OasisEditorApp-Bmif284h.js").then((m) => {
2522
+ import("./OasisEditorApp-CwVZxG1m.js").then((m) => {
2523
2523
  cancelled = true;
2524
2524
  setProgress(1);
2525
2525
  setTimeout(() => setApp(() => m.OasisEditorApp), 180);
@@ -13089,6 +13089,50 @@ function getTableCellContentWidthForParagraph(document2, paragraphId, activeSect
13089
13089
  cellWidth - horizontalChrome
13090
13090
  );
13091
13091
  }
13092
+ const cache = /* @__PURE__ */ new WeakMap();
13093
+ function getOrCreateStylesBucket(byStyles, styles) {
13094
+ let bucket = byStyles.get(styles);
13095
+ if (!bucket) {
13096
+ bucket = /* @__PURE__ */ new Map();
13097
+ byStyles.set(styles, bucket);
13098
+ }
13099
+ return bucket;
13100
+ }
13101
+ function resolveCachedTableCellParagraph(source, formatting, styles) {
13102
+ var _a;
13103
+ const inherited = resolveTableParagraphInheritance(
13104
+ formatting == null ? void 0 : formatting.paragraphStyle,
13105
+ (_a = source.style) == null ? void 0 : _a.styleId,
13106
+ styles
13107
+ );
13108
+ const signature = JSON.stringify([
13109
+ inherited ?? null,
13110
+ (formatting == null ? void 0 : formatting.textStyle) ?? null
13111
+ ]);
13112
+ let perParagraph = cache.get(source);
13113
+ if (!perParagraph) {
13114
+ perParagraph = { noStyles: /* @__PURE__ */ new Map(), byStyles: /* @__PURE__ */ new WeakMap() };
13115
+ cache.set(source, perParagraph);
13116
+ }
13117
+ const bucket = styles ? getOrCreateStylesBucket(perParagraph.byStyles, styles) : perParagraph.noStyles;
13118
+ const cached = bucket.get(signature);
13119
+ if (cached) {
13120
+ return cached;
13121
+ }
13122
+ const resolved = {
13123
+ ...source,
13124
+ style: {
13125
+ ...inherited,
13126
+ ...source.style
13127
+ },
13128
+ runs: source.runs.map((run) => ({
13129
+ ...run,
13130
+ styles: { ...formatting == null ? void 0 : formatting.textStyle, ...run.styles }
13131
+ }))
13132
+ };
13133
+ bucket.set(signature, resolved);
13134
+ return resolved;
13135
+ }
13092
13136
  const DEFAULT_FONT_SIZE$1 = 14.6667;
13093
13137
  const DEFAULT_LINE_HEIGHT = 1.15;
13094
13138
  const DEFAULT_TABLE_CELL_HORIZONTAL_PADDING_PX = 14.4;
@@ -13222,24 +13266,9 @@ function estimateTableRowHeight(row, styles, measurer, defaultTabStop, contentWi
13222
13266
  const cell = {
13223
13267
  ...sourceCell,
13224
13268
  style: (formatting == null ? void 0 : formatting.cellStyle) ?? sourceCell.style,
13225
- blocks: sourceCell.blocks.map((paragraph) => {
13226
- var _a3;
13227
- return {
13228
- ...paragraph,
13229
- style: {
13230
- ...resolveTableParagraphInheritance(
13231
- formatting == null ? void 0 : formatting.paragraphStyle,
13232
- (_a3 = paragraph.style) == null ? void 0 : _a3.styleId,
13233
- styles
13234
- ),
13235
- ...paragraph.style
13236
- },
13237
- runs: paragraph.runs.map((run) => ({
13238
- ...run,
13239
- styles: { ...formatting == null ? void 0 : formatting.textStyle, ...run.styles }
13240
- }))
13241
- };
13242
- })
13269
+ blocks: sourceCell.blocks.map(
13270
+ (paragraph) => resolveCachedTableCellParagraph(paragraph, formatting, styles)
13271
+ )
13243
13272
  };
13244
13273
  if (cell.vMerge === "continue") return 0;
13245
13274
  let columnWidthPx;
@@ -15656,24 +15685,13 @@ function buildCanvasTableLayout(options) {
15656
15685
  const cell = {
15657
15686
  ...sourceCell,
15658
15687
  style: formatting.cellStyle,
15659
- blocks: sourceCell.blocks.map((paragraph) => {
15660
- var _a2;
15661
- return {
15662
- ...paragraph,
15663
- style: {
15664
- ...resolveTableParagraphInheritance(
15665
- formatting.paragraphStyle,
15666
- (_a2 = paragraph.style) == null ? void 0 : _a2.styleId,
15667
- state.document.styles
15668
- ),
15669
- ...paragraph.style
15670
- },
15671
- runs: paragraph.runs.map((run) => ({
15672
- ...run,
15673
- styles: { ...formatting.textStyle, ...run.styles }
15674
- }))
15675
- };
15676
- })
15688
+ blocks: sourceCell.blocks.map(
15689
+ (paragraph) => resolveCachedTableCellParagraph(
15690
+ paragraph,
15691
+ formatting,
15692
+ state.document.styles
15693
+ )
15694
+ )
15677
15695
  };
15678
15696
  const effectiveRow = formatting.rowStyle;
15679
15697
  const rowSpan = Math.max(1, cell.rowSpan ?? 1);
@@ -0,0 +1,39 @@
1
+ import { EditorNamedStyle, EditorParagraphNode, EditorParagraphStyle, EditorTextStyle } from '../core/model.js';
2
+
3
+ /**
4
+ * Table-cell paragraph resolution is identity-sensitive.
5
+ *
6
+ * `projectParagraphLayout` caches the (expensive) text-shaping result in a
7
+ * `WeakMap` keyed on the `EditorParagraphNode` *object identity*. Body
8
+ * paragraphs benefit from this directly because immutable edits only replace
9
+ * the edited paragraph's node — every other paragraph keeps its identity and
10
+ * stays cache-hot.
11
+ *
12
+ * Table cells, however, must apply table-level style inheritance (table style,
13
+ * conditional formatting, row/cell formatting) on top of each cell paragraph.
14
+ * Both the pagination measure path and the canvas render path used to rebuild a
15
+ * fresh paragraph/run object via object spread on *every* layout pass, which
16
+ * gave those clones a brand-new identity and therefore *always* missed the
17
+ * paragraph layout cache. In documents with many tables this re-shaped every
18
+ * table-cell paragraph on every keystroke and dominated edit latency.
19
+ *
20
+ * This helper memoizes the resolved clone so the *same* object identity is
21
+ * reused across passes (restoring the WeakMap cache hit), while still
22
+ * invalidating correctly when the source paragraph, the resolved formatting, or
23
+ * the document's named styles change.
24
+ */
25
+ interface TableParagraphFormatting {
26
+ paragraphStyle?: EditorParagraphStyle;
27
+ textStyle?: EditorTextStyle;
28
+ }
29
+ /**
30
+ * Returns a stable, formatting-resolved clone of a table-cell paragraph.
31
+ *
32
+ * The returned object keeps a consistent identity for the same
33
+ * (source paragraph, resolved formatting, styles) combination so that
34
+ * `projectParagraphLayout`'s identity-keyed cache can hit across layout passes.
35
+ * Both the measure path (`tablePagination`) and the render path
36
+ * (`CanvasTableLayout`) must call this so they share the same clone identity.
37
+ */
38
+ export declare function resolveCachedTableCellParagraph(source: EditorParagraphNode, formatting: TableParagraphFormatting | undefined, styles: Record<string, EditorNamedStyle> | undefined): EditorParagraphNode;
39
+ export {};
@@ -1,4 +1,4 @@
1
- import { O, c8, c9, ca, cb, cc, a8, cd, Q, bT, ce, cf, cg, N, ch, bR, ci, cj, ck, cl, cm, c3, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, ad, cz, c2, cA, ca as ca2, cf as cf2, ch as ch2, cq as cq2, cs as cs2, cx as cx2, cB, bV, bQ, cC, cD, cE, bS, cF, cG, bU } from "./index-CtMU1BSO.js";
1
+ import { O, c8, c9, ca, cb, cc, a8, cd, Q, bT, ce, cf, cg, N, ch, bR, ci, cj, ck, cl, cm, c3, cn, co, cp, cq, cr, cs, ct, cu, cv, cw, cx, cy, ad, cz, c2, cA, ca as ca2, cf as cf2, ch as ch2, cq as cq2, cs as cs2, cx as cx2, cB, bV, bQ, cC, cD, cE, bS, cF, cG, bU } from "./index-DdcPkCmB.js";
2
2
  export {
3
3
  O as BalloonShell,
4
4
  c8 as Button,