@harbour-enterprises/superdoc 1.0.0-beta.65 → 1.0.0-beta.66
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-CqHxrRM3.es.js → PdfViewer-BgQnzisJ.es.js} +1 -1
- package/dist/chunks/{PdfViewer-CPtbSOs5.cjs → PdfViewer-CpRzjNks.cjs} +1 -1
- package/dist/chunks/{index-YSWS94Jr-C7xFStTB.cjs → index-Bjv0_slj-CIZ6x5_a.cjs} +1 -1
- package/dist/chunks/{index-YSWS94Jr-BeHINTZ9.es.js → index-Bjv0_slj-aY5T6UA7.es.js} +1 -1
- package/dist/chunks/{index-DWJXw-IX.cjs → index-Bw7VVDLD.cjs} +3 -3
- package/dist/chunks/{index-BUvQNe-T.es.js → index-k63Akk_i.es.js} +3 -3
- package/dist/chunks/{super-editor.es-BHjskxiY.cjs → super-editor.es-CLrhh2DY.cjs} +290 -157
- package/dist/chunks/{super-editor.es-DaC-R5gx.es.js → super-editor.es-PQo0jrvJ.es.js} +290 -157
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DIAStmht.js → converter-Ybdn8aYC.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-DK-wWQD9.js → docx-zipper-DkmZTQAw.js} +1 -1
- package/dist/super-editor/chunks/{editor-CxKPNxhs.js → editor-pqbWS9yU.js} +345 -95
- package/dist/super-editor/chunks/{index-YSWS94Jr.js → index-Bjv0_slj.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-D7ZHiSKZ.js → toolbar-CSzCVKWZ.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 +292 -159
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -42309,7 +42309,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
42309
42309
|
static getStoredSuperdocVersion(docx) {
|
|
42310
42310
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
42311
42311
|
}
|
|
42312
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
42312
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.66") {
|
|
42313
42313
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
42314
42314
|
}
|
|
42315
42315
|
/**
|
|
@@ -45621,7 +45621,7 @@ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "rea
|
|
|
45621
45621
|
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);
|
|
45622
45622
|
var __privateSet = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
|
|
45623
45623
|
var __privateMethod$1 = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
|
|
45624
|
-
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, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_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, focusEditorAfterImageSelection_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, computeExpectedSectionType_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, computeAnchorMap_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,
|
|
45624
|
+
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, _remoteCursorElements, _remoteCursorDirty, _remoteCursorOverlay, _localSelectionLayer, _awarenessCleanup, _scrollCleanup, _scrollTimeout, _lastRemoteCursorRenderTime, _remoteCursorThrottleTimeout, _PresentationEditor_instances, collectCommentPositions_fn, aggregateLayoutBounds_fn, safeCleanup_fn, setupEditorListeners_fn, setupCollaborationCursors_fn, updateLocalAwarenessCursor_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, focusEditorAfterImageSelection_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, computeExpectedSectionType_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, computeAnchorMap_fn, waitForPageMount_fn, getBodyPageHeight_fn, getHeaderFooterPageHeight_fn, applyDomCorrectionToRects_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, computeDomCaretPageLocal_fn, normalizeClientPoint_fn, computeCaretLayoutRectGeometry_fn, computeCaretLayoutRect_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;
|
|
45625
45625
|
var GOOD_LEAF_SIZE = 200;
|
|
45626
45626
|
var RopeSequence = function RopeSequence2() {
|
|
45627
45627
|
};
|
|
@@ -59498,7 +59498,7 @@ const isHeadless = (editor) => {
|
|
|
59498
59498
|
const shouldSkipNodeView = (editor) => {
|
|
59499
59499
|
return isHeadless(editor);
|
|
59500
59500
|
};
|
|
59501
|
-
const summaryVersion = "1.0.0-beta.
|
|
59501
|
+
const summaryVersion = "1.0.0-beta.66";
|
|
59502
59502
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
59503
59503
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
59504
59504
|
function mapAttributes(attrs) {
|
|
@@ -60287,7 +60287,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60287
60287
|
{ default: remarkStringify },
|
|
60288
60288
|
{ default: remarkGfm }
|
|
60289
60289
|
] = await Promise.all([
|
|
60290
|
-
import("./index-
|
|
60290
|
+
import("./index-Bjv0_slj-aY5T6UA7.es.js"),
|
|
60291
60291
|
import("./index-DRCvimau-Cw339678.es.js"),
|
|
60292
60292
|
import("./index-C_x_N6Uh-DJn8hIEt.es.js"),
|
|
60293
60293
|
import("./index-D_sWOSiG-DE96TaT5.es.js"),
|
|
@@ -60492,7 +60492,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
60492
60492
|
* Process collaboration migrations
|
|
60493
60493
|
*/
|
|
60494
60494
|
processCollaborationMigrations() {
|
|
60495
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
60495
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.66");
|
|
60496
60496
|
if (!this.options.ydoc) return;
|
|
60497
60497
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
60498
60498
|
let docVersion = metaMap.get("version");
|
|
@@ -67997,6 +67997,7 @@ function tableNodeToBlock(node, nextBlockId, positions, defaultFont, defaultSize
|
|
|
67997
67997
|
let measurementCanvas = null;
|
|
67998
67998
|
let measurementCtx = null;
|
|
67999
67999
|
const TAB_CHAR_LENGTH = 1;
|
|
68000
|
+
const SPACE_CHARS = /* @__PURE__ */ new Set([" ", " "]);
|
|
68000
68001
|
const isTabRun$1 = (run2) => run2?.kind === "tab";
|
|
68001
68002
|
function getMeasurementContext() {
|
|
68002
68003
|
if (measurementCtx) return measurementCtx;
|
|
@@ -68013,6 +68014,41 @@ function getMeasurementContext() {
|
|
|
68013
68014
|
}
|
|
68014
68015
|
return measurementCtx;
|
|
68015
68016
|
}
|
|
68017
|
+
const countSpaces = (text) => {
|
|
68018
|
+
let spaces = 0;
|
|
68019
|
+
for (let i = 0; i < text.length; i += 1) {
|
|
68020
|
+
if (SPACE_CHARS.has(text[i])) {
|
|
68021
|
+
spaces += 1;
|
|
68022
|
+
}
|
|
68023
|
+
}
|
|
68024
|
+
return spaces;
|
|
68025
|
+
};
|
|
68026
|
+
const getJustifyAdjustment = (block, line, availableWidthOverride) => {
|
|
68027
|
+
if (block.kind !== "paragraph") {
|
|
68028
|
+
return { extraPerSpace: 0, totalSpaces: 0 };
|
|
68029
|
+
}
|
|
68030
|
+
const alignment2 = block.attrs?.alignment;
|
|
68031
|
+
const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
68032
|
+
const availableWidth = availableWidthOverride ?? line.maxWidth ?? line.width;
|
|
68033
|
+
const slack = Math.max(0, availableWidth - line.width);
|
|
68034
|
+
if (alignment2 !== "justify" || hasExplicitPositioning || slack <= 0) {
|
|
68035
|
+
return { extraPerSpace: 0, totalSpaces: 0 };
|
|
68036
|
+
}
|
|
68037
|
+
const runs = sliceRunsForLine$1(block, line);
|
|
68038
|
+
const totalSpaces = runs.reduce((sum, run2) => {
|
|
68039
|
+
if (isTabRun$1(run2) || "src" in run2 || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation") {
|
|
68040
|
+
return sum;
|
|
68041
|
+
}
|
|
68042
|
+
return sum + countSpaces(run2.text ?? "");
|
|
68043
|
+
}, 0);
|
|
68044
|
+
if (totalSpaces <= 0) {
|
|
68045
|
+
return { extraPerSpace: 0, totalSpaces: 0 };
|
|
68046
|
+
}
|
|
68047
|
+
return {
|
|
68048
|
+
extraPerSpace: slack / totalSpaces,
|
|
68049
|
+
totalSpaces
|
|
68050
|
+
};
|
|
68051
|
+
};
|
|
68016
68052
|
function getRunFontString(run2) {
|
|
68017
68053
|
if (run2.kind === "tab" || run2.kind === "lineBreak" || run2.kind === "break" || run2.kind === "fieldAnnotation" || "src" in run2) {
|
|
68018
68054
|
return "normal normal 16px Arial";
|
|
@@ -68070,9 +68106,15 @@ function sliceRunsForLine$1(block, line) {
|
|
|
68070
68106
|
}
|
|
68071
68107
|
return result;
|
|
68072
68108
|
}
|
|
68073
|
-
function measureCharacterX(block, line, charOffset) {
|
|
68109
|
+
function measureCharacterX(block, line, charOffset, availableWidthOverride) {
|
|
68074
68110
|
const ctx2 = getMeasurementContext();
|
|
68111
|
+
const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: if no maxWidth, approximate available width as line width (no slack)
|
|
68112
|
+
line.width;
|
|
68113
|
+
const justify = getJustifyAdjustment(block, line, availableWidth);
|
|
68114
|
+
const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
|
|
68115
|
+
const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
|
|
68075
68116
|
const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
68117
|
+
const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
|
|
68076
68118
|
if (hasExplicitPositioning && line.segments && ctx2) {
|
|
68077
68119
|
return measureCharacterXSegmentBased(block, line, charOffset, ctx2);
|
|
68078
68120
|
}
|
|
@@ -68087,11 +68129,12 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
68087
68129
|
return sum + (run2.text ?? "").length;
|
|
68088
68130
|
}, 0)
|
|
68089
68131
|
);
|
|
68090
|
-
return charOffset / charsInLine *
|
|
68132
|
+
return charOffset / charsInLine * renderedLineWidth;
|
|
68091
68133
|
}
|
|
68092
68134
|
const runs = sliceRunsForLine$1(block, line);
|
|
68093
68135
|
let currentX = 0;
|
|
68094
68136
|
let currentCharOffset = 0;
|
|
68137
|
+
let spaceTally = 0;
|
|
68095
68138
|
for (const run2 of runs) {
|
|
68096
68139
|
if (isTabRun$1(run2)) {
|
|
68097
68140
|
const runLength2 = TAB_CHAR_LENGTH;
|
|
@@ -68112,14 +68155,18 @@ function measureCharacterX(block, line, charOffset) {
|
|
|
68112
68155
|
const textUpToTarget = text.slice(0, offsetInRun);
|
|
68113
68156
|
const measured2 = ctx2.measureText(textUpToTarget);
|
|
68114
68157
|
const spacingWidth = computeLetterSpacingWidth(run2, offsetInRun, runLength);
|
|
68115
|
-
|
|
68158
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToTarget) : 0;
|
|
68159
|
+
return alignmentOffset + currentX + measured2.width + spacingWidth + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
68116
68160
|
}
|
|
68117
68161
|
ctx2.font = getRunFontString(run2);
|
|
68118
68162
|
const measured = ctx2.measureText(text);
|
|
68119
|
-
|
|
68163
|
+
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
68164
|
+
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
|
|
68165
|
+
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
68166
|
+
spaceTally += spacesInRun;
|
|
68120
68167
|
currentCharOffset += runLength;
|
|
68121
68168
|
}
|
|
68122
|
-
return currentX;
|
|
68169
|
+
return alignmentOffset + currentX;
|
|
68123
68170
|
}
|
|
68124
68171
|
function measureCharacterXSegmentBased(block, line, charOffset, ctx2) {
|
|
68125
68172
|
if (block.kind !== "paragraph" || !line.segments) return 0;
|
|
@@ -68194,8 +68241,15 @@ function charOffsetToPm(block, line, charOffset, fallbackPmStart) {
|
|
|
68194
68241
|
}
|
|
68195
68242
|
return lastPm;
|
|
68196
68243
|
}
|
|
68197
|
-
function findCharacterAtX(block, line, x2, pmStart) {
|
|
68244
|
+
function findCharacterAtX(block, line, x2, pmStart, availableWidthOverride) {
|
|
68198
68245
|
const ctx2 = getMeasurementContext();
|
|
68246
|
+
const availableWidth = availableWidthOverride ?? line.maxWidth ?? // Fallback: approximate with line width when no maxWidth is present
|
|
68247
|
+
line.width;
|
|
68248
|
+
const justify = getJustifyAdjustment(block, line, availableWidth);
|
|
68249
|
+
const renderedLineWidth = line.width + Math.max(0, availableWidth - line.width);
|
|
68250
|
+
const alignment2 = block.kind === "paragraph" ? block.attrs?.alignment : void 0;
|
|
68251
|
+
const hasExplicitPositioning = line.segments?.some((seg) => seg.x !== void 0);
|
|
68252
|
+
const alignmentOffset = !hasExplicitPositioning && alignment2 === "center" ? Math.max(0, (availableWidth - renderedLineWidth) / 2) : !hasExplicitPositioning && alignment2 === "right" ? Math.max(0, availableWidth - renderedLineWidth) : 0;
|
|
68199
68253
|
if (!ctx2) {
|
|
68200
68254
|
const runs2 = sliceRunsForLine$1(block, line);
|
|
68201
68255
|
const charsInLine = Math.max(
|
|
@@ -68207,7 +68261,7 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
68207
68261
|
return sum + (run2.text ?? "").length;
|
|
68208
68262
|
}, 0)
|
|
68209
68263
|
);
|
|
68210
|
-
const ratio = Math.max(0, Math.min(1, x2 /
|
|
68264
|
+
const ratio = Math.max(0, Math.min(1, (x2 - alignmentOffset) / renderedLineWidth));
|
|
68211
68265
|
const charOffset = Math.round(ratio * charsInLine);
|
|
68212
68266
|
const pmPosition2 = charOffsetToPm(block, line, charOffset, pmStart);
|
|
68213
68267
|
return {
|
|
@@ -68216,9 +68270,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
68216
68270
|
};
|
|
68217
68271
|
}
|
|
68218
68272
|
const runs = sliceRunsForLine$1(block, line);
|
|
68219
|
-
const safeX = Math.max(0, Math.min(
|
|
68273
|
+
const safeX = Math.max(0, Math.min(renderedLineWidth, x2 - alignmentOffset));
|
|
68220
68274
|
let currentX = 0;
|
|
68221
68275
|
let currentCharOffset = 0;
|
|
68276
|
+
let spaceTally = 0;
|
|
68222
68277
|
for (const run2 of runs) {
|
|
68223
68278
|
if (isTabRun$1(run2)) {
|
|
68224
68279
|
const tabWidth = run2.width ?? 0;
|
|
@@ -68245,7 +68300,8 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
68245
68300
|
for (let i = 0; i <= runLength; i++) {
|
|
68246
68301
|
const textUpToChar = text.slice(0, i);
|
|
68247
68302
|
const measured2 = ctx2.measureText(textUpToChar);
|
|
68248
|
-
const
|
|
68303
|
+
const spacesInPortion = justify.extraPerSpace > 0 ? countSpaces(textUpToChar) : 0;
|
|
68304
|
+
const charX = currentX + measured2.width + computeLetterSpacingWidth(run2, i, runLength) + justify.extraPerSpace * (spaceTally + spacesInPortion);
|
|
68249
68305
|
if (charX >= safeX) {
|
|
68250
68306
|
if (i === 0) {
|
|
68251
68307
|
const pmPosition3 = charOffsetToPm(block, line, currentCharOffset, pmStart);
|
|
@@ -68268,7 +68324,10 @@ function findCharacterAtX(block, line, x2, pmStart) {
|
|
|
68268
68324
|
}
|
|
68269
68325
|
}
|
|
68270
68326
|
const measured = ctx2.measureText(text);
|
|
68271
|
-
|
|
68327
|
+
const runLetterSpacing = computeLetterSpacingWidth(run2, runLength, runLength);
|
|
68328
|
+
const spacesInRun = justify.extraPerSpace > 0 ? countSpaces(text) : 0;
|
|
68329
|
+
currentX += measured.width + runLetterSpacing + justify.extraPerSpace * spacesInRun;
|
|
68330
|
+
spaceTally += spacesInRun;
|
|
68272
68331
|
currentCharOffset += runLength;
|
|
68273
68332
|
}
|
|
68274
68333
|
const pmPosition = charOffsetToPm(block, line, currentCharOffset, pmStart);
|
|
@@ -80885,7 +80944,10 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
|
|
|
80885
80944
|
}
|
|
80886
80945
|
const line = measure.lines[lineIndex];
|
|
80887
80946
|
const isRTL = isRtlBlock(block);
|
|
80888
|
-
const
|
|
80947
|
+
const paraIndentLeft = block.attrs?.indent?.left ?? 0;
|
|
80948
|
+
const paraIndentRight = block.attrs?.indent?.right ?? 0;
|
|
80949
|
+
const availableWidth = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
|
|
80950
|
+
const pos = mapPointToPm(block, line, pageRelativePoint.x - fragment.x, isRTL, availableWidth);
|
|
80889
80951
|
if (pos == null) {
|
|
80890
80952
|
logClickStage("warn", "no-position", {
|
|
80891
80953
|
blockId: fragment.blockId
|
|
@@ -80916,7 +80978,10 @@ function clickToPosition(layout, blocks, measures, containerPoint, domContainer,
|
|
|
80916
80978
|
if (lineIndex != null) {
|
|
80917
80979
|
const line = cellMeasure.lines[lineIndex];
|
|
80918
80980
|
const isRTL = isRtlBlock(cellBlock);
|
|
80919
|
-
const
|
|
80981
|
+
const paraIndentLeft = cellBlock.attrs?.indent?.left ?? 0;
|
|
80982
|
+
const paraIndentRight = cellBlock.attrs?.indent?.right ?? 0;
|
|
80983
|
+
const availableWidth = Math.max(0, tableHit.fragment.width - (paraIndentLeft + paraIndentRight));
|
|
80984
|
+
const pos = mapPointToPm(cellBlock, line, localX, isRTL, availableWidth);
|
|
80920
80985
|
if (pos != null) {
|
|
80921
80986
|
logClickStage("log", "success", {
|
|
80922
80987
|
blockId: tableHit.fragment.blockId,
|
|
@@ -81075,7 +81140,15 @@ function selectionToRects(layout, blocks, measures, from2, to) {
|
|
|
81075
81140
|
const startX = mapPmToX(block, line, charOffsetFrom, fragment.width);
|
|
81076
81141
|
const endX = mapPmToX(block, line, charOffsetTo, fragment.width);
|
|
81077
81142
|
const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
|
|
81078
|
-
const
|
|
81143
|
+
const paraIndentLeft = block.attrs?.indent?.left ?? 0;
|
|
81144
|
+
const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
|
|
81145
|
+
const isFirstLine = index2 === fragment.fromLine;
|
|
81146
|
+
const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
|
|
81147
|
+
let indentAdjust = 0;
|
|
81148
|
+
if (!isListFirstLine) {
|
|
81149
|
+
indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
|
|
81150
|
+
}
|
|
81151
|
+
const rectX = fragment.x + markerWidth + indentAdjust + Math.min(startX, endX);
|
|
81079
81152
|
const rectWidth = Math.max(1, Math.abs(endX - startX));
|
|
81080
81153
|
const lineOffset = lineHeightBeforeIndex(measure, index2) - lineHeightBeforeIndex(measure, fragment.fromLine);
|
|
81081
81154
|
const rectY = fragment.y + lineOffset;
|
|
@@ -81451,11 +81524,11 @@ const lineHeightBeforeIndex = (measure, absoluteLineIndex) => {
|
|
|
81451
81524
|
}
|
|
81452
81525
|
return height;
|
|
81453
81526
|
};
|
|
81454
|
-
const mapPointToPm = (block, line, x2, isRTL) => {
|
|
81527
|
+
const mapPointToPm = (block, line, x2, isRTL, availableWidthOverride) => {
|
|
81455
81528
|
if (block.kind !== "paragraph") return null;
|
|
81456
81529
|
const range2 = computeLinePmRange(block, line);
|
|
81457
81530
|
if (range2.pmStart == null || range2.pmEnd == null) return null;
|
|
81458
|
-
const result = findCharacterAtX(block, line, x2, range2.pmStart);
|
|
81531
|
+
const result = findCharacterAtX(block, line, x2, range2.pmStart, availableWidthOverride);
|
|
81459
81532
|
if (isRTL) {
|
|
81460
81533
|
const charOffset = result.charOffset;
|
|
81461
81534
|
const charsInLine = Math.max(1, line.toChar - line.fromChar);
|
|
@@ -81466,7 +81539,10 @@ const mapPointToPm = (block, line, x2, isRTL) => {
|
|
|
81466
81539
|
};
|
|
81467
81540
|
const mapPmToX = (block, line, offset2, fragmentWidth) => {
|
|
81468
81541
|
if (fragmentWidth <= 0 || line.width <= 0) return 0;
|
|
81469
|
-
|
|
81542
|
+
const paraIndentLeft = block.kind === "paragraph" ? block.attrs?.indent?.left ?? 0 : 0;
|
|
81543
|
+
const paraIndentRight = block.kind === "paragraph" ? block.attrs?.indent?.right ?? 0 : 0;
|
|
81544
|
+
const availableWidth = Math.max(0, fragmentWidth - (paraIndentLeft + paraIndentRight));
|
|
81545
|
+
return measureCharacterX(block, line, offset2, availableWidth);
|
|
81470
81546
|
};
|
|
81471
81547
|
const isRtlBlock = (block) => {
|
|
81472
81548
|
if (block.kind !== "paragraph") return false;
|
|
@@ -84131,29 +84207,16 @@ ensureEditorHost_fn = function(pageElement, kind, decorationContainer) {
|
|
|
84131
84207
|
}
|
|
84132
84208
|
return editorHost;
|
|
84133
84209
|
};
|
|
84134
|
-
positionEditorHost_fn = function(editorHost, region, decorationContainer,
|
|
84210
|
+
positionEditorHost_fn = function(editorHost, region, decorationContainer, _zoom) {
|
|
84135
84211
|
const pageElement = editorHost.parentElement;
|
|
84136
84212
|
if (!pageElement) {
|
|
84137
84213
|
console.error("[EditorOverlayManager] Editor host has no parent element");
|
|
84138
84214
|
return;
|
|
84139
84215
|
}
|
|
84140
|
-
|
|
84141
|
-
|
|
84142
|
-
|
|
84143
|
-
|
|
84144
|
-
if (decorationContainer) {
|
|
84145
|
-
const decorationRect = decorationContainer.getBoundingClientRect();
|
|
84146
|
-
const pageRect = pageElement.getBoundingClientRect();
|
|
84147
|
-
top2 = decorationRect.top - pageRect.top;
|
|
84148
|
-
left2 = decorationRect.left - pageRect.left;
|
|
84149
|
-
width = decorationRect.width;
|
|
84150
|
-
height = decorationRect.height;
|
|
84151
|
-
} else {
|
|
84152
|
-
top2 = region.localY * zoom;
|
|
84153
|
-
left2 = region.localX * zoom;
|
|
84154
|
-
width = region.width * zoom;
|
|
84155
|
-
height = region.height * zoom;
|
|
84156
|
-
}
|
|
84216
|
+
const top2 = decorationContainer?.offsetTop ?? region.localY;
|
|
84217
|
+
const left2 = decorationContainer?.offsetLeft ?? region.localX;
|
|
84218
|
+
const width = decorationContainer?.offsetWidth ?? region.width;
|
|
84219
|
+
const height = decorationContainer?.offsetHeight ?? region.height;
|
|
84157
84220
|
Object.assign(editorHost.style, {
|
|
84158
84221
|
top: `${top2}px`,
|
|
84159
84222
|
left: `${left2}px`,
|
|
@@ -84168,19 +84231,14 @@ positionEditorHost_fn = function(editorHost, region, decorationContainer, zoom)
|
|
|
84168
84231
|
}
|
|
84169
84232
|
}
|
|
84170
84233
|
};
|
|
84171
|
-
showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer,
|
|
84234
|
+
showHeaderFooterBorder_fn = function(pageElement, region, decorationContainer, _zoom) {
|
|
84172
84235
|
__privateMethod$1(this, _EditorOverlayManager_instances, hideHeaderFooterBorder_fn).call(this);
|
|
84173
84236
|
__privateSet(this, _borderLine, document.createElement("div"));
|
|
84174
84237
|
__privateGet$1(this, _borderLine).className = "superdoc-header-footer-border";
|
|
84175
|
-
let topPosition;
|
|
84176
84238
|
const isHeader = region.kind === "header";
|
|
84177
|
-
|
|
84178
|
-
|
|
84179
|
-
|
|
84180
|
-
topPosition = isHeader ? decorationRect.bottom - pageRect.top : decorationRect.top - pageRect.top;
|
|
84181
|
-
} else {
|
|
84182
|
-
topPosition = isHeader ? (region.localY + region.height) * zoom : region.localY * zoom;
|
|
84183
|
-
}
|
|
84239
|
+
const decorationTop = decorationContainer?.offsetTop;
|
|
84240
|
+
const decorationHeight = decorationContainer?.offsetHeight;
|
|
84241
|
+
const topPosition = isHeader ? decorationTop != null && decorationHeight != null ? decorationTop + decorationHeight : region.localY + region.height : decorationTop ?? region.localY;
|
|
84184
84242
|
Object.assign(__privateGet$1(this, _borderLine).style, {
|
|
84185
84243
|
position: "absolute",
|
|
84186
84244
|
left: "0",
|
|
@@ -85293,8 +85351,10 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
85293
85351
|
const start2 = Math.min(from2, to);
|
|
85294
85352
|
const end2 = Math.max(from2, to);
|
|
85295
85353
|
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
85296
|
-
const overlayRect = __privateGet$1(this, _selectionOverlay2).getBoundingClientRect();
|
|
85297
85354
|
const relativeRect = relativeTo?.getBoundingClientRect() ?? null;
|
|
85355
|
+
const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
|
|
85356
|
+
const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
|
|
85357
|
+
const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
|
|
85298
85358
|
const layoutRectSource = () => {
|
|
85299
85359
|
if (__privateGet$1(this, _session).mode !== "body") {
|
|
85300
85360
|
return __privateMethod$1(this, _PresentationEditor_instances, computeHeaderFooterSelectionRects_fn).call(this, start2, end2);
|
|
@@ -85305,14 +85365,38 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
85305
85365
|
};
|
|
85306
85366
|
const rawRects = layoutRectSource();
|
|
85307
85367
|
if (!rawRects.length) return [];
|
|
85368
|
+
const domCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, start2);
|
|
85369
|
+
const domCaretEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, end2);
|
|
85370
|
+
const layoutCaretStart = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, start2, false);
|
|
85371
|
+
__privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, end2, false);
|
|
85372
|
+
const pageDelta = {};
|
|
85373
|
+
if (domCaretStart && layoutCaretStart && domCaretStart.pageIndex === layoutCaretStart.pageIndex) {
|
|
85374
|
+
pageDelta[domCaretStart.pageIndex] = {
|
|
85375
|
+
dx: domCaretStart.x - layoutCaretStart.x,
|
|
85376
|
+
dy: domCaretStart.y - layoutCaretStart.y
|
|
85377
|
+
};
|
|
85378
|
+
}
|
|
85308
85379
|
const pageHeight = __privateGet$1(this, _session).mode === "body" ? __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this) : __privateMethod$1(this, _PresentationEditor_instances, getHeaderFooterPageHeight_fn).call(this);
|
|
85309
85380
|
const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
|
|
85310
|
-
|
|
85311
|
-
const
|
|
85312
|
-
|
|
85381
|
+
const finalRects = rawRects.map((rect, idx, allRects) => {
|
|
85382
|
+
const delta = pageDelta[rect.pageIndex];
|
|
85383
|
+
let adjustedX = delta ? rect.x + delta.dx : rect.x;
|
|
85384
|
+
const adjustedY = delta ? rect.y + delta.dy : rect.y;
|
|
85385
|
+
const isFirstRect = idx === 0;
|
|
85386
|
+
const isLastRect = idx === allRects.length - 1;
|
|
85387
|
+
if (isFirstRect && domCaretStart && rect.pageIndex === domCaretStart.pageIndex) {
|
|
85388
|
+
adjustedX = domCaretStart.x;
|
|
85389
|
+
}
|
|
85390
|
+
if (isLastRect && domCaretEnd && rect.pageIndex === domCaretEnd.pageIndex) {
|
|
85391
|
+
const endX = domCaretEnd.x;
|
|
85392
|
+
const newWidth = Math.max(1, endX - adjustedX);
|
|
85393
|
+
rect = { ...rect, width: newWidth };
|
|
85394
|
+
}
|
|
85395
|
+
const pageLocalY = adjustedY - rect.pageIndex * (pageHeight + pageGap);
|
|
85396
|
+
const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, adjustedX, pageLocalY);
|
|
85313
85397
|
if (!coords) return null;
|
|
85314
|
-
const absLeft = coords.x * zoom +
|
|
85315
|
-
const absTop = coords.y * zoom +
|
|
85398
|
+
const absLeft = coords.x * zoom - scrollLeft + containerRect.left;
|
|
85399
|
+
const absTop = coords.y * zoom - scrollTop + containerRect.top;
|
|
85316
85400
|
const left2 = relativeRect ? absLeft - relativeRect.left : absLeft;
|
|
85317
85401
|
const top2 = relativeRect ? absTop - relativeRect.top : absTop;
|
|
85318
85402
|
const width = Math.max(1, rect.width * zoom);
|
|
@@ -85327,6 +85411,7 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
85327
85411
|
height
|
|
85328
85412
|
};
|
|
85329
85413
|
}).filter((rect) => Boolean(rect));
|
|
85414
|
+
return finalRects;
|
|
85330
85415
|
}
|
|
85331
85416
|
/**
|
|
85332
85417
|
* Get selection bounds for a document range with aggregated bounding box.
|
|
@@ -85555,24 +85640,22 @@ const _PresentationEditor = class _PresentationEditor2 extends EventEmitter$1 {
|
|
|
85555
85640
|
return null;
|
|
85556
85641
|
}
|
|
85557
85642
|
const rect2 = rects2[0];
|
|
85558
|
-
const
|
|
85559
|
-
|
|
85560
|
-
|
|
85561
|
-
|
|
85643
|
+
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
85644
|
+
const containerRect = __privateGet$1(this, _visibleHost).getBoundingClientRect();
|
|
85645
|
+
const scrollLeft = __privateGet$1(this, _visibleHost).scrollLeft ?? 0;
|
|
85646
|
+
const scrollTop = __privateGet$1(this, _visibleHost).scrollTop ?? 0;
|
|
85562
85647
|
const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
|
|
85563
85648
|
const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
|
|
85564
85649
|
const pageLocalY = rect2.y - rect2.pageIndex * (pageHeight + pageGap);
|
|
85565
85650
|
const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect2.pageIndex, rect2.x, pageLocalY);
|
|
85566
|
-
if (!coords)
|
|
85567
|
-
return null;
|
|
85568
|
-
}
|
|
85651
|
+
if (!coords) return null;
|
|
85569
85652
|
return {
|
|
85570
|
-
top: coords.y +
|
|
85571
|
-
bottom: coords.y +
|
|
85572
|
-
left: coords.x +
|
|
85573
|
-
right: coords.x +
|
|
85574
|
-
width: rect2.width,
|
|
85575
|
-
height: rect2.height
|
|
85653
|
+
top: coords.y * zoom - scrollTop + containerRect.top,
|
|
85654
|
+
bottom: coords.y * zoom - scrollTop + containerRect.top + rect2.height * zoom,
|
|
85655
|
+
left: coords.x * zoom - scrollLeft + containerRect.left,
|
|
85656
|
+
right: coords.x * zoom - scrollLeft + containerRect.left + rect2.width * zoom,
|
|
85657
|
+
width: rect2.width * zoom,
|
|
85658
|
+
height: rect2.height * zoom
|
|
85576
85659
|
};
|
|
85577
85660
|
}
|
|
85578
85661
|
const rects = this.getRangeRects(pos, pos);
|
|
@@ -86938,7 +87021,7 @@ updateSelection_fn = function() {
|
|
|
86938
87021
|
}
|
|
86939
87022
|
try {
|
|
86940
87023
|
__privateGet$1(this, _localSelectionLayer).innerHTML = "";
|
|
86941
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderCaretOverlay_fn).call(this, caretLayout);
|
|
87024
|
+
__privateMethod$1(this, _PresentationEditor_instances, renderCaretOverlay_fn).call(this, caretLayout, from2);
|
|
86942
87025
|
} catch (error) {
|
|
86943
87026
|
if (process$1$1.env.NODE_ENV === "development") {
|
|
86944
87027
|
console.warn("[PresentationEditor] Failed to render caret overlay:", error);
|
|
@@ -86947,9 +87030,12 @@ updateSelection_fn = function() {
|
|
|
86947
87030
|
return;
|
|
86948
87031
|
}
|
|
86949
87032
|
const rects = selectionToRects(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, from2, to) ?? [];
|
|
87033
|
+
const domStart = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, from2);
|
|
87034
|
+
const domEnd = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, to);
|
|
87035
|
+
const correctedRects = __privateMethod$1(this, _PresentationEditor_instances, applyDomCorrectionToRects_fn).call(this, rects, domStart, domEnd);
|
|
86950
87036
|
try {
|
|
86951
87037
|
__privateGet$1(this, _localSelectionLayer).innerHTML = "";
|
|
86952
|
-
__privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this,
|
|
87038
|
+
__privateMethod$1(this, _PresentationEditor_instances, renderSelectionRects_fn).call(this, correctedRects);
|
|
86953
87039
|
} catch (error) {
|
|
86954
87040
|
if (process$1$1.env.NODE_ENV === "development") {
|
|
86955
87041
|
console.warn("[PresentationEditor] Failed to render selection rects:", error);
|
|
@@ -87724,6 +87810,43 @@ getHeaderFooterPageHeight_fn = function() {
|
|
|
87724
87810
|
}
|
|
87725
87811
|
return context.layout.pageSize?.h ?? context.region.height ?? 1;
|
|
87726
87812
|
};
|
|
87813
|
+
applyDomCorrectionToRects_fn = function(rects, domStart, domEnd) {
|
|
87814
|
+
if (rects.length === 0) return rects;
|
|
87815
|
+
const pageDelta = {};
|
|
87816
|
+
if (domStart && rects[0] && domStart.pageIndex === rects[0].pageIndex) {
|
|
87817
|
+
const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
|
|
87818
|
+
const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
|
|
87819
|
+
const layoutY = rects[0].y - rects[0].pageIndex * (pageHeight + pageGap);
|
|
87820
|
+
pageDelta[domStart.pageIndex] = {
|
|
87821
|
+
dx: domStart.x - rects[0].x,
|
|
87822
|
+
dy: domStart.y - layoutY
|
|
87823
|
+
};
|
|
87824
|
+
}
|
|
87825
|
+
return rects.map((rect, idx) => {
|
|
87826
|
+
const delta = pageDelta[rect.pageIndex];
|
|
87827
|
+
let adjustedX = delta ? rect.x + delta.dx : rect.x;
|
|
87828
|
+
let adjustedY = delta ? rect.y + delta.dy : rect.y;
|
|
87829
|
+
let adjustedWidth = rect.width;
|
|
87830
|
+
const isFirstRect = idx === 0;
|
|
87831
|
+
const isLastRect = idx === rects.length - 1;
|
|
87832
|
+
if (isFirstRect && domStart && rect.pageIndex === domStart.pageIndex) {
|
|
87833
|
+
const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
|
|
87834
|
+
const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
|
|
87835
|
+
adjustedX = domStart.x;
|
|
87836
|
+
adjustedY = domStart.y + rect.pageIndex * (pageHeight + pageGap);
|
|
87837
|
+
}
|
|
87838
|
+
if (isLastRect && domEnd && rect.pageIndex === domEnd.pageIndex) {
|
|
87839
|
+
const endX = domEnd.x;
|
|
87840
|
+
adjustedWidth = Math.max(1, endX - adjustedX);
|
|
87841
|
+
}
|
|
87842
|
+
return {
|
|
87843
|
+
...rect,
|
|
87844
|
+
x: adjustedX,
|
|
87845
|
+
y: adjustedY,
|
|
87846
|
+
width: adjustedWidth
|
|
87847
|
+
};
|
|
87848
|
+
});
|
|
87849
|
+
};
|
|
87727
87850
|
renderSelectionRects_fn = function(rects) {
|
|
87728
87851
|
const localSelectionLayer = __privateGet$1(this, _localSelectionLayer);
|
|
87729
87852
|
if (!localSelectionLayer) {
|
|
@@ -87731,7 +87854,7 @@ renderSelectionRects_fn = function(rects) {
|
|
|
87731
87854
|
}
|
|
87732
87855
|
const pageHeight = __privateMethod$1(this, _PresentationEditor_instances, getBodyPageHeight_fn).call(this);
|
|
87733
87856
|
const pageGap = __privateGet$1(this, _layoutState).layout?.pageGap ?? 0;
|
|
87734
|
-
rects.forEach((rect
|
|
87857
|
+
rects.forEach((rect) => {
|
|
87735
87858
|
const pageLocalY = rect.y - rect.pageIndex * (pageHeight + pageGap);
|
|
87736
87859
|
const coords = __privateMethod$1(this, _PresentationEditor_instances, convertPageLocalToOverlayCoords_fn).call(this, rect.pageIndex, rect.x, pageLocalY);
|
|
87737
87860
|
if (!coords) {
|
|
@@ -87784,7 +87907,7 @@ clearHoverRegion_fn = function() {
|
|
|
87784
87907
|
__privateGet$1(this, _hoverTooltip).style.display = "none";
|
|
87785
87908
|
}
|
|
87786
87909
|
};
|
|
87787
|
-
renderCaretOverlay_fn = function(caretLayout) {
|
|
87910
|
+
renderCaretOverlay_fn = function(caretLayout, pos) {
|
|
87788
87911
|
if (!__privateGet$1(this, _localSelectionLayer)) {
|
|
87789
87912
|
return;
|
|
87790
87913
|
}
|
|
@@ -87996,6 +88119,46 @@ convertPageLocalToOverlayCoords_fn = function(pageIndex, pageLocalX, pageLocalY)
|
|
|
87996
88119
|
y: pageIndex * (pageHeight + pageGap) + pageLocalY
|
|
87997
88120
|
};
|
|
87998
88121
|
};
|
|
88122
|
+
computeDomCaretPageLocal_fn = function(pos) {
|
|
88123
|
+
__privateGet$1(this, _viewportHost).querySelector(`.superdoc-page span[data-pm-start][data-pm-end]`) ? __privateGet$1(this, _viewportHost).querySelector(`.superdoc-page`) : null;
|
|
88124
|
+
const spans = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll("span[data-pm-start][data-pm-end]"));
|
|
88125
|
+
let targetSpan = null;
|
|
88126
|
+
for (const span of spans) {
|
|
88127
|
+
const pmStart2 = Number(span.dataset.pmStart ?? "NaN");
|
|
88128
|
+
const pmEnd = Number(span.dataset.pmEnd ?? "NaN");
|
|
88129
|
+
if (!Number.isFinite(pmStart2) || !Number.isFinite(pmEnd)) continue;
|
|
88130
|
+
if (pos < pmStart2 || pos > pmEnd) continue;
|
|
88131
|
+
targetSpan = span;
|
|
88132
|
+
break;
|
|
88133
|
+
}
|
|
88134
|
+
if (!targetSpan) return null;
|
|
88135
|
+
const page = targetSpan.closest(".superdoc-page");
|
|
88136
|
+
if (!page) return null;
|
|
88137
|
+
const pageRect = page.getBoundingClientRect();
|
|
88138
|
+
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
88139
|
+
const textNode = targetSpan.firstChild;
|
|
88140
|
+
if (!textNode || textNode.nodeType !== Node.TEXT_NODE) {
|
|
88141
|
+
const spanRect = targetSpan.getBoundingClientRect();
|
|
88142
|
+
return {
|
|
88143
|
+
pageIndex: Number(page.dataset.pageIndex ?? "0"),
|
|
88144
|
+
x: (spanRect.left - pageRect.left) / zoom,
|
|
88145
|
+
y: (spanRect.top - pageRect.top) / zoom
|
|
88146
|
+
};
|
|
88147
|
+
}
|
|
88148
|
+
const pmStart = Number(targetSpan.dataset.pmStart ?? "NaN");
|
|
88149
|
+
const charIndex = Math.min(pos - pmStart, textNode.length);
|
|
88150
|
+
const range2 = document.createRange();
|
|
88151
|
+
range2.setStart(textNode, Math.max(0, charIndex));
|
|
88152
|
+
range2.setEnd(textNode, Math.max(0, charIndex));
|
|
88153
|
+
const rangeRect = range2.getBoundingClientRect();
|
|
88154
|
+
const lineEl = targetSpan.closest(".superdoc-line");
|
|
88155
|
+
const lineRect = lineEl?.getBoundingClientRect() ?? rangeRect;
|
|
88156
|
+
return {
|
|
88157
|
+
pageIndex: Number(page.dataset.pageIndex ?? "0"),
|
|
88158
|
+
x: (rangeRect.left - pageRect.left) / zoom,
|
|
88159
|
+
y: (lineRect.top - pageRect.top) / zoom
|
|
88160
|
+
};
|
|
88161
|
+
};
|
|
87999
88162
|
normalizeClientPoint_fn = function(clientX, clientY) {
|
|
88000
88163
|
if (!Number.isFinite(clientX) || !Number.isFinite(clientY)) {
|
|
88001
88164
|
return null;
|
|
@@ -88009,13 +88172,9 @@ normalizeClientPoint_fn = function(clientX, clientY) {
|
|
|
88009
88172
|
y: (clientY - rect.top + scrollTop) / zoom
|
|
88010
88173
|
};
|
|
88011
88174
|
};
|
|
88012
|
-
|
|
88175
|
+
computeCaretLayoutRectGeometry_fn = function(pos, includeDomFallback = true) {
|
|
88013
88176
|
const layout = __privateGet$1(this, _layoutState).layout;
|
|
88014
88177
|
if (!layout) return null;
|
|
88015
|
-
const domResult = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectFromDOM_fn).call(this, pos);
|
|
88016
|
-
if (domResult) {
|
|
88017
|
-
return domResult;
|
|
88018
|
-
}
|
|
88019
88178
|
const hit = getFragmentAtPosition(layout, __privateGet$1(this, _layoutState).blocks, __privateGet$1(this, _layoutState).measures, pos);
|
|
88020
88179
|
if (!hit) {
|
|
88021
88180
|
return null;
|
|
@@ -88037,101 +88196,75 @@ computeCaretLayoutRect_fn = function(pos) {
|
|
|
88037
88196
|
const { line, index: index2 } = lineInfo;
|
|
88038
88197
|
const range2 = computeLinePmRange(block, line);
|
|
88039
88198
|
if (range2.pmStart == null || range2.pmEnd == null) return null;
|
|
88040
|
-
const
|
|
88041
|
-
const
|
|
88042
|
-
const
|
|
88199
|
+
const pmOffset = pmPosToCharOffset(block, line, pos);
|
|
88200
|
+
const markerWidth = fragment.markerWidth ?? measure.marker?.markerWidth ?? 0;
|
|
88201
|
+
const paraIndentLeft = block.attrs?.indent?.left ?? 0;
|
|
88202
|
+
const paraIndentRight = block.attrs?.indent?.right ?? 0;
|
|
88203
|
+
const availableWidth = Math.max(0, fragment.width - (paraIndentLeft + paraIndentRight));
|
|
88204
|
+
const charX = measureCharacterX(block, line, pmOffset, availableWidth);
|
|
88205
|
+
const firstLineOffset = (block.attrs?.indent?.firstLine ?? 0) - (block.attrs?.indent?.hanging ?? 0);
|
|
88206
|
+
const isFirstLine = index2 === fragment.fromLine;
|
|
88207
|
+
const isListFirstLine = isFirstLine && !fragment.continuesFromPrev && (fragment.markerWidth ?? 0) > 0;
|
|
88208
|
+
let indentAdjust = 0;
|
|
88209
|
+
if (!isListFirstLine) {
|
|
88210
|
+
indentAdjust = paraIndentLeft + (isFirstLine ? firstLineOffset : 0);
|
|
88211
|
+
}
|
|
88212
|
+
const localX = fragment.x + markerWidth + indentAdjust + charX;
|
|
88043
88213
|
const lineOffset = __privateMethod$1(this, _PresentationEditor_instances, lineHeightBeforeIndex_fn).call(this, measure.lines, fragment.fromLine, index2);
|
|
88044
88214
|
const localY = fragment.y + lineOffset;
|
|
88045
|
-
|
|
88215
|
+
const result = {
|
|
88046
88216
|
pageIndex: hit.pageIndex,
|
|
88047
88217
|
x: localX,
|
|
88048
88218
|
y: localY,
|
|
88049
88219
|
height: line.lineHeight
|
|
88050
88220
|
};
|
|
88051
|
-
|
|
88052
|
-
|
|
88053
|
-
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
88054
|
-
let targetPageEl = null;
|
|
88055
|
-
if (__privateGet$1(this, _layoutState).layout && __privateGet$1(this, _layoutState).blocks && __privateGet$1(this, _layoutState).measures) {
|
|
88056
|
-
const fragmentHit = getFragmentAtPosition(
|
|
88057
|
-
__privateGet$1(this, _layoutState).layout,
|
|
88058
|
-
__privateGet$1(this, _layoutState).blocks,
|
|
88059
|
-
__privateGet$1(this, _layoutState).measures,
|
|
88060
|
-
pos
|
|
88061
|
-
);
|
|
88062
|
-
if (fragmentHit) {
|
|
88063
|
-
const pageEl = __privateGet$1(this, _viewportHost).querySelector(
|
|
88064
|
-
`.superdoc-page[data-page-index="${fragmentHit.pageIndex}"]`
|
|
88065
|
-
);
|
|
88066
|
-
if (pageEl) {
|
|
88067
|
-
targetPageEl = pageEl;
|
|
88068
|
-
}
|
|
88069
|
-
}
|
|
88070
|
-
}
|
|
88071
|
-
const spanEls = Array.from(
|
|
88072
|
-
targetPageEl ? targetPageEl.querySelectorAll(`span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`) : __privateGet$1(this, _viewportHost).querySelectorAll(
|
|
88073
|
-
`span[data-pm-start][data-pm-end]:not(.${DOM_CLASS_NAMES.INLINE_SDT_WRAPPER})`
|
|
88074
|
-
)
|
|
88221
|
+
const pageEl = __privateGet$1(this, _painterHost)?.querySelector(
|
|
88222
|
+
`.superdoc-page[data-page-index="${hit.pageIndex}"]`
|
|
88075
88223
|
);
|
|
88224
|
+
const pageRect = pageEl?.getBoundingClientRect();
|
|
88225
|
+
const zoom = __privateGet$1(this, _layoutOptions).zoom ?? 1;
|
|
88226
|
+
let domCaretX = null;
|
|
88227
|
+
let domCaretY = null;
|
|
88228
|
+
const spanEls = pageEl?.querySelectorAll("span[data-pm-start][data-pm-end]") ?? [];
|
|
88076
88229
|
for (const spanEl of spanEls) {
|
|
88077
|
-
const pmStart = Number(spanEl.dataset.pmStart
|
|
88078
|
-
const pmEnd = Number(spanEl.dataset.pmEnd
|
|
88079
|
-
if (
|
|
88080
|
-
|
|
88081
|
-
|
|
88082
|
-
|
|
88083
|
-
|
|
88084
|
-
|
|
88085
|
-
|
|
88086
|
-
|
|
88087
|
-
|
|
88088
|
-
|
|
88089
|
-
pageIndex,
|
|
88090
|
-
x: (spanRect2.left - pageRect.left) / zoom,
|
|
88091
|
-
y: (spanRect2.top - pageRect.top) / zoom,
|
|
88092
|
-
height: spanRect2.height / zoom
|
|
88093
|
-
};
|
|
88094
|
-
}
|
|
88095
|
-
const text = textNode.textContent ?? "";
|
|
88096
|
-
const charOffset = Math.max(0, Math.min(text.length, pos - pmStart));
|
|
88097
|
-
const range2 = document.createRange();
|
|
88098
|
-
try {
|
|
88099
|
-
range2.setStart(textNode, charOffset);
|
|
88100
|
-
range2.setEnd(textNode, charOffset);
|
|
88101
|
-
} catch (error) {
|
|
88102
|
-
if (process$1$1.env.NODE_ENV === "development") {
|
|
88103
|
-
console.warn("[PresentationEditor] Range.setStart/setEnd failed:", {
|
|
88104
|
-
error: error instanceof Error ? error.message : String(error),
|
|
88105
|
-
charOffset,
|
|
88106
|
-
textLength: text.length,
|
|
88107
|
-
pos,
|
|
88108
|
-
pmStart,
|
|
88109
|
-
pmEnd
|
|
88110
|
-
});
|
|
88230
|
+
const pmStart = Number(spanEl.dataset.pmStart);
|
|
88231
|
+
const pmEnd = Number(spanEl.dataset.pmEnd);
|
|
88232
|
+
if (pos >= pmStart && pos <= pmEnd && spanEl.firstChild?.nodeType === Node.TEXT_NODE) {
|
|
88233
|
+
const textNode = spanEl.firstChild;
|
|
88234
|
+
const charIndex = Math.min(pos - pmStart, textNode.length);
|
|
88235
|
+
const rangeObj = document.createRange();
|
|
88236
|
+
rangeObj.setStart(textNode, charIndex);
|
|
88237
|
+
rangeObj.setEnd(textNode, charIndex);
|
|
88238
|
+
const rangeRect = rangeObj.getBoundingClientRect();
|
|
88239
|
+
if (pageRect) {
|
|
88240
|
+
domCaretX = (rangeRect.left - pageRect.left) / zoom;
|
|
88241
|
+
domCaretY = (rangeRect.top - pageRect.top) / zoom;
|
|
88111
88242
|
}
|
|
88112
|
-
|
|
88113
|
-
return {
|
|
88114
|
-
pageIndex,
|
|
88115
|
-
x: (spanRect2.left - pageRect.left) / zoom,
|
|
88116
|
-
y: (spanRect2.top - pageRect.top) / zoom,
|
|
88117
|
-
height: spanRect2.height / zoom
|
|
88118
|
-
};
|
|
88243
|
+
break;
|
|
88119
88244
|
}
|
|
88120
|
-
|
|
88121
|
-
|
|
88122
|
-
const lineEl = spanEl.closest(".superdoc-line");
|
|
88123
|
-
const lineRect = lineEl ? lineEl.getBoundingClientRect() : spanRect;
|
|
88124
|
-
const caretHeight = spanRect.height;
|
|
88125
|
-
const verticalOffset = (lineRect.height - caretHeight) / 2;
|
|
88126
|
-
const caretY = lineRect.top + verticalOffset;
|
|
88245
|
+
}
|
|
88246
|
+
if (includeDomFallback && domCaretX != null && domCaretY != null) {
|
|
88127
88247
|
return {
|
|
88128
|
-
pageIndex,
|
|
88129
|
-
x:
|
|
88130
|
-
y:
|
|
88131
|
-
height:
|
|
88248
|
+
pageIndex: hit.pageIndex,
|
|
88249
|
+
x: domCaretX,
|
|
88250
|
+
y: domCaretY,
|
|
88251
|
+
height: line.lineHeight
|
|
88132
88252
|
};
|
|
88133
88253
|
}
|
|
88134
|
-
return
|
|
88254
|
+
return result;
|
|
88255
|
+
};
|
|
88256
|
+
computeCaretLayoutRect_fn = function(pos) {
|
|
88257
|
+
const geometry = __privateMethod$1(this, _PresentationEditor_instances, computeCaretLayoutRectGeometry_fn).call(this, pos, true);
|
|
88258
|
+
const dom = __privateMethod$1(this, _PresentationEditor_instances, computeDomCaretPageLocal_fn).call(this, pos);
|
|
88259
|
+
if (dom && geometry) {
|
|
88260
|
+
return {
|
|
88261
|
+
pageIndex: dom.pageIndex,
|
|
88262
|
+
x: dom.x,
|
|
88263
|
+
y: dom.y,
|
|
88264
|
+
height: geometry.height
|
|
88265
|
+
};
|
|
88266
|
+
}
|
|
88267
|
+
return geometry;
|
|
88135
88268
|
};
|
|
88136
88269
|
computeTableCaretLayoutRect_fn = function(pos, _fragment, _tableBlock, _tableMeasure, pageIndex) {
|
|
88137
88270
|
const lineEls = Array.from(__privateGet$1(this, _viewportHost).querySelectorAll(".superdoc-line"));
|