superdoc 1.0.0-beta.30 → 1.0.0-beta.32
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-BADCvUNL.cjs → PdfViewer-CTKbqDWv.cjs} +1 -1
- package/dist/chunks/{PdfViewer-C2nY5qD8.es.js → PdfViewer-edjIRb_p.es.js} +1 -1
- package/dist/chunks/{index-DTgPk1zO.cjs → index-Cajp7-Xa.cjs} +3 -3
- package/dist/chunks/{index-DmelLGEj.es.js → index-Pwv0a9G5.es.js} +3 -3
- package/dist/chunks/{index-DUzV7kkk-BvBMF_lo.es.js → index-SGV4U12y-BPGxOtvI.es.js} +1 -1
- package/dist/chunks/{index-DUzV7kkk-CM3uwGCb.cjs → index-SGV4U12y-Dh5jaROA.cjs} +1 -1
- package/dist/chunks/{super-editor.es-463G9jKM.cjs → super-editor.es-BbbbKgEs.cjs} +1729 -105
- package/dist/chunks/{super-editor.es-Be9785LD.es.js → super-editor.es-CdGsYGU1.es.js} +1729 -105
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-U59bT3FO.js → converter-CpuOoAUa.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-DSnoGkju.js → docx-zipper-Dk99r397.js} +1 -1
- package/dist/super-editor/chunks/{editor-DRHVtMIR.js → editor-CFv-RJI-.js} +1776 -90
- package/dist/super-editor/chunks/{index-DUzV7kkk.js → index-SGV4U12y.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-DbBLxo6N.js → toolbar-CQr3Xnx9.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 +1715 -91
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -9340,14 +9340,14 @@ function requireSax() {
|
|
|
9340
9340
|
var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|
9341
9341
|
var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|
9342
9342
|
var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|
9343
|
-
function
|
|
9343
|
+
function isWhitespace2(c2) {
|
|
9344
9344
|
return c2 === " " || c2 === "\n" || c2 === "\r" || c2 === " ";
|
|
9345
9345
|
}
|
|
9346
9346
|
function isQuote(c2) {
|
|
9347
9347
|
return c2 === '"' || c2 === "'";
|
|
9348
9348
|
}
|
|
9349
9349
|
function isAttribEnd(c2) {
|
|
9350
|
-
return c2 === ">" ||
|
|
9350
|
+
return c2 === ">" || isWhitespace2(c2);
|
|
9351
9351
|
}
|
|
9352
9352
|
function isMatch(regex, c2) {
|
|
9353
9353
|
return regex.test(c2);
|
|
@@ -9972,7 +9972,7 @@ function requireSax() {
|
|
|
9972
9972
|
if (c2 === "<") {
|
|
9973
9973
|
parser.state = S2.OPEN_WAKA;
|
|
9974
9974
|
parser.startTagPosition = parser.position;
|
|
9975
|
-
} else if (!
|
|
9975
|
+
} else if (!isWhitespace2(c2)) {
|
|
9976
9976
|
strictFail(parser, "Non-whitespace before first tag.");
|
|
9977
9977
|
parser.textNode = c2;
|
|
9978
9978
|
parser.state = S2.TEXT;
|
|
@@ -10051,7 +10051,7 @@ function requireSax() {
|
|
|
10051
10051
|
parser.state = S2.OPEN_WAKA;
|
|
10052
10052
|
parser.startTagPosition = parser.position;
|
|
10053
10053
|
} else {
|
|
10054
|
-
if (!
|
|
10054
|
+
if (!isWhitespace2(c2) && (!parser.sawRoot || parser.closedRoot)) {
|
|
10055
10055
|
strictFail(parser, "Text data outside of root node.");
|
|
10056
10056
|
}
|
|
10057
10057
|
if (c2 === "&") {
|
|
@@ -10080,7 +10080,7 @@ function requireSax() {
|
|
|
10080
10080
|
if (c2 === "!") {
|
|
10081
10081
|
parser.state = S2.SGML_DECL;
|
|
10082
10082
|
parser.sgmlDecl = "";
|
|
10083
|
-
} else if (
|
|
10083
|
+
} else if (isWhitespace2(c2)) ;
|
|
10084
10084
|
else if (isMatch(nameStart, c2)) {
|
|
10085
10085
|
parser.state = S2.OPEN_TAG;
|
|
10086
10086
|
parser.tagName = c2;
|
|
@@ -10264,14 +10264,14 @@ function requireSax() {
|
|
|
10264
10264
|
case S2.PROC_INST:
|
|
10265
10265
|
if (c2 === "?") {
|
|
10266
10266
|
parser.state = S2.PROC_INST_ENDING;
|
|
10267
|
-
} else if (
|
|
10267
|
+
} else if (isWhitespace2(c2)) {
|
|
10268
10268
|
parser.state = S2.PROC_INST_BODY;
|
|
10269
10269
|
} else {
|
|
10270
10270
|
parser.procInstName += c2;
|
|
10271
10271
|
}
|
|
10272
10272
|
continue;
|
|
10273
10273
|
case S2.PROC_INST_BODY:
|
|
10274
|
-
if (!parser.procInstBody &&
|
|
10274
|
+
if (!parser.procInstBody && isWhitespace2(c2)) {
|
|
10275
10275
|
continue;
|
|
10276
10276
|
} else if (c2 === "?") {
|
|
10277
10277
|
parser.state = S2.PROC_INST_ENDING;
|
|
@@ -10302,7 +10302,7 @@ function requireSax() {
|
|
|
10302
10302
|
} else if (c2 === "/") {
|
|
10303
10303
|
parser.state = S2.OPEN_TAG_SLASH;
|
|
10304
10304
|
} else {
|
|
10305
|
-
if (!
|
|
10305
|
+
if (!isWhitespace2(c2)) {
|
|
10306
10306
|
strictFail(parser, "Invalid character in tag name");
|
|
10307
10307
|
}
|
|
10308
10308
|
parser.state = S2.ATTRIB;
|
|
@@ -10322,7 +10322,7 @@ function requireSax() {
|
|
|
10322
10322
|
}
|
|
10323
10323
|
continue;
|
|
10324
10324
|
case S2.ATTRIB:
|
|
10325
|
-
if (
|
|
10325
|
+
if (isWhitespace2(c2)) {
|
|
10326
10326
|
continue;
|
|
10327
10327
|
} else if (c2 === ">") {
|
|
10328
10328
|
openTag(parser);
|
|
@@ -10344,7 +10344,7 @@ function requireSax() {
|
|
|
10344
10344
|
parser.attribValue = parser.attribName;
|
|
10345
10345
|
attrib(parser);
|
|
10346
10346
|
openTag(parser);
|
|
10347
|
-
} else if (
|
|
10347
|
+
} else if (isWhitespace2(c2)) {
|
|
10348
10348
|
parser.state = S2.ATTRIB_NAME_SAW_WHITE;
|
|
10349
10349
|
} else if (isMatch(nameBody, c2)) {
|
|
10350
10350
|
parser.attribName += c2;
|
|
@@ -10355,7 +10355,7 @@ function requireSax() {
|
|
|
10355
10355
|
case S2.ATTRIB_NAME_SAW_WHITE:
|
|
10356
10356
|
if (c2 === "=") {
|
|
10357
10357
|
parser.state = S2.ATTRIB_VALUE;
|
|
10358
|
-
} else if (
|
|
10358
|
+
} else if (isWhitespace2(c2)) {
|
|
10359
10359
|
continue;
|
|
10360
10360
|
} else {
|
|
10361
10361
|
strictFail(parser, "Attribute without value");
|
|
@@ -10378,7 +10378,7 @@ function requireSax() {
|
|
|
10378
10378
|
}
|
|
10379
10379
|
continue;
|
|
10380
10380
|
case S2.ATTRIB_VALUE:
|
|
10381
|
-
if (
|
|
10381
|
+
if (isWhitespace2(c2)) {
|
|
10382
10382
|
continue;
|
|
10383
10383
|
} else if (isQuote(c2)) {
|
|
10384
10384
|
parser.q = c2;
|
|
@@ -10405,7 +10405,7 @@ function requireSax() {
|
|
|
10405
10405
|
parser.state = S2.ATTRIB_VALUE_CLOSED;
|
|
10406
10406
|
continue;
|
|
10407
10407
|
case S2.ATTRIB_VALUE_CLOSED:
|
|
10408
|
-
if (
|
|
10408
|
+
if (isWhitespace2(c2)) {
|
|
10409
10409
|
parser.state = S2.ATTRIB;
|
|
10410
10410
|
} else if (c2 === ">") {
|
|
10411
10411
|
openTag(parser);
|
|
@@ -10438,7 +10438,7 @@ function requireSax() {
|
|
|
10438
10438
|
continue;
|
|
10439
10439
|
case S2.CLOSE_TAG:
|
|
10440
10440
|
if (!parser.tagName) {
|
|
10441
|
-
if (
|
|
10441
|
+
if (isWhitespace2(c2)) {
|
|
10442
10442
|
continue;
|
|
10443
10443
|
} else if (notMatch(nameStart, c2)) {
|
|
10444
10444
|
if (parser.script) {
|
|
@@ -10459,14 +10459,14 @@ function requireSax() {
|
|
|
10459
10459
|
parser.tagName = "";
|
|
10460
10460
|
parser.state = S2.SCRIPT;
|
|
10461
10461
|
} else {
|
|
10462
|
-
if (!
|
|
10462
|
+
if (!isWhitespace2(c2)) {
|
|
10463
10463
|
strictFail(parser, "Invalid tagname in closing tag");
|
|
10464
10464
|
}
|
|
10465
10465
|
parser.state = S2.CLOSE_TAG_SAW_WHITE;
|
|
10466
10466
|
}
|
|
10467
10467
|
continue;
|
|
10468
10468
|
case S2.CLOSE_TAG_SAW_WHITE:
|
|
10469
|
-
if (
|
|
10469
|
+
if (isWhitespace2(c2)) {
|
|
10470
10470
|
continue;
|
|
10471
10471
|
}
|
|
10472
10472
|
if (c2 === ">") {
|
|
@@ -41858,7 +41858,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
41858
41858
|
static getStoredSuperdocVersion(docx) {
|
|
41859
41859
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
41860
41860
|
}
|
|
41861
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
41861
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.32") {
|
|
41862
41862
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
41863
41863
|
}
|
|
41864
41864
|
/**
|
|
@@ -45164,7 +45164,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
45164
45164
|
var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
45165
45165
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
45166
45166
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
45167
|
-
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, 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, _remoteCursorState, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _remoteCursorRafHandle, _scrollTimeout, _PresentationEditor_instances, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, normalizeAwarenessStates_fn, getFallbackColor_fn, getValidatedColor_fn, scheduleRemoteCursorUpdate_fn, scheduleRemoteCursorReRender_fn, updateRemoteCursors_fn, renderRemoteCursors_fn, renderRemoteCaret_fn, renderRemoteCursorLabel_fn, renderRemoteSelection_fn, setupPointerHandlers_fn, setupInputBridge_fn, initHeaderFooterRegistry_fn, _handlePointerDown, getFirstTextPosition_fn, registerPointerClick_fn, selectWordAt_fn, selectParagraphAt_fn, isWordCharacter_fn, _handlePointerMove, _handlePointerLeave, _handleDoubleClick, _handleKeyDown, focusHeaderFooterShortcut_fn, scheduleRerender_fn, flushRerenderQueue_fn, rerender_fn, ensurePainter_fn, scheduleSelectionUpdate_fn, updateSelection_fn, resolveLayoutOptions_fn, buildHeaderFooterInput_fn, computeHeaderFooterConstraints_fn, 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;
|
|
45167
|
+
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, 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, 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;
|
|
45168
45168
|
var GOOD_LEAF_SIZE = 200;
|
|
45169
45169
|
var RopeSequence = function RopeSequence2() {
|
|
45170
45170
|
};
|
|
@@ -59031,7 +59031,7 @@ const isHeadless = (editor) => {
|
|
|
59031
59031
|
const shouldSkipNodeView = (editor) => {
|
|
59032
59032
|
return isHeadless(editor);
|
|
59033
59033
|
};
|
|
59034
|
-
const summaryVersion = "1.0.0-beta.
|
|
59034
|
+
const summaryVersion = "1.0.0-beta.32";
|
|
59035
59035
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
59036
59036
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
59037
59037
|
function mapAttributes(attrs) {
|
|
@@ -59820,7 +59820,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
59820
59820
|
{ default: remarkStringify },
|
|
59821
59821
|
{ default: remarkGfm }
|
|
59822
59822
|
] = await Promise.all([
|
|
59823
|
-
Promise.resolve().then(() => require("./index-
|
|
59823
|
+
Promise.resolve().then(() => require("./index-SGV4U12y-Dh5jaROA.cjs")),
|
|
59824
59824
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
59825
59825
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
59826
59826
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -60025,7 +60025,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60025
60025
|
* Process collaboration migrations
|
|
60026
60026
|
*/
|
|
60027
60027
|
processCollaborationMigrations() {
|
|
60028
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
60028
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.32");
|
|
60029
60029
|
if (!this.options.ydoc) return;
|
|
60030
60030
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
60031
60031
|
let docVersion = metaMap.get("version");
|
|
@@ -62062,9 +62062,11 @@ const applyMarksToRun = (run2, marks, hyperlinkConfig = DEFAULT_HYPERLINK_CONFIG
|
|
|
62062
62062
|
case TRACK_INSERT_MARK:
|
|
62063
62063
|
case TRACK_DELETE_MARK:
|
|
62064
62064
|
case TRACK_FORMAT_MARK: {
|
|
62065
|
-
|
|
62066
|
-
|
|
62067
|
-
|
|
62065
|
+
if (!isTabRun2) {
|
|
62066
|
+
const tracked = buildTrackedChangeMetaFromMark(mark);
|
|
62067
|
+
if (tracked) {
|
|
62068
|
+
run2.trackedChange = selectTrackedChangeMeta(run2.trackedChange, tracked);
|
|
62069
|
+
}
|
|
62068
62070
|
}
|
|
62069
62071
|
break;
|
|
62070
62072
|
}
|
|
@@ -65165,7 +65167,27 @@ function handleStructuredContentBlockNode(node, context) {
|
|
|
65165
65167
|
blocks.push(block);
|
|
65166
65168
|
recordBlockKind(block.kind);
|
|
65167
65169
|
});
|
|
65168
|
-
} else if (child.type === "table")
|
|
65170
|
+
} else if (child.type === "table") {
|
|
65171
|
+
const tableNodeToBlock2 = converters?.tableNodeToBlock;
|
|
65172
|
+
if (tableNodeToBlock2) {
|
|
65173
|
+
const tableBlock = tableNodeToBlock2(
|
|
65174
|
+
child,
|
|
65175
|
+
nextBlockId,
|
|
65176
|
+
positions,
|
|
65177
|
+
defaultFont,
|
|
65178
|
+
defaultSize,
|
|
65179
|
+
styleContext,
|
|
65180
|
+
trackedChangesConfig,
|
|
65181
|
+
bookmarks,
|
|
65182
|
+
hyperlinkConfig
|
|
65183
|
+
);
|
|
65184
|
+
if (tableBlock) {
|
|
65185
|
+
applySdtMetadataToTableBlock(tableBlock, structuredContentMetadata);
|
|
65186
|
+
blocks.push(tableBlock);
|
|
65187
|
+
recordBlockKind(tableBlock.kind);
|
|
65188
|
+
}
|
|
65189
|
+
}
|
|
65190
|
+
}
|
|
65169
65191
|
});
|
|
65170
65192
|
}
|
|
65171
65193
|
function processParagraphChild(child, sectionMetadata, context, output, converters) {
|
|
@@ -65635,6 +65657,65 @@ function imageNodeToRun(node, positions, activeSdt) {
|
|
|
65635
65657
|
}
|
|
65636
65658
|
return run2;
|
|
65637
65659
|
}
|
|
65660
|
+
function fieldAnnotationNodeToRun(node, positions, fieldMetadata) {
|
|
65661
|
+
const attrs = node.attrs ?? {};
|
|
65662
|
+
const rawVariant = attrs.type ?? fieldMetadata?.variant ?? "text";
|
|
65663
|
+
const validVariants = ["text", "image", "signature", "checkbox", "html", "link"];
|
|
65664
|
+
const variant = validVariants.includes(rawVariant) ? rawVariant : "text";
|
|
65665
|
+
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) || "";
|
|
65666
|
+
const run2 = {
|
|
65667
|
+
kind: "fieldAnnotation",
|
|
65668
|
+
variant,
|
|
65669
|
+
displayLabel
|
|
65670
|
+
};
|
|
65671
|
+
const fieldId = typeof attrs.fieldId === "string" ? attrs.fieldId : fieldMetadata?.fieldId;
|
|
65672
|
+
if (fieldId) run2.fieldId = fieldId;
|
|
65673
|
+
const fieldType = typeof attrs.fieldType === "string" ? attrs.fieldType : fieldMetadata?.fieldType;
|
|
65674
|
+
if (fieldType) run2.fieldType = fieldType;
|
|
65675
|
+
const fieldColor = typeof attrs.fieldColor === "string" ? attrs.fieldColor : fieldMetadata?.fieldColor;
|
|
65676
|
+
if (fieldColor) run2.fieldColor = fieldColor;
|
|
65677
|
+
const borderColor = typeof attrs.borderColor === "string" ? attrs.borderColor : fieldMetadata?.borderColor;
|
|
65678
|
+
if (borderColor) run2.borderColor = borderColor;
|
|
65679
|
+
const highlighted = attrs.highlighted ?? fieldMetadata?.highlighted;
|
|
65680
|
+
if (highlighted === false) run2.highlighted = false;
|
|
65681
|
+
if (attrs.hidden === true || fieldMetadata?.hidden === true) run2.hidden = true;
|
|
65682
|
+
const visibility = attrs.visibility ?? fieldMetadata?.visibility;
|
|
65683
|
+
if (visibility === "hidden") run2.visibility = "hidden";
|
|
65684
|
+
const imageSrc = typeof attrs.imageSrc === "string" ? attrs.imageSrc : fieldMetadata?.imageSrc;
|
|
65685
|
+
if (imageSrc) run2.imageSrc = imageSrc;
|
|
65686
|
+
const linkUrl = typeof attrs.linkUrl === "string" ? attrs.linkUrl : fieldMetadata?.linkUrl;
|
|
65687
|
+
if (linkUrl) run2.linkUrl = linkUrl;
|
|
65688
|
+
const rawHtml = attrs.rawHtml ?? fieldMetadata?.rawHtml;
|
|
65689
|
+
if (typeof rawHtml === "string") run2.rawHtml = rawHtml;
|
|
65690
|
+
const size2 = attrs.size ?? fieldMetadata?.size;
|
|
65691
|
+
if (size2 && (typeof size2.width === "number" || typeof size2.height === "number")) {
|
|
65692
|
+
run2.size = {
|
|
65693
|
+
width: typeof size2.width === "number" ? size2.width : void 0,
|
|
65694
|
+
height: typeof size2.height === "number" ? size2.height : void 0
|
|
65695
|
+
};
|
|
65696
|
+
}
|
|
65697
|
+
const fontFamily2 = attrs.fontFamily ?? fieldMetadata?.fontFamily;
|
|
65698
|
+
if (typeof fontFamily2 === "string") run2.fontFamily = fontFamily2;
|
|
65699
|
+
const fontSize2 = attrs.fontSize ?? fieldMetadata?.fontSize;
|
|
65700
|
+
if (typeof fontSize2 === "string" || typeof fontSize2 === "number") run2.fontSize = fontSize2;
|
|
65701
|
+
const textColor = attrs.textColor ?? fieldMetadata?.textColor;
|
|
65702
|
+
if (typeof textColor === "string") run2.textColor = textColor;
|
|
65703
|
+
const textHighlight = attrs.textHighlight ?? fieldMetadata?.textHighlight;
|
|
65704
|
+
if (typeof textHighlight === "string") run2.textHighlight = textHighlight;
|
|
65705
|
+
const formatting = fieldMetadata?.formatting;
|
|
65706
|
+
if (attrs.bold === true || formatting?.bold === true) run2.bold = true;
|
|
65707
|
+
if (attrs.italic === true || formatting?.italic === true) run2.italic = true;
|
|
65708
|
+
if (attrs.underline === true || formatting?.underline === true) run2.underline = true;
|
|
65709
|
+
const pos = positions.get(node);
|
|
65710
|
+
if (pos) {
|
|
65711
|
+
run2.pmStart = pos.start;
|
|
65712
|
+
run2.pmEnd = pos.end;
|
|
65713
|
+
}
|
|
65714
|
+
if (fieldMetadata) {
|
|
65715
|
+
run2.sdt = fieldMetadata;
|
|
65716
|
+
}
|
|
65717
|
+
return run2;
|
|
65718
|
+
}
|
|
65638
65719
|
const isTextRun$1 = (run2) => run2.kind !== "tab";
|
|
65639
65720
|
const dataAttrsCompatible = (a, b2) => {
|
|
65640
65721
|
const aAttrs = a.dataAttrs;
|
|
@@ -65930,28 +66011,20 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
65930
66011
|
}
|
|
65931
66012
|
if (node.type === "fieldAnnotation") {
|
|
65932
66013
|
const fieldMetadata = resolveNodeSdtMetadata(node, "fieldAnnotation");
|
|
66014
|
+
let contentText;
|
|
65933
66015
|
if (Array.isArray(node.content) && node.content.length > 0) {
|
|
65934
|
-
|
|
65935
|
-
|
|
65936
|
-
|
|
65937
|
-
|
|
65938
|
-
|
|
65939
|
-
|
|
65940
|
-
|
|
65941
|
-
|
|
65942
|
-
defaultFont,
|
|
65943
|
-
defaultSize,
|
|
65944
|
-
inheritedMarks,
|
|
65945
|
-
fieldMetadata ?? activeSdt,
|
|
65946
|
-
hyperlinkConfig,
|
|
65947
|
-
themeColors
|
|
65948
|
-
);
|
|
65949
|
-
const inlineStyleId = getInlineStyleId(inheritedMarks);
|
|
65950
|
-
applyRunStyles2(run2, inlineStyleId, activeRunStyleId);
|
|
65951
|
-
applyBaseRunDefaults(run2, baseRunDefaults, defaultFont, defaultSize);
|
|
65952
|
-
currentRuns.push(run2);
|
|
65953
|
-
}
|
|
66016
|
+
const extractText = (n) => {
|
|
66017
|
+
if (n.type === "text" && typeof n.text === "string") return n.text;
|
|
66018
|
+
if (Array.isArray(n.content)) {
|
|
66019
|
+
return n.content.map(extractText).join("");
|
|
66020
|
+
}
|
|
66021
|
+
return "";
|
|
66022
|
+
};
|
|
66023
|
+
contentText = node.content.map(extractText).join("");
|
|
65954
66024
|
}
|
|
66025
|
+
const nodeForRun = contentText && contentText.length > 0 ? { ...node, attrs: { ...node.attrs ?? {}, displayLabel: contentText } } : node;
|
|
66026
|
+
const run2 = fieldAnnotationNodeToRun(nodeForRun, positions, fieldMetadata);
|
|
66027
|
+
currentRuns.push(run2);
|
|
65955
66028
|
return;
|
|
65956
66029
|
}
|
|
65957
66030
|
if (node.type === "pageReference") {
|
|
@@ -66788,9 +66861,9 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
|
|
|
66788
66861
|
}
|
|
66789
66862
|
const attrs = spacingEl.attributes;
|
|
66790
66863
|
const spacing = {};
|
|
66791
|
-
const before = parseIntSafe(attrs["w:before"]);
|
|
66792
|
-
const after = parseIntSafe(attrs["w:after"]);
|
|
66793
|
-
const line = parseIntSafe(attrs["w:line"]);
|
|
66864
|
+
const before = parseIntSafe$1(attrs["w:before"]);
|
|
66865
|
+
const after = parseIntSafe$1(attrs["w:after"]);
|
|
66866
|
+
const line = parseIntSafe$1(attrs["w:line"]);
|
|
66794
66867
|
const rawLineRule = attrs["w:lineRule"];
|
|
66795
66868
|
const lineRule = rawLineRule === "auto" || rawLineRule === "exact" || rawLineRule === "atLeast" ? rawLineRule : void 0;
|
|
66796
66869
|
if (before != null) spacing.before = twipsToPx$1(before);
|
|
@@ -66805,11 +66878,11 @@ const extractTableStyleParagraphProps = (styleId, docx) => {
|
|
|
66805
66878
|
if (lineRule) spacing.lineRule = lineRule;
|
|
66806
66879
|
const result = Object.keys(spacing).length > 0 ? { spacing } : void 0;
|
|
66807
66880
|
return result;
|
|
66808
|
-
} catch
|
|
66881
|
+
} catch {
|
|
66809
66882
|
return void 0;
|
|
66810
66883
|
}
|
|
66811
66884
|
};
|
|
66812
|
-
const parseIntSafe = (value) => {
|
|
66885
|
+
const parseIntSafe$1 = (value) => {
|
|
66813
66886
|
if (value == null) return void 0;
|
|
66814
66887
|
const num = typeof value === "number" ? value : parseInt(String(value), 10);
|
|
66815
66888
|
return Number.isFinite(num) ? num : void 0;
|
|
@@ -67461,7 +67534,7 @@ function getMeasurementContext() {
|
|
|
67461
67534
|
return measurementCtx;
|
|
67462
67535
|
}
|
|
67463
67536
|
function getRunFontString(run2) {
|
|
67464
|
-
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || "src" in run2) {
|
|
67537
|
+
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
|
|
67465
67538
|
return "normal normal 16px Arial";
|
|
67466
67539
|
}
|
|
67467
67540
|
const style2 = run2.italic ? "italic" : "normal";
|
|
@@ -67492,6 +67565,10 @@ function sliceRunsForLine$1(block, line) {
|
|
|
67492
67565
|
result.push(run2);
|
|
67493
67566
|
continue;
|
|
67494
67567
|
}
|
|
67568
|
+
if (run2.kind === "fieldAnnotation") {
|
|
67569
|
+
result.push(run2);
|
|
67570
|
+
continue;
|
|
67571
|
+
}
|
|
67495
67572
|
const text = run2.text ?? "";
|
|
67496
67573
|
const isFirstRun = runIndex === line.fromRun;
|
|
67497
67574
|
const isLastRun = runIndex === line.toRun;
|
|
@@ -67525,7 +67602,8 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
67525
67602
|
1,
|
|
67526
67603
|
runs2.reduce((sum, run2) => {
|
|
67527
67604
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
67528
|
-
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break"
|
|
67605
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
|
|
67606
|
+
return sum;
|
|
67529
67607
|
return sum + (run2.text ?? "").length;
|
|
67530
67608
|
}, 0)
|
|
67531
67609
|
);
|
|
@@ -67546,7 +67624,7 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
67546
67624
|
currentCharOffset += runLength2;
|
|
67547
67625
|
continue;
|
|
67548
67626
|
}
|
|
67549
|
-
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
67627
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
67550
67628
|
const runLength = text.length;
|
|
67551
67629
|
if (currentCharOffset + runLength >= charOffset) {
|
|
67552
67630
|
const offsetInRun = charOffset - currentCharOffset;
|
|
@@ -67589,7 +67667,7 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
67589
67667
|
if (isTabRun$1(run2)) {
|
|
67590
67668
|
return segmentBaseX + (offsetInSegment > 0 ? segment.width ?? 0 : 0);
|
|
67591
67669
|
}
|
|
67592
|
-
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
67670
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
|
|
67593
67671
|
return segmentBaseX + (offsetInSegment >= segmentChars ? segment.width ?? 0 : 0);
|
|
67594
67672
|
}
|
|
67595
67673
|
const text = run2.text ?? "";
|
|
@@ -67604,6 +67682,38 @@ function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
|
67604
67682
|
}
|
|
67605
67683
|
return line.width;
|
|
67606
67684
|
}
|
|
67685
|
+
function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
|
|
67686
|
+
if (!Number.isFinite(charOffset) || !Number.isFinite(fallbackPmStart)) {
|
|
67687
|
+
console.warn("[charOffsetToPm] Invalid input:", { charOffset, fallbackPmStart });
|
|
67688
|
+
return fallbackPmStart;
|
|
67689
|
+
}
|
|
67690
|
+
const safeCharOffset = Math.max(0, charOffset);
|
|
67691
|
+
if (block.kind !== "paragraph") {
|
|
67692
|
+
return fallbackPmStart + safeCharOffset;
|
|
67693
|
+
}
|
|
67694
|
+
const runs = sliceRunsForLine$1(block, line);
|
|
67695
|
+
let cursor = 0;
|
|
67696
|
+
let lastPm = fallbackPmStart;
|
|
67697
|
+
for (const run2 of runs) {
|
|
67698
|
+
const isTab = isTabRun$1(run2);
|
|
67699
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
67700
|
+
const runLength = isTab ? TAB_CHAR_LENGTH : text.length;
|
|
67701
|
+
const runPmStart = typeof run2.pmStart === "number" ? run2.pmStart : null;
|
|
67702
|
+
const runPmEnd = typeof run2.pmEnd === "number" ? run2.pmEnd : runPmStart != null ? runPmStart + runLength : null;
|
|
67703
|
+
if (runPmStart != null) {
|
|
67704
|
+
lastPm = runPmStart;
|
|
67705
|
+
}
|
|
67706
|
+
if (safeCharOffset <= cursor + runLength) {
|
|
67707
|
+
const offsetInRun = Math.max(0, safeCharOffset - cursor);
|
|
67708
|
+
return runPmStart != null ? runPmStart + Math.min(offsetInRun, runLength) : fallbackPmStart + safeCharOffset;
|
|
67709
|
+
}
|
|
67710
|
+
if (runPmEnd != null) {
|
|
67711
|
+
lastPm = runPmEnd;
|
|
67712
|
+
}
|
|
67713
|
+
cursor += runLength;
|
|
67714
|
+
}
|
|
67715
|
+
return lastPm;
|
|
67716
|
+
}
|
|
67607
67717
|
function findCharacterAtX(block, line, x2, pmStart) {
|
|
67608
67718
|
const ctx2 = getMeasurementContext();
|
|
67609
67719
|
if (!ctx2) {
|
|
@@ -67612,15 +67722,17 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
67612
67722
|
1,
|
|
67613
67723
|
runs2.reduce((sum, run2) => {
|
|
67614
67724
|
if (isTabRun$1(run2)) return sum + TAB_CHAR_LENGTH;
|
|
67615
|
-
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break"
|
|
67725
|
+
if ("src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation")
|
|
67726
|
+
return sum;
|
|
67616
67727
|
return sum + (run2.text ?? "").length;
|
|
67617
67728
|
}, 0)
|
|
67618
67729
|
);
|
|
67619
67730
|
const ratio = Math.max(0, Math.min(1, x2 / line.width));
|
|
67620
67731
|
const charOffset = Math.round(ratio * charsInLine);
|
|
67732
|
+
const pmPosition2 = charOffsetToPm(block, line, charOffset, pmStart);
|
|
67621
67733
|
return {
|
|
67622
67734
|
charOffset,
|
|
67623
|
-
pmPosition:
|
|
67735
|
+
pmPosition: pmPosition2
|
|
67624
67736
|
};
|
|
67625
67737
|
}
|
|
67626
67738
|
const runs = sliceRunsForLine$1(block, line);
|
|
@@ -67636,18 +67748,17 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
67636
67748
|
const midpoint = startX + tabWidth / 2;
|
|
67637
67749
|
const offsetInRun = safeX < midpoint ? 0 : TAB_CHAR_LENGTH;
|
|
67638
67750
|
const charOffset = currentCharOffset + offsetInRun;
|
|
67639
|
-
const
|
|
67640
|
-
const pmPosition = pmBase + offsetInRun;
|
|
67751
|
+
const pmPosition2 = charOffsetToPm(block, line, charOffset, pmStart);
|
|
67641
67752
|
return {
|
|
67642
67753
|
charOffset,
|
|
67643
|
-
pmPosition
|
|
67754
|
+
pmPosition: pmPosition2
|
|
67644
67755
|
};
|
|
67645
67756
|
}
|
|
67646
67757
|
currentX = endX;
|
|
67647
67758
|
currentCharOffset += TAB_CHAR_LENGTH;
|
|
67648
67759
|
continue;
|
|
67649
67760
|
}
|
|
67650
|
-
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
67761
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
67651
67762
|
const runLength = text.length;
|
|
67652
67763
|
if (runLength === 0) continue;
|
|
67653
67764
|
ctx2.font = getRunFontString(run2);
|
|
@@ -67657,9 +67768,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
67657
67768
|
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength);
|
|
67658
67769
|
if (charX >= safeX) {
|
|
67659
67770
|
if (i === 0) {
|
|
67771
|
+
const pmPosition3 = charOffsetToPm(block, line, currentCharOffset, pmStart);
|
|
67660
67772
|
return {
|
|
67661
67773
|
charOffset: currentCharOffset,
|
|
67662
|
-
pmPosition:
|
|
67774
|
+
pmPosition: pmPosition3
|
|
67663
67775
|
};
|
|
67664
67776
|
}
|
|
67665
67777
|
const prevText = text.slice(0, i - 1);
|
|
@@ -67668,9 +67780,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
67668
67780
|
const distToPrev = Math.abs(safeX - prevX);
|
|
67669
67781
|
const distToCurrent = Math.abs(safeX - charX);
|
|
67670
67782
|
const charOffset = distToPrev < distToCurrent ? currentCharOffset + i - 1 : currentCharOffset + i;
|
|
67783
|
+
const pmPosition2 = charOffsetToPm(block, line, charOffset, pmStart);
|
|
67671
67784
|
return {
|
|
67672
67785
|
charOffset,
|
|
67673
|
-
pmPosition:
|
|
67786
|
+
pmPosition: pmPosition2
|
|
67674
67787
|
};
|
|
67675
67788
|
}
|
|
67676
67789
|
}
|
|
@@ -67678,13 +67791,14 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
67678
67791
|
currentX += measured.width + computeLetterSpacingWidth(run2, runLength, runLength);
|
|
67679
67792
|
currentCharOffset += runLength;
|
|
67680
67793
|
}
|
|
67794
|
+
const pmPosition = charOffsetToPm(block, line, currentCharOffset, pmStart);
|
|
67681
67795
|
return {
|
|
67682
67796
|
charOffset: currentCharOffset,
|
|
67683
|
-
pmPosition
|
|
67797
|
+
pmPosition
|
|
67684
67798
|
};
|
|
67685
67799
|
}
|
|
67686
67800
|
const computeLetterSpacingWidth = (run2, precedingChars, runLength) => {
|
|
67687
|
-
if (isTabRun$1(run2) || "src" in run2 || !("letterSpacing" in run2) || !run2.letterSpacing) {
|
|
67801
|
+
if (isTabRun$1(run2) || "src" in run2 || run2.kind === "fieldAnnotation" || !("letterSpacing" in run2) || !run2.letterSpacing) {
|
|
67688
67802
|
return 0;
|
|
67689
67803
|
}
|
|
67690
67804
|
const maxGaps = Math.max(runLength - 1, 0);
|
|
@@ -67781,6 +67895,17 @@ function clickToPositionDom(domContainer, clientX, clientY) {
|
|
|
67781
67895
|
pmStart: fragmentEl.dataset.pmStart,
|
|
67782
67896
|
pmEnd: fragmentEl.dataset.pmEnd
|
|
67783
67897
|
});
|
|
67898
|
+
const hitChainLine = hitChain.find(
|
|
67899
|
+
(el) => el.classList?.contains?.(CLASS_NAMES$1.line) && el.dataset?.pmStart !== void 0 && el.dataset?.pmEnd !== void 0
|
|
67900
|
+
);
|
|
67901
|
+
if (hitChainLine) {
|
|
67902
|
+
log("Using hit chain line directly:", {
|
|
67903
|
+
pmStart: hitChainLine.dataset.pmStart,
|
|
67904
|
+
pmEnd: hitChainLine.dataset.pmEnd
|
|
67905
|
+
});
|
|
67906
|
+
const result2 = processLineElement(hitChainLine, viewX);
|
|
67907
|
+
return result2;
|
|
67908
|
+
}
|
|
67784
67909
|
const result = processFragment(fragmentEl, viewX, viewY);
|
|
67785
67910
|
return result;
|
|
67786
67911
|
}
|
|
@@ -67846,7 +67971,82 @@ function processFragment(fragmentEl, viewX, viewY) {
|
|
|
67846
67971
|
if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
|
|
67847
67972
|
return null;
|
|
67848
67973
|
}
|
|
67849
|
-
const spanEls = Array.from(lineEl.querySelectorAll("span, a"))
|
|
67974
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
|
|
67975
|
+
(el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
|
|
67976
|
+
);
|
|
67977
|
+
log(
|
|
67978
|
+
"Spans/anchors in line:",
|
|
67979
|
+
spanEls.map((el, i) => {
|
|
67980
|
+
const rect = el.getBoundingClientRect();
|
|
67981
|
+
return {
|
|
67982
|
+
index: i,
|
|
67983
|
+
tag: el.tagName,
|
|
67984
|
+
pmStart: el.dataset.pmStart,
|
|
67985
|
+
pmEnd: el.dataset.pmEnd,
|
|
67986
|
+
text: el.textContent?.substring(0, 20) + (el.textContent && el.textContent.length > 20 ? "..." : ""),
|
|
67987
|
+
visibility: el.style.visibility,
|
|
67988
|
+
rect: { left: rect.left, right: rect.right, width: rect.width }
|
|
67989
|
+
};
|
|
67990
|
+
})
|
|
67991
|
+
);
|
|
67992
|
+
if (spanEls.length === 0) {
|
|
67993
|
+
return lineStart;
|
|
67994
|
+
}
|
|
67995
|
+
const firstRect = spanEls[0].getBoundingClientRect();
|
|
67996
|
+
if (viewX <= firstRect.left) {
|
|
67997
|
+
return lineStart;
|
|
67998
|
+
}
|
|
67999
|
+
const lastRect = spanEls[spanEls.length - 1].getBoundingClientRect();
|
|
68000
|
+
if (viewX >= lastRect.right) {
|
|
68001
|
+
return lineEnd;
|
|
68002
|
+
}
|
|
68003
|
+
const targetEl = findSpanAtX(spanEls, viewX);
|
|
68004
|
+
if (!targetEl) {
|
|
68005
|
+
return lineStart;
|
|
68006
|
+
}
|
|
68007
|
+
const spanStart = Number(targetEl.dataset.pmStart ?? "NaN");
|
|
68008
|
+
const spanEnd = Number(targetEl.dataset.pmEnd ?? "NaN");
|
|
68009
|
+
const targetRect = targetEl.getBoundingClientRect();
|
|
68010
|
+
log("Target element:", {
|
|
68011
|
+
tag: targetEl.tagName,
|
|
68012
|
+
pmStart: spanStart,
|
|
68013
|
+
pmEnd: spanEnd,
|
|
68014
|
+
text: targetEl.textContent?.substring(0, 30),
|
|
68015
|
+
visibility: targetEl.style.visibility,
|
|
68016
|
+
rect: { left: targetRect.left, right: targetRect.right, width: targetRect.width },
|
|
68017
|
+
pageX: viewX,
|
|
68018
|
+
pageY: viewY
|
|
68019
|
+
});
|
|
68020
|
+
if (!Number.isFinite(spanStart) || !Number.isFinite(spanEnd)) {
|
|
68021
|
+
return null;
|
|
68022
|
+
}
|
|
68023
|
+
const firstChild = targetEl.firstChild;
|
|
68024
|
+
if (!firstChild || firstChild.nodeType !== Node.TEXT_NODE || !firstChild.textContent) {
|
|
68025
|
+
const elRect = targetEl.getBoundingClientRect();
|
|
68026
|
+
const closerToLeft = Math.abs(viewX - elRect.left) <= Math.abs(viewX - elRect.right);
|
|
68027
|
+
const snapPos = closerToLeft ? spanStart : spanEnd;
|
|
68028
|
+
return snapPos;
|
|
68029
|
+
}
|
|
68030
|
+
const textNode = firstChild;
|
|
68031
|
+
const charIndex = findCharIndexAtX(textNode, targetEl, viewX);
|
|
68032
|
+
const pos = spanStart + charIndex;
|
|
68033
|
+
return pos;
|
|
68034
|
+
}
|
|
68035
|
+
function processLineElement(lineEl, viewX) {
|
|
68036
|
+
const lineStart = Number(lineEl.dataset.pmStart ?? "NaN");
|
|
68037
|
+
const lineEnd = Number(lineEl.dataset.pmEnd ?? "NaN");
|
|
68038
|
+
const lineRect = lineEl.getBoundingClientRect();
|
|
68039
|
+
log("processLineElement:", {
|
|
68040
|
+
pmStart: lineStart,
|
|
68041
|
+
pmEnd: lineEnd,
|
|
68042
|
+
rect: { top: lineRect.top, bottom: lineRect.bottom, left: lineRect.left, right: lineRect.right }
|
|
68043
|
+
});
|
|
68044
|
+
if (!Number.isFinite(lineStart) || !Number.isFinite(lineEnd)) {
|
|
68045
|
+
return null;
|
|
68046
|
+
}
|
|
68047
|
+
const spanEls = Array.from(lineEl.querySelectorAll("span, a")).filter(
|
|
68048
|
+
(el) => el.dataset.pmStart !== void 0 && el.dataset.pmEnd !== void 0
|
|
68049
|
+
);
|
|
67850
68050
|
log(
|
|
67851
68051
|
"Spans/anchors in line:",
|
|
67852
68052
|
spanEls.map((el, i) => {
|
|
@@ -70793,7 +70993,7 @@ const hashRuns = (block) => {
|
|
|
70793
70993
|
return `img:${srcHash}:${imgRun.width}x${imgRun.height}`;
|
|
70794
70994
|
}
|
|
70795
70995
|
const text = normalizeText(
|
|
70796
|
-
"src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? ""
|
|
70996
|
+
"src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? ""
|
|
70797
70997
|
);
|
|
70798
70998
|
const bold = "bold" in run2 ? run2.bold : false;
|
|
70799
70999
|
const italic = "italic" in run2 ? run2.italic : false;
|
|
@@ -71452,6 +71652,88 @@ async function layoutHeaderFooterWithCache(sections, constraints, measureBlock2,
|
|
|
71452
71652
|
}
|
|
71453
71653
|
return result;
|
|
71454
71654
|
}
|
|
71655
|
+
function findWordBoundaries(blocks, pos) {
|
|
71656
|
+
const blockInfo = findBlockAtPosition(blocks, pos);
|
|
71657
|
+
if (!blockInfo) return null;
|
|
71658
|
+
const { block, localPos } = blockInfo;
|
|
71659
|
+
if (block.kind !== "paragraph") return null;
|
|
71660
|
+
const { text, pmStart } = extractBlockText(block);
|
|
71661
|
+
if (text.length === 0) return null;
|
|
71662
|
+
const clampedPos = Math.max(0, Math.min(localPos, text.length));
|
|
71663
|
+
let wordStart = clampedPos;
|
|
71664
|
+
while (wordStart > 0 && isWordChar(text[wordStart - 1])) {
|
|
71665
|
+
wordStart--;
|
|
71666
|
+
}
|
|
71667
|
+
let wordEnd = clampedPos;
|
|
71668
|
+
while (wordEnd < text.length && isWordChar(text[wordEnd])) {
|
|
71669
|
+
wordEnd++;
|
|
71670
|
+
}
|
|
71671
|
+
if (wordStart === wordEnd) {
|
|
71672
|
+
while (wordStart > 0 && isWhitespace(text[wordStart - 1])) {
|
|
71673
|
+
wordStart--;
|
|
71674
|
+
}
|
|
71675
|
+
while (wordEnd < text.length && isWhitespace(text[wordEnd])) {
|
|
71676
|
+
wordEnd++;
|
|
71677
|
+
}
|
|
71678
|
+
if (wordStart === wordEnd) {
|
|
71679
|
+
return null;
|
|
71680
|
+
}
|
|
71681
|
+
}
|
|
71682
|
+
return {
|
|
71683
|
+
from: pmStart + wordStart,
|
|
71684
|
+
to: pmStart + wordEnd
|
|
71685
|
+
};
|
|
71686
|
+
}
|
|
71687
|
+
function findParagraphBoundaries(blocks, pos) {
|
|
71688
|
+
const blockInfo = findBlockAtPosition(blocks, pos);
|
|
71689
|
+
if (!blockInfo) return null;
|
|
71690
|
+
const { block } = blockInfo;
|
|
71691
|
+
if (block.kind === "paragraph") {
|
|
71692
|
+
const { pmStart, pmEnd } = extractBlockText(block);
|
|
71693
|
+
return { from: pmStart, to: pmEnd };
|
|
71694
|
+
}
|
|
71695
|
+
if (block.kind === "image") {
|
|
71696
|
+
return { from: pos, to: pos + 1 };
|
|
71697
|
+
}
|
|
71698
|
+
return null;
|
|
71699
|
+
}
|
|
71700
|
+
function extractBlockText(block) {
|
|
71701
|
+
if (block.kind !== "paragraph") {
|
|
71702
|
+
return { text: "", pmStart: 0, pmEnd: 0 };
|
|
71703
|
+
}
|
|
71704
|
+
let text = "";
|
|
71705
|
+
let pmStart = Infinity;
|
|
71706
|
+
let pmEnd = 0;
|
|
71707
|
+
for (const run2 of block.runs) {
|
|
71708
|
+
text += "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text;
|
|
71709
|
+
if (run2.pmStart !== void 0) {
|
|
71710
|
+
pmStart = Math.min(pmStart, run2.pmStart);
|
|
71711
|
+
}
|
|
71712
|
+
if (run2.pmEnd !== void 0) {
|
|
71713
|
+
pmEnd = Math.max(pmEnd, run2.pmEnd);
|
|
71714
|
+
}
|
|
71715
|
+
}
|
|
71716
|
+
if (pmStart === Infinity) pmStart = 0;
|
|
71717
|
+
if (pmEnd === 0 && text.length > 0) pmEnd = pmStart + text.length;
|
|
71718
|
+
return { text, pmStart, pmEnd };
|
|
71719
|
+
}
|
|
71720
|
+
function findBlockAtPosition(blocks, pos) {
|
|
71721
|
+
for (const block of blocks) {
|
|
71722
|
+
if (block.kind === "paragraph") {
|
|
71723
|
+
const { pmStart, pmEnd } = extractBlockText(block);
|
|
71724
|
+
if (pos >= pmStart && pos <= pmEnd) {
|
|
71725
|
+
return { block, localPos: pos - pmStart };
|
|
71726
|
+
}
|
|
71727
|
+
}
|
|
71728
|
+
}
|
|
71729
|
+
return null;
|
|
71730
|
+
}
|
|
71731
|
+
function isWordChar(char) {
|
|
71732
|
+
return /[\p{L}\p{N}_]/u.test(char);
|
|
71733
|
+
}
|
|
71734
|
+
function isWhitespace(char) {
|
|
71735
|
+
return /\s/.test(char);
|
|
71736
|
+
}
|
|
71455
71737
|
let canvas = null;
|
|
71456
71738
|
let ctx$1 = null;
|
|
71457
71739
|
function getCtx() {
|
|
@@ -71473,7 +71755,7 @@ function fontString(run2) {
|
|
|
71473
71755
|
return `${italic}${bold}${size2}px ${family}`.trim();
|
|
71474
71756
|
}
|
|
71475
71757
|
function runText(run2) {
|
|
71476
|
-
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
71758
|
+
return "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
71477
71759
|
}
|
|
71478
71760
|
function measureRunSliceWidth(run2, fromChar, toChar) {
|
|
71479
71761
|
const context = getCtx();
|
|
@@ -71635,7 +71917,7 @@ const paragraphBlocksEqual = (a, b2) => {
|
|
|
71635
71917
|
for (let i = 0; i < a.runs.length; i += 1) {
|
|
71636
71918
|
const runA = a.runs[i];
|
|
71637
71919
|
const runB = b2.runs[i];
|
|
71638
|
-
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)) {
|
|
71920
|
+
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)) {
|
|
71639
71921
|
return false;
|
|
71640
71922
|
}
|
|
71641
71923
|
}
|
|
@@ -71755,7 +72037,7 @@ function computeHeaderFooterContentHash(blocks) {
|
|
|
71755
72037
|
parts.push(block.id);
|
|
71756
72038
|
if (block.kind === "paragraph") {
|
|
71757
72039
|
for (const run2 of block.runs) {
|
|
71758
|
-
if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break") {
|
|
72040
|
+
if (!("src" in run2) && run2.kind !== "lineBreak" && run2.kind !== "break" && run2.kind !== "fieldAnnotation") {
|
|
71759
72041
|
parts.push(run2.text ?? "");
|
|
71760
72042
|
}
|
|
71761
72043
|
if ("bold" in run2 && run2.bold) parts.push("b");
|
|
@@ -72240,11 +72522,266 @@ var Priority = /* @__PURE__ */ ((Priority2) => {
|
|
|
72240
72522
|
/** P3: Heavy debounce for full document layout */
|
|
72241
72523
|
[Priority.P3]: 150
|
|
72242
72524
|
});
|
|
72525
|
+
const DEFAULT_MIME_TYPE$1 = "application/x-field-annotation";
|
|
72526
|
+
const LEGACY_MIME_TYPE = "fieldAnnotation";
|
|
72527
|
+
function parseIntSafe(value) {
|
|
72528
|
+
if (!value) return void 0;
|
|
72529
|
+
const parsed = parseInt(value, 10);
|
|
72530
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
72531
|
+
}
|
|
72532
|
+
function extractFieldAnnotationData(element) {
|
|
72533
|
+
const dataset = element.dataset;
|
|
72534
|
+
const attributes = {};
|
|
72535
|
+
for (const key2 in dataset) {
|
|
72536
|
+
const value = dataset[key2];
|
|
72537
|
+
if (value !== void 0) {
|
|
72538
|
+
attributes[key2] = value;
|
|
72539
|
+
}
|
|
72540
|
+
}
|
|
72541
|
+
return {
|
|
72542
|
+
fieldId: dataset.fieldId,
|
|
72543
|
+
fieldType: dataset.fieldType,
|
|
72544
|
+
variant: dataset.variant ?? dataset.type,
|
|
72545
|
+
displayLabel: dataset.displayLabel,
|
|
72546
|
+
pmStart: parseIntSafe(dataset.pmStart),
|
|
72547
|
+
pmEnd: parseIntSafe(dataset.pmEnd),
|
|
72548
|
+
attributes
|
|
72549
|
+
};
|
|
72550
|
+
}
|
|
72551
|
+
class DragHandler {
|
|
72552
|
+
/**
|
|
72553
|
+
* Creates a new DragHandler instance.
|
|
72554
|
+
*
|
|
72555
|
+
* @param container - The DOM container element (typically .superdoc-layout)
|
|
72556
|
+
* @param config - Configuration options and callbacks
|
|
72557
|
+
*/
|
|
72558
|
+
constructor(container, config2 = {}) {
|
|
72559
|
+
this.container = container;
|
|
72560
|
+
this.config = config2;
|
|
72561
|
+
this.mimeType = config2.mimeType ?? DEFAULT_MIME_TYPE$1;
|
|
72562
|
+
this.boundHandlers = {
|
|
72563
|
+
dragstart: this.handleDragStart.bind(this),
|
|
72564
|
+
dragover: this.handleDragOver.bind(this),
|
|
72565
|
+
drop: this.handleDrop.bind(this),
|
|
72566
|
+
dragend: this.handleDragEnd.bind(this),
|
|
72567
|
+
dragleave: this.handleDragLeave.bind(this)
|
|
72568
|
+
};
|
|
72569
|
+
this.windowDragoverHandler = this.handleWindowDragOver.bind(this);
|
|
72570
|
+
this.windowDropHandler = this.handleWindowDrop.bind(this);
|
|
72571
|
+
this.attachListeners();
|
|
72572
|
+
}
|
|
72573
|
+
/**
|
|
72574
|
+
* Attaches event listeners to the container and window.
|
|
72575
|
+
*/
|
|
72576
|
+
attachListeners() {
|
|
72577
|
+
this.container.addEventListener("dragstart", this.boundHandlers.dragstart);
|
|
72578
|
+
this.container.addEventListener("dragover", this.boundHandlers.dragover);
|
|
72579
|
+
this.container.addEventListener("drop", this.boundHandlers.drop);
|
|
72580
|
+
this.container.addEventListener("dragend", this.boundHandlers.dragend);
|
|
72581
|
+
this.container.addEventListener("dragleave", this.boundHandlers.dragleave);
|
|
72582
|
+
window.addEventListener("dragover", this.windowDragoverHandler, false);
|
|
72583
|
+
window.addEventListener("drop", this.windowDropHandler, false);
|
|
72584
|
+
}
|
|
72585
|
+
/**
|
|
72586
|
+
* Removes event listeners from the container and window.
|
|
72587
|
+
*/
|
|
72588
|
+
removeListeners() {
|
|
72589
|
+
this.container.removeEventListener("dragstart", this.boundHandlers.dragstart);
|
|
72590
|
+
this.container.removeEventListener("dragover", this.boundHandlers.dragover);
|
|
72591
|
+
this.container.removeEventListener("drop", this.boundHandlers.drop);
|
|
72592
|
+
this.container.removeEventListener("dragend", this.boundHandlers.dragend);
|
|
72593
|
+
this.container.removeEventListener("dragleave", this.boundHandlers.dragleave);
|
|
72594
|
+
window.removeEventListener("dragover", this.windowDragoverHandler, false);
|
|
72595
|
+
window.removeEventListener("drop", this.windowDropHandler, false);
|
|
72596
|
+
}
|
|
72597
|
+
/**
|
|
72598
|
+
* Handles dragover at window level to allow drops on overlay elements.
|
|
72599
|
+
* This ensures preventDefault is called even when dragging over selection
|
|
72600
|
+
* highlights or other UI elements that sit on top of the layout content.
|
|
72601
|
+
*/
|
|
72602
|
+
handleWindowDragOver(event) {
|
|
72603
|
+
if (this.hasFieldAnnotationData(event)) {
|
|
72604
|
+
event.preventDefault();
|
|
72605
|
+
if (event.dataTransfer) {
|
|
72606
|
+
event.dataTransfer.dropEffect = "move";
|
|
72607
|
+
}
|
|
72608
|
+
const target = event.target;
|
|
72609
|
+
if (!this.container.contains(target)) {
|
|
72610
|
+
this.config.onDragOver?.({
|
|
72611
|
+
event,
|
|
72612
|
+
clientX: event.clientX,
|
|
72613
|
+
clientY: event.clientY,
|
|
72614
|
+
hasFieldAnnotation: true
|
|
72615
|
+
});
|
|
72616
|
+
}
|
|
72617
|
+
}
|
|
72618
|
+
}
|
|
72619
|
+
/**
|
|
72620
|
+
* Handles drop at window level to catch drops on overlay elements.
|
|
72621
|
+
* If the drop target is outside the container, we process it here.
|
|
72622
|
+
*/
|
|
72623
|
+
handleWindowDrop(event) {
|
|
72624
|
+
if (this.hasFieldAnnotationData(event)) {
|
|
72625
|
+
const target = event.target;
|
|
72626
|
+
if (!this.container.contains(target)) {
|
|
72627
|
+
this.handleDrop(event);
|
|
72628
|
+
}
|
|
72629
|
+
}
|
|
72630
|
+
}
|
|
72631
|
+
/**
|
|
72632
|
+
* Handles the dragstart event.
|
|
72633
|
+
* Sets up dataTransfer with field annotation data and drag image.
|
|
72634
|
+
*/
|
|
72635
|
+
handleDragStart(event) {
|
|
72636
|
+
const target = event.target;
|
|
72637
|
+
if (!target?.dataset?.draggable || target.dataset.draggable !== "true") {
|
|
72638
|
+
return;
|
|
72639
|
+
}
|
|
72640
|
+
const data = extractFieldAnnotationData(target);
|
|
72641
|
+
if (event.dataTransfer) {
|
|
72642
|
+
const jsonData = JSON.stringify({
|
|
72643
|
+
attributes: data.attributes,
|
|
72644
|
+
sourceField: data
|
|
72645
|
+
});
|
|
72646
|
+
event.dataTransfer.setData(this.mimeType, jsonData);
|
|
72647
|
+
event.dataTransfer.setData(LEGACY_MIME_TYPE, jsonData);
|
|
72648
|
+
event.dataTransfer.setData("text/plain", data.displayLabel ?? "Field Annotation");
|
|
72649
|
+
event.dataTransfer.setDragImage(target, 0, 0);
|
|
72650
|
+
event.dataTransfer.effectAllowed = "move";
|
|
72651
|
+
}
|
|
72652
|
+
this.config.onDragStart?.({
|
|
72653
|
+
event,
|
|
72654
|
+
element: target,
|
|
72655
|
+
data
|
|
72656
|
+
});
|
|
72657
|
+
}
|
|
72658
|
+
/**
|
|
72659
|
+
* Handles the dragover event.
|
|
72660
|
+
* Provides visual feedback and determines if drop is allowed.
|
|
72661
|
+
*/
|
|
72662
|
+
handleDragOver(event) {
|
|
72663
|
+
const hasFieldAnnotation = this.hasFieldAnnotationData(event);
|
|
72664
|
+
if (hasFieldAnnotation) {
|
|
72665
|
+
event.preventDefault();
|
|
72666
|
+
if (event.dataTransfer) {
|
|
72667
|
+
event.dataTransfer.dropEffect = "move";
|
|
72668
|
+
}
|
|
72669
|
+
this.container.classList.add("drag-over");
|
|
72670
|
+
}
|
|
72671
|
+
this.config.onDragOver?.({
|
|
72672
|
+
event,
|
|
72673
|
+
clientX: event.clientX,
|
|
72674
|
+
clientY: event.clientY,
|
|
72675
|
+
hasFieldAnnotation
|
|
72676
|
+
});
|
|
72677
|
+
}
|
|
72678
|
+
/**
|
|
72679
|
+
* Handles the dragleave event.
|
|
72680
|
+
* Removes visual feedback when drag leaves the container.
|
|
72681
|
+
*/
|
|
72682
|
+
handleDragLeave(event) {
|
|
72683
|
+
const relatedTarget = event.relatedTarget;
|
|
72684
|
+
if (!relatedTarget || !this.container.contains(relatedTarget)) {
|
|
72685
|
+
this.container.classList.remove("drag-over");
|
|
72686
|
+
}
|
|
72687
|
+
}
|
|
72688
|
+
/**
|
|
72689
|
+
* Handles the drop event.
|
|
72690
|
+
* Maps drop coordinates to ProseMirror position and emits drop event.
|
|
72691
|
+
*/
|
|
72692
|
+
handleDrop(event) {
|
|
72693
|
+
this.container.classList.remove("drag-over");
|
|
72694
|
+
if (!this.hasFieldAnnotationData(event)) {
|
|
72695
|
+
return;
|
|
72696
|
+
}
|
|
72697
|
+
event.preventDefault();
|
|
72698
|
+
const data = this.extractDragData(event);
|
|
72699
|
+
if (!data) {
|
|
72700
|
+
return;
|
|
72701
|
+
}
|
|
72702
|
+
const pmPosition = clickToPositionDom(this.container, event.clientX, event.clientY);
|
|
72703
|
+
this.config.onDrop?.({
|
|
72704
|
+
event,
|
|
72705
|
+
data,
|
|
72706
|
+
pmPosition,
|
|
72707
|
+
clientX: event.clientX,
|
|
72708
|
+
clientY: event.clientY
|
|
72709
|
+
});
|
|
72710
|
+
}
|
|
72711
|
+
/**
|
|
72712
|
+
* Handles the dragend event.
|
|
72713
|
+
* Cleans up drag state.
|
|
72714
|
+
*/
|
|
72715
|
+
handleDragEnd(event) {
|
|
72716
|
+
this.container.classList.remove("drag-over");
|
|
72717
|
+
this.config.onDragEnd?.(event);
|
|
72718
|
+
}
|
|
72719
|
+
/**
|
|
72720
|
+
* Checks if a drag event contains field annotation data.
|
|
72721
|
+
*/
|
|
72722
|
+
hasFieldAnnotationData(event) {
|
|
72723
|
+
if (!event.dataTransfer) {
|
|
72724
|
+
return false;
|
|
72725
|
+
}
|
|
72726
|
+
const types2 = event.dataTransfer.types;
|
|
72727
|
+
return types2.includes(this.mimeType) || types2.includes(LEGACY_MIME_TYPE);
|
|
72728
|
+
}
|
|
72729
|
+
/**
|
|
72730
|
+
* Extracts field annotation data from a drag event's dataTransfer.
|
|
72731
|
+
*/
|
|
72732
|
+
extractDragData(event) {
|
|
72733
|
+
if (!event.dataTransfer) {
|
|
72734
|
+
return null;
|
|
72735
|
+
}
|
|
72736
|
+
let jsonData = event.dataTransfer.getData(this.mimeType);
|
|
72737
|
+
if (!jsonData) {
|
|
72738
|
+
jsonData = event.dataTransfer.getData(LEGACY_MIME_TYPE);
|
|
72739
|
+
}
|
|
72740
|
+
if (!jsonData) {
|
|
72741
|
+
return null;
|
|
72742
|
+
}
|
|
72743
|
+
try {
|
|
72744
|
+
const parsed = JSON.parse(jsonData);
|
|
72745
|
+
return parsed.sourceField ?? parsed.attributes ?? parsed;
|
|
72746
|
+
} catch {
|
|
72747
|
+
return null;
|
|
72748
|
+
}
|
|
72749
|
+
}
|
|
72750
|
+
/**
|
|
72751
|
+
* Updates the configuration options.
|
|
72752
|
+
*
|
|
72753
|
+
* @param config - New configuration options to merge
|
|
72754
|
+
*/
|
|
72755
|
+
updateConfig(config2) {
|
|
72756
|
+
this.config = { ...this.config, ...config2 };
|
|
72757
|
+
if (config2.mimeType) {
|
|
72758
|
+
this.mimeType = config2.mimeType;
|
|
72759
|
+
}
|
|
72760
|
+
}
|
|
72761
|
+
/**
|
|
72762
|
+
* Destroys the drag handler and removes all event listeners.
|
|
72763
|
+
* Call this when the layout engine is unmounted or the container is removed.
|
|
72764
|
+
*/
|
|
72765
|
+
destroy() {
|
|
72766
|
+
this.removeListeners();
|
|
72767
|
+
this.container.classList.remove("drag-over");
|
|
72768
|
+
}
|
|
72769
|
+
}
|
|
72770
|
+
function createDragHandler(container, config2 = {}) {
|
|
72771
|
+
const handler2 = new DragHandler(container, config2);
|
|
72772
|
+
return () => handler2.destroy();
|
|
72773
|
+
}
|
|
72243
72774
|
const isAtomicFragment = (fragment) => {
|
|
72244
72775
|
return fragment.kind === "drawing" || fragment.kind === "image";
|
|
72245
72776
|
};
|
|
72246
72777
|
const logClickStage = (_level, _stage, _payload) => {
|
|
72247
72778
|
};
|
|
72779
|
+
const logPositionDebug = (payload) => {
|
|
72780
|
+
return;
|
|
72781
|
+
};
|
|
72782
|
+
const logSelectionMapDebug = (payload) => {
|
|
72783
|
+
return;
|
|
72784
|
+
};
|
|
72248
72785
|
const blockPmRangeFromAttrs = (block) => {
|
|
72249
72786
|
const attrs = block?.attrs;
|
|
72250
72787
|
const pmStart = typeof attrs?.pmStart === "number" ? attrs.pmStart : void 0;
|
|
@@ -72514,6 +73051,10 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
|
|
|
72514
73051
|
return null;
|
|
72515
73052
|
}
|
|
72516
73053
|
const column = determineColumn(layout, fragment.x);
|
|
73054
|
+
logPositionDebug({
|
|
73055
|
+
blockId: fragment.blockId,
|
|
73056
|
+
x: pageRelativePoint.x - fragment.x
|
|
73057
|
+
});
|
|
72517
73058
|
logClickStage("log", "success", {
|
|
72518
73059
|
blockId: fragment.blockId
|
|
72519
73060
|
});
|
|
@@ -72622,10 +73163,13 @@ function selectionToRects(layout, blocks, measures, from2, to) {
|
|
|
72622
73163
|
const sliceFrom = Math.max(range2.pmStart, from2);
|
|
72623
73164
|
const sliceTo = Math.min(range2.pmEnd, to);
|
|
72624
73165
|
if (sliceFrom >= sliceTo) return;
|
|
72625
|
-
const
|
|
72626
|
-
const
|
|
72627
|
-
const
|
|
72628
|
-
const
|
|
73166
|
+
const charOffsetFrom = pmPosToCharOffset(block, line, sliceFrom);
|
|
73167
|
+
const charOffsetTo = pmPosToCharOffset(block, line, sliceTo);
|
|
73168
|
+
const startX = mapPmToX(block, line, charOffsetFrom, fragment.width);
|
|
73169
|
+
const endX = mapPmToX(block, line, charOffsetTo, fragment.width);
|
|
73170
|
+
const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
|
|
73171
|
+
const rectX = fragment.x + markerWidth + Math.min(startX, endX);
|
|
73172
|
+
const rectWidth = Math.max(1, Math.abs(endX - startX));
|
|
72629
73173
|
const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
|
|
72630
73174
|
const rectY = fragment.y + lineOffset;
|
|
72631
73175
|
rects.push({
|
|
@@ -72765,7 +73309,7 @@ function computeLinePmRange$1(block, line) {
|
|
|
72765
73309
|
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
72766
73310
|
const run2 = block.runs[runIndex];
|
|
72767
73311
|
if (!run2) continue;
|
|
72768
|
-
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" ? "" : run2.text ?? "";
|
|
73312
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
72769
73313
|
const runLength = text.length;
|
|
72770
73314
|
const runPmStart = run2.pmStart ?? null;
|
|
72771
73315
|
const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runLength : null);
|
|
@@ -72783,6 +73327,57 @@ function computeLinePmRange$1(block, line) {
|
|
|
72783
73327
|
}
|
|
72784
73328
|
return { pmStart, pmEnd };
|
|
72785
73329
|
}
|
|
73330
|
+
function pmPosToCharOffset(block, line, pmPos) {
|
|
73331
|
+
if (block.kind !== "paragraph") return 0;
|
|
73332
|
+
let charOffset = 0;
|
|
73333
|
+
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
73334
|
+
const run2 = block.runs[runIndex];
|
|
73335
|
+
if (!run2) continue;
|
|
73336
|
+
const text = "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" ? "" : run2.text ?? "";
|
|
73337
|
+
const runTextLength = text.length;
|
|
73338
|
+
const runPmStart = run2.pmStart ?? null;
|
|
73339
|
+
const runPmEnd = run2.pmEnd ?? (runPmStart != null ? runPmStart + runTextLength : null);
|
|
73340
|
+
if (runPmStart == null || runPmEnd == null || runTextLength === 0) continue;
|
|
73341
|
+
const isFirstRun = runIndex === line.fromRun;
|
|
73342
|
+
const isLastRun = runIndex === line.toRun;
|
|
73343
|
+
const lineStartChar = isFirstRun ? line.fromChar : 0;
|
|
73344
|
+
const lineEndChar = isLastRun ? line.toChar : runTextLength;
|
|
73345
|
+
const runSliceCharCount = lineEndChar - lineStartChar;
|
|
73346
|
+
const runPmRange = runPmEnd - runPmStart;
|
|
73347
|
+
const runSlicePmStart = runPmStart + lineStartChar / runTextLength * runPmRange;
|
|
73348
|
+
const runSlicePmEnd = runPmStart + lineEndChar / runTextLength * runPmRange;
|
|
73349
|
+
if (pmPos >= runSlicePmStart && pmPos <= runSlicePmEnd) {
|
|
73350
|
+
const runSlicePmRange = runSlicePmEnd - runSlicePmStart;
|
|
73351
|
+
if (runSlicePmRange > 0) {
|
|
73352
|
+
const pmOffsetInSlice = pmPos - runSlicePmStart;
|
|
73353
|
+
const charOffsetInSlice = Math.round(pmOffsetInSlice / runSlicePmRange * runSliceCharCount);
|
|
73354
|
+
const result = charOffset + Math.min(charOffsetInSlice, runSliceCharCount);
|
|
73355
|
+
const runText2 = text;
|
|
73356
|
+
const offsetInRun = result - charOffset - (isFirstRun ? 0 : 0);
|
|
73357
|
+
logSelectionMapDebug({
|
|
73358
|
+
blockId: block.id,
|
|
73359
|
+
lineFromRun: line.fromRun,
|
|
73360
|
+
lineToRun: line.toRun,
|
|
73361
|
+
runTextPreview: runText2.slice(Math.max(0, offsetInRun - 10), Math.min(runText2.length, offsetInRun + 10))
|
|
73362
|
+
});
|
|
73363
|
+
return result;
|
|
73364
|
+
}
|
|
73365
|
+
logSelectionMapDebug({
|
|
73366
|
+
blockId: block.id
|
|
73367
|
+
});
|
|
73368
|
+
return charOffset;
|
|
73369
|
+
}
|
|
73370
|
+
if (pmPos > runSlicePmEnd) {
|
|
73371
|
+
charOffset += runSliceCharCount;
|
|
73372
|
+
}
|
|
73373
|
+
}
|
|
73374
|
+
logSelectionMapDebug({
|
|
73375
|
+
blockId: block.id,
|
|
73376
|
+
lineFromRun: line.fromRun,
|
|
73377
|
+
lineToRun: line.toRun
|
|
73378
|
+
});
|
|
73379
|
+
return charOffset;
|
|
73380
|
+
}
|
|
72786
73381
|
const determineColumn = (layout, fragmentX) => {
|
|
72787
73382
|
const columns = layout.columns;
|
|
72788
73383
|
if (!columns || columns.count <= 1) return 0;
|
|
@@ -72827,8 +73422,8 @@ const mapPointToPm = (block, line, x2, isRTL) => {
|
|
|
72827
73422
|
if (isRTL) {
|
|
72828
73423
|
const charOffset = result.charOffset;
|
|
72829
73424
|
const charsInLine = Math.max(1, line.toChar - line.fromChar);
|
|
72830
|
-
const reversedOffset = charsInLine - charOffset;
|
|
72831
|
-
return range2.pmStart
|
|
73425
|
+
const reversedOffset = Math.max(0, Math.min(charsInLine, charsInLine - charOffset));
|
|
73426
|
+
return charOffsetToPm(block, line, reversedOffset, range2.pmStart);
|
|
72832
73427
|
}
|
|
72833
73428
|
return result.pmPosition;
|
|
72834
73429
|
};
|
|
@@ -75271,9 +75866,227 @@ const TRACK_CHANGE_STYLES = `
|
|
|
75271
75866
|
border-bottom: 2px solid gold;
|
|
75272
75867
|
}
|
|
75273
75868
|
`;
|
|
75869
|
+
const SDT_CONTAINER_STYLES = `
|
|
75870
|
+
/* Document Section - Block-level container with gray border and hover tooltip */
|
|
75871
|
+
.superdoc-document-section {
|
|
75872
|
+
background-color: #fafafa;
|
|
75873
|
+
border: 1px solid #ababab;
|
|
75874
|
+
border-radius: 4px;
|
|
75875
|
+
position: relative;
|
|
75876
|
+
box-sizing: border-box;
|
|
75877
|
+
}
|
|
75878
|
+
|
|
75879
|
+
/* Document section tooltip - positioned above the fragment */
|
|
75880
|
+
.superdoc-document-section__tooltip {
|
|
75881
|
+
position: absolute;
|
|
75882
|
+
top: -19px;
|
|
75883
|
+
left: -1px;
|
|
75884
|
+
max-width: 100px;
|
|
75885
|
+
min-width: 0;
|
|
75886
|
+
height: 18px;
|
|
75887
|
+
border: 1px solid #ababab;
|
|
75888
|
+
border-bottom: none;
|
|
75889
|
+
border-radius: 6px 6px 0 0;
|
|
75890
|
+
padding: 0 8px;
|
|
75891
|
+
align-items: center;
|
|
75892
|
+
font-size: 10px;
|
|
75893
|
+
display: none;
|
|
75894
|
+
z-index: 100;
|
|
75895
|
+
background-color: #fafafa;
|
|
75896
|
+
pointer-events: none;
|
|
75897
|
+
}
|
|
75898
|
+
|
|
75899
|
+
.superdoc-document-section__tooltip span {
|
|
75900
|
+
max-width: 100%;
|
|
75901
|
+
overflow: hidden;
|
|
75902
|
+
white-space: nowrap;
|
|
75903
|
+
text-overflow: ellipsis;
|
|
75904
|
+
}
|
|
75905
|
+
|
|
75906
|
+
/* Show tooltip on hover - adjust border radius to connect with tooltip tab */
|
|
75907
|
+
.superdoc-document-section:hover {
|
|
75908
|
+
border-radius: 0 4px 4px 4px;
|
|
75909
|
+
}
|
|
75910
|
+
|
|
75911
|
+
.superdoc-document-section:hover .superdoc-document-section__tooltip {
|
|
75912
|
+
display: flex;
|
|
75913
|
+
align-items: center;
|
|
75914
|
+
}
|
|
75915
|
+
|
|
75916
|
+
/* Continuation styling: first fragment has top corners, last has bottom corners */
|
|
75917
|
+
.superdoc-document-section[data-sdt-container-start="true"] {
|
|
75918
|
+
border-radius: 4px 4px 0 0;
|
|
75919
|
+
}
|
|
75920
|
+
|
|
75921
|
+
.superdoc-document-section[data-sdt-container-end="true"] {
|
|
75922
|
+
border-radius: 0 0 4px 4px;
|
|
75923
|
+
}
|
|
75924
|
+
|
|
75925
|
+
.superdoc-document-section[data-sdt-container-start="true"][data-sdt-container-end="true"] {
|
|
75926
|
+
border-radius: 4px;
|
|
75927
|
+
}
|
|
75928
|
+
|
|
75929
|
+
.superdoc-document-section[data-sdt-container-start="true"]:hover {
|
|
75930
|
+
border-radius: 0 4px 0 0;
|
|
75931
|
+
}
|
|
75932
|
+
|
|
75933
|
+
/* Middle fragments have no border radius */
|
|
75934
|
+
.superdoc-document-section:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
|
|
75935
|
+
border-radius: 0;
|
|
75936
|
+
border-top: none;
|
|
75937
|
+
}
|
|
75938
|
+
|
|
75939
|
+
/* Structured Content Block - Blue border container */
|
|
75940
|
+
.superdoc-structured-content-block {
|
|
75941
|
+
padding: 1px;
|
|
75942
|
+
box-sizing: border-box;
|
|
75943
|
+
border-radius: 4px;
|
|
75944
|
+
border: 1px solid #629be7;
|
|
75945
|
+
position: relative;
|
|
75946
|
+
}
|
|
75947
|
+
|
|
75948
|
+
/* Structured content drag handle/label - positioned above */
|
|
75949
|
+
.superdoc-structured-content__label {
|
|
75950
|
+
font-size: 10px;
|
|
75951
|
+
align-items: center;
|
|
75952
|
+
justify-content: center;
|
|
75953
|
+
position: absolute;
|
|
75954
|
+
left: 2px;
|
|
75955
|
+
top: -19px;
|
|
75956
|
+
width: calc(100% - 4px);
|
|
75957
|
+
max-width: 110px;
|
|
75958
|
+
min-width: 0;
|
|
75959
|
+
height: 18px;
|
|
75960
|
+
padding: 0 4px;
|
|
75961
|
+
border: 1px solid #629be7;
|
|
75962
|
+
border-bottom: none;
|
|
75963
|
+
border-radius: 6px 6px 0 0;
|
|
75964
|
+
background-color: #629be7dd;
|
|
75965
|
+
box-sizing: border-box;
|
|
75966
|
+
z-index: 10;
|
|
75967
|
+
display: none;
|
|
75968
|
+
pointer-events: none;
|
|
75969
|
+
}
|
|
75970
|
+
|
|
75971
|
+
.superdoc-structured-content__label span {
|
|
75972
|
+
max-width: 100%;
|
|
75973
|
+
overflow: hidden;
|
|
75974
|
+
white-space: nowrap;
|
|
75975
|
+
text-overflow: ellipsis;
|
|
75976
|
+
}
|
|
75977
|
+
|
|
75978
|
+
.superdoc-structured-content-block:hover .superdoc-structured-content__label {
|
|
75979
|
+
display: inline-flex;
|
|
75980
|
+
}
|
|
75981
|
+
|
|
75982
|
+
/* Continuation styling for structured content blocks */
|
|
75983
|
+
.superdoc-structured-content-block[data-sdt-container-start="true"] {
|
|
75984
|
+
border-radius: 4px 4px 0 0;
|
|
75985
|
+
}
|
|
75986
|
+
|
|
75987
|
+
.superdoc-structured-content-block[data-sdt-container-end="true"] {
|
|
75988
|
+
border-radius: 0 0 4px 4px;
|
|
75989
|
+
}
|
|
75990
|
+
|
|
75991
|
+
.superdoc-structured-content-block[data-sdt-container-start="true"][data-sdt-container-end="true"] {
|
|
75992
|
+
border-radius: 4px;
|
|
75993
|
+
}
|
|
75994
|
+
|
|
75995
|
+
.superdoc-structured-content-block:not([data-sdt-container-start="true"]):not([data-sdt-container-end="true"]) {
|
|
75996
|
+
border-radius: 0;
|
|
75997
|
+
border-top: none;
|
|
75998
|
+
}
|
|
75999
|
+
|
|
76000
|
+
/* Structured Content Inline - Inline wrapper with blue border */
|
|
76001
|
+
.superdoc-structured-content-inline {
|
|
76002
|
+
padding: 1px;
|
|
76003
|
+
box-sizing: border-box;
|
|
76004
|
+
border-radius: 4px;
|
|
76005
|
+
border: 1px solid #629be7;
|
|
76006
|
+
position: relative;
|
|
76007
|
+
display: inline;
|
|
76008
|
+
}
|
|
76009
|
+
|
|
76010
|
+
/* Hover effect for inline structured content */
|
|
76011
|
+
.superdoc-structured-content-inline:hover {
|
|
76012
|
+
background-color: rgba(98, 155, 231, 0.15);
|
|
76013
|
+
border-color: #4a8ad9;
|
|
76014
|
+
}
|
|
76015
|
+
|
|
76016
|
+
/* Inline structured content label - shown on hover */
|
|
76017
|
+
.superdoc-structured-content-inline__label {
|
|
76018
|
+
position: absolute;
|
|
76019
|
+
bottom: calc(100% + 2px);
|
|
76020
|
+
left: 50%;
|
|
76021
|
+
transform: translateX(-50%);
|
|
76022
|
+
font-size: 10px;
|
|
76023
|
+
padding: 2px 6px;
|
|
76024
|
+
background-color: #629be7dd;
|
|
76025
|
+
color: white;
|
|
76026
|
+
border-radius: 4px;
|
|
76027
|
+
white-space: nowrap;
|
|
76028
|
+
z-index: 100;
|
|
76029
|
+
display: none;
|
|
76030
|
+
pointer-events: none;
|
|
76031
|
+
}
|
|
76032
|
+
|
|
76033
|
+
.superdoc-structured-content-inline:hover .superdoc-structured-content-inline__label {
|
|
76034
|
+
display: block;
|
|
76035
|
+
}
|
|
76036
|
+
|
|
76037
|
+
/* Print mode: hide visual styling for SDT containers */
|
|
76038
|
+
@media print {
|
|
76039
|
+
.superdoc-document-section,
|
|
76040
|
+
.superdoc-structured-content-block,
|
|
76041
|
+
.superdoc-structured-content-inline {
|
|
76042
|
+
background: none;
|
|
76043
|
+
border: none;
|
|
76044
|
+
padding: 0;
|
|
76045
|
+
}
|
|
76046
|
+
|
|
76047
|
+
.superdoc-document-section__tooltip,
|
|
76048
|
+
.superdoc-structured-content__label,
|
|
76049
|
+
.superdoc-structured-content-inline__label {
|
|
76050
|
+
display: none !important;
|
|
76051
|
+
}
|
|
76052
|
+
}
|
|
76053
|
+
`;
|
|
76054
|
+
const FIELD_ANNOTATION_STYLES = `
|
|
76055
|
+
/* Field annotation draggable styles */
|
|
76056
|
+
.superdoc-layout .annotation[data-draggable="true"] {
|
|
76057
|
+
cursor: grab;
|
|
76058
|
+
user-select: none;
|
|
76059
|
+
-webkit-user-select: none;
|
|
76060
|
+
}
|
|
76061
|
+
|
|
76062
|
+
.superdoc-layout .annotation[data-draggable="true"]:hover {
|
|
76063
|
+
opacity: 0.9;
|
|
76064
|
+
}
|
|
76065
|
+
|
|
76066
|
+
.superdoc-layout .annotation[data-draggable="true"]:active {
|
|
76067
|
+
cursor: grabbing;
|
|
76068
|
+
}
|
|
76069
|
+
|
|
76070
|
+
/* Drag over indicator for drop targets */
|
|
76071
|
+
.superdoc-layout.drag-over {
|
|
76072
|
+
outline: 2px dashed #b015b3;
|
|
76073
|
+
outline-offset: -2px;
|
|
76074
|
+
}
|
|
76075
|
+
|
|
76076
|
+
/* Drop zone indicator */
|
|
76077
|
+
.superdoc-layout .superdoc-drop-indicator {
|
|
76078
|
+
position: absolute;
|
|
76079
|
+
width: 2px;
|
|
76080
|
+
background-color: #b015b3;
|
|
76081
|
+
pointer-events: none;
|
|
76082
|
+
z-index: 1000;
|
|
76083
|
+
}
|
|
76084
|
+
`;
|
|
75274
76085
|
let printStylesInjected = false;
|
|
75275
76086
|
let linkStylesInjected = false;
|
|
75276
76087
|
let trackChangeStylesInjected = false;
|
|
76088
|
+
let sdtContainerStylesInjected = false;
|
|
76089
|
+
let fieldAnnotationStylesInjected = false;
|
|
75277
76090
|
const ensurePrintStyles = (doc2) => {
|
|
75278
76091
|
if (printStylesInjected || !doc2) return;
|
|
75279
76092
|
const styleEl = doc2.createElement("style");
|
|
@@ -75298,6 +76111,22 @@ const ensureTrackChangeStyles = (doc2) => {
|
|
|
75298
76111
|
doc2.head?.appendChild(styleEl);
|
|
75299
76112
|
trackChangeStylesInjected = true;
|
|
75300
76113
|
};
|
|
76114
|
+
const ensureSdtContainerStyles = (doc2) => {
|
|
76115
|
+
if (sdtContainerStylesInjected || !doc2) return;
|
|
76116
|
+
const styleEl = doc2.createElement("style");
|
|
76117
|
+
styleEl.setAttribute("data-superdoc-sdt-container-styles", "true");
|
|
76118
|
+
styleEl.textContent = SDT_CONTAINER_STYLES;
|
|
76119
|
+
doc2.head?.appendChild(styleEl);
|
|
76120
|
+
sdtContainerStylesInjected = true;
|
|
76121
|
+
};
|
|
76122
|
+
const ensureFieldAnnotationStyles = (doc2) => {
|
|
76123
|
+
if (fieldAnnotationStylesInjected || !doc2) return;
|
|
76124
|
+
const styleEl = doc2.createElement("style");
|
|
76125
|
+
styleEl.setAttribute("data-superdoc-field-annotation-styles", "true");
|
|
76126
|
+
styleEl.textContent = FIELD_ANNOTATION_STYLES;
|
|
76127
|
+
doc2.head?.appendChild(styleEl);
|
|
76128
|
+
fieldAnnotationStylesInjected = true;
|
|
76129
|
+
};
|
|
75301
76130
|
const ALLOWED_BORDER_STYLES = /* @__PURE__ */ new Set([
|
|
75302
76131
|
"none",
|
|
75303
76132
|
"single",
|
|
@@ -75627,6 +76456,50 @@ const renderTableRow = (deps) => {
|
|
|
75627
76456
|
container.appendChild(cellElement);
|
|
75628
76457
|
}
|
|
75629
76458
|
};
|
|
76459
|
+
function isStructuredContentMetadata(sdt) {
|
|
76460
|
+
return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "structuredContent";
|
|
76461
|
+
}
|
|
76462
|
+
function isDocumentSectionMetadata(sdt) {
|
|
76463
|
+
return sdt !== null && sdt !== void 0 && typeof sdt === "object" && "type" in sdt && sdt.type === "documentSection";
|
|
76464
|
+
}
|
|
76465
|
+
function getSdtContainerConfig(sdt) {
|
|
76466
|
+
if (isDocumentSectionMetadata(sdt)) {
|
|
76467
|
+
return {
|
|
76468
|
+
className: "superdoc-document-section",
|
|
76469
|
+
labelText: sdt.title ?? "Document section",
|
|
76470
|
+
labelClassName: "superdoc-document-section__tooltip",
|
|
76471
|
+
isStart: true,
|
|
76472
|
+
isEnd: true
|
|
76473
|
+
};
|
|
76474
|
+
}
|
|
76475
|
+
if (isStructuredContentMetadata(sdt) && sdt.scope === "block") {
|
|
76476
|
+
return {
|
|
76477
|
+
className: "superdoc-structured-content-block",
|
|
76478
|
+
labelText: sdt.alias ?? "Structured content",
|
|
76479
|
+
labelClassName: "superdoc-structured-content__label",
|
|
76480
|
+
isStart: true,
|
|
76481
|
+
isEnd: true
|
|
76482
|
+
};
|
|
76483
|
+
}
|
|
76484
|
+
return null;
|
|
76485
|
+
}
|
|
76486
|
+
function applySdtContainerStyling(doc2, container, sdt, containerSdt) {
|
|
76487
|
+
let config2 = getSdtContainerConfig(sdt);
|
|
76488
|
+
if (!config2 && containerSdt) {
|
|
76489
|
+
config2 = getSdtContainerConfig(containerSdt);
|
|
76490
|
+
}
|
|
76491
|
+
if (!config2) return;
|
|
76492
|
+
container.classList.add(config2.className);
|
|
76493
|
+
container.dataset.sdtContainerStart = String(config2.isStart);
|
|
76494
|
+
container.dataset.sdtContainerEnd = String(config2.isEnd);
|
|
76495
|
+
container.style.overflow = "visible";
|
|
76496
|
+
const labelEl = doc2.createElement("div");
|
|
76497
|
+
labelEl.className = config2.labelClassName;
|
|
76498
|
+
const labelText = doc2.createElement("span");
|
|
76499
|
+
labelText.textContent = config2.labelText;
|
|
76500
|
+
labelEl.appendChild(labelText);
|
|
76501
|
+
container.appendChild(labelEl);
|
|
76502
|
+
}
|
|
75630
76503
|
const renderTableFragment = (deps) => {
|
|
75631
76504
|
const { doc: doc2, fragment, blockLookup, context, renderLine, applyFragmentFrame, applySdtDataset, applyStyles: applyStyles2 } = deps;
|
|
75632
76505
|
if (!doc2) {
|
|
@@ -75663,6 +76536,7 @@ const renderTableFragment = (deps) => {
|
|
|
75663
76536
|
applyFragmentFrame(container, fragment);
|
|
75664
76537
|
container.style.height = `${fragment.height}px`;
|
|
75665
76538
|
applySdtDataset(container, block.attrs?.sdt);
|
|
76539
|
+
applySdtContainerStyling(doc2, container, block.attrs?.sdt);
|
|
75666
76540
|
container.classList.add("superdoc-table-fragment");
|
|
75667
76541
|
if (fragment.metadata?.columnBoundaries) {
|
|
75668
76542
|
const columnCount = measure.columnWidths.length;
|
|
@@ -76129,6 +77003,8 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76129
77003
|
ensurePrintStyles(doc2);
|
|
76130
77004
|
ensureLinkStyles(doc2);
|
|
76131
77005
|
ensureTrackChangeStyles(doc2);
|
|
77006
|
+
ensureFieldAnnotationStyles(doc2);
|
|
77007
|
+
ensureSdtContainerStyles(doc2);
|
|
76132
77008
|
mount2.classList.add(CLASS_NAMES.container);
|
|
76133
77009
|
if (this.mount && this.mount !== mount2) {
|
|
76134
77010
|
this.resetState();
|
|
@@ -76651,7 +77527,8 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76651
77527
|
fragmentEl.classList.add(CLASS_NAMES.fragment);
|
|
76652
77528
|
const isTocEntry = block.attrs?.isTocEntry;
|
|
76653
77529
|
const hasMarker = !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
76654
|
-
const
|
|
77530
|
+
const hasSdtContainer = block.attrs?.sdt?.type === "documentSection" || block.attrs?.sdt?.type === "structuredContent" || block.attrs?.containerSdt?.type === "documentSection" || block.attrs?.containerSdt?.type === "structuredContent";
|
|
77531
|
+
const styles = isTocEntry ? { ...fragmentStyles, whiteSpace: "nowrap" } : hasMarker || hasSdtContainer ? { ...fragmentStyles, overflow: "visible" } : fragmentStyles;
|
|
76655
77532
|
applyStyles$2(fragmentEl, styles);
|
|
76656
77533
|
this.applyFragmentFrame(fragmentEl, fragment, context.section);
|
|
76657
77534
|
if (isTocEntry) {
|
|
@@ -76671,6 +77548,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76671
77548
|
}
|
|
76672
77549
|
this.applySdtDataset(fragmentEl, block.attrs?.sdt);
|
|
76673
77550
|
this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
|
|
77551
|
+
applySdtContainerStyling(this.doc, fragmentEl, block.attrs?.sdt, block.attrs?.containerSdt);
|
|
76674
77552
|
const dropCapDescriptor = block.attrs?.dropCapDescriptor;
|
|
76675
77553
|
const dropCapMeasure = measure.dropCap;
|
|
76676
77554
|
if (dropCapDescriptor && dropCapMeasure && !fragment.continuesFromPrev) {
|
|
@@ -76685,8 +77563,22 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76685
77563
|
const paraIndentRight = paraIndent?.right ?? 0;
|
|
76686
77564
|
const suppressFirstLineIndent = block.attrs?.suppressFirstLineIndent === true;
|
|
76687
77565
|
const firstLineOffset = suppressFirstLineIndent ? 0 : (paraIndent?.firstLine ?? 0) - (paraIndent?.hanging ?? 0);
|
|
77566
|
+
const isListParagraph = !!(fragment.markerWidth && wordLayout?.marker);
|
|
77567
|
+
const lastRun = block.runs.length > 0 ? block.runs[block.runs.length - 1] : null;
|
|
77568
|
+
const paragraphEndsWithLineBreak = lastRun?.kind === "lineBreak";
|
|
76688
77569
|
lines.forEach((line, index2) => {
|
|
76689
|
-
const
|
|
77570
|
+
const availableWidthOverride = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
|
|
77571
|
+
const isLastLineOfFragment = index2 === lines.length - 1;
|
|
77572
|
+
const isLastLineOfParagraph = isLastLineOfFragment && !fragment.continuesOnNext;
|
|
77573
|
+
const shouldSkipJustifyForLastLine = isLastLineOfParagraph && !paragraphEndsWithLineBreak;
|
|
77574
|
+
const lineEl = this.renderLine(
|
|
77575
|
+
block,
|
|
77576
|
+
line,
|
|
77577
|
+
context,
|
|
77578
|
+
availableWidthOverride,
|
|
77579
|
+
fragment.fromLine + index2,
|
|
77580
|
+
isListParagraph || shouldSkipJustifyForLastLine
|
|
77581
|
+
);
|
|
76690
77582
|
const isListFirstLine = index2 === 0 && !fragment.continuesFromPrev && fragment.markerWidth && wordLayout?.marker;
|
|
76691
77583
|
const hasExplicitSegmentPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
76692
77584
|
const isFirstLine = index2 === 0 && !fragment.continuesFromPrev;
|
|
@@ -76875,6 +77767,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76875
77767
|
fragmentEl.dataset.itemId = fragment.itemId;
|
|
76876
77768
|
const paragraphMetadata = item.paragraph.attrs?.sdt;
|
|
76877
77769
|
this.applySdtDataset(fragmentEl, paragraphMetadata);
|
|
77770
|
+
applySdtContainerStyling(this.doc, fragmentEl, paragraphMetadata, item.paragraph.attrs?.containerSdt);
|
|
76878
77771
|
if (fragment.continuesFromPrev) {
|
|
76879
77772
|
fragmentEl.dataset.continuesFromPrev = "true";
|
|
76880
77773
|
}
|
|
@@ -76915,8 +77808,13 @@ const _DomPainter = class _DomPainter2 {
|
|
|
76915
77808
|
const lines = itemMeasure.paragraph.lines.slice(fragment.fromLine, fragment.toLine);
|
|
76916
77809
|
const contentAttrs = wordLayout ? item.paragraph.attrs : stripListIndent(item.paragraph.attrs);
|
|
76917
77810
|
applyParagraphBlockStyles(contentEl, contentAttrs);
|
|
76918
|
-
|
|
76919
|
-
|
|
77811
|
+
contentEl.style.textAlign = "left";
|
|
77812
|
+
const paraForList = {
|
|
77813
|
+
...item.paragraph,
|
|
77814
|
+
attrs: { ...item.paragraph.attrs || {}, alignment: "left" }
|
|
77815
|
+
};
|
|
77816
|
+
lines.forEach((line, idx) => {
|
|
77817
|
+
const lineEl = this.renderLine(paraForList, line, context, fragment.width, fragment.fromLine + idx, true);
|
|
76920
77818
|
contentEl.appendChild(lineEl);
|
|
76921
77819
|
});
|
|
76922
77820
|
fragmentEl.appendChild(contentEl);
|
|
@@ -77438,12 +78336,15 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77438
78336
|
const applyFragmentFrameWithSection = (el, frag) => {
|
|
77439
78337
|
this.applyFragmentFrame(el, frag, context.section);
|
|
77440
78338
|
};
|
|
78339
|
+
const renderLineForTableCell = (block, line, ctx2) => {
|
|
78340
|
+
return this.renderLine(block, line, ctx2, void 0, void 0, true);
|
|
78341
|
+
};
|
|
77441
78342
|
return renderTableFragment({
|
|
77442
78343
|
doc: this.doc,
|
|
77443
78344
|
fragment,
|
|
77444
78345
|
context,
|
|
77445
78346
|
blockLookup: this.blockLookup,
|
|
77446
|
-
renderLine:
|
|
78347
|
+
renderLine: renderLineForTableCell,
|
|
77447
78348
|
applyFragmentFrame: applyFragmentFrameWithSection,
|
|
77448
78349
|
applySdtDataset: this.applySdtDataset.bind(this),
|
|
77449
78350
|
applyStyles: applyStyles$2
|
|
@@ -77638,10 +78539,19 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77638
78539
|
isBreakRun(run2) {
|
|
77639
78540
|
return run2.kind === "break";
|
|
77640
78541
|
}
|
|
78542
|
+
/**
|
|
78543
|
+
* Type guard to check if a run is a field annotation run.
|
|
78544
|
+
*/
|
|
78545
|
+
isFieldAnnotationRun(run2) {
|
|
78546
|
+
return run2.kind === "fieldAnnotation";
|
|
78547
|
+
}
|
|
77641
78548
|
renderRun(run2, context, trackedConfig) {
|
|
77642
78549
|
if (this.isImageRun(run2)) {
|
|
77643
78550
|
return this.renderImageRun(run2);
|
|
77644
78551
|
}
|
|
78552
|
+
if (this.isFieldAnnotationRun(run2)) {
|
|
78553
|
+
return this.renderFieldAnnotationRun(run2);
|
|
78554
|
+
}
|
|
77645
78555
|
if (this.isLineBreakRun(run2)) {
|
|
77646
78556
|
return null;
|
|
77647
78557
|
}
|
|
@@ -77778,7 +78688,212 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77778
78688
|
}
|
|
77779
78689
|
return img;
|
|
77780
78690
|
}
|
|
77781
|
-
|
|
78691
|
+
/**
|
|
78692
|
+
* Renders a FieldAnnotationRun as an inline "pill" element matching super-editor's visual appearance.
|
|
78693
|
+
*
|
|
78694
|
+
* Field annotations are styled inline elements that display form fields with:
|
|
78695
|
+
* - Outer span with border, border-radius, padding, and background color
|
|
78696
|
+
* - Inner span containing the displayLabel or type-specific content (image, link, etc.)
|
|
78697
|
+
*
|
|
78698
|
+
* @param run - The FieldAnnotationRun to render containing field configuration and styling
|
|
78699
|
+
* @returns HTMLElement (span) or null if document is not available
|
|
78700
|
+
*
|
|
78701
|
+
* @example
|
|
78702
|
+
* ```typescript
|
|
78703
|
+
* // Text variant
|
|
78704
|
+
* renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'text', displayLabel: 'Full Name', fieldColor: '#980043' })
|
|
78705
|
+
* // Returns: <span class="annotation" style="border: 2px solid #b015b3; ..."><span class="annotation-content">Full Name</span></span>
|
|
78706
|
+
*
|
|
78707
|
+
* // Image variant with imageSrc
|
|
78708
|
+
* renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'image', displayLabel: 'Photo', imageSrc: 'data:image/png;...' })
|
|
78709
|
+
* // Returns: <span class="annotation"><span class="annotation-content"><img src="..." /></span></span>
|
|
78710
|
+
*
|
|
78711
|
+
* // Link variant
|
|
78712
|
+
* renderFieldAnnotationRun({ kind: 'fieldAnnotation', variant: 'link', displayLabel: 'Website', linkUrl: 'https://example.com' })
|
|
78713
|
+
* // Returns: <span class="annotation"><span class="annotation-content"><a href="...">https://example.com</a></span></span>
|
|
78714
|
+
* ```
|
|
78715
|
+
*/
|
|
78716
|
+
renderFieldAnnotationRun(run2) {
|
|
78717
|
+
if (!this.doc) {
|
|
78718
|
+
return null;
|
|
78719
|
+
}
|
|
78720
|
+
if (run2.hidden) {
|
|
78721
|
+
const hidden = this.doc.createElement("span");
|
|
78722
|
+
hidden.style.display = "none";
|
|
78723
|
+
if (run2.pmStart != null) hidden.dataset.pmStart = String(run2.pmStart);
|
|
78724
|
+
if (run2.pmEnd != null) hidden.dataset.pmEnd = String(run2.pmEnd);
|
|
78725
|
+
return hidden;
|
|
78726
|
+
}
|
|
78727
|
+
const defaultBorderColor = "#b015b3";
|
|
78728
|
+
const defaultFieldColor = "#980043";
|
|
78729
|
+
const annotation = this.doc.createElement("span");
|
|
78730
|
+
annotation.classList.add("annotation");
|
|
78731
|
+
annotation.setAttribute("aria-label", "Field annotation");
|
|
78732
|
+
const showHighlight = run2.highlighted !== false;
|
|
78733
|
+
if (showHighlight) {
|
|
78734
|
+
const borderColor = run2.borderColor || defaultBorderColor;
|
|
78735
|
+
annotation.style.border = `2px solid ${borderColor}`;
|
|
78736
|
+
annotation.style.borderRadius = "2px";
|
|
78737
|
+
annotation.style.padding = "1px 2px";
|
|
78738
|
+
annotation.style.boxSizing = "border-box";
|
|
78739
|
+
const fieldColor = run2.fieldColor || defaultFieldColor;
|
|
78740
|
+
const bgColor = fieldColor.length === 7 ? `${fieldColor}33` : fieldColor;
|
|
78741
|
+
if (run2.textHighlight) {
|
|
78742
|
+
annotation.style.backgroundColor = run2.textHighlight;
|
|
78743
|
+
} else {
|
|
78744
|
+
annotation.style.backgroundColor = bgColor;
|
|
78745
|
+
}
|
|
78746
|
+
}
|
|
78747
|
+
if (run2.visibility === "hidden") {
|
|
78748
|
+
annotation.style.visibility = "hidden";
|
|
78749
|
+
}
|
|
78750
|
+
if (run2.size) {
|
|
78751
|
+
if (run2.size.width) {
|
|
78752
|
+
annotation.style.width = `${run2.size.width}px`;
|
|
78753
|
+
annotation.style.display = "inline-block";
|
|
78754
|
+
annotation.style.overflow = "hidden";
|
|
78755
|
+
}
|
|
78756
|
+
if (run2.size.height) {
|
|
78757
|
+
annotation.style.height = `${run2.size.height}px`;
|
|
78758
|
+
}
|
|
78759
|
+
}
|
|
78760
|
+
if (run2.fontFamily) {
|
|
78761
|
+
annotation.style.fontFamily = run2.fontFamily;
|
|
78762
|
+
}
|
|
78763
|
+
if (run2.fontSize) {
|
|
78764
|
+
const fontSize2 = typeof run2.fontSize === "number" ? `${run2.fontSize}pt` : run2.fontSize;
|
|
78765
|
+
annotation.style.fontSize = fontSize2;
|
|
78766
|
+
}
|
|
78767
|
+
if (run2.textColor) {
|
|
78768
|
+
annotation.style.color = run2.textColor;
|
|
78769
|
+
}
|
|
78770
|
+
if (run2.bold) {
|
|
78771
|
+
annotation.style.fontWeight = "bold";
|
|
78772
|
+
}
|
|
78773
|
+
if (run2.italic) {
|
|
78774
|
+
annotation.style.fontStyle = "italic";
|
|
78775
|
+
}
|
|
78776
|
+
if (run2.underline) {
|
|
78777
|
+
annotation.style.textDecoration = "underline";
|
|
78778
|
+
}
|
|
78779
|
+
annotation.style.zIndex = "1";
|
|
78780
|
+
const content = this.doc.createElement("span");
|
|
78781
|
+
content.classList.add("annotation-content");
|
|
78782
|
+
content.style.pointerEvents = "none";
|
|
78783
|
+
content.setAttribute("contenteditable", "false");
|
|
78784
|
+
switch (run2.variant) {
|
|
78785
|
+
case "image":
|
|
78786
|
+
case "signature": {
|
|
78787
|
+
if (run2.imageSrc) {
|
|
78788
|
+
const img = this.doc.createElement("img");
|
|
78789
|
+
const isDataUrl = run2.imageSrc.startsWith("data:");
|
|
78790
|
+
if (isDataUrl) {
|
|
78791
|
+
if (run2.imageSrc.length <= MAX_DATA_URL_LENGTH && VALID_IMAGE_DATA_URL.test(run2.imageSrc)) {
|
|
78792
|
+
img.src = run2.imageSrc;
|
|
78793
|
+
} else {
|
|
78794
|
+
content.textContent = run2.displayLabel;
|
|
78795
|
+
break;
|
|
78796
|
+
}
|
|
78797
|
+
} else {
|
|
78798
|
+
const sanitized = sanitizeHref(run2.imageSrc);
|
|
78799
|
+
if (sanitized) {
|
|
78800
|
+
img.src = sanitized.href;
|
|
78801
|
+
} else {
|
|
78802
|
+
content.textContent = run2.displayLabel;
|
|
78803
|
+
break;
|
|
78804
|
+
}
|
|
78805
|
+
}
|
|
78806
|
+
img.alt = run2.displayLabel;
|
|
78807
|
+
img.style.height = "auto";
|
|
78808
|
+
img.style.maxWidth = "100%";
|
|
78809
|
+
img.style.pointerEvents = "none";
|
|
78810
|
+
img.style.verticalAlign = "middle";
|
|
78811
|
+
if (run2.variant === "signature") {
|
|
78812
|
+
img.style.maxHeight = "28px";
|
|
78813
|
+
}
|
|
78814
|
+
content.appendChild(img);
|
|
78815
|
+
annotation.style.display = "inline-block";
|
|
78816
|
+
content.style.display = "inline-block";
|
|
78817
|
+
} else {
|
|
78818
|
+
content.textContent = run2.displayLabel || (run2.variant === "signature" ? "Signature" : "");
|
|
78819
|
+
}
|
|
78820
|
+
break;
|
|
78821
|
+
}
|
|
78822
|
+
case "link": {
|
|
78823
|
+
if (run2.linkUrl) {
|
|
78824
|
+
const link = this.doc.createElement("a");
|
|
78825
|
+
const sanitized = sanitizeHref(run2.linkUrl);
|
|
78826
|
+
if (sanitized) {
|
|
78827
|
+
link.href = sanitized.href;
|
|
78828
|
+
link.target = "_blank";
|
|
78829
|
+
link.rel = "noopener noreferrer";
|
|
78830
|
+
link.textContent = run2.linkUrl;
|
|
78831
|
+
link.style.textDecoration = "none";
|
|
78832
|
+
content.style.pointerEvents = "all";
|
|
78833
|
+
content.appendChild(link);
|
|
78834
|
+
} else {
|
|
78835
|
+
content.textContent = run2.displayLabel;
|
|
78836
|
+
}
|
|
78837
|
+
} else {
|
|
78838
|
+
content.textContent = run2.displayLabel;
|
|
78839
|
+
}
|
|
78840
|
+
break;
|
|
78841
|
+
}
|
|
78842
|
+
case "html": {
|
|
78843
|
+
if (run2.rawHtml && typeof run2.rawHtml === "string") {
|
|
78844
|
+
content.textContent = run2.displayLabel;
|
|
78845
|
+
annotation.style.display = "inline-block";
|
|
78846
|
+
content.style.display = "inline-block";
|
|
78847
|
+
} else {
|
|
78848
|
+
content.textContent = run2.displayLabel;
|
|
78849
|
+
}
|
|
78850
|
+
break;
|
|
78851
|
+
}
|
|
78852
|
+
case "text":
|
|
78853
|
+
case "checkbox":
|
|
78854
|
+
default: {
|
|
78855
|
+
content.textContent = run2.displayLabel;
|
|
78856
|
+
break;
|
|
78857
|
+
}
|
|
78858
|
+
}
|
|
78859
|
+
annotation.appendChild(content);
|
|
78860
|
+
annotation.dataset.type = run2.variant;
|
|
78861
|
+
if (run2.fieldId) {
|
|
78862
|
+
annotation.dataset.fieldId = run2.fieldId;
|
|
78863
|
+
}
|
|
78864
|
+
if (run2.fieldType) {
|
|
78865
|
+
annotation.dataset.fieldType = run2.fieldType;
|
|
78866
|
+
}
|
|
78867
|
+
annotation.draggable = true;
|
|
78868
|
+
annotation.dataset.draggable = "true";
|
|
78869
|
+
if (run2.displayLabel) {
|
|
78870
|
+
annotation.dataset.displayLabel = run2.displayLabel;
|
|
78871
|
+
}
|
|
78872
|
+
if (run2.variant) {
|
|
78873
|
+
annotation.dataset.variant = run2.variant;
|
|
78874
|
+
}
|
|
78875
|
+
assertPmPositions(run2, "field annotation run");
|
|
78876
|
+
if (run2.pmStart != null) {
|
|
78877
|
+
annotation.dataset.pmStart = String(run2.pmStart);
|
|
78878
|
+
}
|
|
78879
|
+
if (run2.pmEnd != null) {
|
|
78880
|
+
annotation.dataset.pmEnd = String(run2.pmEnd);
|
|
78881
|
+
}
|
|
78882
|
+
this.applySdtDataset(annotation, run2.sdt);
|
|
78883
|
+
return annotation;
|
|
78884
|
+
}
|
|
78885
|
+
/**
|
|
78886
|
+
* Renders a single line of a paragraph block.
|
|
78887
|
+
*
|
|
78888
|
+
* @param block - The paragraph block containing the line
|
|
78889
|
+
* @param line - The line measurement data
|
|
78890
|
+
* @param context - Rendering context with fragment information
|
|
78891
|
+
* @param availableWidthOverride - Optional override for available width used in justification calculations
|
|
78892
|
+
* @param lineIndex - Optional zero-based index of the line within the fragment
|
|
78893
|
+
* @param skipJustify - When true, prevents justification even if alignment is 'justify'
|
|
78894
|
+
* @returns The rendered line element
|
|
78895
|
+
*/
|
|
78896
|
+
renderLine(block, line, context, availableWidthOverride, lineIndex, skipJustify) {
|
|
77782
78897
|
if (!this.doc) {
|
|
77783
78898
|
throw new Error("DomPainter: document is not available");
|
|
77784
78899
|
}
|
|
@@ -77790,8 +78905,10 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77790
78905
|
el.setAttribute("styleid", styleId);
|
|
77791
78906
|
}
|
|
77792
78907
|
const alignment2 = block.attrs?.alignment;
|
|
77793
|
-
if (alignment2 === "center" || alignment2 === "right"
|
|
77794
|
-
el.style.textAlign = alignment2
|
|
78908
|
+
if (alignment2 === "center" || alignment2 === "right") {
|
|
78909
|
+
el.style.textAlign = alignment2;
|
|
78910
|
+
} else if (alignment2 === "justify") {
|
|
78911
|
+
el.style.textAlign = "left";
|
|
77795
78912
|
} else {
|
|
77796
78913
|
el.style.textAlign = "left";
|
|
77797
78914
|
}
|
|
@@ -77804,6 +78921,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77804
78921
|
}
|
|
77805
78922
|
const runsForLine = sliceRunsForLine(block, line);
|
|
77806
78923
|
const trackedConfig = this.resolveTrackedChangesConfig(block);
|
|
78924
|
+
const textSlices = runsForLine.length > 0 ? runsForLine.filter((r2) => (r2.kind === "text" || r2.kind === void 0) && "text" in r2 && r2.text != null).map((r2) => r2.text) : gatherTextSlicesForLine(block, line);
|
|
77807
78925
|
if (runsForLine.length === 0) {
|
|
77808
78926
|
const span = this.doc.createElement("span");
|
|
77809
78927
|
span.innerHTML = " ";
|
|
@@ -77850,6 +78968,19 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77850
78968
|
});
|
|
77851
78969
|
}
|
|
77852
78970
|
const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
78971
|
+
const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
|
|
78972
|
+
const shouldJustify = !skipJustify && alignment2 === "justify" && !hasExplicitPositioning;
|
|
78973
|
+
if (shouldJustify) {
|
|
78974
|
+
const spaceCount = textSlices.reduce(
|
|
78975
|
+
(sum, s2) => sum + Array.from(s2).filter((ch) => ch === " " || ch === " ").length,
|
|
78976
|
+
0
|
|
78977
|
+
);
|
|
78978
|
+
const slack = Math.max(0, availableWidth - line.width);
|
|
78979
|
+
if (spaceCount > 0 && slack > 0) {
|
|
78980
|
+
const extraPerSpace = slack / spaceCount;
|
|
78981
|
+
el.style.wordSpacing = `${extraPerSpace}px`;
|
|
78982
|
+
}
|
|
78983
|
+
}
|
|
77853
78984
|
if (hasExplicitPositioning && line.segments) {
|
|
77854
78985
|
let cumulativeX = 0;
|
|
77855
78986
|
const segmentsByRun = /* @__PURE__ */ new Map();
|
|
@@ -77928,6 +79059,22 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77928
79059
|
if (this.isBreakRun(baseRun)) {
|
|
77929
79060
|
continue;
|
|
77930
79061
|
}
|
|
79062
|
+
if (this.isFieldAnnotationRun(baseRun)) {
|
|
79063
|
+
const elem = this.renderRun(baseRun, context, trackedConfig);
|
|
79064
|
+
if (elem) {
|
|
79065
|
+
if (styleId) {
|
|
79066
|
+
elem.setAttribute("styleid", styleId);
|
|
79067
|
+
}
|
|
79068
|
+
const runSegments2 = segmentsByRun.get(runIndex);
|
|
79069
|
+
const segX = runSegments2 && runSegments2[0]?.x !== void 0 ? runSegments2[0].x : cumulativeX;
|
|
79070
|
+
const segWidth = (runSegments2 && runSegments2[0]?.width !== void 0 ? runSegments2[0].width : 0) ?? 0;
|
|
79071
|
+
elem.style.position = "absolute";
|
|
79072
|
+
elem.style.left = `${segX}px`;
|
|
79073
|
+
el.appendChild(elem);
|
|
79074
|
+
cumulativeX = segX + segWidth;
|
|
79075
|
+
}
|
|
79076
|
+
continue;
|
|
79077
|
+
}
|
|
77931
79078
|
const runSegments = segmentsByRun.get(runIndex);
|
|
77932
79079
|
if (!runSegments || runSegments.length === 0) {
|
|
77933
79080
|
continue;
|
|
@@ -77973,7 +79120,22 @@ const _DomPainter = class _DomPainter2 {
|
|
|
77973
79120
|
});
|
|
77974
79121
|
}
|
|
77975
79122
|
} else {
|
|
79123
|
+
let currentInlineSdtWrapper = null;
|
|
79124
|
+
let currentInlineSdtId = null;
|
|
79125
|
+
const closeCurrentWrapper = () => {
|
|
79126
|
+
if (currentInlineSdtWrapper) {
|
|
79127
|
+
el.appendChild(currentInlineSdtWrapper);
|
|
79128
|
+
currentInlineSdtWrapper = null;
|
|
79129
|
+
currentInlineSdtId = null;
|
|
79130
|
+
}
|
|
79131
|
+
};
|
|
77976
79132
|
runsForLine.forEach((run2) => {
|
|
79133
|
+
const runSdt = run2.sdt;
|
|
79134
|
+
const isInlineSdt = runSdt?.type === "structuredContent" && runSdt?.scope === "inline";
|
|
79135
|
+
const runSdtId = isInlineSdt && runSdt?.id ? String(runSdt.id) : null;
|
|
79136
|
+
if (runSdtId !== currentInlineSdtId) {
|
|
79137
|
+
closeCurrentWrapper();
|
|
79138
|
+
}
|
|
77977
79139
|
if (run2.kind === "tab") {
|
|
77978
79140
|
const tabEl = this.doc.createElement("span");
|
|
77979
79141
|
tabEl.classList.add("superdoc-tab");
|
|
@@ -78001,9 +79163,37 @@ const _DomPainter = class _DomPainter2 {
|
|
|
78001
79163
|
if (styleId) {
|
|
78002
79164
|
elem.setAttribute("styleid", styleId);
|
|
78003
79165
|
}
|
|
78004
|
-
|
|
79166
|
+
if (isInlineSdt && runSdtId && this.doc) {
|
|
79167
|
+
if (!currentInlineSdtWrapper) {
|
|
79168
|
+
currentInlineSdtWrapper = this.doc.createElement("span");
|
|
79169
|
+
currentInlineSdtWrapper.className = "superdoc-structured-content-inline";
|
|
79170
|
+
currentInlineSdtId = runSdtId;
|
|
79171
|
+
this.applySdtDataset(currentInlineSdtWrapper, runSdt);
|
|
79172
|
+
const alias = runSdt?.alias || "Inline content";
|
|
79173
|
+
const labelEl = this.doc.createElement("span");
|
|
79174
|
+
labelEl.className = "superdoc-structured-content-inline__label";
|
|
79175
|
+
labelEl.textContent = alias;
|
|
79176
|
+
currentInlineSdtWrapper.appendChild(labelEl);
|
|
79177
|
+
}
|
|
79178
|
+
const wrapperPmStart = currentInlineSdtWrapper.dataset.pmStart;
|
|
79179
|
+
const wrapperPmEnd = currentInlineSdtWrapper.dataset.pmEnd;
|
|
79180
|
+
if (run2.pmStart != null) {
|
|
79181
|
+
if (!wrapperPmStart || run2.pmStart < parseInt(wrapperPmStart, 10)) {
|
|
79182
|
+
currentInlineSdtWrapper.dataset.pmStart = String(run2.pmStart);
|
|
79183
|
+
}
|
|
79184
|
+
}
|
|
79185
|
+
if (run2.pmEnd != null) {
|
|
79186
|
+
if (!wrapperPmEnd || run2.pmEnd > parseInt(wrapperPmEnd, 10)) {
|
|
79187
|
+
currentInlineSdtWrapper.dataset.pmEnd = String(run2.pmEnd);
|
|
79188
|
+
}
|
|
79189
|
+
}
|
|
79190
|
+
currentInlineSdtWrapper.appendChild(elem);
|
|
79191
|
+
} else {
|
|
79192
|
+
el.appendChild(elem);
|
|
79193
|
+
}
|
|
78005
79194
|
}
|
|
78006
79195
|
});
|
|
79196
|
+
closeCurrentWrapper();
|
|
78007
79197
|
}
|
|
78008
79198
|
const anchors = el.querySelectorAll("a[href]");
|
|
78009
79199
|
anchors.forEach((anchor) => {
|
|
@@ -78511,7 +79701,7 @@ const deriveBlockVersion = (block) => {
|
|
|
78511
79701
|
return block.id;
|
|
78512
79702
|
};
|
|
78513
79703
|
const applyRunStyles = (element, run2, _isLink = false) => {
|
|
78514
|
-
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break") {
|
|
79704
|
+
if (run2.kind === "tab" || run2.kind === "image" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
|
|
78515
79705
|
return;
|
|
78516
79706
|
}
|
|
78517
79707
|
element.style.fontFamily = run2.fontFamily;
|
|
@@ -78633,6 +79823,23 @@ const applyParagraphShadingStyles = (element, shading) => {
|
|
|
78633
79823
|
if (!shading?.fill) return;
|
|
78634
79824
|
element.style.backgroundColor = shading.fill;
|
|
78635
79825
|
};
|
|
79826
|
+
const gatherTextSlicesForLine = (block, line) => {
|
|
79827
|
+
const slices = [];
|
|
79828
|
+
const startRun = line.fromRun ?? 0;
|
|
79829
|
+
const endRun = line.toRun ?? startRun;
|
|
79830
|
+
for (let runIndex = startRun; runIndex <= endRun; runIndex += 1) {
|
|
79831
|
+
const run2 = block.runs[runIndex];
|
|
79832
|
+
if (!run2 || run2.kind !== "text" && run2.kind !== void 0 || !("text" in run2) || !run2.text) continue;
|
|
79833
|
+
const isFirst = runIndex === startRun;
|
|
79834
|
+
const isLast = runIndex === endRun;
|
|
79835
|
+
const start2 = isFirst ? line.fromChar ?? 0 : 0;
|
|
79836
|
+
const end2 = isLast ? line.toChar ?? run2.text.length : run2.text.length;
|
|
79837
|
+
if (start2 >= end2) continue;
|
|
79838
|
+
const slice2 = run2.text.slice(start2, end2);
|
|
79839
|
+
if (slice2) slices.push(slice2);
|
|
79840
|
+
}
|
|
79841
|
+
return slices;
|
|
79842
|
+
};
|
|
78636
79843
|
const sliceRunsForLine = (block, line) => {
|
|
78637
79844
|
const result = [];
|
|
78638
79845
|
for (let runIndex = line.fromRun; runIndex <= line.toRun; runIndex += 1) {
|
|
@@ -78654,6 +79861,10 @@ const sliceRunsForLine = (block, line) => {
|
|
|
78654
79861
|
result.push(run2);
|
|
78655
79862
|
continue;
|
|
78656
79863
|
}
|
|
79864
|
+
if (run2.kind === "fieldAnnotation") {
|
|
79865
|
+
result.push(run2);
|
|
79866
|
+
continue;
|
|
79867
|
+
}
|
|
78657
79868
|
if (!("text" in run2)) {
|
|
78658
79869
|
continue;
|
|
78659
79870
|
}
|
|
@@ -78969,6 +80180,10 @@ const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
|
|
|
78969
80180
|
const TAB_EPSILON = 0.1;
|
|
78970
80181
|
const DEFAULT_DECIMAL_SEPARATOR = ".";
|
|
78971
80182
|
const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
|
|
80183
|
+
const FIELD_ANNOTATION_PILL_PADDING = 8;
|
|
80184
|
+
const FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER = 1.2;
|
|
80185
|
+
const FIELD_ANNOTATION_VERTICAL_PADDING = 6;
|
|
80186
|
+
const DEFAULT_FIELD_ANNOTATION_FONT_SIZE = 16;
|
|
78972
80187
|
const roundValue = (value) => value;
|
|
78973
80188
|
function getCanvasContext() {
|
|
78974
80189
|
if (!canvasContext) {
|
|
@@ -79048,6 +80263,9 @@ function isImageRun(run2) {
|
|
|
79048
80263
|
function isLineBreakRun(run2) {
|
|
79049
80264
|
return run2.kind === "lineBreak";
|
|
79050
80265
|
}
|
|
80266
|
+
function isFieldAnnotationRun(run2) {
|
|
80267
|
+
return run2.kind === "fieldAnnotation";
|
|
80268
|
+
}
|
|
79051
80269
|
async function measureBlock(block, constraints) {
|
|
79052
80270
|
const normalized = normalizeConstraints(constraints);
|
|
79053
80271
|
if (block.kind === "drawing") {
|
|
@@ -79414,6 +80632,92 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
79414
80632
|
lastAppliedTabAlign = null;
|
|
79415
80633
|
continue;
|
|
79416
80634
|
}
|
|
80635
|
+
if (isFieldAnnotationRun(run2)) {
|
|
80636
|
+
const displayText = run2.displayLabel || "";
|
|
80637
|
+
const annotationFontSize = typeof run2.fontSize === "number" ? run2.fontSize : typeof run2.fontSize === "string" ? parseFloat(run2.fontSize) || DEFAULT_FIELD_ANNOTATION_FONT_SIZE : DEFAULT_FIELD_ANNOTATION_FONT_SIZE;
|
|
80638
|
+
const annotationFontFamily = run2.fontFamily || "Arial, sans-serif";
|
|
80639
|
+
const fontWeight = run2.bold ? "bold" : "normal";
|
|
80640
|
+
const fontStyle = run2.italic ? "italic" : "normal";
|
|
80641
|
+
const annotationFont = `${fontStyle} ${fontWeight} ${annotationFontSize}px ${annotationFontFamily}`;
|
|
80642
|
+
ctx2.font = annotationFont;
|
|
80643
|
+
const textWidth = displayText ? ctx2.measureText(displayText).width : 0;
|
|
80644
|
+
const annotationWidth = textWidth + FIELD_ANNOTATION_PILL_PADDING;
|
|
80645
|
+
const annotationHeight = annotationFontSize * FIELD_ANNOTATION_LINE_HEIGHT_MULTIPLIER + FIELD_ANNOTATION_VERTICAL_PADDING;
|
|
80646
|
+
let annotationStartX;
|
|
80647
|
+
if (pendingTabAlignment && currentLine) {
|
|
80648
|
+
annotationStartX = alignPendingTabForWidth(annotationWidth);
|
|
80649
|
+
}
|
|
80650
|
+
if (!currentLine) {
|
|
80651
|
+
currentLine = {
|
|
80652
|
+
fromRun: runIndex,
|
|
80653
|
+
fromChar: 0,
|
|
80654
|
+
toRun: runIndex,
|
|
80655
|
+
toChar: 1,
|
|
80656
|
+
// Field annotations are atomic units
|
|
80657
|
+
width: annotationWidth,
|
|
80658
|
+
maxFontSize: annotationHeight,
|
|
80659
|
+
maxWidth: getEffectiveWidth(initialAvailableWidth),
|
|
80660
|
+
segments: [
|
|
80661
|
+
{
|
|
80662
|
+
runIndex,
|
|
80663
|
+
fromChar: 0,
|
|
80664
|
+
toChar: 1,
|
|
80665
|
+
width: annotationWidth,
|
|
80666
|
+
...annotationStartX !== void 0 ? { x: annotationStartX } : {}
|
|
80667
|
+
}
|
|
80668
|
+
]
|
|
80669
|
+
};
|
|
80670
|
+
continue;
|
|
80671
|
+
}
|
|
80672
|
+
if (currentLine.width + annotationWidth > currentLine.maxWidth && currentLine.width > 0) {
|
|
80673
|
+
const metrics = calculateTypographyMetrics(currentLine.maxFontSize, spacing, currentLine.maxFontInfo);
|
|
80674
|
+
const completedLine = {
|
|
80675
|
+
...currentLine,
|
|
80676
|
+
...metrics
|
|
80677
|
+
};
|
|
80678
|
+
addBarTabsToLine(completedLine);
|
|
80679
|
+
lines.push(completedLine);
|
|
80680
|
+
tabStopCursor = 0;
|
|
80681
|
+
pendingTabAlignment = null;
|
|
80682
|
+
lastAppliedTabAlign = null;
|
|
80683
|
+
currentLine = {
|
|
80684
|
+
fromRun: runIndex,
|
|
80685
|
+
fromChar: 0,
|
|
80686
|
+
toRun: runIndex,
|
|
80687
|
+
toChar: 1,
|
|
80688
|
+
width: annotationWidth,
|
|
80689
|
+
maxFontSize: annotationHeight,
|
|
80690
|
+
maxWidth: getEffectiveWidth(contentWidth),
|
|
80691
|
+
segments: [
|
|
80692
|
+
{
|
|
80693
|
+
runIndex,
|
|
80694
|
+
fromChar: 0,
|
|
80695
|
+
toChar: 1,
|
|
80696
|
+
width: annotationWidth
|
|
80697
|
+
}
|
|
80698
|
+
]
|
|
80699
|
+
};
|
|
80700
|
+
} else {
|
|
80701
|
+
currentLine.toRun = runIndex;
|
|
80702
|
+
currentLine.toChar = 1;
|
|
80703
|
+
currentLine.width = roundValue(currentLine.width + annotationWidth);
|
|
80704
|
+
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, annotationHeight);
|
|
80705
|
+
if (!currentLine.segments) currentLine.segments = [];
|
|
80706
|
+
currentLine.segments.push({
|
|
80707
|
+
runIndex,
|
|
80708
|
+
fromChar: 0,
|
|
80709
|
+
toChar: 1,
|
|
80710
|
+
width: annotationWidth,
|
|
80711
|
+
...annotationStartX !== void 0 ? { x: annotationStartX } : {}
|
|
80712
|
+
});
|
|
80713
|
+
}
|
|
80714
|
+
const tabAlign = lastAppliedTabAlign;
|
|
80715
|
+
if (tabAlign && currentLine && tabAlign.val === "end") {
|
|
80716
|
+
currentLine.width = roundValue(tabAlign.target);
|
|
80717
|
+
}
|
|
80718
|
+
lastAppliedTabAlign = null;
|
|
80719
|
+
continue;
|
|
80720
|
+
}
|
|
79417
80721
|
if (!("text" in run2) || !("fontSize" in run2)) {
|
|
79418
80722
|
continue;
|
|
79419
80723
|
}
|
|
@@ -81378,6 +82682,12 @@ function isInRegisteredSurface(event) {
|
|
|
81378
82682
|
}
|
|
81379
82683
|
return false;
|
|
81380
82684
|
}
|
|
82685
|
+
function isValidFieldAnnotationAttributes(attrs) {
|
|
82686
|
+
if (!attrs || typeof attrs !== "object") return false;
|
|
82687
|
+
const a = attrs;
|
|
82688
|
+
return typeof a.fieldId === "string" && typeof a.fieldType === "string" && typeof a.displayLabel === "string" && typeof a.type === "string";
|
|
82689
|
+
}
|
|
82690
|
+
const FIELD_ANNOTATION_DATA_TYPE = "fieldAnnotation";
|
|
81381
82691
|
const DEFAULT_PAGE_SIZE = { w: 612, h: 792 };
|
|
81382
82692
|
const DEFAULT_MARGINS = { top: 72, right: 72, bottom: 72, left: 72 };
|
|
81383
82693
|
const WORD_CHARACTER_REGEX = /[\p{L}\p{N}''_~-]/u;
|
|
@@ -81403,6 +82713,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81403
82713
|
__privateAdd$1(this, _layoutOptions);
|
|
81404
82714
|
__privateAdd$1(this, _layoutState, { blocks: [], measures: [], layout: null });
|
|
81405
82715
|
__privateAdd$1(this, _domPainter, null);
|
|
82716
|
+
__privateAdd$1(this, _dragHandlerCleanup, null);
|
|
81406
82717
|
__privateAdd$1(this, _layoutError, null);
|
|
81407
82718
|
__privateAdd$1(this, _layoutErrorState, "healthy");
|
|
81408
82719
|
__privateAdd$1(this, _errorBanner, null);
|
|
@@ -81446,6 +82757,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81446
82757
|
__privateAdd$1(this, _lastClickTime, 0);
|
|
81447
82758
|
__privateAdd$1(this, _lastClickPosition, { x: 0, y: 0 });
|
|
81448
82759
|
__privateAdd$1(this, _lastSelectedImageBlockId, null);
|
|
82760
|
+
__privateAdd$1(this, _dragAnchor, null);
|
|
82761
|
+
__privateAdd$1(this, _isDragging, false);
|
|
82762
|
+
__privateAdd$1(this, _dragExtensionMode, "char");
|
|
81449
82763
|
__privateAdd$1(this, _remoteCursorState, /* @__PURE__ */ new Map());
|
|
81450
82764
|
__privateAdd$1(this, _remoteCursorDirty, false);
|
|
81451
82765
|
__privateAdd$1(this, _remoteCursorOverlay, null);
|
|
@@ -81458,8 +82772,12 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81458
82772
|
if (event.button !== 0) {
|
|
81459
82773
|
return;
|
|
81460
82774
|
}
|
|
82775
|
+
const target = event.target;
|
|
82776
|
+
const isDraggableAnnotation = target?.closest?.('[data-draggable="true"]') != null;
|
|
81461
82777
|
if (!__privateGet$1(this, _layoutState).layout) {
|
|
81462
|
-
|
|
82778
|
+
if (!isDraggableAnnotation) {
|
|
82779
|
+
event.preventDefault();
|
|
82780
|
+
}
|
|
81463
82781
|
if (document.activeElement instanceof HTMLElement) {
|
|
81464
82782
|
document.activeElement.blur();
|
|
81465
82783
|
}
|
|
@@ -81468,10 +82786,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81468
82786
|
return;
|
|
81469
82787
|
}
|
|
81470
82788
|
const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
|
|
81471
|
-
const
|
|
81472
|
-
if (
|
|
82789
|
+
const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
|
|
82790
|
+
if (doc222) {
|
|
81473
82791
|
try {
|
|
81474
|
-
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(
|
|
82792
|
+
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
|
|
81475
82793
|
__privateGet$1(this, _editor3).view?.dispatch(tr);
|
|
81476
82794
|
} catch (error) {
|
|
81477
82795
|
if (process$1$1.env.NODE_ENV === "development") {
|
|
@@ -81507,7 +82825,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81507
82825
|
if (headerFooterRegion) {
|
|
81508
82826
|
return;
|
|
81509
82827
|
}
|
|
81510
|
-
const
|
|
82828
|
+
const rawHit = clickToPosition(
|
|
81511
82829
|
__privateGet$1(this, _layoutState).layout,
|
|
81512
82830
|
__privateGet$1(this, _layoutState).blocks,
|
|
81513
82831
|
__privateGet$1(this, _layoutState).measures,
|
|
@@ -81516,7 +82834,11 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81516
82834
|
event.clientX,
|
|
81517
82835
|
event.clientY
|
|
81518
82836
|
);
|
|
81519
|
-
|
|
82837
|
+
const doc22 = __privateGet$1(this, _editor3).state?.doc;
|
|
82838
|
+
const hit = rawHit && doc22 ? { ...rawHit, pos: Math.max(0, Math.min(rawHit.pos, doc22.content.size)) } : rawHit;
|
|
82839
|
+
if (!isDraggableAnnotation) {
|
|
82840
|
+
event.preventDefault();
|
|
82841
|
+
}
|
|
81520
82842
|
if (!hit) {
|
|
81521
82843
|
if (document.activeElement instanceof HTMLElement) {
|
|
81522
82844
|
document.activeElement.blur();
|
|
@@ -81524,10 +82846,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81524
82846
|
const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
|
|
81525
82847
|
if (editorDom2) {
|
|
81526
82848
|
const validPos = __privateMethod$1(this, _PresentationEditor_instances, getFirstTextPosition_fn).call(this);
|
|
81527
|
-
const
|
|
81528
|
-
if (
|
|
82849
|
+
const doc222 = __privateGet$1(this, _editor3)?.state?.doc;
|
|
82850
|
+
if (doc222) {
|
|
81529
82851
|
try {
|
|
81530
|
-
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(
|
|
82852
|
+
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(doc222, validPos));
|
|
81531
82853
|
__privateGet$1(this, _editor3).view?.dispatch(tr);
|
|
81532
82854
|
} catch (error) {
|
|
81533
82855
|
if (process$1$1.env.NODE_ENV === "development") {
|
|
@@ -81548,9 +82870,9 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81548
82870
|
hit.pos
|
|
81549
82871
|
);
|
|
81550
82872
|
if (fragmentHit && (fragmentHit.fragment.kind === "image" || fragmentHit.fragment.kind === "drawing")) {
|
|
81551
|
-
const
|
|
82873
|
+
const doc222 = __privateGet$1(this, _editor3).state.doc;
|
|
81552
82874
|
try {
|
|
81553
|
-
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(
|
|
82875
|
+
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(NodeSelection.create(doc222, hit.pos));
|
|
81554
82876
|
__privateGet$1(this, _editor3).view?.dispatch(tr);
|
|
81555
82877
|
if (__privateGet$1(this, _lastSelectedImageBlockId) && __privateGet$1(this, _lastSelectedImageBlockId) !== fragmentHit.fragment.blockId) {
|
|
81556
82878
|
this.emit("imageDeselected", { blockId: __privateGet$1(this, _lastSelectedImageBlockId) });
|
|
@@ -81588,18 +82910,61 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81588
82910
|
this.emit("imageDeselected", { blockId: __privateGet$1(this, _lastSelectedImageBlockId) });
|
|
81589
82911
|
__privateSet(this, _lastSelectedImageBlockId, null);
|
|
81590
82912
|
}
|
|
82913
|
+
if (event.shiftKey && __privateGet$1(this, _editor3).state.selection.$anchor) {
|
|
82914
|
+
const anchor = __privateGet$1(this, _editor3).state.selection.anchor;
|
|
82915
|
+
const head = hit.pos;
|
|
82916
|
+
const { selAnchor, selHead } = __privateMethod$1(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet$1(this, _dragExtensionMode));
|
|
82917
|
+
try {
|
|
82918
|
+
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, selAnchor, selHead));
|
|
82919
|
+
__privateGet$1(this, _editor3).view?.dispatch(tr);
|
|
82920
|
+
__privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
82921
|
+
} catch (error) {
|
|
82922
|
+
console.warn("[SELECTION] Failed to extend selection on shift+click:", {
|
|
82923
|
+
error,
|
|
82924
|
+
anchor,
|
|
82925
|
+
head,
|
|
82926
|
+
selAnchor,
|
|
82927
|
+
selHead,
|
|
82928
|
+
mode: __privateGet$1(this, _dragExtensionMode)
|
|
82929
|
+
});
|
|
82930
|
+
}
|
|
82931
|
+
if (document.activeElement instanceof HTMLElement) {
|
|
82932
|
+
document.activeElement.blur();
|
|
82933
|
+
}
|
|
82934
|
+
const editorDom2 = __privateGet$1(this, _editor3).view?.dom;
|
|
82935
|
+
if (editorDom2) {
|
|
82936
|
+
editorDom2.focus();
|
|
82937
|
+
__privateGet$1(this, _editor3).view?.focus();
|
|
82938
|
+
}
|
|
82939
|
+
return;
|
|
82940
|
+
}
|
|
81591
82941
|
const clickDepth = __privateMethod$1(this, _PresentationEditor_instances, registerPointerClick_fn).call(this, event);
|
|
82942
|
+
if (clickDepth === 1) {
|
|
82943
|
+
__privateSet(this, _dragAnchor, hit.pos);
|
|
82944
|
+
}
|
|
82945
|
+
__privateSet(this, _isDragging, true);
|
|
82946
|
+
if (clickDepth >= 3) {
|
|
82947
|
+
__privateSet(this, _dragExtensionMode, "para");
|
|
82948
|
+
} else if (clickDepth === 2) {
|
|
82949
|
+
__privateSet(this, _dragExtensionMode, "word");
|
|
82950
|
+
} else {
|
|
82951
|
+
__privateSet(this, _dragExtensionMode, "char");
|
|
82952
|
+
}
|
|
82953
|
+
if (typeof __privateGet$1(this, _viewportHost).setPointerCapture === "function") {
|
|
82954
|
+
__privateGet$1(this, _viewportHost).setPointerCapture(event.pointerId);
|
|
82955
|
+
}
|
|
81592
82956
|
let handledByDepth = false;
|
|
81593
82957
|
if (__privateGet$1(this, _session).mode === "body") {
|
|
82958
|
+
const selectionPos = clickDepth >= 2 && __privateGet$1(this, _dragAnchor) !== null ? __privateGet$1(this, _dragAnchor) : hit.pos;
|
|
81594
82959
|
if (clickDepth >= 3) {
|
|
81595
|
-
handledByDepth = __privateMethod$1(this, _PresentationEditor_instances, selectParagraphAt_fn).call(this,
|
|
82960
|
+
handledByDepth = __privateMethod$1(this, _PresentationEditor_instances, selectParagraphAt_fn).call(this, selectionPos);
|
|
81596
82961
|
} else if (clickDepth === 2) {
|
|
81597
|
-
handledByDepth = __privateMethod$1(this, _PresentationEditor_instances, selectWordAt_fn).call(this,
|
|
82962
|
+
handledByDepth = __privateMethod$1(this, _PresentationEditor_instances, selectWordAt_fn).call(this, selectionPos);
|
|
81598
82963
|
}
|
|
81599
82964
|
}
|
|
81600
82965
|
if (!handledByDepth) {
|
|
81601
|
-
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
|
|
81602
82966
|
try {
|
|
82967
|
+
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, hit.pos));
|
|
81603
82968
|
__privateGet$1(this, _editor3).view?.dispatch(tr);
|
|
81604
82969
|
} catch {
|
|
81605
82970
|
}
|
|
@@ -81619,6 +82984,36 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81619
82984
|
if (!__privateGet$1(this, _layoutState).layout) return;
|
|
81620
82985
|
const normalized = __privateMethod$1(this, _PresentationEditor_instances, normalizeClientPoint_fn).call(this, event.clientX, event.clientY);
|
|
81621
82986
|
if (!normalized) return;
|
|
82987
|
+
if (__privateGet$1(this, _isDragging) && __privateGet$1(this, _dragAnchor) !== null && event.buttons & 1) {
|
|
82988
|
+
const hit = clickToPosition(
|
|
82989
|
+
__privateGet$1(this, _layoutState).layout,
|
|
82990
|
+
__privateGet$1(this, _layoutState).blocks,
|
|
82991
|
+
__privateGet$1(this, _layoutState).measures,
|
|
82992
|
+
{ x: normalized.x, y: normalized.y },
|
|
82993
|
+
__privateGet$1(this, _viewportHost),
|
|
82994
|
+
event.clientX,
|
|
82995
|
+
event.clientY
|
|
82996
|
+
);
|
|
82997
|
+
if (!hit) return;
|
|
82998
|
+
const anchor = __privateGet$1(this, _dragAnchor);
|
|
82999
|
+
const head = hit.pos;
|
|
83000
|
+
const { selAnchor, selHead } = __privateMethod$1(this, _PresentationEditor_instances, calculateExtendedSelection_fn).call(this, anchor, head, __privateGet$1(this, _dragExtensionMode));
|
|
83001
|
+
try {
|
|
83002
|
+
const tr = __privateGet$1(this, _editor3).state.tr.setSelection(TextSelection$1.create(__privateGet$1(this, _editor3).state.doc, selAnchor, selHead));
|
|
83003
|
+
__privateGet$1(this, _editor3).view?.dispatch(tr);
|
|
83004
|
+
__privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
83005
|
+
} catch (error) {
|
|
83006
|
+
console.warn("[SELECTION] Failed to extend selection during drag:", {
|
|
83007
|
+
error,
|
|
83008
|
+
anchor,
|
|
83009
|
+
head,
|
|
83010
|
+
selAnchor,
|
|
83011
|
+
selHead,
|
|
83012
|
+
mode: __privateGet$1(this, _dragExtensionMode)
|
|
83013
|
+
});
|
|
83014
|
+
}
|
|
83015
|
+
return;
|
|
83016
|
+
}
|
|
81622
83017
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
81623
83018
|
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
81624
83019
|
return;
|
|
@@ -81637,6 +83032,97 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81637
83032
|
__privateAdd$1(this, _handlePointerLeave, () => {
|
|
81638
83033
|
__privateMethod$1(this, _PresentationEditor_instances, clearHoverRegion_fn).call(this);
|
|
81639
83034
|
});
|
|
83035
|
+
__privateAdd$1(this, _handlePointerUp, (event) => {
|
|
83036
|
+
if (!__privateGet$1(this, _isDragging)) return;
|
|
83037
|
+
if (typeof __privateGet$1(this, _viewportHost).hasPointerCapture === "function" && typeof __privateGet$1(this, _viewportHost).releasePointerCapture === "function" && __privateGet$1(this, _viewportHost).hasPointerCapture(event.pointerId)) {
|
|
83038
|
+
__privateGet$1(this, _viewportHost).releasePointerCapture(event.pointerId);
|
|
83039
|
+
}
|
|
83040
|
+
__privateSet(this, _isDragging, false);
|
|
83041
|
+
});
|
|
83042
|
+
__privateAdd$1(this, _handleDragOver, (event) => {
|
|
83043
|
+
const activeEditor = this.getActiveEditor();
|
|
83044
|
+
if (!activeEditor?.isEditable) {
|
|
83045
|
+
return;
|
|
83046
|
+
}
|
|
83047
|
+
event.preventDefault();
|
|
83048
|
+
if (event.dataTransfer) {
|
|
83049
|
+
event.dataTransfer.dropEffect = "copy";
|
|
83050
|
+
}
|
|
83051
|
+
const dt = event.dataTransfer;
|
|
83052
|
+
const hasFieldAnnotation = dt?.types?.includes(FIELD_ANNOTATION_DATA_TYPE) || Boolean(dt?.getData?.(FIELD_ANNOTATION_DATA_TYPE));
|
|
83053
|
+
if (!hasFieldAnnotation) {
|
|
83054
|
+
return;
|
|
83055
|
+
}
|
|
83056
|
+
const hit = this.hitTest(event.clientX, event.clientY);
|
|
83057
|
+
const doc22 = activeEditor.state?.doc;
|
|
83058
|
+
if (!hit || !doc22) {
|
|
83059
|
+
return;
|
|
83060
|
+
}
|
|
83061
|
+
const pos = Math.min(Math.max(hit.pos, 1), doc22.content.size);
|
|
83062
|
+
const currentSelection = activeEditor.state.selection;
|
|
83063
|
+
const isSameCursor = currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos;
|
|
83064
|
+
if (isSameCursor) {
|
|
83065
|
+
return;
|
|
83066
|
+
}
|
|
83067
|
+
try {
|
|
83068
|
+
const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc22, pos)).setMeta("addToHistory", false);
|
|
83069
|
+
activeEditor.view?.dispatch(tr);
|
|
83070
|
+
__privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
83071
|
+
} catch (error) {
|
|
83072
|
+
if (process$1$1.env.NODE_ENV === "development") {
|
|
83073
|
+
console.debug("[PresentationEditor] Drag position update skipped:", error);
|
|
83074
|
+
}
|
|
83075
|
+
}
|
|
83076
|
+
});
|
|
83077
|
+
__privateAdd$1(this, _handleDrop, (event) => {
|
|
83078
|
+
const activeEditor = this.getActiveEditor();
|
|
83079
|
+
if (!activeEditor?.isEditable) {
|
|
83080
|
+
return;
|
|
83081
|
+
}
|
|
83082
|
+
if (event.dataTransfer?.types?.includes("application/x-field-annotation")) {
|
|
83083
|
+
return;
|
|
83084
|
+
}
|
|
83085
|
+
event.preventDefault();
|
|
83086
|
+
event.stopPropagation();
|
|
83087
|
+
const fieldAnnotationData = event.dataTransfer?.getData(FIELD_ANNOTATION_DATA_TYPE);
|
|
83088
|
+
if (!fieldAnnotationData) {
|
|
83089
|
+
return;
|
|
83090
|
+
}
|
|
83091
|
+
const hit = this.hitTest(event.clientX, event.clientY);
|
|
83092
|
+
const selection = activeEditor.state?.selection;
|
|
83093
|
+
const fallbackPos = selection?.from ?? activeEditor.state?.doc?.content.size ?? null;
|
|
83094
|
+
const pos = hit?.pos ?? fallbackPos;
|
|
83095
|
+
if (pos == null) {
|
|
83096
|
+
return;
|
|
83097
|
+
}
|
|
83098
|
+
let parsedData = null;
|
|
83099
|
+
try {
|
|
83100
|
+
parsedData = JSON.parse(fieldAnnotationData);
|
|
83101
|
+
} catch {
|
|
83102
|
+
return;
|
|
83103
|
+
}
|
|
83104
|
+
const { attributes, sourceField } = parsedData ?? {};
|
|
83105
|
+
activeEditor.emit?.("fieldAnnotationDropped", {
|
|
83106
|
+
sourceField,
|
|
83107
|
+
editor: activeEditor,
|
|
83108
|
+
coordinates: hit,
|
|
83109
|
+
pos
|
|
83110
|
+
});
|
|
83111
|
+
if (attributes && isValidFieldAnnotationAttributes(attributes)) {
|
|
83112
|
+
activeEditor.commands?.addFieldAnnotation?.(pos, attributes, true);
|
|
83113
|
+
const posAfter = Math.min(pos + 1, activeEditor.state?.doc?.content.size ?? pos + 1);
|
|
83114
|
+
const tr = activeEditor.state?.tr.setSelection(TextSelection$1.create(activeEditor.state.doc, posAfter));
|
|
83115
|
+
if (tr) {
|
|
83116
|
+
activeEditor.view?.dispatch(tr);
|
|
83117
|
+
}
|
|
83118
|
+
__privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
83119
|
+
}
|
|
83120
|
+
const editorDom = activeEditor.view?.dom;
|
|
83121
|
+
if (editorDom) {
|
|
83122
|
+
editorDom.focus();
|
|
83123
|
+
activeEditor.view?.focus();
|
|
83124
|
+
}
|
|
83125
|
+
});
|
|
81640
83126
|
__privateAdd$1(this, _handleDoubleClick, (event) => {
|
|
81641
83127
|
if (event.button !== 0) return;
|
|
81642
83128
|
if (!__privateGet$1(this, _layoutState).layout) return;
|
|
@@ -81826,6 +83312,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
81826
83312
|
__privateMethod$1(this, _PresentationEditor_instances, applyZoom_fn).call(this);
|
|
81827
83313
|
__privateMethod$1(this, _PresentationEditor_instances, setupEditorListeners_fn).call(this);
|
|
81828
83314
|
__privateMethod$1(this, _PresentationEditor_instances, setupPointerHandlers_fn).call(this);
|
|
83315
|
+
__privateMethod$1(this, _PresentationEditor_instances, setupDragHandlers_fn).call(this);
|
|
81829
83316
|
__privateMethod$1(this, _PresentationEditor_instances, setupInputBridge_fn).call(this);
|
|
81830
83317
|
__privateMethod$1(this, _PresentationEditor_instances, syncTrackedChangesPreferences_fn).call(this);
|
|
81831
83318
|
if (options.documentId) {
|
|
@@ -82537,6 +84024,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
82537
84024
|
* Safe to call during partial initialization.
|
|
82538
84025
|
*/
|
|
82539
84026
|
destroy() {
|
|
84027
|
+
var _a2;
|
|
82540
84028
|
if (__privateGet$1(this, _rafHandle) != null) {
|
|
82541
84029
|
__privateMethod$1(this, _PresentationEditor_instances, safeCleanup_fn).call(this, () => {
|
|
82542
84030
|
const win = __privateGet$1(this, _visibleHost)?.ownerDocument?.defaultView ?? window;
|
|
@@ -82556,7 +84044,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
82556
84044
|
__privateGet$1(this, _viewportHost)?.removeEventListener("pointerdown", __privateGet$1(this, _handlePointerDown));
|
|
82557
84045
|
__privateGet$1(this, _viewportHost)?.removeEventListener("dblclick", __privateGet$1(this, _handleDoubleClick));
|
|
82558
84046
|
__privateGet$1(this, _viewportHost)?.removeEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
|
|
84047
|
+
__privateGet$1(this, _viewportHost)?.removeEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
|
|
82559
84048
|
__privateGet$1(this, _viewportHost)?.removeEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
|
|
84049
|
+
__privateGet$1(this, _viewportHost)?.removeEventListener("dragover", __privateGet$1(this, _handleDragOver));
|
|
84050
|
+
__privateGet$1(this, _viewportHost)?.removeEventListener("drop", __privateGet$1(this, _handleDrop));
|
|
82560
84051
|
__privateGet$1(this, _visibleHost)?.removeEventListener("keydown", __privateGet$1(this, _handleKeyDown));
|
|
82561
84052
|
__privateGet$1(this, _inputBridge)?.notifyTargetChanged();
|
|
82562
84053
|
__privateGet$1(this, _inputBridge)?.destroy();
|
|
@@ -82595,6 +84086,8 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
82595
84086
|
__privateSet(this, _session, { mode: "body" });
|
|
82596
84087
|
__privateSet(this, _activeHeaderFooterEditor, null);
|
|
82597
84088
|
__privateSet(this, _domPainter, null);
|
|
84089
|
+
(_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
|
|
84090
|
+
__privateSet(this, _dragHandlerCleanup, null);
|
|
82598
84091
|
__privateGet$1(this, _selectionOverlay2)?.remove();
|
|
82599
84092
|
__privateGet$1(this, _painterHost)?.remove();
|
|
82600
84093
|
__privateGet$1(this, _hiddenHost)?.remove();
|
|
@@ -82622,6 +84115,7 @@ _hiddenHost = /* @__PURE__ */ new WeakMap();
|
|
|
82622
84115
|
_layoutOptions = /* @__PURE__ */ new WeakMap();
|
|
82623
84116
|
_layoutState = /* @__PURE__ */ new WeakMap();
|
|
82624
84117
|
_domPainter = /* @__PURE__ */ new WeakMap();
|
|
84118
|
+
_dragHandlerCleanup = /* @__PURE__ */ new WeakMap();
|
|
82625
84119
|
_layoutError = /* @__PURE__ */ new WeakMap();
|
|
82626
84120
|
_layoutErrorState = /* @__PURE__ */ new WeakMap();
|
|
82627
84121
|
_errorBanner = /* @__PURE__ */ new WeakMap();
|
|
@@ -82665,6 +84159,9 @@ _clickCount = /* @__PURE__ */ new WeakMap();
|
|
|
82665
84159
|
_lastClickTime = /* @__PURE__ */ new WeakMap();
|
|
82666
84160
|
_lastClickPosition = /* @__PURE__ */ new WeakMap();
|
|
82667
84161
|
_lastSelectedImageBlockId = /* @__PURE__ */ new WeakMap();
|
|
84162
|
+
_dragAnchor = /* @__PURE__ */ new WeakMap();
|
|
84163
|
+
_isDragging = /* @__PURE__ */ new WeakMap();
|
|
84164
|
+
_dragExtensionMode = /* @__PURE__ */ new WeakMap();
|
|
82668
84165
|
_remoteCursorState = /* @__PURE__ */ new WeakMap();
|
|
82669
84166
|
_remoteCursorDirty = /* @__PURE__ */ new WeakMap();
|
|
82670
84167
|
_remoteCursorOverlay = /* @__PURE__ */ new WeakMap();
|
|
@@ -83000,9 +84497,101 @@ setupPointerHandlers_fn = function() {
|
|
|
83000
84497
|
__privateGet$1(this, _viewportHost).addEventListener("pointerdown", __privateGet$1(this, _handlePointerDown));
|
|
83001
84498
|
__privateGet$1(this, _viewportHost).addEventListener("dblclick", __privateGet$1(this, _handleDoubleClick));
|
|
83002
84499
|
__privateGet$1(this, _viewportHost).addEventListener("pointermove", __privateGet$1(this, _handlePointerMove));
|
|
84500
|
+
__privateGet$1(this, _viewportHost).addEventListener("pointerup", __privateGet$1(this, _handlePointerUp));
|
|
83003
84501
|
__privateGet$1(this, _viewportHost).addEventListener("pointerleave", __privateGet$1(this, _handlePointerLeave));
|
|
84502
|
+
__privateGet$1(this, _viewportHost).addEventListener("dragover", __privateGet$1(this, _handleDragOver));
|
|
84503
|
+
__privateGet$1(this, _viewportHost).addEventListener("drop", __privateGet$1(this, _handleDrop));
|
|
83004
84504
|
__privateGet$1(this, _visibleHost).addEventListener("keydown", __privateGet$1(this, _handleKeyDown));
|
|
83005
84505
|
};
|
|
84506
|
+
setupDragHandlers_fn = function() {
|
|
84507
|
+
var _a2;
|
|
84508
|
+
(_a2 = __privateGet$1(this, _dragHandlerCleanup)) == null ? void 0 : _a2.call(this);
|
|
84509
|
+
__privateSet(this, _dragHandlerCleanup, null);
|
|
84510
|
+
__privateSet(this, _dragHandlerCleanup, createDragHandler(__privateGet$1(this, _painterHost), {
|
|
84511
|
+
onDragOver: (event) => {
|
|
84512
|
+
if (!event.hasFieldAnnotation || event.event.clientX === 0) {
|
|
84513
|
+
return;
|
|
84514
|
+
}
|
|
84515
|
+
const activeEditor = this.getActiveEditor();
|
|
84516
|
+
if (!activeEditor?.isEditable) {
|
|
84517
|
+
return;
|
|
84518
|
+
}
|
|
84519
|
+
const hit = this.hitTest(event.clientX, event.clientY);
|
|
84520
|
+
const doc2 = activeEditor.state?.doc;
|
|
84521
|
+
if (!hit || !doc2) {
|
|
84522
|
+
return;
|
|
84523
|
+
}
|
|
84524
|
+
const pos = Math.min(Math.max(hit.pos, 1), doc2.content.size);
|
|
84525
|
+
const currentSelection = activeEditor.state.selection;
|
|
84526
|
+
if (currentSelection instanceof TextSelection$1 && currentSelection.from === pos && currentSelection.to === pos) {
|
|
84527
|
+
return;
|
|
84528
|
+
}
|
|
84529
|
+
try {
|
|
84530
|
+
const tr = activeEditor.state.tr.setSelection(TextSelection$1.create(doc2, pos)).setMeta("addToHistory", false);
|
|
84531
|
+
activeEditor.view?.dispatch(tr);
|
|
84532
|
+
__privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
84533
|
+
} catch {
|
|
84534
|
+
}
|
|
84535
|
+
},
|
|
84536
|
+
onDrop: (event) => {
|
|
84537
|
+
event.event.preventDefault();
|
|
84538
|
+
event.event.stopPropagation();
|
|
84539
|
+
if (event.pmPosition === null) {
|
|
84540
|
+
return;
|
|
84541
|
+
}
|
|
84542
|
+
const activeEditor = this.getActiveEditor();
|
|
84543
|
+
const { state: state2, view } = activeEditor;
|
|
84544
|
+
if (!state2 || !view) {
|
|
84545
|
+
return;
|
|
84546
|
+
}
|
|
84547
|
+
const fieldId = event.data.fieldId;
|
|
84548
|
+
if (fieldId) {
|
|
84549
|
+
const targetPos = event.pmPosition;
|
|
84550
|
+
let sourceStart = null;
|
|
84551
|
+
let sourceEnd = null;
|
|
84552
|
+
let sourceNode = null;
|
|
84553
|
+
state2.doc.descendants((node, pos) => {
|
|
84554
|
+
if (node.type.name === "fieldAnnotation" && node.attrs.fieldId === fieldId) {
|
|
84555
|
+
sourceStart = pos;
|
|
84556
|
+
sourceEnd = pos + node.nodeSize;
|
|
84557
|
+
sourceNode = node;
|
|
84558
|
+
return false;
|
|
84559
|
+
}
|
|
84560
|
+
return true;
|
|
84561
|
+
});
|
|
84562
|
+
if (sourceStart === null || sourceEnd === null || !sourceNode) {
|
|
84563
|
+
return;
|
|
84564
|
+
}
|
|
84565
|
+
if (targetPos >= sourceStart && targetPos <= sourceEnd) {
|
|
84566
|
+
return;
|
|
84567
|
+
}
|
|
84568
|
+
const tr = state2.tr;
|
|
84569
|
+
tr.delete(sourceStart, sourceEnd);
|
|
84570
|
+
const mappedTarget = tr.mapping.map(targetPos);
|
|
84571
|
+
if (mappedTarget < 0 || mappedTarget > tr.doc.content.size) {
|
|
84572
|
+
return;
|
|
84573
|
+
}
|
|
84574
|
+
tr.insert(mappedTarget, sourceNode);
|
|
84575
|
+
tr.setMeta("uiEvent", "drop");
|
|
84576
|
+
view.dispatch(tr);
|
|
84577
|
+
return;
|
|
84578
|
+
}
|
|
84579
|
+
const attrs = event.data.attributes;
|
|
84580
|
+
if (attrs && isValidFieldAnnotationAttributes(attrs)) {
|
|
84581
|
+
const inserted = activeEditor.commands?.addFieldAnnotation?.(event.pmPosition, attrs, true);
|
|
84582
|
+
if (inserted) {
|
|
84583
|
+
__privateMethod$1(this, _PresentationEditor_instances, scheduleSelectionUpdate_fn).call(this);
|
|
84584
|
+
}
|
|
84585
|
+
return;
|
|
84586
|
+
}
|
|
84587
|
+
activeEditor.emit("fieldAnnotationDropped", {
|
|
84588
|
+
sourceField: event.data,
|
|
84589
|
+
editor: activeEditor,
|
|
84590
|
+
coordinates: { pos: event.pmPosition }
|
|
84591
|
+
});
|
|
84592
|
+
}
|
|
84593
|
+
}));
|
|
84594
|
+
};
|
|
83006
84595
|
setupInputBridge_fn = function() {
|
|
83007
84596
|
__privateGet$1(this, _inputBridge)?.destroy();
|
|
83008
84597
|
const win = __privateGet$1(this, _visibleHost).ownerDocument?.defaultView ?? window;
|
|
@@ -83079,8 +84668,11 @@ getFirstTextPosition_fn = function() {
|
|
|
83079
84668
|
registerPointerClick_fn = function(event) {
|
|
83080
84669
|
const MAX_CLICK_COUNT = 3;
|
|
83081
84670
|
const time2 = event.timeStamp ?? performance.now();
|
|
83082
|
-
const
|
|
83083
|
-
const
|
|
84671
|
+
const timeDelta = time2 - __privateGet$1(this, _lastClickTime);
|
|
84672
|
+
const withinTime = timeDelta <= MULTI_CLICK_TIME_THRESHOLD_MS;
|
|
84673
|
+
const distanceX = Math.abs(event.clientX - __privateGet$1(this, _lastClickPosition).x);
|
|
84674
|
+
const distanceY = Math.abs(event.clientY - __privateGet$1(this, _lastClickPosition).y);
|
|
84675
|
+
const withinDistance = distanceX <= MULTI_CLICK_DISTANCE_THRESHOLD_PX && distanceY <= MULTI_CLICK_DISTANCE_THRESHOLD_PX;
|
|
83084
84676
|
if (withinTime && withinDistance) {
|
|
83085
84677
|
__privateSet(this, _clickCount, Math.min(__privateGet$1(this, _clickCount) + 1, MAX_CLICK_COUNT));
|
|
83086
84678
|
} else {
|
|
@@ -83095,6 +84687,9 @@ selectWordAt_fn = function(pos) {
|
|
|
83095
84687
|
if (!state2?.doc) {
|
|
83096
84688
|
return false;
|
|
83097
84689
|
}
|
|
84690
|
+
if (pos < 0 || pos > state2.doc.content.size) {
|
|
84691
|
+
return false;
|
|
84692
|
+
}
|
|
83098
84693
|
const $pos = state2.doc.resolve(pos);
|
|
83099
84694
|
let textblockPos = $pos;
|
|
83100
84695
|
while (textblockPos.depth > 0) {
|
|
@@ -83181,6 +84776,30 @@ selectParagraphAt_fn = function(pos) {
|
|
|
83181
84776
|
return false;
|
|
83182
84777
|
}
|
|
83183
84778
|
};
|
|
84779
|
+
calculateExtendedSelection_fn = function(anchor, head, mode) {
|
|
84780
|
+
if (mode === "word") {
|
|
84781
|
+
const anchorBounds = findWordBoundaries(__privateGet$1(this, _layoutState).blocks, anchor);
|
|
84782
|
+
const headBounds = findWordBoundaries(__privateGet$1(this, _layoutState).blocks, head);
|
|
84783
|
+
if (anchorBounds && headBounds) {
|
|
84784
|
+
if (head >= anchor) {
|
|
84785
|
+
return { selAnchor: anchorBounds.from, selHead: headBounds.to };
|
|
84786
|
+
} else {
|
|
84787
|
+
return { selAnchor: anchorBounds.to, selHead: headBounds.from };
|
|
84788
|
+
}
|
|
84789
|
+
}
|
|
84790
|
+
} else if (mode === "para") {
|
|
84791
|
+
const anchorBounds = findParagraphBoundaries(__privateGet$1(this, _layoutState).blocks, anchor);
|
|
84792
|
+
const headBounds = findParagraphBoundaries(__privateGet$1(this, _layoutState).blocks, head);
|
|
84793
|
+
if (anchorBounds && headBounds) {
|
|
84794
|
+
if (head >= anchor) {
|
|
84795
|
+
return { selAnchor: anchorBounds.from, selHead: headBounds.to };
|
|
84796
|
+
} else {
|
|
84797
|
+
return { selAnchor: anchorBounds.to, selHead: headBounds.from };
|
|
84798
|
+
}
|
|
84799
|
+
}
|
|
84800
|
+
}
|
|
84801
|
+
return { selAnchor: anchor, selHead: head };
|
|
84802
|
+
};
|
|
83184
84803
|
isWordCharacter_fn = function(char) {
|
|
83185
84804
|
if (!char) {
|
|
83186
84805
|
return false;
|
|
@@ -83189,6 +84808,9 @@ isWordCharacter_fn = function(char) {
|
|
|
83189
84808
|
};
|
|
83190
84809
|
_handlePointerMove = /* @__PURE__ */ new WeakMap();
|
|
83191
84810
|
_handlePointerLeave = /* @__PURE__ */ new WeakMap();
|
|
84811
|
+
_handlePointerUp = /* @__PURE__ */ new WeakMap();
|
|
84812
|
+
_handleDragOver = /* @__PURE__ */ new WeakMap();
|
|
84813
|
+
_handleDrop = /* @__PURE__ */ new WeakMap();
|
|
83192
84814
|
_handleDoubleClick = /* @__PURE__ */ new WeakMap();
|
|
83193
84815
|
_handleKeyDown = /* @__PURE__ */ new WeakMap();
|
|
83194
84816
|
focusHeaderFooterShortcut_fn = function(kind) {
|
|
@@ -84361,10 +85983,12 @@ convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY)
|
|
|
84361
85983
|
}
|
|
84362
85984
|
const pageRect = pageEl.getBoundingClientRect();
|
|
84363
85985
|
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
84364
|
-
const
|
|
85986
|
+
const layoutPageSize = __privateGet$1(this, _layoutState).layout?.pageSize;
|
|
85987
|
+
const scaleX = layoutPageSize && typeof layoutPageSize.w === "number" && layoutPageSize.w > 0 ? pageRect.width / layoutPageSize.w : 1;
|
|
85988
|
+
const scaleY = layoutPageSize && typeof layoutPageSize.h === "number" && layoutPageSize.h > 0 ? pageRect.height / layoutPageSize.h : 1;
|
|
84365
85989
|
return {
|
|
84366
|
-
x: pageRect.left - overlayRect.left + pageLocalX *
|
|
84367
|
-
y: pageRect.top - overlayRect.top + pageLocalY *
|
|
85990
|
+
x: pageRect.left - overlayRect.left + pageLocalX * scaleX,
|
|
85991
|
+
y: pageRect.top - overlayRect.top + pageLocalY * scaleY
|
|
84368
85992
|
};
|
|
84369
85993
|
};
|
|
84370
85994
|
normalizeClientPoint_fn = function(clientX, clientY) {
|