superdoc 1.0.0-beta.5 → 1.0.0-beta.7

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.
Files changed (30) hide show
  1. package/dist/chunks/{PdfViewer-B2yJpudB.cjs → PdfViewer-T4fTm1XF.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-Ebg4DPUi.es.js → PdfViewer-hAYAlKzI.es.js} +1 -1
  3. package/dist/chunks/{index-DcKcwu3F.cjs → index-CYQjWGo5.cjs} +3 -3
  4. package/dist/chunks/{index-6_t69RiQ.es.js → index-DGYP5Xod.es.js} +3 -3
  5. package/dist/chunks/{index-D653XgvV-B-4_BIjA.es.js → index-DV613LhK-BY095UD2.es.js} +1 -1
  6. package/dist/chunks/{index-D653XgvV-BN--CbY4.cjs → index-DV613LhK-CqFLIBmd.cjs} +1 -1
  7. package/dist/chunks/{super-editor.es-0TS__OEc.es.js → super-editor.es-CcaD69pQ.es.js} +533 -217
  8. package/dist/chunks/{super-editor.es-Bt9VCC9D.cjs → super-editor.es-DmhQckCV.cjs} +533 -217
  9. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  10. package/dist/style.css +9 -9
  11. package/dist/super-editor/ai-writer.es.js +2 -2
  12. package/dist/super-editor/chunks/{converter-BiUZIOjP.js → converter-BM6gXTRC.js} +1 -1
  13. package/dist/super-editor/chunks/{docx-zipper-Dz6dcXS4.js → docx-zipper-fwXPJGKu.js} +1 -1
  14. package/dist/super-editor/chunks/{editor-BtePjrrv.js → editor-RPTrfArg.js} +577 -206
  15. package/dist/super-editor/chunks/{index-D653XgvV.js → index-DV613LhK.js} +1 -1
  16. package/dist/super-editor/chunks/{toolbar-D6JNBgna.js → toolbar-DacKXz_n.js} +5 -4
  17. package/dist/super-editor/converter.es.js +1 -1
  18. package/dist/super-editor/docx-zipper.es.js +2 -2
  19. package/dist/super-editor/editor.es.js +3 -3
  20. package/dist/super-editor/file-zipper.es.js +1 -1
  21. package/dist/super-editor/style.css +9 -9
  22. package/dist/super-editor/super-editor.es.js +22 -16
  23. package/dist/super-editor/toolbar.es.js +2 -2
  24. package/dist/super-editor.cjs +1 -1
  25. package/dist/super-editor.es.js +1 -1
  26. package/dist/superdoc.cjs +2 -2
  27. package/dist/superdoc.es.js +2 -2
  28. package/dist/superdoc.umd.js +535 -219
  29. package/dist/superdoc.umd.js.map +1 -1
  30. package/package.json +1 -1
@@ -35580,7 +35580,7 @@ const _SuperConverter = class _SuperConverter2 {
35580
35580
  static getStoredSuperdocVersion(docx) {
35581
35581
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35582
35582
  }
35583
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.5") {
35583
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.7") {
35584
35584
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35585
35585
  }
35586
35586
  /**
@@ -38780,7 +38780,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
38780
38780
  var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
38781
38781
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
38782
38782
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
38783
- var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _headerLayoutResults, _footerLayoutResults, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, updateDecorationProviders_fn, createDecorationProvider_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, computeHeaderFooterCaretRect_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _visibleHost2, _getTargetDom, _onTargetChanged, _listeners, _currentTarget, _destroyed, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, updateHTMLAttributes_fn, updateDOMStyles_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
38783
+ var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _headerLayoutResults, _footerLayoutResults, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, updateDecorationProviders_fn, createDecorationProvider_fn, computeDecorationBox_fn, rebuildHeaderFooterRegions_fn, hitTestHeaderFooterRegion_fn, pointInRegion_fn, activateHeaderFooterRegion_fn, enterHeaderFooterMode_fn, exitHeaderFooterMode_fn, getActiveDomTarget_fn, emitHeaderFooterModeChanged_fn, emitHeaderFooterEditingContext_fn, updateAwarenessSession_fn, updateModeBanner_fn, announce_fn, validateHeaderFooterEditPermission_fn, emitHeaderFooterEditBlocked_fn, resolveDescriptorForRegion_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_fn, computeHeaderFooterCaretRect_fn, syncTrackedChangesPreferences_fn, deriveTrackedChangesMode_fn, deriveTrackedChangesEnabled_fn, getTrackChangesPluginState_fn, computeDefaultLayoutDefaults_fn, parseColumns_fn, inchesToPx_fn, applyZoom_fn, createLayoutMetrics_fn, convertPageLocalToOverlayCoords_fn, normalizeClientPoint_fn, computeCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, updateHTMLAttributes_fn, updateDOMStyles_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn;
38784
38784
  var GOOD_LEAF_SIZE = 200;
38785
38785
  var RopeSequence = function RopeSequence2() {
38786
38786
  };
@@ -52287,7 +52287,7 @@ const isHeadless = (editor) => {
52287
52287
  const shouldSkipNodeView = (editor) => {
52288
52288
  return isHeadless(editor);
52289
52289
  };
52290
- const summaryVersion = "1.0.0-beta.5";
52290
+ const summaryVersion = "1.0.0-beta.7";
52291
52291
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
52292
52292
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
52293
52293
  function mapAttributes(attrs) {
@@ -53066,7 +53066,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
53066
53066
  { default: remarkStringify },
53067
53067
  { default: remarkGfm }
53068
53068
  ] = await Promise.all([
53069
- Promise.resolve().then(() => require("./index-D653XgvV-BN--CbY4.cjs")),
53069
+ Promise.resolve().then(() => require("./index-DV613LhK-CqFLIBmd.cjs")),
53070
53070
  Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
53071
53071
  Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
53072
53072
  Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
@@ -53271,7 +53271,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
53271
53271
  * Process collaboration migrations
53272
53272
  */
53273
53273
  processCollaborationMigrations() {
53274
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.5");
53274
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.7");
53275
53275
  if (!this.options.ydoc) return;
53276
53276
  const metaMap = this.options.ydoc.getMap("meta");
53277
53277
  let docVersion = metaMap.get("version");
@@ -55403,9 +55403,10 @@ function extractTableBorders(bordersInput) {
55403
55403
  }
55404
55404
  function extractCellBorders(cellAttrs) {
55405
55405
  if (!cellAttrs?.borders) return void 0;
55406
+ const bordersData = cellAttrs.borders;
55406
55407
  const borders = {};
55407
55408
  for (const side of ["top", "right", "bottom", "left"]) {
55408
- const spec = convertBorderSpec(cellAttrs.borders[side]);
55409
+ const spec = convertBorderSpec(bordersData[side]);
55409
55410
  if (spec) {
55410
55411
  borders[side] = spec;
55411
55412
  }
@@ -55509,7 +55510,7 @@ const normalizeString = (value) => {
55509
55510
  return trimmed ? trimmed : void 0;
55510
55511
  };
55511
55512
  const MAX_AUTO_LINE_MULTIPLIER = 10;
55512
- const TWIPS_THRESHOLD = 50;
55513
+ const TWIPS_THRESHOLD$1 = 50;
55513
55514
  const spacingPxToPt = (spacing) => {
55514
55515
  const result = {};
55515
55516
  if (spacing.before != null) result.before = pxToPt(spacing.before);
@@ -55649,7 +55650,7 @@ const normalizeParagraphIndent = (value) => {
55649
55650
  const convert = (value2) => {
55650
55651
  const num = pickNumber(value2);
55651
55652
  if (num == null) return void 0;
55652
- if (Math.abs(num) <= TWIPS_THRESHOLD) {
55653
+ if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
55653
55654
  return num;
55654
55655
  }
55655
55656
  return twipsToPx$1(Number(num));
@@ -55664,24 +55665,18 @@ const normalizeParagraphIndent = (value) => {
55664
55665
  if (hanging != null) indent.hanging = hanging;
55665
55666
  return Object.keys(indent).length > 0 ? indent : void 0;
55666
55667
  };
55668
+ const PX_TO_TWIPS = 15;
55669
+ const TWIPS_THRESHOLD = 1e3;
55667
55670
  const normalizeOoxmlTabs = (tabs) => {
55668
55671
  if (!Array.isArray(tabs)) return void 0;
55669
55672
  const normalized = [];
55670
55673
  for (const entry of tabs) {
55671
55674
  if (!entry || typeof entry !== "object") continue;
55672
- const source = entry;
55673
- let posTwips;
55674
- const originalPos = pickNumber(source.originalPos);
55675
- if (originalPos != null) {
55676
- posTwips = originalPos;
55677
- } else {
55678
- const posPx = pickNumber(source.pos ?? source.position ?? source.offset);
55679
- if (posPx != null) {
55680
- posTwips = Math.round(posPx * 15);
55681
- }
55682
- }
55675
+ const rawEntry = entry;
55676
+ const source = rawEntry.tab && typeof rawEntry.tab === "object" ? rawEntry.tab : rawEntry;
55677
+ const posTwips = resolveTabPosition(source);
55683
55678
  if (posTwips == null) continue;
55684
- const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type);
55679
+ const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type ?? source.tabType);
55685
55680
  if (!val) continue;
55686
55681
  const tab = {
55687
55682
  val,
@@ -55693,6 +55688,21 @@ const normalizeOoxmlTabs = (tabs) => {
55693
55688
  }
55694
55689
  return normalized.length > 0 ? normalized : void 0;
55695
55690
  };
55691
+ const resolveTabPosition = (source) => {
55692
+ const originalPos = pickNumber(source.originalPos);
55693
+ if (originalPos != null) {
55694
+ return originalPos;
55695
+ }
55696
+ const posValue = pickNumber(source.pos ?? source.position ?? source.offset);
55697
+ if (posValue == null) {
55698
+ return void 0;
55699
+ }
55700
+ if (posValue > TWIPS_THRESHOLD) {
55701
+ return posValue;
55702
+ } else {
55703
+ return Math.round(posValue * PX_TO_TWIPS);
55704
+ }
55705
+ };
55696
55706
  const normalizeTabVal = (value) => {
55697
55707
  switch (value) {
55698
55708
  case "start":
@@ -55704,12 +55714,13 @@ const normalizeTabVal = (value) => {
55704
55714
  return value;
55705
55715
  case "left":
55706
55716
  return "start";
55707
- // Legacy mapping
55717
+ // Legacy mapping for RTL support
55708
55718
  case "right":
55709
55719
  return "end";
55710
- // Legacy mapping
55720
+ // Legacy mapping for RTL support
55711
55721
  case "dec":
55712
55722
  return "decimal";
55723
+ // Abbreviation mapping
55713
55724
  default:
55714
55725
  return void 0;
55715
55726
  }
@@ -55725,7 +55736,7 @@ const normalizeTabLeader = (value) => {
55725
55736
  return value;
55726
55737
  case "thick":
55727
55738
  return "heavy";
55728
- // Map legacy 'thick' to OOXML 'heavy'
55739
+ // Legacy mapping
55729
55740
  default:
55730
55741
  return void 0;
55731
55742
  }
@@ -56653,29 +56664,6 @@ const normalizeSuffix = (suffix2) => {
56653
56664
  }
56654
56665
  return void 0;
56655
56666
  };
56656
- function resolveSpacingIndent$1(style2, numbering) {
56657
- const spacing = {
56658
- before: style2.spacing?.before ?? 0,
56659
- after: style2.spacing?.after ?? 0,
56660
- line: style2.spacing?.line ?? 12,
56661
- // Default line spacing
56662
- lineRule: style2.spacing?.lineRule ?? "auto"
56663
- };
56664
- let indent = {
56665
- left: style2.indent?.left ?? 0,
56666
- right: style2.indent?.right ?? 0,
56667
- firstLine: style2.indent?.firstLine ?? 0,
56668
- hanging: style2.indent?.hanging ?? 0
56669
- };
56670
- if (numbering?.indent) {
56671
- indent = {
56672
- ...indent,
56673
- left: numbering.indent.left ?? indent.left,
56674
- hanging: numbering.indent.hanging ?? indent.hanging
56675
- };
56676
- }
56677
- return { spacing, indent };
56678
- }
56679
56667
  function computeTabStops$1(context) {
56680
56668
  const { explicitStops, defaultTabInterval, paragraphIndent } = context;
56681
56669
  const leftIndent = paragraphIndent.left ?? 0;
@@ -56787,6 +56775,90 @@ function computeEndAlignedX(entry, stop) {
56787
56775
  const targetX = stop.pos - width;
56788
56776
  return targetX < 0 ? 0 : targetX;
56789
56777
  }
56778
+ function calculateTabWidth(params2) {
56779
+ const {
56780
+ currentX,
56781
+ tabStops,
56782
+ paragraphWidth,
56783
+ defaultTabDistance: defaultTabDistance2,
56784
+ defaultLineLength: defaultLineLength2,
56785
+ followingText = "",
56786
+ measureText: measureText2,
56787
+ decimalSeparator = "."
56788
+ } = params2;
56789
+ const nextStop = tabStops.find((stop) => stop.val !== "clear" && stop.pos > currentX);
56790
+ const fallbackWidth = () => {
56791
+ let tabWidth = defaultTabDistance2 - currentX % defaultLineLength2 % defaultTabDistance2;
56792
+ if (tabWidth <= 0) tabWidth = defaultTabDistance2;
56793
+ return {
56794
+ width: tabWidth,
56795
+ alignment: "default",
56796
+ tabStopPosUsed: "default"
56797
+ };
56798
+ };
56799
+ if (!nextStop) {
56800
+ return fallbackWidth();
56801
+ }
56802
+ let width = Math.min(nextStop.pos, paragraphWidth) - currentX;
56803
+ const alignment2 = nextStop.val;
56804
+ if (alignment2 === "bar") {
56805
+ return {
56806
+ width: 0,
56807
+ leader: nextStop.leader,
56808
+ alignment: alignment2,
56809
+ tabStopPosUsed: nextStop.pos
56810
+ };
56811
+ }
56812
+ if (alignment2 === "center" || alignment2 === "end") {
56813
+ const textWidth = measureText2 ? measureText2(followingText) : 0;
56814
+ if (alignment2 === "center") {
56815
+ width -= textWidth / 2;
56816
+ } else {
56817
+ width -= textWidth;
56818
+ }
56819
+ } else if (alignment2 === "decimal") {
56820
+ const decimalIndex = followingText.indexOf(decimalSeparator);
56821
+ if (decimalIndex >= 0) {
56822
+ const before = followingText.slice(0, decimalIndex);
56823
+ const beforeWidth = measureText2 ? measureText2(before) : 0;
56824
+ width -= beforeWidth;
56825
+ }
56826
+ } else if (alignment2 === "bar") {
56827
+ width = 0;
56828
+ }
56829
+ if (width < 1) {
56830
+ return fallbackWidth();
56831
+ }
56832
+ return {
56833
+ width,
56834
+ leader: nextStop.leader,
56835
+ alignment: alignment2,
56836
+ tabStopPosUsed: nextStop.pos
56837
+ };
56838
+ }
56839
+ function resolveSpacingIndent$1(style2, numbering) {
56840
+ const spacing = {
56841
+ before: style2.spacing?.before ?? 0,
56842
+ after: style2.spacing?.after ?? 0,
56843
+ line: style2.spacing?.line ?? 12,
56844
+ // Default line spacing
56845
+ lineRule: style2.spacing?.lineRule ?? "auto"
56846
+ };
56847
+ let indent = {
56848
+ left: style2.indent?.left ?? 0,
56849
+ right: style2.indent?.right ?? 0,
56850
+ firstLine: style2.indent?.firstLine ?? 0,
56851
+ hanging: style2.indent?.hanging ?? 0
56852
+ };
56853
+ if (numbering?.indent) {
56854
+ indent = {
56855
+ ...indent,
56856
+ left: numbering.indent.left ?? indent.left,
56857
+ hanging: numbering.indent.hanging ?? indent.hanging
56858
+ };
56859
+ }
56860
+ return { spacing, indent };
56861
+ }
56790
56862
  function formatListLabel(level, indices) {
56791
56863
  const { format, text: template, start: start2 } = level;
56792
56864
  if (format === "bullet" || format === "custom") {
@@ -56952,6 +57024,7 @@ function measureRowHeights(cells, _columnWidths) {
56952
57024
  }
56953
57025
  const Engines = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
56954
57026
  __proto__: null,
57027
+ calculateTabWidth,
56955
57028
  computeListIndent,
56956
57029
  computeTabStops: computeTabStops$1,
56957
57030
  computeWrapExclusion,
@@ -57000,17 +57073,18 @@ const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
57000
57073
  return null;
57001
57074
  }
57002
57075
  const resolvedExtended = resolved;
57076
+ const resolvedAsRecord = resolved;
57003
57077
  const hydrated = {
57004
57078
  resolved,
57005
- spacing: cloneIfObject(resolved.spacing),
57006
- indent: cloneIfObject(resolved.indent),
57079
+ spacing: cloneIfObject(resolvedAsRecord.spacing),
57080
+ indent: cloneIfObject(resolvedAsRecord.indent),
57007
57081
  borders: cloneIfObject(resolvedExtended.borders),
57008
57082
  shading: cloneIfObject(resolvedExtended.shading),
57009
57083
  alignment: resolvedExtended.justification,
57010
57084
  tabStops: cloneIfObject(resolvedExtended.tabStops),
57011
57085
  keepLines: resolvedExtended.keepLines,
57012
57086
  keepNext: resolvedExtended.keepNext,
57013
- numberingProperties: cloneIfObject(resolved.numberingProperties)
57087
+ numberingProperties: cloneIfObject(resolvedAsRecord.numberingProperties)
57014
57088
  };
57015
57089
  return hydrated;
57016
57090
  };
@@ -57223,6 +57297,9 @@ const normalizeResolvedTabAlignment = (value) => {
57223
57297
  }
57224
57298
  };
57225
57299
  const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext) => {
57300
+ if (numberingProps === null) {
57301
+ return null;
57302
+ }
57226
57303
  try {
57227
57304
  let effectiveIndent = paragraphAttrs.indent;
57228
57305
  if (numberingProps?.resolvedLevelIndent) {
@@ -57257,7 +57334,7 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
57257
57334
  return computeWordParagraphLayout({
57258
57335
  paragraph: resolvedParagraph,
57259
57336
  numbering: numberingProps,
57260
- markerRun: numberingProps.resolvedMarkerRpr,
57337
+ markerRun: numberingProps?.resolvedMarkerRpr,
57261
57338
  // Use cached if available
57262
57339
  docDefaults
57263
57340
  });
@@ -57703,7 +57780,7 @@ function processImageChild(child, sectionMetadata, context, output, converters)
57703
57780
  function processNestedStructuredContent(child, sectionMetadata, context, output, converters) {
57704
57781
  const { getListCounter, incrementListCounter, resetListCounter } = context.listCounterContext;
57705
57782
  const nestedMetadata = resolveNodeSdtMetadata(child, "structuredContentBlock");
57706
- child.content.forEach((grandchild) => {
57783
+ child.content?.forEach((grandchild) => {
57707
57784
  if (grandchild.type === "paragraph") {
57708
57785
  const paragraphBlocks = converters.paragraphToFlowBlocks(
57709
57786
  grandchild,
@@ -57755,7 +57832,7 @@ function processDocumentPartObject(child, sectionMetadata, context, output, conv
57755
57832
  if (docPartGallery === "Table of Contents") {
57756
57833
  const blocksBeforeToc = output.blocks.length;
57757
57834
  processTocChildren(
57758
- Array.from(child.content),
57835
+ Array.from(child.content ?? []),
57759
57836
  { docPartGallery, docPartObjectId, tocInstruction, sdtMetadata: docPartSdtMetadata },
57760
57837
  {
57761
57838
  nextBlockId: context.nextBlockId,
@@ -58433,7 +58510,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
58433
58510
  trackedChanges,
58434
58511
  bookmarks,
58435
58512
  hyperlinkConfig,
58436
- converterContext
58513
+ themeColors,
58514
+ ...converterContext !== void 0 ? [converterContext] : []
58437
58515
  );
58438
58516
  if (tableBlock) {
58439
58517
  blocks.push(tableBlock);
@@ -58559,6 +58637,8 @@ function handleParagraphNode(node, context) {
58559
58637
  trackedChangesConfig,
58560
58638
  bookmarks,
58561
58639
  hyperlinkConfig,
58640
+ void 0,
58641
+ // themeColors - not available in NodeHandlerContext
58562
58642
  context.converterContext
58563
58643
  );
58564
58644
  paragraphBlocks.forEach((block) => {
@@ -59068,9 +59148,9 @@ const parseTableCell = (args) => {
59068
59148
  const paragraph = paragraphBlocks.find((b2) => b2.kind === "paragraph");
59069
59149
  if (!paragraph) return null;
59070
59150
  const cellAttrs = {};
59071
- const borders = extractCellBorders(cellNode.attrs);
59151
+ const borders = extractCellBorders(cellNode.attrs ?? {});
59072
59152
  if (borders) cellAttrs.borders = borders;
59073
- const padding = extractCellPadding(cellNode.attrs) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
59153
+ const padding = extractCellPadding(cellNode.attrs ?? {}) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
59074
59154
  if (padding) cellAttrs.padding = padding;
59075
59155
  const verticalAlign = cellNode.attrs?.verticalAlign;
59076
59156
  if (verticalAlign === "top" || verticalAlign === "middle" || verticalAlign === "bottom") {
@@ -59407,7 +59487,7 @@ function toFlowBlocks(pmDoc, options) {
59407
59487
  themeColors,
59408
59488
  converterContext
59409
59489
  );
59410
- const tableConverter = (node, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2) => tableNodeToBlock(
59490
+ const tableConverter = (node, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2, themeColorsParam, converterCtx) => tableNodeToBlock(
59411
59491
  node,
59412
59492
  nextBlockId2,
59413
59493
  positions2,
@@ -59417,8 +59497,8 @@ function toFlowBlocks(pmDoc, options) {
59417
59497
  trackedChanges,
59418
59498
  bookmarks2,
59419
59499
  hyperlinkConfig2,
59420
- themeColors,
59421
- converterContext
59500
+ themeColorsParam ?? themeColors,
59501
+ converterCtx ?? converterContext
59422
59502
  );
59423
59503
  const handlerContext = {
59424
59504
  blocks,
@@ -66100,7 +66180,7 @@ const _DomPainter = class _DomPainter2 {
66100
66180
  markerEl.style.display = "inline-block";
66101
66181
  markerEl.style.width = `${Math.max(0, fragment.markerWidth - LIST_MARKER_GAP$1)}px`;
66102
66182
  markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
66103
- markerEl.style.textAlign = marker.justification ?? "";
66183
+ markerEl.style.textAlign = marker.justification ?? "left";
66104
66184
  markerEl.style.fontFamily = marker.run.fontFamily;
66105
66185
  markerEl.style.fontSize = `${marker.run.fontSize}px`;
66106
66186
  if (marker.run.bold) markerEl.style.fontWeight = "bold";
@@ -66488,7 +66568,7 @@ const _DomPainter = class _DomPainter2 {
66488
66568
  buildLinkRenderData(link) {
66489
66569
  const dataset = buildLinkDataset(link);
66490
66570
  const sanitized = typeof link.href === "string" ? sanitizeHref(link.href) : null;
66491
- const anchorHref = normalizeAnchor(link.anchor ?? link.name ?? null);
66571
+ const anchorHref = normalizeAnchor(link.anchor ?? link.name ?? "");
66492
66572
  let href = sanitized?.href ?? anchorHref;
66493
66573
  if (link.version === 2) {
66494
66574
  href = appendDocLocation(href, link.docLocation ?? null);
@@ -66666,6 +66746,10 @@ const _DomPainter = class _DomPainter2 {
66666
66746
  const el = this.doc.createElement("div");
66667
66747
  el.classList.add(CLASS_NAMES.line);
66668
66748
  applyStyles$2(el, lineStyles(line.lineHeight));
66749
+ const styleId = block.attrs?.styleId;
66750
+ if (styleId) {
66751
+ el.setAttribute("styleid", styleId);
66752
+ }
66669
66753
  const lineRange = computeLinePmRange(block, line);
66670
66754
  if (lineRange.pmStart != null) {
66671
66755
  el.dataset.pmStart = String(lineRange.pmStart);
@@ -66693,7 +66777,7 @@ const _DomPainter = class _DomPainter2 {
66693
66777
  leaderEl.style.height = ld.style === "heavy" ? "2px" : "1px";
66694
66778
  leaderEl.style.pointerEvents = "none";
66695
66779
  leaderEl.style.zIndex = "0";
66696
- if (ld.style === "dot") {
66780
+ if (ld.style === "dot" || ld.style === "middleDot") {
66697
66781
  leaderEl.style.borderBottom = "1px dotted currentColor";
66698
66782
  } else if (ld.style === "hyphen") {
66699
66783
  leaderEl.style.borderBottom = "1px dashed currentColor";
@@ -66730,6 +66814,9 @@ const _DomPainter = class _DomPainter2 {
66730
66814
  const segmentRun = { ...baseRun, text: segmentText };
66731
66815
  const elem = this.renderRun(segmentRun, context, trackedConfig);
66732
66816
  if (elem) {
66817
+ if (styleId) {
66818
+ elem.setAttribute("styleid", styleId);
66819
+ }
66733
66820
  let xPos;
66734
66821
  if (segment.x !== void 0) {
66735
66822
  xPos = segment.x;
@@ -66755,6 +66842,9 @@ const _DomPainter = class _DomPainter2 {
66755
66842
  runs.forEach((run2) => {
66756
66843
  const elem = this.renderRun(run2, context, trackedConfig);
66757
66844
  if (elem) {
66845
+ if (styleId) {
66846
+ elem.setAttribute("styleid", styleId);
66847
+ }
66758
66848
  el.appendChild(elem);
66759
66849
  }
66760
66850
  });
@@ -67174,6 +67264,9 @@ const applyRunDataAttributes = (element, dataAttrs) => {
67174
67264
  };
67175
67265
  const applyParagraphBlockStyles = (element, attrs) => {
67176
67266
  if (!attrs) return;
67267
+ if (attrs.styleId) {
67268
+ element.setAttribute("styleid", attrs.styleId);
67269
+ }
67177
67270
  if (attrs.alignment) {
67178
67271
  element.style.textAlign = attrs.alignment;
67179
67272
  }
@@ -67395,6 +67488,7 @@ const pxToTwips = (px) => Math.round(px * TWIPS_PER_PX);
67395
67488
  const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
67396
67489
  const TAB_EPSILON = 0.1;
67397
67490
  const DEFAULT_DECIMAL_SEPARATOR = ".";
67491
+ const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
67398
67492
  const roundValue = (value) => value;
67399
67493
  function getCanvasContext() {
67400
67494
  if (!canvasContext) {
@@ -67517,6 +67611,14 @@ async function measureParagraphBlock(block, maxWidth) {
67517
67611
  let tabStopCursor = 0;
67518
67612
  let pendingTabAlignment = null;
67519
67613
  let lastAppliedTabAlign = null;
67614
+ const warnedTabVals = /* @__PURE__ */ new Set();
67615
+ const validateTabStopVal = (stop) => {
67616
+ if (!ALLOWED_TAB_VALS.has(stop.val) && !warnedTabVals.has(stop.val)) {
67617
+ warnedTabVals.add(stop.val);
67618
+ return false;
67619
+ }
67620
+ return true;
67621
+ };
67520
67622
  const alignSegmentAtTab = (segmentText, font, runContext) => {
67521
67623
  if (!pendingTabAlignment || !currentLine) return;
67522
67624
  const { target, val } = pendingTabAlignment;
@@ -67565,8 +67667,13 @@ async function measureParagraphBlock(block, maxWidth) {
67565
67667
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
67566
67668
  currentLine.toRun = runIndex;
67567
67669
  currentLine.toChar = 1;
67568
- pendingTabAlignment = stop ? { target, val: stop.val } : null;
67569
- if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
67670
+ if (stop) {
67671
+ validateTabStopVal(stop);
67672
+ pendingTabAlignment = { target, val: stop.val };
67673
+ } else {
67674
+ pendingTabAlignment = null;
67675
+ }
67676
+ if (stop && stop.leader && stop.leader !== "none") {
67570
67677
  const leaderStyle = stop.leader;
67571
67678
  const from2 = Math.min(originX, target);
67572
67679
  const to = Math.max(originX, target);
@@ -67712,7 +67819,12 @@ async function measureParagraphBlock(block, maxWidth) {
67712
67819
  currentLine.toRun = runIndex;
67713
67820
  currentLine.toChar = charPosInRun;
67714
67821
  charPosInRun += 1;
67715
- pendingTabAlignment = stop ? { target, val: stop.val } : null;
67822
+ if (stop) {
67823
+ validateTabStopVal(stop);
67824
+ pendingTabAlignment = { target, val: stop.val };
67825
+ } else {
67826
+ pendingTabAlignment = null;
67827
+ }
67716
67828
  if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
67717
67829
  const leaderStyle = stop.leader;
67718
67830
  const from2 = Math.min(originX, target);
@@ -67764,10 +67876,6 @@ async function measureParagraphBlock(block, maxWidth) {
67764
67876
  markerTextWidth: glyphWidth,
67765
67877
  indentLeft: wordLayout.indentLeftPx ?? 0
67766
67878
  };
67767
- console.log(
67768
- "[measure] Marker:",
67769
- JSON.stringify({ text: markerText, width: markerInfo.markerWidth, indent: markerInfo.indentLeft })
67770
- );
67771
67879
  }
67772
67880
  return {
67773
67881
  kind: "paragraph",
@@ -68875,6 +68983,24 @@ getConverterContext_fn = function() {
68875
68983
  }
68876
68984
  return Object.keys(context).length > 0 ? context : void 0;
68877
68985
  };
68986
+ const uiSurfaces = /* @__PURE__ */ new WeakSet();
68987
+ function isInRegisteredSurface(event) {
68988
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
68989
+ if (path.length > 0) {
68990
+ for (const node2 of path) {
68991
+ if (uiSurfaces.has(node2)) return true;
68992
+ if (node2?.hasAttribute?.("data-editor-ui-surface")) return true;
68993
+ }
68994
+ return false;
68995
+ }
68996
+ let node = event.target;
68997
+ while (node) {
68998
+ if (uiSurfaces.has(node)) return true;
68999
+ if (node.hasAttribute?.("data-editor-ui-surface")) return true;
69000
+ node = node.parentElement;
69001
+ }
69002
+ return false;
69003
+ }
68878
69004
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
68879
69005
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
68880
69006
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -71651,39 +71777,49 @@ _PresentationEditor.CURSOR_STYLES = {
71651
71777
  };
71652
71778
  let PresentationEditor = _PresentationEditor;
71653
71779
  class PresentationInputBridge {
71654
- constructor(windowRoot, visibleHost, getTargetDom, onTargetChanged) {
71780
+ constructor(windowRoot, layoutSurface, getTargetDom, onTargetChanged, options) {
71655
71781
  __privateAdd$1(this, _PresentationInputBridge_instances);
71656
71782
  __privateAdd$1(this, _windowRoot);
71657
- __privateAdd$1(this, _visibleHost2);
71783
+ __privateAdd$1(this, _layoutSurfaces);
71658
71784
  __privateAdd$1(this, _getTargetDom);
71659
71785
  __privateAdd$1(this, _onTargetChanged);
71660
71786
  __privateAdd$1(this, _listeners);
71661
71787
  __privateAdd$1(this, _currentTarget, null);
71662
71788
  __privateAdd$1(this, _destroyed, false);
71789
+ __privateAdd$1(this, _useWindowFallback);
71663
71790
  __privateSet(this, _windowRoot, windowRoot);
71664
- __privateSet(this, _visibleHost2, visibleHost);
71791
+ __privateSet(this, _layoutSurfaces, /* @__PURE__ */ new Set([layoutSurface]));
71665
71792
  __privateSet(this, _getTargetDom, getTargetDom);
71666
71793
  __privateSet(this, _onTargetChanged, onTargetChanged);
71667
71794
  __privateSet(this, _listeners, []);
71795
+ __privateSet(this, _useWindowFallback, options?.useWindowFallback ?? false);
71668
71796
  }
71669
71797
  bind() {
71670
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71671
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keypress", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71672
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71673
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71674
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71675
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71676
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), __privateGet$1(this, _windowRoot));
71677
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71678
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71679
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71680
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71681
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71682
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71798
+ const keyboardTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71799
+ keyboardTargets.forEach((target) => {
71800
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
71801
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
71802
+ });
71803
+ const compositionTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71804
+ compositionTargets.forEach((target) => {
71805
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71806
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71807
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71808
+ });
71809
+ const textTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71810
+ textTargets.forEach((target) => {
71811
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71812
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71813
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71814
+ });
71815
+ const contextTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71816
+ contextTargets.forEach((target) => {
71817
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), target);
71818
+ });
71683
71819
  }
71684
71820
  destroy() {
71685
- __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target }) => {
71686
- target.removeEventListener(type2, handler2, true);
71821
+ __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target, useCapture }) => {
71822
+ target.removeEventListener(type2, handler2, useCapture);
71687
71823
  });
71688
71824
  __privateSet(this, _listeners, []);
71689
71825
  __privateSet(this, _currentTarget, null);
@@ -71718,17 +71854,18 @@ class PresentationInputBridge {
71718
71854
  }
71719
71855
  }
71720
71856
  _windowRoot = /* @__PURE__ */ new WeakMap();
71721
- _visibleHost2 = /* @__PURE__ */ new WeakMap();
71857
+ _layoutSurfaces = /* @__PURE__ */ new WeakMap();
71722
71858
  _getTargetDom = /* @__PURE__ */ new WeakMap();
71723
71859
  _onTargetChanged = /* @__PURE__ */ new WeakMap();
71724
71860
  _listeners = /* @__PURE__ */ new WeakMap();
71725
71861
  _currentTarget = /* @__PURE__ */ new WeakMap();
71726
71862
  _destroyed = /* @__PURE__ */ new WeakMap();
71863
+ _useWindowFallback = /* @__PURE__ */ new WeakMap();
71727
71864
  _PresentationInputBridge_instances = /* @__PURE__ */ new WeakSet();
71728
- addListener_fn = function(type2, handler2, target) {
71865
+ addListener_fn = function(type2, handler2, target, useCapture = false) {
71729
71866
  const bound = handler2.bind(this);
71730
- __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target });
71731
- target.addEventListener(type2, bound, true);
71867
+ __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target, useCapture });
71868
+ target.addEventListener(type2, bound, useCapture);
71732
71869
  };
71733
71870
  dispatchToTarget_fn = function(originalEvent, synthetic) {
71734
71871
  if (__privateGet$1(this, _destroyed)) return;
@@ -71749,7 +71886,16 @@ dispatchToTarget_fn = function(originalEvent, synthetic) {
71749
71886
  }
71750
71887
  };
71751
71888
  forwardKeyboardEvent_fn = function(event) {
71752
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71889
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71890
+ return;
71891
+ }
71892
+ if (event.defaultPrevented) {
71893
+ return;
71894
+ }
71895
+ if (event.isComposing || event.keyCode === 229) {
71896
+ return;
71897
+ }
71898
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isPlainCharacterKey_fn).call(this, event)) {
71753
71899
  return;
71754
71900
  }
71755
71901
  const synthetic = new KeyboardEvent(event.type, {
@@ -71767,26 +71913,40 @@ forwardKeyboardEvent_fn = function(event) {
71767
71913
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71768
71914
  };
71769
71915
  forwardTextEvent_fn = function(event) {
71770
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71916
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71771
71917
  return;
71772
71918
  }
71773
- let synthetic;
71774
- if (typeof InputEvent !== "undefined") {
71775
- synthetic = new InputEvent(event.type, {
71776
- data: event.data ?? event.data ?? null,
71777
- inputType: event.inputType ?? "insertText",
71778
- dataTransfer: event.dataTransfer ?? null,
71779
- isComposing: event.isComposing ?? false,
71780
- bubbles: true,
71781
- cancelable: true
71782
- });
71783
- } else {
71784
- synthetic = new Event(event.type, { bubbles: true, cancelable: true });
71919
+ if (event.defaultPrevented) {
71920
+ return;
71785
71921
  }
71786
- __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71922
+ if (event.isComposing) {
71923
+ return;
71924
+ }
71925
+ queueMicrotask(() => {
71926
+ if (event.defaultPrevented) {
71927
+ return;
71928
+ }
71929
+ let synthetic;
71930
+ if (typeof InputEvent !== "undefined") {
71931
+ synthetic = new InputEvent(event.type, {
71932
+ data: event.data ?? event.data ?? null,
71933
+ inputType: event.inputType ?? "insertText",
71934
+ dataTransfer: event.dataTransfer ?? null,
71935
+ isComposing: event.isComposing ?? false,
71936
+ bubbles: true,
71937
+ cancelable: true
71938
+ });
71939
+ } else {
71940
+ synthetic = new Event(event.type, { bubbles: true, cancelable: true });
71941
+ }
71942
+ __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71943
+ });
71787
71944
  };
71788
71945
  forwardCompositionEvent_fn = function(event) {
71789
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71946
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71947
+ return;
71948
+ }
71949
+ if (event.defaultPrevented) {
71790
71950
  return;
71791
71951
  }
71792
71952
  let synthetic;
@@ -71802,7 +71962,10 @@ forwardCompositionEvent_fn = function(event) {
71802
71962
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71803
71963
  };
71804
71964
  forwardContextMenu_fn = function(event) {
71805
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71965
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71966
+ return;
71967
+ }
71968
+ if (event.defaultPrevented) {
71806
71969
  return;
71807
71970
  }
71808
71971
  const synthetic = new MouseEvent("contextmenu", {
@@ -71836,6 +71999,36 @@ isEventOnActiveTarget_fn = function(event) {
71836
71999
  }
71837
72000
  return false;
71838
72001
  };
72002
+ shouldSkipSurface_fn = function(event) {
72003
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
72004
+ return true;
72005
+ }
72006
+ if (!__privateMethod$1(this, _PresentationInputBridge_instances, isInLayoutSurface_fn).call(this, event)) {
72007
+ return true;
72008
+ }
72009
+ if (isInRegisteredSurface(event)) {
72010
+ return true;
72011
+ }
72012
+ return false;
72013
+ };
72014
+ isInLayoutSurface_fn = function(event) {
72015
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
72016
+ if (path.length) {
72017
+ return path.some((node) => __privateGet$1(this, _layoutSurfaces).has(node));
72018
+ }
72019
+ const origin = event.target;
72020
+ return origin ? __privateGet$1(this, _layoutSurfaces).has(origin) : false;
72021
+ };
72022
+ getListenerTargets_fn = function() {
72023
+ const targets = new Set(__privateGet$1(this, _layoutSurfaces));
72024
+ if (__privateGet$1(this, _useWindowFallback)) {
72025
+ targets.add(__privateGet$1(this, _windowRoot));
72026
+ }
72027
+ return Array.from(targets);
72028
+ };
72029
+ isPlainCharacterKey_fn = function(event) {
72030
+ return event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
72031
+ };
71839
72032
  const Color = Extension.create({
71840
72033
  name: "color",
71841
72034
  addOptions() {
@@ -74596,29 +74789,6 @@ const restartNumbering = ({ editor, tr, state: state2, dispatch }) => {
74596
74789
  };
74597
74790
  const defaultTabDistance = 48;
74598
74791
  const defaultLineLength = 816;
74599
- const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
74600
- const decorations = [];
74601
- const paragraphCache = /* @__PURE__ */ new Map();
74602
- const coordCache = /* @__PURE__ */ new Map();
74603
- const domPosCache = /* @__PURE__ */ new Map();
74604
- const end2 = to ?? doc2.content.size;
74605
- doc2.nodesBetween(from2, end2, (node, pos) => {
74606
- if (node.type.name !== "tab") return;
74607
- const $pos = doc2.resolve(pos);
74608
- const paragraphContext = findParagraphContext($pos, paragraphCache, helpers2);
74609
- if (!paragraphContext) return;
74610
- const blockParent2 = $pos.node(paragraphContext.paragraphDepth);
74611
- const style2 = calculateTabStyle(node.nodeSize, view, pos, blockParent2, paragraphContext, coordCache, domPosCache);
74612
- if (style2) {
74613
- decorations.push(
74614
- Decoration.node(pos, pos + node.nodeSize, {
74615
- style: style2
74616
- })
74617
- );
74618
- }
74619
- });
74620
- return decorations;
74621
- };
74622
74792
  function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext, coordCache = null, domPosCache = null) {
74623
74793
  let extraStyles = "";
74624
74794
  try {
@@ -74670,14 +74840,14 @@ function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext,
74670
74840
  tabWidth -= integralWidth;
74671
74841
  }
74672
74842
  if (tabStop.leader) {
74673
- const leaderStyles = {
74843
+ const leaderStyles2 = {
74674
74844
  dot: "border-bottom: 1px dotted black;",
74675
74845
  heavy: "border-bottom: 2px solid black;",
74676
74846
  hyphen: "border-bottom: 1px solid black;",
74677
74847
  middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
74678
74848
  underscore: "border-bottom: 1px solid black;"
74679
74849
  };
74680
- extraStyles += leaderStyles[tabStop.leader] || "";
74850
+ extraStyles += leaderStyles2[tabStop.leader] || "";
74681
74851
  }
74682
74852
  }
74683
74853
  }
@@ -74689,7 +74859,7 @@ function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext,
74689
74859
  paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
74690
74860
  return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
74691
74861
  } catch (error) {
74692
- console.error("tab decoration error", error);
74862
+ return null;
74693
74863
  }
74694
74864
  }
74695
74865
  function findParagraphContext($pos, cache2, helpers2) {
@@ -74708,13 +74878,16 @@ function findParagraphContext($pos, cache2, helpers2) {
74708
74878
  }
74709
74879
  function extractParagraphContext(node, startPos, helpers2, depth = 0) {
74710
74880
  const paragraphProperties = getResolvedParagraphProperties(node);
74881
+ const alignmentAliases = { left: "start", right: "end" };
74711
74882
  let tabStops = [];
74712
74883
  if (Array.isArray(paragraphProperties.tabStops)) {
74713
74884
  tabStops = paragraphProperties.tabStops.map((stop) => {
74714
74885
  const ref2 = stop?.tab;
74715
74886
  if (!ref2) return stop || null;
74887
+ const rawType = ref2.tabType || "start";
74888
+ const mappedVal = alignmentAliases[rawType] || rawType;
74716
74889
  return {
74717
- val: ref2.tabType || "start",
74890
+ val: mappedVal,
74718
74891
  pos: twipsToPixels(Number(ref2.pos) || 0),
74719
74892
  leader: ref2.leader
74720
74893
  };
@@ -75779,6 +75952,184 @@ const CommentsMark = Mark2.create({
75779
75952
  return [CommentMarkName, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
75780
75953
  }
75781
75954
  });
75955
+ const leaderStyles = {
75956
+ dot: "border-bottom: 1px dotted black;",
75957
+ heavy: "border-bottom: 2px solid black;",
75958
+ hyphen: "border-bottom: 1px solid black;",
75959
+ middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
75960
+ underscore: "border-bottom: 1px solid black;"
75961
+ };
75962
+ const paragraphIdFromPos = (startPos) => `para-${startPos}`;
75963
+ const tabIdForIndex = (paragraphId, index2) => `${paragraphId}-tab-${index2}`;
75964
+ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, paragraphWidthOverride) {
75965
+ const $pos = doc2.resolve(paragraphPos);
75966
+ const paragraphCache = /* @__PURE__ */ new Map();
75967
+ const paragraphContext = findParagraphContext($pos, paragraphCache, helpers2);
75968
+ if (!paragraphContext) return null;
75969
+ const paragraphId = paragraphIdFromPos(paragraphContext.startPos);
75970
+ const paragraphNode = paragraphContext.paragraph;
75971
+ const { entries } = flattenParagraph(paragraphNode, paragraphContext.startPos);
75972
+ const spans = [];
75973
+ let tabIndex = 0;
75974
+ entries.forEach((entry, idx) => {
75975
+ const node = entry.node;
75976
+ const spanId = `${paragraphId}-span-${idx}`;
75977
+ const from2 = entry.pos;
75978
+ const to = entry.pos + node.nodeSize;
75979
+ if (node.type.name === "tab") {
75980
+ spans.push({
75981
+ type: "tab",
75982
+ spanId,
75983
+ tabId: tabIdForIndex(paragraphId, tabIndex++),
75984
+ pos: entry.pos,
75985
+ nodeSize: node.nodeSize
75986
+ });
75987
+ } else if (node.type.name === "text") {
75988
+ spans.push({
75989
+ type: "text",
75990
+ spanId,
75991
+ text: node.text || "",
75992
+ style: node.marks?.find((mark) => mark.type.name === "textStyle")?.attrs || {},
75993
+ from: from2,
75994
+ to
75995
+ });
75996
+ }
75997
+ });
75998
+ const tabStops = Array.isArray(paragraphContext.tabStops) ? [...paragraphContext.tabStops] : [];
75999
+ const hangingPx = twipsToPixels(Number(paragraphContext.indent?.hanging) || 0);
76000
+ if (hangingPx > 0 && paragraphContext.indentWidth != null) {
76001
+ tabStops.unshift({ val: "start", pos: paragraphContext.indentWidth + hangingPx, leader: "none" });
76002
+ }
76003
+ const paragraphWidth = getBlockNodeWidth(view, paragraphContext.startPos) ?? defaultLineLength;
76004
+ const indentWidth = paragraphContext.indentWidth ?? getIndentWidth(view, paragraphContext.startPos, paragraphContext.indent);
76005
+ return {
76006
+ paragraphId,
76007
+ revision,
76008
+ paragraphWidth,
76009
+ defaultTabDistance,
76010
+ defaultLineLength,
76011
+ indents: {
76012
+ left: twipsToPixels(Number(paragraphContext.indent?.left) || 0),
76013
+ right: twipsToPixels(Number(paragraphContext.indent?.right) || 0),
76014
+ firstLine: twipsToPixels(Number(paragraphContext.indent?.firstLine) || 0),
76015
+ hanging: hangingPx
76016
+ },
76017
+ tabStops,
76018
+ spans,
76019
+ indentWidth,
76020
+ paragraphNode
76021
+ };
76022
+ }
76023
+ function calculateTabLayout(request, measurement, view) {
76024
+ const {
76025
+ spans,
76026
+ tabStops,
76027
+ paragraphWidth,
76028
+ defaultTabDistance: defaultTabDistance2,
76029
+ defaultLineLength: defaultLineLength2,
76030
+ paragraphId,
76031
+ revision,
76032
+ indentWidth = 0,
76033
+ paragraphNode
76034
+ } = request;
76035
+ const tabs = {};
76036
+ let currentX = indentWidth;
76037
+ const measureText2 = (span) => {
76038
+ if (view && typeof span.from === "number" && typeof span.to === "number") {
76039
+ return measureRangeWidth(view, span.from, span.to);
76040
+ }
76041
+ return 0;
76042
+ };
76043
+ const tabHeight = paragraphNode ? calcTabHeight(paragraphNode) : void 0;
76044
+ for (let i = 0; i < spans.length; i++) {
76045
+ const span = spans[i];
76046
+ if (span.type === "text") {
76047
+ currentX += measureText2(span);
76048
+ } else if (span.type === "tab") {
76049
+ const followingText = collectFollowingText(spans, i + 1);
76050
+ let measureTextCallback;
76051
+ if (view) {
76052
+ const followingRange = getFollowingTextRange(spans, i + 1);
76053
+ if (followingRange) {
76054
+ const fullWidth = measureRangeWidth(view, followingRange.from, followingRange.to);
76055
+ const fullText = followingText;
76056
+ measureTextCallback = (text) => {
76057
+ if (text === fullText) return fullWidth;
76058
+ if (fullText.length > 0) {
76059
+ return text.length / fullText.length * fullWidth;
76060
+ }
76061
+ return 0;
76062
+ };
76063
+ }
76064
+ }
76065
+ const result = calculateTabWidth({
76066
+ currentX,
76067
+ tabStops,
76068
+ paragraphWidth,
76069
+ defaultTabDistance: defaultTabDistance2,
76070
+ defaultLineLength: defaultLineLength2,
76071
+ followingText,
76072
+ measureText: measureTextCallback
76073
+ });
76074
+ tabs[span.tabId] = {
76075
+ width: result.width,
76076
+ height: tabHeight,
76077
+ leader: result.leader,
76078
+ alignment: result.alignment,
76079
+ tabStopPosUsed: result.tabStopPosUsed
76080
+ };
76081
+ currentX += result.width;
76082
+ }
76083
+ }
76084
+ return {
76085
+ paragraphId,
76086
+ revision,
76087
+ tabs
76088
+ };
76089
+ }
76090
+ function applyLayoutResult(result, paragraph, paragraphPos) {
76091
+ const decorations = [];
76092
+ let tabIndex = 0;
76093
+ paragraph.forEach((node, offset2) => {
76094
+ if (node.type.name !== "tab") return;
76095
+ const pos = paragraphPos + offset2 + 1;
76096
+ const tabId = tabIdForIndex(result.paragraphId, tabIndex++);
76097
+ const layout = result.tabs[tabId];
76098
+ if (!layout) return;
76099
+ let style2 = `width: ${layout.width}px;`;
76100
+ if (layout.height) style2 += ` height: ${layout.height};`;
76101
+ if (layout.leader && leaderStyles[layout.leader]) {
76102
+ style2 += ` ${leaderStyles[layout.leader]}`;
76103
+ }
76104
+ decorations.push(Decoration.node(pos, pos + node.nodeSize, { style: style2 }));
76105
+ });
76106
+ return decorations;
76107
+ }
76108
+ function collectFollowingText(spans, startIndex) {
76109
+ let text = "";
76110
+ for (let i = startIndex; i < spans.length; i++) {
76111
+ const span = spans[i];
76112
+ if (span.type === "tab") break;
76113
+ if (span.type === "text") text += span.text || "";
76114
+ }
76115
+ return text;
76116
+ }
76117
+ function getFollowingTextRange(spans, startIndex) {
76118
+ let from2 = null;
76119
+ let to = null;
76120
+ for (let i = startIndex; i < spans.length; i++) {
76121
+ const span = spans[i];
76122
+ if (span.type === "tab") break;
76123
+ if (span.type === "text" && typeof span.from === "number" && typeof span.to === "number") {
76124
+ if (from2 === null) from2 = span.from;
76125
+ to = span.to;
76126
+ }
76127
+ }
76128
+ if (from2 !== null && to !== null) {
76129
+ return { from: from2, to };
76130
+ }
76131
+ return null;
76132
+ }
75782
76133
  const TabNode = Node$1.create({
75783
76134
  name: "tab",
75784
76135
  group: "inline",
@@ -75820,87 +76171,24 @@ const TabNode = Node$1.create({
75820
76171
  return [];
75821
76172
  }
75822
76173
  const { view, helpers: helpers2 } = this.editor;
75823
- const mergeRanges2 = (ranges) => {
75824
- if (ranges.length === 0) return [];
75825
- const sorted = ranges.slice().sort((a, b2) => a[0] - b2[0]);
75826
- const merged = [sorted[0]];
75827
- for (let i = 1; i < sorted.length; i++) {
75828
- const [start2, end2] = sorted[i];
75829
- const last = merged[merged.length - 1];
75830
- if (start2 <= last[1]) {
75831
- last[1] = Math.max(last[1], end2);
75832
- } else {
75833
- merged.push([start2, end2]);
75834
- }
75835
- }
75836
- return merged;
75837
- };
75838
76174
  const tabPlugin = new Plugin({
75839
76175
  name: "tabPlugin",
75840
76176
  key: new PluginKey("tabPlugin"),
75841
76177
  state: {
75842
76178
  init() {
75843
- return { decorations: false };
76179
+ return { decorations: false, revision: 0 };
75844
76180
  },
75845
- apply(tr, { decorations }, _oldState, newState) {
76181
+ apply(tr, { decorations, revision }, _oldState, newState) {
75846
76182
  if (!decorations) {
75847
- decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view, helpers2));
75848
- return { decorations };
76183
+ const newDecorations2 = buildDecorations(newState.doc, view, helpers2, 0);
76184
+ return { decorations: newDecorations2, revision: 0 };
75849
76185
  }
75850
76186
  if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
75851
- return { decorations };
76187
+ return { decorations, revision };
75852
76188
  }
75853
- decorations = decorations.map(tr.mapping, tr.doc);
75854
- const rangesToRecalculate = [];
75855
- const containsTab = (node) => node.type.name === "tab";
75856
- tr.steps.forEach((step, index2) => {
75857
- if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1)) {
75858
- return;
75859
- }
75860
- let hasTabInRange = false;
75861
- if (step.slice?.content) {
75862
- step.slice.content.descendants((node) => {
75863
- if (containsTab(node)) {
75864
- hasTabInRange = true;
75865
- return false;
75866
- }
75867
- });
75868
- }
75869
- if (!hasTabInRange) {
75870
- tr.docs[index2].nodesBetween(step.from, step.to, (node) => {
75871
- if (containsTab(node)) {
75872
- hasTabInRange = true;
75873
- return false;
75874
- }
75875
- });
75876
- }
75877
- if (!hasTabInRange) {
75878
- return;
75879
- }
75880
- let fromPos = step.from;
75881
- let toPos = step.to;
75882
- for (let i = index2; i < tr.steps.length; i++) {
75883
- const stepMap = tr.steps[i].getMap();
75884
- fromPos = stepMap.map(fromPos, -1);
75885
- toPos = stepMap.map(toPos, 1);
75886
- }
75887
- const $from = newState.doc.resolve(fromPos);
75888
- const $to = newState.doc.resolve(toPos);
75889
- const start2 = $from.start(Math.min($from.depth, 1));
75890
- const end2 = $to.end(Math.min($to.depth, 1));
75891
- rangesToRecalculate.push([start2, end2]);
75892
- });
75893
- if (rangesToRecalculate.length === 0) {
75894
- return { decorations };
75895
- }
75896
- const mergedRanges = mergeRanges2(rangesToRecalculate);
75897
- mergedRanges.forEach(([start2, end2]) => {
75898
- const oldDecorations = decorations.find(start2, end2);
75899
- decorations = decorations.remove(oldDecorations);
75900
- const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
75901
- decorations = decorations.add(newState.doc, newDecorations);
75902
- });
75903
- return { decorations };
76189
+ const nextRevision = revision + 1;
76190
+ const newDecorations = buildDecorations(newState.doc, view, helpers2, nextRevision);
76191
+ return { decorations: newDecorations, revision: nextRevision };
75904
76192
  }
75905
76193
  },
75906
76194
  props: {
@@ -75912,6 +76200,27 @@ const TabNode = Node$1.create({
75912
76200
  return [tabPlugin];
75913
76201
  }
75914
76202
  });
76203
+ function buildDecorations(doc2, view, helpers2, revision) {
76204
+ const decorations = [];
76205
+ doc2.descendants((node, pos) => {
76206
+ if (node.type.name !== "paragraph") return;
76207
+ let hasTab = false;
76208
+ node.descendants((child) => {
76209
+ if (child.type.name === "tab") {
76210
+ hasTab = true;
76211
+ return false;
76212
+ }
76213
+ return true;
76214
+ });
76215
+ if (!hasTab) return;
76216
+ const request = createLayoutRequest(doc2, pos + 1, view, helpers2, revision);
76217
+ if (!request) return;
76218
+ const result = calculateTabLayout(request, void 0, view);
76219
+ const paragraphDecorations = applyLayoutResult(result, node, pos);
76220
+ decorations.push(...paragraphDecorations);
76221
+ });
76222
+ return DecorationSet.create(doc2, decorations);
76223
+ }
75915
76224
  const LineBreak = Node$1.create({
75916
76225
  name: "lineBreak",
75917
76226
  group: "inline",
@@ -100107,7 +100416,8 @@ const _sfc_main$h = {
100107
100416
  class: "superdoc-toolbar",
100108
100417
  key: vue.unref(toolbarKey),
100109
100418
  role: "toolbar",
100110
- "aria-label": "Toolbar"
100419
+ "aria-label": "Toolbar",
100420
+ "data-editor-ui-surface": ""
100111
100421
  }, [
100112
100422
  vue.unref(showLeftSide) ? (vue.openBlock(), vue.createBlock(ButtonGroup, {
100113
100423
  key: 0,
@@ -100139,7 +100449,7 @@ const _sfc_main$h = {
100139
100449
  };
100140
100450
  }
100141
100451
  };
100142
- const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-639f50b4"]]);
100452
+ const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-3f5ec271"]]);
100143
100453
  const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
100144
100454
  const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
100145
100455
  async function baseInsightsFetch(payload, options = {}) {
@@ -101151,7 +101461,8 @@ const _sfc_main$e = {
101151
101461
  const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-8730b752"]]);
101152
101462
  const _hoisted_1$c = {
101153
101463
  key: 0,
101154
- class: "linked-style-buttons"
101464
+ class: "linked-style-buttons",
101465
+ "data-editor-ui-surface": ""
101155
101466
  };
101156
101467
  const _hoisted_2$8 = ["onClick", "onKeydown", "aria-label"];
101157
101468
  const _sfc_main$d = {
@@ -101230,7 +101541,7 @@ const _sfc_main$d = {
101230
101541
  };
101231
101542
  }
101232
101543
  };
101233
- const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-b53508a8"]]);
101544
+ const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-ecb78965"]]);
101234
101545
  const _hoisted_1$b = {
101235
101546
  key: 0,
101236
101547
  class: "link-title"
@@ -103896,14 +104207,19 @@ deactivateAll_fn = function() {
103896
104207
  });
103897
104208
  };
103898
104209
  updateToolbarHistory_fn = function() {
103899
- if (!this.activeEditor) return;
103900
- if (this.activeEditor.options.ydoc) {
103901
- const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
103902
- this.undoDepth = undoManager?.undoStack.length || 0;
103903
- this.redoDepth = undoManager?.redoStack.length || 0;
103904
- } else {
103905
- this.undoDepth = undoDepth(this.activeEditor.state);
103906
- this.redoDepth = redoDepth(this.activeEditor.state);
104210
+ if (!this.activeEditor?.state) return;
104211
+ try {
104212
+ if (this.activeEditor.options.ydoc) {
104213
+ const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
104214
+ this.undoDepth = undoManager?.undoStack.length || 0;
104215
+ this.redoDepth = undoManager?.redoStack.length || 0;
104216
+ } else {
104217
+ this.undoDepth = undoDepth(this.activeEditor.state);
104218
+ this.redoDepth = redoDepth(this.activeEditor.state);
104219
+ }
104220
+ } catch {
104221
+ this.undoDepth = 0;
104222
+ this.redoDepth = 0;
103907
104223
  }
103908
104224
  };
103909
104225
  enrichTrackedChanges_fn = function(trackedChanges = []) {