@harbour-enterprises/superdoc 1.0.0-beta.6 → 1.0.0-beta.8

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-CdGAVn-4.es.js → PdfViewer-BfEwF25T.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-DmPiOFJ8.cjs → PdfViewer-DJ7BWUbW.cjs} +1 -1
  3. package/dist/chunks/{index-nXifzD54.es.js → index-BCZ82zY5.es.js} +3 -3
  4. package/dist/chunks/{index-hjUbJ86s-BLl65XJn.cjs → index-DJrRlj1_-E5dmStMF.cjs} +1 -1
  5. package/dist/chunks/{index-hjUbJ86s-BMiwCR8J.es.js → index-DJrRlj1_-HA-nVwDO.es.js} +1 -1
  6. package/dist/chunks/{index-QulG3CF7.cjs → index-DMwWcmrk.cjs} +3 -3
  7. package/dist/chunks/{super-editor.es-0GatZWs9.cjs → super-editor.es-Bo_fWMy6.cjs} +281 -83
  8. package/dist/chunks/{super-editor.es-BYVEYLjl.es.js → super-editor.es-MRWI4sfo.es.js} +281 -83
  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-CZF9SnYh.js → converter-CflxlFnM.js} +1 -1
  13. package/dist/super-editor/chunks/{docx-zipper-DWypbE0V.js → docx-zipper-DKWL4mo2.js} +1 -1
  14. package/dist/super-editor/chunks/{editor-BdXHlHt-.js → editor-B9V7oJbW.js} +351 -93
  15. package/dist/super-editor/chunks/{index-hjUbJ86s.js → index-DJrRlj1_.js} +1 -1
  16. package/dist/super-editor/chunks/{toolbar-CmelvLTd.js → toolbar-B5WlPN4s.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 +9 -8
  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 +283 -85
  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.6") {
35583
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.8") {
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.6";
52290
+ const summaryVersion = "1.0.0-beta.8";
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-hjUbJ86s-BLl65XJn.cjs")),
53069
+ Promise.resolve().then(() => require("./index-DJrRlj1_-E5dmStMF.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.6");
53274
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.8");
53275
53275
  if (!this.options.ydoc) return;
53276
53276
  const metaMap = this.options.ydoc.getMap("meta");
53277
53277
  let docVersion = metaMap.get("version");
@@ -56823,8 +56823,6 @@ function calculateTabWidth(params2) {
56823
56823
  const beforeWidth = measureText2 ? measureText2(before) : 0;
56824
56824
  width -= beforeWidth;
56825
56825
  }
56826
- } else if (alignment2 === "bar") {
56827
- width = 0;
56828
56826
  }
56829
56827
  if (width < 1) {
56830
56828
  return fallbackWidth();
@@ -61867,14 +61865,14 @@ function measureRunSliceWidth(run2, fromChar, toChar) {
61867
61865
  return metrics.width;
61868
61866
  }
61869
61867
  function lineHeightForRuns(runs, fromRun, toRun) {
61870
- let maxSize = 0;
61868
+ let maxSize2 = 0;
61871
61869
  for (let i = fromRun; i <= toRun; i += 1) {
61872
61870
  const run2 = runs[i];
61873
61871
  const textRun = run2 && isTextRun(run2) ? run2 : null;
61874
61872
  const size2 = textRun?.fontSize ?? 16;
61875
- if (size2 > maxSize) maxSize = size2;
61873
+ if (size2 > maxSize2) maxSize2 = size2;
61876
61874
  }
61877
- return maxSize * 1.2;
61875
+ return maxSize2 * 1.2;
61878
61876
  }
61879
61877
  function remeasureParagraph(block, maxWidth) {
61880
61878
  const runs = block.runs ?? [];
@@ -67477,6 +67475,45 @@ function normalizeRotation(rotation) {
67477
67475
  function degToRad(degrees) {
67478
67476
  return degrees * Math.PI / 180;
67479
67477
  }
67478
+ const defaultMaxSize = 5e3;
67479
+ let maxSize = defaultMaxSize;
67480
+ const cache$1 = /* @__PURE__ */ new Map();
67481
+ const makeKey = (text, font, letterSpacing) => {
67482
+ return `${text}|${font}|${letterSpacing || 0}`;
67483
+ };
67484
+ function getMeasuredTextWidth(text, font, letterSpacing, ctx2) {
67485
+ if (text.length > 32e3) {
67486
+ text = text.substring(0, 32e3);
67487
+ }
67488
+ const key2 = makeKey(text, font, letterSpacing);
67489
+ const hit = cache$1.get(key2);
67490
+ if (hit !== void 0) {
67491
+ cache$1.delete(key2);
67492
+ cache$1.set(key2, hit);
67493
+ return hit.width;
67494
+ }
67495
+ try {
67496
+ ctx2.font = font;
67497
+ const metrics = ctx2.measureText(text);
67498
+ const advanceWidth = metrics.width;
67499
+ const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
67500
+ const baseWidth = Math.max(advanceWidth, paintedWidth);
67501
+ const extra = letterSpacing ? Math.max(0, text.length - 1) * letterSpacing : 0;
67502
+ const width = baseWidth + extra;
67503
+ cache$1.set(key2, { width });
67504
+ evictIfNeeded();
67505
+ return width;
67506
+ } catch {
67507
+ return 0;
67508
+ }
67509
+ }
67510
+ function evictIfNeeded() {
67511
+ while (cache$1.size > maxSize) {
67512
+ const oldestKey = cache$1.keys().next().value;
67513
+ if (oldestKey === void 0) break;
67514
+ cache$1.delete(oldestKey);
67515
+ }
67516
+ }
67480
67517
  const { computeTabStops } = Engines;
67481
67518
  let canvasContext = null;
67482
67519
  const DEFAULT_TAB_INTERVAL_TWIPS = 720;
@@ -67521,8 +67558,7 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
67521
67558
  const metrics = ctx2.measureText(text);
67522
67559
  const advanceWidth = metrics.width;
67523
67560
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
67524
- const baseWidth = Math.max(advanceWidth, paintedWidth);
67525
- return baseWidth;
67561
+ return Math.max(advanceWidth, paintedWidth);
67526
67562
  }
67527
67563
  const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
67528
67564
  function calculateTypographyMetrics(fontSize2, spacing) {
@@ -68103,13 +68139,9 @@ const getPrimaryRun = (paragraph) => {
68103
68139
  };
68104
68140
  };
68105
68141
  const measureRunWidth = (text, font, ctx2, run2) => {
68106
- const baseWidth = measureText(text, font, ctx2);
68107
- const letterSpacing = run2.kind !== "tab" ? run2.letterSpacing : void 0;
68108
- if (!letterSpacing) {
68109
- return baseWidth;
68110
- }
68111
- const extra = Math.max(0, text.length - 1) * letterSpacing;
68112
- return roundValue(baseWidth + extra);
68142
+ const letterSpacing = run2.kind !== "tab" ? run2.letterSpacing || 0 : 0;
68143
+ const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
68144
+ return roundValue(width);
68113
68145
  };
68114
68146
  const appendSegment = (segments, runIndex, fromChar, toChar, width, x2) => {
68115
68147
  if (!segments) return;
@@ -68983,6 +69015,24 @@ getConverterContext_fn = function() {
68983
69015
  }
68984
69016
  return Object.keys(context).length > 0 ? context : void 0;
68985
69017
  };
69018
+ const uiSurfaces = /* @__PURE__ */ new WeakSet();
69019
+ function isInRegisteredSurface(event) {
69020
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
69021
+ if (path.length > 0) {
69022
+ for (const node2 of path) {
69023
+ if (uiSurfaces.has(node2)) return true;
69024
+ if (node2?.hasAttribute?.("data-editor-ui-surface")) return true;
69025
+ }
69026
+ return false;
69027
+ }
69028
+ let node = event.target;
69029
+ while (node) {
69030
+ if (uiSurfaces.has(node)) return true;
69031
+ if (node.hasAttribute?.("data-editor-ui-surface")) return true;
69032
+ node = node.parentElement;
69033
+ }
69034
+ return false;
69035
+ }
68986
69036
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
68987
69037
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
68988
69038
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -71759,39 +71809,49 @@ _PresentationEditor.CURSOR_STYLES = {
71759
71809
  };
71760
71810
  let PresentationEditor = _PresentationEditor;
71761
71811
  class PresentationInputBridge {
71762
- constructor(windowRoot, visibleHost, getTargetDom, onTargetChanged) {
71812
+ constructor(windowRoot, layoutSurface, getTargetDom, onTargetChanged, options) {
71763
71813
  __privateAdd$1(this, _PresentationInputBridge_instances);
71764
71814
  __privateAdd$1(this, _windowRoot);
71765
- __privateAdd$1(this, _visibleHost2);
71815
+ __privateAdd$1(this, _layoutSurfaces);
71766
71816
  __privateAdd$1(this, _getTargetDom);
71767
71817
  __privateAdd$1(this, _onTargetChanged);
71768
71818
  __privateAdd$1(this, _listeners);
71769
71819
  __privateAdd$1(this, _currentTarget, null);
71770
71820
  __privateAdd$1(this, _destroyed, false);
71821
+ __privateAdd$1(this, _useWindowFallback);
71771
71822
  __privateSet(this, _windowRoot, windowRoot);
71772
- __privateSet(this, _visibleHost2, visibleHost);
71823
+ __privateSet(this, _layoutSurfaces, /* @__PURE__ */ new Set([layoutSurface]));
71773
71824
  __privateSet(this, _getTargetDom, getTargetDom);
71774
71825
  __privateSet(this, _onTargetChanged, onTargetChanged);
71775
71826
  __privateSet(this, _listeners, []);
71827
+ __privateSet(this, _useWindowFallback, options?.useWindowFallback ?? false);
71776
71828
  }
71777
71829
  bind() {
71778
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71779
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keypress", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71780
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71781
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71782
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71783
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71784
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), __privateGet$1(this, _windowRoot));
71785
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71786
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71787
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71788
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71789
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71790
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71830
+ const keyboardTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71831
+ keyboardTargets.forEach((target) => {
71832
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
71833
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
71834
+ });
71835
+ const compositionTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71836
+ compositionTargets.forEach((target) => {
71837
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71838
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71839
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71840
+ });
71841
+ const textTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71842
+ textTargets.forEach((target) => {
71843
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71844
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71845
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71846
+ });
71847
+ const contextTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71848
+ contextTargets.forEach((target) => {
71849
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), target);
71850
+ });
71791
71851
  }
71792
71852
  destroy() {
71793
- __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target }) => {
71794
- target.removeEventListener(type2, handler2, true);
71853
+ __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target, useCapture }) => {
71854
+ target.removeEventListener(type2, handler2, useCapture);
71795
71855
  });
71796
71856
  __privateSet(this, _listeners, []);
71797
71857
  __privateSet(this, _currentTarget, null);
@@ -71826,17 +71886,18 @@ class PresentationInputBridge {
71826
71886
  }
71827
71887
  }
71828
71888
  _windowRoot = /* @__PURE__ */ new WeakMap();
71829
- _visibleHost2 = /* @__PURE__ */ new WeakMap();
71889
+ _layoutSurfaces = /* @__PURE__ */ new WeakMap();
71830
71890
  _getTargetDom = /* @__PURE__ */ new WeakMap();
71831
71891
  _onTargetChanged = /* @__PURE__ */ new WeakMap();
71832
71892
  _listeners = /* @__PURE__ */ new WeakMap();
71833
71893
  _currentTarget = /* @__PURE__ */ new WeakMap();
71834
71894
  _destroyed = /* @__PURE__ */ new WeakMap();
71895
+ _useWindowFallback = /* @__PURE__ */ new WeakMap();
71835
71896
  _PresentationInputBridge_instances = /* @__PURE__ */ new WeakSet();
71836
- addListener_fn = function(type2, handler2, target) {
71897
+ addListener_fn = function(type2, handler2, target, useCapture = false) {
71837
71898
  const bound = handler2.bind(this);
71838
- __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target });
71839
- target.addEventListener(type2, bound, true);
71899
+ __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target, useCapture });
71900
+ target.addEventListener(type2, bound, useCapture);
71840
71901
  };
71841
71902
  dispatchToTarget_fn = function(originalEvent, synthetic) {
71842
71903
  if (__privateGet$1(this, _destroyed)) return;
@@ -71857,7 +71918,16 @@ dispatchToTarget_fn = function(originalEvent, synthetic) {
71857
71918
  }
71858
71919
  };
71859
71920
  forwardKeyboardEvent_fn = function(event) {
71860
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71921
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71922
+ return;
71923
+ }
71924
+ if (event.defaultPrevented) {
71925
+ return;
71926
+ }
71927
+ if (event.isComposing || event.keyCode === 229) {
71928
+ return;
71929
+ }
71930
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isPlainCharacterKey_fn).call(this, event)) {
71861
71931
  return;
71862
71932
  }
71863
71933
  const synthetic = new KeyboardEvent(event.type, {
@@ -71875,26 +71945,40 @@ forwardKeyboardEvent_fn = function(event) {
71875
71945
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71876
71946
  };
71877
71947
  forwardTextEvent_fn = function(event) {
71878
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71948
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71879
71949
  return;
71880
71950
  }
71881
- let synthetic;
71882
- if (typeof InputEvent !== "undefined") {
71883
- synthetic = new InputEvent(event.type, {
71884
- data: event.data ?? event.data ?? null,
71885
- inputType: event.inputType ?? "insertText",
71886
- dataTransfer: event.dataTransfer ?? null,
71887
- isComposing: event.isComposing ?? false,
71888
- bubbles: true,
71889
- cancelable: true
71890
- });
71891
- } else {
71892
- synthetic = new Event(event.type, { bubbles: true, cancelable: true });
71951
+ if (event.defaultPrevented) {
71952
+ return;
71893
71953
  }
71894
- __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71954
+ if (event.isComposing) {
71955
+ return;
71956
+ }
71957
+ queueMicrotask(() => {
71958
+ if (event.defaultPrevented) {
71959
+ return;
71960
+ }
71961
+ let synthetic;
71962
+ if (typeof InputEvent !== "undefined") {
71963
+ synthetic = new InputEvent(event.type, {
71964
+ data: event.data ?? event.data ?? null,
71965
+ inputType: event.inputType ?? "insertText",
71966
+ dataTransfer: event.dataTransfer ?? null,
71967
+ isComposing: event.isComposing ?? false,
71968
+ bubbles: true,
71969
+ cancelable: true
71970
+ });
71971
+ } else {
71972
+ synthetic = new Event(event.type, { bubbles: true, cancelable: true });
71973
+ }
71974
+ __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71975
+ });
71895
71976
  };
71896
71977
  forwardCompositionEvent_fn = function(event) {
71897
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71978
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71979
+ return;
71980
+ }
71981
+ if (event.defaultPrevented) {
71898
71982
  return;
71899
71983
  }
71900
71984
  let synthetic;
@@ -71910,7 +71994,10 @@ forwardCompositionEvent_fn = function(event) {
71910
71994
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71911
71995
  };
71912
71996
  forwardContextMenu_fn = function(event) {
71913
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71997
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71998
+ return;
71999
+ }
72000
+ if (event.defaultPrevented) {
71914
72001
  return;
71915
72002
  }
71916
72003
  const synthetic = new MouseEvent("contextmenu", {
@@ -71944,6 +72031,36 @@ isEventOnActiveTarget_fn = function(event) {
71944
72031
  }
71945
72032
  return false;
71946
72033
  };
72034
+ shouldSkipSurface_fn = function(event) {
72035
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
72036
+ return true;
72037
+ }
72038
+ if (!__privateMethod$1(this, _PresentationInputBridge_instances, isInLayoutSurface_fn).call(this, event)) {
72039
+ return true;
72040
+ }
72041
+ if (isInRegisteredSurface(event)) {
72042
+ return true;
72043
+ }
72044
+ return false;
72045
+ };
72046
+ isInLayoutSurface_fn = function(event) {
72047
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
72048
+ if (path.length) {
72049
+ return path.some((node) => __privateGet$1(this, _layoutSurfaces).has(node));
72050
+ }
72051
+ const origin = event.target;
72052
+ return origin ? __privateGet$1(this, _layoutSurfaces).has(origin) : false;
72053
+ };
72054
+ getListenerTargets_fn = function() {
72055
+ const targets = new Set(__privateGet$1(this, _layoutSurfaces));
72056
+ if (__privateGet$1(this, _useWindowFallback)) {
72057
+ targets.add(__privateGet$1(this, _windowRoot));
72058
+ }
72059
+ return Array.from(targets);
72060
+ };
72061
+ isPlainCharacterKey_fn = function(event) {
72062
+ return event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
72063
+ };
71947
72064
  const Color = Extension.create({
71948
72065
  name: "color",
71949
72066
  addOptions() {
@@ -74773,7 +74890,7 @@ function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext,
74773
74890
  const tabHeight = paragraphContext.tabHeight;
74774
74891
  paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
74775
74892
  return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
74776
- } catch (error) {
74893
+ } catch {
74777
74894
  return null;
74778
74895
  }
74779
74896
  }
@@ -75867,6 +75984,19 @@ const CommentsMark = Mark2.create({
75867
75984
  return [CommentMarkName, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
75868
75985
  }
75869
75986
  });
75987
+ let cache$2 = /* @__PURE__ */ new WeakMap();
75988
+ function getParagraphContext(paragraph, startPos, helpers2, revision, compute) {
75989
+ const cached = cache$2.get(paragraph);
75990
+ if (cached && cached.revision === revision) {
75991
+ return cached.context;
75992
+ }
75993
+ const context = compute(paragraph, startPos, helpers2);
75994
+ cache$2.set(paragraph, { revision, context });
75995
+ return context;
75996
+ }
75997
+ function clearAllParagraphContexts() {
75998
+ cache$2 = /* @__PURE__ */ new WeakMap();
75999
+ }
75870
76000
  const leaderStyles = {
75871
76001
  dot: "border-bottom: 1px dotted black;",
75872
76002
  heavy: "border-bottom: 2px solid black;",
@@ -75883,6 +76013,14 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
75883
76013
  if (!paragraphContext) return null;
75884
76014
  const paragraphId = paragraphIdFromPos(paragraphContext.startPos);
75885
76015
  const paragraphNode = paragraphContext.paragraph;
76016
+ const cachedContext = getParagraphContext(
76017
+ paragraphNode,
76018
+ paragraphContext.startPos,
76019
+ helpers2,
76020
+ revision,
76021
+ () => extractParagraphContext(paragraphNode, paragraphContext.startPos, helpers2, paragraphContext.paragraphDepth)
76022
+ );
76023
+ const effectiveContext = cachedContext || paragraphContext;
75886
76024
  const { entries } = flattenParagraph(paragraphNode, paragraphContext.startPos);
75887
76025
  const spans = [];
75888
76026
  let tabIndex = 0;
@@ -75910,13 +76048,13 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
75910
76048
  });
75911
76049
  }
75912
76050
  });
75913
- const tabStops = Array.isArray(paragraphContext.tabStops) ? [...paragraphContext.tabStops] : [];
75914
- const hangingPx = twipsToPixels(Number(paragraphContext.indent?.hanging) || 0);
75915
- if (hangingPx > 0 && paragraphContext.indentWidth != null) {
75916
- tabStops.unshift({ val: "start", pos: paragraphContext.indentWidth + hangingPx, leader: "none" });
76051
+ const tabStops = Array.isArray(effectiveContext.tabStops) ? [...effectiveContext.tabStops] : [];
76052
+ const hangingPx = twipsToPixels(Number(effectiveContext.indent?.hanging) || 0);
76053
+ if (hangingPx > 0 && effectiveContext.indentWidth != null) {
76054
+ tabStops.unshift({ val: "start", pos: effectiveContext.indentWidth + hangingPx, leader: "none" });
75917
76055
  }
75918
- const paragraphWidth = getBlockNodeWidth(view, paragraphContext.startPos) ?? defaultLineLength;
75919
- const indentWidth = paragraphContext.indentWidth ?? getIndentWidth(view, paragraphContext.startPos, paragraphContext.indent);
76056
+ const paragraphWidth = getBlockNodeWidth(view, effectiveContext.startPos) ?? defaultLineLength;
76057
+ const indentWidth = effectiveContext.indentWidth ?? getIndentWidth(view, effectiveContext.startPos, effectiveContext.indent);
75920
76058
  return {
75921
76059
  paragraphId,
75922
76060
  revision,
@@ -75924,9 +76062,9 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
75924
76062
  defaultTabDistance,
75925
76063
  defaultLineLength,
75926
76064
  indents: {
75927
- left: twipsToPixels(Number(paragraphContext.indent?.left) || 0),
75928
- right: twipsToPixels(Number(paragraphContext.indent?.right) || 0),
75929
- firstLine: twipsToPixels(Number(paragraphContext.indent?.firstLine) || 0),
76065
+ left: twipsToPixels(Number(effectiveContext.indent?.left) || 0),
76066
+ right: twipsToPixels(Number(effectiveContext.indent?.right) || 0),
76067
+ firstLine: twipsToPixels(Number(effectiveContext.indent?.firstLine) || 0),
75930
76068
  hanging: hangingPx
75931
76069
  },
75932
76070
  tabStops,
@@ -76091,31 +76229,58 @@ const TabNode = Node$1.create({
76091
76229
  key: new PluginKey("tabPlugin"),
76092
76230
  state: {
76093
76231
  init() {
76094
- return { decorations: false, revision: 0 };
76232
+ const initialDecorations = buildInitialDecorations(view.state.doc, view, helpers2, 0);
76233
+ return { decorations: initialDecorations, revision: 0 };
76095
76234
  },
76096
76235
  apply(tr, { decorations, revision }, _oldState, newState) {
76097
- if (!decorations) {
76098
- const newDecorations2 = buildDecorations(newState.doc, view, helpers2, 0);
76099
- return { decorations: newDecorations2, revision: 0 };
76100
- }
76236
+ const currentDecorations = decorations && decorations.map ? decorations.map(tr.mapping, tr.doc) : DecorationSet.empty;
76101
76237
  if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
76102
- return { decorations, revision };
76103
- }
76104
- const nextRevision = revision + 1;
76105
- const newDecorations = buildDecorations(newState.doc, view, helpers2, nextRevision);
76106
- return { decorations: newDecorations, revision: nextRevision };
76238
+ return { decorations: currentDecorations, revision };
76239
+ }
76240
+ const affectedParagraphs = getAffectedParagraphStarts(tr, newState);
76241
+ if (affectedParagraphs.size === 0) {
76242
+ return { decorations: currentDecorations, revision };
76243
+ }
76244
+ let nextDecorations = currentDecorations;
76245
+ affectedParagraphs.forEach((pos) => {
76246
+ const paragraph = newState.doc.nodeAt(pos);
76247
+ if (!paragraph || paragraph.type.name !== "paragraph") return;
76248
+ const from2 = pos;
76249
+ const to = pos + paragraph.nodeSize;
76250
+ const existing = nextDecorations.find(from2, to);
76251
+ if (existing?.length) {
76252
+ nextDecorations = nextDecorations.remove(existing);
76253
+ }
76254
+ const paragraphDecorations = buildParagraphDecorations(
76255
+ newState.doc,
76256
+ pos + 1,
76257
+ paragraph,
76258
+ view,
76259
+ helpers2,
76260
+ revision + 1
76261
+ );
76262
+ nextDecorations = nextDecorations.add(newState.doc, paragraphDecorations);
76263
+ });
76264
+ return { decorations: nextDecorations, revision: revision + 1 };
76107
76265
  }
76108
76266
  },
76109
76267
  props: {
76110
76268
  decorations(state2) {
76111
76269
  return this.getState(state2).decorations;
76112
76270
  }
76271
+ },
76272
+ view() {
76273
+ return {
76274
+ destroy() {
76275
+ clearAllParagraphContexts();
76276
+ }
76277
+ };
76113
76278
  }
76114
76279
  });
76115
76280
  return [tabPlugin];
76116
76281
  }
76117
76282
  });
76118
- function buildDecorations(doc2, view, helpers2, revision) {
76283
+ function buildInitialDecorations(doc2, view, helpers2, revision) {
76119
76284
  const decorations = [];
76120
76285
  doc2.descendants((node, pos) => {
76121
76286
  if (node.type.name !== "paragraph") return;
@@ -76136,6 +76301,37 @@ function buildDecorations(doc2, view, helpers2, revision) {
76136
76301
  });
76137
76302
  return DecorationSet.create(doc2, decorations);
76138
76303
  }
76304
+ function buildParagraphDecorations(doc2, paragraphContentPos, paragraphNode, view, helpers2, revision) {
76305
+ const request = createLayoutRequest(doc2, paragraphContentPos, view, helpers2, revision);
76306
+ if (!request) return [];
76307
+ const result = calculateTabLayout(request, void 0, view);
76308
+ return applyLayoutResult(result, paragraphNode, paragraphContentPos - 1);
76309
+ }
76310
+ function getAffectedParagraphStarts(tr, newState) {
76311
+ const affected = /* @__PURE__ */ new Set();
76312
+ tr.steps.forEach((step, index2) => {
76313
+ if (step.from == null && step.to == null) return;
76314
+ let fromPos = step.from;
76315
+ let toPos = step.to;
76316
+ if (typeof fromPos !== "number" || typeof toPos !== "number") return;
76317
+ for (let i = index2; i < tr.steps.length; i++) {
76318
+ const stepMap = tr.steps[i].getMap();
76319
+ fromPos = stepMap.map(fromPos, -1);
76320
+ toPos = stepMap.map(toPos, 1);
76321
+ }
76322
+ if (fromPos < 0 || toPos < 0 || fromPos > newState.doc.content.size || toPos > newState.doc.content.size) {
76323
+ return;
76324
+ }
76325
+ newState.doc.nodesBetween(fromPos, toPos, (node, pos) => {
76326
+ if (node.type.name === "paragraph") {
76327
+ affected.add(pos);
76328
+ return false;
76329
+ }
76330
+ return true;
76331
+ });
76332
+ });
76333
+ return affected;
76334
+ }
76139
76335
  const LineBreak = Node$1.create({
76140
76336
  name: "lineBreak",
76141
76337
  group: "inline",
@@ -100331,7 +100527,8 @@ const _sfc_main$h = {
100331
100527
  class: "superdoc-toolbar",
100332
100528
  key: vue.unref(toolbarKey),
100333
100529
  role: "toolbar",
100334
- "aria-label": "Toolbar"
100530
+ "aria-label": "Toolbar",
100531
+ "data-editor-ui-surface": ""
100335
100532
  }, [
100336
100533
  vue.unref(showLeftSide) ? (vue.openBlock(), vue.createBlock(ButtonGroup, {
100337
100534
  key: 0,
@@ -100363,7 +100560,7 @@ const _sfc_main$h = {
100363
100560
  };
100364
100561
  }
100365
100562
  };
100366
- const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-639f50b4"]]);
100563
+ const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-3f5ec271"]]);
100367
100564
  const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
100368
100565
  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: ";
100369
100566
  async function baseInsightsFetch(payload, options = {}) {
@@ -101375,7 +101572,8 @@ const _sfc_main$e = {
101375
101572
  const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-8730b752"]]);
101376
101573
  const _hoisted_1$c = {
101377
101574
  key: 0,
101378
- class: "linked-style-buttons"
101575
+ class: "linked-style-buttons",
101576
+ "data-editor-ui-surface": ""
101379
101577
  };
101380
101578
  const _hoisted_2$8 = ["onClick", "onKeydown", "aria-label"];
101381
101579
  const _sfc_main$d = {
@@ -101454,7 +101652,7 @@ const _sfc_main$d = {
101454
101652
  };
101455
101653
  }
101456
101654
  };
101457
- const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-b53508a8"]]);
101655
+ const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-ecb78965"]]);
101458
101656
  const _hoisted_1$b = {
101459
101657
  key: 0,
101460
101658
  class: "link-title"