@harbour-enterprises/superdoc 1.0.0-beta.31 → 1.0.0-beta.33
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.
- package/dist/chunks/{PdfViewer-C8iiBtQt.cjs → PdfViewer-1hoKlV0M.cjs} +1 -1
- package/dist/chunks/{PdfViewer-jGctuklH.es.js → PdfViewer-CVrn4X-3.es.js} +1 -1
- package/dist/chunks/{index-Bu5UUj9S.es.js → index-BTDOWM_2.es.js} +57 -32
- package/dist/chunks/{index-ELjoBC86.cjs → index-VKd9fPLu.cjs} +57 -32
- package/dist/chunks/{index-eG-VYUeN-CIuOnW8W.es.js → index-hX4H5xPH-ChjioDix.es.js} +1 -1
- package/dist/chunks/{index-eG-VYUeN-CG3M1n5T.cjs → index-hX4H5xPH-DfkQd7UH.cjs} +1 -1
- package/dist/chunks/{super-editor.es-BAKZgAuj.es.js → super-editor.es-CpmC4G9F.es.js} +1467 -138
- package/dist/chunks/{super-editor.es-DatOA_vA.cjs → super-editor.es-Dzrm58hW.cjs} +1467 -138
- package/dist/style.css +33 -33
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-CRKt1TG_.js → converter-DZNL-ld-.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-CgVw58T-.js → docx-zipper-DukE72iM.js} +1 -1
- package/dist/super-editor/chunks/{editor-COQCS1pn.js → editor-CJCGDp-l.js} +1516 -128
- package/dist/super-editor/chunks/{index-eG-VYUeN.js → index-hX4H5xPH.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-B3CSV2yT.js → toolbar-D6tqFv6-.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +6 -6
- package/dist/super-editor/toolbar.es.js +2 -2
- package/dist/super-editor.cjs +1 -1
- package/dist/super-editor.es.js +1 -1
- package/dist/superdoc.cjs +2 -2
- package/dist/superdoc.es.js +2 -2
- package/dist/superdoc.umd.js +1523 -169
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -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, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _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, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _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, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_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, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_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, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _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, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_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, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
|
|
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, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, collectCommentPositions_fn, 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, setupDragHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, calculateExtendedSelection_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handlePointerUp, _handleDragOver, _handleDrop, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, layoutPerRIdHeaderFooters_fn, updateDecorationProviders_fn, createDecorationProvider_fn, findHeaderFooterPageForPageNumber_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, createDefaultHeaderFooter_fn, getPageElement_fn, scrollPageIntoView_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, renderSelectionRects_fn, renderHoverRegion_fn, clearHoverRegion_fn, renderCaretOverlay_fn, getHeaderFooterContext_fn, computeHeaderFooterSelectionRects_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, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _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, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_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, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
|
|
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 changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, 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 decodeRPrFromMarks, ar as calculateResolvedParagraphProperties, as as encodeCSSFromPPr, at as twipsToPixels$2, au as resolveRunProperties, av as encodeCSSFromRPr, aw as generateOrderedListIndex, ax as docxNumberingHelpers, ay as InputRule, az as convertSizeToCSS, aA as SelectionRange, aB as Transform, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-
|
|
16
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
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 changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, 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 decodeRPrFromMarks, ar as calculateResolvedParagraphProperties, as as encodeCSSFromPPr, at as twipsToPixels$2, au as resolveRunProperties, av as encodeCSSFromRPr, aw as generateOrderedListIndex, ax as docxNumberingHelpers, ay as InputRule, az as convertSizeToCSS, aA as SelectionRange, aB as Transform, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-DZNL-ld-.js";
|
|
16
|
+
import { D as DocxZipper } from "./docx-zipper-DukE72iM.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() {
|
|
@@ -10875,13 +10875,13 @@ const findTrackedMarkBetween = ({
|
|
|
10875
10875
|
return markFound;
|
|
10876
10876
|
};
|
|
10877
10877
|
const markInsertion = ({ tr, from: from2, to, user, date }) => {
|
|
10878
|
-
tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName]);
|
|
10879
|
-
tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName]);
|
|
10878
|
+
tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackDeleteMarkName$1]);
|
|
10879
|
+
tr.removeMark(from2, to, tr.doc.type.schema.marks[TrackInsertMarkName$1]);
|
|
10880
10880
|
let trackedMark = findTrackedMarkBetween({
|
|
10881
10881
|
tr,
|
|
10882
10882
|
from: from2,
|
|
10883
10883
|
to,
|
|
10884
|
-
markName: TrackInsertMarkName,
|
|
10884
|
+
markName: TrackInsertMarkName$1,
|
|
10885
10885
|
attrs: { authorEmail: user.email }
|
|
10886
10886
|
});
|
|
10887
10887
|
let id;
|
|
@@ -10890,7 +10890,7 @@ const markInsertion = ({ tr, from: from2, to, user, date }) => {
|
|
|
10890
10890
|
} else {
|
|
10891
10891
|
id = v4();
|
|
10892
10892
|
}
|
|
10893
|
-
const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName].create({
|
|
10893
|
+
const insertionMark = tr.doc.type.schema.marks[TrackInsertMarkName$1].create({
|
|
10894
10894
|
id,
|
|
10895
10895
|
author: user.name,
|
|
10896
10896
|
authorEmail: user.email,
|
|
@@ -10916,7 +10916,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
|
|
|
10916
10916
|
tr,
|
|
10917
10917
|
from: from2,
|
|
10918
10918
|
to,
|
|
10919
|
-
markName: TrackDeleteMarkName,
|
|
10919
|
+
markName: TrackDeleteMarkName$1,
|
|
10920
10920
|
attrs: { authorEmail: user.email }
|
|
10921
10921
|
});
|
|
10922
10922
|
let id;
|
|
@@ -10927,7 +10927,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
|
|
|
10927
10927
|
} else {
|
|
10928
10928
|
id = v4();
|
|
10929
10929
|
}
|
|
10930
|
-
const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName].create({
|
|
10930
|
+
const deletionMark = tr.doc.type.schema.marks[TrackDeleteMarkName$1].create({
|
|
10931
10931
|
id,
|
|
10932
10932
|
author: user.name,
|
|
10933
10933
|
authorEmail: user.email,
|
|
@@ -10940,7 +10940,7 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
|
|
|
10940
10940
|
if (node.type.name.includes("table")) {
|
|
10941
10941
|
return;
|
|
10942
10942
|
}
|
|
10943
|
-
if (node.isInline && node.marks.find((mark) => mark.type.name === TrackInsertMarkName && mark.attrs.authorEmail === user.email)) {
|
|
10943
|
+
if (node.isInline && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1 && mark.attrs.authorEmail === user.email)) {
|
|
10944
10944
|
const removeStep = new ReplaceStep(
|
|
10945
10945
|
deletionMap.map(Math.max(from2, pos)),
|
|
10946
10946
|
deletionMap.map(Math.min(to, pos + node.nodeSize)),
|
|
@@ -10949,14 +10949,14 @@ const markDeletion = ({ tr, from: from2, to, user, date, id: providedId }) => {
|
|
|
10949
10949
|
if (!tr.maybeStep(removeStep).failed) {
|
|
10950
10950
|
deletionMap.appendMap(removeStep.getMap());
|
|
10951
10951
|
}
|
|
10952
|
-
} else if (node.isInline && !node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
10952
|
+
} else if (node.isInline && !node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
|
|
10953
10953
|
nodes.push(node);
|
|
10954
10954
|
tr.addMark(
|
|
10955
10955
|
deletionMap.map(Math.max(from2, pos)),
|
|
10956
10956
|
deletionMap.map(Math.min(to, pos + node.nodeSize)),
|
|
10957
10957
|
deletionMark
|
|
10958
10958
|
);
|
|
10959
|
-
} else if (node.attrs.track && !node.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName) && !["bulletList", "orderedList"].includes(node.type.name)) ;
|
|
10959
|
+
} else if (node.attrs.track && !node.attrs.track.find((trackAttr) => trackAttr.type === TrackDeleteMarkName$1) && !["bulletList", "orderedList"].includes(node.type.name)) ;
|
|
10960
10960
|
});
|
|
10961
10961
|
return { deletionMark, deletionMap, nodes };
|
|
10962
10962
|
};
|
|
@@ -11023,7 +11023,7 @@ const getTrackChanges = (state, id = null) => {
|
|
|
11023
11023
|
}
|
|
11024
11024
|
allInlineNodes.forEach(({ node, pos }) => {
|
|
11025
11025
|
const { marks } = node;
|
|
11026
|
-
const trackedMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
|
|
11026
|
+
const trackedMarks = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
|
|
11027
11027
|
if (marks.length > 0) {
|
|
11028
11028
|
marks.forEach((mark) => {
|
|
11029
11029
|
if (trackedMarks.includes(mark.type.name)) {
|
|
@@ -11136,7 +11136,7 @@ const getTrackChangesDecorations = (state, onlyOriginalShown, onlyModifiedShown)
|
|
|
11136
11136
|
return DecorationSet.empty;
|
|
11137
11137
|
}
|
|
11138
11138
|
trackedChanges.forEach(({ mark, from: from2, to }) => {
|
|
11139
|
-
if (mark.type.name === TrackInsertMarkName) {
|
|
11139
|
+
if (mark.type.name === TrackInsertMarkName$1) {
|
|
11140
11140
|
if (onlyOriginalShown) {
|
|
11141
11141
|
const decoration = Decoration.inline(from2, to, {
|
|
11142
11142
|
class: "track-insert-dec hidden"
|
|
@@ -11154,7 +11154,7 @@ const getTrackChangesDecorations = (state, onlyOriginalShown, onlyModifiedShown)
|
|
|
11154
11154
|
decorations.push(decoration);
|
|
11155
11155
|
}
|
|
11156
11156
|
}
|
|
11157
|
-
if (mark.type.name === TrackDeleteMarkName) {
|
|
11157
|
+
if (mark.type.name === TrackDeleteMarkName$1) {
|
|
11158
11158
|
if (onlyOriginalShown) {
|
|
11159
11159
|
const decoration = Decoration.inline(from2, to, {
|
|
11160
11160
|
class: "track-delete-dec normal"
|
|
@@ -11186,7 +11186,7 @@ const getTrackChangesDecorations = (state, onlyOriginalShown, onlyModifiedShown)
|
|
|
11186
11186
|
decorations.push(decorationWidget);
|
|
11187
11187
|
}
|
|
11188
11188
|
}
|
|
11189
|
-
if (mark.type.name === TrackFormatMarkName) {
|
|
11189
|
+
if (mark.type.name === TrackFormatMarkName$1) {
|
|
11190
11190
|
if (onlyOriginalShown) {
|
|
11191
11191
|
const decoration = Decoration.inline(from2, to, {
|
|
11192
11192
|
class: "track-format-dec before"
|
|
@@ -11207,7 +11207,7 @@ const getTrackChangesDecorations = (state, onlyOriginalShown, onlyModifiedShown)
|
|
|
11207
11207
|
});
|
|
11208
11208
|
return DecorationSet.create(state.doc, decorations);
|
|
11209
11209
|
};
|
|
11210
|
-
const CommentMarkName = "commentMark";
|
|
11210
|
+
const CommentMarkName$1 = "commentMark";
|
|
11211
11211
|
const resolveCommentMeta = ({ converter, importedId }) => {
|
|
11212
11212
|
const comments = converter?.comments || [];
|
|
11213
11213
|
const matchingImportedComment = comments.find((c) => c.importedId == importedId);
|
|
@@ -11238,7 +11238,7 @@ const ensureFallbackComment = ({ converter, matchingImportedComment, commentId,
|
|
|
11238
11238
|
const removeCommentsById = ({ commentId, state, tr, dispatch }) => {
|
|
11239
11239
|
const positions = getCommentPositionsById(commentId, state.doc);
|
|
11240
11240
|
positions.forEach(({ from: from2, to }) => {
|
|
11241
|
-
tr.removeMark(from2, to, state.schema.marks[CommentMarkName]);
|
|
11241
|
+
tr.removeMark(from2, to, state.schema.marks[CommentMarkName$1]);
|
|
11242
11242
|
});
|
|
11243
11243
|
dispatch(tr);
|
|
11244
11244
|
};
|
|
@@ -11246,7 +11246,7 @@ const getCommentPositionsById = (commentId, doc2) => {
|
|
|
11246
11246
|
const positions = [];
|
|
11247
11247
|
doc2.descendants((node, pos) => {
|
|
11248
11248
|
const { marks } = node;
|
|
11249
|
-
const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
|
|
11249
|
+
const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
|
|
11250
11250
|
if (commentMark) {
|
|
11251
11251
|
const { attrs } = commentMark;
|
|
11252
11252
|
const { commentId: currentCommentId } = attrs;
|
|
@@ -11266,7 +11266,7 @@ const prepareCommentsForExport = (doc2, tr, schema, comments = []) => {
|
|
|
11266
11266
|
const endNodes = [];
|
|
11267
11267
|
const seen = /* @__PURE__ */ new Set();
|
|
11268
11268
|
doc2.descendants((node, pos) => {
|
|
11269
|
-
const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName) || [];
|
|
11269
|
+
const commentMarks = node.marks?.filter((mark) => mark.type.name === CommentMarkName$1) || [];
|
|
11270
11270
|
commentMarks.forEach((commentMark) => {
|
|
11271
11271
|
const { attrs = {} } = commentMark;
|
|
11272
11272
|
const { commentId } = attrs;
|
|
@@ -11394,7 +11394,7 @@ const prepareCommentsForImport = (doc2, tr, schema, converter) => {
|
|
|
11394
11394
|
importedId,
|
|
11395
11395
|
internal: itemToMark.internal
|
|
11396
11396
|
};
|
|
11397
|
-
tr.addMark(start2, pos + 1, schema.marks[CommentMarkName].create(markAttrs));
|
|
11397
|
+
tr.addMark(start2, pos + 1, schema.marks[CommentMarkName$1].create(markAttrs));
|
|
11398
11398
|
toDelete.push({ start: pos, end: pos + 1 });
|
|
11399
11399
|
} else if (type.name === "commentReference") {
|
|
11400
11400
|
toDelete.push({ start: pos, end: pos + 1 });
|
|
@@ -11512,7 +11512,7 @@ const updatePosition = ({ allCommentPositions, threadId, pos, currentBounds, nod
|
|
|
11512
11512
|
existing.bounds.bottom = Math.max(existing.bounds.bottom, currentBounds.bottom);
|
|
11513
11513
|
}
|
|
11514
11514
|
};
|
|
11515
|
-
const TRACK_CHANGE_MARKS = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
|
|
11515
|
+
const TRACK_CHANGE_MARKS = [TrackInsertMarkName$1, TrackDeleteMarkName$1, TrackFormatMarkName$1];
|
|
11516
11516
|
const CommentsPluginKey = new PluginKey("comments");
|
|
11517
11517
|
const CommentsPlugin = Extension.create({
|
|
11518
11518
|
name: "comments",
|
|
@@ -11528,7 +11528,7 @@ const CommentsPlugin = Extension.create({
|
|
|
11528
11528
|
tr.addMark(
|
|
11529
11529
|
$from.pos,
|
|
11530
11530
|
$to.pos,
|
|
11531
|
-
this.editor.schema.marks[CommentMarkName].create({
|
|
11531
|
+
this.editor.schema.marks[CommentMarkName$1].create({
|
|
11532
11532
|
commentId: resolvedCommentId,
|
|
11533
11533
|
internal: resolvedInternal
|
|
11534
11534
|
})
|
|
@@ -11568,7 +11568,7 @@ const CommentsPlugin = Extension.create({
|
|
|
11568
11568
|
doc2.descendants((node, pos) => {
|
|
11569
11569
|
if (foundStartNode) return;
|
|
11570
11570
|
const { marks = [] } = node;
|
|
11571
|
-
const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
|
|
11571
|
+
const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
|
|
11572
11572
|
if (commentMark) {
|
|
11573
11573
|
const { attrs } = commentMark;
|
|
11574
11574
|
const wid = attrs.commentId;
|
|
@@ -11582,7 +11582,7 @@ const CommentsPlugin = Extension.create({
|
|
|
11582
11582
|
tr.addMark(
|
|
11583
11583
|
foundPos,
|
|
11584
11584
|
foundPos + foundStartNode.nodeSize,
|
|
11585
|
-
this.editor.schema.marks[CommentMarkName].create({
|
|
11585
|
+
this.editor.schema.marks[CommentMarkName$1].create({
|
|
11586
11586
|
commentId,
|
|
11587
11587
|
internal: isInternal
|
|
11588
11588
|
})
|
|
@@ -11711,10 +11711,10 @@ const CommentsPlugin = Extension.create({
|
|
|
11711
11711
|
prevDoc = doc2;
|
|
11712
11712
|
shouldUpdate = false;
|
|
11713
11713
|
const decorations = [];
|
|
11714
|
-
const allCommentPositions =
|
|
11714
|
+
const allCommentPositions = {};
|
|
11715
11715
|
doc2.descendants((node, pos) => {
|
|
11716
11716
|
const { marks = [] } = node;
|
|
11717
|
-
const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName);
|
|
11717
|
+
const commentMarks = marks.filter((mark) => mark.type.name === CommentMarkName$1);
|
|
11718
11718
|
let hasActive = false;
|
|
11719
11719
|
commentMarks.forEach((commentMark) => {
|
|
11720
11720
|
const { attrs } = commentMark;
|
|
@@ -11840,7 +11840,7 @@ const getActiveCommentId = (doc2, selection) => {
|
|
|
11840
11840
|
return;
|
|
11841
11841
|
}
|
|
11842
11842
|
const { marks = [] } = node;
|
|
11843
|
-
const commentMark = marks.find((mark) => mark.type.name === CommentMarkName);
|
|
11843
|
+
const commentMark = marks.find((mark) => mark.type.name === CommentMarkName$1);
|
|
11844
11844
|
if (commentMark) {
|
|
11845
11845
|
overlaps.push({
|
|
11846
11846
|
node,
|
|
@@ -11863,7 +11863,7 @@ const getActiveCommentId = (doc2, selection) => {
|
|
|
11863
11863
|
}
|
|
11864
11864
|
});
|
|
11865
11865
|
const { marks: closestMarks = [] } = closestCommentRangeStart || {};
|
|
11866
|
-
const closestCommentMark = closestMarks.find((mark) => mark.type.name === CommentMarkName);
|
|
11866
|
+
const closestCommentMark = closestMarks.find((mark) => mark.type.name === CommentMarkName$1);
|
|
11867
11867
|
return closestCommentMark?.attrs?.commentId || closestCommentMark?.attrs?.importedId;
|
|
11868
11868
|
};
|
|
11869
11869
|
const findTrackedMark = ({
|
|
@@ -11913,7 +11913,7 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
|
|
|
11913
11913
|
let nodes = step?.slice?.content?.content || [];
|
|
11914
11914
|
if (!nodes.length) {
|
|
11915
11915
|
newEditorState.doc.descendants((node) => {
|
|
11916
|
-
const hasFormatMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
11916
|
+
const hasFormatMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
|
|
11917
11917
|
if (hasFormatMark) {
|
|
11918
11918
|
nodes = [node];
|
|
11919
11919
|
return false;
|
|
@@ -11938,19 +11938,19 @@ const handleTrackedChangeTransaction = (trackedChangeMeta, trackedChanges, newEd
|
|
|
11938
11938
|
const getTrackedChangeText = ({ nodes, mark, trackedChangeType, isDeletionInsertion }) => {
|
|
11939
11939
|
let trackedChangeText = "";
|
|
11940
11940
|
let deletionText = "";
|
|
11941
|
-
if (trackedChangeType === TrackInsertMarkName) {
|
|
11941
|
+
if (trackedChangeType === TrackInsertMarkName$1) {
|
|
11942
11942
|
trackedChangeText = nodes.reduce((acc, node) => {
|
|
11943
11943
|
if (!node.marks.find((nodeMark) => nodeMark.type.name === mark.type.name)) return acc;
|
|
11944
11944
|
acc += node?.text || node?.textContent || "";
|
|
11945
11945
|
return acc;
|
|
11946
11946
|
}, "");
|
|
11947
11947
|
}
|
|
11948
|
-
if (trackedChangeType === TrackFormatMarkName) {
|
|
11948
|
+
if (trackedChangeType === TrackFormatMarkName$1) {
|
|
11949
11949
|
trackedChangeText = translateFormatChangesToEnglish(mark.attrs);
|
|
11950
11950
|
}
|
|
11951
|
-
if (trackedChangeType === TrackDeleteMarkName || isDeletionInsertion) {
|
|
11951
|
+
if (trackedChangeType === TrackDeleteMarkName$1 || isDeletionInsertion) {
|
|
11952
11952
|
deletionText = nodes.reduce((acc, node) => {
|
|
11953
|
-
if (!node.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName)) return acc;
|
|
11953
|
+
if (!node.marks.find((nodeMark) => nodeMark.type.name === TrackDeleteMarkName$1)) return acc;
|
|
11954
11954
|
acc += node?.text || node?.textContent || "";
|
|
11955
11955
|
return acc;
|
|
11956
11956
|
}, "");
|
|
@@ -12016,7 +12016,7 @@ function findRangeById(doc2, id) {
|
|
|
12016
12016
|
if (to === null || pos + node.nodeSize > to) to = pos + node.nodeSize;
|
|
12017
12017
|
}
|
|
12018
12018
|
const commentMark = node.marks.find(
|
|
12019
|
-
(m) => m.type.name === CommentMarkName && (m.attrs.commentId === id || m.attrs.importedId === id)
|
|
12019
|
+
(m) => m.type.name === CommentMarkName$1 && (m.attrs.commentId === id || m.attrs.importedId === id)
|
|
12020
12020
|
);
|
|
12021
12021
|
if (commentMark) {
|
|
12022
12022
|
if (from2 === null || pos < from2) from2 = pos;
|
|
@@ -12026,7 +12026,7 @@ function findRangeById(doc2, id) {
|
|
|
12026
12026
|
return from2 !== null && to !== null ? { from: from2, to } : null;
|
|
12027
12027
|
}
|
|
12028
12028
|
const replaceStep = ({ state, tr, step, newTr, map: map2, user, date, originalStep, originalStepIndex }) => {
|
|
12029
|
-
const deletionMarkSchema = state.schema.marks[TrackDeleteMarkName];
|
|
12029
|
+
const deletionMarkSchema = state.schema.marks[TrackDeleteMarkName$1];
|
|
12030
12030
|
const deletionMark = findMark(state, deletionMarkSchema, false);
|
|
12031
12031
|
const positionTo = deletionMark ? deletionMark.to : step.to;
|
|
12032
12032
|
const newStep = new ReplaceStep(
|
|
@@ -12090,17 +12090,17 @@ const addMarkStep = ({ state, step, newTr, doc: doc2, user, date }) => {
|
|
|
12090
12090
|
if (!node.isInline) {
|
|
12091
12091
|
return;
|
|
12092
12092
|
}
|
|
12093
|
-
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
12093
|
+
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
|
|
12094
12094
|
return false;
|
|
12095
12095
|
}
|
|
12096
12096
|
const existingChangeMark = node.marks.find(
|
|
12097
|
-
(mark) => [TrackDeleteMarkName, TrackFormatMarkName].includes(mark.type.name)
|
|
12097
|
+
(mark) => [TrackDeleteMarkName$1, TrackFormatMarkName$1].includes(mark.type.name)
|
|
12098
12098
|
);
|
|
12099
12099
|
const wid = existingChangeMark ? existingChangeMark.attrs.id : v4();
|
|
12100
12100
|
newTr.addMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
|
|
12101
12101
|
const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
|
|
12102
12102
|
if (allowedMarks.includes(step.mark.type.name) && !node.marks.find((mark) => mark.type === step.mark.type)) {
|
|
12103
|
-
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
12103
|
+
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
|
|
12104
12104
|
let after = [];
|
|
12105
12105
|
let before = [];
|
|
12106
12106
|
if (formatChangeMark) {
|
|
@@ -12136,7 +12136,7 @@ const addMarkStep = ({ state, step, newTr, doc: doc2, user, date }) => {
|
|
|
12136
12136
|
];
|
|
12137
12137
|
}
|
|
12138
12138
|
if (after.length || before.length) {
|
|
12139
|
-
const newFormatMark = state.schema.marks[TrackFormatMarkName].create({
|
|
12139
|
+
const newFormatMark = state.schema.marks[TrackFormatMarkName$1].create({
|
|
12140
12140
|
id: wid,
|
|
12141
12141
|
author: user.name,
|
|
12142
12142
|
authorEmail: user.email,
|
|
@@ -12168,13 +12168,13 @@ const removeMarkStep = ({ state, step, newTr, doc: doc2, user, date }) => {
|
|
|
12168
12168
|
if (!node.isInline) {
|
|
12169
12169
|
return true;
|
|
12170
12170
|
}
|
|
12171
|
-
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
12171
|
+
if (node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
|
|
12172
12172
|
return false;
|
|
12173
12173
|
}
|
|
12174
12174
|
newTr.removeMark(Math.max(step.from, pos), Math.min(step.to, pos + node.nodeSize), step.mark);
|
|
12175
12175
|
const allowedMarks = ["bold", "italic", "strike", "underline", "textStyle"];
|
|
12176
12176
|
if (allowedMarks.includes(step.mark.type.name) && node.marks.find((mark) => mark.type === step.mark.type)) {
|
|
12177
|
-
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
12177
|
+
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
|
|
12178
12178
|
let after = [];
|
|
12179
12179
|
let before = [];
|
|
12180
12180
|
if (formatChangeMark) {
|
|
@@ -12202,7 +12202,7 @@ const removeMarkStep = ({ state, step, newTr, doc: doc2, user, date }) => {
|
|
|
12202
12202
|
];
|
|
12203
12203
|
}
|
|
12204
12204
|
if (after.length || before.length) {
|
|
12205
|
-
const newFormatMark = state.schema.marks[TrackFormatMarkName].create({
|
|
12205
|
+
const newFormatMark = state.schema.marks[TrackFormatMarkName$1].create({
|
|
12206
12206
|
id: v4(),
|
|
12207
12207
|
author: user.name,
|
|
12208
12208
|
authorEmail: user.email,
|
|
@@ -12283,7 +12283,7 @@ const trackedTransaction = ({ tr, state, user }) => {
|
|
|
12283
12283
|
newTr.setMeta("addToHistory", tr.getMeta("addToHistory"));
|
|
12284
12284
|
}
|
|
12285
12285
|
if (tr.selectionSet) {
|
|
12286
|
-
const deletionMarkSchema = state.schema.marks[TrackDeleteMarkName];
|
|
12286
|
+
const deletionMarkSchema = state.schema.marks[TrackDeleteMarkName$1];
|
|
12287
12287
|
const deletionMark = findMark(state, deletionMarkSchema, false);
|
|
12288
12288
|
if (tr.selection instanceof TextSelection && (tr.selection.from < state.selection.from || tr.getMeta("inputType") === "deleteContentBackward")) {
|
|
12289
12289
|
const caretPos = map2.map(tr.selection.from, -1);
|
|
@@ -13913,7 +13913,7 @@ const isHeadless = (editor) => {
|
|
|
13913
13913
|
const shouldSkipNodeView = (editor) => {
|
|
13914
13914
|
return isHeadless(editor);
|
|
13915
13915
|
};
|
|
13916
|
-
const summaryVersion = "1.0.0-beta.
|
|
13916
|
+
const summaryVersion = "1.0.0-beta.33";
|
|
13917
13917
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
13918
13918
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
13919
13919
|
function mapAttributes(attrs) {
|
|
@@ -14705,7 +14705,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14705
14705
|
{ default: remarkStringify },
|
|
14706
14706
|
{ default: remarkGfm }
|
|
14707
14707
|
] = await Promise.all([
|
|
14708
|
-
import("./index-
|
|
14708
|
+
import("./index-hX4H5xPH.js"),
|
|
14709
14709
|
import("./index-DRCvimau.js"),
|
|
14710
14710
|
import("./index-C_x_N6Uh.js"),
|
|
14711
14711
|
import("./index-D_sWOSiG.js"),
|
|
@@ -14910,7 +14910,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14910
14910
|
* Process collaboration migrations
|
|
14911
14911
|
*/
|
|
14912
14912
|
processCollaborationMigrations() {
|
|
14913
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
14913
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.33");
|
|
14914
14914
|
if (!this.options.ydoc) return;
|
|
14915
14915
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14916
14916
|
let docVersion = metaMap.get("version");
|
|
@@ -20140,7 +20140,27 @@ function handleStructuredContentBlockNode(node, context) {
|
|
|
20140
20140
|
blocks.push(block);
|
|
20141
20141
|
recordBlockKind(block.kind);
|
|
20142
20142
|
});
|
|
20143
|
-
} else if (child.type === "table")
|
|
20143
|
+
} else if (child.type === "table") {
|
|
20144
|
+
const tableNodeToBlock2 = converters?.tableNodeToBlock;
|
|
20145
|
+
if (tableNodeToBlock2) {
|
|
20146
|
+
const tableBlock = tableNodeToBlock2(
|
|
20147
|
+
child,
|
|
20148
|
+
nextBlockId,
|
|
20149
|
+
positions,
|
|
20150
|
+
defaultFont,
|
|
20151
|
+
defaultSize,
|
|
20152
|
+
styleContext,
|
|
20153
|
+
trackedChangesConfig,
|
|
20154
|
+
bookmarks,
|
|
20155
|
+
hyperlinkConfig
|
|
20156
|
+
);
|
|
20157
|
+
if (tableBlock) {
|
|
20158
|
+
applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
|
|
20159
|
+
blocks.push(tableBlock);
|
|
20160
|
+
recordBlockKind(tableBlock.kind);
|
|
20161
|
+
}
|
|
20162
|
+
}
|
|
20163
|
+
}
|
|
20144
20164
|
});
|
|
20145
20165
|
}
|
|
20146
20166
|
function processParagraphChild(child, sectionMetadata, context, output, converters) {
|
|
@@ -20610,6 +20630,65 @@ function imageNodeToRun(node, positions, activeSdt) {
|
|
|
20610
20630
|
}
|
|
20611
20631
|
return run;
|
|
20612
20632
|
}
|
|
20633
|
+
function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
|
|
20634
|
+
const attrs = node.attrs ?? {};
|
|
20635
|
+
const rawVariant = attrs.type ?? fieldMetadata?.variant ?? "text";
|
|
20636
|
+
const validVariants = ["text", "image", "signature", "checkbox", "html", "link"];
|
|
20637
|
+
const variant = validVariants.includes(rawVariant) ? rawVariant : "text";
|
|
20638
|
+
const displayLabel = (typeof attrs.displayLabel === "string" ? attrs.displayLabel : void 0) || (typeof attrs.defaultDisplayLabel === "string" ? attrs.defaultDisplayLabel : void 0) || (typeof fieldMetadata?.displayLabel === "string" ? fieldMetadata.displayLabel : void 0) || (typeof fieldMetadata?.defaultDisplayLabel === "string" ? fieldMetadata.defaultDisplayLabel : void 0) || (typeof attrs.alias === "string" ? attrs.alias : void 0) || (typeof fieldMetadata?.alias === "string" ? fieldMetadata.alias : void 0) || "";
|
|
20639
|
+
const run = {
|
|
20640
|
+
kind: "fieldAnnotation",
|
|
20641
|
+
variant,
|
|
20642
|
+
displayLabel
|
|
20643
|
+
};
|
|
20644
|
+
const fieldId = typeof attrs.fieldId === "string" ? attrs.fieldId : fieldMetadata?.fieldId;
|
|
20645
|
+
if (fieldId) run.fieldId = fieldId;
|
|
20646
|
+
const fieldType = typeof attrs.fieldType === "string" ? attrs.fieldType : fieldMetadata?.fieldType;
|
|
20647
|
+
if (fieldType) run.fieldType = fieldType;
|
|
20648
|
+
const fieldColor = typeof attrs.fieldColor === "string" ? attrs.fieldColor : fieldMetadata?.fieldColor;
|
|
20649
|
+
if (fieldColor) run.fieldColor = fieldColor;
|
|
20650
|
+
const borderColor = typeof attrs.borderColor === "string" ? attrs.borderColor : fieldMetadata?.borderColor;
|
|
20651
|
+
if (borderColor) run.borderColor = borderColor;
|
|
20652
|
+
const highlighted = attrs.highlighted ?? fieldMetadata?.highlighted;
|
|
20653
|
+
if (highlighted === false) run.highlighted = false;
|
|
20654
|
+
if (attrs.hidden === true || fieldMetadata?.hidden === true) run.hidden = true;
|
|
20655
|
+
const visibility = attrs.visibility ?? fieldMetadata?.visibility;
|
|
20656
|
+
if (visibility === "hidden") run.visibility = "hidden";
|
|
20657
|
+
const imageSrc = typeof attrs.imageSrc === "string" ? attrs.imageSrc : fieldMetadata?.imageSrc;
|
|
20658
|
+
if (imageSrc) run.imageSrc = imageSrc;
|
|
20659
|
+
const linkUrl = typeof attrs.linkUrl === "string" ? attrs.linkUrl : fieldMetadata?.linkUrl;
|
|
20660
|
+
if (linkUrl) run.linkUrl = linkUrl;
|
|
20661
|
+
const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
|
|
20662
|
+
if (typeof rawHtml === "string") run.rawHtml = rawHtml;
|
|
20663
|
+
const size = attrs.size ?? fieldMetadata?.size;
|
|
20664
|
+
if (size && (typeof size.width === "number" || typeof size.height === "number")) {
|
|
20665
|
+
run.size = {
|
|
20666
|
+
width: typeof size.width === "number" ? size.width : void 0,
|
|
20667
|
+
height: typeof size.height === "number" ? size.height : void 0
|
|
20668
|
+
};
|
|
20669
|
+
}
|
|
20670
|
+
const fontFamily = attrs.fontFamily ?? fieldMetadata?.fontFamily;
|
|
20671
|
+
if (typeof fontFamily === "string") run.fontFamily = fontFamily;
|
|
20672
|
+
const fontSize = attrs.fontSize ?? fieldMetadata?.fontSize;
|
|
20673
|
+
if (typeof fontSize === "string" || typeof fontSize === "number") run.fontSize = fontSize;
|
|
20674
|
+
const textColor = attrs.textColor ?? fieldMetadata?.textColor;
|
|
20675
|
+
if (typeof textColor === "string") run.textColor = textColor;
|
|
20676
|
+
const textHighlight = attrs.textHighlight ?? fieldMetadata?.textHighlight;
|
|
20677
|
+
if (typeof textHighlight === "string") run.textHighlight = textHighlight;
|
|
20678
|
+
const formatting = fieldMetadata?.formatting;
|
|
20679
|
+
if (attrs.bold === true || formatting?.bold === true) run.bold = true;
|
|
20680
|
+
if (attrs.italic === true || formatting?.italic === true) run.italic = true;
|
|
20681
|
+
if (attrs.underline === true || formatting?.underline === true) run.underline = true;
|
|
20682
|
+
const pos = positions.get(node);
|
|
20683
|
+
if (pos) {
|
|
20684
|
+
run.pmStart = pos.start;
|
|
20685
|
+
run.pmEnd = pos.end;
|
|
20686
|
+
}
|
|
20687
|
+
if (fieldMetadata) {
|
|
20688
|
+
run.sdt = fieldMetadata;
|
|
20689
|
+
}
|
|
20690
|
+
return run;
|
|
20691
|
+
}
|
|
20613
20692
|
const isTextRun$1 = (run) => run.kind !== "tab";
|
|
20614
20693
|
const dataAttrsCompatible = (a, b) => {
|
|
20615
20694
|
const aAttrs = a.dataAttrs;
|
|
@@ -20905,28 +20984,20 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
20905
20984
|
}
|
|
20906
20985
|
if (node.type === "fieldAnnotation") {
|
|
20907
20986
|
const fieldMetadata = resolveNodeSdtMetadata(node, "fieldAnnotation");
|
|
20987
|
+
let contentText;
|
|
20908
20988
|
if (Array.isArray(node.content) && node.content.length > 0) {
|
|
20909
|
-
|
|
20910
|
-
|
|
20911
|
-
|
|
20912
|
-
|
|
20913
|
-
|
|
20914
|
-
|
|
20915
|
-
|
|
20916
|
-
|
|
20917
|
-
defaultFont,
|
|
20918
|
-
defaultSize,
|
|
20919
|
-
inheritedMarks,
|
|
20920
|
-
fieldMetadata ?? activeSdt,
|
|
20921
|
-
hyperlinkConfig,
|
|
20922
|
-
themeColors
|
|
20923
|
-
);
|
|
20924
|
-
const inlineStyleId = getInlineStyleId(inheritedMarks);
|
|
20925
|
-
applyRunStyles2(run, inlineStyleId, activeRunStyleId);
|
|
20926
|
-
applyBaseRunDefaults(run, baseRunDefaults, defaultFont, defaultSize);
|
|
20927
|
-
currentRuns.push(run);
|
|
20928
|
-
}
|
|
20989
|
+
const extractText = (n) => {
|
|
20990
|
+
if (n.type === "text" && typeof n.text === "string") return n.text;
|
|
20991
|
+
if (Array.isArray(n.content)) {
|
|
20992
|
+
return n.content.map(extractText).join("");
|
|
20993
|
+
}
|
|
20994
|
+
return "";
|
|
20995
|
+
};
|
|
20996
|
+
contentText = node.content.map(extractText).join("");
|
|
20929
20997
|
}
|
|
20998
|
+
const nodeForRun = contentText && contentText.length > 0 ? { ...node, attrs: { ...node.attrs ?? {}, displayLabel: contentText } } : node;
|
|
20999
|
+
const run = fieldAnnotationNodeToRun(nodeForRun, positions, fieldMetadata);
|
|
21000
|
+
currentRuns.push(run);
|
|
20930
21001
|
return;
|
|
20931
21002
|
}
|
|
20932
21003
|
if (node.type === "pageReference") {
|
|
@@ -21763,9 +21834,9 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
|
|
|
21763
21834
|
}
|
|
21764
21835
|
const attrs = spacingEl.attributes;
|
|
21765
21836
|
const spacing = {};
|
|
21766
|
-
const before = parseIntSafe(attrs["w:before"]);
|
|
21767
|
-
const after = parseIntSafe(attrs["w:after"]);
|
|
21768
|
-
const line = parseIntSafe(attrs["w:line"]);
|
|
21837
|
+
const before = parseIntSafe$1(attrs["w:before"]);
|
|
21838
|
+
const after = parseIntSafe$1(attrs["w:after"]);
|
|
21839
|
+
const line = parseIntSafe$1(attrs["w:line"]);
|
|
21769
21840
|
const rawLineRule = attrs["w:lineRule"];
|
|
21770
21841
|
const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
|
|
21771
21842
|
if (before != null) spacing.before = twipsToPx$1(before);
|
|
@@ -21780,11 +21851,11 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
|
|
|
21780
21851
|
if (lineRule) spacing.lineRule = lineRule;
|
|
21781
21852
|
const result = Object.keys(spacing).length > 0 ? { spacing } : void 0;
|
|
21782
21853
|
return result;
|
|
21783
|
-
} catch
|
|
21854
|
+
} catch {
|
|
21784
21855
|
return void 0;
|
|
21785
21856
|
}
|
|
21786
21857
|
};
|
|
21787
|
-
const parseIntSafe = (value) => {
|
|
21858
|
+
const parseIntSafe$1 = (value) => {
|
|
21788
21859
|
if (value == null) return void 0;
|
|
21789
21860
|
const num = typeof value === "number" ? value : parseInt(String(value), 10);
|
|
21790
21861
|
return Number.isFinite(num) ? num : void 0;
|
|
@@ -22436,7 +22507,7 @@ function getMeasurementContext() {
|
|
|
22436
22507
|
return measurementCtx;
|
|
22437
22508
|
}
|
|
22438
22509
|
function getRunFontString(run) {
|
|
22439
|
-
if (run.kind === "tab" || run.kind === "lineBreak" || run.kind === "break" || "src" in run) {
|
|
22510
|
+
if (run.kind === "tab" || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" || "src" in run) {
|
|
22440
22511
|
return "normal normal 16px Arial";
|
|
22441
22512
|
}
|
|
22442
22513
|
const style = run.italic ? "italic" : "normal";
|
|
@@ -22467,6 +22538,10 @@ function sliceRunsForLine$1(block, line) {
|
|
|
22467
22538
|
result.push(run);
|
|
22468
22539
|
continue;
|
|
22469
22540
|
}
|
|
22541
|
+
if (run.kind === "fieldAnnotation") {
|
|
22542
|
+
result.push(run);
|
|
22543
|
+
continue;
|
|
22544
|
+
}
|
|
22470
22545
|
const text = run.text ?? "";
|
|
22471
22546
|
const isFirstRun = runIndex === line.fromRun;
|
|
22472
22547
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -22500,7 +22575,8 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
22500
22575
|
1,
|
|
22501
22576
|
runs2.reduce((sum, run) => {
|
|
22502
22577
|
if (isTabRun$1(run)) return sum + TAB_CHAR_LENGTH;
|
|
22503
|
-
if ("src" in run || run.kind === "lineBreak" || run.kind === "break"
|
|
22578
|
+
if ("src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation")
|
|
22579
|
+
return sum;
|
|
22504
22580
|
return sum + (run.text ?? "").length;
|
|
22505
22581
|
}, 0)
|
|
22506
22582
|
);
|
|
@@ -22521,7 +22597,7 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
22521
22597
|
currentCharOffset += runLength2;
|
|
22522
22598
|
continue;
|
|
22523
22599
|
}
|
|
22524
|
-
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text ?? "";
|
|
22600
|
+
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
|
|
22525
22601
|
const runLength = text.length;
|
|
22526
22602
|
if (currentCharOffset + runLength >= charOffset) {
|
|
22527
22603
|
const offsetInRun = charOffset - currentCharOffset;
|
|
@@ -22564,7 +22640,7 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
22564
22640
|
if (isTabRun$1(run)) {
|
|
22565
22641
|
return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
|
|
22566
22642
|
}
|
|
22567
|
-
if ("src" in run || run.kind === "lineBreak" || run.kind === "break") {
|
|
22643
|
+
if ("src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation") {
|
|
22568
22644
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
22569
22645
|
}
|
|
22570
22646
|
const text = run.text ?? "";
|
|
@@ -22593,7 +22669,7 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
|
|
|
22593
22669
|
let lastPm = fallbackPmStart;
|
|
22594
22670
|
for (const run of runs) {
|
|
22595
22671
|
const isTab = isTabRun$1(run);
|
|
22596
|
-
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text ?? "";
|
|
22672
|
+
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
|
|
22597
22673
|
const runLength = isTab ? TAB_CHAR_LENGTH : text.length;
|
|
22598
22674
|
const runPmStart = typeof run.pmStart === "number" ? run.pmStart : null;
|
|
22599
22675
|
const runPmEnd = typeof run.pmEnd === "number" ? run.pmEnd : runPmStart != null ? runPmStart + runLength : null;
|
|
@@ -22619,7 +22695,8 @@ function findCharacterAtX(block, line, x, pmStart) {
|
|
|
22619
22695
|
1,
|
|
22620
22696
|
runs2.reduce((sum, run) => {
|
|
22621
22697
|
if (isTabRun$1(run)) return sum + TAB_CHAR_LENGTH;
|
|
22622
|
-
if ("src" in run || run.kind === "lineBreak" || run.kind === "break"
|
|
22698
|
+
if ("src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation")
|
|
22699
|
+
return sum;
|
|
22623
22700
|
return sum + (run.text ?? "").length;
|
|
22624
22701
|
}, 0)
|
|
22625
22702
|
);
|
|
@@ -22654,7 +22731,7 @@ function findCharacterAtX(block, line, x, pmStart) {
|
|
|
22654
22731
|
currentCharOffset += TAB_CHAR_LENGTH;
|
|
22655
22732
|
continue;
|
|
22656
22733
|
}
|
|
22657
|
-
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text ?? "";
|
|
22734
|
+
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
|
|
22658
22735
|
const runLength = text.length;
|
|
22659
22736
|
if (runLength === 0) continue;
|
|
22660
22737
|
ctx2.font = getRunFontString(run);
|
|
@@ -22694,7 +22771,7 @@ function findCharacterAtX(block, line, x, pmStart) {
|
|
|
22694
22771
|
};
|
|
22695
22772
|
}
|
|
22696
22773
|
const computeLetterSpacingWidth = (run, precedingChars, runLength) => {
|
|
22697
|
-
if (isTabRun$1(run) || "src" in run || !("letterSpacing" in run) || !run.letterSpacing) {
|
|
22774
|
+
if (isTabRun$1(run) || "src" in run || run.kind === "fieldAnnotation" || !("letterSpacing" in run) || !run.letterSpacing) {
|
|
22698
22775
|
return 0;
|
|
22699
22776
|
}
|
|
22700
22777
|
const maxGaps = Math.max(runLength - 1, 0);
|
|
@@ -22791,6 +22868,17 @@ function clickToPositionDom(domContainer, clientX, clientY) {
|
|
|
22791
22868
|
pmStart: fragmentEl.dataset.pmStart,
|
|
22792
22869
|
pmEnd: fragmentEl.dataset.pmEnd
|
|
22793
22870
|
});
|
|
22871
|
+
const hitChainLine = hitChain.find(
|
|
22872
|
+
(el) => el.classList?.contains?.(CLASS_NAMES$1.line) && el.dataset?.pmStart !== void 0 && el.dataset?.pmEnd !== void 0
|
|
22873
|
+
);
|
|
22874
|
+
if (hitChainLine) {
|
|
22875
|
+
log("Using hit chain line directly:", {
|
|
22876
|
+
pmStart: hitChainLine.dataset.pmStart,
|
|
22877
|
+
pmEnd: hitChainLine.dataset.pmEnd
|
|
22878
|
+
});
|
|
22879
|
+
const result2 = processLineElement(hitChainLine, viewX);
|
|
22880
|
+
return result2;
|
|
22881
|
+
}
|
|
22794
22882
|
const result = processFragment(fragmentEl, viewX, viewY);
|
|
22795
22883
|
return result;
|
|
22796
22884
|
}
|
|
@@ -22856,7 +22944,9 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
22856
22944
|
if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
|
|
22857
22945
|
return null;
|
|
22858
22946
|
}
|
|
22859
|
-
const spanEls = Array.from(lineEl.querySelectorAll("span, a"))
|
|
22947
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
|
|
22948
|
+
(el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
|
|
22949
|
+
);
|
|
22860
22950
|
log(
|
|
22861
22951
|
"Spans/anchors in line:",
|
|
22862
22952
|
spanEls.map((el, i) => {
|
|
@@ -22915,6 +23005,77 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
22915
23005
|
const pos = spanStart + charIndex;
|
|
22916
23006
|
return pos;
|
|
22917
23007
|
}
|
|
23008
|
+
function processLineElement(lineEl, viewX) {
|
|
23009
|
+
const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
|
|
23010
|
+
const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
|
|
23011
|
+
const lineRect = lineEl.getBoundingClientRect();
|
|
23012
|
+
log("processLineElement:", {
|
|
23013
|
+
pmStart: lineStart,
|
|
23014
|
+
pmEnd: lineEnd,
|
|
23015
|
+
rect: { top: lineRect.top, bottom: lineRect.bottom, left: lineRect.left, right: lineRect.right }
|
|
23016
|
+
});
|
|
23017
|
+
if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
|
|
23018
|
+
return null;
|
|
23019
|
+
}
|
|
23020
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
|
|
23021
|
+
(el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
|
|
23022
|
+
);
|
|
23023
|
+
log(
|
|
23024
|
+
"Spans/anchors in line:",
|
|
23025
|
+
spanEls.map((el, i) => {
|
|
23026
|
+
const rect = el.getBoundingClientRect();
|
|
23027
|
+
return {
|
|
23028
|
+
index: i,
|
|
23029
|
+
tag: el.tagName,
|
|
23030
|
+
pmStart: el.dataset.pmStart,
|
|
23031
|
+
pmEnd: el.dataset.pmEnd,
|
|
23032
|
+
text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
|
|
23033
|
+
visibility: el.style.visibility,
|
|
23034
|
+
rect: { left: rect.left, right: rect.right, width: rect.width }
|
|
23035
|
+
};
|
|
23036
|
+
})
|
|
23037
|
+
);
|
|
23038
|
+
if (spanEls.length === 0) {
|
|
23039
|
+
return lineStart;
|
|
23040
|
+
}
|
|
23041
|
+
const firstRect = spanEls[0].getBoundingClientRect();
|
|
23042
|
+
if (viewX <= firstRect.left) {
|
|
23043
|
+
return lineStart;
|
|
23044
|
+
}
|
|
23045
|
+
const lastRect = spanEls[spanEls.length - 1].getBoundingClientRect();
|
|
23046
|
+
if (viewX >= lastRect.right) {
|
|
23047
|
+
return lineEnd;
|
|
23048
|
+
}
|
|
23049
|
+
const targetEl = findSpanAtX(spanEls, viewX);
|
|
23050
|
+
if (!targetEl) {
|
|
23051
|
+
return lineStart;
|
|
23052
|
+
}
|
|
23053
|
+
const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
|
|
23054
|
+
const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
|
|
23055
|
+
const targetRect = targetEl.getBoundingClientRect();
|
|
23056
|
+
log("Target element:", {
|
|
23057
|
+
tag: targetEl.tagName,
|
|
23058
|
+
pmStart: spanStart,
|
|
23059
|
+
pmEnd: spanEnd,
|
|
23060
|
+
text: targetEl.textContent?.substring(0, 30),
|
|
23061
|
+
visibility: targetEl.style.visibility,
|
|
23062
|
+
rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width }
|
|
23063
|
+
});
|
|
23064
|
+
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
|
|
23065
|
+
return null;
|
|
23066
|
+
}
|
|
23067
|
+
const firstChild = targetEl.firstChild;
|
|
23068
|
+
if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
|
|
23069
|
+
const elRect = targetEl.getBoundingClientRect();
|
|
23070
|
+
const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
|
|
23071
|
+
const snapPos = closerToLeft ? spanStart : spanEnd;
|
|
23072
|
+
return snapPos;
|
|
23073
|
+
}
|
|
23074
|
+
const textNode = firstChild;
|
|
23075
|
+
const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
|
|
23076
|
+
const pos = spanStart + charIndex;
|
|
23077
|
+
return pos;
|
|
23078
|
+
}
|
|
22918
23079
|
function findLineAtY(lineEls, viewY) {
|
|
22919
23080
|
if (lineEls.length === 0) {
|
|
22920
23081
|
return null;
|
|
@@ -25805,7 +25966,7 @@ const hashRuns = (block) => {
|
|
|
25805
25966
|
return `img:${srcHash}:${imgRun.width}x${imgRun.height}`;
|
|
25806
25967
|
}
|
|
25807
25968
|
const text = normalizeText(
|
|
25808
|
-
"src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text ?? ""
|
|
25969
|
+
"src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? ""
|
|
25809
25970
|
);
|
|
25810
25971
|
const bold = "bold" in run ? run.bold : false;
|
|
25811
25972
|
const italic = "italic" in run ? run.italic : false;
|
|
@@ -26517,7 +26678,7 @@ function extractBlockText(block) {
|
|
|
26517
26678
|
let pmStart = Infinity;
|
|
26518
26679
|
let pmEnd = 0;
|
|
26519
26680
|
for (const run of block.runs) {
|
|
26520
|
-
text += "src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text;
|
|
26681
|
+
text += "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text;
|
|
26521
26682
|
if (run.pmStart !== void 0) {
|
|
26522
26683
|
pmStart = Math.min(pmStart, run.pmStart);
|
|
26523
26684
|
}
|
|
@@ -26567,7 +26728,7 @@ function fontString(run) {
|
|
|
26567
26728
|
return `${italic}${bold}${size}px ${family}`.trim();
|
|
26568
26729
|
}
|
|
26569
26730
|
function runText(run) {
|
|
26570
|
-
return "src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text ?? "";
|
|
26731
|
+
return "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
|
|
26571
26732
|
}
|
|
26572
26733
|
function measureRunSliceWidth(run, fromChar, toChar) {
|
|
26573
26734
|
const context = getCtx();
|
|
@@ -26729,7 +26890,7 @@ const paragraphBlocksEqual = (a, b) => {
|
|
|
26729
26890
|
for (let i = 0; i < a.runs.length; i += 1) {
|
|
26730
26891
|
const runA = a.runs[i];
|
|
26731
26892
|
const runB = b.runs[i];
|
|
26732
|
-
if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
|
|
26893
|
+
if (("src" in runA || runA.kind === "lineBreak" || runA.kind === "break" || runA.kind === "fieldAnnotation" ? "" : runA.text) !== ("src" in runB || runB.kind === "lineBreak" || runB.kind === "break" || runB.kind === "fieldAnnotation" ? "" : runB.text) || ("bold" in runA ? runA.bold : false) !== ("bold" in runB ? runB.bold : false) || ("italic" in runA ? runA.italic : false) !== ("italic" in runB ? runB.italic : false) || ("color" in runA ? runA.color : void 0) !== ("color" in runB ? runB.color : void 0) || getTrackedChangeKey(runA) !== getTrackedChangeKey(runB)) {
|
|
26733
26894
|
return false;
|
|
26734
26895
|
}
|
|
26735
26896
|
}
|
|
@@ -26849,7 +27010,7 @@ function computeHeaderFooterContentHash(blocks) {
|
|
|
26849
27010
|
parts.push(block.id);
|
|
26850
27011
|
if (block.kind === "paragraph") {
|
|
26851
27012
|
for (const run of block.runs) {
|
|
26852
|
-
if (!("src" in run) && run.kind !== "lineBreak" && run.kind !== "break") {
|
|
27013
|
+
if (!("src" in run) && run.kind !== "lineBreak" && run.kind !== "break" && run.kind !== "fieldAnnotation") {
|
|
26853
27014
|
parts.push(run.text ?? "");
|
|
26854
27015
|
}
|
|
26855
27016
|
if ("bold" in run && run.bold) parts.push("b");
|
|
@@ -27334,6 +27495,255 @@ var Priority = /* @__PURE__ */ ((Priority2) => {
|
|
|
27334
27495
|
/** P3: Heavy debounce for full document layout */
|
|
27335
27496
|
[Priority.P3]: 150
|
|
27336
27497
|
});
|
|
27498
|
+
const DEFAULT_MIME_TYPE$1 = "application/x-field-annotation";
|
|
27499
|
+
const LEGACY_MIME_TYPE = "fieldAnnotation";
|
|
27500
|
+
function parseIntSafe(value) {
|
|
27501
|
+
if (!value) return void 0;
|
|
27502
|
+
const parsed = parseInt(value, 10);
|
|
27503
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
27504
|
+
}
|
|
27505
|
+
function extractFieldAnnotationData(element) {
|
|
27506
|
+
const dataset = element.dataset;
|
|
27507
|
+
const attributes = {};
|
|
27508
|
+
for (const key2 in dataset) {
|
|
27509
|
+
const value = dataset[key2];
|
|
27510
|
+
if (value !== void 0) {
|
|
27511
|
+
attributes[key2] = value;
|
|
27512
|
+
}
|
|
27513
|
+
}
|
|
27514
|
+
return {
|
|
27515
|
+
fieldId: dataset.fieldId,
|
|
27516
|
+
fieldType: dataset.fieldType,
|
|
27517
|
+
variant: dataset.variant ?? dataset.type,
|
|
27518
|
+
displayLabel: dataset.displayLabel,
|
|
27519
|
+
pmStart: parseIntSafe(dataset.pmStart),
|
|
27520
|
+
pmEnd: parseIntSafe(dataset.pmEnd),
|
|
27521
|
+
attributes
|
|
27522
|
+
};
|
|
27523
|
+
}
|
|
27524
|
+
class DragHandler {
|
|
27525
|
+
/**
|
|
27526
|
+
* Creates a new DragHandler instance.
|
|
27527
|
+
*
|
|
27528
|
+
* @param container - The DOM container element (typically .superdoc-layout)
|
|
27529
|
+
* @param config - Configuration options and callbacks
|
|
27530
|
+
*/
|
|
27531
|
+
constructor(container, config = {}) {
|
|
27532
|
+
this.container = container;
|
|
27533
|
+
this.config = config;
|
|
27534
|
+
this.mimeType = config.mimeType ?? DEFAULT_MIME_TYPE$1;
|
|
27535
|
+
this.boundHandlers = {
|
|
27536
|
+
dragstart: this.handleDragStart.bind(this),
|
|
27537
|
+
dragover: this.handleDragOver.bind(this),
|
|
27538
|
+
drop: this.handleDrop.bind(this),
|
|
27539
|
+
dragend: this.handleDragEnd.bind(this),
|
|
27540
|
+
dragleave: this.handleDragLeave.bind(this)
|
|
27541
|
+
};
|
|
27542
|
+
this.windowDragoverHandler = this.handleWindowDragOver.bind(this);
|
|
27543
|
+
this.windowDropHandler = this.handleWindowDrop.bind(this);
|
|
27544
|
+
this.attachListeners();
|
|
27545
|
+
}
|
|
27546
|
+
/**
|
|
27547
|
+
* Attaches event listeners to the container and window.
|
|
27548
|
+
*/
|
|
27549
|
+
attachListeners() {
|
|
27550
|
+
this.container.addEventListener("dragstart", this.boundHandlers.dragstart);
|
|
27551
|
+
this.container.addEventListener("dragover", this.boundHandlers.dragover);
|
|
27552
|
+
this.container.addEventListener("drop", this.boundHandlers.drop);
|
|
27553
|
+
this.container.addEventListener("dragend", this.boundHandlers.dragend);
|
|
27554
|
+
this.container.addEventListener("dragleave", this.boundHandlers.dragleave);
|
|
27555
|
+
window.addEventListener("dragover", this.windowDragoverHandler, false);
|
|
27556
|
+
window.addEventListener("drop", this.windowDropHandler, false);
|
|
27557
|
+
}
|
|
27558
|
+
/**
|
|
27559
|
+
* Removes event listeners from the container and window.
|
|
27560
|
+
*/
|
|
27561
|
+
removeListeners() {
|
|
27562
|
+
this.container.removeEventListener("dragstart", this.boundHandlers.dragstart);
|
|
27563
|
+
this.container.removeEventListener("dragover", this.boundHandlers.dragover);
|
|
27564
|
+
this.container.removeEventListener("drop", this.boundHandlers.drop);
|
|
27565
|
+
this.container.removeEventListener("dragend", this.boundHandlers.dragend);
|
|
27566
|
+
this.container.removeEventListener("dragleave", this.boundHandlers.dragleave);
|
|
27567
|
+
window.removeEventListener("dragover", this.windowDragoverHandler, false);
|
|
27568
|
+
window.removeEventListener("drop", this.windowDropHandler, false);
|
|
27569
|
+
}
|
|
27570
|
+
/**
|
|
27571
|
+
* Handles dragover at window level to allow drops on overlay elements.
|
|
27572
|
+
* This ensures preventDefault is called even when dragging over selection
|
|
27573
|
+
* highlights or other UI elements that sit on top of the layout content.
|
|
27574
|
+
*/
|
|
27575
|
+
handleWindowDragOver(event) {
|
|
27576
|
+
if (this.hasFieldAnnotationData(event)) {
|
|
27577
|
+
event.preventDefault();
|
|
27578
|
+
if (event.dataTransfer) {
|
|
27579
|
+
event.dataTransfer.dropEffect = "move";
|
|
27580
|
+
}
|
|
27581
|
+
const target = event.target;
|
|
27582
|
+
if (!this.container.contains(target)) {
|
|
27583
|
+
this.config.onDragOver?.({
|
|
27584
|
+
event,
|
|
27585
|
+
clientX: event.clientX,
|
|
27586
|
+
clientY: event.clientY,
|
|
27587
|
+
hasFieldAnnotation: true
|
|
27588
|
+
});
|
|
27589
|
+
}
|
|
27590
|
+
}
|
|
27591
|
+
}
|
|
27592
|
+
/**
|
|
27593
|
+
* Handles drop at window level to catch drops on overlay elements.
|
|
27594
|
+
* If the drop target is outside the container, we process it here.
|
|
27595
|
+
*/
|
|
27596
|
+
handleWindowDrop(event) {
|
|
27597
|
+
if (this.hasFieldAnnotationData(event)) {
|
|
27598
|
+
const target = event.target;
|
|
27599
|
+
if (!this.container.contains(target)) {
|
|
27600
|
+
this.handleDrop(event);
|
|
27601
|
+
}
|
|
27602
|
+
}
|
|
27603
|
+
}
|
|
27604
|
+
/**
|
|
27605
|
+
* Handles the dragstart event.
|
|
27606
|
+
* Sets up dataTransfer with field annotation data and drag image.
|
|
27607
|
+
*/
|
|
27608
|
+
handleDragStart(event) {
|
|
27609
|
+
const target = event.target;
|
|
27610
|
+
if (!target?.dataset?.draggable || target.dataset.draggable !== "true") {
|
|
27611
|
+
return;
|
|
27612
|
+
}
|
|
27613
|
+
const data = extractFieldAnnotationData(target);
|
|
27614
|
+
if (event.dataTransfer) {
|
|
27615
|
+
const jsonData = JSON.stringify({
|
|
27616
|
+
attributes: data.attributes,
|
|
27617
|
+
sourceField: data
|
|
27618
|
+
});
|
|
27619
|
+
event.dataTransfer.setData(this.mimeType, jsonData);
|
|
27620
|
+
event.dataTransfer.setData(LEGACY_MIME_TYPE, jsonData);
|
|
27621
|
+
event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
|
|
27622
|
+
event.dataTransfer.setDragImage(target, 0, 0);
|
|
27623
|
+
event.dataTransfer.effectAllowed = "move";
|
|
27624
|
+
}
|
|
27625
|
+
this.config.onDragStart?.({
|
|
27626
|
+
event,
|
|
27627
|
+
element: target,
|
|
27628
|
+
data
|
|
27629
|
+
});
|
|
27630
|
+
}
|
|
27631
|
+
/**
|
|
27632
|
+
* Handles the dragover event.
|
|
27633
|
+
* Provides visual feedback and determines if drop is allowed.
|
|
27634
|
+
*/
|
|
27635
|
+
handleDragOver(event) {
|
|
27636
|
+
const hasFieldAnnotation = this.hasFieldAnnotationData(event);
|
|
27637
|
+
if (hasFieldAnnotation) {
|
|
27638
|
+
event.preventDefault();
|
|
27639
|
+
if (event.dataTransfer) {
|
|
27640
|
+
event.dataTransfer.dropEffect = "move";
|
|
27641
|
+
}
|
|
27642
|
+
this.container.classList.add("drag-over");
|
|
27643
|
+
}
|
|
27644
|
+
this.config.onDragOver?.({
|
|
27645
|
+
event,
|
|
27646
|
+
clientX: event.clientX,
|
|
27647
|
+
clientY: event.clientY,
|
|
27648
|
+
hasFieldAnnotation
|
|
27649
|
+
});
|
|
27650
|
+
}
|
|
27651
|
+
/**
|
|
27652
|
+
* Handles the dragleave event.
|
|
27653
|
+
* Removes visual feedback when drag leaves the container.
|
|
27654
|
+
*/
|
|
27655
|
+
handleDragLeave(event) {
|
|
27656
|
+
const relatedTarget = event.relatedTarget;
|
|
27657
|
+
if (!relatedTarget || !this.container.contains(relatedTarget)) {
|
|
27658
|
+
this.container.classList.remove("drag-over");
|
|
27659
|
+
}
|
|
27660
|
+
}
|
|
27661
|
+
/**
|
|
27662
|
+
* Handles the drop event.
|
|
27663
|
+
* Maps drop coordinates to ProseMirror position and emits drop event.
|
|
27664
|
+
*/
|
|
27665
|
+
handleDrop(event) {
|
|
27666
|
+
this.container.classList.remove("drag-over");
|
|
27667
|
+
if (!this.hasFieldAnnotationData(event)) {
|
|
27668
|
+
return;
|
|
27669
|
+
}
|
|
27670
|
+
event.preventDefault();
|
|
27671
|
+
const data = this.extractDragData(event);
|
|
27672
|
+
if (!data) {
|
|
27673
|
+
return;
|
|
27674
|
+
}
|
|
27675
|
+
const pmPosition = clickToPositionDom(this.container, event.clientX, event.clientY);
|
|
27676
|
+
this.config.onDrop?.({
|
|
27677
|
+
event,
|
|
27678
|
+
data,
|
|
27679
|
+
pmPosition,
|
|
27680
|
+
clientX: event.clientX,
|
|
27681
|
+
clientY: event.clientY
|
|
27682
|
+
});
|
|
27683
|
+
}
|
|
27684
|
+
/**
|
|
27685
|
+
* Handles the dragend event.
|
|
27686
|
+
* Cleans up drag state.
|
|
27687
|
+
*/
|
|
27688
|
+
handleDragEnd(event) {
|
|
27689
|
+
this.container.classList.remove("drag-over");
|
|
27690
|
+
this.config.onDragEnd?.(event);
|
|
27691
|
+
}
|
|
27692
|
+
/**
|
|
27693
|
+
* Checks if a drag event contains field annotation data.
|
|
27694
|
+
*/
|
|
27695
|
+
hasFieldAnnotationData(event) {
|
|
27696
|
+
if (!event.dataTransfer) {
|
|
27697
|
+
return false;
|
|
27698
|
+
}
|
|
27699
|
+
const types = event.dataTransfer.types;
|
|
27700
|
+
return types.includes(this.mimeType) || types.includes(LEGACY_MIME_TYPE);
|
|
27701
|
+
}
|
|
27702
|
+
/**
|
|
27703
|
+
* Extracts field annotation data from a drag event's dataTransfer.
|
|
27704
|
+
*/
|
|
27705
|
+
extractDragData(event) {
|
|
27706
|
+
if (!event.dataTransfer) {
|
|
27707
|
+
return null;
|
|
27708
|
+
}
|
|
27709
|
+
let jsonData = event.dataTransfer.getData(this.mimeType);
|
|
27710
|
+
if (!jsonData) {
|
|
27711
|
+
jsonData = event.dataTransfer.getData(LEGACY_MIME_TYPE);
|
|
27712
|
+
}
|
|
27713
|
+
if (!jsonData) {
|
|
27714
|
+
return null;
|
|
27715
|
+
}
|
|
27716
|
+
try {
|
|
27717
|
+
const parsed = JSON.parse(jsonData);
|
|
27718
|
+
return parsed.sourceField ?? parsed.attributes ?? parsed;
|
|
27719
|
+
} catch {
|
|
27720
|
+
return null;
|
|
27721
|
+
}
|
|
27722
|
+
}
|
|
27723
|
+
/**
|
|
27724
|
+
* Updates the configuration options.
|
|
27725
|
+
*
|
|
27726
|
+
* @param config - New configuration options to merge
|
|
27727
|
+
*/
|
|
27728
|
+
updateConfig(config) {
|
|
27729
|
+
this.config = { ...this.config, ...config };
|
|
27730
|
+
if (config.mimeType) {
|
|
27731
|
+
this.mimeType = config.mimeType;
|
|
27732
|
+
}
|
|
27733
|
+
}
|
|
27734
|
+
/**
|
|
27735
|
+
* Destroys the drag handler and removes all event listeners.
|
|
27736
|
+
* Call this when the layout engine is unmounted or the container is removed.
|
|
27737
|
+
*/
|
|
27738
|
+
destroy() {
|
|
27739
|
+
this.removeListeners();
|
|
27740
|
+
this.container.classList.remove("drag-over");
|
|
27741
|
+
}
|
|
27742
|
+
}
|
|
27743
|
+
function createDragHandler(container, config = {}) {
|
|
27744
|
+
const handler = new DragHandler(container, config);
|
|
27745
|
+
return () => handler.destroy();
|
|
27746
|
+
}
|
|
27337
27747
|
const isAtomicFragment = (fragment) => {
|
|
27338
27748
|
return fragment.kind === "drawing" || fragment.kind === "image";
|
|
27339
27749
|
};
|
|
@@ -27385,7 +27795,7 @@ function hitTestFragment(layout, pageHit, blocks, measures, point) {
|
|
|
27385
27795
|
});
|
|
27386
27796
|
for (const fragment of fragments) {
|
|
27387
27797
|
if (fragment.kind !== "para") continue;
|
|
27388
|
-
const blockIndex = blocks
|
|
27798
|
+
const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
|
|
27389
27799
|
if (blockIndex === -1) continue;
|
|
27390
27800
|
const block = blocks[blockIndex];
|
|
27391
27801
|
const measure = measures[blockIndex];
|
|
@@ -27412,7 +27822,7 @@ const hitTestAtomicFragment = (pageHit, blocks, measures, point) => {
|
|
|
27412
27822
|
const withinX = point.x >= fragment.x && point.x <= fragment.x + fragment.width;
|
|
27413
27823
|
const withinY = point.y >= fragment.y && point.y <= fragment.y + fragment.height;
|
|
27414
27824
|
if (!withinX || !withinY) continue;
|
|
27415
|
-
const blockIndex = blocks
|
|
27825
|
+
const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
|
|
27416
27826
|
if (blockIndex === -1) continue;
|
|
27417
27827
|
const block = blocks[blockIndex];
|
|
27418
27828
|
const measure = measures[blockIndex];
|
|
@@ -27551,7 +27961,7 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
|
|
|
27551
27961
|
blockId = fragment.blockId;
|
|
27552
27962
|
pageIndex = pi;
|
|
27553
27963
|
column = determineColumn(layout, fragment.x);
|
|
27554
|
-
const blockIndex = blocks
|
|
27964
|
+
const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
|
|
27555
27965
|
if (blockIndex !== -1) {
|
|
27556
27966
|
const measure = measures[blockIndex];
|
|
27557
27967
|
if (measure && measure.kind === "paragraph") {
|
|
@@ -27701,6 +28111,44 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
|
|
|
27701
28111
|
});
|
|
27702
28112
|
return null;
|
|
27703
28113
|
}
|
|
28114
|
+
function findBlockIndexByFragmentId(blocks, fragmentBlockId, targetPmRange) {
|
|
28115
|
+
const index2 = blocks.findIndex(
|
|
28116
|
+
(block) => block.id === fragmentBlockId && block.kind !== "pageBreak" && block.kind !== "sectionBreak"
|
|
28117
|
+
);
|
|
28118
|
+
if (index2 !== -1) {
|
|
28119
|
+
return index2;
|
|
28120
|
+
}
|
|
28121
|
+
const baseBlockId = fragmentBlockId.replace(/-\d+$/, "");
|
|
28122
|
+
if (baseBlockId === fragmentBlockId) {
|
|
28123
|
+
return -1;
|
|
28124
|
+
}
|
|
28125
|
+
const matchingIndices = [];
|
|
28126
|
+
blocks.forEach((block, idx) => {
|
|
28127
|
+
if (block.id === baseBlockId && block.kind === "paragraph") {
|
|
28128
|
+
matchingIndices.push(idx);
|
|
28129
|
+
}
|
|
28130
|
+
});
|
|
28131
|
+
if (matchingIndices.length === 0) {
|
|
28132
|
+
return -1;
|
|
28133
|
+
}
|
|
28134
|
+
if (matchingIndices.length === 1) {
|
|
28135
|
+
return matchingIndices[0];
|
|
28136
|
+
}
|
|
28137
|
+
if (targetPmRange) {
|
|
28138
|
+
for (const idx of matchingIndices) {
|
|
28139
|
+
const block = blocks[idx];
|
|
28140
|
+
if (block.kind !== "paragraph") continue;
|
|
28141
|
+
const hasOverlap = block.runs.some((run) => {
|
|
28142
|
+
if (run.pmStart == null || run.pmEnd == null) return false;
|
|
28143
|
+
return run.pmEnd > targetPmRange.from && run.pmStart < targetPmRange.to;
|
|
28144
|
+
});
|
|
28145
|
+
if (hasOverlap) {
|
|
28146
|
+
return idx;
|
|
28147
|
+
}
|
|
28148
|
+
}
|
|
28149
|
+
}
|
|
28150
|
+
return matchingIndices[0];
|
|
28151
|
+
}
|
|
27704
28152
|
function selectionToRects(layout, blocks, measures, from2, to) {
|
|
27705
28153
|
if (from2 === to) {
|
|
27706
28154
|
return [];
|
|
@@ -27709,8 +28157,10 @@ function selectionToRects(layout, blocks, measures, from2, to) {
|
|
|
27709
28157
|
layout.pages.forEach((page, pageIndex) => {
|
|
27710
28158
|
page.fragments.forEach((fragment) => {
|
|
27711
28159
|
if (fragment.kind === "para") {
|
|
27712
|
-
const blockIndex = blocks.
|
|
27713
|
-
if (blockIndex === -1)
|
|
28160
|
+
const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
|
|
28161
|
+
if (blockIndex === -1) {
|
|
28162
|
+
return;
|
|
28163
|
+
}
|
|
27714
28164
|
const block = blocks[blockIndex];
|
|
27715
28165
|
const measure = measures[blockIndex];
|
|
27716
28166
|
if (!block || block.kind !== "paragraph" || measure?.kind !== "paragraph") {
|
|
@@ -27746,7 +28196,7 @@ function selectionToRects(layout, blocks, measures, from2, to) {
|
|
|
27746
28196
|
return;
|
|
27747
28197
|
}
|
|
27748
28198
|
if (isAtomicFragment(fragment)) {
|
|
27749
|
-
const blockIndex = blocks.
|
|
28199
|
+
const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId, { from: from2, to });
|
|
27750
28200
|
if (blockIndex === -1) return;
|
|
27751
28201
|
const block = blocks[blockIndex];
|
|
27752
28202
|
const pmRange = getAtomicPmRange(fragment, block);
|
|
@@ -27767,7 +28217,7 @@ function getFragmentAtPosition(layout, blocks, measures, pos) {
|
|
|
27767
28217
|
for (let pageIndex = 0; pageIndex < layout.pages.length; pageIndex += 1) {
|
|
27768
28218
|
const page = layout.pages[pageIndex];
|
|
27769
28219
|
for (const fragment of page.fragments) {
|
|
27770
|
-
const blockIndex = blocks
|
|
28220
|
+
const blockIndex = findBlockIndexByFragmentId(blocks, fragment.blockId);
|
|
27771
28221
|
if (blockIndex === -1) {
|
|
27772
28222
|
continue;
|
|
27773
28223
|
}
|
|
@@ -27872,7 +28322,7 @@ function computeLinePmRange$1(block, line) {
|
|
|
27872
28322
|
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
27873
28323
|
const run = block.runs[runIndex];
|
|
27874
28324
|
if (!run) continue;
|
|
27875
|
-
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text ?? "";
|
|
28325
|
+
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
|
|
27876
28326
|
const runLength = text.length;
|
|
27877
28327
|
const runPmStart = run.pmStart ?? null;
|
|
27878
28328
|
const runPmEnd = run.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
|
|
@@ -27896,7 +28346,7 @@ function pmPosToCharOffset(block, line, pmPos) {
|
|
|
27896
28346
|
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
27897
28347
|
const run = block.runs[runIndex];
|
|
27898
28348
|
if (!run) continue;
|
|
27899
|
-
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" ? "" : run.text ?? "";
|
|
28349
|
+
const text = "src" in run || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation" ? "" : run.text ?? "";
|
|
27900
28350
|
const runTextLength = text.length;
|
|
27901
28351
|
const runPmStart = run.pmStart ?? null;
|
|
27902
28352
|
const runPmEnd = run.pmEnd ?? (runPmStart != null ? runPmStart + runTextLength : null);
|
|
@@ -30429,9 +30879,227 @@ const TRACK_CHANGE_STYLES = `
|
|
|
30429
30879
|
border-bottom: 2px solid gold;
|
|
30430
30880
|
}
|
|
30431
30881
|
`;
|
|
30882
|
+
const SDT_CONTAINER_STYLES = `
|
|
30883
|
+
/* Document Section - Block-level container with gray border and hover tooltip */
|
|
30884
|
+
.superdoc-document-section {
|
|
30885
|
+
background-color: #fafafa;
|
|
30886
|
+
border: 1px solid #ababab;
|
|
30887
|
+
border-radius: 4px;
|
|
30888
|
+
position: relative;
|
|
30889
|
+
box-sizing: border-box;
|
|
30890
|
+
}
|
|
30891
|
+
|
|
30892
|
+
/* Document section tooltip - positioned above the fragment */
|
|
30893
|
+
.superdoc-document-section__tooltip {
|
|
30894
|
+
position: absolute;
|
|
30895
|
+
top: -19px;
|
|
30896
|
+
left: -1px;
|
|
30897
|
+
max-width: 100px;
|
|
30898
|
+
min-width: 0;
|
|
30899
|
+
height: 18px;
|
|
30900
|
+
border: 1px solid #ababab;
|
|
30901
|
+
border-bottom: none;
|
|
30902
|
+
border-radius: 6px 6px 0 0;
|
|
30903
|
+
padding: 0 8px;
|
|
30904
|
+
align-items: center;
|
|
30905
|
+
font-size: 10px;
|
|
30906
|
+
display: none;
|
|
30907
|
+
z-index: 100;
|
|
30908
|
+
background-color: #fafafa;
|
|
30909
|
+
pointer-events: none;
|
|
30910
|
+
}
|
|
30911
|
+
|
|
30912
|
+
.superdoc-document-section__tooltip span {
|
|
30913
|
+
max-width: 100%;
|
|
30914
|
+
overflow: hidden;
|
|
30915
|
+
white-space: nowrap;
|
|
30916
|
+
text-overflow: ellipsis;
|
|
30917
|
+
}
|
|
30918
|
+
|
|
30919
|
+
/* Show tooltip on hover - adjust border radius to connect with tooltip tab */
|
|
30920
|
+
.superdoc-document-section:hover {
|
|
30921
|
+
border-radius: 0 4px 4px 4px;
|
|
30922
|
+
}
|
|
30923
|
+
|
|
30924
|
+
.superdoc-document-section:hover .superdoc-document-section__tooltip {
|
|
30925
|
+
display: flex;
|
|
30926
|
+
align-items: center;
|
|
30927
|
+
}
|
|
30928
|
+
|
|
30929
|
+
/* Continuation styling: first fragment has top corners, last has bottom corners */
|
|
30930
|
+
.superdoc-document-section[data-sdt-container-start="true"] {
|
|
30931
|
+
border-radius: 4px 4px 0 0;
|
|
30932
|
+
}
|
|
30933
|
+
|
|
30934
|
+
.superdoc-document-section[data-sdt-container-end="true"] {
|
|
30935
|
+
border-radius: 0 0 4px 4px;
|
|
30936
|
+
}
|
|
30937
|
+
|
|
30938
|
+
.superdoc-document-section[data-sdt-container-start="true"][data-sdt-container-end="true"] {
|
|
30939
|
+
border-radius: 4px;
|
|
30940
|
+
}
|
|
30941
|
+
|
|
30942
|
+
.superdoc-document-section[data-sdt-container-start="true"]:hover {
|
|
30943
|
+
border-radius: 0 4px 0 0;
|
|
30944
|
+
}
|
|
30945
|
+
|
|
30946
|
+
/* Middle fragments have no border radius */
|
|
30947
|
+
.superdoc-document-section:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
|
|
30948
|
+
border-radius: 0;
|
|
30949
|
+
border-top: none;
|
|
30950
|
+
}
|
|
30951
|
+
|
|
30952
|
+
/* Structured Content Block - Blue border container */
|
|
30953
|
+
.superdoc-structured-content-block {
|
|
30954
|
+
padding: 1px;
|
|
30955
|
+
box-sizing: border-box;
|
|
30956
|
+
border-radius: 4px;
|
|
30957
|
+
border: 1px solid #629be7;
|
|
30958
|
+
position: relative;
|
|
30959
|
+
}
|
|
30960
|
+
|
|
30961
|
+
/* Structured content drag handle/label - positioned above */
|
|
30962
|
+
.superdoc-structured-content__label {
|
|
30963
|
+
font-size: 10px;
|
|
30964
|
+
align-items: center;
|
|
30965
|
+
justify-content: center;
|
|
30966
|
+
position: absolute;
|
|
30967
|
+
left: 2px;
|
|
30968
|
+
top: -19px;
|
|
30969
|
+
width: calc(100% - 4px);
|
|
30970
|
+
max-width: 110px;
|
|
30971
|
+
min-width: 0;
|
|
30972
|
+
height: 18px;
|
|
30973
|
+
padding: 0 4px;
|
|
30974
|
+
border: 1px solid #629be7;
|
|
30975
|
+
border-bottom: none;
|
|
30976
|
+
border-radius: 6px 6px 0 0;
|
|
30977
|
+
background-color: #629be7dd;
|
|
30978
|
+
box-sizing: border-box;
|
|
30979
|
+
z-index: 10;
|
|
30980
|
+
display: none;
|
|
30981
|
+
pointer-events: none;
|
|
30982
|
+
}
|
|
30983
|
+
|
|
30984
|
+
.superdoc-structured-content__label span {
|
|
30985
|
+
max-width: 100%;
|
|
30986
|
+
overflow: hidden;
|
|
30987
|
+
white-space: nowrap;
|
|
30988
|
+
text-overflow: ellipsis;
|
|
30989
|
+
}
|
|
30990
|
+
|
|
30991
|
+
.superdoc-structured-content-block:hover .superdoc-structured-content__label {
|
|
30992
|
+
display: inline-flex;
|
|
30993
|
+
}
|
|
30994
|
+
|
|
30995
|
+
/* Continuation styling for structured content blocks */
|
|
30996
|
+
.superdoc-structured-content-block[data-sdt-container-start="true"] {
|
|
30997
|
+
border-radius: 4px 4px 0 0;
|
|
30998
|
+
}
|
|
30999
|
+
|
|
31000
|
+
.superdoc-structured-content-block[data-sdt-container-end="true"] {
|
|
31001
|
+
border-radius: 0 0 4px 4px;
|
|
31002
|
+
}
|
|
31003
|
+
|
|
31004
|
+
.superdoc-structured-content-block[data-sdt-container-start="true"][data-sdt-container-end="true"] {
|
|
31005
|
+
border-radius: 4px;
|
|
31006
|
+
}
|
|
31007
|
+
|
|
31008
|
+
.superdoc-structured-content-block:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
|
|
31009
|
+
border-radius: 0;
|
|
31010
|
+
border-top: none;
|
|
31011
|
+
}
|
|
31012
|
+
|
|
31013
|
+
/* Structured Content Inline - Inline wrapper with blue border */
|
|
31014
|
+
.superdoc-structured-content-inline {
|
|
31015
|
+
padding: 1px;
|
|
31016
|
+
box-sizing: border-box;
|
|
31017
|
+
border-radius: 4px;
|
|
31018
|
+
border: 1px solid #629be7;
|
|
31019
|
+
position: relative;
|
|
31020
|
+
display: inline;
|
|
31021
|
+
}
|
|
31022
|
+
|
|
31023
|
+
/* Hover effect for inline structured content */
|
|
31024
|
+
.superdoc-structured-content-inline:hover {
|
|
31025
|
+
background-color: rgba(98, 155, 231, 0.15);
|
|
31026
|
+
border-color: #4a8ad9;
|
|
31027
|
+
}
|
|
31028
|
+
|
|
31029
|
+
/* Inline structured content label - shown on hover */
|
|
31030
|
+
.superdoc-structured-content-inline__label {
|
|
31031
|
+
position: absolute;
|
|
31032
|
+
bottom: calc(100% + 2px);
|
|
31033
|
+
left: 50%;
|
|
31034
|
+
transform: translateX(-50%);
|
|
31035
|
+
font-size: 10px;
|
|
31036
|
+
padding: 2px 6px;
|
|
31037
|
+
background-color: #629be7dd;
|
|
31038
|
+
color: white;
|
|
31039
|
+
border-radius: 4px;
|
|
31040
|
+
white-space: nowrap;
|
|
31041
|
+
z-index: 100;
|
|
31042
|
+
display: none;
|
|
31043
|
+
pointer-events: none;
|
|
31044
|
+
}
|
|
31045
|
+
|
|
31046
|
+
.superdoc-structured-content-inline:hover .superdoc-structured-content-inline__label {
|
|
31047
|
+
display: block;
|
|
31048
|
+
}
|
|
31049
|
+
|
|
31050
|
+
/* Print mode: hide visual styling for SDT containers */
|
|
31051
|
+
@media print {
|
|
31052
|
+
.superdoc-document-section,
|
|
31053
|
+
.superdoc-structured-content-block,
|
|
31054
|
+
.superdoc-structured-content-inline {
|
|
31055
|
+
background: none;
|
|
31056
|
+
border: none;
|
|
31057
|
+
padding: 0;
|
|
31058
|
+
}
|
|
31059
|
+
|
|
31060
|
+
.superdoc-document-section__tooltip,
|
|
31061
|
+
.superdoc-structured-content__label,
|
|
31062
|
+
.superdoc-structured-content-inline__label {
|
|
31063
|
+
display: none !important;
|
|
31064
|
+
}
|
|
31065
|
+
}
|
|
31066
|
+
`;
|
|
31067
|
+
const FIELD_ANNOTATION_STYLES = `
|
|
31068
|
+
/* Field annotation draggable styles */
|
|
31069
|
+
.superdoc-layout .annotation[data-draggable="true"] {
|
|
31070
|
+
cursor: grab;
|
|
31071
|
+
user-select: none;
|
|
31072
|
+
-webkit-user-select: none;
|
|
31073
|
+
}
|
|
31074
|
+
|
|
31075
|
+
.superdoc-layout .annotation[data-draggable="true"]:hover {
|
|
31076
|
+
opacity: 0.9;
|
|
31077
|
+
}
|
|
31078
|
+
|
|
31079
|
+
.superdoc-layout .annotation[data-draggable="true"]:active {
|
|
31080
|
+
cursor: grabbing;
|
|
31081
|
+
}
|
|
31082
|
+
|
|
31083
|
+
/* Drag over indicator for drop targets */
|
|
31084
|
+
.superdoc-layout.drag-over {
|
|
31085
|
+
outline: 2px dashed #b015b3;
|
|
31086
|
+
outline-offset: -2px;
|
|
31087
|
+
}
|
|
31088
|
+
|
|
31089
|
+
/* Drop zone indicator */
|
|
31090
|
+
.superdoc-layout .superdoc-drop-indicator {
|
|
31091
|
+
position: absolute;
|
|
31092
|
+
width: 2px;
|
|
31093
|
+
background-color: #b015b3;
|
|
31094
|
+
pointer-events: none;
|
|
31095
|
+
z-index: 1000;
|
|
31096
|
+
}
|
|
31097
|
+
`;
|
|
30432
31098
|
let printStylesInjected = false;
|
|
30433
31099
|
let linkStylesInjected = false;
|
|
30434
31100
|
let trackChangeStylesInjected = false;
|
|
31101
|
+
let sdtContainerStylesInjected = false;
|
|
31102
|
+
let fieldAnnotationStylesInjected = false;
|
|
30435
31103
|
const ensurePrintStyles = (doc2) => {
|
|
30436
31104
|
if (printStylesInjected || !doc2) return;
|
|
30437
31105
|
const styleEl = doc2.createElement("style");
|
|
@@ -30456,6 +31124,22 @@ const ensureTrackChangeStyles = (doc2) => {
|
|
|
30456
31124
|
doc2.head?.appendChild(styleEl);
|
|
30457
31125
|
trackChangeStylesInjected = true;
|
|
30458
31126
|
};
|
|
31127
|
+
const ensureSdtContainerStyles = (doc2) => {
|
|
31128
|
+
if (sdtContainerStylesInjected || !doc2) return;
|
|
31129
|
+
const styleEl = doc2.createElement("style");
|
|
31130
|
+
styleEl.setAttribute("data-superdoc-sdt-container-styles", "true");
|
|
31131
|
+
styleEl.textContent = SDT_CONTAINER_STYLES;
|
|
31132
|
+
doc2.head?.appendChild(styleEl);
|
|
31133
|
+
sdtContainerStylesInjected = true;
|
|
31134
|
+
};
|
|
31135
|
+
const ensureFieldAnnotationStyles = (doc2) => {
|
|
31136
|
+
if (fieldAnnotationStylesInjected || !doc2) return;
|
|
31137
|
+
const styleEl = doc2.createElement("style");
|
|
31138
|
+
styleEl.setAttribute("data-superdoc-field-annotation-styles", "true");
|
|
31139
|
+
styleEl.textContent = FIELD_ANNOTATION_STYLES;
|
|
31140
|
+
doc2.head?.appendChild(styleEl);
|
|
31141
|
+
fieldAnnotationStylesInjected = true;
|
|
31142
|
+
};
|
|
30459
31143
|
const ALLOWED_BORDER_STYLES = /* @__PURE__ */ new Set([
|
|
30460
31144
|
"none",
|
|
30461
31145
|
"single",
|
|
@@ -30785,6 +31469,50 @@ const renderTableRow = (deps) => {
|
|
|
30785
31469
|
container.appendChild(cellElement);
|
|
30786
31470
|
}
|
|
30787
31471
|
};
|
|
31472
|
+
function isStructuredContentMetadata(sdt) {
|
|
31473
|
+
return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
|
|
31474
|
+
}
|
|
31475
|
+
function isDocumentSectionMetadata(sdt) {
|
|
31476
|
+
return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "documentSection";
|
|
31477
|
+
}
|
|
31478
|
+
function getSdtContainerConfig(sdt) {
|
|
31479
|
+
if (isDocumentSectionMetadata(sdt)) {
|
|
31480
|
+
return {
|
|
31481
|
+
className: "superdoc-document-section",
|
|
31482
|
+
labelText: sdt.title ?? "Document section",
|
|
31483
|
+
labelClassName: "superdoc-document-section__tooltip",
|
|
31484
|
+
isStart: true,
|
|
31485
|
+
isEnd: true
|
|
31486
|
+
};
|
|
31487
|
+
}
|
|
31488
|
+
if (isStructuredContentMetadata(sdt) && sdt.scope === "block") {
|
|
31489
|
+
return {
|
|
31490
|
+
className: "superdoc-structured-content-block",
|
|
31491
|
+
labelText: sdt.alias ?? "Structured content",
|
|
31492
|
+
labelClassName: "superdoc-structured-content__label",
|
|
31493
|
+
isStart: true,
|
|
31494
|
+
isEnd: true
|
|
31495
|
+
};
|
|
31496
|
+
}
|
|
31497
|
+
return null;
|
|
31498
|
+
}
|
|
31499
|
+
function applySdtContainerStyling(doc2, container, sdt, containerSdt) {
|
|
31500
|
+
let config = getSdtContainerConfig(sdt);
|
|
31501
|
+
if (!config && containerSdt) {
|
|
31502
|
+
config = getSdtContainerConfig(containerSdt);
|
|
31503
|
+
}
|
|
31504
|
+
if (!config) return;
|
|
31505
|
+
container.classList.add(config.className);
|
|
31506
|
+
container.dataset.sdtContainerStart = String(config.isStart);
|
|
31507
|
+
container.dataset.sdtContainerEnd = String(config.isEnd);
|
|
31508
|
+
container.style.overflow = "visible";
|
|
31509
|
+
const labelEl = doc2.createElement("div");
|
|
31510
|
+
labelEl.className = config.labelClassName;
|
|
31511
|
+
const labelText = doc2.createElement("span");
|
|
31512
|
+
labelText.textContent = config.labelText;
|
|
31513
|
+
labelEl.appendChild(labelText);
|
|
31514
|
+
container.appendChild(labelEl);
|
|
31515
|
+
}
|
|
30788
31516
|
const renderTableFragment = (deps) => {
|
|
30789
31517
|
const { doc: doc2, fragment, blockLookup, context, renderLine, applyFragmentFrame, applySdtDataset, applyStyles: applyStyles2 } = deps;
|
|
30790
31518
|
if (!doc2) {
|
|
@@ -30821,6 +31549,7 @@ const renderTableFragment = (deps) => {
|
|
|
30821
31549
|
applyFragmentFrame(container, fragment);
|
|
30822
31550
|
container.style.height = `${fragment.height}px`;
|
|
30823
31551
|
applySdtDataset(container, block.attrs?.sdt);
|
|
31552
|
+
applySdtContainerStyling(doc2, container, block.attrs?.sdt);
|
|
30824
31553
|
container.classList.add("superdoc-table-fragment");
|
|
30825
31554
|
if (fragment.metadata?.columnBoundaries) {
|
|
30826
31555
|
const columnCount = measure.columnWidths.length;
|
|
@@ -31287,6 +32016,8 @@ const _DomPainter = class _DomPainter {
|
|
|
31287
32016
|
ensurePrintStyles(doc2);
|
|
31288
32017
|
ensureLinkStyles(doc2);
|
|
31289
32018
|
ensureTrackChangeStyles(doc2);
|
|
32019
|
+
ensureFieldAnnotationStyles(doc2);
|
|
32020
|
+
ensureSdtContainerStyles(doc2);
|
|
31290
32021
|
mount.classList.add(CLASS_NAMES.container);
|
|
31291
32022
|
if (this.mount && this.mount !== mount) {
|
|
31292
32023
|
this.resetState();
|
|
@@ -31809,7 +32540,8 @@ const _DomPainter = class _DomPainter {
|
|
|
31809
32540
|
fragmentEl.classList.add(CLASS_NAMES.fragment);
|
|
31810
32541
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
31811
32542
|
const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
31812
|
-
const
|
|
32543
|
+
const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
|
|
32544
|
+
const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
|
|
31813
32545
|
applyStyles$2(fragmentEl, styles);
|
|
31814
32546
|
this.applyFragmentFrame(fragmentEl, fragment, context.section);
|
|
31815
32547
|
if (isTocEntry) {
|
|
@@ -31829,6 +32561,7 @@ const _DomPainter = class _DomPainter {
|
|
|
31829
32561
|
}
|
|
31830
32562
|
this.applySdtDataset(fragmentEl, block.attrs?.sdt);
|
|
31831
32563
|
this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
|
|
32564
|
+
applySdtContainerStyling(this.doc, fragmentEl, block.attrs?.sdt, block.attrs?.containerSdt);
|
|
31832
32565
|
const dropCapDescriptor = block.attrs?.dropCapDescriptor;
|
|
31833
32566
|
const dropCapMeasure = measure.dropCap;
|
|
31834
32567
|
if (dropCapDescriptor && dropCapMeasure && !fragment.continuesFromPrev) {
|
|
@@ -32047,6 +32780,7 @@ const _DomPainter = class _DomPainter {
|
|
|
32047
32780
|
fragmentEl.dataset.itemId = fragment.itemId;
|
|
32048
32781
|
const paragraphMetadata = item.paragraph.attrs?.sdt;
|
|
32049
32782
|
this.applySdtDataset(fragmentEl, paragraphMetadata);
|
|
32783
|
+
applySdtContainerStyling(this.doc, fragmentEl, paragraphMetadata, item.paragraph.attrs?.containerSdt);
|
|
32050
32784
|
if (fragment.continuesFromPrev) {
|
|
32051
32785
|
fragmentEl.dataset.continuesFromPrev = "true";
|
|
32052
32786
|
}
|
|
@@ -32818,10 +33552,19 @@ const _DomPainter = class _DomPainter {
|
|
|
32818
33552
|
isBreakRun(run) {
|
|
32819
33553
|
return run.kind === "break";
|
|
32820
33554
|
}
|
|
33555
|
+
/**
|
|
33556
|
+
* Type guard to check if a run is a field annotation run.
|
|
33557
|
+
*/
|
|
33558
|
+
isFieldAnnotationRun(run) {
|
|
33559
|
+
return run.kind === "fieldAnnotation";
|
|
33560
|
+
}
|
|
32821
33561
|
renderRun(run, context, trackedConfig) {
|
|
32822
33562
|
if (this.isImageRun(run)) {
|
|
32823
33563
|
return this.renderImageRun(run);
|
|
32824
33564
|
}
|
|
33565
|
+
if (this.isFieldAnnotationRun(run)) {
|
|
33566
|
+
return this.renderFieldAnnotationRun(run);
|
|
33567
|
+
}
|
|
32825
33568
|
if (this.isLineBreakRun(run)) {
|
|
32826
33569
|
return null;
|
|
32827
33570
|
}
|
|
@@ -32958,6 +33701,200 @@ const _DomPainter = class _DomPainter {
|
|
|
32958
33701
|
}
|
|
32959
33702
|
return img;
|
|
32960
33703
|
}
|
|
33704
|
+
/**
|
|
33705
|
+
* Renders a FieldAnnotationRun as an inline "pill" element matching super-editor's visual appearance.
|
|
33706
|
+
*
|
|
33707
|
+
* Field annotations are styled inline elements that display form fields with:
|
|
33708
|
+
* - Outer span with border, border-radius, padding, and background color
|
|
33709
|
+
* - Inner span containing the displayLabel or type-specific content (image, link, etc.)
|
|
33710
|
+
*
|
|
33711
|
+
* @param run - The FieldAnnotationRun to render containing field configuration and styling
|
|
33712
|
+
* @returns HTMLElement (span) or null if document is not available
|
|
33713
|
+
*
|
|
33714
|
+
* @example
|
|
33715
|
+
* ```typescript
|
|
33716
|
+
* // Text variant
|
|
33717
|
+
* renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'text', displayLabel: 'Full Name', fieldColor: '#980043' })
|
|
33718
|
+
* // Returns: <span class="annotation" style="border: 2px solid #b015b3; ..."><span class="annotation-content">Full Name</span></span>
|
|
33719
|
+
*
|
|
33720
|
+
* // Image variant with imageSrc
|
|
33721
|
+
* renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'image', displayLabel: 'Photo', imageSrc: 'data:image/png;...' })
|
|
33722
|
+
* // Returns: <span class="annotation"><span class="annotation-content"><img src="..." /></span></span>
|
|
33723
|
+
*
|
|
33724
|
+
* // Link variant
|
|
33725
|
+
* renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'link', displayLabel: 'Website', linkUrl: 'https://example.com' })
|
|
33726
|
+
* // Returns: <span class="annotation"><span class="annotation-content"><a href="...">https://example.com</a></span></span>
|
|
33727
|
+
* ```
|
|
33728
|
+
*/
|
|
33729
|
+
renderFieldAnnotationRun(run) {
|
|
33730
|
+
if (!this.doc) {
|
|
33731
|
+
return null;
|
|
33732
|
+
}
|
|
33733
|
+
if (run.hidden) {
|
|
33734
|
+
const hidden = this.doc.createElement("span");
|
|
33735
|
+
hidden.style.display = "none";
|
|
33736
|
+
if (run.pmStart != null) hidden.dataset.pmStart = String(run.pmStart);
|
|
33737
|
+
if (run.pmEnd != null) hidden.dataset.pmEnd = String(run.pmEnd);
|
|
33738
|
+
return hidden;
|
|
33739
|
+
}
|
|
33740
|
+
const defaultBorderColor = "#b015b3";
|
|
33741
|
+
const defaultFieldColor = "#980043";
|
|
33742
|
+
const annotation = this.doc.createElement("span");
|
|
33743
|
+
annotation.classList.add("annotation");
|
|
33744
|
+
annotation.setAttribute("aria-label", "Field annotation");
|
|
33745
|
+
const showHighlight = run.highlighted !== false;
|
|
33746
|
+
if (showHighlight) {
|
|
33747
|
+
const borderColor = run.borderColor || defaultBorderColor;
|
|
33748
|
+
annotation.style.border = `2px solid ${borderColor}`;
|
|
33749
|
+
annotation.style.borderRadius = "2px";
|
|
33750
|
+
annotation.style.padding = "1px 2px";
|
|
33751
|
+
annotation.style.boxSizing = "border-box";
|
|
33752
|
+
const fieldColor = run.fieldColor || defaultFieldColor;
|
|
33753
|
+
const bgColor = fieldColor.length === 7 ? `${fieldColor}33` : fieldColor;
|
|
33754
|
+
if (run.textHighlight) {
|
|
33755
|
+
annotation.style.backgroundColor = run.textHighlight;
|
|
33756
|
+
} else {
|
|
33757
|
+
annotation.style.backgroundColor = bgColor;
|
|
33758
|
+
}
|
|
33759
|
+
}
|
|
33760
|
+
if (run.visibility === "hidden") {
|
|
33761
|
+
annotation.style.visibility = "hidden";
|
|
33762
|
+
}
|
|
33763
|
+
if (run.size) {
|
|
33764
|
+
if (run.size.width) {
|
|
33765
|
+
annotation.style.width = `${run.size.width}px`;
|
|
33766
|
+
annotation.style.display = "inline-block";
|
|
33767
|
+
annotation.style.overflow = "hidden";
|
|
33768
|
+
}
|
|
33769
|
+
if (run.size.height) {
|
|
33770
|
+
annotation.style.height = `${run.size.height}px`;
|
|
33771
|
+
}
|
|
33772
|
+
}
|
|
33773
|
+
if (run.fontFamily) {
|
|
33774
|
+
annotation.style.fontFamily = run.fontFamily;
|
|
33775
|
+
}
|
|
33776
|
+
if (run.fontSize) {
|
|
33777
|
+
const fontSize = typeof run.fontSize === "number" ? `${run.fontSize}pt` : run.fontSize;
|
|
33778
|
+
annotation.style.fontSize = fontSize;
|
|
33779
|
+
}
|
|
33780
|
+
if (run.textColor) {
|
|
33781
|
+
annotation.style.color = run.textColor;
|
|
33782
|
+
}
|
|
33783
|
+
if (run.bold) {
|
|
33784
|
+
annotation.style.fontWeight = "bold";
|
|
33785
|
+
}
|
|
33786
|
+
if (run.italic) {
|
|
33787
|
+
annotation.style.fontStyle = "italic";
|
|
33788
|
+
}
|
|
33789
|
+
if (run.underline) {
|
|
33790
|
+
annotation.style.textDecoration = "underline";
|
|
33791
|
+
}
|
|
33792
|
+
annotation.style.zIndex = "1";
|
|
33793
|
+
const content = this.doc.createElement("span");
|
|
33794
|
+
content.classList.add("annotation-content");
|
|
33795
|
+
content.style.pointerEvents = "none";
|
|
33796
|
+
content.setAttribute("contenteditable", "false");
|
|
33797
|
+
switch (run.variant) {
|
|
33798
|
+
case "image":
|
|
33799
|
+
case "signature": {
|
|
33800
|
+
if (run.imageSrc) {
|
|
33801
|
+
const img = this.doc.createElement("img");
|
|
33802
|
+
const isDataUrl = run.imageSrc.startsWith("data:");
|
|
33803
|
+
if (isDataUrl) {
|
|
33804
|
+
if (run.imageSrc.length <= MAX_DATA_URL_LENGTH && VALID_IMAGE_DATA_URL.test(run.imageSrc)) {
|
|
33805
|
+
img.src = run.imageSrc;
|
|
33806
|
+
} else {
|
|
33807
|
+
content.textContent = run.displayLabel;
|
|
33808
|
+
break;
|
|
33809
|
+
}
|
|
33810
|
+
} else {
|
|
33811
|
+
const sanitized = sanitizeHref(run.imageSrc);
|
|
33812
|
+
if (sanitized) {
|
|
33813
|
+
img.src = sanitized.href;
|
|
33814
|
+
} else {
|
|
33815
|
+
content.textContent = run.displayLabel;
|
|
33816
|
+
break;
|
|
33817
|
+
}
|
|
33818
|
+
}
|
|
33819
|
+
img.alt = run.displayLabel;
|
|
33820
|
+
img.style.height = "auto";
|
|
33821
|
+
img.style.maxWidth = "100%";
|
|
33822
|
+
img.style.pointerEvents = "none";
|
|
33823
|
+
img.style.verticalAlign = "middle";
|
|
33824
|
+
if (run.variant === "signature") {
|
|
33825
|
+
img.style.maxHeight = "28px";
|
|
33826
|
+
}
|
|
33827
|
+
content.appendChild(img);
|
|
33828
|
+
annotation.style.display = "inline-block";
|
|
33829
|
+
content.style.display = "inline-block";
|
|
33830
|
+
} else {
|
|
33831
|
+
content.textContent = run.displayLabel || (run.variant === "signature" ? "Signature" : "");
|
|
33832
|
+
}
|
|
33833
|
+
break;
|
|
33834
|
+
}
|
|
33835
|
+
case "link": {
|
|
33836
|
+
if (run.linkUrl) {
|
|
33837
|
+
const link = this.doc.createElement("a");
|
|
33838
|
+
const sanitized = sanitizeHref(run.linkUrl);
|
|
33839
|
+
if (sanitized) {
|
|
33840
|
+
link.href = sanitized.href;
|
|
33841
|
+
link.target = "_blank";
|
|
33842
|
+
link.rel = "noopener noreferrer";
|
|
33843
|
+
link.textContent = run.linkUrl;
|
|
33844
|
+
link.style.textDecoration = "none";
|
|
33845
|
+
content.style.pointerEvents = "all";
|
|
33846
|
+
content.appendChild(link);
|
|
33847
|
+
} else {
|
|
33848
|
+
content.textContent = run.displayLabel;
|
|
33849
|
+
}
|
|
33850
|
+
} else {
|
|
33851
|
+
content.textContent = run.displayLabel;
|
|
33852
|
+
}
|
|
33853
|
+
break;
|
|
33854
|
+
}
|
|
33855
|
+
case "html": {
|
|
33856
|
+
if (run.rawHtml && typeof run.rawHtml === "string") {
|
|
33857
|
+
content.textContent = run.displayLabel;
|
|
33858
|
+
annotation.style.display = "inline-block";
|
|
33859
|
+
content.style.display = "inline-block";
|
|
33860
|
+
} else {
|
|
33861
|
+
content.textContent = run.displayLabel;
|
|
33862
|
+
}
|
|
33863
|
+
break;
|
|
33864
|
+
}
|
|
33865
|
+
case "text":
|
|
33866
|
+
case "checkbox":
|
|
33867
|
+
default: {
|
|
33868
|
+
content.textContent = run.displayLabel;
|
|
33869
|
+
break;
|
|
33870
|
+
}
|
|
33871
|
+
}
|
|
33872
|
+
annotation.appendChild(content);
|
|
33873
|
+
annotation.dataset.type = run.variant;
|
|
33874
|
+
if (run.fieldId) {
|
|
33875
|
+
annotation.dataset.fieldId = run.fieldId;
|
|
33876
|
+
}
|
|
33877
|
+
if (run.fieldType) {
|
|
33878
|
+
annotation.dataset.fieldType = run.fieldType;
|
|
33879
|
+
}
|
|
33880
|
+
annotation.draggable = true;
|
|
33881
|
+
annotation.dataset.draggable = "true";
|
|
33882
|
+
if (run.displayLabel) {
|
|
33883
|
+
annotation.dataset.displayLabel = run.displayLabel;
|
|
33884
|
+
}
|
|
33885
|
+
if (run.variant) {
|
|
33886
|
+
annotation.dataset.variant = run.variant;
|
|
33887
|
+
}
|
|
33888
|
+
assertPmPositions(run, "field annotation run");
|
|
33889
|
+
if (run.pmStart != null) {
|
|
33890
|
+
annotation.dataset.pmStart = String(run.pmStart);
|
|
33891
|
+
}
|
|
33892
|
+
if (run.pmEnd != null) {
|
|
33893
|
+
annotation.dataset.pmEnd = String(run.pmEnd);
|
|
33894
|
+
}
|
|
33895
|
+
this.applySdtDataset(annotation, run.sdt);
|
|
33896
|
+
return annotation;
|
|
33897
|
+
}
|
|
32961
33898
|
/**
|
|
32962
33899
|
* Renders a single line of a paragraph block.
|
|
32963
33900
|
*
|
|
@@ -33135,6 +34072,22 @@ const _DomPainter = class _DomPainter {
|
|
|
33135
34072
|
if (this.isBreakRun(baseRun)) {
|
|
33136
34073
|
continue;
|
|
33137
34074
|
}
|
|
34075
|
+
if (this.isFieldAnnotationRun(baseRun)) {
|
|
34076
|
+
const elem = this.renderRun(baseRun, context, trackedConfig);
|
|
34077
|
+
if (elem) {
|
|
34078
|
+
if (styleId) {
|
|
34079
|
+
elem.setAttribute("styleid", styleId);
|
|
34080
|
+
}
|
|
34081
|
+
const runSegments2 = segmentsByRun.get(runIndex);
|
|
34082
|
+
const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
|
|
34083
|
+
const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
|
|
34084
|
+
elem.style.position = "absolute";
|
|
34085
|
+
elem.style.left = `${segX}px`;
|
|
34086
|
+
el.appendChild(elem);
|
|
34087
|
+
cumulativeX = segX + segWidth;
|
|
34088
|
+
}
|
|
34089
|
+
continue;
|
|
34090
|
+
}
|
|
33138
34091
|
const runSegments = segmentsByRun.get(runIndex);
|
|
33139
34092
|
if (!runSegments || runSegments.length === 0) {
|
|
33140
34093
|
continue;
|
|
@@ -33180,7 +34133,22 @@ const _DomPainter = class _DomPainter {
|
|
|
33180
34133
|
});
|
|
33181
34134
|
}
|
|
33182
34135
|
} else {
|
|
34136
|
+
let currentInlineSdtWrapper = null;
|
|
34137
|
+
let currentInlineSdtId = null;
|
|
34138
|
+
const closeCurrentWrapper = () => {
|
|
34139
|
+
if (currentInlineSdtWrapper) {
|
|
34140
|
+
el.appendChild(currentInlineSdtWrapper);
|
|
34141
|
+
currentInlineSdtWrapper = null;
|
|
34142
|
+
currentInlineSdtId = null;
|
|
34143
|
+
}
|
|
34144
|
+
};
|
|
33183
34145
|
runsForLine.forEach((run) => {
|
|
34146
|
+
const runSdt = run.sdt;
|
|
34147
|
+
const isInlineSdt = runSdt?.type === "structuredContent" && runSdt?.scope === "inline";
|
|
34148
|
+
const runSdtId = isInlineSdt && runSdt?.id ? String(runSdt.id) : null;
|
|
34149
|
+
if (runSdtId !== currentInlineSdtId) {
|
|
34150
|
+
closeCurrentWrapper();
|
|
34151
|
+
}
|
|
33184
34152
|
if (run.kind === "tab") {
|
|
33185
34153
|
const tabEl = this.doc.createElement("span");
|
|
33186
34154
|
tabEl.classList.add("superdoc-tab");
|
|
@@ -33208,9 +34176,37 @@ const _DomPainter = class _DomPainter {
|
|
|
33208
34176
|
if (styleId) {
|
|
33209
34177
|
elem.setAttribute("styleid", styleId);
|
|
33210
34178
|
}
|
|
33211
|
-
|
|
34179
|
+
if (isInlineSdt && runSdtId && this.doc) {
|
|
34180
|
+
if (!currentInlineSdtWrapper) {
|
|
34181
|
+
currentInlineSdtWrapper = this.doc.createElement("span");
|
|
34182
|
+
currentInlineSdtWrapper.className = "superdoc-structured-content-inline";
|
|
34183
|
+
currentInlineSdtId = runSdtId;
|
|
34184
|
+
this.applySdtDataset(currentInlineSdtWrapper, runSdt);
|
|
34185
|
+
const alias = runSdt?.alias || "Inline content";
|
|
34186
|
+
const labelEl = this.doc.createElement("span");
|
|
34187
|
+
labelEl.className = "superdoc-structured-content-inline__label";
|
|
34188
|
+
labelEl.textContent = alias;
|
|
34189
|
+
currentInlineSdtWrapper.appendChild(labelEl);
|
|
34190
|
+
}
|
|
34191
|
+
const wrapperPmStart = currentInlineSdtWrapper.dataset.pmStart;
|
|
34192
|
+
const wrapperPmEnd = currentInlineSdtWrapper.dataset.pmEnd;
|
|
34193
|
+
if (run.pmStart != null) {
|
|
34194
|
+
if (!wrapperPmStart || run.pmStart < parseInt(wrapperPmStart, 10)) {
|
|
34195
|
+
currentInlineSdtWrapper.dataset.pmStart = String(run.pmStart);
|
|
34196
|
+
}
|
|
34197
|
+
}
|
|
34198
|
+
if (run.pmEnd != null) {
|
|
34199
|
+
if (!wrapperPmEnd || run.pmEnd > parseInt(wrapperPmEnd, 10)) {
|
|
34200
|
+
currentInlineSdtWrapper.dataset.pmEnd = String(run.pmEnd);
|
|
34201
|
+
}
|
|
34202
|
+
}
|
|
34203
|
+
currentInlineSdtWrapper.appendChild(elem);
|
|
34204
|
+
} else {
|
|
34205
|
+
el.appendChild(elem);
|
|
34206
|
+
}
|
|
33212
34207
|
}
|
|
33213
34208
|
});
|
|
34209
|
+
closeCurrentWrapper();
|
|
33214
34210
|
}
|
|
33215
34211
|
const anchors = el.querySelectorAll("a[href]");
|
|
33216
34212
|
anchors.forEach((anchor) => {
|
|
@@ -33718,7 +34714,7 @@ const deriveBlockVersion = (block) => {
|
|
|
33718
34714
|
return block.id;
|
|
33719
34715
|
};
|
|
33720
34716
|
const applyRunStyles = (element, run, _isLink = false) => {
|
|
33721
|
-
if (run.kind === "tab" || run.kind === "image" || run.kind === "lineBreak" || run.kind === "break") {
|
|
34717
|
+
if (run.kind === "tab" || run.kind === "image" || run.kind === "lineBreak" || run.kind === "break" || run.kind === "fieldAnnotation") {
|
|
33722
34718
|
return;
|
|
33723
34719
|
}
|
|
33724
34720
|
element.style.fontFamily = run.fontFamily;
|
|
@@ -33878,6 +34874,10 @@ const sliceRunsForLine = (block, line) => {
|
|
|
33878
34874
|
result.push(run);
|
|
33879
34875
|
continue;
|
|
33880
34876
|
}
|
|
34877
|
+
if (run.kind === "fieldAnnotation") {
|
|
34878
|
+
result.push(run);
|
|
34879
|
+
continue;
|
|
34880
|
+
}
|
|
33881
34881
|
if (!("text" in run)) {
|
|
33882
34882
|
continue;
|
|
33883
34883
|
}
|
|
@@ -34193,6 +35193,10 @@ const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
|
|
|
34193
35193
|
const TAB_EPSILON = 0.1;
|
|
34194
35194
|
const DEFAULT_DECIMAL_SEPARATOR = ".";
|
|
34195
35195
|
const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
|
|
35196
|
+
const FIELD_ANNOTATION_PILL_PADDING = 8;
|
|
35197
|
+
const FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2;
|
|
35198
|
+
const FIELD_ANNOTATION_VERTICAL_PADDING = 6;
|
|
35199
|
+
const DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16;
|
|
34196
35200
|
const roundValue = (value) => value;
|
|
34197
35201
|
function getCanvasContext() {
|
|
34198
35202
|
if (!canvasContext) {
|
|
@@ -34272,6 +35276,9 @@ function isImageRun(run) {
|
|
|
34272
35276
|
function isLineBreakRun(run) {
|
|
34273
35277
|
return run.kind === "lineBreak";
|
|
34274
35278
|
}
|
|
35279
|
+
function isFieldAnnotationRun(run) {
|
|
35280
|
+
return run.kind === "fieldAnnotation";
|
|
35281
|
+
}
|
|
34275
35282
|
async function measureBlock(block, constraints) {
|
|
34276
35283
|
const normalized = normalizeConstraints(constraints);
|
|
34277
35284
|
if (block.kind === "drawing") {
|
|
@@ -34638,6 +35645,92 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
34638
35645
|
lastAppliedTabAlign = null;
|
|
34639
35646
|
continue;
|
|
34640
35647
|
}
|
|
35648
|
+
if (isFieldAnnotationRun(run)) {
|
|
35649
|
+
const displayText = run.displayLabel || "";
|
|
35650
|
+
const annotationFontSize = typeof run.fontSize === "number" ? run.fontSize : typeof run.fontSize === "string" ? parseFloat(run.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
|
|
35651
|
+
const annotationFontFamily = run.fontFamily || "Arial, sans-serif";
|
|
35652
|
+
const fontWeight = run.bold ? "bold" : "normal";
|
|
35653
|
+
const fontStyle = run.italic ? "italic" : "normal";
|
|
35654
|
+
const annotationFont = `${fontStyle} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
|
|
35655
|
+
ctx2.font = annotationFont;
|
|
35656
|
+
const textWidth = displayText ? ctx2.measureText(displayText).width : 0;
|
|
35657
|
+
const annotationWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
|
|
35658
|
+
const annotationHeight = annotationFontSize * FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER + FIELD_ANNOTATION_VERTICAL_PADDING;
|
|
35659
|
+
let annotationStartX;
|
|
35660
|
+
if (pendingTabAlignment && currentLine) {
|
|
35661
|
+
annotationStartX = alignPendingTabForWidth(annotationWidth);
|
|
35662
|
+
}
|
|
35663
|
+
if (!currentLine) {
|
|
35664
|
+
currentLine = {
|
|
35665
|
+
fromRun: runIndex,
|
|
35666
|
+
fromChar: 0,
|
|
35667
|
+
toRun: runIndex,
|
|
35668
|
+
toChar: 1,
|
|
35669
|
+
// Field annotations are atomic units
|
|
35670
|
+
width: annotationWidth,
|
|
35671
|
+
maxFontSize: annotationHeight,
|
|
35672
|
+
maxWidth: getEffectiveWidth(initialAvailableWidth),
|
|
35673
|
+
segments: [
|
|
35674
|
+
{
|
|
35675
|
+
runIndex,
|
|
35676
|
+
fromChar: 0,
|
|
35677
|
+
toChar: 1,
|
|
35678
|
+
width: annotationWidth,
|
|
35679
|
+
...annotationStartX !== void 0 ? { x: annotationStartX } : {}
|
|
35680
|
+
}
|
|
35681
|
+
]
|
|
35682
|
+
};
|
|
35683
|
+
continue;
|
|
35684
|
+
}
|
|
35685
|
+
if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
|
|
35686
|
+
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
35687
|
+
const completedLine = {
|
|
35688
|
+
...currentLine,
|
|
35689
|
+
...metrics
|
|
35690
|
+
};
|
|
35691
|
+
addBarTabsToLine(completedLine);
|
|
35692
|
+
lines.push(completedLine);
|
|
35693
|
+
tabStopCursor = 0;
|
|
35694
|
+
pendingTabAlignment = null;
|
|
35695
|
+
lastAppliedTabAlign = null;
|
|
35696
|
+
currentLine = {
|
|
35697
|
+
fromRun: runIndex,
|
|
35698
|
+
fromChar: 0,
|
|
35699
|
+
toRun: runIndex,
|
|
35700
|
+
toChar: 1,
|
|
35701
|
+
width: annotationWidth,
|
|
35702
|
+
maxFontSize: annotationHeight,
|
|
35703
|
+
maxWidth: getEffectiveWidth(contentWidth),
|
|
35704
|
+
segments: [
|
|
35705
|
+
{
|
|
35706
|
+
runIndex,
|
|
35707
|
+
fromChar: 0,
|
|
35708
|
+
toChar: 1,
|
|
35709
|
+
width: annotationWidth
|
|
35710
|
+
}
|
|
35711
|
+
]
|
|
35712
|
+
};
|
|
35713
|
+
} else {
|
|
35714
|
+
currentLine.toRun = runIndex;
|
|
35715
|
+
currentLine.toChar = 1;
|
|
35716
|
+
currentLine.width = roundValue(currentLine.width + annotationWidth);
|
|
35717
|
+
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, annotationHeight);
|
|
35718
|
+
if (!currentLine.segments) currentLine.segments = [];
|
|
35719
|
+
currentLine.segments.push({
|
|
35720
|
+
runIndex,
|
|
35721
|
+
fromChar: 0,
|
|
35722
|
+
toChar: 1,
|
|
35723
|
+
width: annotationWidth,
|
|
35724
|
+
...annotationStartX !== void 0 ? { x: annotationStartX } : {}
|
|
35725
|
+
});
|
|
35726
|
+
}
|
|
35727
|
+
const tabAlign = lastAppliedTabAlign;
|
|
35728
|
+
if (tabAlign && currentLine && tabAlign.val === "end") {
|
|
35729
|
+
currentLine.width = roundValue(tabAlign.target);
|
|
35730
|
+
}
|
|
35731
|
+
lastAppliedTabAlign = null;
|
|
35732
|
+
continue;
|
|
35733
|
+
}
|
|
34641
35734
|
if (!("text" in run) || !("fontSize" in run)) {
|
|
34642
35735
|
continue;
|
|
34643
35736
|
}
|
|
@@ -36711,6 +37804,16 @@ function isInRegisteredSurface(event) {
|
|
|
36711
37804
|
}
|
|
36712
37805
|
return false;
|
|
36713
37806
|
}
|
|
37807
|
+
const CommentMarkName = "commentMark";
|
|
37808
|
+
const TrackInsertMarkName = "trackInsert";
|
|
37809
|
+
const TrackDeleteMarkName = "trackDelete";
|
|
37810
|
+
const TrackFormatMarkName = "trackFormat";
|
|
37811
|
+
function isValidFieldAnnotationAttributes(attrs) {
|
|
37812
|
+
if (!attrs || typeof attrs !== "object") return false;
|
|
37813
|
+
const a = attrs;
|
|
37814
|
+
return typeof a.fieldId === "string" && typeof a.fieldType === "string" && typeof a.displayLabel === "string" && typeof a.type === "string";
|
|
37815
|
+
}
|
|
37816
|
+
const FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation";
|
|
36714
37817
|
const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
|
|
36715
37818
|
const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
36716
37819
|
const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
|
|
@@ -36736,6 +37839,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36736
37839
|
__privateAdd(this, _layoutOptions);
|
|
36737
37840
|
__privateAdd(this, _layoutState, { blocks: [], measures: [], layout: null });
|
|
36738
37841
|
__privateAdd(this, _domPainter, null);
|
|
37842
|
+
__privateAdd(this, _dragHandlerCleanup, null);
|
|
36739
37843
|
__privateAdd(this, _layoutError, null);
|
|
36740
37844
|
__privateAdd(this, _layoutErrorState, "healthy");
|
|
36741
37845
|
__privateAdd(this, _errorBanner, null);
|
|
@@ -36805,8 +37909,12 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36805
37909
|
if (event.button !== 0) {
|
|
36806
37910
|
return;
|
|
36807
37911
|
}
|
|
37912
|
+
const target = event.target;
|
|
37913
|
+
const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
|
|
36808
37914
|
if (!__privateGet(this, _layoutState).layout) {
|
|
36809
|
-
|
|
37915
|
+
if (!isDraggableAnnotation) {
|
|
37916
|
+
event.preventDefault();
|
|
37917
|
+
}
|
|
36810
37918
|
if (document.activeElement instanceof HTMLElement) {
|
|
36811
37919
|
document.activeElement.blur();
|
|
36812
37920
|
}
|
|
@@ -36815,10 +37923,10 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36815
37923
|
return;
|
|
36816
37924
|
}
|
|
36817
37925
|
const validPos = __privateMethod(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
|
|
36818
|
-
const
|
|
36819
|
-
if (
|
|
37926
|
+
const doc22 = __privateGet(this, _editor3)?.state?.doc;
|
|
37927
|
+
if (doc22) {
|
|
36820
37928
|
try {
|
|
36821
|
-
const tr = __privateGet(this, _editor3).state.tr.setSelection(TextSelection.create(
|
|
37929
|
+
const tr = __privateGet(this, _editor3).state.tr.setSelection(TextSelection.create(doc22, validPos));
|
|
36822
37930
|
__privateGet(this, _editor3).view?.dispatch(tr);
|
|
36823
37931
|
} catch (error) {
|
|
36824
37932
|
if (process$1.env.NODE_ENV === "development") {
|
|
@@ -36854,7 +37962,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36854
37962
|
if (headerFooterRegion) {
|
|
36855
37963
|
return;
|
|
36856
37964
|
}
|
|
36857
|
-
const
|
|
37965
|
+
const rawHit = clickToPosition(
|
|
36858
37966
|
__privateGet(this, _layoutState).layout,
|
|
36859
37967
|
__privateGet(this, _layoutState).blocks,
|
|
36860
37968
|
__privateGet(this, _layoutState).measures,
|
|
@@ -36863,7 +37971,11 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36863
37971
|
event.clientX,
|
|
36864
37972
|
event.clientY
|
|
36865
37973
|
);
|
|
36866
|
-
|
|
37974
|
+
const doc2 = __privateGet(this, _editor3).state?.doc;
|
|
37975
|
+
const hit = rawHit && doc2 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc2.content.size)) } : rawHit;
|
|
37976
|
+
if (!isDraggableAnnotation) {
|
|
37977
|
+
event.preventDefault();
|
|
37978
|
+
}
|
|
36867
37979
|
if (!hit) {
|
|
36868
37980
|
if (document.activeElement instanceof HTMLElement) {
|
|
36869
37981
|
document.activeElement.blur();
|
|
@@ -36871,10 +37983,10 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36871
37983
|
const editorDom2 = __privateGet(this, _editor3).view?.dom;
|
|
36872
37984
|
if (editorDom2) {
|
|
36873
37985
|
const validPos = __privateMethod(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
|
|
36874
|
-
const
|
|
36875
|
-
if (
|
|
37986
|
+
const doc22 = __privateGet(this, _editor3)?.state?.doc;
|
|
37987
|
+
if (doc22) {
|
|
36876
37988
|
try {
|
|
36877
|
-
const tr = __privateGet(this, _editor3).state.tr.setSelection(TextSelection.create(
|
|
37989
|
+
const tr = __privateGet(this, _editor3).state.tr.setSelection(TextSelection.create(doc22, validPos));
|
|
36878
37990
|
__privateGet(this, _editor3).view?.dispatch(tr);
|
|
36879
37991
|
} catch (error) {
|
|
36880
37992
|
if (process$1.env.NODE_ENV === "development") {
|
|
@@ -36895,9 +38007,9 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36895
38007
|
hit.pos
|
|
36896
38008
|
);
|
|
36897
38009
|
if (fragmentHit && (fragmentHit.fragment.kind === "image" || fragmentHit.fragment.kind === "drawing")) {
|
|
36898
|
-
const
|
|
38010
|
+
const doc22 = __privateGet(this, _editor3).state.doc;
|
|
36899
38011
|
try {
|
|
36900
|
-
const tr = __privateGet(this, _editor3).state.tr.setSelection(NodeSelection.create(
|
|
38012
|
+
const tr = __privateGet(this, _editor3).state.tr.setSelection(NodeSelection.create(doc22, hit.pos));
|
|
36901
38013
|
__privateGet(this, _editor3).view?.dispatch(tr);
|
|
36902
38014
|
if (__privateGet(this, _lastSelectedImageBlockId) && __privateGet(this, _lastSelectedImageBlockId) !== fragmentHit.fragment.blockId) {
|
|
36903
38015
|
this.emit("imageDeselected", { blockId: __privateGet(this, _lastSelectedImageBlockId) });
|
|
@@ -36988,8 +38100,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
36988
38100
|
}
|
|
36989
38101
|
}
|
|
36990
38102
|
if (!handledByDepth) {
|
|
36991
|
-
const tr = __privateGet(this, _editor3).state.tr.setSelection(TextSelection.create(__privateGet(this, _editor3).state.doc, hit.pos));
|
|
36992
38103
|
try {
|
|
38104
|
+
const tr = __privateGet(this, _editor3).state.tr.setSelection(TextSelection.create(__privateGet(this, _editor3).state.doc, hit.pos));
|
|
36993
38105
|
__privateGet(this, _editor3).view?.dispatch(tr);
|
|
36994
38106
|
} catch {
|
|
36995
38107
|
}
|
|
@@ -37064,6 +38176,133 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
37064
38176
|
}
|
|
37065
38177
|
__privateSet(this, _isDragging, false);
|
|
37066
38178
|
});
|
|
38179
|
+
/**
|
|
38180
|
+
* Handles dragover events for field annotation drag-and-drop operations.
|
|
38181
|
+
* Updates the cursor position during drag to provide visual feedback.
|
|
38182
|
+
*
|
|
38183
|
+
* @param event - The dragover event from the browser
|
|
38184
|
+
*
|
|
38185
|
+
* Side effects:
|
|
38186
|
+
* - Prevents default browser drag behavior
|
|
38187
|
+
* - Sets dropEffect to 'copy' to indicate the drag operation type
|
|
38188
|
+
* - Updates the editor's text selection to follow the drag cursor
|
|
38189
|
+
* - Triggers selection overlay updates via #scheduleSelectionUpdate
|
|
38190
|
+
*
|
|
38191
|
+
* Early returns:
|
|
38192
|
+
* - If the editor is not editable
|
|
38193
|
+
* - If no field annotation data is present in the drag
|
|
38194
|
+
* - If hit testing fails or document is unavailable
|
|
38195
|
+
* - If the cursor position hasn't changed
|
|
38196
|
+
*/
|
|
38197
|
+
__privateAdd(this, _handleDragOver, (event) => {
|
|
38198
|
+
const activeEditor = this.getActiveEditor();
|
|
38199
|
+
if (!activeEditor?.isEditable) {
|
|
38200
|
+
return;
|
|
38201
|
+
}
|
|
38202
|
+
event.preventDefault();
|
|
38203
|
+
if (event.dataTransfer) {
|
|
38204
|
+
event.dataTransfer.dropEffect = "copy";
|
|
38205
|
+
}
|
|
38206
|
+
const dt = event.dataTransfer;
|
|
38207
|
+
const hasFieldAnnotation = dt?.types?.includes(FIELD_ANNOTATION_DATA_TYPE) || Boolean(dt?.getData?.(FIELD_ANNOTATION_DATA_TYPE));
|
|
38208
|
+
if (!hasFieldAnnotation) {
|
|
38209
|
+
return;
|
|
38210
|
+
}
|
|
38211
|
+
const hit = this.hitTest(event.clientX, event.clientY);
|
|
38212
|
+
const doc2 = activeEditor.state?.doc;
|
|
38213
|
+
if (!hit || !doc2) {
|
|
38214
|
+
return;
|
|
38215
|
+
}
|
|
38216
|
+
const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
|
|
38217
|
+
const currentSelection = activeEditor.state.selection;
|
|
38218
|
+
const isSameCursor = currentSelection instanceof TextSelection && currentSelection.from === pos && currentSelection.to === pos;
|
|
38219
|
+
if (isSameCursor) {
|
|
38220
|
+
return;
|
|
38221
|
+
}
|
|
38222
|
+
try {
|
|
38223
|
+
const tr = activeEditor.state.tr.setSelection(TextSelection.create(doc2, pos)).setMeta("addToHistory", false);
|
|
38224
|
+
activeEditor.view?.dispatch(tr);
|
|
38225
|
+
__privateMethod(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
38226
|
+
} catch (error) {
|
|
38227
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
38228
|
+
console.debug("[PresentationEditor] Drag position update skipped:", error);
|
|
38229
|
+
}
|
|
38230
|
+
}
|
|
38231
|
+
});
|
|
38232
|
+
/**
|
|
38233
|
+
* Handles drop events for field annotation drag-and-drop operations.
|
|
38234
|
+
* Inserts a field annotation at the drop position and emits events for tracking.
|
|
38235
|
+
*
|
|
38236
|
+
* @param event - The drop event from the browser
|
|
38237
|
+
*
|
|
38238
|
+
* Side effects:
|
|
38239
|
+
* - Prevents default browser drop behavior and stops event propagation
|
|
38240
|
+
* - Inserts a field annotation node at the drop position
|
|
38241
|
+
* - Moves the cursor to just after the inserted node
|
|
38242
|
+
* - Emits 'fieldAnnotationDropped' event with drop metadata
|
|
38243
|
+
* - Focuses the editor view
|
|
38244
|
+
* - Triggers selection overlay updates via #scheduleSelectionUpdate
|
|
38245
|
+
*
|
|
38246
|
+
* Early returns:
|
|
38247
|
+
* - If the editor is not editable
|
|
38248
|
+
* - If no field annotation data is present in the drop
|
|
38249
|
+
* - If JSON parsing of the payload fails
|
|
38250
|
+
* - If hit testing and fallback position both fail
|
|
38251
|
+
* - If the parsed attributes fail validation
|
|
38252
|
+
*
|
|
38253
|
+
* Fallback behavior:
|
|
38254
|
+
* - If hit testing fails (e.g., during a reflow), falls back to current selection position
|
|
38255
|
+
* - If selection is unavailable, falls back to end of document
|
|
38256
|
+
*/
|
|
38257
|
+
__privateAdd(this, _handleDrop, (event) => {
|
|
38258
|
+
const activeEditor = this.getActiveEditor();
|
|
38259
|
+
if (!activeEditor?.isEditable) {
|
|
38260
|
+
return;
|
|
38261
|
+
}
|
|
38262
|
+
if (event.dataTransfer?.types?.includes("application/x-field-annotation")) {
|
|
38263
|
+
return;
|
|
38264
|
+
}
|
|
38265
|
+
event.preventDefault();
|
|
38266
|
+
event.stopPropagation();
|
|
38267
|
+
const fieldAnnotationData = event.dataTransfer?.getData(FIELD_ANNOTATION_DATA_TYPE);
|
|
38268
|
+
if (!fieldAnnotationData) {
|
|
38269
|
+
return;
|
|
38270
|
+
}
|
|
38271
|
+
const hit = this.hitTest(event.clientX, event.clientY);
|
|
38272
|
+
const selection = activeEditor.state?.selection;
|
|
38273
|
+
const fallbackPos = selection?.from ?? activeEditor.state?.doc?.content.size ?? null;
|
|
38274
|
+
const pos = hit?.pos ?? fallbackPos;
|
|
38275
|
+
if (pos == null) {
|
|
38276
|
+
return;
|
|
38277
|
+
}
|
|
38278
|
+
let parsedData = null;
|
|
38279
|
+
try {
|
|
38280
|
+
parsedData = JSON.parse(fieldAnnotationData);
|
|
38281
|
+
} catch {
|
|
38282
|
+
return;
|
|
38283
|
+
}
|
|
38284
|
+
const { attributes, sourceField } = parsedData ?? {};
|
|
38285
|
+
activeEditor.emit?.("fieldAnnotationDropped", {
|
|
38286
|
+
sourceField,
|
|
38287
|
+
editor: activeEditor,
|
|
38288
|
+
coordinates: hit,
|
|
38289
|
+
pos
|
|
38290
|
+
});
|
|
38291
|
+
if (attributes && isValidFieldAnnotationAttributes(attributes)) {
|
|
38292
|
+
activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
|
|
38293
|
+
const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
|
|
38294
|
+
const tr = activeEditor.state?.tr.setSelection(TextSelection.create(activeEditor.state.doc, posAfter));
|
|
38295
|
+
if (tr) {
|
|
38296
|
+
activeEditor.view?.dispatch(tr);
|
|
38297
|
+
}
|
|
38298
|
+
__privateMethod(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
38299
|
+
}
|
|
38300
|
+
const editorDom = activeEditor.view?.dom;
|
|
38301
|
+
if (editorDom) {
|
|
38302
|
+
editorDom.focus();
|
|
38303
|
+
activeEditor.view?.focus();
|
|
38304
|
+
}
|
|
38305
|
+
});
|
|
37067
38306
|
__privateAdd(this, _handleDoubleClick, (event) => {
|
|
37068
38307
|
if (event.button !== 0) return;
|
|
37069
38308
|
if (!__privateGet(this, _layoutState).layout) return;
|
|
@@ -37253,6 +38492,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
37253
38492
|
__privateMethod(this, _PresentationEditor_instances, applyZoom_fn).call(this);
|
|
37254
38493
|
__privateMethod(this, _PresentationEditor_instances, setupEditorListeners_fn).call(this);
|
|
37255
38494
|
__privateMethod(this, _PresentationEditor_instances, setupPointerHandlers_fn).call(this);
|
|
38495
|
+
__privateMethod(this, _PresentationEditor_instances, setupDragHandlers_fn).call(this);
|
|
37256
38496
|
__privateMethod(this, _PresentationEditor_instances, setupInputBridge_fn).call(this);
|
|
37257
38497
|
__privateMethod(this, _PresentationEditor_instances, syncTrackedChangesPreferences_fn).call(this);
|
|
37258
38498
|
if (options.documentId) {
|
|
@@ -37964,6 +39204,7 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
37964
39204
|
* Safe to call during partial initialization.
|
|
37965
39205
|
*/
|
|
37966
39206
|
destroy() {
|
|
39207
|
+
var _a;
|
|
37967
39208
|
if (__privateGet(this, _rafHandle) != null) {
|
|
37968
39209
|
__privateMethod(this, _PresentationEditor_instances, safeCleanup_fn).call(this, () => {
|
|
37969
39210
|
const win = __privateGet(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
|
|
@@ -37985,6 +39226,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
37985
39226
|
__privateGet(this, _viewportHost)?.removeEventListener("pointermove", __privateGet(this, _handlePointerMove));
|
|
37986
39227
|
__privateGet(this, _viewportHost)?.removeEventListener("pointerup", __privateGet(this, _handlePointerUp));
|
|
37987
39228
|
__privateGet(this, _viewportHost)?.removeEventListener("pointerleave", __privateGet(this, _handlePointerLeave));
|
|
39229
|
+
__privateGet(this, _viewportHost)?.removeEventListener("dragover", __privateGet(this, _handleDragOver));
|
|
39230
|
+
__privateGet(this, _viewportHost)?.removeEventListener("drop", __privateGet(this, _handleDrop));
|
|
37988
39231
|
__privateGet(this, _visibleHost)?.removeEventListener("keydown", __privateGet(this, _handleKeyDown));
|
|
37989
39232
|
__privateGet(this, _inputBridge)?.notifyTargetChanged();
|
|
37990
39233
|
__privateGet(this, _inputBridge)?.destroy();
|
|
@@ -38023,6 +39266,8 @@ const _PresentationEditor = class _PresentationEditor extends EventEmitter {
|
|
|
38023
39266
|
__privateSet(this, _session, { mode: "body" });
|
|
38024
39267
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
38025
39268
|
__privateSet(this, _domPainter, null);
|
|
39269
|
+
(_a = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a.call(this);
|
|
39270
|
+
__privateSet(this, _dragHandlerCleanup, null);
|
|
38026
39271
|
__privateGet(this, _selectionOverlay2)?.remove();
|
|
38027
39272
|
__privateGet(this, _painterHost)?.remove();
|
|
38028
39273
|
__privateGet(this, _hiddenHost)?.remove();
|
|
@@ -38050,6 +39295,7 @@ _hiddenHost = new WeakMap();
|
|
|
38050
39295
|
_layoutOptions = new WeakMap();
|
|
38051
39296
|
_layoutState = new WeakMap();
|
|
38052
39297
|
_domPainter = new WeakMap();
|
|
39298
|
+
_dragHandlerCleanup = new WeakMap();
|
|
38053
39299
|
_layoutError = new WeakMap();
|
|
38054
39300
|
_layoutErrorState = new WeakMap();
|
|
38055
39301
|
_errorBanner = new WeakMap();
|
|
@@ -38105,6 +39351,44 @@ _scrollCleanup = new WeakMap();
|
|
|
38105
39351
|
_remoteCursorRafHandle = new WeakMap();
|
|
38106
39352
|
_scrollTimeout = new WeakMap();
|
|
38107
39353
|
_PresentationEditor_instances = new WeakSet();
|
|
39354
|
+
/**
|
|
39355
|
+
* Collect all comment and tracked change positions from the PM document.
|
|
39356
|
+
*
|
|
39357
|
+
* This is the authoritative source for PM positions - called after every
|
|
39358
|
+
* layout update to ensure positions are always fresh from the current document.
|
|
39359
|
+
*
|
|
39360
|
+
* The returned positions contain PM offsets (start, end) which can be passed
|
|
39361
|
+
* to getCommentBounds() to compute visual layout coordinates.
|
|
39362
|
+
*
|
|
39363
|
+
* @returns Map of threadId -> { threadId, start, end }
|
|
39364
|
+
*/
|
|
39365
|
+
collectCommentPositions_fn = function() {
|
|
39366
|
+
const editorState = __privateGet(this, _editor3)?.state;
|
|
39367
|
+
if (!editorState) return {};
|
|
39368
|
+
const doc2 = editorState.doc;
|
|
39369
|
+
const trackChangeMarks = [TrackInsertMarkName, TrackDeleteMarkName, TrackFormatMarkName];
|
|
39370
|
+
const pmPositions = {};
|
|
39371
|
+
doc2.descendants((node, pos) => {
|
|
39372
|
+
const marks = node.marks || [];
|
|
39373
|
+
for (const mark of marks) {
|
|
39374
|
+
let threadId;
|
|
39375
|
+
if (mark.type.name === CommentMarkName) {
|
|
39376
|
+
threadId = mark.attrs.commentId || mark.attrs.importedId;
|
|
39377
|
+
} else if (trackChangeMarks.includes(mark.type.name)) {
|
|
39378
|
+
threadId = mark.attrs.id;
|
|
39379
|
+
}
|
|
39380
|
+
if (!threadId) continue;
|
|
39381
|
+
const nodeEnd = pos + node.nodeSize;
|
|
39382
|
+
if (!pmPositions[threadId]) {
|
|
39383
|
+
pmPositions[threadId] = { threadId, start: pos, end: nodeEnd };
|
|
39384
|
+
} else {
|
|
39385
|
+
pmPositions[threadId].start = Math.min(pmPositions[threadId].start, pos);
|
|
39386
|
+
pmPositions[threadId].end = Math.max(pmPositions[threadId].end, nodeEnd);
|
|
39387
|
+
}
|
|
39388
|
+
}
|
|
39389
|
+
});
|
|
39390
|
+
return pmPositions;
|
|
39391
|
+
};
|
|
38108
39392
|
/**
|
|
38109
39393
|
* Aggregate an array of rects into a single bounding box.
|
|
38110
39394
|
*/
|
|
@@ -38550,8 +39834,104 @@ setupPointerHandlers_fn = function() {
|
|
|
38550
39834
|
__privateGet(this, _viewportHost).addEventListener("pointermove", __privateGet(this, _handlePointerMove));
|
|
38551
39835
|
__privateGet(this, _viewportHost).addEventListener("pointerup", __privateGet(this, _handlePointerUp));
|
|
38552
39836
|
__privateGet(this, _viewportHost).addEventListener("pointerleave", __privateGet(this, _handlePointerLeave));
|
|
39837
|
+
__privateGet(this, _viewportHost).addEventListener("dragover", __privateGet(this, _handleDragOver));
|
|
39838
|
+
__privateGet(this, _viewportHost).addEventListener("drop", __privateGet(this, _handleDrop));
|
|
38553
39839
|
__privateGet(this, _visibleHost).addEventListener("keydown", __privateGet(this, _handleKeyDown));
|
|
38554
39840
|
};
|
|
39841
|
+
/**
|
|
39842
|
+
* Sets up drag and drop handlers for field annotations in the layout engine view.
|
|
39843
|
+
* Uses the DragHandler from layout-bridge to handle drag events and map drop
|
|
39844
|
+
* coordinates to ProseMirror positions.
|
|
39845
|
+
*/
|
|
39846
|
+
setupDragHandlers_fn = function() {
|
|
39847
|
+
var _a;
|
|
39848
|
+
(_a = __privateGet(this, _dragHandlerCleanup)) == null ? void 0 : _a.call(this);
|
|
39849
|
+
__privateSet(this, _dragHandlerCleanup, null);
|
|
39850
|
+
__privateSet(this, _dragHandlerCleanup, createDragHandler(__privateGet(this, _painterHost), {
|
|
39851
|
+
onDragOver: (event) => {
|
|
39852
|
+
if (!event.hasFieldAnnotation || event.event.clientX === 0) {
|
|
39853
|
+
return;
|
|
39854
|
+
}
|
|
39855
|
+
const activeEditor = this.getActiveEditor();
|
|
39856
|
+
if (!activeEditor?.isEditable) {
|
|
39857
|
+
return;
|
|
39858
|
+
}
|
|
39859
|
+
const hit = this.hitTest(event.clientX, event.clientY);
|
|
39860
|
+
const doc2 = activeEditor.state?.doc;
|
|
39861
|
+
if (!hit || !doc2) {
|
|
39862
|
+
return;
|
|
39863
|
+
}
|
|
39864
|
+
const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
|
|
39865
|
+
const currentSelection = activeEditor.state.selection;
|
|
39866
|
+
if (currentSelection instanceof TextSelection && currentSelection.from === pos && currentSelection.to === pos) {
|
|
39867
|
+
return;
|
|
39868
|
+
}
|
|
39869
|
+
try {
|
|
39870
|
+
const tr = activeEditor.state.tr.setSelection(TextSelection.create(doc2, pos)).setMeta("addToHistory", false);
|
|
39871
|
+
activeEditor.view?.dispatch(tr);
|
|
39872
|
+
__privateMethod(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
39873
|
+
} catch {
|
|
39874
|
+
}
|
|
39875
|
+
},
|
|
39876
|
+
onDrop: (event) => {
|
|
39877
|
+
event.event.preventDefault();
|
|
39878
|
+
event.event.stopPropagation();
|
|
39879
|
+
if (event.pmPosition === null) {
|
|
39880
|
+
return;
|
|
39881
|
+
}
|
|
39882
|
+
const activeEditor = this.getActiveEditor();
|
|
39883
|
+
const { state, view } = activeEditor;
|
|
39884
|
+
if (!state || !view) {
|
|
39885
|
+
return;
|
|
39886
|
+
}
|
|
39887
|
+
const fieldId = event.data.fieldId;
|
|
39888
|
+
if (fieldId) {
|
|
39889
|
+
const targetPos = event.pmPosition;
|
|
39890
|
+
let sourceStart = null;
|
|
39891
|
+
let sourceEnd = null;
|
|
39892
|
+
let sourceNode = null;
|
|
39893
|
+
state.doc.descendants((node, pos) => {
|
|
39894
|
+
if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
|
|
39895
|
+
sourceStart = pos;
|
|
39896
|
+
sourceEnd = pos + node.nodeSize;
|
|
39897
|
+
sourceNode = node;
|
|
39898
|
+
return false;
|
|
39899
|
+
}
|
|
39900
|
+
return true;
|
|
39901
|
+
});
|
|
39902
|
+
if (sourceStart === null || sourceEnd === null || !sourceNode) {
|
|
39903
|
+
return;
|
|
39904
|
+
}
|
|
39905
|
+
if (targetPos >= sourceStart && targetPos <= sourceEnd) {
|
|
39906
|
+
return;
|
|
39907
|
+
}
|
|
39908
|
+
const tr = state.tr;
|
|
39909
|
+
tr.delete(sourceStart, sourceEnd);
|
|
39910
|
+
const mappedTarget = tr.mapping.map(targetPos);
|
|
39911
|
+
if (mappedTarget < 0 || mappedTarget > tr.doc.content.size) {
|
|
39912
|
+
return;
|
|
39913
|
+
}
|
|
39914
|
+
tr.insert(mappedTarget, sourceNode);
|
|
39915
|
+
tr.setMeta("uiEvent", "drop");
|
|
39916
|
+
view.dispatch(tr);
|
|
39917
|
+
return;
|
|
39918
|
+
}
|
|
39919
|
+
const attrs = event.data.attributes;
|
|
39920
|
+
if (attrs && isValidFieldAnnotationAttributes(attrs)) {
|
|
39921
|
+
const inserted = activeEditor.commands?.addFieldAnnotation?.(event.pmPosition, attrs, true);
|
|
39922
|
+
if (inserted) {
|
|
39923
|
+
__privateMethod(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
39924
|
+
}
|
|
39925
|
+
return;
|
|
39926
|
+
}
|
|
39927
|
+
activeEditor.emit("fieldAnnotationDropped", {
|
|
39928
|
+
sourceField: event.data,
|
|
39929
|
+
editor: activeEditor,
|
|
39930
|
+
coordinates: { pos: event.pmPosition }
|
|
39931
|
+
});
|
|
39932
|
+
}
|
|
39933
|
+
}));
|
|
39934
|
+
};
|
|
38555
39935
|
setupInputBridge_fn = function() {
|
|
38556
39936
|
__privateGet(this, _inputBridge)?.destroy();
|
|
38557
39937
|
const win = __privateGet(this, _visibleHost).ownerDocument?.defaultView ?? window;
|
|
@@ -38850,6 +40230,8 @@ isWordCharacter_fn = function(char) {
|
|
|
38850
40230
|
_handlePointerMove = new WeakMap();
|
|
38851
40231
|
_handlePointerLeave = new WeakMap();
|
|
38852
40232
|
_handlePointerUp = new WeakMap();
|
|
40233
|
+
_handleDragOver = new WeakMap();
|
|
40234
|
+
_handleDrop = new WeakMap();
|
|
38853
40235
|
_handleDoubleClick = new WeakMap();
|
|
38854
40236
|
_handleKeyDown = new WeakMap();
|
|
38855
40237
|
focusHeaderFooterShortcut_fn = function(kind) {
|
|
@@ -39020,6 +40402,11 @@ rerender_fn = async function() {
|
|
|
39020
40402
|
const payload = { layout, blocks, measures, metrics };
|
|
39021
40403
|
this.emit("layoutUpdated", payload);
|
|
39022
40404
|
this.emit("paginationUpdate", payload);
|
|
40405
|
+
const commentPositions = __privateMethod(this, _PresentationEditor_instances, collectCommentPositions_fn).call(this);
|
|
40406
|
+
const positionKeys = Object.keys(commentPositions);
|
|
40407
|
+
if (positionKeys.length > 0) {
|
|
40408
|
+
this.emit("commentPositions", { positions: commentPositions });
|
|
40409
|
+
}
|
|
39023
40410
|
if (__privateGet(this, _telemetryEmitter) && metrics) {
|
|
39024
40411
|
__privateGet(this, _telemetryEmitter).call(this, { type: "layout", data: { layout, blocks, measures, metrics } });
|
|
39025
40412
|
}
|
|
@@ -44674,6 +46061,7 @@ const Paragraph = OxmlNode.create({
|
|
|
44674
46061
|
return ["p", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
|
|
44675
46062
|
},
|
|
44676
46063
|
addNodeView() {
|
|
46064
|
+
if (this.editor.options?.mode !== "docx" || !this.editor.converter) return null;
|
|
44677
46065
|
if (shouldSkipNodeView(this.editor)) return null;
|
|
44678
46066
|
return ({ node, editor, getPos, decorations, extensionAttrs }) => {
|
|
44679
46067
|
return new ParagraphNodeView(node, editor, getPos, decorations, extensionAttrs);
|
|
@@ -44916,7 +46304,7 @@ const CommentReference = Node$1.create({
|
|
|
44916
46304
|
}
|
|
44917
46305
|
});
|
|
44918
46306
|
const CommentsMark = Mark.create({
|
|
44919
|
-
name: CommentMarkName,
|
|
46307
|
+
name: CommentMarkName$1,
|
|
44920
46308
|
group: "comments",
|
|
44921
46309
|
excludes: "",
|
|
44922
46310
|
addOptions() {
|
|
@@ -44935,10 +46323,10 @@ const CommentsMark = Mark.create({
|
|
|
44935
46323
|
};
|
|
44936
46324
|
},
|
|
44937
46325
|
parseDOM() {
|
|
44938
|
-
return [{ tag: CommentMarkName }];
|
|
46326
|
+
return [{ tag: CommentMarkName$1 }];
|
|
44939
46327
|
},
|
|
44940
46328
|
renderDOM({ htmlAttributes }) {
|
|
44941
|
-
return [CommentMarkName, Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
46329
|
+
return [CommentMarkName$1, Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
44942
46330
|
}
|
|
44943
46331
|
});
|
|
44944
46332
|
let cache = /* @__PURE__ */ new WeakMap();
|
|
@@ -55150,7 +56538,7 @@ function addLinkRelationship({ editor, href }) {
|
|
|
55150
56538
|
}
|
|
55151
56539
|
const trackInsertClass = "track-insert";
|
|
55152
56540
|
const TrackInsert = Mark.create({
|
|
55153
|
-
name: TrackInsertMarkName,
|
|
56541
|
+
name: TrackInsertMarkName$1,
|
|
55154
56542
|
group: "track",
|
|
55155
56543
|
inclusive: false,
|
|
55156
56544
|
addOptions() {
|
|
@@ -55227,7 +56615,7 @@ const TrackInsert = Mark.create({
|
|
|
55227
56615
|
});
|
|
55228
56616
|
const trackDeleteClass = "track-delete";
|
|
55229
56617
|
const TrackDelete = Mark.create({
|
|
55230
|
-
name: TrackDeleteMarkName,
|
|
56618
|
+
name: TrackDeleteMarkName$1,
|
|
55231
56619
|
group: "track",
|
|
55232
56620
|
inclusive: false,
|
|
55233
56621
|
addOptions() {
|
|
@@ -55336,7 +56724,7 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
55336
56724
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
55337
56725
|
const trackFormatClass = "track-format";
|
|
55338
56726
|
const TrackFormat = Mark.create({
|
|
55339
|
-
name: TrackFormatMarkName,
|
|
56727
|
+
name: TrackFormatMarkName$1,
|
|
55340
56728
|
group: "track",
|
|
55341
56729
|
inclusive: false,
|
|
55342
56730
|
addOptions() {
|
|
@@ -55550,7 +56938,7 @@ const TrackChanges = Extension.create({
|
|
|
55550
56938
|
tr.setMeta("inputType", "acceptReject");
|
|
55551
56939
|
const map2 = new Mapping();
|
|
55552
56940
|
doc2.nodesBetween(from2, to, (node, pos) => {
|
|
55553
|
-
if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
56941
|
+
if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
|
|
55554
56942
|
const deletionStep = new ReplaceStep(
|
|
55555
56943
|
map2.map(Math.max(pos, from2)),
|
|
55556
56944
|
map2.map(Math.min(pos + node.nodeSize, to)),
|
|
@@ -55558,8 +56946,8 @@ const TrackChanges = Extension.create({
|
|
|
55558
56946
|
);
|
|
55559
56947
|
tr.step(deletionStep);
|
|
55560
56948
|
map2.appendMap(deletionStep.getMap());
|
|
55561
|
-
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName)) {
|
|
55562
|
-
const insertionMark = node.marks.find((mark) => mark.type.name === TrackInsertMarkName);
|
|
56949
|
+
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1)) {
|
|
56950
|
+
const insertionMark = node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1);
|
|
55563
56951
|
tr.step(
|
|
55564
56952
|
new RemoveMarkStep(
|
|
55565
56953
|
map2.map(Math.max(pos, from2)),
|
|
@@ -55567,8 +56955,8 @@ const TrackChanges = Extension.create({
|
|
|
55567
56955
|
insertionMark
|
|
55568
56956
|
)
|
|
55569
56957
|
);
|
|
55570
|
-
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName)) {
|
|
55571
|
-
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
56958
|
+
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1)) {
|
|
56959
|
+
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
|
|
55572
56960
|
tr.step(
|
|
55573
56961
|
new RemoveMarkStep(
|
|
55574
56962
|
map2.map(Math.max(pos, from2)),
|
|
@@ -55590,8 +56978,8 @@ const TrackChanges = Extension.create({
|
|
|
55590
56978
|
tr.setMeta("inputType", "acceptReject");
|
|
55591
56979
|
const map2 = new Mapping();
|
|
55592
56980
|
doc2.nodesBetween(from2, to, (node, pos) => {
|
|
55593
|
-
if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName)) {
|
|
55594
|
-
const deletionMark = node.marks.find((mark) => mark.type.name === TrackDeleteMarkName);
|
|
56981
|
+
if (node.marks && node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1)) {
|
|
56982
|
+
const deletionMark = node.marks.find((mark) => mark.type.name === TrackDeleteMarkName$1);
|
|
55595
56983
|
tr.step(
|
|
55596
56984
|
new RemoveMarkStep(
|
|
55597
56985
|
map2.map(Math.max(pos, from2)),
|
|
@@ -55599,7 +56987,7 @@ const TrackChanges = Extension.create({
|
|
|
55599
56987
|
deletionMark
|
|
55600
56988
|
)
|
|
55601
56989
|
);
|
|
55602
|
-
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName)) {
|
|
56990
|
+
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackInsertMarkName$1)) {
|
|
55603
56991
|
const deletionStep = new ReplaceStep(
|
|
55604
56992
|
map2.map(Math.max(pos, from2)),
|
|
55605
56993
|
map2.map(Math.min(pos + node.nodeSize, to)),
|
|
@@ -55607,8 +56995,8 @@ const TrackChanges = Extension.create({
|
|
|
55607
56995
|
);
|
|
55608
56996
|
tr.step(deletionStep);
|
|
55609
56997
|
map2.appendMap(deletionStep.getMap());
|
|
55610
|
-
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName)) {
|
|
55611
|
-
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName);
|
|
56998
|
+
} else if (node.marks && node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1)) {
|
|
56999
|
+
const formatChangeMark = node.marks.find((mark) => mark.type.name === TrackFormatMarkName$1);
|
|
55612
57000
|
formatChangeMark.attrs.before.forEach((oldMark) => {
|
|
55613
57001
|
tr.step(
|
|
55614
57002
|
new AddMarkStep(
|
|
@@ -55784,7 +57172,7 @@ const getChangesByIdToResolve = (state, id) => {
|
|
|
55784
57172
|
const hasContentBetween = state.doc.textBetween(left2.from, right2.to, "\n").length > getSegmentSize(left2) + getSegmentSize(right2);
|
|
55785
57173
|
return !hasContentBetween;
|
|
55786
57174
|
};
|
|
55787
|
-
const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName && secondType === TrackInsertMarkName || firstType === TrackInsertMarkName && secondType === TrackDeleteMarkName;
|
|
57175
|
+
const isComplementaryPair = (firstType, secondType) => firstType === TrackDeleteMarkName$1 && secondType === TrackInsertMarkName$1 || firstType === TrackInsertMarkName$1 && secondType === TrackDeleteMarkName$1;
|
|
55788
57176
|
const linkedBefore = [];
|
|
55789
57177
|
const linkedAfter = [];
|
|
55790
57178
|
const collectDirection = (direction, collection) => {
|