oasis-editor 0.0.186 → 0.0.188

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, key2, value) => key2 in obj ? __defProp(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
3
3
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, 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, q as createSignal, r as cloneEditorState, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, v as probeLocalFontFamilies, w as createEditorParagraphFromRuns, x as isInlineObjectRun, y as stylesEqual, z as cloneStyle, A as createEditorStyledRun, B as cloneParagraphList, C as cloneParagraph, D as getParagraphLength, G as cloneRun, H as getActiveZone, I as getActiveSectionIndex, J as getParagraphs, K as normalizeSelection, L as positionToParagraphOffset, M as cloneParagraphs, N as paragraphOffsetToPosition, O as findParagraphIndex, P as createCollapsedSelection, Q as isSelectionCollapsed, R as MATH_OBJECT_REPLACEMENT, T as setValueStyle, U as setBooleanStyle, V as parseFontSizePtToPx, W as formatFontSizePt, X as setParagraphStyleValue, Y as createEditorParagraph, Z as cloneBlocks, _ as resolveDefaultParagraphStyleId, $ as findParagraphTablePathLocation, a0 as findParagraphLocation, a1 as resolveTablePath, a2 as buildTableCellLayout, a3 as PT_PER_PX, a4 as createEditorTableCell, a5 as createEditorTableRow, a6 as createEditorTable, a7 as clampPosition, a8 as PX_PER_POINT, a9 as underlineStyleToCssDecorationStyle, aa as resolveImageSrc, ab as listKindForTag, ac as isParagraphTag, ad as collectInlineRuns, ae as parseParagraphStyle, af as getRunImage, ag as InlineShell, ah as BalloonShell, ai as DocumentShell, aj as findParagraphTableLocation, ak as createMemo, al as getCaretRectFromSnapshot, am as getParagraphRectFromSnapshot, an as createComponent, ao as CaretOverlay, ap as Show, aq as createRenderEffect, ar as style, as as setStyleProperty, at as setAttribute, au as memo, av as template, aw as Button, ax as useI18n, ay as createEffect, az as TextField, aA as Dialog, aB as insert, aC as className, aD as Grid, aE as SelectField, aF as StatusText, aG as ColorField, aH as UNDERLINE_STYLE_OPTIONS, aI as Stack, aJ as For, aK as ToggleChip, aL as FormField, aM as Checkbox, aN as FieldGroup, aO as Tabs, aP as NumberField, aQ as parseNumber, aR as createStore, aS as reconcile, aT as RadioGroup, aU as Radio$1, aV as TextAreaField, aW as COMMON_SYMBOLS, aX as getRecentSymbols, aY as SYMBOL_CATEGORIES, aZ as rememberSymbol, a_ as delegateEvents, a$ as EMPTY_EDITOR_MATH_EXPRESSION, b0 as serializeLinearMath, b1 as parseLinearMath, b2 as Text, b3 as SurfaceButton, b4 as onMount, b5 as onCleanup, b6 as CheckIcon, b7 as use, b8 as PluginUiHost, b9 as OasisEditorEditor, ba as OasisBrandMark, bb as setPreciseFontPreference, bc as setWelcomeSeen, bd as enablePreciseFontMode, be as WORD_NS$6, bf as XMLSerializer, bg as DOMParser, bh as WORD14_NS, bi as mergeNestedExtensionMarkup, bj as resolveOpcRelationships, bk as parseOpcRelationships, bl as JSZip, bm as normalizeOpcPartPath, bn as OPC_CONTENT_TYPES_PATH, bo as getOpcRelationshipOwnerPath, bp as serializeOpcRelationships, bq as OPC_ROOT_RELATIONSHIPS_PATH, br as hashDocxPartBytes, bs as parseOpcContentTypes, bt as serializeOpcContentTypes, bu as mergeParagraphPropertiesXmlSource, bv as setEditorRunOoxmlSource, bw as mergeRunOoxmlSourceIntoGeneratedXml, bx as mergeTableCellPropertiesXmlSource, by as mergeTableRowPropertiesXmlSource, bz as mergeTablePropertiesXmlSource, bA as getDocumentSectionsCanonical, bB as exportEditorDocumentToDocxBlob, bC as exportEditorDocumentToDocx, bD as pxToPt$1, bE as resolveFloatingObjectRect, bF as getTextBoxFloatingGeometry, bG as getPresetPathSegments, bH as buildListLabels, bI as assertNever, bJ as lineDashPatternPt, bK as DEFAULT_FONT_SIZE_PX, bL as resolveGradientAxis, bM as isDoubleUnderlineStyle, bN as isWavyUnderlineStyle, bO as underlineStyleLineWidthPx, bP as WAVY_UNDERLINE_WAVELENGTH_PX, bQ as WAVY_UNDERLINE_AMPLITUDE_PX, bR as DOUBLE_UNDERLINE_OFFSET_PX, bS as underlineStyleDashArray, bT as resolveEffectiveParagraphStyle, bU as EMPHASIS_GLYPH, bV as parseHexColorToRgb255, bW as rgb255ToHex, bX as getImageFloatingGeometry, bY as resolveEffectiveTextStyleForParagraph, bZ as textStyleToFontSizePt, b_ as mathDisplayText, b$ as TEXT_BASELINE_RATIO, c0 as resolveTextAlignmentBaselineOffset, c1 as resolveRenderedTextChar, c2 as resolveOpenTypeFeatureTags, c3 as isLowercaseSmallCapsChar, c4 as resolveDecorationLineY, c5 as DOUBLE_STRIKE_OFFSET_PX, c6 as resolveListLabel, c7 as getListLabelInset, c8 as getAlignedListLabelInset, c9 as getParagraphBorderInsets, ca as buildSegmentTable, cb as buildCanvasTableLayout, cc as resolveCanvasTableWidth, cd as resolveFloatingTableRect, ce as paragraphBetweenBorderMatches, cf as normalizeFamily, cg as ROBOTO_FONT_FILES, ch as loadFontAsset, ci as getRemotePdfFontFaces, cj as OFFICE_COMPAT_FONT_FAMILIES, ck as BinaryReader, cl as buildSfnt, cm as defaultFontDecoderRegistry, cn as SfntFontProgram, co as zlibSync, cp as renumberImageCaptionsInDocument, cq as collectPdfFontFamilies, cr as outlineFrom, cs as getPageHeaderZoneTop, ct as getPageColumnRects, cu as findFootnoteReference, cv as resolveImporterForFile, cw as roundTo, cx as getDocumentParagraphsCanonical, cy as getDocumentParagraphs, cz as getImageCaptionText, cA as isImageCaptionParagraph, cB as updateImageCaptionParagraph, cC as createImageCaptionParagraph, cD as renumberImageCaptionParagraphs, cE as getCaptionSelectionOffset, cF as PX_PER_CM, cG as getDocumentPageSettings, cH as getTableCellContentWidthForParagraph, cI as layoutMetricsEpoch, cJ as bumpLayoutMetricsEpoch, cK as createCanvasLayoutSnapshotProvider, cL as on, cM as debounce, cN as unwrap, cO as cloneSection, cP as perfTimer, cQ as prepareDocumentFonts, cR as getRunTextBox, cS as EMU_PER_PX, cT as createEditorDocument, cU as cloneBlock, cV as resolveResizedDimensions, cW as axisSignForDirection, cX as clamp$1, cY as MIN_RESIZE_SIZE_PX, cZ as resolveTextBoxRenderHeight, c_ as getToolbarStyleState, c$ as VERTICAL_HIT_WEIGHT, d0 as getCachedCanvasImage, d1 as measureParagraphMinContentWidthPx, d2 as createSectionBoundaryParagraph, d3 as normalizePageSettings, d4 as DEFAULT_EDITOR_PAGE_SETTINGS, d5 as markStart, d6 as markEnd, d7 as getParagraphEntries, d8 as getParagraphById, d9 as createEditorFootnote, da as createFootnoteReferenceRun, db as renumberFootnotes, dc as iterateFootnoteReferenceRuns, dd as preciseFontModeVersion, de as isPreciseFontModeEnabled, df as getRunFieldChar, dg as getRunFieldInstruction, dh as getHeadingLevel, di as createEditorRun, dj as TWIPS_PER_INCH, dk as PX_PER_INCH, dl as togglePreciseFontMode, dm as nextFontSizePt, dn as previousFontSizePt, dp as fontSizePtToPx, dq as resolveNamedTextStyle, dr as resolveNamedTableStyle, ds as resolveEffectiveTableStyle, dt as createDefaultToolbarPreset, du as MenuRegistry, dv as createToolbarRegistry, dw as Editor, dx as resolveCommandRef, dy as commandRefName, dz as createOasisEditorClient, dA as createEditorZoom, dB as startLongTaskObserver, dC as installGlobalReport, dD as applyStoredPreciseFontPreference, dE as getWelcomeSeen, dF as isLocalFontAccessSupported, dG as EDITOR_SCROLL_PADDING_PX, dH as Toolbar, dI as OasisEditorLoading, dJ as I18nProvider, dK as createTranslator, dL as registerDomStatsSurface, dM as createEditorLogger } from "./index-DazwB_Pd.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, q as createSignal, r as cloneEditorState, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, v as probeLocalFontFamilies, w as createEditorParagraphFromRuns, x as isInlineObjectRun, y as stylesEqual, z as cloneStyle, A as createEditorStyledRun, B as cloneParagraphList, C as cloneParagraph, D as getParagraphLength, G as cloneRun, H as getActiveZone, I as getActiveSectionIndex, J as getParagraphs, K as normalizeSelection, L as positionToParagraphOffset, M as cloneParagraphs, N as paragraphOffsetToPosition, O as findParagraphIndex, P as createCollapsedSelection, Q as isSelectionCollapsed, R as MATH_OBJECT_REPLACEMENT, T as setValueStyle, U as setBooleanStyle, V as parseFontSizePtToPx, W as formatFontSizePt, X as setParagraphStyleValue, Y as createEditorParagraph, Z as cloneBlocks, _ as resolveDefaultParagraphStyleId, $ as findParagraphTablePathLocation, a0 as findParagraphLocation, a1 as resolveTablePath, a2 as buildTableCellLayout, a3 as PT_PER_PX, a4 as createEditorTableCell, a5 as createEditorTableRow, a6 as createEditorTable, a7 as clampPosition, a8 as PX_PER_POINT, a9 as underlineStyleToCssDecorationStyle, aa as resolveImageSrc, ab as listKindForTag, ac as isParagraphTag, ad as collectInlineRuns, ae as parseParagraphStyle, af as getRunImage, ag as InlineShell, ah as BalloonShell, ai as DocumentShell, aj as findParagraphTableLocation, ak as createMemo, al as getCaretRectFromSnapshot, am as getParagraphRectFromSnapshot, an as createComponent, ao as CaretOverlay, ap as Show, aq as createRenderEffect, ar as style, as as setStyleProperty, at as setAttribute, au as memo, av as template, aw as Button, ax as useI18n, ay as createEffect, az as TextField, aA as Dialog, aB as insert, aC as className, aD as Grid, aE as SelectField, aF as StatusText, aG as ColorField, aH as UNDERLINE_STYLE_OPTIONS, aI as Stack, aJ as For, aK as ToggleChip, aL as FormField, aM as Checkbox, aN as FieldGroup, aO as Tabs, aP as NumberField, aQ as parseNumber, aR as createStore, aS as reconcile, aT as RadioGroup, aU as Radio$1, aV as TextAreaField, aW as COMMON_SYMBOLS, aX as getRecentSymbols, aY as SYMBOL_CATEGORIES, aZ as rememberSymbol, a_ as delegateEvents, a$ as EMPTY_EDITOR_MATH_EXPRESSION, b0 as serializeLinearMath, b1 as parseLinearMath, b2 as Text, b3 as SurfaceButton, b4 as onMount, b5 as onCleanup, b6 as CheckIcon, b7 as use, b8 as PluginUiHost, b9 as OasisEditorEditor, ba as OasisBrandMark, bb as setPreciseFontPreference, bc as setWelcomeSeen, bd as enablePreciseFontMode, be as WORD_NS$6, bf as XMLSerializer, bg as DOMParser, bh as WORD14_NS, bi as mergeNestedExtensionMarkup, bj as resolveOpcRelationships, bk as parseOpcRelationships, bl as JSZip, bm as normalizeOpcPartPath, bn as OPC_CONTENT_TYPES_PATH, bo as getOpcRelationshipOwnerPath, bp as serializeOpcRelationships, bq as OPC_ROOT_RELATIONSHIPS_PATH, br as hashDocxPartBytes, bs as parseOpcContentTypes, bt as serializeOpcContentTypes, bu as mergeParagraphPropertiesXmlSource, bv as setEditorRunOoxmlSource, bw as mergeRunOoxmlSourceIntoGeneratedXml, bx as mergeTableCellPropertiesXmlSource, by as mergeTableRowPropertiesXmlSource, bz as mergeTablePropertiesXmlSource, bA as getDocumentSectionsCanonical, bB as exportEditorDocumentToDocxBlob, bC as exportEditorDocumentToDocx, bD as pxToPt$1, bE as resolveFloatingObjectRect, bF as getTextBoxFloatingGeometry, bG as getPresetPathSegments, bH as buildListLabels, bI as assertNever, bJ as lineDashPatternPt, bK as DEFAULT_FONT_SIZE_PX, bL as resolveGradientAxis, bM as isDoubleUnderlineStyle, bN as isWavyUnderlineStyle, bO as underlineStyleLineWidthPx, bP as WAVY_UNDERLINE_WAVELENGTH_PX, bQ as WAVY_UNDERLINE_AMPLITUDE_PX, bR as DOUBLE_UNDERLINE_OFFSET_PX, bS as underlineStyleDashArray, bT as resolveEffectiveParagraphStyle, bU as EMPHASIS_GLYPH, bV as parseHexColorToRgb255, bW as rgb255ToHex, bX as getImageFloatingGeometry, bY as resolveEffectiveTextStyleForParagraph, bZ as textStyleToFontSizePt, b_ as mathDisplayText, b$ as TEXT_BASELINE_RATIO, c0 as resolveTextAlignmentBaselineOffset, c1 as resolveRenderedTextChar, c2 as resolveOpenTypeFeatureTags, c3 as isLowercaseSmallCapsChar, c4 as resolveDecorationLineY, c5 as DOUBLE_STRIKE_OFFSET_PX, c6 as resolveListLabel, c7 as getListLabelInset, c8 as getAlignedListLabelInset, c9 as getParagraphBorderInsets, ca as buildSegmentTable, cb as buildCanvasTableLayout, cc as resolveCanvasTableWidth, cd as resolveFloatingTableRect, ce as paragraphBetweenBorderMatches, cf as normalizeFamily, cg as ROBOTO_FONT_FILES, ch as loadFontAsset, ci as getRemotePdfFontFaces, cj as OFFICE_COMPAT_FONT_FAMILIES, ck as BinaryReader, cl as buildSfnt, cm as defaultFontDecoderRegistry, cn as SfntFontProgram, co as zlibSync, cp as renumberImageCaptionsInDocument, cq as collectPdfFontFamilies, cr as outlineFrom, cs as getPageHeaderZoneTop, ct as getPageColumnRects, cu as findFootnoteReference, cv as resolveImporterForFile, cw as roundTo, cx as getDocumentParagraphsCanonical, cy as getDocumentParagraphs, cz as getImageCaptionText, cA as isImageCaptionParagraph, cB as updateImageCaptionParagraph, cC as createImageCaptionParagraph, cD as renumberImageCaptionParagraphs, cE as getCaptionSelectionOffset, cF as PX_PER_CM, cG as getDocumentPageSettings, cH as getTableCellContentWidthForParagraph, cI as layoutMetricsEpoch, cJ as bumpLayoutMetricsEpoch, cK as createCanvasLayoutSnapshotProvider, cL as on, cM as debounce, cN as unwrap, cO as cloneSection, cP as perfTimer, cQ as prepareDocumentFonts, cR as getRunTextBox, cS as EMU_PER_PX, cT as createEditorDocument, cU as cloneBlock, cV as resolveResizedDimensions, cW as axisSignForDirection, cX as clamp$1, cY as MIN_RESIZE_SIZE_PX, cZ as resolveTextBoxRenderHeight, c_ as getToolbarStyleState, c$ as VERTICAL_HIT_WEIGHT, d0 as getCachedCanvasImage, d1 as measureParagraphMinContentWidthPx, d2 as createSectionBoundaryParagraph, d3 as normalizePageSettings, d4 as DEFAULT_EDITOR_PAGE_SETTINGS, d5 as markStart, d6 as markEnd, d7 as getParagraphEntries, d8 as getParagraphById, d9 as createEditorFootnote, da as createFootnoteReferenceRun, db as renumberFootnotes, dc as iterateFootnoteReferenceRuns, dd as preciseFontModeVersion, de as isPreciseFontModeEnabled, df as getRunFieldChar, dg as getRunFieldInstruction, dh as getHeadingLevel, di as createEditorRun, dj as TWIPS_PER_INCH, dk as PX_PER_INCH, dl as togglePreciseFontMode, dm as nextFontSizePt, dn as previousFontSizePt, dp as fontSizePtToPx, dq as resolveNamedTextStyle, dr as resolveNamedTableStyle, ds as resolveEffectiveTableStyle, dt as createDefaultToolbarPreset, du as MenuRegistry, dv as createToolbarRegistry, dw as Editor, dx as resolveCommandRef, dy as commandRefName, dz as createOasisEditorClient, dA as createEditorZoom, dB as startLongTaskObserver, dC as installGlobalReport, dD as applyStoredPreciseFontPreference, dE as getWelcomeSeen, dF as isLocalFontAccessSupported, dG as EDITOR_SCROLL_PADDING_PX, dH as Toolbar, dI as OasisEditorLoading, dJ as I18nProvider, dK as createTranslator, dL as registerDomStatsSurface, dM as createEditorLogger } from "./index-B5djGyiB.js";
5
5
  function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
6
6
  const {
7
7
  pageIndex,
@@ -26817,11 +26817,20 @@ function createEditorFocusController() {
26817
26817
  });
26818
26818
  });
26819
26819
  };
26820
+ const focusInputSync = () => {
26821
+ setFocused(true);
26822
+ textareaRef == null ? void 0 : textareaRef.focus({ preventScroll: true });
26823
+ if (textareaRef) {
26824
+ textareaRef.selectionStart = textareaRef.value.length;
26825
+ textareaRef.selectionEnd = textareaRef.value.length;
26826
+ }
26827
+ };
26820
26828
  return {
26821
26829
  focused,
26822
26830
  setFocused,
26823
26831
  focusInput,
26824
26832
  focusInputAfterPointerSelection,
26833
+ focusInputSync,
26825
26834
  get viewportRef() {
26826
26835
  return viewportRef;
26827
26836
  },
@@ -36490,21 +36499,21 @@ function buildEditorViewProps(ctx) {
36490
36499
  const surfaceHandlers = {
36491
36500
  onDragOver: (event) => event.preventDefault(),
36492
36501
  onDrop: surface.handleDrop,
36493
- onEditorMouseDown: surface.onEditorMouseDown,
36494
- onSurfaceMouseDown: surface.surfaceEvents.handleSurfaceMouseDown,
36502
+ onEditorPointerDown: surface.onEditorPointerDown,
36503
+ onSurfacePointerDown: surface.surfaceEvents.handleSurfacePointerDown,
36495
36504
  onSurfaceClick: surface.surfaceEvents.handleSurfaceClick,
36496
- onSurfaceMouseMove: surface.tableResize.handleMouseMove,
36505
+ onSurfacePointerMove: surface.tableResize.handlePointerMove,
36497
36506
  onSurfaceDblClick: surface.surfaceEvents.handleSurfaceDblClick,
36498
- onParagraphMouseDown: surface.surfaceEvents.handleParagraphMouseDown,
36499
- onImageMouseDown: surface.handleImageMouseDown,
36500
- onImageResizeHandleMouseDown: surface.handleImageResizeHandleMouseDown,
36501
- onTextBoxResizeHandleMouseDown: surface.handleTextBoxResizeHandleMouseDown,
36502
- onImageRotateHandleMouseDown: surface.handleImageRotateHandleMouseDown,
36503
- onImageCropHandleMouseDown: surface.handleImageCropHandleMouseDown,
36504
- onImageCropBodyMouseDown: surface.handleImageCropBodyMouseDown,
36505
- onTextBoxRotateHandleMouseDown: surface.handleTextBoxRotateHandleMouseDown,
36506
- onTableDragHandleMouseDown: surface.tableDrag.handleMouseDown,
36507
- onTableCornerResizeHandleMouseDown: surface.tableCornerResize.handleMouseDown,
36507
+ onParagraphPointerDown: surface.surfaceEvents.handleParagraphPointerDown,
36508
+ onImagePointerDown: surface.handleImagePointerDown,
36509
+ onImageResizeHandlePointerDown: surface.handleImageResizeHandlePointerDown,
36510
+ onTextBoxResizeHandlePointerDown: surface.handleTextBoxResizeHandlePointerDown,
36511
+ onImageRotateHandlePointerDown: surface.handleImageRotateHandlePointerDown,
36512
+ onImageCropHandlePointerDown: surface.handleImageCropHandlePointerDown,
36513
+ onImageCropBodyPointerDown: surface.handleImageCropBodyPointerDown,
36514
+ onTextBoxRotateHandlePointerDown: surface.handleTextBoxRotateHandlePointerDown,
36515
+ onTableDragHandlePointerDown: surface.tableDrag.handlePointerDown,
36516
+ onTableCornerResizeHandlePointerDown: surface.tableCornerResize.handlePointerDown,
36508
36517
  onRevisionMouseEnter: surface.revisionController.handleRevisionMouseEnter,
36509
36518
  onRevisionMouseLeave: surface.revisionController.handleRevisionMouseLeave,
36510
36519
  onEditorContextMenu: (event) => surface.handleEditorContextMenu(event)
@@ -40551,7 +40560,7 @@ function parsePrefixMappings(value) {
40551
40560
  return result;
40552
40561
  }
40553
40562
  function parseStep(step) {
40554
- const match = /^(([^:\[]+):)?([^\[]+?)(?:\[(\d+)\])?$/.exec(step);
40563
+ const match = /^(([^:[]+):)?([^[]+?)(?:\[(\d+)\])?$/.exec(step);
40555
40564
  if (!match) return null;
40556
40565
  const index = match[4] ? Number.parseInt(match[4], 10) : 1;
40557
40566
  if (!Number.isFinite(index) || index < 1) return null;
@@ -49524,6 +49533,20 @@ function createEditorTableOperationsImpl(deps) {
49524
49533
  insertTableCommand
49525
49534
  };
49526
49535
  }
49536
+ function createPointerGesture() {
49537
+ let pointerId = null;
49538
+ return {
49539
+ claim: (event) => {
49540
+ pointerId = event.pointerId ?? null;
49541
+ },
49542
+ // An unclaimed gesture owns everything: sessions driven by synthetic events
49543
+ // that carry no pointerId must keep working.
49544
+ owns: (event) => pointerId === null || event.pointerId === pointerId,
49545
+ release: () => {
49546
+ pointerId = null;
49547
+ }
49548
+ };
49549
+ }
49527
49550
  function createResizeSession(adapter, deps) {
49528
49551
  let active = null;
49529
49552
  const selectionForObject = (state, paragraphId, paragraphOffset) => {
@@ -49545,8 +49568,10 @@ function createResizeSession(adapter, deps) {
49545
49568
  focus: { ...selection.focus }
49546
49569
  }
49547
49570
  });
49571
+ const gesture = createPointerGesture();
49548
49572
  const handleMouseMove = (event) => {
49549
49573
  var _a;
49574
+ if (!gesture.owns(event)) return;
49550
49575
  const resize = active;
49551
49576
  if (!resize) {
49552
49577
  return;
@@ -49597,8 +49622,10 @@ function createResizeSession(adapter, deps) {
49597
49622
  };
49598
49623
  const stop = () => {
49599
49624
  active = null;
49600
- window.removeEventListener("mousemove", handleMouseMove);
49601
- window.removeEventListener("mouseup", handleMouseUp);
49625
+ gesture.release();
49626
+ window.removeEventListener("pointermove", handleMouseMove);
49627
+ window.removeEventListener("pointerup", handleMouseUp);
49628
+ window.removeEventListener("pointercancel", handleMouseUp);
49602
49629
  };
49603
49630
  const start = (paragraphId, paragraphOffset, handleDirection, event, initialState) => {
49604
49631
  const selection = selectionForObject(
@@ -49626,8 +49653,10 @@ function createResizeSession(adapter, deps) {
49626
49653
  aspectRatio: selected.width / selected.height,
49627
49654
  initialState: deps.cloneState(initialState)
49628
49655
  };
49629
- window.addEventListener("mousemove", handleMouseMove);
49630
- window.addEventListener("mouseup", handleMouseUp);
49656
+ gesture.claim(event);
49657
+ window.addEventListener("pointermove", handleMouseMove);
49658
+ window.addEventListener("pointerup", handleMouseUp);
49659
+ window.addEventListener("pointercancel", handleMouseUp);
49631
49660
  };
49632
49661
  return { start, stop };
49633
49662
  }
@@ -49653,7 +49682,9 @@ function createRotateSession(adapter, deps) {
49653
49682
  focus: { ...selection.focus }
49654
49683
  }
49655
49684
  });
49685
+ const gesture = createPointerGesture();
49656
49686
  const handleMouseMove = (event) => {
49687
+ if (!gesture.owns(event)) return;
49657
49688
  const rotate = active;
49658
49689
  if (!rotate) {
49659
49690
  return;
@@ -49696,8 +49727,10 @@ function createRotateSession(adapter, deps) {
49696
49727
  };
49697
49728
  const stop = () => {
49698
49729
  active = null;
49699
- window.removeEventListener("mousemove", handleMouseMove);
49700
- window.removeEventListener("mouseup", handleMouseUp);
49730
+ gesture.release();
49731
+ window.removeEventListener("pointermove", handleMouseMove);
49732
+ window.removeEventListener("pointerup", handleMouseUp);
49733
+ window.removeEventListener("pointercancel", handleMouseUp);
49701
49734
  };
49702
49735
  const start = (paragraphId, paragraphOffset, event, initialState) => {
49703
49736
  const overlay = event.currentTarget.closest(
@@ -49714,8 +49747,10 @@ function createRotateSession(adapter, deps) {
49714
49747
  centerY: rect.top + rect.height / 2,
49715
49748
  initialState: deps.cloneState(initialState)
49716
49749
  };
49717
- window.addEventListener("mousemove", handleMouseMove);
49718
- window.addEventListener("mouseup", handleMouseUp);
49750
+ gesture.claim(event);
49751
+ window.addEventListener("pointermove", handleMouseMove);
49752
+ window.addEventListener("pointerup", handleMouseUp);
49753
+ window.addEventListener("pointercancel", handleMouseUp);
49719
49754
  };
49720
49755
  return { start, stop };
49721
49756
  }
@@ -49827,8 +49862,10 @@ function createCropSession(deps) {
49827
49862
  focus: { ...selection.focus }
49828
49863
  }
49829
49864
  });
49865
+ const gesture = createPointerGesture();
49830
49866
  const handleMouseMove = (event) => {
49831
49867
  var _a;
49868
+ if (!gesture.owns(event)) return;
49832
49869
  const crop = active;
49833
49870
  if (!crop) {
49834
49871
  return;
@@ -49871,8 +49908,10 @@ function createCropSession(deps) {
49871
49908
  };
49872
49909
  const stop = () => {
49873
49910
  active = null;
49874
- window.removeEventListener("mousemove", handleMouseMove);
49875
- window.removeEventListener("mouseup", handleMouseUp);
49911
+ gesture.release();
49912
+ window.removeEventListener("pointermove", handleMouseMove);
49913
+ window.removeEventListener("pointerup", handleMouseUp);
49914
+ window.removeEventListener("pointercancel", handleMouseUp);
49876
49915
  };
49877
49916
  const begin = (paragraphId, paragraphOffset, handleDirection, event, initialState, mode) => {
49878
49917
  const selection = selectionForObject(
@@ -49903,8 +49942,10 @@ function createCropSession(deps) {
49903
49942
  initialState: deps.cloneState(initialState),
49904
49943
  mode
49905
49944
  };
49906
- window.addEventListener("mousemove", handleMouseMove);
49907
- window.addEventListener("mouseup", handleMouseUp);
49945
+ gesture.claim(event);
49946
+ window.addEventListener("pointermove", handleMouseMove);
49947
+ window.addEventListener("pointerup", handleMouseUp);
49948
+ window.addEventListener("pointercancel", handleMouseUp);
49908
49949
  };
49909
49950
  const start = (paragraphId, paragraphOffset, handleDirection, event, initialState) => begin(
49910
49951
  paragraphId,
@@ -49988,6 +50029,7 @@ function createEditorImageOperationsImpl(deps) {
49988
50029
  }
49989
50030
  document.body.style.cursor = "";
49990
50031
  };
50032
+ const gesture = createPointerGesture();
49991
50033
  const clearImagePointerTracking = () => {
49992
50034
  hideImageDragCursor();
49993
50035
  pendingImagePointer = null;
@@ -49995,8 +50037,10 @@ function createEditorImageOperationsImpl(deps) {
49995
50037
  setDragging(false);
49996
50038
  setDraggedImageInfo(null);
49997
50039
  setDropTargetPos(null);
49998
- window.removeEventListener("mousemove", handleImageDragMouseMove);
49999
- window.removeEventListener("mouseup", handleImageDragMouseUp);
50040
+ gesture.release();
50041
+ window.removeEventListener("pointermove", handleImageDragMouseMove);
50042
+ window.removeEventListener("pointerup", handleImageDragMouseUp);
50043
+ window.removeEventListener("pointercancel", handleImageDragMouseUp);
50000
50044
  };
50001
50045
  const stopImageDrag = () => {
50002
50046
  clearImagePointerTracking();
@@ -50047,6 +50091,7 @@ function createEditorImageOperationsImpl(deps) {
50047
50091
  zoomFactor: deps.zoomFactor
50048
50092
  });
50049
50093
  const handleImageDragMouseMove = (event) => {
50094
+ if (!gesture.owns(event)) return;
50050
50095
  let dragState = activeImageDrag;
50051
50096
  if (!dragState) {
50052
50097
  const pendingState = pendingImagePointer;
@@ -50082,6 +50127,7 @@ function createEditorImageOperationsImpl(deps) {
50082
50127
  );
50083
50128
  };
50084
50129
  const handleImageDragMouseUp = (event) => {
50130
+ if (!gesture.owns(event)) return;
50085
50131
  const pendingState = pendingImagePointer;
50086
50132
  const dragState = activeImageDrag;
50087
50133
  if (!dragState && !pendingState) {
@@ -50138,10 +50184,12 @@ function createEditorImageOperationsImpl(deps) {
50138
50184
  setDragging(false);
50139
50185
  setDraggedImageInfo(null);
50140
50186
  setDropTargetPos(null);
50141
- window.addEventListener("mousemove", handleImageDragMouseMove);
50142
- window.addEventListener("mouseup", handleImageDragMouseUp);
50187
+ gesture.claim(event);
50188
+ window.addEventListener("pointermove", handleImageDragMouseMove);
50189
+ window.addEventListener("pointerup", handleImageDragMouseUp);
50190
+ window.addEventListener("pointercancel", handleImageDragMouseUp);
50143
50191
  };
50144
- const handleImageMouseDown = (paragraphId, paragraphOffset, event) => {
50192
+ const handleImagePointerDown = (paragraphId, paragraphOffset, event) => {
50145
50193
  event.preventDefault();
50146
50194
  event.stopPropagation();
50147
50195
  const paragraph = getDocumentParagraphs(deps.state.document).find(
@@ -50158,7 +50206,7 @@ function createEditorImageOperationsImpl(deps) {
50158
50206
  startImageDrag(paragraphId, paragraphOffset, event);
50159
50207
  deps.focusInputAfterPointerSelection();
50160
50208
  };
50161
- const handleImageResizeHandleMouseDown = (paragraphId, paragraphOffset, direction, event) => {
50209
+ const handleImageResizeHandlePointerDown = (paragraphId, paragraphOffset, direction, event) => {
50162
50210
  event.preventDefault();
50163
50211
  event.stopPropagation();
50164
50212
  imageResizeSession.start(
@@ -50169,12 +50217,12 @@ function createEditorImageOperationsImpl(deps) {
50169
50217
  deps.state
50170
50218
  );
50171
50219
  };
50172
- const handleImageRotateHandleMouseDown = (paragraphId, paragraphOffset, event) => {
50220
+ const handleImageRotateHandlePointerDown = (paragraphId, paragraphOffset, event) => {
50173
50221
  event.preventDefault();
50174
50222
  event.stopPropagation();
50175
50223
  imageRotateSession.start(paragraphId, paragraphOffset, event, deps.state);
50176
50224
  };
50177
- const handleImageCropHandleMouseDown = (paragraphId, paragraphOffset, direction, event) => {
50225
+ const handleImageCropHandlePointerDown = (paragraphId, paragraphOffset, direction, event) => {
50178
50226
  event.preventDefault();
50179
50227
  event.stopPropagation();
50180
50228
  imageCropSession.start(
@@ -50185,7 +50233,7 @@ function createEditorImageOperationsImpl(deps) {
50185
50233
  deps.state
50186
50234
  );
50187
50235
  };
50188
- const handleImageCropBodyMouseDown = (paragraphId, paragraphOffset, event) => {
50236
+ const handleImageCropBodyPointerDown = (paragraphId, paragraphOffset, event) => {
50189
50237
  event.preventDefault();
50190
50238
  event.stopPropagation();
50191
50239
  imageCropSession.startMove(paragraphId, paragraphOffset, event, deps.state);
@@ -50204,11 +50252,11 @@ function createEditorImageOperationsImpl(deps) {
50204
50252
  stopImageResize: imageResizeSession.stop,
50205
50253
  stopImageRotate: imageRotateSession.stop,
50206
50254
  stopImageCrop: imageCropSession.stop,
50207
- handleImageMouseDown,
50208
- handleImageResizeHandleMouseDown,
50209
- handleImageRotateHandleMouseDown,
50210
- handleImageCropHandleMouseDown,
50211
- handleImageCropBodyMouseDown
50255
+ handleImagePointerDown,
50256
+ handleImageResizeHandlePointerDown,
50257
+ handleImageRotateHandlePointerDown,
50258
+ handleImageCropHandlePointerDown,
50259
+ handleImageCropBodyPointerDown
50212
50260
  };
50213
50261
  }
50214
50262
  function createEditorTextBoxOperations(deps) {
@@ -50274,7 +50322,7 @@ function createEditorTextBoxOperationsImpl(deps) {
50274
50322
  logger: deps.logger
50275
50323
  }
50276
50324
  );
50277
- const handleTextBoxResizeHandleMouseDown = (paragraphId, paragraphOffset, direction, event) => {
50325
+ const handleTextBoxResizeHandlePointerDown = (paragraphId, paragraphOffset, direction, event) => {
50278
50326
  event.preventDefault();
50279
50327
  event.stopPropagation();
50280
50328
  resizeSession.start(
@@ -50285,14 +50333,14 @@ function createEditorTextBoxOperationsImpl(deps) {
50285
50333
  deps.state
50286
50334
  );
50287
50335
  };
50288
- const handleTextBoxRotateHandleMouseDown = (paragraphId, paragraphOffset, event) => {
50336
+ const handleTextBoxRotateHandlePointerDown = (paragraphId, paragraphOffset, event) => {
50289
50337
  event.preventDefault();
50290
50338
  event.stopPropagation();
50291
50339
  rotateSession.start(paragraphId, paragraphOffset, event, deps.state);
50292
50340
  };
50293
50341
  return {
50294
- handleTextBoxResizeHandleMouseDown,
50295
- handleTextBoxRotateHandleMouseDown,
50342
+ handleTextBoxResizeHandlePointerDown,
50343
+ handleTextBoxRotateHandlePointerDown,
50296
50344
  stopTextBoxResize: resizeSession.stop,
50297
50345
  stopTextBoxRotate: rotateSession.stop
50298
50346
  };
@@ -51804,14 +51852,16 @@ function createEditorTableResize(deps) {
51804
51852
  cursorOwner
51805
51853
  );
51806
51854
  };
51807
- const handleMouseMove = (event) => {
51855
+ const gesture = createPointerGesture();
51856
+ const handlePointerMove = (event) => {
51857
+ if (!gesture.owns(event)) return;
51808
51858
  if (resizing()) return;
51809
51859
  hoverPendingPoint = { clientX: event.clientX, clientY: event.clientY };
51810
51860
  if (hoverFrameHandle === null) {
51811
51861
  hoverFrameHandle = scheduleAnimationFrame(processHoverFrame);
51812
51862
  }
51813
51863
  };
51814
- const handleMouseDown = (event) => {
51864
+ const handlePointerDown = (event) => {
51815
51865
  var _a, _b;
51816
51866
  hoverPendingPoint = null;
51817
51867
  if (hoverFrameHandle !== null) {
@@ -51863,8 +51913,10 @@ function createEditorTableResize(deps) {
51863
51913
  guideBounds: getGuideBounds(deps.viewportRef)
51864
51914
  });
51865
51915
  setActiveCursorClass(true, cursorOwner);
51866
- window.addEventListener("mousemove", handleWindowMouseMove);
51867
- window.addEventListener("mouseup", handleWindowMouseUp);
51916
+ gesture.claim(event);
51917
+ window.addEventListener("pointermove", handleWindowMouseMove);
51918
+ window.addEventListener("pointerup", handleWindowMouseUp);
51919
+ window.addEventListener("pointercancel", handleWindowMouseUp);
51868
51920
  event.preventDefault();
51869
51921
  event.stopPropagation();
51870
51922
  return true;
@@ -51896,13 +51948,16 @@ function createEditorTableResize(deps) {
51896
51948
  guideBounds: getGuideBounds(deps.viewportRef)
51897
51949
  });
51898
51950
  setActiveCursorClass(false, cursorOwner);
51899
- window.addEventListener("mousemove", handleWindowMouseMove);
51900
- window.addEventListener("mouseup", handleWindowMouseUp);
51951
+ gesture.claim(event);
51952
+ window.addEventListener("pointermove", handleWindowMouseMove);
51953
+ window.addEventListener("pointerup", handleWindowMouseUp);
51954
+ window.addEventListener("pointercancel", handleWindowMouseUp);
51901
51955
  event.preventDefault();
51902
51956
  event.stopPropagation();
51903
51957
  return true;
51904
51958
  };
51905
51959
  const handleWindowMouseMove = (event) => {
51960
+ if (!gesture.owns(event)) return;
51906
51961
  if (!resizing()) return;
51907
51962
  resizePendingPoint = { clientX: event.clientX, clientY: event.clientY };
51908
51963
  if (resizeFrameHandle === null) {
@@ -51934,11 +51989,14 @@ function createEditorTableResize(deps) {
51934
51989
  }
51935
51990
  setResizing(null);
51936
51991
  clearResizeCursorClasses(cursorOwner);
51937
- window.removeEventListener("mousemove", handleWindowMouseMove);
51938
- window.removeEventListener("mouseup", handleWindowMouseUp);
51992
+ gesture.release();
51993
+ window.removeEventListener("pointermove", handleWindowMouseMove);
51994
+ window.removeEventListener("pointerup", handleWindowMouseUp);
51995
+ window.removeEventListener("pointercancel", handleWindowMouseUp);
51939
51996
  };
51940
51997
  const handleWindowMouseUp = (event) => {
51941
51998
  var _a;
51999
+ if (!gesture.owns(event)) return;
51942
52000
  const currentResizing = resizing();
51943
52001
  if (!currentResizing) return;
51944
52002
  const z = ((_a = deps.zoomFactor) == null ? void 0 : _a.call(deps)) ?? 1;
@@ -51955,8 +52013,8 @@ function createEditorTableResize(deps) {
51955
52013
  };
51956
52014
  return {
51957
52015
  resizing,
51958
- handleMouseMove,
51959
- handleMouseDown,
52016
+ handlePointerMove,
52017
+ handlePointerDown,
51960
52018
  stop
51961
52019
  };
51962
52020
  }
@@ -52022,7 +52080,9 @@ function createEditorTableCornerResize(deps) {
52022
52080
  height: current.bounds.height * scaleY
52023
52081
  };
52024
52082
  };
52083
+ const gesture = createPointerGesture();
52025
52084
  const handleWindowMouseMove = (event) => {
52085
+ if (!gesture.owns(event)) return;
52026
52086
  if (!resizing()) return;
52027
52087
  resizePendingPoint = { clientX: event.clientX, clientY: event.clientY };
52028
52088
  if (resizeFrameHandle === null) {
@@ -52049,8 +52109,10 @@ function createEditorTableCornerResize(deps) {
52049
52109
  resizeFrameHandle = null;
52050
52110
  }
52051
52111
  setResizing(null);
52052
- window.removeEventListener("mousemove", handleWindowMouseMove);
52053
- window.removeEventListener("mouseup", handleWindowMouseUp);
52112
+ gesture.release();
52113
+ window.removeEventListener("pointermove", handleWindowMouseMove);
52114
+ window.removeEventListener("pointerup", handleWindowMouseUp);
52115
+ window.removeEventListener("pointercancel", handleWindowMouseUp);
52054
52116
  if (tableCornerResizeCursorOwner === cursorOwner) {
52055
52117
  tableCornerResizeCursorOwner = null;
52056
52118
  if (document.body.style.cursor === "nwse-resize") {
@@ -52059,6 +52121,7 @@ function createEditorTableCornerResize(deps) {
52059
52121
  }
52060
52122
  };
52061
52123
  const handleWindowMouseUp = (event) => {
52124
+ if (!gesture.owns(event)) return;
52062
52125
  const current = resizing();
52063
52126
  if (current) {
52064
52127
  const movedX = Math.abs(event.clientX - current.startClientX);
@@ -52077,7 +52140,7 @@ function createEditorTableCornerResize(deps) {
52077
52140
  }
52078
52141
  stop();
52079
52142
  };
52080
- const handleMouseDown = (tableId, event) => {
52143
+ const handlePointerDown = (tableId, event) => {
52081
52144
  var _a;
52082
52145
  const surface = deps.surfaceRef();
52083
52146
  if (!surface) return;
@@ -52122,12 +52185,14 @@ function createEditorTableCornerResize(deps) {
52122
52185
  });
52123
52186
  tableCornerResizeCursorOwner = cursorOwner;
52124
52187
  document.body.style.cursor = "nwse-resize";
52125
- window.addEventListener("mousemove", handleWindowMouseMove);
52126
- window.addEventListener("mouseup", handleWindowMouseUp);
52188
+ gesture.claim(event);
52189
+ window.addEventListener("pointermove", handleWindowMouseMove);
52190
+ window.addEventListener("pointerup", handleWindowMouseUp);
52191
+ window.addEventListener("pointercancel", handleWindowMouseUp);
52127
52192
  event.preventDefault();
52128
52193
  event.stopPropagation();
52129
52194
  };
52130
- return { resizing, previewRect, handleMouseDown, stop };
52195
+ return { resizing, previewRect, handlePointerDown, stop };
52131
52196
  }
52132
52197
  let tableDragCursorOwner = null;
52133
52198
  function findTableInBlocks(blocks, tableId, nested, movableTopLevelStory) {
@@ -52202,6 +52267,7 @@ function createEditorTableDragImpl(deps) {
52202
52267
  (current) => positionsEqual(current, next) ? current : next
52203
52268
  );
52204
52269
  };
52270
+ const gesture = createPointerGesture();
52205
52271
  const stopDrag = () => {
52206
52272
  dragPendingPoint = null;
52207
52273
  if (dragFrameHandle !== null) {
@@ -52211,8 +52277,10 @@ function createEditorTableDragImpl(deps) {
52211
52277
  setDragging(false);
52212
52278
  setDraggedTableInfo(null);
52213
52279
  setDropTargetPos(null);
52214
- window.removeEventListener("mousemove", handleMouseMove);
52215
- window.removeEventListener("mouseup", handleMouseUp);
52280
+ gesture.release();
52281
+ window.removeEventListener("pointermove", handleMouseMove);
52282
+ window.removeEventListener("pointerup", handleMouseUp);
52283
+ window.removeEventListener("pointercancel", handleMouseUp);
52216
52284
  if (tableDragCursorOwner === cursorOwner) {
52217
52285
  tableDragCursorOwner = null;
52218
52286
  if (document.body.style.cursor === "grabbing") {
@@ -52239,6 +52307,7 @@ function createEditorTableDragImpl(deps) {
52239
52307
  updateDropTarget(pos);
52240
52308
  };
52241
52309
  const handleMouseMove = (event) => {
52310
+ if (!gesture.owns(event)) return;
52242
52311
  if (!dragging()) {
52243
52312
  const delta = Math.abs(event.clientY - startClientY());
52244
52313
  if (delta <= 4) return;
@@ -52252,6 +52321,7 @@ function createEditorTableDragImpl(deps) {
52252
52321
  }
52253
52322
  };
52254
52323
  const handleMouseUp = (event) => {
52324
+ if (!gesture.owns(event)) return;
52255
52325
  const info = draggedTableInfo();
52256
52326
  if (dragging()) {
52257
52327
  const pos = deps.resolvePositionAtSurfacePoint(
@@ -52284,7 +52354,7 @@ function createEditorTableDragImpl(deps) {
52284
52354
  stopDrag();
52285
52355
  deps.focusInput();
52286
52356
  };
52287
- const handleMouseDown = (tableId, event) => {
52357
+ const handlePointerDown = (tableId, event) => {
52288
52358
  event.preventDefault();
52289
52359
  event.stopPropagation();
52290
52360
  const handle = event.currentTarget;
@@ -52302,15 +52372,17 @@ function createEditorTableDragImpl(deps) {
52302
52372
  setMousePos({ x: event.clientX, y: event.clientY });
52303
52373
  setDragging(false);
52304
52374
  setDropTargetPos(null);
52305
- window.addEventListener("mousemove", handleMouseMove);
52306
- window.addEventListener("mouseup", handleMouseUp);
52375
+ gesture.claim(event);
52376
+ window.addEventListener("pointermove", handleMouseMove);
52377
+ window.addEventListener("pointerup", handleMouseUp);
52378
+ window.addEventListener("pointercancel", handleMouseUp);
52307
52379
  };
52308
52380
  return {
52309
52381
  dragging,
52310
52382
  draggedTableInfo,
52311
52383
  mousePos,
52312
52384
  dropTargetPos,
52313
- handleMouseDown,
52385
+ handlePointerDown,
52314
52386
  stop: stopDrag
52315
52387
  };
52316
52388
  }
@@ -52386,6 +52458,11 @@ function findNextWordBoundary(text, offset) {
52386
52458
  }
52387
52459
  const REUSE_MOUSE_DOWN_HIT_MAX_AGE_MS = 600;
52388
52460
  const REUSE_MOUSE_DOWN_HIT_MAX_DISTANCE_PX = 8;
52461
+ const TOUCH_SLOP_PX = 20;
52462
+ const LONG_PRESS_MS = 500;
52463
+ const TAP_MAX_DURATION_MS = 500;
52464
+ const isTouch = (event) => event.pointerType === "touch";
52465
+ const slopFor = (event, mouseSlop) => isTouch(event) ? TOUCH_SLOP_PX : mouseSlop;
52389
52466
  function resolveZoneFirstParagraph(blocks, zone) {
52390
52467
  if (!blocks || blocks.length === 0) {
52391
52468
  const paragraph2 = createSectionBoundaryParagraph(zone);
@@ -52426,6 +52503,8 @@ function createEditorSurfaceEventsImpl(deps) {
52426
52503
  let lastMouseDownAt = 0;
52427
52504
  let lastMouseDownX = 0;
52428
52505
  let lastMouseDownY = 0;
52506
+ let activePointerId = null;
52507
+ let pendingTouch = null;
52429
52508
  const scheduleFrame2 = (callback) => {
52430
52509
  if (typeof window !== "undefined" && typeof window.requestAnimationFrame === "function") {
52431
52510
  return window.requestAnimationFrame(() => callback());
@@ -52522,15 +52601,30 @@ function createEditorSurfaceEventsImpl(deps) {
52522
52601
  `${label} ${sel.anchor.paragraphId}[${sel.anchor.offset}]→${sel.focus.paragraphId}[${sel.focus.offset}] [${anchorLoc}→${focusLoc}]`
52523
52602
  );
52524
52603
  };
52604
+ const cancelPendingTouch = () => {
52605
+ if (pendingTouch == null ? void 0 : pendingTouch.longPressHandle) {
52606
+ clearTimeout(pendingTouch.longPressHandle);
52607
+ }
52608
+ pendingTouch = null;
52609
+ };
52525
52610
  const stopDragging = () => {
52526
52611
  dragAnchor = null;
52527
52612
  dragPendingPoint = null;
52613
+ activePointerId = null;
52614
+ cancelPendingTouch();
52528
52615
  if (dragFrameHandle !== null) {
52529
52616
  cancelFrame(dragFrameHandle);
52530
52617
  dragFrameHandle = null;
52531
52618
  }
52532
- window.removeEventListener("mousemove", handleWindowMouseMove);
52533
- window.removeEventListener("mouseup", handleWindowMouseUp);
52619
+ window.removeEventListener("pointermove", handleWindowPointerMove);
52620
+ window.removeEventListener("pointerup", handleWindowPointerUp);
52621
+ window.removeEventListener("pointercancel", handleWindowPointerCancel);
52622
+ };
52623
+ const startTrackingPointer = (pointerId) => {
52624
+ activePointerId = pointerId;
52625
+ window.addEventListener("pointermove", handleWindowPointerMove);
52626
+ window.addEventListener("pointerup", handleWindowPointerUp);
52627
+ window.addEventListener("pointercancel", handleWindowPointerCancel);
52534
52628
  };
52535
52629
  const processDragFrame = () => {
52536
52630
  dragFrameHandle = null;
@@ -52556,18 +52650,63 @@ function createEditorSurfaceEventsImpl(deps) {
52556
52650
  applyWithZone(state, hit.zone, next, hit.position);
52557
52651
  logSelection("selection:drag");
52558
52652
  };
52559
- const handleWindowMouseMove = (event) => {
52653
+ const flushPendingDragFrame = () => {
52654
+ if (!dragPendingPoint) return;
52655
+ if (dragFrameHandle !== null) {
52656
+ cancelFrame(dragFrameHandle);
52657
+ dragFrameHandle = null;
52658
+ }
52659
+ processDragFrame();
52660
+ };
52661
+ const handleWindowPointerMove = (event) => {
52662
+ if (activePointerId !== null && event.pointerId !== activePointerId) {
52663
+ return;
52664
+ }
52665
+ if (pendingTouch && !pendingTouch.longPressFired) {
52666
+ const moved = Math.hypot(
52667
+ event.clientX - pendingTouch.clientX,
52668
+ event.clientY - pendingTouch.clientY
52669
+ );
52670
+ if (moved > TOUCH_SLOP_PX) {
52671
+ stopDragging();
52672
+ }
52673
+ return;
52674
+ }
52560
52675
  if (!dragAnchor) return;
52561
52676
  dragPendingPoint = { clientX: event.clientX, clientY: event.clientY };
52562
52677
  if (dragFrameHandle === null) {
52563
52678
  dragFrameHandle = scheduleFrame2(processDragFrame);
52564
52679
  }
52565
52680
  };
52566
- const handleWindowMouseUp = () => {
52681
+ const handleWindowPointerUp = (event) => {
52682
+ if (activePointerId !== null && event.pointerId !== activePointerId) {
52683
+ return;
52684
+ }
52685
+ if (pendingTouch && !pendingTouch.longPressFired) {
52686
+ const touch = pendingTouch;
52687
+ const moved = Math.hypot(
52688
+ event.clientX - touch.clientX,
52689
+ event.clientY - touch.clientY
52690
+ );
52691
+ const isTap = moved <= TOUCH_SLOP_PX && Date.now() - touch.startedAt <= TAP_MAX_DURATION_MS;
52692
+ cancelPendingTouch();
52693
+ stopDragging();
52694
+ if (isTap) {
52695
+ commitTouchTap(touch.hit, touch.clickDetail, event);
52696
+ }
52697
+ return;
52698
+ }
52699
+ flushPendingDragFrame();
52567
52700
  logSelection("selection:end");
52568
52701
  stopDragging();
52569
52702
  deps.focusInputAfterPointerSelection();
52570
52703
  };
52704
+ const handleWindowPointerCancel = (event) => {
52705
+ if (activePointerId !== null && event.pointerId !== activePointerId) {
52706
+ return;
52707
+ }
52708
+ stopDragging();
52709
+ };
52571
52710
  const handleZoneTransitionDown = (state, hit, clickDetail) => {
52572
52711
  if (clickDetail < 2) {
52573
52712
  dragAnchor = null;
@@ -52644,20 +52783,22 @@ function createEditorSurfaceEventsImpl(deps) {
52644
52783
  start
52645
52784
  );
52646
52785
  stopDragging();
52647
- deps.imageOps.startImageDrag(
52648
- hit.image.paragraphId,
52649
- hit.image.startOffset,
52650
- event,
52651
- {
52652
- left: hit.image.left,
52653
- top: hit.image.top,
52654
- width: hit.image.width,
52655
- height: hit.image.height
52656
- }
52657
- );
52786
+ if (!isTouch(event)) {
52787
+ deps.imageOps.startImageDrag(
52788
+ hit.image.paragraphId,
52789
+ hit.image.startOffset,
52790
+ event,
52791
+ {
52792
+ left: hit.image.left,
52793
+ top: hit.image.top,
52794
+ width: hit.image.width,
52795
+ height: hit.image.height
52796
+ }
52797
+ );
52798
+ }
52658
52799
  deps.focusInputAfterPointerSelection();
52659
52800
  };
52660
- const handleShiftClickDown = (state, hit) => {
52801
+ const handleShiftClickDown = (state, hit, pointerId) => {
52661
52802
  dragAnchor = state.selection.anchor;
52662
52803
  applyWithZone(
52663
52804
  state,
@@ -52668,8 +52809,7 @@ function createEditorSurfaceEventsImpl(deps) {
52668
52809
  }),
52669
52810
  hit.position
52670
52811
  );
52671
- window.addEventListener("mousemove", handleWindowMouseMove);
52672
- window.addEventListener("mouseup", handleWindowMouseUp);
52812
+ startTrackingPointer(pointerId);
52673
52813
  deps.focusInputAfterPointerSelection();
52674
52814
  };
52675
52815
  const handleTripleClickDown = (state, hit, paragraph) => {
@@ -52722,43 +52862,17 @@ function createEditorSurfaceEventsImpl(deps) {
52722
52862
  stopDragging();
52723
52863
  deps.focusInputAfterPointerSelection();
52724
52864
  };
52725
- const handleSurfaceMouseDown = (event) => {
52865
+ const dispatchSurfaceDown = (state, hit, clickDetail, event) => {
52726
52866
  var _a;
52727
- if (event.button !== 0) {
52728
- return;
52729
- }
52730
- const now = Date.now();
52731
- const distance = Math.hypot(
52732
- event.clientX - lastClickX,
52733
- event.clientY - lastClickY
52734
- );
52735
- const withinStreakWindow = now - lastClickAt <= 450 && distance <= 6 && event.button === lastClickButton;
52736
- clickStreak = withinStreakWindow ? clickStreak + 1 : 1;
52737
- lastClickAt = now;
52738
- lastClickX = event.clientX;
52739
- lastClickY = event.clientY;
52740
- lastClickButton = event.button;
52741
- const clickDetail = Math.max(event.detail, clickStreak);
52742
- const state = deps.state();
52743
- deps.clearPendingCaretTextStyle();
52744
- if (deps.tableResize.handleMouseDown(event)) return;
52745
- event.preventDefault();
52746
52867
  deps.imageOps.stopImageDrag();
52747
52868
  deps.imageOps.stopImageResize();
52748
52869
  deps.clearPreferredColumn();
52749
52870
  deps.resetTransactionGrouping();
52750
- const hit = deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY, {
52751
- pierce: event.altKey
52752
- });
52753
- lastMouseDownHit = hit;
52754
- lastMouseDownAt = now;
52755
- lastMouseDownX = event.clientX;
52756
- lastMouseDownY = event.clientY;
52757
52871
  if (!hit) {
52758
52872
  deps.focusInputAfterPointerSelection();
52759
52873
  return;
52760
52874
  }
52761
- if ((_a = deps.textDrag) == null ? void 0 : _a.tryStartTextDrag(event, hit)) {
52875
+ if (!isTouch(event) && ((_a = deps.textDrag) == null ? void 0 : _a.tryStartTextDrag(event, hit))) {
52762
52876
  dragAnchor = null;
52763
52877
  stopDragging();
52764
52878
  deps.focusInputAfterPointerSelection();
@@ -52779,7 +52893,7 @@ function createEditorSurfaceEventsImpl(deps) {
52779
52893
  return;
52780
52894
  }
52781
52895
  if (event.shiftKey && hit.resolvedFromParagraph) {
52782
- handleShiftClickDown(state, hit);
52896
+ handleShiftClickDown(state, hit, event.pointerId);
52783
52897
  return;
52784
52898
  }
52785
52899
  if (clickDetail >= 3 && paragraph) {
@@ -52807,10 +52921,87 @@ function createEditorSurfaceEventsImpl(deps) {
52807
52921
  },
52808
52922
  hit.position
52809
52923
  );
52810
- window.addEventListener("mousemove", handleWindowMouseMove);
52811
- window.addEventListener("mouseup", handleWindowMouseUp);
52924
+ if (!isTouch(event)) {
52925
+ startTrackingPointer(event.pointerId);
52926
+ }
52812
52927
  deps.focusInputAfterPointerSelection();
52813
52928
  };
52929
+ const commitTouchTap = (hit, clickDetail, event) => {
52930
+ dispatchSurfaceDown(deps.state(), hit, clickDetail, event);
52931
+ deps.focusInputSync();
52932
+ };
52933
+ const beginTouchLongPress = () => {
52934
+ const touch = pendingTouch;
52935
+ if (!touch) return;
52936
+ touch.longPressHandle = null;
52937
+ touch.longPressFired = true;
52938
+ const hit = touch.hit;
52939
+ if (!(hit == null ? void 0 : hit.resolvedFromParagraph)) return;
52940
+ const state = deps.state();
52941
+ const paragraph = deps.getParagraphById(state.document, hit.paragraphId);
52942
+ if (!paragraph) return;
52943
+ const word = resolveWordSelection(
52944
+ getParagraphText(paragraph),
52945
+ hit.paragraphOffset
52946
+ );
52947
+ const startPos = paragraphOffsetToPosition(paragraph, word.start);
52948
+ const endPos = paragraphOffsetToPosition(paragraph, word.end);
52949
+ applyWithZone(
52950
+ state,
52951
+ hit.zone,
52952
+ setSelection(state, { anchor: startPos, focus: endPos }),
52953
+ startPos
52954
+ );
52955
+ dragAnchor = startPos;
52956
+ deps.focusInputSync();
52957
+ };
52958
+ const handleSurfacePointerDown = (event) => {
52959
+ if (event.button !== 0) {
52960
+ return;
52961
+ }
52962
+ const now = Date.now();
52963
+ const distance = Math.hypot(
52964
+ event.clientX - lastClickX,
52965
+ event.clientY - lastClickY
52966
+ );
52967
+ const withinStreakWindow = now - lastClickAt <= 450 && distance <= slopFor(event, 6) && event.button === lastClickButton;
52968
+ clickStreak = withinStreakWindow ? clickStreak + 1 : 1;
52969
+ lastClickAt = now;
52970
+ lastClickX = event.clientX;
52971
+ lastClickY = event.clientY;
52972
+ lastClickButton = event.button;
52973
+ const clickDetail = Math.max(event.detail, clickStreak);
52974
+ const state = deps.state();
52975
+ deps.clearPendingCaretTextStyle();
52976
+ if (deps.tableResize.handlePointerDown(event)) {
52977
+ event.preventDefault();
52978
+ return;
52979
+ }
52980
+ const hit = deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY, {
52981
+ pierce: event.altKey
52982
+ });
52983
+ lastMouseDownHit = hit;
52984
+ lastMouseDownAt = now;
52985
+ lastMouseDownX = event.clientX;
52986
+ lastMouseDownY = event.clientY;
52987
+ if (isTouch(event)) {
52988
+ cancelPendingTouch();
52989
+ pendingTouch = {
52990
+ pointerId: event.pointerId,
52991
+ clientX: event.clientX,
52992
+ clientY: event.clientY,
52993
+ startedAt: now,
52994
+ hit,
52995
+ clickDetail,
52996
+ longPressHandle: setTimeout(beginTouchLongPress, LONG_PRESS_MS),
52997
+ longPressFired: false
52998
+ };
52999
+ startTrackingPointer(event.pointerId);
53000
+ return;
53001
+ }
53002
+ event.preventDefault();
53003
+ dispatchSurfaceDown(state, hit, clickDetail, event);
53004
+ };
52814
53005
  const handleSurfaceDblClick = (event) => {
52815
53006
  event.preventDefault();
52816
53007
  };
@@ -52846,18 +53037,20 @@ function createEditorSurfaceEventsImpl(deps) {
52846
53037
  stopDragging();
52847
53038
  deps.focusInputAfterPointerSelection();
52848
53039
  };
52849
- const handleParagraphMouseDown = (_paragraphId, event) => {
53040
+ const handleParagraphPointerDown = (_paragraphId, event) => {
52850
53041
  if (event.button !== 0) {
52851
53042
  return;
52852
53043
  }
52853
- event.preventDefault();
52854
- handleSurfaceMouseDown(event);
53044
+ if (!isTouch(event)) {
53045
+ event.preventDefault();
53046
+ }
53047
+ handleSurfacePointerDown(event);
52855
53048
  };
52856
53049
  return {
52857
- handleSurfaceMouseDown,
53050
+ handleSurfacePointerDown,
52858
53051
  handleSurfaceClick,
52859
53052
  handleSurfaceDblClick,
52860
- handleParagraphMouseDown,
53053
+ handleParagraphPointerDown,
52861
53054
  stopDragging
52862
53055
  };
52863
53056
  }
@@ -53049,6 +53242,7 @@ function createEditorTextDragImpl(deps) {
53049
53242
  cursorStyleEl.textContent = `*, *::before, *::after { cursor: ${WORD_LIKE_DRAG_CURSOR} !important; }`;
53050
53243
  document.head.appendChild(cursorStyleEl);
53051
53244
  };
53245
+ const gesture = createPointerGesture();
53052
53246
  const stopDrag = () => {
53053
53247
  var _a;
53054
53248
  (_a = deps.logger) == null ? void 0 : _a.info("text-drag:stop", {
@@ -53064,11 +53258,14 @@ function createEditorTextDragImpl(deps) {
53064
53258
  setPointerPos(null);
53065
53259
  setCaretViewport(null);
53066
53260
  hideCursor();
53067
- window.removeEventListener("mousemove", handleWindowMouseMove);
53068
- window.removeEventListener("mouseup", handleWindowMouseUp);
53261
+ gesture.release();
53262
+ window.removeEventListener("pointermove", handleWindowMouseMove);
53263
+ window.removeEventListener("pointerup", handleWindowMouseUp);
53264
+ window.removeEventListener("pointercancel", handleWindowMouseUp);
53069
53265
  };
53070
53266
  const handleWindowMouseMove = (event) => {
53071
53267
  var _a, _b, _c;
53268
+ if (!gesture.owns(event)) return;
53072
53269
  if (!pendingStart) {
53073
53270
  return;
53074
53271
  }
@@ -53121,6 +53318,7 @@ function createEditorTextDragImpl(deps) {
53121
53318
  };
53122
53319
  const handleWindowMouseUp = (event) => {
53123
53320
  var _a, _b, _c;
53321
+ if (!gesture.owns(event)) return;
53124
53322
  (_a = deps.logger) == null ? void 0 : _a.info("text-drag:mouseup", {
53125
53323
  x: event.clientX,
53126
53324
  y: event.clientY,
@@ -53203,8 +53401,10 @@ function createEditorTextDragImpl(deps) {
53203
53401
  setDropTargetPos(null);
53204
53402
  setCaretViewport(hit.caretViewport ?? null);
53205
53403
  setDragging(false);
53206
- window.addEventListener("mousemove", handleWindowMouseMove);
53207
- window.addEventListener("mouseup", handleWindowMouseUp);
53404
+ gesture.claim(event);
53405
+ window.addEventListener("pointermove", handleWindowMouseMove);
53406
+ window.addEventListener("pointerup", handleWindowMouseUp);
53407
+ window.addEventListener("pointercancel", handleWindowMouseUp);
53208
53408
  return true;
53209
53409
  };
53210
53410
  return {
@@ -53602,6 +53802,7 @@ function useEditorInteractionWiring(ctx) {
53602
53802
  clearPreferredColumn: ctx.clearPreferredColumn,
53603
53803
  resetTransactionGrouping: ctx.resetTransactionGrouping,
53604
53804
  focusInputAfterPointerSelection: ctx.focusInputAfterPointerSelection,
53805
+ focusInputSync: ctx.focusInputSync,
53605
53806
  resolveSurfaceHitAtPoint: ctx.resolveSurfaceHitAtPoint,
53606
53807
  getParagraphById,
53607
53808
  textDrag: {
@@ -53675,6 +53876,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53675
53876
  cloneState,
53676
53877
  focusInput,
53677
53878
  focusInputAfterPointerSelection,
53879
+ focusInputSync,
53678
53880
  surfaceRef,
53679
53881
  viewportRef,
53680
53882
  zoomFactor,
@@ -53768,6 +53970,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53768
53970
  logger,
53769
53971
  focusInput,
53770
53972
  focusInputAfterPointerSelection,
53973
+ focusInputSync,
53771
53974
  clearPreferredColumn,
53772
53975
  resetTransactionGrouping,
53773
53976
  surfaceRef,
@@ -53788,7 +53991,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53788
53991
  insertImageFromFile,
53789
53992
  openEquationDialog: deps.openEquationDialog
53790
53993
  });
53791
- const onEditorMouseDown = (event) => {
53994
+ const onEditorPointerDown = (event) => {
53792
53995
  if (event.button !== 0) {
53793
53996
  return;
53794
53997
  }
@@ -53807,7 +54010,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53807
54010
  imageOps,
53808
54011
  textBoxOps,
53809
54012
  styleController,
53810
- onEditorMouseDown,
54013
+ onEditorPointerDown,
53811
54014
  tableResize: wiring.tableResize,
53812
54015
  tableCornerResize: wiring.tableCornerResize,
53813
54016
  tableDrag: wiring.tableDrag,
@@ -58503,6 +58706,7 @@ function OasisEditorApp(props = {}) {
58503
58706
  const setFocused = focusController.setFocused;
58504
58707
  const focusInput = focusController.focusInput;
58505
58708
  const focusInputAfterPointerSelection = focusController.focusInputAfterPointerSelection;
58709
+ const focusInputSync = focusController.focusInputSync;
58506
58710
  const [initialLoading, setInitialLoading] = createSignal(ui().loading !== false);
58507
58711
  const zoom = createEditorZoom();
58508
58712
  const {
@@ -58578,6 +58782,7 @@ function OasisEditorApp(props = {}) {
58578
58782
  cloneState,
58579
58783
  focusInput,
58580
58784
  focusInputAfterPointerSelection,
58785
+ focusInputSync,
58581
58786
  surfaceRef,
58582
58787
  viewportRef,
58583
58788
  zoomFactor: zoom.zoomFactor,
@@ -58611,7 +58816,7 @@ function OasisEditorApp(props = {}) {
58611
58816
  imageOps,
58612
58817
  textBoxOps,
58613
58818
  styleController,
58614
- onEditorMouseDown,
58819
+ onEditorPointerDown,
58615
58820
  tableResize,
58616
58821
  tableCornerResize,
58617
58822
  tableDrag,
@@ -58743,14 +58948,14 @@ function OasisEditorApp(props = {}) {
58743
58948
  tableDrag,
58744
58949
  revisionController,
58745
58950
  handleDrop,
58746
- onEditorMouseDown,
58747
- handleImageMouseDown: imageOps.handleImageMouseDown,
58748
- handleImageResizeHandleMouseDown: imageOps.handleImageResizeHandleMouseDown,
58749
- handleTextBoxResizeHandleMouseDown: textBoxOps.handleTextBoxResizeHandleMouseDown,
58750
- handleImageRotateHandleMouseDown: imageOps.handleImageRotateHandleMouseDown,
58751
- handleImageCropHandleMouseDown: imageOps.handleImageCropHandleMouseDown,
58752
- handleImageCropBodyMouseDown: imageOps.handleImageCropBodyMouseDown,
58753
- handleTextBoxRotateHandleMouseDown: textBoxOps.handleTextBoxRotateHandleMouseDown,
58951
+ onEditorPointerDown,
58952
+ handleImagePointerDown: imageOps.handleImagePointerDown,
58953
+ handleImageResizeHandlePointerDown: imageOps.handleImageResizeHandlePointerDown,
58954
+ handleTextBoxResizeHandlePointerDown: textBoxOps.handleTextBoxResizeHandlePointerDown,
58955
+ handleImageRotateHandlePointerDown: imageOps.handleImageRotateHandlePointerDown,
58956
+ handleImageCropHandlePointerDown: imageOps.handleImageCropHandlePointerDown,
58957
+ handleImageCropBodyPointerDown: imageOps.handleImageCropBodyPointerDown,
58958
+ handleTextBoxRotateHandlePointerDown: textBoxOps.handleTextBoxRotateHandlePointerDown,
58754
58959
  handleEditorContextMenu
58755
58960
  },
58756
58961
  input: {