oasis-editor 0.0.186 → 0.0.187

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-sfDgngZ-.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,54 @@ 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 handleWindowPointerMove = (event) => {
52654
+ if (activePointerId !== null && event.pointerId !== activePointerId) {
52655
+ return;
52656
+ }
52657
+ if (pendingTouch && !pendingTouch.longPressFired) {
52658
+ const moved = Math.hypot(
52659
+ event.clientX - pendingTouch.clientX,
52660
+ event.clientY - pendingTouch.clientY
52661
+ );
52662
+ if (moved > TOUCH_SLOP_PX) {
52663
+ stopDragging();
52664
+ }
52665
+ return;
52666
+ }
52560
52667
  if (!dragAnchor) return;
52561
52668
  dragPendingPoint = { clientX: event.clientX, clientY: event.clientY };
52562
52669
  if (dragFrameHandle === null) {
52563
52670
  dragFrameHandle = scheduleFrame2(processDragFrame);
52564
52671
  }
52565
52672
  };
52566
- const handleWindowMouseUp = () => {
52673
+ const handleWindowPointerUp = (event) => {
52674
+ if (activePointerId !== null && event.pointerId !== activePointerId) {
52675
+ return;
52676
+ }
52677
+ if (pendingTouch && !pendingTouch.longPressFired) {
52678
+ const touch = pendingTouch;
52679
+ const moved = Math.hypot(
52680
+ event.clientX - touch.clientX,
52681
+ event.clientY - touch.clientY
52682
+ );
52683
+ const isTap = moved <= TOUCH_SLOP_PX && Date.now() - touch.startedAt <= TAP_MAX_DURATION_MS;
52684
+ cancelPendingTouch();
52685
+ stopDragging();
52686
+ if (isTap) {
52687
+ commitTouchTap(touch.hit, touch.clickDetail, event);
52688
+ }
52689
+ return;
52690
+ }
52567
52691
  logSelection("selection:end");
52568
52692
  stopDragging();
52569
52693
  deps.focusInputAfterPointerSelection();
52570
52694
  };
52695
+ const handleWindowPointerCancel = (event) => {
52696
+ if (activePointerId !== null && event.pointerId !== activePointerId) {
52697
+ return;
52698
+ }
52699
+ stopDragging();
52700
+ };
52571
52701
  const handleZoneTransitionDown = (state, hit, clickDetail) => {
52572
52702
  if (clickDetail < 2) {
52573
52703
  dragAnchor = null;
@@ -52644,20 +52774,22 @@ function createEditorSurfaceEventsImpl(deps) {
52644
52774
  start
52645
52775
  );
52646
52776
  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
- );
52777
+ if (!isTouch(event)) {
52778
+ deps.imageOps.startImageDrag(
52779
+ hit.image.paragraphId,
52780
+ hit.image.startOffset,
52781
+ event,
52782
+ {
52783
+ left: hit.image.left,
52784
+ top: hit.image.top,
52785
+ width: hit.image.width,
52786
+ height: hit.image.height
52787
+ }
52788
+ );
52789
+ }
52658
52790
  deps.focusInputAfterPointerSelection();
52659
52791
  };
52660
- const handleShiftClickDown = (state, hit) => {
52792
+ const handleShiftClickDown = (state, hit, pointerId) => {
52661
52793
  dragAnchor = state.selection.anchor;
52662
52794
  applyWithZone(
52663
52795
  state,
@@ -52668,8 +52800,7 @@ function createEditorSurfaceEventsImpl(deps) {
52668
52800
  }),
52669
52801
  hit.position
52670
52802
  );
52671
- window.addEventListener("mousemove", handleWindowMouseMove);
52672
- window.addEventListener("mouseup", handleWindowMouseUp);
52803
+ startTrackingPointer(pointerId);
52673
52804
  deps.focusInputAfterPointerSelection();
52674
52805
  };
52675
52806
  const handleTripleClickDown = (state, hit, paragraph) => {
@@ -52722,43 +52853,17 @@ function createEditorSurfaceEventsImpl(deps) {
52722
52853
  stopDragging();
52723
52854
  deps.focusInputAfterPointerSelection();
52724
52855
  };
52725
- const handleSurfaceMouseDown = (event) => {
52856
+ const dispatchSurfaceDown = (state, hit, clickDetail, event) => {
52726
52857
  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
52858
  deps.imageOps.stopImageDrag();
52747
52859
  deps.imageOps.stopImageResize();
52748
52860
  deps.clearPreferredColumn();
52749
52861
  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
52862
  if (!hit) {
52758
52863
  deps.focusInputAfterPointerSelection();
52759
52864
  return;
52760
52865
  }
52761
- if ((_a = deps.textDrag) == null ? void 0 : _a.tryStartTextDrag(event, hit)) {
52866
+ if (!isTouch(event) && ((_a = deps.textDrag) == null ? void 0 : _a.tryStartTextDrag(event, hit))) {
52762
52867
  dragAnchor = null;
52763
52868
  stopDragging();
52764
52869
  deps.focusInputAfterPointerSelection();
@@ -52779,7 +52884,7 @@ function createEditorSurfaceEventsImpl(deps) {
52779
52884
  return;
52780
52885
  }
52781
52886
  if (event.shiftKey && hit.resolvedFromParagraph) {
52782
- handleShiftClickDown(state, hit);
52887
+ handleShiftClickDown(state, hit, event.pointerId);
52783
52888
  return;
52784
52889
  }
52785
52890
  if (clickDetail >= 3 && paragraph) {
@@ -52807,10 +52912,87 @@ function createEditorSurfaceEventsImpl(deps) {
52807
52912
  },
52808
52913
  hit.position
52809
52914
  );
52810
- window.addEventListener("mousemove", handleWindowMouseMove);
52811
- window.addEventListener("mouseup", handleWindowMouseUp);
52915
+ if (!isTouch(event)) {
52916
+ startTrackingPointer(event.pointerId);
52917
+ }
52812
52918
  deps.focusInputAfterPointerSelection();
52813
52919
  };
52920
+ const commitTouchTap = (hit, clickDetail, event) => {
52921
+ dispatchSurfaceDown(deps.state(), hit, clickDetail, event);
52922
+ deps.focusInputSync();
52923
+ };
52924
+ const beginTouchLongPress = () => {
52925
+ const touch = pendingTouch;
52926
+ if (!touch) return;
52927
+ touch.longPressHandle = null;
52928
+ touch.longPressFired = true;
52929
+ const hit = touch.hit;
52930
+ if (!(hit == null ? void 0 : hit.resolvedFromParagraph)) return;
52931
+ const state = deps.state();
52932
+ const paragraph = deps.getParagraphById(state.document, hit.paragraphId);
52933
+ if (!paragraph) return;
52934
+ const word = resolveWordSelection(
52935
+ getParagraphText(paragraph),
52936
+ hit.paragraphOffset
52937
+ );
52938
+ const startPos = paragraphOffsetToPosition(paragraph, word.start);
52939
+ const endPos = paragraphOffsetToPosition(paragraph, word.end);
52940
+ applyWithZone(
52941
+ state,
52942
+ hit.zone,
52943
+ setSelection(state, { anchor: startPos, focus: endPos }),
52944
+ startPos
52945
+ );
52946
+ dragAnchor = startPos;
52947
+ deps.focusInputSync();
52948
+ };
52949
+ const handleSurfacePointerDown = (event) => {
52950
+ if (event.button !== 0) {
52951
+ return;
52952
+ }
52953
+ const now = Date.now();
52954
+ const distance = Math.hypot(
52955
+ event.clientX - lastClickX,
52956
+ event.clientY - lastClickY
52957
+ );
52958
+ const withinStreakWindow = now - lastClickAt <= 450 && distance <= slopFor(event, 6) && event.button === lastClickButton;
52959
+ clickStreak = withinStreakWindow ? clickStreak + 1 : 1;
52960
+ lastClickAt = now;
52961
+ lastClickX = event.clientX;
52962
+ lastClickY = event.clientY;
52963
+ lastClickButton = event.button;
52964
+ const clickDetail = Math.max(event.detail, clickStreak);
52965
+ const state = deps.state();
52966
+ deps.clearPendingCaretTextStyle();
52967
+ if (deps.tableResize.handlePointerDown(event)) {
52968
+ event.preventDefault();
52969
+ return;
52970
+ }
52971
+ const hit = deps.resolveSurfaceHitAtPoint(event.clientX, event.clientY, {
52972
+ pierce: event.altKey
52973
+ });
52974
+ lastMouseDownHit = hit;
52975
+ lastMouseDownAt = now;
52976
+ lastMouseDownX = event.clientX;
52977
+ lastMouseDownY = event.clientY;
52978
+ if (isTouch(event)) {
52979
+ cancelPendingTouch();
52980
+ pendingTouch = {
52981
+ pointerId: event.pointerId,
52982
+ clientX: event.clientX,
52983
+ clientY: event.clientY,
52984
+ startedAt: now,
52985
+ hit,
52986
+ clickDetail,
52987
+ longPressHandle: setTimeout(beginTouchLongPress, LONG_PRESS_MS),
52988
+ longPressFired: false
52989
+ };
52990
+ startTrackingPointer(event.pointerId);
52991
+ return;
52992
+ }
52993
+ event.preventDefault();
52994
+ dispatchSurfaceDown(state, hit, clickDetail, event);
52995
+ };
52814
52996
  const handleSurfaceDblClick = (event) => {
52815
52997
  event.preventDefault();
52816
52998
  };
@@ -52846,18 +53028,20 @@ function createEditorSurfaceEventsImpl(deps) {
52846
53028
  stopDragging();
52847
53029
  deps.focusInputAfterPointerSelection();
52848
53030
  };
52849
- const handleParagraphMouseDown = (_paragraphId, event) => {
53031
+ const handleParagraphPointerDown = (_paragraphId, event) => {
52850
53032
  if (event.button !== 0) {
52851
53033
  return;
52852
53034
  }
52853
- event.preventDefault();
52854
- handleSurfaceMouseDown(event);
53035
+ if (!isTouch(event)) {
53036
+ event.preventDefault();
53037
+ }
53038
+ handleSurfacePointerDown(event);
52855
53039
  };
52856
53040
  return {
52857
- handleSurfaceMouseDown,
53041
+ handleSurfacePointerDown,
52858
53042
  handleSurfaceClick,
52859
53043
  handleSurfaceDblClick,
52860
- handleParagraphMouseDown,
53044
+ handleParagraphPointerDown,
52861
53045
  stopDragging
52862
53046
  };
52863
53047
  }
@@ -53049,6 +53233,7 @@ function createEditorTextDragImpl(deps) {
53049
53233
  cursorStyleEl.textContent = `*, *::before, *::after { cursor: ${WORD_LIKE_DRAG_CURSOR} !important; }`;
53050
53234
  document.head.appendChild(cursorStyleEl);
53051
53235
  };
53236
+ const gesture = createPointerGesture();
53052
53237
  const stopDrag = () => {
53053
53238
  var _a;
53054
53239
  (_a = deps.logger) == null ? void 0 : _a.info("text-drag:stop", {
@@ -53064,11 +53249,14 @@ function createEditorTextDragImpl(deps) {
53064
53249
  setPointerPos(null);
53065
53250
  setCaretViewport(null);
53066
53251
  hideCursor();
53067
- window.removeEventListener("mousemove", handleWindowMouseMove);
53068
- window.removeEventListener("mouseup", handleWindowMouseUp);
53252
+ gesture.release();
53253
+ window.removeEventListener("pointermove", handleWindowMouseMove);
53254
+ window.removeEventListener("pointerup", handleWindowMouseUp);
53255
+ window.removeEventListener("pointercancel", handleWindowMouseUp);
53069
53256
  };
53070
53257
  const handleWindowMouseMove = (event) => {
53071
53258
  var _a, _b, _c;
53259
+ if (!gesture.owns(event)) return;
53072
53260
  if (!pendingStart) {
53073
53261
  return;
53074
53262
  }
@@ -53121,6 +53309,7 @@ function createEditorTextDragImpl(deps) {
53121
53309
  };
53122
53310
  const handleWindowMouseUp = (event) => {
53123
53311
  var _a, _b, _c;
53312
+ if (!gesture.owns(event)) return;
53124
53313
  (_a = deps.logger) == null ? void 0 : _a.info("text-drag:mouseup", {
53125
53314
  x: event.clientX,
53126
53315
  y: event.clientY,
@@ -53203,8 +53392,10 @@ function createEditorTextDragImpl(deps) {
53203
53392
  setDropTargetPos(null);
53204
53393
  setCaretViewport(hit.caretViewport ?? null);
53205
53394
  setDragging(false);
53206
- window.addEventListener("mousemove", handleWindowMouseMove);
53207
- window.addEventListener("mouseup", handleWindowMouseUp);
53395
+ gesture.claim(event);
53396
+ window.addEventListener("pointermove", handleWindowMouseMove);
53397
+ window.addEventListener("pointerup", handleWindowMouseUp);
53398
+ window.addEventListener("pointercancel", handleWindowMouseUp);
53208
53399
  return true;
53209
53400
  };
53210
53401
  return {
@@ -53602,6 +53793,7 @@ function useEditorInteractionWiring(ctx) {
53602
53793
  clearPreferredColumn: ctx.clearPreferredColumn,
53603
53794
  resetTransactionGrouping: ctx.resetTransactionGrouping,
53604
53795
  focusInputAfterPointerSelection: ctx.focusInputAfterPointerSelection,
53796
+ focusInputSync: ctx.focusInputSync,
53605
53797
  resolveSurfaceHitAtPoint: ctx.resolveSurfaceHitAtPoint,
53606
53798
  getParagraphById,
53607
53799
  textDrag: {
@@ -53675,6 +53867,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53675
53867
  cloneState,
53676
53868
  focusInput,
53677
53869
  focusInputAfterPointerSelection,
53870
+ focusInputSync,
53678
53871
  surfaceRef,
53679
53872
  viewportRef,
53680
53873
  zoomFactor,
@@ -53768,6 +53961,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53768
53961
  logger,
53769
53962
  focusInput,
53770
53963
  focusInputAfterPointerSelection,
53964
+ focusInputSync,
53771
53965
  clearPreferredColumn,
53772
53966
  resetTransactionGrouping,
53773
53967
  surfaceRef,
@@ -53788,7 +53982,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53788
53982
  insertImageFromFile,
53789
53983
  openEquationDialog: deps.openEquationDialog
53790
53984
  });
53791
- const onEditorMouseDown = (event) => {
53985
+ const onEditorPointerDown = (event) => {
53792
53986
  if (event.button !== 0) {
53793
53987
  return;
53794
53988
  }
@@ -53807,7 +54001,7 @@ function createEditorInteractionRuntimeImpl(deps) {
53807
54001
  imageOps,
53808
54002
  textBoxOps,
53809
54003
  styleController,
53810
- onEditorMouseDown,
54004
+ onEditorPointerDown,
53811
54005
  tableResize: wiring.tableResize,
53812
54006
  tableCornerResize: wiring.tableCornerResize,
53813
54007
  tableDrag: wiring.tableDrag,
@@ -58503,6 +58697,7 @@ function OasisEditorApp(props = {}) {
58503
58697
  const setFocused = focusController.setFocused;
58504
58698
  const focusInput = focusController.focusInput;
58505
58699
  const focusInputAfterPointerSelection = focusController.focusInputAfterPointerSelection;
58700
+ const focusInputSync = focusController.focusInputSync;
58506
58701
  const [initialLoading, setInitialLoading] = createSignal(ui().loading !== false);
58507
58702
  const zoom = createEditorZoom();
58508
58703
  const {
@@ -58578,6 +58773,7 @@ function OasisEditorApp(props = {}) {
58578
58773
  cloneState,
58579
58774
  focusInput,
58580
58775
  focusInputAfterPointerSelection,
58776
+ focusInputSync,
58581
58777
  surfaceRef,
58582
58778
  viewportRef,
58583
58779
  zoomFactor: zoom.zoomFactor,
@@ -58611,7 +58807,7 @@ function OasisEditorApp(props = {}) {
58611
58807
  imageOps,
58612
58808
  textBoxOps,
58613
58809
  styleController,
58614
- onEditorMouseDown,
58810
+ onEditorPointerDown,
58615
58811
  tableResize,
58616
58812
  tableCornerResize,
58617
58813
  tableDrag,
@@ -58743,14 +58939,14 @@ function OasisEditorApp(props = {}) {
58743
58939
  tableDrag,
58744
58940
  revisionController,
58745
58941
  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,
58942
+ onEditorPointerDown,
58943
+ handleImagePointerDown: imageOps.handleImagePointerDown,
58944
+ handleImageResizeHandlePointerDown: imageOps.handleImageResizeHandlePointerDown,
58945
+ handleTextBoxResizeHandlePointerDown: textBoxOps.handleTextBoxResizeHandlePointerDown,
58946
+ handleImageRotateHandlePointerDown: imageOps.handleImageRotateHandlePointerDown,
58947
+ handleImageCropHandlePointerDown: imageOps.handleImageCropHandlePointerDown,
58948
+ handleImageCropBodyPointerDown: imageOps.handleImageCropBodyPointerDown,
58949
+ handleTextBoxRotateHandlePointerDown: textBoxOps.handleTextBoxRotateHandlePointerDown,
58754
58950
  handleEditorContextMenu
58755
58951
  },
58756
58952
  input: {