superdoc 1.0.0-beta.2 → 1.0.0-beta.3

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 (34) hide show
  1. package/dist/chunks/{PdfViewer-saAhozRR.es.js → PdfViewer-CKzs9Ct5.es.js} +2 -2
  2. package/dist/chunks/{PdfViewer-CeuX3gOe.cjs → PdfViewer-CxHbcDGx.cjs} +1 -1
  3. package/dist/chunks/{eventemitter3-BZXKb7j7.es.js → eventemitter3-ByBH0NYV.es.js} +1 -1
  4. package/dist/chunks/{index-Sn-JVHIg-BxOp3gSx.cjs → index-CJUy3fVi-BGLfCP5B.cjs} +1 -1
  5. package/dist/chunks/{index-Sn-JVHIg-BCItIT88.es.js → index-CJUy3fVi-D8zt9F3Z.es.js} +1 -1
  6. package/dist/chunks/{index-Dh5oVJua.cjs → index-Dp3rVMnX.cjs} +3 -3
  7. package/dist/chunks/{index-C0OeGje6.es.js → index-DukSDI8_.es.js} +6 -6
  8. package/dist/chunks/{jszip-Duxs2YMV.es.js → jszip-BwsONqK5.es.js} +1 -1
  9. package/dist/chunks/{super-editor.es-Dcz39nKY.es.js → super-editor.es-BRKZG90h.es.js} +593 -200
  10. package/dist/chunks/{super-editor.es-BKljkYUU.cjs → super-editor.es-CDiTp9Fe.cjs} +592 -199
  11. package/dist/chunks/{vue-B5QAf5pA.es.js → vue-CztqUvm1.es.js} +17 -17
  12. package/dist/chunks/xml-js-BZPSMmVo.es.js +2 -0
  13. package/dist/packages/superdoc/src/core/SuperDoc.d.ts +35 -2
  14. package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
  15. package/dist/super-editor/ai-writer.es.js +2 -2
  16. package/dist/super-editor/chunks/{converter-BFGB7hqj.js → converter-B9YfBdcc.js} +1 -1
  17. package/dist/super-editor/chunks/{docx-zipper-OPbzIk16.js → docx-zipper-V16OzZ7a.js} +1 -1
  18. package/dist/super-editor/chunks/{editor-CtI4XnMw.js → editor-DlvlVSbc.js} +409 -165
  19. package/dist/super-editor/chunks/{index-Sn-JVHIg.js → index-CJUy3fVi.js} +1 -1
  20. package/dist/super-editor/chunks/{toolbar-BydALv4o.js → toolbar-cNDvtryE.js} +2 -2
  21. package/dist/super-editor/converter.es.js +1 -1
  22. package/dist/super-editor/docx-zipper.es.js +2 -2
  23. package/dist/super-editor/editor.es.js +3 -3
  24. package/dist/super-editor/file-zipper.es.js +1 -1
  25. package/dist/super-editor/super-editor.es.js +217 -41
  26. package/dist/super-editor/toolbar.es.js +2 -2
  27. package/dist/super-editor.cjs +1 -1
  28. package/dist/super-editor.es.js +2 -2
  29. package/dist/superdoc.cjs +2 -2
  30. package/dist/superdoc.es.js +2 -2
  31. package/dist/superdoc.umd.js +594 -201
  32. package/dist/superdoc.umd.js.map +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunks/xml-js-CVyfrKaV.es.js +0 -2
@@ -9,11 +9,11 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- 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, _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;
12
+ 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;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as ListHelpers, O as updateNumberingProperties, Q as changeListLevel, U as findParentNode, V as isList, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName, $ as TrackInsertMarkName, a0 as v4, a1 as TrackFormatMarkName, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as resolveParagraphProperties, ak as _getReferencedTableStyles, al as parseSizeUnit, am as minMax, an as updateDOMAttributes, ao as findChildren$5, ap as generateRandomSigned32BitIntStrId, aq as calculateResolvedParagraphProperties, ar as encodeCSSFromPPr, as as twipsToPixels$2, at as resolveRunProperties, au as encodeCSSFromRPr, av as generateOrderedListIndex, aw as docxNumberingHelpers, ax as InputRule, ay as convertSizeToCSS, az as SelectionRange, aA as Transform, aB as findParentNodeClosestToPos, aC as isInTable$1, aD as generateDocxRandomId, aE as insertNewRelationship, aF as inchesToPixels, aG as kebabCase, aH as getUnderlineCssString } from "./converter-BFGB7hqj.js";
16
- import { D as DocxZipper } from "./docx-zipper-OPbzIk16.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as ListHelpers, O as updateNumberingProperties, Q as changeListLevel, U as findParentNode, V as isList, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName, $ as TrackInsertMarkName, a0 as v4, a1 as TrackFormatMarkName, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as resolveParagraphProperties, ak as _getReferencedTableStyles, al as parseSizeUnit, am as minMax, an as updateDOMAttributes, ao as findChildren$5, ap as generateRandomSigned32BitIntStrId, aq as calculateResolvedParagraphProperties, ar as encodeCSSFromPPr, as as twipsToPixels$2, at as resolveRunProperties, au as encodeCSSFromRPr, av as generateOrderedListIndex, aw as docxNumberingHelpers, ax as InputRule, ay as convertSizeToCSS, az as SelectionRange, aA as Transform, aB as findParentNodeClosestToPos, aC as isInTable$1, aD as generateDocxRandomId, aE as insertNewRelationship, aF as inchesToPixels, aG as kebabCase, aH as getUnderlineCssString } from "./converter-B9YfBdcc.js";
16
+ import { D as DocxZipper } from "./docx-zipper-V16OzZ7a.js";
17
17
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
@@ -13553,7 +13553,7 @@ const isHeadless = (editor) => {
13553
13553
  const shouldSkipNodeView = (editor) => {
13554
13554
  return isHeadless(editor);
13555
13555
  };
13556
- const summaryVersion = "1.0.0-beta.2";
13556
+ const summaryVersion = "1.0.0-beta.3";
13557
13557
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
13558
13558
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
13559
13559
  function mapAttributes(attrs) {
@@ -14335,7 +14335,7 @@ const _Editor = class _Editor extends EventEmitter {
14335
14335
  { default: remarkStringify },
14336
14336
  { default: remarkGfm }
14337
14337
  ] = await Promise.all([
14338
- import("./index-Sn-JVHIg.js"),
14338
+ import("./index-CJUy3fVi.js"),
14339
14339
  import("./index-DRCvimau.js"),
14340
14340
  import("./index-C_x_N6Uh.js"),
14341
14341
  import("./index-D_sWOSiG.js"),
@@ -14540,7 +14540,7 @@ const _Editor = class _Editor extends EventEmitter {
14540
14540
  * Process collaboration migrations
14541
14541
  */
14542
14542
  processCollaborationMigrations() {
14543
- console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.2");
14543
+ console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.3");
14544
14544
  if (!this.options.ydoc) return;
14545
14545
  const metaMap = this.options.ydoc.getMap("meta");
14546
14546
  let docVersion = metaMap.get("version");
@@ -16247,6 +16247,50 @@ const resolveColorFromAttributes = (attrs, themeColors) => {
16247
16247
  }
16248
16248
  return void 0;
16249
16249
  };
16250
+ const MAX_DATA_ATTR_COUNT = 50;
16251
+ const MAX_DATA_ATTR_VALUE_LENGTH = 1e3;
16252
+ const MAX_DATA_ATTR_NAME_LENGTH = 100;
16253
+ const extractDataAttributes = (attrs) => {
16254
+ if (!attrs) return void 0;
16255
+ const result = {};
16256
+ let attrCount = 0;
16257
+ for (const [key2, value] of Object.entries(attrs)) {
16258
+ if (typeof key2 !== "string" || !key2.toLowerCase().startsWith("data-")) {
16259
+ continue;
16260
+ }
16261
+ if (attrCount >= MAX_DATA_ATTR_COUNT) {
16262
+ if (process$1.env.NODE_ENV === "development") {
16263
+ console.warn(`[PM-Adapter] Rejecting data attributes exceeding ${MAX_DATA_ATTR_COUNT} limit`);
16264
+ }
16265
+ break;
16266
+ }
16267
+ if (key2.length > MAX_DATA_ATTR_NAME_LENGTH) {
16268
+ if (process$1.env.NODE_ENV === "development") {
16269
+ console.warn(
16270
+ `[PM-Adapter] Rejecting data attribute name exceeding ${MAX_DATA_ATTR_NAME_LENGTH} chars: ${key2.substring(0, 50)}...`
16271
+ );
16272
+ }
16273
+ continue;
16274
+ }
16275
+ if (value == null) {
16276
+ continue;
16277
+ }
16278
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
16279
+ const stringValue = String(value);
16280
+ if (stringValue.length > MAX_DATA_ATTR_VALUE_LENGTH) {
16281
+ if (process$1.env.NODE_ENV === "development") {
16282
+ console.warn(
16283
+ `[PM-Adapter] Rejecting data attribute value exceeding ${MAX_DATA_ATTR_VALUE_LENGTH} chars for key: ${key2}`
16284
+ );
16285
+ }
16286
+ continue;
16287
+ }
16288
+ result[key2] = stringValue;
16289
+ attrCount++;
16290
+ }
16291
+ }
16292
+ return Object.keys(result).length > 0 ? result : void 0;
16293
+ };
16250
16294
  const normalizeRunMarkList = (value) => {
16251
16295
  if (!value) return void 0;
16252
16296
  let entries = value;
@@ -16426,11 +16470,9 @@ const applyTextStyleMark = (run, attrs, themeColors) => {
16426
16470
  run.fontFamily = sanitized;
16427
16471
  }
16428
16472
  }
16429
- if (isFiniteNumber(attrs.fontSize)) {
16430
- const size = Number(attrs.fontSize);
16431
- if (size >= 1 && size <= 1e3) {
16432
- run.fontSize = size;
16433
- }
16473
+ const fontSizeValue = pickNumber(attrs.fontSize);
16474
+ if (fontSizeValue !== void 0 && fontSizeValue >= 1 && fontSizeValue <= 1e3) {
16475
+ run.fontSize = fontSizeValue;
16434
16476
  }
16435
16477
  if (isFiniteNumber(attrs.letterSpacing)) {
16436
16478
  const spacing = Number(attrs.letterSpacing);
@@ -16444,6 +16486,7 @@ const DEFAULT_HYPERLINK_CONFIG = {
16444
16486
  };
16445
16487
  const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG, themeColors) => {
16446
16488
  marks.forEach((mark) => {
16489
+ const forwardedDataAttrs = extractDataAttributes(mark.attrs);
16447
16490
  try {
16448
16491
  switch (mark.type) {
16449
16492
  case TRACK_INSERT_MARK:
@@ -16538,6 +16581,9 @@ const applyMarksToRun = (run, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG,
16538
16581
  console.warn(`[PM-Adapter] Failed to apply mark ${mark.type}:`, error);
16539
16582
  }
16540
16583
  }
16584
+ if (forwardedDataAttrs) {
16585
+ run.dataAttrs = { ...run.dataAttrs ?? {}, ...forwardedDataAttrs };
16586
+ }
16541
16587
  });
16542
16588
  };
16543
16589
  function textNodeToRun(textNode, positions, defaultFont, defaultSize, inheritedMarks = [], sdtMetadata, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors) {
@@ -16561,8 +16607,9 @@ function tabNodeToRun(node, positions, tabIndex, paragraph) {
16561
16607
  const pos = positions.get(node);
16562
16608
  if (!pos) return null;
16563
16609
  const paragraphAttrs = paragraph.attrs ?? {};
16564
- const tabStops = Array.isArray(paragraphAttrs.tabStops) ? paragraphAttrs.tabStops : void 0;
16565
- const indent = paragraphAttrs.indent;
16610
+ const paragraphProps = typeof paragraphAttrs.paragraphProperties === "object" && paragraphAttrs.paragraphProperties !== null ? paragraphAttrs.paragraphProperties : {};
16611
+ const tabStops = Array.isArray(paragraphAttrs.tabStops) && paragraphAttrs.tabStops.length ? paragraphAttrs.tabStops : Array.isArray(paragraphProps.tabStops) ? paragraphProps.tabStops : void 0;
16612
+ const indent = paragraphAttrs.indent ?? paragraphProps.indent ?? void 0;
16566
16613
  return {
16567
16614
  kind: "tab",
16568
16615
  text: " ",
@@ -16876,6 +16923,9 @@ const normalizeParagraphSpacing = (value) => {
16876
16923
  const afterRaw = pickNumber(source.after);
16877
16924
  const lineRaw = pickNumber(source.line);
16878
16925
  const lineRule = normalizeLineRule(source.lineRule);
16926
+ const beforeAutospacing = toBooleanFlag(source.beforeAutospacing ?? source.beforeAutoSpacing);
16927
+ const afterAutospacing = toBooleanFlag(source.afterAutospacing ?? source.afterAutoSpacing);
16928
+ const contextualSpacing = toBooleanFlag(source.contextualSpacing);
16879
16929
  const before = beforeRaw != null ? twipsToPx$1(beforeRaw) : pickNumber(source.lineSpaceBefore);
16880
16930
  const after = afterRaw != null ? twipsToPx$1(afterRaw) : pickNumber(source.lineSpaceAfter);
16881
16931
  const line = normalizeLineValue(lineRaw, lineRule);
@@ -16883,8 +16933,24 @@ const normalizeParagraphSpacing = (value) => {
16883
16933
  if (after != null) spacing.after = after;
16884
16934
  if (line != null) spacing.line = line;
16885
16935
  if (lineRule) spacing.lineRule = lineRule;
16936
+ if (beforeAutospacing != null) spacing.beforeAutospacing = beforeAutospacing;
16937
+ if (afterAutospacing != null) spacing.afterAutospacing = afterAutospacing;
16938
+ if (contextualSpacing != null) spacing.contextualSpacing = contextualSpacing;
16886
16939
  return Object.keys(spacing).length > 0 ? spacing : void 0;
16887
16940
  };
16941
+ const toBooleanFlag = (value) => {
16942
+ if (value === true || value === false) return value;
16943
+ if (typeof value === "string") {
16944
+ const normalized = value.trim().toLowerCase();
16945
+ if (["true", "1", "on", "yes"].includes(normalized)) return true;
16946
+ if (["false", "0", "off", "no"].includes(normalized)) return false;
16947
+ }
16948
+ if (typeof value === "number") {
16949
+ if (value === 1) return true;
16950
+ if (value === 0) return false;
16951
+ }
16952
+ return void 0;
16953
+ };
16888
16954
  const normalizeLineValue = (value, lineRule) => {
16889
16955
  if (value == null) return void 0;
16890
16956
  if (lineRule === "auto") {
@@ -18257,15 +18323,17 @@ const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
18257
18323
  return null;
18258
18324
  }
18259
18325
  const attrs = para.attrs ?? {};
18260
- const styleId = typeof attrs.styleId === "string" && attrs.styleId.trim() ? attrs.styleId : null;
18326
+ const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
18327
+ const styleIdSource = attrs.styleId ?? paragraphProps.styleId;
18328
+ const styleId = typeof styleIdSource === "string" && styleIdSource.trim() ? styleIdSource : null;
18261
18329
  if (!styleId) {
18262
18330
  return null;
18263
18331
  }
18264
18332
  const inlineProps = {
18265
18333
  styleId,
18266
- numberingProperties: cloneIfObject(attrs.numberingProperties),
18267
- indent: cloneIfObject(attrs.indent),
18268
- spacing: cloneIfObject(attrs.spacing)
18334
+ numberingProperties: cloneIfObject(attrs.numberingProperties ?? paragraphProps.numberingProperties),
18335
+ indent: cloneIfObject(attrs.indent ?? paragraphProps.indent),
18336
+ spacing: cloneIfObject(attrs.spacing ?? paragraphProps.spacing)
18269
18337
  };
18270
18338
  const resolverParams = {
18271
18339
  docx: context.docx,
@@ -18543,13 +18611,17 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
18543
18611
  };
18544
18612
  const computeParagraphAttrs = (para, styleContext, listCounterContext, converterContext, hydrationOverride) => {
18545
18613
  const attrs = para.attrs ?? {};
18614
+ const paragraphProps = typeof attrs.paragraphProperties === "object" && attrs.paragraphProperties !== null ? attrs.paragraphProperties : {};
18546
18615
  const hydrated = hydrationOverride ?? hydrateParagraphStyleAttrs(para, converterContext);
18547
- const spacingSource = attrs.spacing !== void 0 ? attrs.spacing : hydrated?.spacing;
18616
+ const spacingSource = attrs.spacing !== void 0 ? attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : hydrated?.spacing;
18548
18617
  const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
18549
- const indentSource = attrs.indent ?? hydrated?.indent;
18618
+ const indentSource = attrs.indent ?? paragraphProps.indent ?? hydrated?.indent;
18550
18619
  const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? attrs.textIndent);
18551
- const styleNodeAttrs = hydrated?.tabStops && !attrs.tabStops && !attrs.tabs ? { ...attrs, tabStops: hydrated.tabStops } : attrs;
18620
+ const styleNodeAttrs = hydrated?.tabStops && !attrs.tabStops && !attrs.tabs ? { ...attrs, tabStops: hydrated.tabStops } : !attrs.tabStops && paragraphProps.tabStops ? { ...attrs, tabStops: paragraphProps.tabStops } : attrs;
18552
18621
  const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
18622
+ if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
18623
+ styleNode.styleId = paragraphProps.styleId;
18624
+ }
18553
18625
  const computed2 = resolveStyle(styleNode, styleContext);
18554
18626
  const { spacing, indent } = resolveSpacingIndent(computed2.paragraph, computed2.numbering);
18555
18627
  const paragraphAttrs = {};
@@ -18574,6 +18646,18 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
18574
18646
  }
18575
18647
  const spacingPx = spacingPtToPx(spacing, normalizedSpacing);
18576
18648
  if (spacingPx) paragraphAttrs.spacing = spacingPx;
18649
+ if (normalizedSpacing?.beforeAutospacing != null || normalizedSpacing?.afterAutospacing != null) {
18650
+ paragraphAttrs.spacing = paragraphAttrs.spacing ?? {};
18651
+ if (normalizedSpacing?.beforeAutospacing != null) {
18652
+ paragraphAttrs.spacing.beforeAutospacing = normalizedSpacing.beforeAutospacing;
18653
+ }
18654
+ if (normalizedSpacing?.afterAutospacing != null) {
18655
+ paragraphAttrs.spacing.afterAutospacing = normalizedSpacing.afterAutospacing;
18656
+ }
18657
+ }
18658
+ if (normalizedSpacing?.contextualSpacing != null) {
18659
+ paragraphAttrs.contextualSpacing = normalizedSpacing.contextualSpacing;
18660
+ }
18577
18661
  const hasExplicitIndent = Boolean(normalizedIndent);
18578
18662
  const hasNumberingIndent = Boolean(computed2.numbering?.indent?.left || computed2.numbering?.indent?.hanging);
18579
18663
  if (hasExplicitIndent || hasNumberingIndent || bidi && adjustRightInd) {
@@ -18592,10 +18676,20 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
18592
18676
  if (borders) paragraphAttrs.borders = borders;
18593
18677
  const shading = normalizeParagraphShading(attrs.shading ?? hydrated?.shading);
18594
18678
  if (shading) paragraphAttrs.shading = shading;
18679
+ const keepNext = paragraphProps.keepNext ?? hydrated?.keepNext ?? attrs.keepNext;
18680
+ if (keepNext === true) paragraphAttrs.keepNext = true;
18681
+ const keepLines = paragraphProps.keepLines ?? hydrated?.keepLines ?? attrs.keepLines;
18682
+ if (keepLines === true) paragraphAttrs.keepLines = true;
18595
18683
  const paragraphDecimalSeparator = styleContext.defaults?.decimalSeparator ?? DEFAULT_DECIMAL_SEPARATOR$2;
18596
18684
  if (paragraphDecimalSeparator !== DEFAULT_DECIMAL_SEPARATOR$2) {
18597
18685
  paragraphAttrs.decimalSeparator = paragraphDecimalSeparator;
18598
18686
  }
18687
+ const styleIdAttr = typeof attrs.styleId === "string" ? attrs.styleId : void 0;
18688
+ if (styleIdAttr) {
18689
+ paragraphAttrs.styleId = styleIdAttr;
18690
+ } else if (paragraphProps.styleId) {
18691
+ paragraphAttrs.styleId = paragraphProps.styleId;
18692
+ }
18599
18693
  const paraIntervalTwips = pickNumber(attrs.tabIntervalTwips) ?? (() => {
18600
18694
  const px = pickNumber(attrs.tabIntervalPx);
18601
18695
  return px != null ? Math.round(px * 15) : void 0;
@@ -18632,7 +18726,7 @@ const computeParagraphAttrs = (para, styleContext, listCounterContext, converter
18632
18726
  paragraphAttrs.floatAlignment = xAlign;
18633
18727
  }
18634
18728
  }
18635
- const numberingSource = attrs.numberingProperties ?? hydrated?.numberingProperties;
18729
+ const numberingSource = attrs.numberingProperties ?? paragraphProps.numberingProperties ?? hydrated?.numberingProperties;
18636
18730
  const rawNumberingProps = toAdapterNumberingProps(numberingSource);
18637
18731
  if (rawNumberingProps) {
18638
18732
  const numberingProps = rawNumberingProps;
@@ -19285,13 +19379,29 @@ const extractRunStyleId = (runProperties) => {
19285
19379
  return null;
19286
19380
  };
19287
19381
  const isTextRun$1 = (run) => run.kind !== "tab";
19382
+ const dataAttrsCompatible = (a, b) => {
19383
+ const aAttrs = a.dataAttrs;
19384
+ const bAttrs = b.dataAttrs;
19385
+ if (!aAttrs && !bAttrs) return true;
19386
+ if (!aAttrs || !bAttrs) return false;
19387
+ const aKeys = Object.keys(aAttrs).sort();
19388
+ const bKeys = Object.keys(bAttrs).sort();
19389
+ if (aKeys.length !== bKeys.length) return false;
19390
+ for (let i = 0; i < aKeys.length; i++) {
19391
+ const key2 = aKeys[i];
19392
+ if (key2 !== bKeys[i] || aAttrs[key2] !== bAttrs[key2]) {
19393
+ return false;
19394
+ }
19395
+ }
19396
+ return true;
19397
+ };
19288
19398
  function mergeAdjacentRuns(runs) {
19289
19399
  if (runs.length <= 1) return runs;
19290
19400
  const merged = [];
19291
19401
  let current = runs[0];
19292
19402
  for (let i = 1; i < runs.length; i++) {
19293
19403
  const next = runs[i];
19294
- const canMerge = isTextRun$1(current) && isTextRun$1(next) && !current.token && !next.token && current.pmStart != null && current.pmEnd != null && next.pmStart != null && next.pmEnd != null && current.pmEnd === next.pmStart && current.fontFamily === next.fontFamily && current.fontSize === next.fontSize && current.bold === next.bold && current.italic === next.italic && current.underline === next.underline && current.strike === next.strike && current.color === next.color && current.highlight === next.highlight && (current.letterSpacing ?? 0) === (next.letterSpacing ?? 0) && trackedChangesCompatible(current, next);
19404
+ const canMerge = isTextRun$1(current) && isTextRun$1(next) && !current.token && !next.token && current.pmStart != null && current.pmEnd != null && next.pmStart != null && next.pmEnd != null && current.pmEnd === next.pmStart && current.fontFamily === next.fontFamily && current.fontSize === next.fontSize && current.bold === next.bold && current.italic === next.italic && current.underline === next.underline && current.strike === next.strike && current.color === next.color && current.highlight === next.highlight && (current.letterSpacing ?? 0) === (next.letterSpacing ?? 0) && trackedChangesCompatible(current, next) && dataAttrsCompatible(current, next);
19295
19405
  if (canMerge) {
19296
19406
  const currText = current.text ?? "";
19297
19407
  const nextText = next.text ?? "";
@@ -19308,10 +19418,62 @@ function mergeAdjacentRuns(runs) {
19308
19418
  merged.push(current);
19309
19419
  return merged;
19310
19420
  }
19421
+ const applyBaseRunDefaults = (run, defaults, fallbackFont, fallbackSize) => {
19422
+ if (!run) return;
19423
+ if (defaults.fontFamily && run.fontFamily === fallbackFont) {
19424
+ run.fontFamily = defaults.fontFamily;
19425
+ }
19426
+ if (defaults.fontSizePx != null && run.fontSize === fallbackSize) {
19427
+ run.fontSize = defaults.fontSizePx;
19428
+ }
19429
+ if (defaults.color && !run.color) {
19430
+ run.color = defaults.color;
19431
+ }
19432
+ if (defaults.letterSpacing != null && run.letterSpacing == null) {
19433
+ run.letterSpacing = defaults.letterSpacing;
19434
+ }
19435
+ if (defaults.bold && run.bold === void 0) {
19436
+ run.bold = true;
19437
+ }
19438
+ if (defaults.italic && run.italic === void 0) {
19439
+ run.italic = true;
19440
+ }
19441
+ if (defaults.underline && !run.underline) {
19442
+ run.underline = defaults.underline;
19443
+ }
19444
+ };
19311
19445
  function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defaultSize, styleContext, listCounterContext, trackedChanges, bookmarks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG$1, themeColors, converters, converterContext) {
19312
19446
  const baseBlockId = nextBlockId("paragraph");
19313
- const paragraphStyleId = typeof para.attrs?.styleId === "string" ? para.attrs.styleId : null;
19447
+ const paragraphProps = typeof para.attrs?.paragraphProperties === "object" && para.attrs.paragraphProperties !== null ? para.attrs.paragraphProperties : {};
19448
+ const paragraphStyleId = typeof para.attrs?.styleId === "string" && para.attrs.styleId.trim() ? para.attrs.styleId : typeof paragraphProps.styleId === "string" && paragraphProps.styleId.trim() ? paragraphProps.styleId : null;
19314
19449
  const paragraphHydration = converterContext ? hydrateParagraphStyleAttrs(para, converterContext) : null;
19450
+ let baseRunDefaults = {};
19451
+ try {
19452
+ const spacingSource = para.attrs?.spacing !== void 0 ? para.attrs.spacing : paragraphProps.spacing !== void 0 ? paragraphProps.spacing : paragraphHydration?.spacing;
19453
+ const indentSource = para.attrs?.indent ?? paragraphProps.indent ?? paragraphHydration?.indent;
19454
+ const normalizedSpacing = normalizeParagraphSpacing(spacingSource);
19455
+ const normalizedIndent = normalizePxIndent(indentSource) ?? normalizeParagraphIndent(indentSource ?? para.attrs?.textIndent);
19456
+ const styleNodeAttrs = paragraphHydration?.tabStops && !para.attrs?.tabStops && !para.attrs?.tabs ? { ...para.attrs ?? {}, tabStops: paragraphHydration.tabStops } : para.attrs ?? {};
19457
+ const styleNode = buildStyleNodeFromAttrs(styleNodeAttrs, normalizedSpacing, normalizedIndent);
19458
+ if (styleNodeAttrs.styleId == null && paragraphProps.styleId) {
19459
+ styleNode.styleId = paragraphProps.styleId;
19460
+ }
19461
+ const resolved = resolveStyle(styleNode, styleContext);
19462
+ baseRunDefaults = {
19463
+ fontFamily: resolved.character.font?.family,
19464
+ fontSizePx: ptToPx(resolved.character.font?.size),
19465
+ color: resolved.character.color,
19466
+ bold: resolved.character.font?.weight != null ? resolved.character.font.weight >= 600 : void 0,
19467
+ italic: resolved.character.font?.italic,
19468
+ underline: resolved.character.underline ? {
19469
+ style: resolved.character.underline.style,
19470
+ color: resolved.character.underline.color
19471
+ } : void 0,
19472
+ letterSpacing: ptToPx(resolved.character.letterSpacing)
19473
+ };
19474
+ } catch {
19475
+ baseRunDefaults = {};
19476
+ }
19315
19477
  const paragraphAttrs = computeParagraphAttrs(
19316
19478
  para,
19317
19479
  styleContext,
@@ -19319,6 +19481,18 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
19319
19481
  converterContext,
19320
19482
  paragraphHydration
19321
19483
  );
19484
+ if (paragraphAttrs?.spacing) {
19485
+ const spacing = { ...paragraphAttrs.spacing };
19486
+ const effectiveFontSize = baseRunDefaults.fontSizePx ?? defaultSize;
19487
+ const isList2 = Boolean(paragraphAttrs.numberingProperties);
19488
+ if (spacing.beforeAutospacing) {
19489
+ spacing.before = isList2 ? 0 : Math.max(0, Number(spacing.before ?? 0) + effectiveFontSize * 0.5);
19490
+ }
19491
+ if (spacing.afterAutospacing) {
19492
+ spacing.after = isList2 ? 0 : Math.max(0, Number(spacing.after ?? 0) + effectiveFontSize * 0.5);
19493
+ }
19494
+ paragraphAttrs.spacing = spacing;
19495
+ }
19322
19496
  const linkedStyleResolver = createLinkedStyleResolver(converterContext?.linkedStyles);
19323
19497
  const blocks = [];
19324
19498
  if (hasPageBreakBefore(para)) {
@@ -19396,6 +19570,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
19396
19570
  );
19397
19571
  const inlineStyleId = getInlineStyleId(inheritedMarks);
19398
19572
  applyRunStyles2(run, inlineStyleId, activeRunStyleId);
19573
+ applyBaseRunDefaults(run, baseRunDefaults, defaultFont, defaultSize);
19399
19574
  currentRuns.push(run);
19400
19575
  return;
19401
19576
  }
@@ -19431,6 +19606,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
19431
19606
  );
19432
19607
  const inlineStyleId = getInlineStyleId(inheritedMarks);
19433
19608
  applyRunStyles2(run, inlineStyleId, activeRunStyleId);
19609
+ applyBaseRunDefaults(run, baseRunDefaults, defaultFont, defaultSize);
19434
19610
  currentRuns.push(run);
19435
19611
  }
19436
19612
  }
@@ -19468,6 +19644,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
19468
19644
  );
19469
19645
  const inlineStyleId = getInlineStyleId(mergedMarks);
19470
19646
  applyRunStyles2(tokenRun, inlineStyleId, activeRunStyleId);
19647
+ applyBaseRunDefaults(tokenRun, baseRunDefaults, defaultFont, defaultSize);
19471
19648
  if (pageRefPos) {
19472
19649
  tokenRun.pmStart = pageRefPos.start;
19473
19650
  tokenRun.pmEnd = pageRefPos.end;
@@ -19526,6 +19703,7 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
19526
19703
  }
19527
19704
  const inlineStyleId = getInlineStyleId(inheritedMarks);
19528
19705
  applyRunStyles2(tokenRun, inlineStyleId, activeRunStyleId);
19706
+ applyBaseRunDefaults(tokenRun, baseRunDefaults, defaultFont, defaultSize);
19529
19707
  currentRuns.push(tokenRun);
19530
19708
  }
19531
19709
  return;
@@ -21554,7 +21732,9 @@ function layoutParagraphBlock(ctx2, anchors) {
21554
21732
  let lines = normalizeLines(measure);
21555
21733
  let fromLine = 0;
21556
21734
  const spacing = block.attrs?.spacing ?? {};
21557
- const spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
21735
+ const styleId = block.attrs?.styleId;
21736
+ const contextualSpacing = Boolean(block.attrs?.contextualSpacing);
21737
+ let spacingBefore = Math.max(0, Number(spacing.before ?? spacing.lineSpaceBefore ?? 0));
21558
21738
  const spacingAfter = Math.max(0, Number(spacing.after ?? spacing.lineSpaceAfter ?? 0));
21559
21739
  let appliedSpacingBefore = spacingBefore === 0;
21560
21740
  let lastState = null;
@@ -21570,6 +21750,15 @@ function layoutParagraphBlock(ctx2, anchors) {
21570
21750
  while (fromLine < lines.length) {
21571
21751
  let state = ensurePage();
21572
21752
  if (state.trailingSpacing == null) state.trailingSpacing = 0;
21753
+ if (contextualSpacing) {
21754
+ const prevStyle = state.lastParagraphStyleId;
21755
+ if (styleId && prevStyle && prevStyle === styleId) {
21756
+ spacingBefore = 0;
21757
+ }
21758
+ }
21759
+ if (contextualSpacing && state.lastParagraphStyleId && styleId && state.lastParagraphStyleId === styleId) {
21760
+ spacingBefore = 0;
21761
+ }
21573
21762
  if (!appliedSpacingBefore && spacingBefore > 0) {
21574
21763
  while (!appliedSpacingBefore) {
21575
21764
  const prevTrailing = state.trailingSpacing ?? 0;
@@ -21738,6 +21927,7 @@ function layoutParagraphBlock(ctx2, anchors) {
21738
21927
  } else {
21739
21928
  lastState.trailingSpacing = 0;
21740
21929
  }
21930
+ lastState.lastParagraphStyleId = styleId;
21741
21931
  }
21742
21932
  }
21743
21933
  function layoutImageBlock({
@@ -21976,7 +22166,8 @@ function createPaginator(opts) {
21976
22166
  contentBottom,
21977
22167
  constraintBoundaries: [],
21978
22168
  activeConstraintIndex: -1,
21979
- trailingSpacing: 0
22169
+ trailingSpacing: 0,
22170
+ lastParagraphStyleId: void 0
21980
22171
  };
21981
22172
  states.push(state);
21982
22173
  pages.push(state.page);
@@ -21998,6 +22189,7 @@ function createPaginator(opts) {
21998
22189
  state.cursorY = state.topMargin;
21999
22190
  }
22000
22191
  state.trailingSpacing = 0;
22192
+ state.lastParagraphStyleId = void 0;
22001
22193
  return state;
22002
22194
  }
22003
22195
  return startNewPage();
@@ -27149,147 +27341,162 @@ const _DomPainter = class _DomPainter {
27149
27341
  return el;
27150
27342
  }
27151
27343
  renderListItemFragment(fragment, context) {
27152
- const lookup = this.blockLookup.get(fragment.blockId);
27153
- if (!lookup || lookup.block.kind !== "list" || lookup.measure.kind !== "list") {
27154
- throw new Error(`DomPainter: missing list data for fragment ${fragment.blockId}`);
27155
- }
27156
- if (!this.doc) {
27157
- throw new Error("DomPainter: document is not available");
27344
+ try {
27345
+ const lookup = this.blockLookup.get(fragment.blockId);
27346
+ if (!lookup || lookup.block.kind !== "list" || lookup.measure.kind !== "list") {
27347
+ throw new Error(`DomPainter: missing list data for fragment ${fragment.blockId}`);
27348
+ }
27349
+ if (!this.doc) {
27350
+ throw new Error("DomPainter: document is not available");
27351
+ }
27352
+ const block = lookup.block;
27353
+ const measure = lookup.measure;
27354
+ const item = block.items.find((entry) => entry.id === fragment.itemId);
27355
+ const itemMeasure = measure.items.find((entry) => entry.itemId === fragment.itemId);
27356
+ if (!item || !itemMeasure) {
27357
+ throw new Error(`DomPainter: missing list item ${fragment.itemId}`);
27358
+ }
27359
+ const fragmentEl = this.doc.createElement("div");
27360
+ fragmentEl.classList.add(CLASS_NAMES.fragment, `${CLASS_NAMES.fragment}-list-item`);
27361
+ applyStyles$2(fragmentEl, fragmentStyles);
27362
+ fragmentEl.style.left = `${fragment.x - fragment.markerWidth}px`;
27363
+ fragmentEl.style.top = `${fragment.y}px`;
27364
+ fragmentEl.style.width = `${fragment.markerWidth + fragment.width}px`;
27365
+ fragmentEl.dataset.blockId = fragment.blockId;
27366
+ fragmentEl.dataset.itemId = fragment.itemId;
27367
+ const paragraphMetadata = item.paragraph.attrs?.sdt;
27368
+ this.applySdtDataset(fragmentEl, paragraphMetadata);
27369
+ if (fragment.continuesFromPrev) {
27370
+ fragmentEl.dataset.continuesFromPrev = "true";
27371
+ }
27372
+ if (fragment.continuesOnNext) {
27373
+ fragmentEl.dataset.continuesOnNext = "true";
27374
+ }
27375
+ const markerEl = this.doc.createElement("span");
27376
+ markerEl.classList.add("superdoc-list-marker");
27377
+ const wordLayout = item.paragraph.attrs?.wordLayout;
27378
+ if (wordLayout?.marker) {
27379
+ const marker = wordLayout.marker;
27380
+ markerEl.textContent = marker.markerText;
27381
+ markerEl.style.display = "inline-block";
27382
+ markerEl.style.width = `${Math.max(0, fragment.markerWidth - LIST_MARKER_GAP$1)}px`;
27383
+ markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
27384
+ markerEl.style.textAlign = marker.justification;
27385
+ markerEl.style.fontFamily = marker.run.fontFamily;
27386
+ markerEl.style.fontSize = `${marker.run.fontSize}px`;
27387
+ if (marker.run.bold) markerEl.style.fontWeight = "bold";
27388
+ if (marker.run.italic) markerEl.style.fontStyle = "italic";
27389
+ if (marker.run.color) markerEl.style.color = marker.run.color;
27390
+ if (marker.run.letterSpacing) markerEl.style.letterSpacing = `${marker.run.letterSpacing}px`;
27391
+ } else {
27392
+ markerEl.textContent = item.marker.text;
27393
+ markerEl.style.display = "inline-block";
27394
+ markerEl.style.width = `${Math.max(0, fragment.markerWidth - LIST_MARKER_GAP$1)}px`;
27395
+ markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
27396
+ if (item.marker.align) {
27397
+ markerEl.style.textAlign = item.marker.align;
27398
+ }
27399
+ }
27400
+ fragmentEl.appendChild(markerEl);
27401
+ const contentEl = this.doc.createElement("div");
27402
+ contentEl.classList.add("superdoc-list-content");
27403
+ this.applySdtDataset(contentEl, paragraphMetadata);
27404
+ contentEl.style.display = "inline-block";
27405
+ contentEl.style.width = `${fragment.width}px`;
27406
+ const lines = itemMeasure.paragraph.lines.slice(fragment.fromLine, fragment.toLine);
27407
+ const contentAttrs = wordLayout ? item.paragraph.attrs : stripListIndent(item.paragraph.attrs);
27408
+ applyParagraphBlockStyles(contentEl, contentAttrs);
27409
+ lines.forEach((line) => {
27410
+ const lineEl = this.renderLine(item.paragraph, line, context);
27411
+ contentEl.appendChild(lineEl);
27412
+ });
27413
+ fragmentEl.appendChild(contentEl);
27414
+ return fragmentEl;
27415
+ } catch (error) {
27416
+ console.error("[DomPainter] List item fragment rendering failed:", { fragment, error });
27417
+ return this.createErrorPlaceholder(fragment.blockId, error);
27158
27418
  }
27159
- const block = lookup.block;
27160
- const measure = lookup.measure;
27161
- const item = block.items.find((entry) => entry.id === fragment.itemId);
27162
- const itemMeasure = measure.items.find((entry) => entry.itemId === fragment.itemId);
27163
- if (!item || !itemMeasure) {
27164
- throw new Error(`DomPainter: missing list item ${fragment.itemId}`);
27165
- }
27166
- const fragmentEl = this.doc.createElement("div");
27167
- fragmentEl.classList.add(CLASS_NAMES.fragment, `${CLASS_NAMES.fragment}-list-item`);
27168
- applyStyles$2(fragmentEl, fragmentStyles);
27169
- fragmentEl.style.left = `${fragment.x - fragment.markerWidth}px`;
27170
- fragmentEl.style.top = `${fragment.y}px`;
27171
- fragmentEl.style.width = `${fragment.markerWidth + fragment.width}px`;
27172
- fragmentEl.dataset.blockId = fragment.blockId;
27173
- fragmentEl.dataset.itemId = fragment.itemId;
27174
- const paragraphMetadata = item.paragraph.attrs?.sdt;
27175
- this.applySdtDataset(fragmentEl, paragraphMetadata);
27176
- if (fragment.continuesFromPrev) {
27177
- fragmentEl.dataset.continuesFromPrev = "true";
27178
- }
27179
- if (fragment.continuesOnNext) {
27180
- fragmentEl.dataset.continuesOnNext = "true";
27181
- }
27182
- const markerEl = this.doc.createElement("span");
27183
- markerEl.classList.add("superdoc-list-marker");
27184
- const wordLayout = item.paragraph.attrs?.wordLayout;
27185
- if (wordLayout?.marker) {
27186
- const marker = wordLayout.marker;
27187
- markerEl.textContent = marker.markerText;
27188
- markerEl.style.display = "inline-block";
27189
- markerEl.style.width = `${Math.max(0, fragment.markerWidth - LIST_MARKER_GAP$1)}px`;
27190
- markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
27191
- markerEl.style.textAlign = marker.justification;
27192
- markerEl.style.fontFamily = marker.run.fontFamily;
27193
- markerEl.style.fontSize = `${marker.run.fontSize}px`;
27194
- if (marker.run.bold) markerEl.style.fontWeight = "bold";
27195
- if (marker.run.italic) markerEl.style.fontStyle = "italic";
27196
- if (marker.run.color) markerEl.style.color = marker.run.color;
27197
- if (marker.run.letterSpacing) markerEl.style.letterSpacing = `${marker.run.letterSpacing}px`;
27198
- } else {
27199
- markerEl.textContent = item.marker.text;
27200
- markerEl.style.display = "inline-block";
27201
- markerEl.style.width = `${Math.max(0, fragment.markerWidth - LIST_MARKER_GAP$1)}px`;
27202
- markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
27203
- if (item.marker.align) {
27204
- markerEl.style.textAlign = item.marker.align;
27205
- }
27206
- }
27207
- fragmentEl.appendChild(markerEl);
27208
- const contentEl = this.doc.createElement("div");
27209
- contentEl.classList.add("superdoc-list-content");
27210
- this.applySdtDataset(contentEl, paragraphMetadata);
27211
- contentEl.style.display = "inline-block";
27212
- contentEl.style.width = `${fragment.width}px`;
27213
- const lines = itemMeasure.paragraph.lines.slice(fragment.fromLine, fragment.toLine);
27214
- const contentAttrs = wordLayout ? item.paragraph.attrs : stripListIndent(item.paragraph.attrs);
27215
- applyParagraphBlockStyles(contentEl, contentAttrs);
27216
- lines.forEach((line) => {
27217
- const lineEl = this.renderLine(item.paragraph, line, context);
27218
- contentEl.appendChild(lineEl);
27219
- });
27220
- fragmentEl.appendChild(contentEl);
27221
- return fragmentEl;
27222
27419
  }
27223
27420
  renderImageFragment(fragment) {
27224
- const lookup = this.blockLookup.get(fragment.blockId);
27225
- if (!lookup || lookup.block.kind !== "image" || lookup.measure.kind !== "image") {
27226
- throw new Error(`DomPainter: missing image block for fragment ${fragment.blockId}`);
27227
- }
27228
- if (!this.doc) {
27229
- throw new Error("DomPainter: document is not available");
27230
- }
27231
- const block = lookup.block;
27232
- const fragmentEl = this.doc.createElement("div");
27233
- fragmentEl.classList.add(CLASS_NAMES.fragment);
27234
- applyStyles$2(fragmentEl, fragmentStyles);
27235
- this.applyFragmentFrame(fragmentEl, fragment);
27236
- fragmentEl.style.height = `${fragment.height}px`;
27237
- this.applySdtDataset(fragmentEl, block.attrs?.sdt);
27238
- this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
27239
- if (fragment.isAnchored && fragment.zIndex != null) {
27240
- fragmentEl.style.zIndex = String(fragment.zIndex);
27241
- }
27242
- const img = this.doc.createElement("img");
27243
- if (block.src) {
27244
- img.src = block.src;
27421
+ try {
27422
+ const lookup = this.blockLookup.get(fragment.blockId);
27423
+ if (!lookup || lookup.block.kind !== "image" || lookup.measure.kind !== "image") {
27424
+ throw new Error(`DomPainter: missing image block for fragment ${fragment.blockId}`);
27425
+ }
27426
+ if (!this.doc) {
27427
+ throw new Error("DomPainter: document is not available");
27428
+ }
27429
+ const block = lookup.block;
27430
+ const fragmentEl = this.doc.createElement("div");
27431
+ fragmentEl.classList.add(CLASS_NAMES.fragment);
27432
+ applyStyles$2(fragmentEl, fragmentStyles);
27433
+ this.applyFragmentFrame(fragmentEl, fragment);
27434
+ fragmentEl.style.height = `${fragment.height}px`;
27435
+ this.applySdtDataset(fragmentEl, block.attrs?.sdt);
27436
+ this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
27437
+ if (fragment.isAnchored && fragment.zIndex != null) {
27438
+ fragmentEl.style.zIndex = String(fragment.zIndex);
27439
+ }
27440
+ const img = this.doc.createElement("img");
27441
+ if (block.src) {
27442
+ img.src = block.src;
27443
+ }
27444
+ img.alt = block.alt ?? "";
27445
+ img.style.width = "100%";
27446
+ img.style.height = "100%";
27447
+ img.style.objectFit = block.objectFit ?? "contain";
27448
+ img.style.display = block.display === "inline" ? "inline-block" : "block";
27449
+ fragmentEl.appendChild(img);
27450
+ return fragmentEl;
27451
+ } catch (error) {
27452
+ console.error("[DomPainter] Image fragment rendering failed:", { fragment, error });
27453
+ return this.createErrorPlaceholder(fragment.blockId, error);
27245
27454
  }
27246
- img.alt = block.alt ?? "";
27247
- img.style.width = "100%";
27248
- img.style.height = "100%";
27249
- img.style.objectFit = block.objectFit ?? "contain";
27250
- img.style.display = block.display === "inline" ? "inline-block" : "block";
27251
- fragmentEl.appendChild(img);
27252
- return fragmentEl;
27253
27455
  }
27254
27456
  renderDrawingFragment(fragment) {
27255
- const lookup = this.blockLookup.get(fragment.blockId);
27256
- if (!lookup || lookup.block.kind !== "drawing" || lookup.measure.kind !== "drawing") {
27257
- throw new Error(`DomPainter: missing drawing block for fragment ${fragment.blockId}`);
27258
- }
27259
- if (!this.doc) {
27260
- throw new Error("DomPainter: document is not available");
27457
+ try {
27458
+ const lookup = this.blockLookup.get(fragment.blockId);
27459
+ if (!lookup || lookup.block.kind !== "drawing" || lookup.measure.kind !== "drawing") {
27460
+ throw new Error(`DomPainter: missing drawing block for fragment ${fragment.blockId}`);
27461
+ }
27462
+ if (!this.doc) {
27463
+ throw new Error("DomPainter: document is not available");
27464
+ }
27465
+ const block = lookup.block;
27466
+ const isVectorShapeBlock = block.kind === "drawing" && block.drawingKind === "vectorShape";
27467
+ const fragmentEl = this.doc.createElement("div");
27468
+ fragmentEl.classList.add(CLASS_NAMES.fragment, "superdoc-drawing-fragment");
27469
+ applyStyles$2(fragmentEl, fragmentStyles);
27470
+ this.applyFragmentFrame(fragmentEl, fragment);
27471
+ fragmentEl.style.height = `${fragment.height}px`;
27472
+ fragmentEl.style.position = "absolute";
27473
+ if (fragment.isAnchored && fragment.zIndex != null) {
27474
+ fragmentEl.style.zIndex = String(fragment.zIndex);
27475
+ }
27476
+ const innerWrapper = this.doc.createElement("div");
27477
+ innerWrapper.classList.add("superdoc-drawing-inner");
27478
+ innerWrapper.style.position = "absolute";
27479
+ innerWrapper.style.left = "50%";
27480
+ innerWrapper.style.top = "50%";
27481
+ innerWrapper.style.width = `${fragment.geometry.width}px`;
27482
+ innerWrapper.style.height = `${fragment.geometry.height}px`;
27483
+ innerWrapper.style.transformOrigin = "center";
27484
+ const scale = fragment.scale ?? 1;
27485
+ const transforms = ["translate(-50%, -50%)"];
27486
+ if (!isVectorShapeBlock) {
27487
+ transforms.push(`rotate(${fragment.geometry.rotation ?? 0}deg)`);
27488
+ transforms.push(`scaleX(${fragment.geometry.flipH ? -1 : 1})`);
27489
+ transforms.push(`scaleY(${fragment.geometry.flipV ? -1 : 1})`);
27490
+ }
27491
+ transforms.push(`scale(${scale})`);
27492
+ innerWrapper.style.transform = transforms.join(" ");
27493
+ innerWrapper.appendChild(this.renderDrawingContent(block, fragment));
27494
+ fragmentEl.appendChild(innerWrapper);
27495
+ return fragmentEl;
27496
+ } catch (error) {
27497
+ console.error("[DomPainter] Drawing fragment rendering failed:", { fragment, error });
27498
+ return this.createErrorPlaceholder(fragment.blockId, error);
27261
27499
  }
27262
- const block = lookup.block;
27263
- const isVectorShapeBlock = block.kind === "drawing" && block.drawingKind === "vectorShape";
27264
- const fragmentEl = this.doc.createElement("div");
27265
- fragmentEl.classList.add(CLASS_NAMES.fragment, "superdoc-drawing-fragment");
27266
- applyStyles$2(fragmentEl, fragmentStyles);
27267
- this.applyFragmentFrame(fragmentEl, fragment);
27268
- fragmentEl.style.height = `${fragment.height}px`;
27269
- fragmentEl.style.position = "absolute";
27270
- if (fragment.isAnchored && fragment.zIndex != null) {
27271
- fragmentEl.style.zIndex = String(fragment.zIndex);
27272
- }
27273
- const innerWrapper = this.doc.createElement("div");
27274
- innerWrapper.classList.add("superdoc-drawing-inner");
27275
- innerWrapper.style.position = "absolute";
27276
- innerWrapper.style.left = "50%";
27277
- innerWrapper.style.top = "50%";
27278
- innerWrapper.style.width = `${fragment.geometry.width}px`;
27279
- innerWrapper.style.height = `${fragment.geometry.height}px`;
27280
- innerWrapper.style.transformOrigin = "center";
27281
- const scale = fragment.scale ?? 1;
27282
- const transforms = ["translate(-50%, -50%)"];
27283
- if (!isVectorShapeBlock) {
27284
- transforms.push(`rotate(${fragment.geometry.rotation ?? 0}deg)`);
27285
- transforms.push(`scaleX(${fragment.geometry.flipH ? -1 : 1})`);
27286
- transforms.push(`scaleY(${fragment.geometry.flipV ? -1 : 1})`);
27287
- }
27288
- transforms.push(`scale(${scale})`);
27289
- innerWrapper.style.transform = transforms.join(" ");
27290
- innerWrapper.appendChild(this.renderDrawingContent(block, fragment));
27291
- fragmentEl.appendChild(innerWrapper);
27292
- return fragmentEl;
27293
27500
  }
27294
27501
  renderDrawingContent(block, fragment) {
27295
27502
  if (!this.doc) {
@@ -27724,6 +27931,7 @@ const _DomPainter = class _DomPainter {
27724
27931
  }
27725
27932
  applyRunStyles(elem, run, isActiveLink);
27726
27933
  elem.style.zIndex = "1";
27934
+ applyRunDataAttributes(elem, run.dataAttrs);
27727
27935
  if (run.pmStart != null) elem.dataset.pmStart = String(run.pmStart);
27728
27936
  if (run.pmEnd != null) elem.dataset.pmEnd = String(run.pmEnd);
27729
27937
  if (trackedConfig) {
@@ -28104,6 +28312,12 @@ const deriveBlockVersion = (block) => {
28104
28312
  run.kind !== "tab" && run.bold ? 1 : 0,
28105
28313
  run.kind !== "tab" && run.italic ? 1 : 0,
28106
28314
  run.kind !== "tab" ? run.color ?? "" : "",
28315
+ // Text decorations - ensures DOM updates when decoration properties change.
28316
+ run.kind !== "tab" ? run.underline?.style ?? "" : "",
28317
+ run.kind !== "tab" ? run.underline?.color ?? "" : "",
28318
+ run.kind !== "tab" && run.strike ? 1 : 0,
28319
+ run.kind !== "tab" ? run.highlight ?? "" : "",
28320
+ run.kind !== "tab" && run.letterSpacing != null ? run.letterSpacing : "",
28107
28321
  run.pmStart ?? "",
28108
28322
  run.pmEnd ?? "",
28109
28323
  run.kind !== "tab" ? run.token ?? "" : ""
@@ -28198,6 +28412,20 @@ const applyRunStyles = (element, run, isLink = false) => {
28198
28412
  element.style.textDecorationLine = decorations.join(" ");
28199
28413
  }
28200
28414
  };
28415
+ const applyRunDataAttributes = (element, dataAttrs) => {
28416
+ if (!dataAttrs) return;
28417
+ Object.entries(dataAttrs).forEach(([key2, value]) => {
28418
+ if (typeof key2 !== "string" || !key2.toLowerCase().startsWith("data-")) return;
28419
+ if (typeof value !== "string") return;
28420
+ try {
28421
+ element.setAttribute(key2, value);
28422
+ } catch (error) {
28423
+ if (process$1.env.NODE_ENV === "development") {
28424
+ console.warn(`[DomPainter] Failed to set data attribute "${key2}":`, error);
28425
+ }
28426
+ }
28427
+ });
28428
+ };
28201
28429
  const applyParagraphBlockStyles = (element, attrs) => {
28202
28430
  if (!attrs) return;
28203
28431
  if (attrs.alignment) {
@@ -32437,7 +32665,8 @@ getHeaderFooterPageHeight_fn = function() {
32437
32665
  return context.layout.pageSize?.h ?? context.region.height ?? 1;
32438
32666
  };
32439
32667
  renderSelectionRects_fn = function(rects) {
32440
- if (!__privateGet(this, _selectionOverlay)) {
32668
+ const localSelectionLayer = __privateGet(this, _localSelectionLayer);
32669
+ if (!localSelectionLayer) {
32441
32670
  return;
32442
32671
  }
32443
32672
  const pageHeight = __privateMethod(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
@@ -32448,7 +32677,7 @@ renderSelectionRects_fn = function(rects) {
32448
32677
  if (!coords) {
32449
32678
  return;
32450
32679
  }
32451
- const highlight = __privateGet(this, _selectionOverlay).ownerDocument?.createElement("div");
32680
+ const highlight = localSelectionLayer.ownerDocument?.createElement("div");
32452
32681
  if (!highlight) {
32453
32682
  return;
32454
32683
  }
@@ -32461,7 +32690,7 @@ renderSelectionRects_fn = function(rects) {
32461
32690
  highlight.style.backgroundColor = "rgba(51, 132, 255, 0.35)";
32462
32691
  highlight.style.borderRadius = "2px";
32463
32692
  highlight.style.pointerEvents = "none";
32464
- __privateGet(this, _selectionOverlay).appendChild(highlight);
32693
+ localSelectionLayer.appendChild(highlight);
32465
32694
  });
32466
32695
  };
32467
32696
  renderHoverRegion_fn = function(region) {
@@ -32912,6 +33141,7 @@ class PresentationInputBridge {
32912
33141
  __privateAdd(this, _onTargetChanged);
32913
33142
  __privateAdd(this, _listeners);
32914
33143
  __privateAdd(this, _currentTarget, null);
33144
+ __privateAdd(this, _destroyed, false);
32915
33145
  __privateSet(this, _windowRoot, windowRoot);
32916
33146
  __privateSet(this, _visibleHost2, visibleHost);
32917
33147
  __privateSet(this, _getTargetDom, getTargetDom);
@@ -32939,9 +33169,13 @@ class PresentationInputBridge {
32939
33169
  });
32940
33170
  __privateSet(this, _listeners, []);
32941
33171
  __privateSet(this, _currentTarget, null);
33172
+ __privateSet(this, _destroyed, true);
32942
33173
  }
32943
33174
  notifyTargetChanged() {
32944
33175
  var _a;
33176
+ if (__privateGet(this, _destroyed)) {
33177
+ return;
33178
+ }
32945
33179
  const nextTarget = __privateGet(this, _getTargetDom).call(this);
32946
33180
  if (nextTarget === __privateGet(this, _currentTarget)) {
32947
33181
  return;
@@ -32971,6 +33205,7 @@ _getTargetDom = new WeakMap();
32971
33205
  _onTargetChanged = new WeakMap();
32972
33206
  _listeners = new WeakMap();
32973
33207
  _currentTarget = new WeakMap();
33208
+ _destroyed = new WeakMap();
32974
33209
  _PresentationInputBridge_instances = new WeakSet();
32975
33210
  addListener_fn = function(type, handler, target) {
32976
33211
  const bound = handler.bind(this);
@@ -32978,12 +33213,21 @@ addListener_fn = function(type, handler, target) {
32978
33213
  target.addEventListener(type, bound, true);
32979
33214
  };
32980
33215
  dispatchToTarget_fn = function(originalEvent, synthetic) {
33216
+ if (__privateGet(this, _destroyed)) return;
32981
33217
  const target = __privateGet(this, _getTargetDom).call(this);
32982
33218
  __privateSet(this, _currentTarget, target);
32983
33219
  if (!target) return;
32984
- const canceled = !target.dispatchEvent(synthetic) || synthetic.defaultPrevented;
32985
- if (canceled) {
32986
- originalEvent.preventDefault();
33220
+ const isConnected = target.isConnected;
33221
+ if (isConnected === false) return;
33222
+ try {
33223
+ const canceled = !target.dispatchEvent(synthetic) || synthetic.defaultPrevented;
33224
+ if (canceled) {
33225
+ originalEvent.preventDefault();
33226
+ }
33227
+ } catch (error) {
33228
+ if (process$1.env.NODE_ENV === "development") {
33229
+ console.warn("[PresentationEditor] Failed to dispatch event to target:", error);
33230
+ }
32987
33231
  }
32988
33232
  };
32989
33233
  forwardKeyboardEvent_fn = function(event) {