@harbour-enterprises/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
@@ -35581,7 +35581,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
35581
35581
  static getStoredSuperdocVersion(docx) {
35582
35582
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35583
35583
  }
35584
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.5") {
35584
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.7") {
35585
35585
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35586
35586
  }
35587
35587
  /**
@@ -46562,7 +46562,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
46562
46562
  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);
46563
46563
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
46564
46564
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
46565
- 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;
46565
+ 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;
46566
46566
  var GOOD_LEAF_SIZE = 200;
46567
46567
  var RopeSequence = function RopeSequence2() {
46568
46568
  };
@@ -60069,7 +60069,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60069
60069
  const shouldSkipNodeView = (editor) => {
60070
60070
  return isHeadless(editor);
60071
60071
  };
60072
- const summaryVersion = "1.0.0-beta.5";
60072
+ const summaryVersion = "1.0.0-beta.7";
60073
60073
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
60074
60074
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
60075
60075
  function mapAttributes(attrs) {
@@ -60848,7 +60848,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
60848
60848
  { default: remarkStringify2 },
60849
60849
  { default: remarkGfm2 }
60850
60850
  ] = await Promise.all([
60851
- Promise.resolve().then(() => indexD653XgvV),
60851
+ Promise.resolve().then(() => indexDV613LhK),
60852
60852
  Promise.resolve().then(() => indexDRCvimau),
60853
60853
  Promise.resolve().then(() => indexC_x_N6Uh),
60854
60854
  Promise.resolve().then(() => indexD_sWOSiG),
@@ -61053,7 +61053,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
61053
61053
  * Process collaboration migrations
61054
61054
  */
61055
61055
  processCollaborationMigrations() {
61056
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.5");
61056
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.7");
61057
61057
  if (!this.options.ydoc) return;
61058
61058
  const metaMap = this.options.ydoc.getMap("meta");
61059
61059
  let docVersion = metaMap.get("version");
@@ -63185,9 +63185,10 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63185
63185
  }
63186
63186
  function extractCellBorders(cellAttrs) {
63187
63187
  if (!cellAttrs?.borders) return void 0;
63188
+ const bordersData = cellAttrs.borders;
63188
63189
  const borders = {};
63189
63190
  for (const side of ["top", "right", "bottom", "left"]) {
63190
- const spec = convertBorderSpec(cellAttrs.borders[side]);
63191
+ const spec = convertBorderSpec(bordersData[side]);
63191
63192
  if (spec) {
63192
63193
  borders[side] = spec;
63193
63194
  }
@@ -63291,7 +63292,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63291
63292
  return trimmed ? trimmed : void 0;
63292
63293
  };
63293
63294
  const MAX_AUTO_LINE_MULTIPLIER = 10;
63294
- const TWIPS_THRESHOLD = 50;
63295
+ const TWIPS_THRESHOLD$1 = 50;
63295
63296
  const spacingPxToPt = (spacing) => {
63296
63297
  const result = {};
63297
63298
  if (spacing.before != null) result.before = pxToPt(spacing.before);
@@ -63431,7 +63432,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63431
63432
  const convert2 = (value2) => {
63432
63433
  const num = pickNumber(value2);
63433
63434
  if (num == null) return void 0;
63434
- if (Math.abs(num) <= TWIPS_THRESHOLD) {
63435
+ if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
63435
63436
  return num;
63436
63437
  }
63437
63438
  return twipsToPx$1(Number(num));
@@ -63446,24 +63447,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63446
63447
  if (hanging != null) indent2.hanging = hanging;
63447
63448
  return Object.keys(indent2).length > 0 ? indent2 : void 0;
63448
63449
  };
63450
+ const PX_TO_TWIPS = 15;
63451
+ const TWIPS_THRESHOLD = 1e3;
63449
63452
  const normalizeOoxmlTabs = (tabs) => {
63450
63453
  if (!Array.isArray(tabs)) return void 0;
63451
63454
  const normalized = [];
63452
63455
  for (const entry of tabs) {
63453
63456
  if (!entry || typeof entry !== "object") continue;
63454
- const source = entry;
63455
- let posTwips;
63456
- const originalPos = pickNumber(source.originalPos);
63457
- if (originalPos != null) {
63458
- posTwips = originalPos;
63459
- } else {
63460
- const posPx = pickNumber(source.pos ?? source.position ?? source.offset);
63461
- if (posPx != null) {
63462
- posTwips = Math.round(posPx * 15);
63463
- }
63464
- }
63457
+ const rawEntry = entry;
63458
+ const source = rawEntry.tab && typeof rawEntry.tab === "object" ? rawEntry.tab : rawEntry;
63459
+ const posTwips = resolveTabPosition(source);
63465
63460
  if (posTwips == null) continue;
63466
- const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type);
63461
+ const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type ?? source.tabType);
63467
63462
  if (!val) continue;
63468
63463
  const tab = {
63469
63464
  val,
@@ -63475,6 +63470,21 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63475
63470
  }
63476
63471
  return normalized.length > 0 ? normalized : void 0;
63477
63472
  };
63473
+ const resolveTabPosition = (source) => {
63474
+ const originalPos = pickNumber(source.originalPos);
63475
+ if (originalPos != null) {
63476
+ return originalPos;
63477
+ }
63478
+ const posValue = pickNumber(source.pos ?? source.position ?? source.offset);
63479
+ if (posValue == null) {
63480
+ return void 0;
63481
+ }
63482
+ if (posValue > TWIPS_THRESHOLD) {
63483
+ return posValue;
63484
+ } else {
63485
+ return Math.round(posValue * PX_TO_TWIPS);
63486
+ }
63487
+ };
63478
63488
  const normalizeTabVal = (value) => {
63479
63489
  switch (value) {
63480
63490
  case "start":
@@ -63486,12 +63496,13 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63486
63496
  return value;
63487
63497
  case "left":
63488
63498
  return "start";
63489
- // Legacy mapping
63499
+ // Legacy mapping for RTL support
63490
63500
  case "right":
63491
63501
  return "end";
63492
- // Legacy mapping
63502
+ // Legacy mapping for RTL support
63493
63503
  case "dec":
63494
63504
  return "decimal";
63505
+ // Abbreviation mapping
63495
63506
  default:
63496
63507
  return void 0;
63497
63508
  }
@@ -63507,7 +63518,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
63507
63518
  return value;
63508
63519
  case "thick":
63509
63520
  return "heavy";
63510
- // Map legacy 'thick' to OOXML 'heavy'
63521
+ // Legacy mapping
63511
63522
  default:
63512
63523
  return void 0;
63513
63524
  }
@@ -64435,29 +64446,6 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64435
64446
  }
64436
64447
  return void 0;
64437
64448
  };
64438
- function resolveSpacingIndent$1(style2, numbering) {
64439
- const spacing = {
64440
- before: style2.spacing?.before ?? 0,
64441
- after: style2.spacing?.after ?? 0,
64442
- line: style2.spacing?.line ?? 12,
64443
- // Default line spacing
64444
- lineRule: style2.spacing?.lineRule ?? "auto"
64445
- };
64446
- let indent2 = {
64447
- left: style2.indent?.left ?? 0,
64448
- right: style2.indent?.right ?? 0,
64449
- firstLine: style2.indent?.firstLine ?? 0,
64450
- hanging: style2.indent?.hanging ?? 0
64451
- };
64452
- if (numbering?.indent) {
64453
- indent2 = {
64454
- ...indent2,
64455
- left: numbering.indent.left ?? indent2.left,
64456
- hanging: numbering.indent.hanging ?? indent2.hanging
64457
- };
64458
- }
64459
- return { spacing, indent: indent2 };
64460
- }
64461
64449
  function computeTabStops$1(context) {
64462
64450
  const { explicitStops, defaultTabInterval, paragraphIndent } = context;
64463
64451
  const leftIndent = paragraphIndent.left ?? 0;
@@ -64569,6 +64557,90 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64569
64557
  const targetX = stop.pos - width;
64570
64558
  return targetX < 0 ? 0 : targetX;
64571
64559
  }
64560
+ function calculateTabWidth(params2) {
64561
+ const {
64562
+ currentX,
64563
+ tabStops,
64564
+ paragraphWidth,
64565
+ defaultTabDistance: defaultTabDistance2,
64566
+ defaultLineLength: defaultLineLength2,
64567
+ followingText = "",
64568
+ measureText: measureText2,
64569
+ decimalSeparator = "."
64570
+ } = params2;
64571
+ const nextStop = tabStops.find((stop) => stop.val !== "clear" && stop.pos > currentX);
64572
+ const fallbackWidth = () => {
64573
+ let tabWidth = defaultTabDistance2 - currentX % defaultLineLength2 % defaultTabDistance2;
64574
+ if (tabWidth <= 0) tabWidth = defaultTabDistance2;
64575
+ return {
64576
+ width: tabWidth,
64577
+ alignment: "default",
64578
+ tabStopPosUsed: "default"
64579
+ };
64580
+ };
64581
+ if (!nextStop) {
64582
+ return fallbackWidth();
64583
+ }
64584
+ let width = Math.min(nextStop.pos, paragraphWidth) - currentX;
64585
+ const alignment2 = nextStop.val;
64586
+ if (alignment2 === "bar") {
64587
+ return {
64588
+ width: 0,
64589
+ leader: nextStop.leader,
64590
+ alignment: alignment2,
64591
+ tabStopPosUsed: nextStop.pos
64592
+ };
64593
+ }
64594
+ if (alignment2 === "center" || alignment2 === "end") {
64595
+ const textWidth = measureText2 ? measureText2(followingText) : 0;
64596
+ if (alignment2 === "center") {
64597
+ width -= textWidth / 2;
64598
+ } else {
64599
+ width -= textWidth;
64600
+ }
64601
+ } else if (alignment2 === "decimal") {
64602
+ const decimalIndex = followingText.indexOf(decimalSeparator);
64603
+ if (decimalIndex >= 0) {
64604
+ const before = followingText.slice(0, decimalIndex);
64605
+ const beforeWidth = measureText2 ? measureText2(before) : 0;
64606
+ width -= beforeWidth;
64607
+ }
64608
+ } else if (alignment2 === "bar") {
64609
+ width = 0;
64610
+ }
64611
+ if (width < 1) {
64612
+ return fallbackWidth();
64613
+ }
64614
+ return {
64615
+ width,
64616
+ leader: nextStop.leader,
64617
+ alignment: alignment2,
64618
+ tabStopPosUsed: nextStop.pos
64619
+ };
64620
+ }
64621
+ function resolveSpacingIndent$1(style2, numbering) {
64622
+ const spacing = {
64623
+ before: style2.spacing?.before ?? 0,
64624
+ after: style2.spacing?.after ?? 0,
64625
+ line: style2.spacing?.line ?? 12,
64626
+ // Default line spacing
64627
+ lineRule: style2.spacing?.lineRule ?? "auto"
64628
+ };
64629
+ let indent2 = {
64630
+ left: style2.indent?.left ?? 0,
64631
+ right: style2.indent?.right ?? 0,
64632
+ firstLine: style2.indent?.firstLine ?? 0,
64633
+ hanging: style2.indent?.hanging ?? 0
64634
+ };
64635
+ if (numbering?.indent) {
64636
+ indent2 = {
64637
+ ...indent2,
64638
+ left: numbering.indent.left ?? indent2.left,
64639
+ hanging: numbering.indent.hanging ?? indent2.hanging
64640
+ };
64641
+ }
64642
+ return { spacing, indent: indent2 };
64643
+ }
64572
64644
  function formatListLabel(level, indices) {
64573
64645
  const { format, text: template, start: start2 } = level;
64574
64646
  if (format === "bullet" || format === "custom") {
@@ -64734,6 +64806,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64734
64806
  }
64735
64807
  const Engines = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
64736
64808
  __proto__: null,
64809
+ calculateTabWidth,
64737
64810
  computeListIndent,
64738
64811
  computeTabStops: computeTabStops$1,
64739
64812
  computeWrapExclusion,
@@ -64782,17 +64855,18 @@ Please report this to https://github.com/markedjs/marked.`, e) {
64782
64855
  return null;
64783
64856
  }
64784
64857
  const resolvedExtended = resolved;
64858
+ const resolvedAsRecord = resolved;
64785
64859
  const hydrated = {
64786
64860
  resolved,
64787
- spacing: cloneIfObject(resolved.spacing),
64788
- indent: cloneIfObject(resolved.indent),
64861
+ spacing: cloneIfObject(resolvedAsRecord.spacing),
64862
+ indent: cloneIfObject(resolvedAsRecord.indent),
64789
64863
  borders: cloneIfObject(resolvedExtended.borders),
64790
64864
  shading: cloneIfObject(resolvedExtended.shading),
64791
64865
  alignment: resolvedExtended.justification,
64792
64866
  tabStops: cloneIfObject(resolvedExtended.tabStops),
64793
64867
  keepLines: resolvedExtended.keepLines,
64794
64868
  keepNext: resolvedExtended.keepNext,
64795
- numberingProperties: cloneIfObject(resolved.numberingProperties)
64869
+ numberingProperties: cloneIfObject(resolvedAsRecord.numberingProperties)
64796
64870
  };
64797
64871
  return hydrated;
64798
64872
  };
@@ -65005,6 +65079,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65005
65079
  }
65006
65080
  };
65007
65081
  const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext) => {
65082
+ if (numberingProps === null) {
65083
+ return null;
65084
+ }
65008
65085
  try {
65009
65086
  let effectiveIndent = paragraphAttrs.indent;
65010
65087
  if (numberingProps?.resolvedLevelIndent) {
@@ -65039,7 +65116,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65039
65116
  return computeWordParagraphLayout({
65040
65117
  paragraph: resolvedParagraph,
65041
65118
  numbering: numberingProps,
65042
- markerRun: numberingProps.resolvedMarkerRpr,
65119
+ markerRun: numberingProps?.resolvedMarkerRpr,
65043
65120
  // Use cached if available
65044
65121
  docDefaults
65045
65122
  });
@@ -65485,7 +65562,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65485
65562
  function processNestedStructuredContent(child, sectionMetadata, context, output, converters) {
65486
65563
  const { getListCounter, incrementListCounter, resetListCounter } = context.listCounterContext;
65487
65564
  const nestedMetadata = resolveNodeSdtMetadata(child, "structuredContentBlock");
65488
- child.content.forEach((grandchild) => {
65565
+ child.content?.forEach((grandchild) => {
65489
65566
  if (grandchild.type === "paragraph") {
65490
65567
  const paragraphBlocks = converters.paragraphToFlowBlocks(
65491
65568
  grandchild,
@@ -65537,7 +65614,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
65537
65614
  if (docPartGallery === "Table of Contents") {
65538
65615
  const blocksBeforeToc = output.blocks.length;
65539
65616
  processTocChildren(
65540
- Array.from(child.content),
65617
+ Array.from(child.content ?? []),
65541
65618
  { docPartGallery, docPartObjectId, tocInstruction, sdtMetadata: docPartSdtMetadata },
65542
65619
  {
65543
65620
  nextBlockId: context.nextBlockId,
@@ -66215,7 +66292,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66215
66292
  trackedChanges,
66216
66293
  bookmarks,
66217
66294
  hyperlinkConfig,
66218
- converterContext
66295
+ themeColors,
66296
+ ...converterContext !== void 0 ? [converterContext] : []
66219
66297
  );
66220
66298
  if (tableBlock) {
66221
66299
  blocks2.push(tableBlock);
@@ -66341,6 +66419,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66341
66419
  trackedChangesConfig,
66342
66420
  bookmarks,
66343
66421
  hyperlinkConfig,
66422
+ void 0,
66423
+ // themeColors - not available in NodeHandlerContext
66344
66424
  context.converterContext
66345
66425
  );
66346
66426
  paragraphBlocks.forEach((block) => {
@@ -66850,9 +66930,9 @@ Please report this to https://github.com/markedjs/marked.`, e) {
66850
66930
  const paragraph2 = paragraphBlocks.find((b2) => b2.kind === "paragraph");
66851
66931
  if (!paragraph2) return null;
66852
66932
  const cellAttrs = {};
66853
- const borders = extractCellBorders(cellNode.attrs);
66933
+ const borders = extractCellBorders(cellNode.attrs ?? {});
66854
66934
  if (borders) cellAttrs.borders = borders;
66855
- const padding = extractCellPadding(cellNode.attrs) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
66935
+ const padding = extractCellPadding(cellNode.attrs ?? {}) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
66856
66936
  if (padding) cellAttrs.padding = padding;
66857
66937
  const verticalAlign = cellNode.attrs?.verticalAlign;
66858
66938
  if (verticalAlign === "top" || verticalAlign === "middle" || verticalAlign === "bottom") {
@@ -67189,7 +67269,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67189
67269
  themeColors,
67190
67270
  converterContext
67191
67271
  );
67192
- const tableConverter = (node2, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2) => tableNodeToBlock(
67272
+ const tableConverter = (node2, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2, themeColorsParam, converterCtx) => tableNodeToBlock(
67193
67273
  node2,
67194
67274
  nextBlockId2,
67195
67275
  positions2,
@@ -67199,8 +67279,8 @@ Please report this to https://github.com/markedjs/marked.`, e) {
67199
67279
  trackedChanges,
67200
67280
  bookmarks2,
67201
67281
  hyperlinkConfig2,
67202
- themeColors,
67203
- converterContext
67282
+ themeColorsParam ?? themeColors,
67283
+ converterCtx ?? converterContext
67204
67284
  );
67205
67285
  const handlerContext = {
67206
67286
  blocks: blocks2,
@@ -73882,7 +73962,7 @@ ${l}
73882
73962
  markerEl.style.display = "inline-block";
73883
73963
  markerEl.style.width = `${Math.max(0, fragment.markerWidth - LIST_MARKER_GAP$1)}px`;
73884
73964
  markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
73885
- markerEl.style.textAlign = marker.justification ?? "";
73965
+ markerEl.style.textAlign = marker.justification ?? "left";
73886
73966
  markerEl.style.fontFamily = marker.run.fontFamily;
73887
73967
  markerEl.style.fontSize = `${marker.run.fontSize}px`;
73888
73968
  if (marker.run.bold) markerEl.style.fontWeight = "bold";
@@ -74270,7 +74350,7 @@ ${l}
74270
74350
  buildLinkRenderData(link2) {
74271
74351
  const dataset = buildLinkDataset(link2);
74272
74352
  const sanitized = typeof link2.href === "string" ? sanitizeHref(link2.href) : null;
74273
- const anchorHref = normalizeAnchor(link2.anchor ?? link2.name ?? null);
74353
+ const anchorHref = normalizeAnchor(link2.anchor ?? link2.name ?? "");
74274
74354
  let href = sanitized?.href ?? anchorHref;
74275
74355
  if (link2.version === 2) {
74276
74356
  href = appendDocLocation(href, link2.docLocation ?? null);
@@ -74448,6 +74528,10 @@ ${l}
74448
74528
  const el = this.doc.createElement("div");
74449
74529
  el.classList.add(CLASS_NAMES.line);
74450
74530
  applyStyles$2(el, lineStyles(line.lineHeight));
74531
+ const styleId = block.attrs?.styleId;
74532
+ if (styleId) {
74533
+ el.setAttribute("styleid", styleId);
74534
+ }
74451
74535
  const lineRange = computeLinePmRange(block, line);
74452
74536
  if (lineRange.pmStart != null) {
74453
74537
  el.dataset.pmStart = String(lineRange.pmStart);
@@ -74475,7 +74559,7 @@ ${l}
74475
74559
  leaderEl.style.height = ld.style === "heavy" ? "2px" : "1px";
74476
74560
  leaderEl.style.pointerEvents = "none";
74477
74561
  leaderEl.style.zIndex = "0";
74478
- if (ld.style === "dot") {
74562
+ if (ld.style === "dot" || ld.style === "middleDot") {
74479
74563
  leaderEl.style.borderBottom = "1px dotted currentColor";
74480
74564
  } else if (ld.style === "hyphen") {
74481
74565
  leaderEl.style.borderBottom = "1px dashed currentColor";
@@ -74512,6 +74596,9 @@ ${l}
74512
74596
  const segmentRun = { ...baseRun, text: segmentText };
74513
74597
  const elem = this.renderRun(segmentRun, context, trackedConfig);
74514
74598
  if (elem) {
74599
+ if (styleId) {
74600
+ elem.setAttribute("styleid", styleId);
74601
+ }
74515
74602
  let xPos;
74516
74603
  if (segment.x !== void 0) {
74517
74604
  xPos = segment.x;
@@ -74537,6 +74624,9 @@ ${l}
74537
74624
  runs2.forEach((run2) => {
74538
74625
  const elem = this.renderRun(run2, context, trackedConfig);
74539
74626
  if (elem) {
74627
+ if (styleId) {
74628
+ elem.setAttribute("styleid", styleId);
74629
+ }
74540
74630
  el.appendChild(elem);
74541
74631
  }
74542
74632
  });
@@ -74956,6 +75046,9 @@ ${l}
74956
75046
  };
74957
75047
  const applyParagraphBlockStyles = (element2, attrs) => {
74958
75048
  if (!attrs) return;
75049
+ if (attrs.styleId) {
75050
+ element2.setAttribute("styleid", attrs.styleId);
75051
+ }
74959
75052
  if (attrs.alignment) {
74960
75053
  element2.style.textAlign = attrs.alignment;
74961
75054
  }
@@ -75177,6 +75270,7 @@ ${l}
75177
75270
  const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
75178
75271
  const TAB_EPSILON = 0.1;
75179
75272
  const DEFAULT_DECIMAL_SEPARATOR = ".";
75273
+ const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
75180
75274
  const roundValue = (value) => value;
75181
75275
  function getCanvasContext() {
75182
75276
  if (!canvasContext) {
@@ -75299,6 +75393,14 @@ ${l}
75299
75393
  let tabStopCursor = 0;
75300
75394
  let pendingTabAlignment = null;
75301
75395
  let lastAppliedTabAlign = null;
75396
+ const warnedTabVals = /* @__PURE__ */ new Set();
75397
+ const validateTabStopVal = (stop) => {
75398
+ if (!ALLOWED_TAB_VALS.has(stop.val) && !warnedTabVals.has(stop.val)) {
75399
+ warnedTabVals.add(stop.val);
75400
+ return false;
75401
+ }
75402
+ return true;
75403
+ };
75302
75404
  const alignSegmentAtTab = (segmentText, font, runContext) => {
75303
75405
  if (!pendingTabAlignment || !currentLine) return;
75304
75406
  const { target, val } = pendingTabAlignment;
@@ -75347,8 +75449,13 @@ ${l}
75347
75449
  currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
75348
75450
  currentLine.toRun = runIndex;
75349
75451
  currentLine.toChar = 1;
75350
- pendingTabAlignment = stop ? { target, val: stop.val } : null;
75351
- if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
75452
+ if (stop) {
75453
+ validateTabStopVal(stop);
75454
+ pendingTabAlignment = { target, val: stop.val };
75455
+ } else {
75456
+ pendingTabAlignment = null;
75457
+ }
75458
+ if (stop && stop.leader && stop.leader !== "none") {
75352
75459
  const leaderStyle = stop.leader;
75353
75460
  const from2 = Math.min(originX, target);
75354
75461
  const to = Math.max(originX, target);
@@ -75494,7 +75601,12 @@ ${l}
75494
75601
  currentLine.toRun = runIndex;
75495
75602
  currentLine.toChar = charPosInRun;
75496
75603
  charPosInRun += 1;
75497
- pendingTabAlignment = stop ? { target, val: stop.val } : null;
75604
+ if (stop) {
75605
+ validateTabStopVal(stop);
75606
+ pendingTabAlignment = { target, val: stop.val };
75607
+ } else {
75608
+ pendingTabAlignment = null;
75609
+ }
75498
75610
  if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
75499
75611
  const leaderStyle = stop.leader;
75500
75612
  const from2 = Math.min(originX, target);
@@ -75546,10 +75658,6 @@ ${l}
75546
75658
  markerTextWidth: glyphWidth,
75547
75659
  indentLeft: wordLayout.indentLeftPx ?? 0
75548
75660
  };
75549
- console.log(
75550
- "[measure] Marker:",
75551
- JSON.stringify({ text: markerText, width: markerInfo.markerWidth, indent: markerInfo.indentLeft })
75552
- );
75553
75661
  }
75554
75662
  return {
75555
75663
  kind: "paragraph",
@@ -76657,6 +76765,24 @@ ${l}
76657
76765
  }
76658
76766
  return Object.keys(context).length > 0 ? context : void 0;
76659
76767
  };
76768
+ const uiSurfaces = /* @__PURE__ */ new WeakSet();
76769
+ function isInRegisteredSurface(event) {
76770
+ const path2 = typeof event.composedPath === "function" ? event.composedPath() : [];
76771
+ if (path2.length > 0) {
76772
+ for (const node22 of path2) {
76773
+ if (uiSurfaces.has(node22)) return true;
76774
+ if (node22?.hasAttribute?.("data-editor-ui-surface")) return true;
76775
+ }
76776
+ return false;
76777
+ }
76778
+ let node2 = event.target;
76779
+ while (node2) {
76780
+ if (uiSurfaces.has(node2)) return true;
76781
+ if (node2.hasAttribute?.("data-editor-ui-surface")) return true;
76782
+ node2 = node2.parentElement;
76783
+ }
76784
+ return false;
76785
+ }
76660
76786
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
76661
76787
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
76662
76788
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -79433,39 +79559,49 @@ ${l}
79433
79559
  };
79434
79560
  let PresentationEditor = _PresentationEditor;
79435
79561
  class PresentationInputBridge {
79436
- constructor(windowRoot, visibleHost, getTargetDom, onTargetChanged) {
79562
+ constructor(windowRoot, layoutSurface, getTargetDom, onTargetChanged, options) {
79437
79563
  __privateAdd$1(this, _PresentationInputBridge_instances);
79438
79564
  __privateAdd$1(this, _windowRoot);
79439
- __privateAdd$1(this, _visibleHost2);
79565
+ __privateAdd$1(this, _layoutSurfaces);
79440
79566
  __privateAdd$1(this, _getTargetDom);
79441
79567
  __privateAdd$1(this, _onTargetChanged);
79442
79568
  __privateAdd$1(this, _listeners);
79443
79569
  __privateAdd$1(this, _currentTarget, null);
79444
79570
  __privateAdd$1(this, _destroyed, false);
79571
+ __privateAdd$1(this, _useWindowFallback);
79445
79572
  __privateSet(this, _windowRoot, windowRoot);
79446
- __privateSet(this, _visibleHost2, visibleHost);
79573
+ __privateSet(this, _layoutSurfaces, /* @__PURE__ */ new Set([layoutSurface]));
79447
79574
  __privateSet(this, _getTargetDom, getTargetDom);
79448
79575
  __privateSet(this, _onTargetChanged, onTargetChanged);
79449
79576
  __privateSet(this, _listeners, []);
79577
+ __privateSet(this, _useWindowFallback, options?.useWindowFallback ?? false);
79450
79578
  }
79451
79579
  bind() {
79452
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
79453
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keypress", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
79454
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
79455
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
79456
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
79457
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
79458
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), __privateGet$1(this, _windowRoot));
79459
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
79460
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
79461
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
79462
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
79463
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
79464
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
79580
+ const keyboardTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
79581
+ keyboardTargets.forEach((target) => {
79582
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
79583
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
79584
+ });
79585
+ const compositionTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
79586
+ compositionTargets.forEach((target) => {
79587
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
79588
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
79589
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
79590
+ });
79591
+ const textTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
79592
+ textTargets.forEach((target) => {
79593
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
79594
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
79595
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
79596
+ });
79597
+ const contextTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
79598
+ contextTargets.forEach((target) => {
79599
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), target);
79600
+ });
79465
79601
  }
79466
79602
  destroy() {
79467
- __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target }) => {
79468
- target.removeEventListener(type2, handler2, true);
79603
+ __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target, useCapture }) => {
79604
+ target.removeEventListener(type2, handler2, useCapture);
79469
79605
  });
79470
79606
  __privateSet(this, _listeners, []);
79471
79607
  __privateSet(this, _currentTarget, null);
@@ -79500,17 +79636,18 @@ ${l}
79500
79636
  }
79501
79637
  }
79502
79638
  _windowRoot = /* @__PURE__ */ new WeakMap();
79503
- _visibleHost2 = /* @__PURE__ */ new WeakMap();
79639
+ _layoutSurfaces = /* @__PURE__ */ new WeakMap();
79504
79640
  _getTargetDom = /* @__PURE__ */ new WeakMap();
79505
79641
  _onTargetChanged = /* @__PURE__ */ new WeakMap();
79506
79642
  _listeners = /* @__PURE__ */ new WeakMap();
79507
79643
  _currentTarget = /* @__PURE__ */ new WeakMap();
79508
79644
  _destroyed = /* @__PURE__ */ new WeakMap();
79645
+ _useWindowFallback = /* @__PURE__ */ new WeakMap();
79509
79646
  _PresentationInputBridge_instances = /* @__PURE__ */ new WeakSet();
79510
- addListener_fn = function(type2, handler2, target) {
79647
+ addListener_fn = function(type2, handler2, target, useCapture = false) {
79511
79648
  const bound = handler2.bind(this);
79512
- __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target });
79513
- target.addEventListener(type2, bound, true);
79649
+ __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target, useCapture });
79650
+ target.addEventListener(type2, bound, useCapture);
79514
79651
  };
79515
79652
  dispatchToTarget_fn = function(originalEvent, synthetic) {
79516
79653
  if (__privateGet$1(this, _destroyed)) return;
@@ -79531,7 +79668,16 @@ ${l}
79531
79668
  }
79532
79669
  };
79533
79670
  forwardKeyboardEvent_fn = function(event) {
79534
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
79671
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
79672
+ return;
79673
+ }
79674
+ if (event.defaultPrevented) {
79675
+ return;
79676
+ }
79677
+ if (event.isComposing || event.keyCode === 229) {
79678
+ return;
79679
+ }
79680
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isPlainCharacterKey_fn).call(this, event)) {
79535
79681
  return;
79536
79682
  }
79537
79683
  const synthetic = new KeyboardEvent(event.type, {
@@ -79549,26 +79695,40 @@ ${l}
79549
79695
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
79550
79696
  };
79551
79697
  forwardTextEvent_fn = function(event) {
79552
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
79698
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
79553
79699
  return;
79554
79700
  }
79555
- let synthetic;
79556
- if (typeof InputEvent !== "undefined") {
79557
- synthetic = new InputEvent(event.type, {
79558
- data: event.data ?? event.data ?? null,
79559
- inputType: event.inputType ?? "insertText",
79560
- dataTransfer: event.dataTransfer ?? null,
79561
- isComposing: event.isComposing ?? false,
79562
- bubbles: true,
79563
- cancelable: true
79564
- });
79565
- } else {
79566
- synthetic = new Event(event.type, { bubbles: true, cancelable: true });
79701
+ if (event.defaultPrevented) {
79702
+ return;
79567
79703
  }
79568
- __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
79704
+ if (event.isComposing) {
79705
+ return;
79706
+ }
79707
+ queueMicrotask(() => {
79708
+ if (event.defaultPrevented) {
79709
+ return;
79710
+ }
79711
+ let synthetic;
79712
+ if (typeof InputEvent !== "undefined") {
79713
+ synthetic = new InputEvent(event.type, {
79714
+ data: event.data ?? event.data ?? null,
79715
+ inputType: event.inputType ?? "insertText",
79716
+ dataTransfer: event.dataTransfer ?? null,
79717
+ isComposing: event.isComposing ?? false,
79718
+ bubbles: true,
79719
+ cancelable: true
79720
+ });
79721
+ } else {
79722
+ synthetic = new Event(event.type, { bubbles: true, cancelable: true });
79723
+ }
79724
+ __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
79725
+ });
79569
79726
  };
79570
79727
  forwardCompositionEvent_fn = function(event) {
79571
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
79728
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
79729
+ return;
79730
+ }
79731
+ if (event.defaultPrevented) {
79572
79732
  return;
79573
79733
  }
79574
79734
  let synthetic;
@@ -79584,7 +79744,10 @@ ${l}
79584
79744
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
79585
79745
  };
79586
79746
  forwardContextMenu_fn = function(event) {
79587
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
79747
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
79748
+ return;
79749
+ }
79750
+ if (event.defaultPrevented) {
79588
79751
  return;
79589
79752
  }
79590
79753
  const synthetic = new MouseEvent("contextmenu", {
@@ -79618,6 +79781,36 @@ ${l}
79618
79781
  }
79619
79782
  return false;
79620
79783
  };
79784
+ shouldSkipSurface_fn = function(event) {
79785
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
79786
+ return true;
79787
+ }
79788
+ if (!__privateMethod$1(this, _PresentationInputBridge_instances, isInLayoutSurface_fn).call(this, event)) {
79789
+ return true;
79790
+ }
79791
+ if (isInRegisteredSurface(event)) {
79792
+ return true;
79793
+ }
79794
+ return false;
79795
+ };
79796
+ isInLayoutSurface_fn = function(event) {
79797
+ const path2 = typeof event.composedPath === "function" ? event.composedPath() : [];
79798
+ if (path2.length) {
79799
+ return path2.some((node2) => __privateGet$1(this, _layoutSurfaces).has(node2));
79800
+ }
79801
+ const origin = event.target;
79802
+ return origin ? __privateGet$1(this, _layoutSurfaces).has(origin) : false;
79803
+ };
79804
+ getListenerTargets_fn = function() {
79805
+ const targets = new Set(__privateGet$1(this, _layoutSurfaces));
79806
+ if (__privateGet$1(this, _useWindowFallback)) {
79807
+ targets.add(__privateGet$1(this, _windowRoot));
79808
+ }
79809
+ return Array.from(targets);
79810
+ };
79811
+ isPlainCharacterKey_fn = function(event) {
79812
+ return event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
79813
+ };
79621
79814
  const Color = Extension.create({
79622
79815
  name: "color",
79623
79816
  addOptions() {
@@ -82378,29 +82571,6 @@ ${l}
82378
82571
  };
82379
82572
  const defaultTabDistance = 48;
82380
82573
  const defaultLineLength = 816;
82381
- const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
82382
- const decorations = [];
82383
- const paragraphCache = /* @__PURE__ */ new Map();
82384
- const coordCache = /* @__PURE__ */ new Map();
82385
- const domPosCache = /* @__PURE__ */ new Map();
82386
- const end2 = to ?? doc2.content.size;
82387
- doc2.nodesBetween(from2, end2, (node2, pos) => {
82388
- if (node2.type.name !== "tab") return;
82389
- const $pos = doc2.resolve(pos);
82390
- const paragraphContext = findParagraphContext($pos, paragraphCache, helpers2);
82391
- if (!paragraphContext) return;
82392
- const blockParent2 = $pos.node(paragraphContext.paragraphDepth);
82393
- const style2 = calculateTabStyle(node2.nodeSize, view, pos, blockParent2, paragraphContext, coordCache, domPosCache);
82394
- if (style2) {
82395
- decorations.push(
82396
- Decoration.node(pos, pos + node2.nodeSize, {
82397
- style: style2
82398
- })
82399
- );
82400
- }
82401
- });
82402
- return decorations;
82403
- };
82404
82574
  function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext, coordCache = null, domPosCache = null) {
82405
82575
  let extraStyles = "";
82406
82576
  try {
@@ -82452,14 +82622,14 @@ ${l}
82452
82622
  tabWidth -= integralWidth;
82453
82623
  }
82454
82624
  if (tabStop.leader) {
82455
- const leaderStyles = {
82625
+ const leaderStyles2 = {
82456
82626
  dot: "border-bottom: 1px dotted black;",
82457
82627
  heavy: "border-bottom: 2px solid black;",
82458
82628
  hyphen: "border-bottom: 1px solid black;",
82459
82629
  middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
82460
82630
  underscore: "border-bottom: 1px solid black;"
82461
82631
  };
82462
- extraStyles += leaderStyles[tabStop.leader] || "";
82632
+ extraStyles += leaderStyles2[tabStop.leader] || "";
82463
82633
  }
82464
82634
  }
82465
82635
  }
@@ -82471,7 +82641,7 @@ ${l}
82471
82641
  paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
82472
82642
  return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
82473
82643
  } catch (error) {
82474
- console.error("tab decoration error", error);
82644
+ return null;
82475
82645
  }
82476
82646
  }
82477
82647
  function findParagraphContext($pos, cache2, helpers2) {
@@ -82490,13 +82660,16 @@ ${l}
82490
82660
  }
82491
82661
  function extractParagraphContext(node2, startPos, helpers2, depth = 0) {
82492
82662
  const paragraphProperties = getResolvedParagraphProperties(node2);
82663
+ const alignmentAliases = { left: "start", right: "end" };
82493
82664
  let tabStops = [];
82494
82665
  if (Array.isArray(paragraphProperties.tabStops)) {
82495
82666
  tabStops = paragraphProperties.tabStops.map((stop) => {
82496
82667
  const ref2 = stop?.tab;
82497
82668
  if (!ref2) return stop || null;
82669
+ const rawType = ref2.tabType || "start";
82670
+ const mappedVal = alignmentAliases[rawType] || rawType;
82498
82671
  return {
82499
- val: ref2.tabType || "start",
82672
+ val: mappedVal,
82500
82673
  pos: twipsToPixels(Number(ref2.pos) || 0),
82501
82674
  leader: ref2.leader
82502
82675
  };
@@ -83561,6 +83734,184 @@ ${l}
83561
83734
  return [CommentMarkName, Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
83562
83735
  }
83563
83736
  });
83737
+ const leaderStyles = {
83738
+ dot: "border-bottom: 1px dotted black;",
83739
+ heavy: "border-bottom: 2px solid black;",
83740
+ hyphen: "border-bottom: 1px solid black;",
83741
+ middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
83742
+ underscore: "border-bottom: 1px solid black;"
83743
+ };
83744
+ const paragraphIdFromPos = (startPos) => `para-${startPos}`;
83745
+ const tabIdForIndex = (paragraphId, index2) => `${paragraphId}-tab-${index2}`;
83746
+ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, paragraphWidthOverride) {
83747
+ const $pos = doc2.resolve(paragraphPos);
83748
+ const paragraphCache = /* @__PURE__ */ new Map();
83749
+ const paragraphContext = findParagraphContext($pos, paragraphCache, helpers2);
83750
+ if (!paragraphContext) return null;
83751
+ const paragraphId = paragraphIdFromPos(paragraphContext.startPos);
83752
+ const paragraphNode = paragraphContext.paragraph;
83753
+ const { entries } = flattenParagraph(paragraphNode, paragraphContext.startPos);
83754
+ const spans = [];
83755
+ let tabIndex = 0;
83756
+ entries.forEach((entry, idx) => {
83757
+ const node2 = entry.node;
83758
+ const spanId = `${paragraphId}-span-${idx}`;
83759
+ const from2 = entry.pos;
83760
+ const to = entry.pos + node2.nodeSize;
83761
+ if (node2.type.name === "tab") {
83762
+ spans.push({
83763
+ type: "tab",
83764
+ spanId,
83765
+ tabId: tabIdForIndex(paragraphId, tabIndex++),
83766
+ pos: entry.pos,
83767
+ nodeSize: node2.nodeSize
83768
+ });
83769
+ } else if (node2.type.name === "text") {
83770
+ spans.push({
83771
+ type: "text",
83772
+ spanId,
83773
+ text: node2.text || "",
83774
+ style: node2.marks?.find((mark2) => mark2.type.name === "textStyle")?.attrs || {},
83775
+ from: from2,
83776
+ to
83777
+ });
83778
+ }
83779
+ });
83780
+ const tabStops = Array.isArray(paragraphContext.tabStops) ? [...paragraphContext.tabStops] : [];
83781
+ const hangingPx = twipsToPixels(Number(paragraphContext.indent?.hanging) || 0);
83782
+ if (hangingPx > 0 && paragraphContext.indentWidth != null) {
83783
+ tabStops.unshift({ val: "start", pos: paragraphContext.indentWidth + hangingPx, leader: "none" });
83784
+ }
83785
+ const paragraphWidth = getBlockNodeWidth(view, paragraphContext.startPos) ?? defaultLineLength;
83786
+ const indentWidth = paragraphContext.indentWidth ?? getIndentWidth(view, paragraphContext.startPos, paragraphContext.indent);
83787
+ return {
83788
+ paragraphId,
83789
+ revision,
83790
+ paragraphWidth,
83791
+ defaultTabDistance,
83792
+ defaultLineLength,
83793
+ indents: {
83794
+ left: twipsToPixels(Number(paragraphContext.indent?.left) || 0),
83795
+ right: twipsToPixels(Number(paragraphContext.indent?.right) || 0),
83796
+ firstLine: twipsToPixels(Number(paragraphContext.indent?.firstLine) || 0),
83797
+ hanging: hangingPx
83798
+ },
83799
+ tabStops,
83800
+ spans,
83801
+ indentWidth,
83802
+ paragraphNode
83803
+ };
83804
+ }
83805
+ function calculateTabLayout(request, measurement, view) {
83806
+ const {
83807
+ spans,
83808
+ tabStops,
83809
+ paragraphWidth,
83810
+ defaultTabDistance: defaultTabDistance2,
83811
+ defaultLineLength: defaultLineLength2,
83812
+ paragraphId,
83813
+ revision,
83814
+ indentWidth = 0,
83815
+ paragraphNode
83816
+ } = request;
83817
+ const tabs = {};
83818
+ let currentX = indentWidth;
83819
+ const measureText2 = (span) => {
83820
+ if (view && typeof span.from === "number" && typeof span.to === "number") {
83821
+ return measureRangeWidth(view, span.from, span.to);
83822
+ }
83823
+ return 0;
83824
+ };
83825
+ const tabHeight = paragraphNode ? calcTabHeight(paragraphNode) : void 0;
83826
+ for (let i2 = 0; i2 < spans.length; i2++) {
83827
+ const span = spans[i2];
83828
+ if (span.type === "text") {
83829
+ currentX += measureText2(span);
83830
+ } else if (span.type === "tab") {
83831
+ const followingText = collectFollowingText(spans, i2 + 1);
83832
+ let measureTextCallback;
83833
+ if (view) {
83834
+ const followingRange = getFollowingTextRange(spans, i2 + 1);
83835
+ if (followingRange) {
83836
+ const fullWidth = measureRangeWidth(view, followingRange.from, followingRange.to);
83837
+ const fullText = followingText;
83838
+ measureTextCallback = (text2) => {
83839
+ if (text2 === fullText) return fullWidth;
83840
+ if (fullText.length > 0) {
83841
+ return text2.length / fullText.length * fullWidth;
83842
+ }
83843
+ return 0;
83844
+ };
83845
+ }
83846
+ }
83847
+ const result = calculateTabWidth({
83848
+ currentX,
83849
+ tabStops,
83850
+ paragraphWidth,
83851
+ defaultTabDistance: defaultTabDistance2,
83852
+ defaultLineLength: defaultLineLength2,
83853
+ followingText,
83854
+ measureText: measureTextCallback
83855
+ });
83856
+ tabs[span.tabId] = {
83857
+ width: result.width,
83858
+ height: tabHeight,
83859
+ leader: result.leader,
83860
+ alignment: result.alignment,
83861
+ tabStopPosUsed: result.tabStopPosUsed
83862
+ };
83863
+ currentX += result.width;
83864
+ }
83865
+ }
83866
+ return {
83867
+ paragraphId,
83868
+ revision,
83869
+ tabs
83870
+ };
83871
+ }
83872
+ function applyLayoutResult(result, paragraph2, paragraphPos) {
83873
+ const decorations = [];
83874
+ let tabIndex = 0;
83875
+ paragraph2.forEach((node2, offset2) => {
83876
+ if (node2.type.name !== "tab") return;
83877
+ const pos = paragraphPos + offset2 + 1;
83878
+ const tabId = tabIdForIndex(result.paragraphId, tabIndex++);
83879
+ const layout = result.tabs[tabId];
83880
+ if (!layout) return;
83881
+ let style2 = `width: ${layout.width}px;`;
83882
+ if (layout.height) style2 += ` height: ${layout.height};`;
83883
+ if (layout.leader && leaderStyles[layout.leader]) {
83884
+ style2 += ` ${leaderStyles[layout.leader]}`;
83885
+ }
83886
+ decorations.push(Decoration.node(pos, pos + node2.nodeSize, { style: style2 }));
83887
+ });
83888
+ return decorations;
83889
+ }
83890
+ function collectFollowingText(spans, startIndex) {
83891
+ let text2 = "";
83892
+ for (let i2 = startIndex; i2 < spans.length; i2++) {
83893
+ const span = spans[i2];
83894
+ if (span.type === "tab") break;
83895
+ if (span.type === "text") text2 += span.text || "";
83896
+ }
83897
+ return text2;
83898
+ }
83899
+ function getFollowingTextRange(spans, startIndex) {
83900
+ let from2 = null;
83901
+ let to = null;
83902
+ for (let i2 = startIndex; i2 < spans.length; i2++) {
83903
+ const span = spans[i2];
83904
+ if (span.type === "tab") break;
83905
+ if (span.type === "text" && typeof span.from === "number" && typeof span.to === "number") {
83906
+ if (from2 === null) from2 = span.from;
83907
+ to = span.to;
83908
+ }
83909
+ }
83910
+ if (from2 !== null && to !== null) {
83911
+ return { from: from2, to };
83912
+ }
83913
+ return null;
83914
+ }
83564
83915
  const TabNode = Node$1.create({
83565
83916
  name: "tab",
83566
83917
  group: "inline",
@@ -83602,87 +83953,24 @@ ${l}
83602
83953
  return [];
83603
83954
  }
83604
83955
  const { view, helpers: helpers2 } = this.editor;
83605
- const mergeRanges2 = (ranges) => {
83606
- if (ranges.length === 0) return [];
83607
- const sorted = ranges.slice().sort((a2, b2) => a2[0] - b2[0]);
83608
- const merged = [sorted[0]];
83609
- for (let i2 = 1; i2 < sorted.length; i2++) {
83610
- const [start2, end2] = sorted[i2];
83611
- const last = merged[merged.length - 1];
83612
- if (start2 <= last[1]) {
83613
- last[1] = Math.max(last[1], end2);
83614
- } else {
83615
- merged.push([start2, end2]);
83616
- }
83617
- }
83618
- return merged;
83619
- };
83620
83956
  const tabPlugin = new Plugin({
83621
83957
  name: "tabPlugin",
83622
83958
  key: new PluginKey("tabPlugin"),
83623
83959
  state: {
83624
83960
  init() {
83625
- return { decorations: false };
83961
+ return { decorations: false, revision: 0 };
83626
83962
  },
83627
- apply(tr, { decorations }, _oldState, newState) {
83963
+ apply(tr, { decorations, revision }, _oldState, newState) {
83628
83964
  if (!decorations) {
83629
- decorations = DecorationSet.create(newState.doc, getTabDecorations(newState.doc, view, helpers2));
83630
- return { decorations };
83965
+ const newDecorations2 = buildDecorations(newState.doc, view, helpers2, 0);
83966
+ return { decorations: newDecorations2, revision: 0 };
83631
83967
  }
83632
83968
  if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
83633
- return { decorations };
83969
+ return { decorations, revision };
83634
83970
  }
83635
- decorations = decorations.map(tr.mapping, tr.doc);
83636
- const rangesToRecalculate = [];
83637
- const containsTab = (node2) => node2.type.name === "tab";
83638
- tr.steps.forEach((step, index2) => {
83639
- if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1)) {
83640
- return;
83641
- }
83642
- let hasTabInRange = false;
83643
- if (step.slice?.content) {
83644
- step.slice.content.descendants((node2) => {
83645
- if (containsTab(node2)) {
83646
- hasTabInRange = true;
83647
- return false;
83648
- }
83649
- });
83650
- }
83651
- if (!hasTabInRange) {
83652
- tr.docs[index2].nodesBetween(step.from, step.to, (node2) => {
83653
- if (containsTab(node2)) {
83654
- hasTabInRange = true;
83655
- return false;
83656
- }
83657
- });
83658
- }
83659
- if (!hasTabInRange) {
83660
- return;
83661
- }
83662
- let fromPos = step.from;
83663
- let toPos = step.to;
83664
- for (let i2 = index2; i2 < tr.steps.length; i2++) {
83665
- const stepMap = tr.steps[i2].getMap();
83666
- fromPos = stepMap.map(fromPos, -1);
83667
- toPos = stepMap.map(toPos, 1);
83668
- }
83669
- const $from = newState.doc.resolve(fromPos);
83670
- const $to = newState.doc.resolve(toPos);
83671
- const start2 = $from.start(Math.min($from.depth, 1));
83672
- const end2 = $to.end(Math.min($to.depth, 1));
83673
- rangesToRecalculate.push([start2, end2]);
83674
- });
83675
- if (rangesToRecalculate.length === 0) {
83676
- return { decorations };
83677
- }
83678
- const mergedRanges = mergeRanges2(rangesToRecalculate);
83679
- mergedRanges.forEach(([start2, end2]) => {
83680
- const oldDecorations = decorations.find(start2, end2);
83681
- decorations = decorations.remove(oldDecorations);
83682
- const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
83683
- decorations = decorations.add(newState.doc, newDecorations);
83684
- });
83685
- return { decorations };
83971
+ const nextRevision = revision + 1;
83972
+ const newDecorations = buildDecorations(newState.doc, view, helpers2, nextRevision);
83973
+ return { decorations: newDecorations, revision: nextRevision };
83686
83974
  }
83687
83975
  },
83688
83976
  props: {
@@ -83694,6 +83982,27 @@ ${l}
83694
83982
  return [tabPlugin];
83695
83983
  }
83696
83984
  });
83985
+ function buildDecorations(doc2, view, helpers2, revision) {
83986
+ const decorations = [];
83987
+ doc2.descendants((node2, pos) => {
83988
+ if (node2.type.name !== "paragraph") return;
83989
+ let hasTab = false;
83990
+ node2.descendants((child) => {
83991
+ if (child.type.name === "tab") {
83992
+ hasTab = true;
83993
+ return false;
83994
+ }
83995
+ return true;
83996
+ });
83997
+ if (!hasTab) return;
83998
+ const request = createLayoutRequest(doc2, pos + 1, view, helpers2, revision);
83999
+ if (!request) return;
84000
+ const result = calculateTabLayout(request, void 0, view);
84001
+ const paragraphDecorations = applyLayoutResult(result, node2, pos);
84002
+ decorations.push(...paragraphDecorations);
84003
+ });
84004
+ return DecorationSet.create(doc2, decorations);
84005
+ }
83697
84006
  const LineBreak = Node$1.create({
83698
84007
  name: "lineBreak",
83699
84008
  group: "inline",
@@ -107889,7 +108198,8 @@ ${style2}
107889
108198
  class: "superdoc-toolbar",
107890
108199
  key: unref(toolbarKey),
107891
108200
  role: "toolbar",
107892
- "aria-label": "Toolbar"
108201
+ "aria-label": "Toolbar",
108202
+ "data-editor-ui-surface": ""
107893
108203
  }, [
107894
108204
  unref(showLeftSide) ? (openBlock(), createBlock(ButtonGroup, {
107895
108205
  key: 0,
@@ -107921,7 +108231,7 @@ ${style2}
107921
108231
  };
107922
108232
  }
107923
108233
  };
107924
- const Toolbar = /* @__PURE__ */ _export_sfc$1(_sfc_main$k, [["__scopeId", "data-v-639f50b4"]]);
108234
+ const Toolbar = /* @__PURE__ */ _export_sfc$1(_sfc_main$k, [["__scopeId", "data-v-3f5ec271"]]);
107925
108235
  const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
107926
108236
  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: ";
107927
108237
  async function baseInsightsFetch(payload, options = {}) {
@@ -108933,7 +109243,8 @@ ${style2}
108933
109243
  const DocumentMode = /* @__PURE__ */ _export_sfc$1(_sfc_main$e$1, [["__scopeId", "data-v-8730b752"]]);
108934
109244
  const _hoisted_1$c$1 = {
108935
109245
  key: 0,
108936
- class: "linked-style-buttons"
109246
+ class: "linked-style-buttons",
109247
+ "data-editor-ui-surface": ""
108937
109248
  };
108938
109249
  const _hoisted_2$8$1 = ["onClick", "onKeydown", "aria-label"];
108939
109250
  const _sfc_main$d$1 = {
@@ -109012,7 +109323,7 @@ ${style2}
109012
109323
  };
109013
109324
  }
109014
109325
  };
109015
- const LinkedStyle = /* @__PURE__ */ _export_sfc$1(_sfc_main$d$1, [["__scopeId", "data-v-b53508a8"]]);
109326
+ const LinkedStyle = /* @__PURE__ */ _export_sfc$1(_sfc_main$d$1, [["__scopeId", "data-v-ecb78965"]]);
109016
109327
  const _hoisted_1$b$1 = {
109017
109328
  key: 0,
109018
109329
  class: "link-title"
@@ -111678,14 +111989,19 @@ ${style2}
111678
111989
  });
111679
111990
  };
111680
111991
  updateToolbarHistory_fn = function() {
111681
- if (!this.activeEditor) return;
111682
- if (this.activeEditor.options.ydoc) {
111683
- const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
111684
- this.undoDepth = undoManager?.undoStack.length || 0;
111685
- this.redoDepth = undoManager?.redoStack.length || 0;
111686
- } else {
111687
- this.undoDepth = undoDepth(this.activeEditor.state);
111688
- this.redoDepth = redoDepth(this.activeEditor.state);
111992
+ if (!this.activeEditor?.state) return;
111993
+ try {
111994
+ if (this.activeEditor.options.ydoc) {
111995
+ const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
111996
+ this.undoDepth = undoManager?.undoStack.length || 0;
111997
+ this.redoDepth = undoManager?.redoStack.length || 0;
111998
+ } else {
111999
+ this.undoDepth = undoDepth(this.activeEditor.state);
112000
+ this.redoDepth = redoDepth(this.activeEditor.state);
112001
+ }
112002
+ } catch {
112003
+ this.undoDepth = 0;
112004
+ this.redoDepth = 0;
111689
112005
  }
111690
112006
  };
111691
112007
  enrichTrackedChanges_fn = function(trackedChanges = []) {
@@ -131214,7 +131530,7 @@ ${style2}
131214
131530
  this.config.colors = shuffleArray(this.config.colors);
131215
131531
  this.userColorMap = /* @__PURE__ */ new Map();
131216
131532
  this.colorIndex = 0;
131217
- this.version = "1.0.0-beta.5";
131533
+ this.version = "1.0.0-beta.7";
131218
131534
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
131219
131535
  this.superdocId = config2.superdocId || v4();
131220
131536
  this.colors = this.config.colors;
@@ -133657,7 +133973,7 @@ ${style2}
133657
133973
  value && typeof value === "object" && "byteLength" in value && "byteOffset" in value
133658
133974
  );
133659
133975
  }
133660
- const indexD653XgvV = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
133976
+ const indexDV613LhK = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
133661
133977
  __proto__: null,
133662
133978
  unified
133663
133979
  }, Symbol.toStringTag, { value: "Module" }));