oasis-editor 0.0.23 → 0.0.25

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 { n as normalizeSelection, g as getParagraphs, c as createEditorParagraphFromRuns, a as getParagraphLength, b as createEditorRun, d as getDocumentSections, e as createEditorStyledRun, f as getParagraphText, h as getActiveZone, i as getActiveSectionIndex, p as positionToParagraphOffset, j as paragraphOffsetToPosition, k as clampPosition, l as findParagraphIndex, m as createCollapsedSelection, o as isSelectionCollapsed, q as createEditorParagraph, r as getBlockParagraphs, s as findParagraphTableLocation, t as buildTableCellLayout, u as createEditorTableCell, v as createEditorTable, w as createEditorTableRow, x as underlineStyleToCssDecorationStyle, y as resolveImageSrc, z as createEditorFootnote, A as createFootnoteReferenceRun, B as renumberFootnotes, C as iterateFootnoteReferenceRuns, D as getFootnoteDisplayMarker, E as createSignal, F as createEffect, G as onCleanup, H as buildCanvasLayoutSnapshot, I as on, J as onMount, K as debounce, L as unwrap, M as getDocumentParagraphs, N as getDocumentSectionsCanonical, O as createEditorDocument, P as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveTextBoxRenderHeight, U as resolveEffectiveParagraphStyle, V as resolveEffectiveTextStyleForParagraph, W as iterateEndnoteReferenceRuns, X as JSZip, Y as imageContentTypeDefaults, Z as imageExtensionFromMime, _ as pxToPt$1, $ as buildSegmentTable, a0 as buildCanvasTableLayout, a1 as resolveFloatingObjectRect, a2 as getTextBoxFloatingGeometry, a3 as getPresetPathSegments, a4 as projectBlocksLayout, a5 as textStyleToFontSizePt, a6 as PX_PER_POINT, a7 as DEFAULT_FONT_SIZE_PX, a8 as isDoubleUnderlineStyle, a9 as isWavyUnderlineStyle, aa as underlineStyleLineWidthPx, ab as underlineStyleDashArray, ac as getListLabelInset, ad as getParagraphBorderInsets, ae as normalizeFamily, af as ROBOTO_FONT_FILES, ag as loadFontAsset, ah as OFFICE_COMPAT_FONT_FAMILIES, ai as buildSfnt, aj as defaultFontDecoderRegistry, ak as SfntFontProgram, al as collectPdfFontFamilies, am as projectDocumentLayout, an as getPageHeaderZoneTop, ao as getPageBodyTop, ap as getPageColumnRects, aq as findFootnoteReference, ar as FOOTNOTE_MARKER_GUTTER_PX, as as resolveImporterForFile, at as createEditorStateFromDocument, au as getDocumentParagraphsCanonical, av as getToolbarStyleState, aw as STANDARD_FONT_SIZES_PT, ax as fontSizePxToPt, ay as probeLocalFontFamilies, az as createInitialEditorState, aA as parseFontSizePtToPx, aB as formatFontSizePt, aC as listKindForTag, aD as isParagraphTag, aE as collectInlineRuns, aF as parseParagraphStyle, aG as t, aH as preciseFontModeVersion, aI as isPreciseFontModeEnabled, aJ as togglePreciseFontMode, aK as nextFontSizePt, aL as previousFontSizePt, aM as fontSizePtToPx, aN as createDefaultToolbarPreset, aO as defaultMenuItems, aP as MenuRegistry, aQ as createToolbarRegistry, aR as Editor, aS as resolveCommandRef, aT as commandRefName, aU as InlineShell, aV as BalloonShell, aW as DocumentShell, aX as createMemo, aY as getCaretRectFromSnapshot, aZ as getParagraphRectFromSnapshot, a_ as createComponent, a$ as CaretOverlay, b0 as Show, b1 as createRenderEffect, b2 as style, b3 as setAttribute, b4 as setStyleProperty, b5 as memo, b6 as template, b7 as insert, b8 as use, b9 as addEventListener, ba as Dialog, bb as delegateEvents, bc as className, bd as For, be as UNDERLINE_STYLE_OPTIONS, bf as Tabs, bg as measureParagraphMinContentWidthPx, bh as getEditableBlocksForZone, bi as findParagraphLocation, bj as createSectionBoundaryParagraph, bk as normalizePageSettings, bl as DEFAULT_EDITOR_PAGE_SETTINGS, bm as markStart, bn as markEnd, bo as getParagraphEntries, bp as getParagraphById, bq as PluginUiHost, br as OasisEditorEditor, bs as perfTimer, bt as OasisBrandMark, bu as setPreciseFontPreference, bv as setWelcomeSeen, bw as enablePreciseFontMode, bx as createOasisEditorClient, by as setLocale, bz as startLongTaskObserver, bA as installGlobalReport, bB as applyStoredPreciseFontPreference, bC as getWelcomeSeen, bD as isLocalFontAccessSupported, bE as EDITOR_SCROLL_PADDING_PX, bF as Toolbar, bG as OasisEditorLoading, bH as createEditorLogger, bI as getCachedCanvasImage, bJ as registerDomStatsSurface } from "./index-Cok7gHa_.js";
4
+ import { n as normalizeSelection, g as getParagraphs, c as createEditorParagraphFromRuns, a as getParagraphLength, b as createEditorRun, d as getDocumentSections, e as createEditorStyledRun, f as getParagraphText, h as getActiveZone, i as getActiveSectionIndex, p as positionToParagraphOffset, j as paragraphOffsetToPosition, k as clampPosition, l as findParagraphIndex, m as createCollapsedSelection, o as isSelectionCollapsed, q as createEditorParagraph, r as getBlockParagraphs, s as findParagraphTableLocation, t as buildTableCellLayout, u as createEditorTableCell, v as createEditorTable, w as createEditorTableRow, x as underlineStyleToCssDecorationStyle, y as resolveImageSrc, z as createEditorFootnote, A as createFootnoteReferenceRun, B as renumberFootnotes, C as iterateFootnoteReferenceRuns, D as getFootnoteDisplayMarker, E as createSignal, F as createEffect, G as onCleanup, H as buildCanvasLayoutSnapshot, I as on, J as onMount, K as debounce, L as unwrap, M as getDocumentParagraphs, N as getDocumentSectionsCanonical, O as createEditorDocument, P as getPageContentWidth, Q as getDocumentPageSettings, R as getTableCellContentWidthForParagraph, S as resolveResizedDimensions, T as resolveTextBoxRenderHeight, U as resolveEffectiveParagraphStyle, V as resolveEffectiveTextStyleForParagraph, W as iterateEndnoteReferenceRuns, X as JSZip, Y as imageContentTypeDefaults, Z as imageExtensionFromMime, _ as pxToPt$1, $ as buildSegmentTable, a0 as buildCanvasTableLayout, a1 as resolveFloatingObjectRect, a2 as getTextBoxFloatingGeometry, a3 as getPresetPathSegments, a4 as projectBlocksLayout, a5 as textStyleToFontSizePt, a6 as PX_PER_POINT, a7 as DEFAULT_FONT_SIZE_PX, a8 as isDoubleUnderlineStyle, a9 as isWavyUnderlineStyle, aa as underlineStyleLineWidthPx, ab as underlineStyleDashArray, ac as getListLabelInset, ad as getParagraphBorderInsets, ae as normalizeFamily, af as ROBOTO_FONT_FILES, ag as loadFontAsset, ah as OFFICE_COMPAT_FONT_FAMILIES, ai as buildSfnt, aj as defaultFontDecoderRegistry, ak as SfntFontProgram, al as collectPdfFontFamilies, am as projectDocumentLayout, an as getPageHeaderZoneTop, ao as getPageBodyTop, ap as getPageColumnRects, aq as findFootnoteReference, ar as FOOTNOTE_MARKER_GUTTER_PX, as as resolveImporterForFile, at as createEditorStateFromDocument, au as getDocumentParagraphsCanonical, av as getToolbarStyleState, aw as STANDARD_FONT_SIZES_PT, ax as fontSizePxToPt, ay as probeLocalFontFamilies, az as createInitialEditorState, aA as parseFontSizePtToPx, aB as formatFontSizePt, aC as listKindForTag, aD as isParagraphTag, aE as collectInlineRuns, aF as parseParagraphStyle, aG as t, aH as preciseFontModeVersion, aI as isPreciseFontModeEnabled, aJ as togglePreciseFontMode, aK as nextFontSizePt, aL as previousFontSizePt, aM as fontSizePtToPx, aN as createDefaultToolbarPreset, aO as defaultMenuItems, aP as MenuRegistry, aQ as createToolbarRegistry, aR as Editor, aS as resolveCommandRef, aT as commandRefName, aU as InlineShell, aV as BalloonShell, aW as DocumentShell, aX as createMemo, aY as getCaretRectFromSnapshot, aZ as getParagraphRectFromSnapshot, a_ as createComponent, a$ as CaretOverlay, b0 as Show, b1 as createRenderEffect, b2 as style, b3 as setAttribute, b4 as setStyleProperty, b5 as memo, b6 as template, b7 as insert, b8 as use, b9 as addEventListener, ba as Dialog, bb as delegateEvents, bc as className, bd as For, be as UNDERLINE_STYLE_OPTIONS, bf as Tabs, bg as measureParagraphMinContentWidthPx, bh as getEditableBlocksForZone, bi as findParagraphLocation, bj as createSectionBoundaryParagraph, bk as normalizePageSettings, bl as DEFAULT_EDITOR_PAGE_SETTINGS, bm as markStart, bn as markEnd, bo as getParagraphEntries, bp as getParagraphById, bq as PluginUiHost, br as OasisEditorEditor, bs as perfTimer, bt as OasisBrandMark, bu as setPreciseFontPreference, bv as setWelcomeSeen, bw as enablePreciseFontMode, bx as createOasisEditorClient, by as setLocale, bz as createEditorZoom, bA as startLongTaskObserver, bB as installGlobalReport, bC as applyStoredPreciseFontPreference, bD as getWelcomeSeen, bE as isLocalFontAccessSupported, bF as EDITOR_SCROLL_PADDING_PX, bG as Toolbar, bH as OasisEditorLoading, bI as createEditorLogger, bJ as getCachedCanvasImage, bK as registerDomStatsSurface } from "./index-Df7Ob0Ek.js";
5
5
  function getSelectedObjectRun(state, predicate) {
6
6
  const normalized = normalizeSelection(state);
7
7
  if (normalized.isCollapsed || normalized.startIndex !== normalized.endIndex || normalized.endParagraphOffset - normalized.startParagraphOffset !== 1) {
@@ -5488,6 +5488,7 @@ function useEditorLayout(props) {
5488
5488
  );
5489
5489
  let syncRequestId = 0;
5490
5490
  const syncInputBox = (_reason = "selection") => {
5491
+ var _a;
5491
5492
  const surface = props.surfaceRef();
5492
5493
  if (!surface) {
5493
5494
  setSelectionBoxes([]);
@@ -5501,7 +5502,8 @@ function useEditorLayout(props) {
5501
5502
  surface,
5502
5503
  state: props.state,
5503
5504
  measuredBlockHeights: measuredBlockHeights(),
5504
- measuredParagraphLayouts: measuredParagraphLayouts()
5505
+ measuredParagraphLayouts: measuredParagraphLayouts(),
5506
+ zoomFactor: (_a = props.zoomFactor) == null ? void 0 : _a.call(props)
5505
5507
  });
5506
5508
  if (!snapshot) {
5507
5509
  setSelectionBoxes([]);
@@ -39822,8 +39824,12 @@ function resolveImageAtPoint(snapshot, pageIndex, zone, clientX, clientY, pierce
39822
39824
  }
39823
39825
  function resolveCanvasSurfaceHitAtPoint(options) {
39824
39826
  var _a, _b, _c;
39825
- const { snapshot, state, clientX, clientY } = options;
39827
+ const { snapshot, state } = options;
39826
39828
  const pierce = options.pierce ?? false;
39829
+ const zoomFactor = options.zoomFactor && options.zoomFactor > 0 ? options.zoomFactor : 1;
39830
+ const surfaceRect = snapshot.surfaceRect;
39831
+ const clientX = surfaceRect.left + (options.clientX - surfaceRect.left) / zoomFactor;
39832
+ const clientY = surfaceRect.top + (options.clientY - surfaceRect.top) / zoomFactor;
39827
39833
  const page = resolveNearestPage(snapshot.pages, clientX, clientY);
39828
39834
  if (!page) {
39829
39835
  return null;
@@ -39982,12 +39988,14 @@ function createCanvasSurfaceHitResolver(deps) {
39982
39988
  const viewportScrollLeft = (currentViewportRef == null ? void 0 : currentViewportRef.scrollLeft) ?? 0;
39983
39989
  const windowWidth = window.innerWidth;
39984
39990
  const windowHeight = window.innerHeight;
39985
- const shouldReuseSnapshot = canvasSnapshotCache && canvasSnapshotCache.documentRef === currentState.document && canvasSnapshotCache.measuredBlockHeightsRef === currentMeasuredBlockHeights && canvasSnapshotCache.measuredParagraphLayoutsRef === currentMeasuredParagraphLayouts && canvasSnapshotCache.surfaceRef === currentSurfaceRef && canvasSnapshotCache.viewportScrollTop === viewportScrollTop && canvasSnapshotCache.viewportScrollLeft === viewportScrollLeft && canvasSnapshotCache.surfaceClientWidth === currentSurfaceRef.clientWidth && canvasSnapshotCache.surfaceClientHeight === currentSurfaceRef.clientHeight && canvasSnapshotCache.windowWidth === windowWidth && canvasSnapshotCache.windowHeight === windowHeight;
39991
+ const zoomFactor = deps.zoomFactor();
39992
+ const shouldReuseSnapshot = canvasSnapshotCache && canvasSnapshotCache.documentRef === currentState.document && canvasSnapshotCache.measuredBlockHeightsRef === currentMeasuredBlockHeights && canvasSnapshotCache.measuredParagraphLayoutsRef === currentMeasuredParagraphLayouts && canvasSnapshotCache.surfaceRef === currentSurfaceRef && canvasSnapshotCache.viewportScrollTop === viewportScrollTop && canvasSnapshotCache.viewportScrollLeft === viewportScrollLeft && canvasSnapshotCache.surfaceClientWidth === currentSurfaceRef.clientWidth && canvasSnapshotCache.surfaceClientHeight === currentSurfaceRef.clientHeight && canvasSnapshotCache.windowWidth === windowWidth && canvasSnapshotCache.windowHeight === windowHeight && canvasSnapshotCache.zoomFactor === zoomFactor;
39986
39993
  const snapshot = shouldReuseSnapshot ? canvasSnapshotCache.snapshot : buildCanvasLayoutSnapshot({
39987
39994
  surface: currentSurfaceRef,
39988
39995
  state: currentState,
39989
39996
  measuredBlockHeights: currentMeasuredBlockHeights,
39990
- measuredParagraphLayouts: currentMeasuredParagraphLayouts
39997
+ measuredParagraphLayouts: currentMeasuredParagraphLayouts,
39998
+ zoomFactor
39991
39999
  });
39992
40000
  if (!shouldReuseSnapshot) {
39993
40001
  canvasSnapshotCache = {
@@ -40001,7 +40009,8 @@ function createCanvasSurfaceHitResolver(deps) {
40001
40009
  surfaceClientWidth: currentSurfaceRef.clientWidth,
40002
40010
  surfaceClientHeight: currentSurfaceRef.clientHeight,
40003
40011
  windowWidth,
40004
- windowHeight
40012
+ windowHeight,
40013
+ zoomFactor
40005
40014
  };
40006
40015
  }
40007
40016
  recordCanvasDebugLayoutSnapshot(snapshot);
@@ -40014,7 +40023,8 @@ function createCanvasSurfaceHitResolver(deps) {
40014
40023
  state: currentState,
40015
40024
  clientX,
40016
40025
  clientY,
40017
- pierce: context.pierce ?? false
40026
+ pierce: context.pierce ?? false,
40027
+ zoomFactor
40018
40028
  });
40019
40029
  recordCanvasDebugHit(hit);
40020
40030
  return hit;
@@ -45736,7 +45746,7 @@ function createEditorNavigation(deps) {
45736
45746
  return moveVerticalSelection(direction, false);
45737
45747
  };
45738
45748
  const moveVerticalSelection = (direction, extend) => {
45739
- var _a, _b, _c, _d, _e;
45749
+ var _a, _b, _c, _d, _e, _f;
45740
45750
  const state = deps.state();
45741
45751
  const paragraphs = getParagraphs(state);
45742
45752
  const currentIndex = paragraphs.findIndex(
@@ -45751,7 +45761,8 @@ function createEditorNavigation(deps) {
45751
45761
  const desiredX = preferredX === null ? deps.caretBox().left + ((surfaceRect == null ? void 0 : surfaceRect.left) ?? 0) : preferredX;
45752
45762
  const snapshot = surfaceRef ? buildCanvasLayoutSnapshot({
45753
45763
  surface: surfaceRef,
45754
- state
45764
+ state,
45765
+ zoomFactor: (_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)
45755
45766
  }) : null;
45756
45767
  let targetIndex = currentIndex + direction;
45757
45768
  const tableLocation = findParagraphTableLocation(
@@ -45793,7 +45804,7 @@ function createEditorNavigation(deps) {
45793
45804
  const distance = desiredX < left ? left - desiredX : desiredX > right ? desiredX - right : 0;
45794
45805
  return { entry, distance };
45795
45806
  }).sort((left, right) => left.distance - right.distance);
45796
- const candidate = (_a = scoredCandidates[0]) == null ? void 0 : _a.entry;
45807
+ const candidate = (_b = scoredCandidates[0]) == null ? void 0 : _b.entry;
45797
45808
  if (!candidate) {
45798
45809
  continue;
45799
45810
  }
@@ -45803,14 +45814,14 @@ function createEditorNavigation(deps) {
45803
45814
  }
45804
45815
  } else {
45805
45816
  if (direction < 0) {
45806
- const firstParaId = (_d = (_c = (_b = block.rows[0]) == null ? void 0 : _b.cells[0]) == null ? void 0 : _c.blocks[0]) == null ? void 0 : _d.id;
45817
+ const firstParaId = (_e = (_d = (_c = block.rows[0]) == null ? void 0 : _c.cells[0]) == null ? void 0 : _d.blocks[0]) == null ? void 0 : _e.id;
45807
45818
  if (firstParaId) {
45808
45819
  targetIndex = paragraphs.findIndex((p) => p.id === firstParaId) - 1;
45809
45820
  }
45810
45821
  } else {
45811
45822
  const lastRow = block.rows[block.rows.length - 1];
45812
45823
  const lastCell = lastRow == null ? void 0 : lastRow.cells[lastRow.cells.length - 1];
45813
- const lastParaId = (_e = lastCell == null ? void 0 : lastCell.blocks[lastCell.blocks.length - 1]) == null ? void 0 : _e.id;
45824
+ const lastParaId = (_f = lastCell == null ? void 0 : lastCell.blocks[lastCell.blocks.length - 1]) == null ? void 0 : _f.id;
45814
45825
  if (lastParaId) {
45815
45826
  targetIndex = paragraphs.findIndex((p) => p.id === lastParaId) + 1;
45816
45827
  }
@@ -45959,7 +45970,8 @@ function useEditorInteractionWiring(ctx) {
45959
45970
  setPreferredColumnX: ctx.setPreferredColumnX,
45960
45971
  clearPreferredColumn: ctx.clearPreferredColumn,
45961
45972
  resetTransactionGrouping: ctx.resetTransactionGrouping,
45962
- focusInput: ctx.focusInput
45973
+ focusInput: ctx.focusInput,
45974
+ zoomFactor: ctx.zoomFactor
45963
45975
  });
45964
45976
  const { handleCopy, handleCut, handlePaste, handleDrop } = createEditorClipboardController({
45965
45977
  state,
@@ -45992,7 +46004,10 @@ function buildEditorViewProps(ctx) {
45992
46004
  const layout = {
45993
46005
  viewportHeight: ctx.viewportHeight,
45994
46006
  class: ctx.className,
45995
- style: ctx.style
46007
+ style: ctx.style,
46008
+ zoomPercent: ctx.zoomPercent,
46009
+ setZoomPercent: ctx.setZoomPercent,
46010
+ zoomFactor: ctx.zoomFactor
45996
46011
  };
45997
46012
  const overlays = {
45998
46013
  selectionBoxes: ctx.selectionBoxes,
@@ -46397,6 +46412,7 @@ function OasisEditorApp(props = {}) {
46397
46412
  const focusInput = focusController.focusInput;
46398
46413
  const focusInputAfterPointerSelection = focusController.focusInputAfterPointerSelection;
46399
46414
  const [initialLoading, setInitialLoading] = createSignal(ui().loading !== false);
46415
+ const zoom = createEditorZoom();
46400
46416
  const {
46401
46417
  linkDialog,
46402
46418
  setLinkDialog,
@@ -46456,7 +46472,8 @@ function OasisEditorApp(props = {}) {
46456
46472
  state,
46457
46473
  surfaceRef,
46458
46474
  viewportRef,
46459
- isImporting: isImportInProgress
46475
+ isImporting: isImportInProgress,
46476
+ zoomFactor: zoom.zoomFactor
46460
46477
  });
46461
46478
  const {
46462
46479
  status: persistenceStatus
@@ -46579,7 +46596,8 @@ function OasisEditorApp(props = {}) {
46579
46596
  surfaceRef: () => surfaceRef() ?? null,
46580
46597
  viewportRef: () => viewportRef() ?? null,
46581
46598
  measuredBlockHeights,
46582
- measuredParagraphLayouts
46599
+ measuredParagraphLayouts,
46600
+ zoomFactor: zoom.zoomFactor
46583
46601
  });
46584
46602
  const resolveSurfaceHitAtPoint = canvasHitResolver.resolveSurfaceHitAtPoint;
46585
46603
  const fr = useEditorFindReplace({
@@ -46664,6 +46682,7 @@ function OasisEditorApp(props = {}) {
46664
46682
  caretBox: () => caretBox(),
46665
46683
  preferredColumnX: () => preferredColumnX(),
46666
46684
  setPreferredColumnX,
46685
+ zoomFactor: zoom.zoomFactor,
46667
46686
  resolveSurfaceHitAtPoint,
46668
46687
  resolvePositionAtSurfacePoint,
46669
46688
  tableOps,
@@ -46960,6 +46979,9 @@ function OasisEditorApp(props = {}) {
46960
46979
  viewportHeight: ui().viewportHeight,
46961
46980
  className: ui().class,
46962
46981
  style: ui().style,
46982
+ zoomPercent: zoom.zoomPercent,
46983
+ setZoomPercent: zoom.setZoomPercent,
46984
+ zoomFactor: zoom.zoomFactor,
46963
46985
  selectionBoxes,
46964
46986
  commentHighlights,
46965
46987
  selectedImageBox,
@@ -7,6 +7,8 @@ interface UseEditorLayoutProps {
7
7
  surfaceRef: () => HTMLDivElement | undefined;
8
8
  viewportRef: () => HTMLDivElement | undefined;
9
9
  isImporting?: () => boolean;
10
+ /** Current visual zoom factor; the snapshot stays zoom-invariant. */
11
+ zoomFactor?: () => number;
10
12
  }
11
13
  type LayoutSyncReason = "selection" | "scroll" | "content-change" | "resize" | "import";
12
14
  export interface LayoutInvalidation {
@@ -12,6 +12,12 @@ export interface UseEditorNavigationProps {
12
12
  clearPreferredColumn: () => void;
13
13
  resetTransactionGrouping: () => void;
14
14
  focusInput: () => void;
15
+ /**
16
+ * Current visual zoom factor. `desiredX` and the snapshot slots both live in
17
+ * "screen-anchored local" space, so the comparison stays correct once the
18
+ * snapshot is built zoom-aware.
19
+ */
20
+ zoomFactor?: () => number;
15
21
  }
16
22
  export declare function createEditorNavigation(deps: UseEditorNavigationProps): {
17
23
  moveSelectionToParagraphBoundary: (boundary: "start" | "end", extend: boolean) => boolean;