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
@@ -35563,7 +35563,7 @@ const _SuperConverter = class _SuperConverter2 {
35563
35563
  static getStoredSuperdocVersion(docx) {
35564
35564
  return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
35565
35565
  }
35566
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.6") {
35566
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.8") {
35567
35567
  return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
35568
35568
  }
35569
35569
  /**
@@ -38763,7 +38763,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
38763
38763
  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);
38764
38764
  var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
38765
38765
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
38766
- 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;
38766
+ 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;
38767
38767
  var GOOD_LEAF_SIZE = 200;
38768
38768
  var RopeSequence = function RopeSequence2() {
38769
38769
  };
@@ -52270,7 +52270,7 @@ const isHeadless = (editor) => {
52270
52270
  const shouldSkipNodeView = (editor) => {
52271
52271
  return isHeadless(editor);
52272
52272
  };
52273
- const summaryVersion = "1.0.0-beta.6";
52273
+ const summaryVersion = "1.0.0-beta.8";
52274
52274
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
52275
52275
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
52276
52276
  function mapAttributes(attrs) {
@@ -53049,7 +53049,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
53049
53049
  { default: remarkStringify },
53050
53050
  { default: remarkGfm }
53051
53051
  ] = await Promise.all([
53052
- import("./index-hjUbJ86s-BMiwCR8J.es.js"),
53052
+ import("./index-DJrRlj1_-HA-nVwDO.es.js"),
53053
53053
  import("./index-DRCvimau-Cw339678.es.js"),
53054
53054
  import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
53055
53055
  import("./index-D_sWOSiG-DE96TaT5.es.js"),
@@ -53254,7 +53254,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
53254
53254
  * Process collaboration migrations
53255
53255
  */
53256
53256
  processCollaborationMigrations() {
53257
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.6");
53257
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.8");
53258
53258
  if (!this.options.ydoc) return;
53259
53259
  const metaMap = this.options.ydoc.getMap("meta");
53260
53260
  let docVersion = metaMap.get("version");
@@ -56806,8 +56806,6 @@ function calculateTabWidth(params2) {
56806
56806
  const beforeWidth = measureText2 ? measureText2(before) : 0;
56807
56807
  width -= beforeWidth;
56808
56808
  }
56809
- } else if (alignment2 === "bar") {
56810
- width = 0;
56811
56809
  }
56812
56810
  if (width < 1) {
56813
56811
  return fallbackWidth();
@@ -61850,14 +61848,14 @@ function measureRunSliceWidth(run2, fromChar, toChar) {
61850
61848
  return metrics.width;
61851
61849
  }
61852
61850
  function lineHeightForRuns(runs, fromRun, toRun) {
61853
- let maxSize = 0;
61851
+ let maxSize2 = 0;
61854
61852
  for (let i = fromRun; i <= toRun; i += 1) {
61855
61853
  const run2 = runs[i];
61856
61854
  const textRun = run2 && isTextRun(run2) ? run2 : null;
61857
61855
  const size2 = textRun?.fontSize ?? 16;
61858
- if (size2 > maxSize) maxSize = size2;
61856
+ if (size2 > maxSize2) maxSize2 = size2;
61859
61857
  }
61860
- return maxSize * 1.2;
61858
+ return maxSize2 * 1.2;
61861
61859
  }
61862
61860
  function remeasureParagraph(block, maxWidth) {
61863
61861
  const runs = block.runs ?? [];
@@ -67460,6 +67458,45 @@ function normalizeRotation(rotation) {
67460
67458
  function degToRad(degrees) {
67461
67459
  return degrees * Math.PI / 180;
67462
67460
  }
67461
+ const defaultMaxSize = 5e3;
67462
+ let maxSize = defaultMaxSize;
67463
+ const cache$1 = /* @__PURE__ */ new Map();
67464
+ const makeKey = (text, font, letterSpacing) => {
67465
+ return `${text}|${font}|${letterSpacing || 0}`;
67466
+ };
67467
+ function getMeasuredTextWidth(text, font, letterSpacing, ctx2) {
67468
+ if (text.length > 32e3) {
67469
+ text = text.substring(0, 32e3);
67470
+ }
67471
+ const key2 = makeKey(text, font, letterSpacing);
67472
+ const hit = cache$1.get(key2);
67473
+ if (hit !== void 0) {
67474
+ cache$1.delete(key2);
67475
+ cache$1.set(key2, hit);
67476
+ return hit.width;
67477
+ }
67478
+ try {
67479
+ ctx2.font = font;
67480
+ const metrics = ctx2.measureText(text);
67481
+ const advanceWidth = metrics.width;
67482
+ const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
67483
+ const baseWidth = Math.max(advanceWidth, paintedWidth);
67484
+ const extra = letterSpacing ? Math.max(0, text.length - 1) * letterSpacing : 0;
67485
+ const width = baseWidth + extra;
67486
+ cache$1.set(key2, { width });
67487
+ evictIfNeeded();
67488
+ return width;
67489
+ } catch {
67490
+ return 0;
67491
+ }
67492
+ }
67493
+ function evictIfNeeded() {
67494
+ while (cache$1.size > maxSize) {
67495
+ const oldestKey = cache$1.keys().next().value;
67496
+ if (oldestKey === void 0) break;
67497
+ cache$1.delete(oldestKey);
67498
+ }
67499
+ }
67463
67500
  const { computeTabStops } = Engines;
67464
67501
  let canvasContext = null;
67465
67502
  const DEFAULT_TAB_INTERVAL_TWIPS = 720;
@@ -67504,8 +67541,7 @@ function measureText(text, font, ctx2, _fontFamily, _letterSpacing) {
67504
67541
  const metrics = ctx2.measureText(text);
67505
67542
  const advanceWidth = metrics.width;
67506
67543
  const paintedWidth = (metrics.actualBoundingBoxLeft || 0) + (metrics.actualBoundingBoxRight || 0);
67507
- const baseWidth = Math.max(advanceWidth, paintedWidth);
67508
- return baseWidth;
67544
+ return Math.max(advanceWidth, paintedWidth);
67509
67545
  }
67510
67546
  const MIN_SINGLE_LINE_PX = 12 * 96 / 72;
67511
67547
  function calculateTypographyMetrics(fontSize2, spacing) {
@@ -68086,13 +68122,9 @@ const getPrimaryRun = (paragraph) => {
68086
68122
  };
68087
68123
  };
68088
68124
  const measureRunWidth = (text, font, ctx2, run2) => {
68089
- const baseWidth = measureText(text, font, ctx2);
68090
- const letterSpacing = run2.kind !== "tab" ? run2.letterSpacing : void 0;
68091
- if (!letterSpacing) {
68092
- return baseWidth;
68093
- }
68094
- const extra = Math.max(0, text.length - 1) * letterSpacing;
68095
- return roundValue(baseWidth + extra);
68125
+ const letterSpacing = run2.kind !== "tab" ? run2.letterSpacing || 0 : 0;
68126
+ const width = getMeasuredTextWidth(text, font, letterSpacing, ctx2);
68127
+ return roundValue(width);
68096
68128
  };
68097
68129
  const appendSegment = (segments, runIndex, fromChar, toChar, width, x2) => {
68098
68130
  if (!segments) return;
@@ -68966,6 +68998,24 @@ getConverterContext_fn = function() {
68966
68998
  }
68967
68999
  return Object.keys(context).length > 0 ? context : void 0;
68968
69000
  };
69001
+ const uiSurfaces = /* @__PURE__ */ new WeakSet();
69002
+ function isInRegisteredSurface(event) {
69003
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
69004
+ if (path.length > 0) {
69005
+ for (const node2 of path) {
69006
+ if (uiSurfaces.has(node2)) return true;
69007
+ if (node2?.hasAttribute?.("data-editor-ui-surface")) return true;
69008
+ }
69009
+ return false;
69010
+ }
69011
+ let node = event.target;
69012
+ while (node) {
69013
+ if (uiSurfaces.has(node)) return true;
69014
+ if (node.hasAttribute?.("data-editor-ui-surface")) return true;
69015
+ node = node.parentElement;
69016
+ }
69017
+ return false;
69018
+ }
68969
69019
  const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
68970
69020
  const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
68971
69021
  const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
@@ -71742,39 +71792,49 @@ _PresentationEditor.CURSOR_STYLES = {
71742
71792
  };
71743
71793
  let PresentationEditor = _PresentationEditor;
71744
71794
  class PresentationInputBridge {
71745
- constructor(windowRoot, visibleHost, getTargetDom, onTargetChanged) {
71795
+ constructor(windowRoot, layoutSurface, getTargetDom, onTargetChanged, options) {
71746
71796
  __privateAdd$1(this, _PresentationInputBridge_instances);
71747
71797
  __privateAdd$1(this, _windowRoot);
71748
- __privateAdd$1(this, _visibleHost2);
71798
+ __privateAdd$1(this, _layoutSurfaces);
71749
71799
  __privateAdd$1(this, _getTargetDom);
71750
71800
  __privateAdd$1(this, _onTargetChanged);
71751
71801
  __privateAdd$1(this, _listeners);
71752
71802
  __privateAdd$1(this, _currentTarget, null);
71753
71803
  __privateAdd$1(this, _destroyed, false);
71804
+ __privateAdd$1(this, _useWindowFallback);
71754
71805
  __privateSet(this, _windowRoot, windowRoot);
71755
- __privateSet(this, _visibleHost2, visibleHost);
71806
+ __privateSet(this, _layoutSurfaces, /* @__PURE__ */ new Set([layoutSurface]));
71756
71807
  __privateSet(this, _getTargetDom, getTargetDom);
71757
71808
  __privateSet(this, _onTargetChanged, onTargetChanged);
71758
71809
  __privateSet(this, _listeners, []);
71810
+ __privateSet(this, _useWindowFallback, options?.useWindowFallback ?? false);
71759
71811
  }
71760
71812
  bind() {
71761
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71762
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keypress", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71763
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), __privateGet$1(this, _windowRoot));
71764
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71765
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71766
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), __privateGet$1(this, _windowRoot));
71767
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), __privateGet$1(this, _windowRoot));
71768
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71769
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71770
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _visibleHost2));
71771
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71772
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71773
- __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), __privateGet$1(this, _windowRoot));
71813
+ const keyboardTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71814
+ keyboardTargets.forEach((target) => {
71815
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keydown", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
71816
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "keyup", __privateMethod$1(this, _PresentationInputBridge_instances, forwardKeyboardEvent_fn), target);
71817
+ });
71818
+ const compositionTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71819
+ compositionTargets.forEach((target) => {
71820
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionstart", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71821
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionupdate", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71822
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "compositionend", __privateMethod$1(this, _PresentationInputBridge_instances, forwardCompositionEvent_fn), target);
71823
+ });
71824
+ const textTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71825
+ textTargets.forEach((target) => {
71826
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "beforeinput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71827
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "input", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71828
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "textInput", __privateMethod$1(this, _PresentationInputBridge_instances, forwardTextEvent_fn), target);
71829
+ });
71830
+ const contextTargets = __privateMethod$1(this, _PresentationInputBridge_instances, getListenerTargets_fn).call(this);
71831
+ contextTargets.forEach((target) => {
71832
+ __privateMethod$1(this, _PresentationInputBridge_instances, addListener_fn).call(this, "contextmenu", __privateMethod$1(this, _PresentationInputBridge_instances, forwardContextMenu_fn), target);
71833
+ });
71774
71834
  }
71775
71835
  destroy() {
71776
- __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target }) => {
71777
- target.removeEventListener(type2, handler2, true);
71836
+ __privateGet$1(this, _listeners).forEach(({ type: type2, handler: handler2, target, useCapture }) => {
71837
+ target.removeEventListener(type2, handler2, useCapture);
71778
71838
  });
71779
71839
  __privateSet(this, _listeners, []);
71780
71840
  __privateSet(this, _currentTarget, null);
@@ -71809,17 +71869,18 @@ class PresentationInputBridge {
71809
71869
  }
71810
71870
  }
71811
71871
  _windowRoot = /* @__PURE__ */ new WeakMap();
71812
- _visibleHost2 = /* @__PURE__ */ new WeakMap();
71872
+ _layoutSurfaces = /* @__PURE__ */ new WeakMap();
71813
71873
  _getTargetDom = /* @__PURE__ */ new WeakMap();
71814
71874
  _onTargetChanged = /* @__PURE__ */ new WeakMap();
71815
71875
  _listeners = /* @__PURE__ */ new WeakMap();
71816
71876
  _currentTarget = /* @__PURE__ */ new WeakMap();
71817
71877
  _destroyed = /* @__PURE__ */ new WeakMap();
71878
+ _useWindowFallback = /* @__PURE__ */ new WeakMap();
71818
71879
  _PresentationInputBridge_instances = /* @__PURE__ */ new WeakSet();
71819
- addListener_fn = function(type2, handler2, target) {
71880
+ addListener_fn = function(type2, handler2, target, useCapture = false) {
71820
71881
  const bound = handler2.bind(this);
71821
- __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target });
71822
- target.addEventListener(type2, bound, true);
71882
+ __privateGet$1(this, _listeners).push({ type: type2, handler: bound, target, useCapture });
71883
+ target.addEventListener(type2, bound, useCapture);
71823
71884
  };
71824
71885
  dispatchToTarget_fn = function(originalEvent, synthetic) {
71825
71886
  if (__privateGet$1(this, _destroyed)) return;
@@ -71840,7 +71901,16 @@ dispatchToTarget_fn = function(originalEvent, synthetic) {
71840
71901
  }
71841
71902
  };
71842
71903
  forwardKeyboardEvent_fn = function(event) {
71843
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71904
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71905
+ return;
71906
+ }
71907
+ if (event.defaultPrevented) {
71908
+ return;
71909
+ }
71910
+ if (event.isComposing || event.keyCode === 229) {
71911
+ return;
71912
+ }
71913
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isPlainCharacterKey_fn).call(this, event)) {
71844
71914
  return;
71845
71915
  }
71846
71916
  const synthetic = new KeyboardEvent(event.type, {
@@ -71858,26 +71928,40 @@ forwardKeyboardEvent_fn = function(event) {
71858
71928
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71859
71929
  };
71860
71930
  forwardTextEvent_fn = function(event) {
71861
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71931
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71862
71932
  return;
71863
71933
  }
71864
- let synthetic;
71865
- if (typeof InputEvent !== "undefined") {
71866
- synthetic = new InputEvent(event.type, {
71867
- data: event.data ?? event.data ?? null,
71868
- inputType: event.inputType ?? "insertText",
71869
- dataTransfer: event.dataTransfer ?? null,
71870
- isComposing: event.isComposing ?? false,
71871
- bubbles: true,
71872
- cancelable: true
71873
- });
71874
- } else {
71875
- synthetic = new Event(event.type, { bubbles: true, cancelable: true });
71934
+ if (event.defaultPrevented) {
71935
+ return;
71876
71936
  }
71877
- __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71937
+ if (event.isComposing) {
71938
+ return;
71939
+ }
71940
+ queueMicrotask(() => {
71941
+ if (event.defaultPrevented) {
71942
+ return;
71943
+ }
71944
+ let synthetic;
71945
+ if (typeof InputEvent !== "undefined") {
71946
+ synthetic = new InputEvent(event.type, {
71947
+ data: event.data ?? event.data ?? null,
71948
+ inputType: event.inputType ?? "insertText",
71949
+ dataTransfer: event.dataTransfer ?? null,
71950
+ isComposing: event.isComposing ?? false,
71951
+ bubbles: true,
71952
+ cancelable: true
71953
+ });
71954
+ } else {
71955
+ synthetic = new Event(event.type, { bubbles: true, cancelable: true });
71956
+ }
71957
+ __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71958
+ });
71878
71959
  };
71879
71960
  forwardCompositionEvent_fn = function(event) {
71880
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71961
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71962
+ return;
71963
+ }
71964
+ if (event.defaultPrevented) {
71881
71965
  return;
71882
71966
  }
71883
71967
  let synthetic;
@@ -71893,7 +71977,10 @@ forwardCompositionEvent_fn = function(event) {
71893
71977
  __privateMethod$1(this, _PresentationInputBridge_instances, dispatchToTarget_fn).call(this, event, synthetic);
71894
71978
  };
71895
71979
  forwardContextMenu_fn = function(event) {
71896
- if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
71980
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, shouldSkipSurface_fn).call(this, event)) {
71981
+ return;
71982
+ }
71983
+ if (event.defaultPrevented) {
71897
71984
  return;
71898
71985
  }
71899
71986
  const synthetic = new MouseEvent("contextmenu", {
@@ -71927,6 +72014,36 @@ isEventOnActiveTarget_fn = function(event) {
71927
72014
  }
71928
72015
  return false;
71929
72016
  };
72017
+ shouldSkipSurface_fn = function(event) {
72018
+ if (__privateMethod$1(this, _PresentationInputBridge_instances, isEventOnActiveTarget_fn).call(this, event)) {
72019
+ return true;
72020
+ }
72021
+ if (!__privateMethod$1(this, _PresentationInputBridge_instances, isInLayoutSurface_fn).call(this, event)) {
72022
+ return true;
72023
+ }
72024
+ if (isInRegisteredSurface(event)) {
72025
+ return true;
72026
+ }
72027
+ return false;
72028
+ };
72029
+ isInLayoutSurface_fn = function(event) {
72030
+ const path = typeof event.composedPath === "function" ? event.composedPath() : [];
72031
+ if (path.length) {
72032
+ return path.some((node) => __privateGet$1(this, _layoutSurfaces).has(node));
72033
+ }
72034
+ const origin = event.target;
72035
+ return origin ? __privateGet$1(this, _layoutSurfaces).has(origin) : false;
72036
+ };
72037
+ getListenerTargets_fn = function() {
72038
+ const targets = new Set(__privateGet$1(this, _layoutSurfaces));
72039
+ if (__privateGet$1(this, _useWindowFallback)) {
72040
+ targets.add(__privateGet$1(this, _windowRoot));
72041
+ }
72042
+ return Array.from(targets);
72043
+ };
72044
+ isPlainCharacterKey_fn = function(event) {
72045
+ return event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
72046
+ };
71930
72047
  const Color = Extension.create({
71931
72048
  name: "color",
71932
72049
  addOptions() {
@@ -74756,7 +74873,7 @@ function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext,
74756
74873
  const tabHeight = paragraphContext.tabHeight;
74757
74874
  paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
74758
74875
  return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
74759
- } catch (error) {
74876
+ } catch {
74760
74877
  return null;
74761
74878
  }
74762
74879
  }
@@ -75850,6 +75967,19 @@ const CommentsMark = Mark2.create({
75850
75967
  return [CommentMarkName, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
75851
75968
  }
75852
75969
  });
75970
+ let cache$2 = /* @__PURE__ */ new WeakMap();
75971
+ function getParagraphContext(paragraph, startPos, helpers2, revision, compute) {
75972
+ const cached = cache$2.get(paragraph);
75973
+ if (cached && cached.revision === revision) {
75974
+ return cached.context;
75975
+ }
75976
+ const context = compute(paragraph, startPos, helpers2);
75977
+ cache$2.set(paragraph, { revision, context });
75978
+ return context;
75979
+ }
75980
+ function clearAllParagraphContexts() {
75981
+ cache$2 = /* @__PURE__ */ new WeakMap();
75982
+ }
75853
75983
  const leaderStyles = {
75854
75984
  dot: "border-bottom: 1px dotted black;",
75855
75985
  heavy: "border-bottom: 2px solid black;",
@@ -75866,6 +75996,14 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
75866
75996
  if (!paragraphContext) return null;
75867
75997
  const paragraphId = paragraphIdFromPos(paragraphContext.startPos);
75868
75998
  const paragraphNode = paragraphContext.paragraph;
75999
+ const cachedContext = getParagraphContext(
76000
+ paragraphNode,
76001
+ paragraphContext.startPos,
76002
+ helpers2,
76003
+ revision,
76004
+ () => extractParagraphContext(paragraphNode, paragraphContext.startPos, helpers2, paragraphContext.paragraphDepth)
76005
+ );
76006
+ const effectiveContext = cachedContext || paragraphContext;
75869
76007
  const { entries } = flattenParagraph(paragraphNode, paragraphContext.startPos);
75870
76008
  const spans = [];
75871
76009
  let tabIndex = 0;
@@ -75893,13 +76031,13 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
75893
76031
  });
75894
76032
  }
75895
76033
  });
75896
- const tabStops = Array.isArray(paragraphContext.tabStops) ? [...paragraphContext.tabStops] : [];
75897
- const hangingPx = twipsToPixels(Number(paragraphContext.indent?.hanging) || 0);
75898
- if (hangingPx > 0 && paragraphContext.indentWidth != null) {
75899
- tabStops.unshift({ val: "start", pos: paragraphContext.indentWidth + hangingPx, leader: "none" });
76034
+ const tabStops = Array.isArray(effectiveContext.tabStops) ? [...effectiveContext.tabStops] : [];
76035
+ const hangingPx = twipsToPixels(Number(effectiveContext.indent?.hanging) || 0);
76036
+ if (hangingPx > 0 && effectiveContext.indentWidth != null) {
76037
+ tabStops.unshift({ val: "start", pos: effectiveContext.indentWidth + hangingPx, leader: "none" });
75900
76038
  }
75901
- const paragraphWidth = getBlockNodeWidth(view, paragraphContext.startPos) ?? defaultLineLength;
75902
- const indentWidth = paragraphContext.indentWidth ?? getIndentWidth(view, paragraphContext.startPos, paragraphContext.indent);
76039
+ const paragraphWidth = getBlockNodeWidth(view, effectiveContext.startPos) ?? defaultLineLength;
76040
+ const indentWidth = effectiveContext.indentWidth ?? getIndentWidth(view, effectiveContext.startPos, effectiveContext.indent);
75903
76041
  return {
75904
76042
  paragraphId,
75905
76043
  revision,
@@ -75907,9 +76045,9 @@ function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, parag
75907
76045
  defaultTabDistance,
75908
76046
  defaultLineLength,
75909
76047
  indents: {
75910
- left: twipsToPixels(Number(paragraphContext.indent?.left) || 0),
75911
- right: twipsToPixels(Number(paragraphContext.indent?.right) || 0),
75912
- firstLine: twipsToPixels(Number(paragraphContext.indent?.firstLine) || 0),
76048
+ left: twipsToPixels(Number(effectiveContext.indent?.left) || 0),
76049
+ right: twipsToPixels(Number(effectiveContext.indent?.right) || 0),
76050
+ firstLine: twipsToPixels(Number(effectiveContext.indent?.firstLine) || 0),
75913
76051
  hanging: hangingPx
75914
76052
  },
75915
76053
  tabStops,
@@ -76074,31 +76212,58 @@ const TabNode = Node$1.create({
76074
76212
  key: new PluginKey("tabPlugin"),
76075
76213
  state: {
76076
76214
  init() {
76077
- return { decorations: false, revision: 0 };
76215
+ const initialDecorations = buildInitialDecorations(view.state.doc, view, helpers2, 0);
76216
+ return { decorations: initialDecorations, revision: 0 };
76078
76217
  },
76079
76218
  apply(tr, { decorations, revision }, _oldState, newState) {
76080
- if (!decorations) {
76081
- const newDecorations2 = buildDecorations(newState.doc, view, helpers2, 0);
76082
- return { decorations: newDecorations2, revision: 0 };
76083
- }
76219
+ const currentDecorations = decorations && decorations.map ? decorations.map(tr.mapping, tr.doc) : DecorationSet.empty;
76084
76220
  if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
76085
- return { decorations, revision };
76086
- }
76087
- const nextRevision = revision + 1;
76088
- const newDecorations = buildDecorations(newState.doc, view, helpers2, nextRevision);
76089
- return { decorations: newDecorations, revision: nextRevision };
76221
+ return { decorations: currentDecorations, revision };
76222
+ }
76223
+ const affectedParagraphs = getAffectedParagraphStarts(tr, newState);
76224
+ if (affectedParagraphs.size === 0) {
76225
+ return { decorations: currentDecorations, revision };
76226
+ }
76227
+ let nextDecorations = currentDecorations;
76228
+ affectedParagraphs.forEach((pos) => {
76229
+ const paragraph = newState.doc.nodeAt(pos);
76230
+ if (!paragraph || paragraph.type.name !== "paragraph") return;
76231
+ const from2 = pos;
76232
+ const to = pos + paragraph.nodeSize;
76233
+ const existing = nextDecorations.find(from2, to);
76234
+ if (existing?.length) {
76235
+ nextDecorations = nextDecorations.remove(existing);
76236
+ }
76237
+ const paragraphDecorations = buildParagraphDecorations(
76238
+ newState.doc,
76239
+ pos + 1,
76240
+ paragraph,
76241
+ view,
76242
+ helpers2,
76243
+ revision + 1
76244
+ );
76245
+ nextDecorations = nextDecorations.add(newState.doc, paragraphDecorations);
76246
+ });
76247
+ return { decorations: nextDecorations, revision: revision + 1 };
76090
76248
  }
76091
76249
  },
76092
76250
  props: {
76093
76251
  decorations(state2) {
76094
76252
  return this.getState(state2).decorations;
76095
76253
  }
76254
+ },
76255
+ view() {
76256
+ return {
76257
+ destroy() {
76258
+ clearAllParagraphContexts();
76259
+ }
76260
+ };
76096
76261
  }
76097
76262
  });
76098
76263
  return [tabPlugin];
76099
76264
  }
76100
76265
  });
76101
- function buildDecorations(doc2, view, helpers2, revision) {
76266
+ function buildInitialDecorations(doc2, view, helpers2, revision) {
76102
76267
  const decorations = [];
76103
76268
  doc2.descendants((node, pos) => {
76104
76269
  if (node.type.name !== "paragraph") return;
@@ -76119,6 +76284,37 @@ function buildDecorations(doc2, view, helpers2, revision) {
76119
76284
  });
76120
76285
  return DecorationSet.create(doc2, decorations);
76121
76286
  }
76287
+ function buildParagraphDecorations(doc2, paragraphContentPos, paragraphNode, view, helpers2, revision) {
76288
+ const request = createLayoutRequest(doc2, paragraphContentPos, view, helpers2, revision);
76289
+ if (!request) return [];
76290
+ const result = calculateTabLayout(request, void 0, view);
76291
+ return applyLayoutResult(result, paragraphNode, paragraphContentPos - 1);
76292
+ }
76293
+ function getAffectedParagraphStarts(tr, newState) {
76294
+ const affected = /* @__PURE__ */ new Set();
76295
+ tr.steps.forEach((step, index2) => {
76296
+ if (step.from == null && step.to == null) return;
76297
+ let fromPos = step.from;
76298
+ let toPos = step.to;
76299
+ if (typeof fromPos !== "number" || typeof toPos !== "number") return;
76300
+ for (let i = index2; i < tr.steps.length; i++) {
76301
+ const stepMap = tr.steps[i].getMap();
76302
+ fromPos = stepMap.map(fromPos, -1);
76303
+ toPos = stepMap.map(toPos, 1);
76304
+ }
76305
+ if (fromPos < 0 || toPos < 0 || fromPos > newState.doc.content.size || toPos > newState.doc.content.size) {
76306
+ return;
76307
+ }
76308
+ newState.doc.nodesBetween(fromPos, toPos, (node, pos) => {
76309
+ if (node.type.name === "paragraph") {
76310
+ affected.add(pos);
76311
+ return false;
76312
+ }
76313
+ return true;
76314
+ });
76315
+ });
76316
+ return affected;
76317
+ }
76122
76318
  const LineBreak = Node$1.create({
76123
76319
  name: "lineBreak",
76124
76320
  group: "inline",
@@ -100314,7 +100510,8 @@ const _sfc_main$h = {
100314
100510
  class: "superdoc-toolbar",
100315
100511
  key: unref(toolbarKey),
100316
100512
  role: "toolbar",
100317
- "aria-label": "Toolbar"
100513
+ "aria-label": "Toolbar",
100514
+ "data-editor-ui-surface": ""
100318
100515
  }, [
100319
100516
  unref(showLeftSide) ? (openBlock(), createBlock(ButtonGroup, {
100320
100517
  key: 0,
@@ -100346,7 +100543,7 @@ const _sfc_main$h = {
100346
100543
  };
100347
100544
  }
100348
100545
  };
100349
- const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-639f50b4"]]);
100546
+ const Toolbar = /* @__PURE__ */ _export_sfc(_sfc_main$h, [["__scopeId", "data-v-3f5ec271"]]);
100350
100547
  const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
100351
100548
  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: ";
100352
100549
  async function baseInsightsFetch(payload, options = {}) {
@@ -101358,7 +101555,8 @@ const _sfc_main$e = {
101358
101555
  const DocumentMode = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-8730b752"]]);
101359
101556
  const _hoisted_1$c = {
101360
101557
  key: 0,
101361
- class: "linked-style-buttons"
101558
+ class: "linked-style-buttons",
101559
+ "data-editor-ui-surface": ""
101362
101560
  };
101363
101561
  const _hoisted_2$8 = ["onClick", "onKeydown", "aria-label"];
101364
101562
  const _sfc_main$d = {
@@ -101437,7 +101635,7 @@ const _sfc_main$d = {
101437
101635
  };
101438
101636
  }
101439
101637
  };
101440
- const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-b53508a8"]]);
101638
+ const LinkedStyle = /* @__PURE__ */ _export_sfc(_sfc_main$d, [["__scopeId", "data-v-ecb78965"]]);
101441
101639
  const _hoisted_1$b = {
101442
101640
  key: 0,
101443
101641
  class: "link-title"
@@ -1 +1 @@
1
- {"version":3,"file":"SuperDoc.d.ts","sourceRoot":"","sources":["../../../../../src/core/SuperDoc.js"],"names":[],"mappings":"AAqBA,6CAA6C;AAC7C,mEAAmE;AACnE,qDAAqD;AACrD,mDAAmD;AACnD,iDAAiD;AACjD,6DAA6D;AAC7D,iDAAiD;AACjD,6DAA6D;AAE7D;;;;;;GAMG;AACH;IACE,4BAA4B;IAC5B,qBADW,KAAK,CAAC,MAAM,CAAC,CACgB;IA4ExC;;OAEG;IACH,oBAFW,MAAM,EAKhB;IAhFD,qBAAqB;IACrB,SADW,MAAM,CACT;IAER,qBAAqB;IACrB,OADW,IAAI,EAAE,CACX;IAEN,4CAA4C;IAC5C,MADW,OAAO,KAAK,EAAE,GAAG,GAAG,SAAS,CACnC;IAEL,4EAA4E;IAC5E,UADW,OAAO,sBAAsB,EAAE,kBAAkB,GAAG,SAAS,CAC/D;IAET,qBAAqB;IACrB,QADW,MAAM,CA4Df;IAiDA,wCAA6B;IAC7B,+BAAmB;IAMnB,gBAA+C;IAC/C,6BAAgC;IAchC,yCAA4B;IAE5B,YAAkB;IAElB,2BAAuC;IAEvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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