superdoc 1.0.0-beta.60 → 1.0.0-beta.62
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-4-HewDUK.cjs → PdfViewer-Dm3bZ_1B.cjs} +1 -1
- package/dist/chunks/{PdfViewer-C4HeazGQ.es.js → PdfViewer-rmkhzY1H.es.js} +1 -1
- package/dist/chunks/{index-BKfoD32c.es.js → index-5vPj3xiM.es.js} +13 -6
- package/dist/chunks/{index-9qSCXVF1.cjs → index-VQNmJYMh.cjs} +13 -6
- package/dist/chunks/{index-GAzIoyrZ-C17wg4bM.cjs → index-XOsGE2PW-BL-ekicF.cjs} +1 -1
- package/dist/chunks/{index-GAzIoyrZ-zhiF5zMK.es.js → index-XOsGE2PW-hNAnvmsK.es.js} +1 -1
- package/dist/chunks/{super-editor.es-CJ3Aw1GR.es.js → super-editor.es-BIEE4joF.es.js} +756 -144
- package/dist/chunks/{super-editor.es-DCHFBNql.cjs → super-editor.es-CxtR72x8.cjs} +756 -144
- package/dist/packages/superdoc/src/core/SuperDoc.d.ts.map +1 -1
- package/dist/style.css +44 -56
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-DZ7Tkh7u.js → converter-Bo9KIIo_.js} +165 -47
- package/dist/super-editor/chunks/{docx-zipper-CZQWEuyi.js → docx-zipper-Cw0Rbwvk.js} +1 -1
- package/dist/super-editor/chunks/{editor-CDMuD1Nx.js → editor-v-i8Oo_X.js} +531 -36
- package/dist/super-editor/chunks/{index-GAzIoyrZ.js → index-XOsGE2PW.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-DL3rTlKm.js → toolbar-CiKH0Ttu.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/style.css +17 -29
- package/dist/super-editor/super-editor.es.js +96 -94
- 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 +768 -149
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -12,8 +12,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
|
|
|
12
12
|
var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, dispatchWithFallback_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, getPluginKeyName_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, checkFonts_fn, determineUnsupportedFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _map, _editor2, _descriptors, _collections, _editorEntries, _maxCachedEditors, _editorAccessOrder, _pendingCreations, _cacheHits, _cacheMisses, _evictions, _HeaderFooterEditorManager_instances, hasConverter_fn, extractCollections_fn, collectDescriptors_fn, teardownMissingEditors_fn, teardownEditors_fn, createEditor_fn, createEditorContainer_fn, registerConverterEditor_fn, unregisterConverterEditor_fn, updateAccessOrder_fn, enforceCacheSizeLimit_fn, _manager, _mediaFiles, _blockCache, _HeaderFooterLayoutAdapter_instances, getBlocks_fn, getConverterContext_fn, _selectionOverlay, _activeEditorHost, _activeDecorationContainer, _activeRegion, _borderLine, _dimmingOverlay, _EditorOverlayManager_instances, findDecorationContainer_fn, ensureEditorHost_fn, positionEditorHost_fn, hideDimmingOverlay_fn, showHeaderFooterBorder_fn, hideHeaderFooterBorder_fn, _instances, _options, _editor3, _visibleHost, _viewportHost, _painterHost, _selectionOverlay2, _hiddenHost, _layoutOptions, _layoutState, _domPainter, _dragHandlerCleanup, _layoutError, _layoutErrorState, _errorBanner, _errorBannerMessage, _telemetryEmitter, _renderScheduled, _pendingDocChange, _isRerendering, _selectionUpdateScheduled, _remoteCursorUpdateScheduled, _rafHandle, _editorListeners, _sectionMetadata, _documentMode, _inputBridge, _trackedChangesMode, _trackedChangesEnabled, _trackedChangesOverrides, _headerFooterManager, _headerFooterAdapter, _headerFooterIdentifier, _multiSectionIdentifier, _headerLayoutResults, _footerLayoutResults, _headerLayoutsByRId, _footerLayoutsByRId, _headerDecorationProvider, _footerDecorationProvider, _headerFooterManagerCleanups, _headerRegions, _footerRegions, _session, _activeHeaderFooterEditor, _overlayManager, _hoverOverlay, _hoverTooltip, _modeBanner, _ariaLiveRegion, _hoverRegion, _clickCount, _lastClickTime, _lastClickPosition, _lastSelectedImageBlockId, _dragAnchor, _isDragging, _dragExtensionMode, _remoteCursorState, _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, computeCaretLayoutRect_fn, computeCaretLayoutRectFromDOM_fn, computeTableCaretLayoutRect_fn, findLineContainingPos_fn, lineHeightBeforeIndex_fn, getCurrentPageIndex_fn, findRegionForPage_fn, handleLayoutError_fn, decorateError_fn, showLayoutErrorBanner_fn, dismissErrorBanner_fn, createHiddenHost_fn, _windowRoot, _layoutSurfaces, _getTargetDom, _isEditable, _onTargetChanged, _listeners, _currentTarget, _destroyed, _useWindowFallback, _PresentationInputBridge_instances, addListener_fn, dispatchToTarget_fn, forwardKeyboardEvent_fn, forwardTextEvent_fn, forwardCompositionEvent_fn, forwardContextMenu_fn, isEventOnActiveTarget_fn, shouldSkipSurface_fn, isInLayoutSurface_fn, getListenerTargets_fn, isPlainCharacterKey_fn, _DocumentSectionView_instances, init_fn2, addToolTip_fn, _ParagraphNodeView_instances, checkShouldUpdate_fn, updateHTMLAttributes_fn, updateDOMStyles_fn, resolveNeighborParagraphProperties_fn, updateListStyles_fn, initList_fn, checkIsList_fn, createMarker_fn, createSeparator_fn, calculateTabSeparatorStyle_fn, calculateMarkerStyle_fn, removeList_fn, getParagraphContext_fn, scheduleAnimation_fn, cancelScheduledAnimation_fn, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _VectorShapeView_instances, ensureParentPositioned_fn, _ShapeGroupView_instances, ensureParentPositioned_fn2;
|
|
13
13
|
import * as Y from "yjs";
|
|
14
14
|
import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
|
|
15
|
-
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as resolveParagraphProperties, ak as _getReferencedTableStyles, al as parseSizeUnit, am as minMax, an as updateDOMAttributes, ao as findChildren$5, ap as generateRandomSigned32BitIntStrId, aq as decodeRPrFromMarks, ar as calculateResolvedParagraphProperties, as as resolveRunProperties, at as encodeCSSFromPPr, au as twipsToPixels$2, av as encodeCSSFromRPr, aw as generateOrderedListIndex, ax as docxNumberingHelpers, ay as InputRule, az as convertSizeToCSS, aA as SelectionRange, aB as Transform, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-
|
|
16
|
-
import { D as DocxZipper } from "./docx-zipper-
|
|
15
|
+
import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as htmlHandler, E as ReplaceStep, G as twipsToInches, H as inchesToTwips, I as ptToTwips, J as getResolvedParagraphProperties, K as linesToTwips, L as changeListLevel, O as findParentNode, Q as isList, U as updateNumberingProperties, V as ListHelpers, W as isMacOS, X as isIOS, Y as getSchemaTypeByName, Z as inputRulesPlugin, _ as TrackDeleteMarkName$1, $ as TrackInsertMarkName$1, a0 as v4, a1 as TrackFormatMarkName$1, a2 as comments_module_events, a3 as findMark, a4 as objectIncludes, a5 as AddMarkStep, a6 as RemoveMarkStep, a7 as twipsToLines, a8 as pixelsToTwips, a9 as helpers, aa as posToDOMRect, ab as CommandService, ac as SuperConverter, ad as createDocument, ae as createDocFromMarkdown, af as createDocFromHTML, ag as EditorState, ah as isActive, ai as unflattenListsInHtml, aj as resolveParagraphProperties, ak as _getReferencedTableStyles, al as parseSizeUnit, am as minMax, an as updateDOMAttributes, ao as findChildren$5, ap as generateRandomSigned32BitIntStrId, aq as decodeRPrFromMarks, ar as calculateResolvedParagraphProperties, as as resolveRunProperties, at as encodeCSSFromPPr, au as twipsToPixels$2, av as encodeCSSFromRPr, aw as generateOrderedListIndex, ax as docxNumberingHelpers, ay as InputRule, az as convertSizeToCSS, aA as SelectionRange, aB as Transform, aC as findParentNodeClosestToPos, aD as isInTable$1, aE as generateDocxRandomId, aF as insertNewRelationship, aG as inchesToPixels, aH as kebabCase, aI as getUnderlineCssString } from "./converter-Bo9KIIo_.js";
|
|
16
|
+
import { D as DocxZipper } from "./docx-zipper-Cw0Rbwvk.js";
|
|
17
17
|
import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
|
|
18
18
|
var GOOD_LEAF_SIZE = 200;
|
|
19
19
|
var RopeSequence = function RopeSequence2() {
|
|
@@ -13923,7 +13923,7 @@ const isHeadless = (editor) => {
|
|
|
13923
13923
|
const shouldSkipNodeView = (editor) => {
|
|
13924
13924
|
return isHeadless(editor);
|
|
13925
13925
|
};
|
|
13926
|
-
const summaryVersion = "1.0.0-beta.
|
|
13926
|
+
const summaryVersion = "1.0.0-beta.62";
|
|
13927
13927
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
13928
13928
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
13929
13929
|
function mapAttributes(attrs) {
|
|
@@ -14715,7 +14715,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14715
14715
|
{ default: remarkStringify },
|
|
14716
14716
|
{ default: remarkGfm }
|
|
14717
14717
|
] = await Promise.all([
|
|
14718
|
-
import("./index-
|
|
14718
|
+
import("./index-XOsGE2PW.js"),
|
|
14719
14719
|
import("./index-DRCvimau.js"),
|
|
14720
14720
|
import("./index-C_x_N6Uh.js"),
|
|
14721
14721
|
import("./index-D_sWOSiG.js"),
|
|
@@ -14920,7 +14920,7 @@ const _Editor = class _Editor extends EventEmitter {
|
|
|
14920
14920
|
* Process collaboration migrations
|
|
14921
14921
|
*/
|
|
14922
14922
|
processCollaborationMigrations() {
|
|
14923
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
14923
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.62");
|
|
14924
14924
|
if (!this.options.ydoc) return;
|
|
14925
14925
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
14926
14926
|
let docVersion = metaMap.get("version");
|
|
@@ -18981,12 +18981,6 @@ const Engines = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePrope
|
|
|
18981
18981
|
resolveSpacingIndent: resolveSpacingIndent$1,
|
|
18982
18982
|
scaleWrapPolygon
|
|
18983
18983
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
18984
|
-
const extractHeaderFooterSpace = (margins) => {
|
|
18985
|
-
return {
|
|
18986
|
-
headerSpace: margins?.header ?? 0,
|
|
18987
|
-
footerSpace: margins?.footer ?? 0
|
|
18988
|
-
};
|
|
18989
|
-
};
|
|
18990
18984
|
const hasParagraphStyleContext = (context) => {
|
|
18991
18985
|
return Boolean(context?.docx);
|
|
18992
18986
|
};
|
|
@@ -26174,6 +26168,408 @@ function assertFragmentPmPositions(fragment, _context) {
|
|
|
26174
26168
|
const hasPmEnd = fragment.pmEnd != null;
|
|
26175
26169
|
globalValidationStats.record(hasPmStart, hasPmEnd);
|
|
26176
26170
|
}
|
|
26171
|
+
const DEFAULT_PPI = 96;
|
|
26172
|
+
const DEFAULT_RULER_HEIGHT = 25;
|
|
26173
|
+
const TICK_SPACING_PX = DEFAULT_PPI / 8;
|
|
26174
|
+
function generateRulerDefinition(config) {
|
|
26175
|
+
const ppi = config.ppi ?? DEFAULT_PPI;
|
|
26176
|
+
const heightPx = config.heightPx ?? DEFAULT_RULER_HEIGHT;
|
|
26177
|
+
const { pageSize, pageMargins } = config;
|
|
26178
|
+
if (!Number.isFinite(ppi) || ppi <= 0) {
|
|
26179
|
+
throw new Error(`Invalid PPI: ${ppi}. Must be a positive finite number.`);
|
|
26180
|
+
}
|
|
26181
|
+
if (!Number.isFinite(pageSize.width) || pageSize.width <= 0) {
|
|
26182
|
+
throw new Error(`Invalid page width: ${pageSize.width}. Must be a positive finite number.`);
|
|
26183
|
+
}
|
|
26184
|
+
if (!Number.isFinite(pageSize.height) || pageSize.height <= 0) {
|
|
26185
|
+
throw new Error(`Invalid page height: ${pageSize.height}. Must be a positive finite number.`);
|
|
26186
|
+
}
|
|
26187
|
+
if (!Number.isFinite(pageMargins.left) || pageMargins.left < 0) {
|
|
26188
|
+
throw new Error(`Invalid left margin: ${pageMargins.left}. Must be a non-negative finite number.`);
|
|
26189
|
+
}
|
|
26190
|
+
if (!Number.isFinite(pageMargins.right) || pageMargins.right < 0) {
|
|
26191
|
+
throw new Error(`Invalid right margin: ${pageMargins.right}. Must be a non-negative finite number.`);
|
|
26192
|
+
}
|
|
26193
|
+
if (pageMargins.left + pageMargins.right >= pageSize.width) {
|
|
26194
|
+
throw new Error(
|
|
26195
|
+
`Invalid margins: left (${pageMargins.left}) + right (${pageMargins.right}) must be less than page width (${pageSize.width}).`
|
|
26196
|
+
);
|
|
26197
|
+
}
|
|
26198
|
+
const widthPx = pageSize.width * ppi;
|
|
26199
|
+
const ticks = [];
|
|
26200
|
+
let currentX = 0;
|
|
26201
|
+
for (let inch = 0; inch < pageSize.width; inch++) {
|
|
26202
|
+
const remaining = pageSize.width - inch;
|
|
26203
|
+
ticks.push({
|
|
26204
|
+
size: "main",
|
|
26205
|
+
height: "20%",
|
|
26206
|
+
label: inch,
|
|
26207
|
+
x: currentX
|
|
26208
|
+
});
|
|
26209
|
+
currentX += TICK_SPACING_PX;
|
|
26210
|
+
for (let i = 0; i < 3; i++) {
|
|
26211
|
+
ticks.push({
|
|
26212
|
+
size: "eighth",
|
|
26213
|
+
height: "10%",
|
|
26214
|
+
x: currentX
|
|
26215
|
+
});
|
|
26216
|
+
currentX += TICK_SPACING_PX;
|
|
26217
|
+
}
|
|
26218
|
+
ticks.push({
|
|
26219
|
+
size: "half",
|
|
26220
|
+
height: "40%",
|
|
26221
|
+
x: currentX
|
|
26222
|
+
});
|
|
26223
|
+
currentX += TICK_SPACING_PX;
|
|
26224
|
+
if (remaining <= 0.5) break;
|
|
26225
|
+
for (let i = 0; i < 3; i++) {
|
|
26226
|
+
ticks.push({
|
|
26227
|
+
size: "eighth",
|
|
26228
|
+
height: "10%",
|
|
26229
|
+
x: currentX
|
|
26230
|
+
});
|
|
26231
|
+
currentX += TICK_SPACING_PX;
|
|
26232
|
+
}
|
|
26233
|
+
}
|
|
26234
|
+
return {
|
|
26235
|
+
widthPx,
|
|
26236
|
+
heightPx,
|
|
26237
|
+
ticks,
|
|
26238
|
+
leftMarginPx: pageMargins.left * ppi,
|
|
26239
|
+
rightMarginPx: widthPx - pageMargins.right * ppi,
|
|
26240
|
+
pageWidthInches: pageSize.width
|
|
26241
|
+
};
|
|
26242
|
+
}
|
|
26243
|
+
function calculateMarginFromHandle(handleX, side, pageWidthPx, ppi = DEFAULT_PPI) {
|
|
26244
|
+
if (side === "left") {
|
|
26245
|
+
return handleX / ppi;
|
|
26246
|
+
} else {
|
|
26247
|
+
return (pageWidthPx - handleX) / ppi;
|
|
26248
|
+
}
|
|
26249
|
+
}
|
|
26250
|
+
function clampHandlePosition(handleX, side, otherHandleX, pageWidthPx, minContentWidthPx = 200) {
|
|
26251
|
+
if (!Number.isFinite(handleX)) {
|
|
26252
|
+
throw new Error(`Invalid handleX: ${handleX}. Must be a finite number.`);
|
|
26253
|
+
}
|
|
26254
|
+
if (!Number.isFinite(otherHandleX)) {
|
|
26255
|
+
throw new Error(`Invalid otherHandleX: ${otherHandleX}. Must be a finite number.`);
|
|
26256
|
+
}
|
|
26257
|
+
if (!Number.isFinite(pageWidthPx)) {
|
|
26258
|
+
throw new Error(`Invalid pageWidthPx: ${pageWidthPx}. Must be a finite number.`);
|
|
26259
|
+
}
|
|
26260
|
+
if (!Number.isFinite(minContentWidthPx)) {
|
|
26261
|
+
throw new Error(`Invalid minContentWidthPx: ${minContentWidthPx}. Must be a finite number.`);
|
|
26262
|
+
}
|
|
26263
|
+
if (side === "left") {
|
|
26264
|
+
const min2 = 0;
|
|
26265
|
+
const max2 = otherHandleX - minContentWidthPx;
|
|
26266
|
+
return Math.max(min2, Math.min(max2, handleX));
|
|
26267
|
+
} else {
|
|
26268
|
+
const min2 = otherHandleX + minContentWidthPx;
|
|
26269
|
+
const max2 = pageWidthPx;
|
|
26270
|
+
return Math.max(min2, Math.min(max2, handleX));
|
|
26271
|
+
}
|
|
26272
|
+
}
|
|
26273
|
+
function generateRulerDefinitionFromPx(config) {
|
|
26274
|
+
const ppi = config.ppi ?? DEFAULT_PPI;
|
|
26275
|
+
const heightPx = config.heightPx ?? DEFAULT_RULER_HEIGHT;
|
|
26276
|
+
const { pageWidthPx, leftMarginPx, rightMarginPx } = config;
|
|
26277
|
+
if (!Number.isFinite(ppi) || ppi <= 0) {
|
|
26278
|
+
throw new Error(`Invalid PPI: ${ppi}. Must be a positive finite number.`);
|
|
26279
|
+
}
|
|
26280
|
+
if (!Number.isFinite(pageWidthPx) || pageWidthPx <= 0) {
|
|
26281
|
+
throw new Error(`Invalid page width: ${pageWidthPx}px. Must be a positive finite number.`);
|
|
26282
|
+
}
|
|
26283
|
+
if (!Number.isFinite(config.pageHeightPx) || config.pageHeightPx <= 0) {
|
|
26284
|
+
throw new Error(`Invalid page height: ${config.pageHeightPx}px. Must be a positive finite number.`);
|
|
26285
|
+
}
|
|
26286
|
+
if (!Number.isFinite(leftMarginPx) || leftMarginPx < 0) {
|
|
26287
|
+
throw new Error(`Invalid left margin: ${leftMarginPx}px. Must be a non-negative finite number.`);
|
|
26288
|
+
}
|
|
26289
|
+
if (!Number.isFinite(rightMarginPx) || rightMarginPx < 0) {
|
|
26290
|
+
throw new Error(`Invalid right margin: ${rightMarginPx}px. Must be a non-negative finite number.`);
|
|
26291
|
+
}
|
|
26292
|
+
if (leftMarginPx + rightMarginPx >= pageWidthPx) {
|
|
26293
|
+
throw new Error(
|
|
26294
|
+
`Invalid margins: left (${leftMarginPx}px) + right (${rightMarginPx}px) must be less than page width (${pageWidthPx}px).`
|
|
26295
|
+
);
|
|
26296
|
+
}
|
|
26297
|
+
const pageWidthInches = pageWidthPx / ppi;
|
|
26298
|
+
const ticks = [];
|
|
26299
|
+
let currentX = 0;
|
|
26300
|
+
for (let inch = 0; inch < pageWidthInches; inch++) {
|
|
26301
|
+
const remaining = pageWidthInches - inch;
|
|
26302
|
+
ticks.push({
|
|
26303
|
+
size: "main",
|
|
26304
|
+
height: "20%",
|
|
26305
|
+
label: inch,
|
|
26306
|
+
x: currentX
|
|
26307
|
+
});
|
|
26308
|
+
currentX += TICK_SPACING_PX;
|
|
26309
|
+
for (let i = 0; i < 3; i++) {
|
|
26310
|
+
ticks.push({
|
|
26311
|
+
size: "eighth",
|
|
26312
|
+
height: "10%",
|
|
26313
|
+
x: currentX
|
|
26314
|
+
});
|
|
26315
|
+
currentX += TICK_SPACING_PX;
|
|
26316
|
+
}
|
|
26317
|
+
ticks.push({
|
|
26318
|
+
size: "half",
|
|
26319
|
+
height: "40%",
|
|
26320
|
+
x: currentX
|
|
26321
|
+
});
|
|
26322
|
+
currentX += TICK_SPACING_PX;
|
|
26323
|
+
if (remaining <= 0.5) break;
|
|
26324
|
+
for (let i = 0; i < 3; i++) {
|
|
26325
|
+
ticks.push({
|
|
26326
|
+
size: "eighth",
|
|
26327
|
+
height: "10%",
|
|
26328
|
+
x: currentX
|
|
26329
|
+
});
|
|
26330
|
+
currentX += TICK_SPACING_PX;
|
|
26331
|
+
}
|
|
26332
|
+
}
|
|
26333
|
+
return {
|
|
26334
|
+
widthPx: pageWidthPx,
|
|
26335
|
+
heightPx,
|
|
26336
|
+
ticks,
|
|
26337
|
+
leftMarginPx,
|
|
26338
|
+
rightMarginPx: pageWidthPx - rightMarginPx,
|
|
26339
|
+
pageWidthInches
|
|
26340
|
+
};
|
|
26341
|
+
}
|
|
26342
|
+
const RULER_CLASS_NAMES = {
|
|
26343
|
+
/** Main ruler container */
|
|
26344
|
+
ruler: "superdoc-ruler",
|
|
26345
|
+
/** Tick mark element */
|
|
26346
|
+
tick: "superdoc-ruler-tick",
|
|
26347
|
+
/** Main (inch) tick */
|
|
26348
|
+
tickMain: "superdoc-ruler-tick--main",
|
|
26349
|
+
/** Half-inch tick */
|
|
26350
|
+
tickHalf: "superdoc-ruler-tick--half",
|
|
26351
|
+
/** Eighth-inch tick */
|
|
26352
|
+
tickEighth: "superdoc-ruler-tick--eighth",
|
|
26353
|
+
/** Inch label number */
|
|
26354
|
+
label: "superdoc-ruler-label",
|
|
26355
|
+
/** Margin handle */
|
|
26356
|
+
handle: "superdoc-ruler-handle",
|
|
26357
|
+
/** Left margin handle */
|
|
26358
|
+
handleLeft: "superdoc-ruler-handle--left",
|
|
26359
|
+
/** Right margin handle */
|
|
26360
|
+
handleRight: "superdoc-ruler-handle--right",
|
|
26361
|
+
/** Vertical indicator line during drag */
|
|
26362
|
+
indicator: "superdoc-ruler-indicator"
|
|
26363
|
+
};
|
|
26364
|
+
function createRulerElement(options) {
|
|
26365
|
+
const { definition, doc: doc2, interactive = false } = options;
|
|
26366
|
+
if (!Number.isFinite(definition.widthPx) || definition.widthPx <= 0) {
|
|
26367
|
+
console.warn(`[createRulerElement] Invalid ruler width: ${definition.widthPx}px. Using minimum width of 1px.`);
|
|
26368
|
+
definition.widthPx = Math.max(1, definition.widthPx || 1);
|
|
26369
|
+
}
|
|
26370
|
+
if (!definition.ticks || definition.ticks.length === 0) {
|
|
26371
|
+
console.warn("[createRulerElement] Ruler definition has no ticks. Ruler will be empty.");
|
|
26372
|
+
}
|
|
26373
|
+
const ruler = doc2.createElement("div");
|
|
26374
|
+
ruler.className = RULER_CLASS_NAMES.ruler;
|
|
26375
|
+
ruler.style.cssText = `
|
|
26376
|
+
position: relative;
|
|
26377
|
+
width: ${definition.widthPx}px;
|
|
26378
|
+
height: ${definition.heightPx}px;
|
|
26379
|
+
display: flex;
|
|
26380
|
+
align-items: flex-end;
|
|
26381
|
+
box-sizing: border-box;
|
|
26382
|
+
user-select: none;
|
|
26383
|
+
pointer-events: ${interactive ? "auto" : "none"};
|
|
26384
|
+
`;
|
|
26385
|
+
for (const tick of definition.ticks) {
|
|
26386
|
+
const tickEl = createTickElement(tick, doc2);
|
|
26387
|
+
ruler.appendChild(tickEl);
|
|
26388
|
+
}
|
|
26389
|
+
if (interactive) {
|
|
26390
|
+
const leftHandle = createHandleElement("left", definition.leftMarginPx, doc2, options);
|
|
26391
|
+
const rightHandle = createHandleElement("right", definition.rightMarginPx, doc2, options);
|
|
26392
|
+
ruler.appendChild(leftHandle);
|
|
26393
|
+
ruler.appendChild(rightHandle);
|
|
26394
|
+
}
|
|
26395
|
+
return ruler;
|
|
26396
|
+
}
|
|
26397
|
+
function createTickElement(tick, doc2) {
|
|
26398
|
+
const el = doc2.createElement("div");
|
|
26399
|
+
const sizeClass = tick.size === "main" ? RULER_CLASS_NAMES.tickMain : tick.size === "half" ? RULER_CLASS_NAMES.tickHalf : RULER_CLASS_NAMES.tickEighth;
|
|
26400
|
+
el.className = `${RULER_CLASS_NAMES.tick} ${sizeClass}`;
|
|
26401
|
+
el.style.cssText = `
|
|
26402
|
+
position: absolute;
|
|
26403
|
+
left: ${tick.x}px;
|
|
26404
|
+
bottom: 0;
|
|
26405
|
+
width: 1px;
|
|
26406
|
+
height: ${tick.height};
|
|
26407
|
+
background-color: #666;
|
|
26408
|
+
pointer-events: none;
|
|
26409
|
+
`;
|
|
26410
|
+
if (tick.label !== void 0) {
|
|
26411
|
+
const label = doc2.createElement("span");
|
|
26412
|
+
label.className = RULER_CLASS_NAMES.label;
|
|
26413
|
+
label.textContent = String(tick.label);
|
|
26414
|
+
label.style.cssText = `
|
|
26415
|
+
position: absolute;
|
|
26416
|
+
top: -16px;
|
|
26417
|
+
left: -2px;
|
|
26418
|
+
font-size: 10px;
|
|
26419
|
+
color: #666;
|
|
26420
|
+
pointer-events: none;
|
|
26421
|
+
user-select: none;
|
|
26422
|
+
`;
|
|
26423
|
+
el.appendChild(label);
|
|
26424
|
+
}
|
|
26425
|
+
return el;
|
|
26426
|
+
}
|
|
26427
|
+
function createHandleElement(side, x, doc2, options) {
|
|
26428
|
+
const handle = doc2.createElement("div");
|
|
26429
|
+
const sideClass = side === "left" ? RULER_CLASS_NAMES.handleLeft : RULER_CLASS_NAMES.handleRight;
|
|
26430
|
+
handle.className = `${RULER_CLASS_NAMES.handle} ${sideClass}`;
|
|
26431
|
+
handle.dataset.side = side;
|
|
26432
|
+
handle.style.cssText = `
|
|
26433
|
+
position: absolute;
|
|
26434
|
+
left: ${x}px;
|
|
26435
|
+
top: 0;
|
|
26436
|
+
width: 5px;
|
|
26437
|
+
height: 20px;
|
|
26438
|
+
margin-left: -2px;
|
|
26439
|
+
background-color: #ccc;
|
|
26440
|
+
border-radius: 4px 4px 0 0;
|
|
26441
|
+
cursor: grab;
|
|
26442
|
+
transition: background-color 150ms ease;
|
|
26443
|
+
z-index: 10;
|
|
26444
|
+
`;
|
|
26445
|
+
handle.addEventListener("mouseenter", () => {
|
|
26446
|
+
if (!handle.dataset.dragging) {
|
|
26447
|
+
handle.style.backgroundColor = "rgba(37, 99, 235, 0.4)";
|
|
26448
|
+
}
|
|
26449
|
+
});
|
|
26450
|
+
handle.addEventListener("mouseleave", () => {
|
|
26451
|
+
if (!handle.dataset.dragging) {
|
|
26452
|
+
handle.style.backgroundColor = "#ccc";
|
|
26453
|
+
}
|
|
26454
|
+
});
|
|
26455
|
+
if (options.onDragStart || options.onDrag || options.onDragEnd) {
|
|
26456
|
+
setupHandleDrag(handle, side, options);
|
|
26457
|
+
}
|
|
26458
|
+
return handle;
|
|
26459
|
+
}
|
|
26460
|
+
function setupHandleDrag(handle, side, options) {
|
|
26461
|
+
let offsetX = 0;
|
|
26462
|
+
const onPointerDown = (event) => {
|
|
26463
|
+
event.preventDefault();
|
|
26464
|
+
handle.dataset.dragging = "true";
|
|
26465
|
+
handle.style.backgroundColor = "rgba(37, 99, 235, 0.4)";
|
|
26466
|
+
handle.style.cursor = "grabbing";
|
|
26467
|
+
const rect = handle.getBoundingClientRect();
|
|
26468
|
+
offsetX = event.clientX - rect.left - rect.width / 2;
|
|
26469
|
+
handle.setPointerCapture(event.pointerId);
|
|
26470
|
+
options.onDragStart?.(side, event);
|
|
26471
|
+
};
|
|
26472
|
+
const onPointerMove = (event) => {
|
|
26473
|
+
if (handle.dataset.dragging !== "true") return;
|
|
26474
|
+
const ruler = handle.parentElement;
|
|
26475
|
+
if (!ruler) return;
|
|
26476
|
+
const rulerRect = ruler.getBoundingClientRect();
|
|
26477
|
+
const newX = event.clientX - rulerRect.left - offsetX;
|
|
26478
|
+
options.onDrag?.(side, newX, event);
|
|
26479
|
+
};
|
|
26480
|
+
const onPointerUp = (event) => {
|
|
26481
|
+
if (handle.dataset.dragging !== "true") return;
|
|
26482
|
+
handle.dataset.dragging = "";
|
|
26483
|
+
handle.style.backgroundColor = "#ccc";
|
|
26484
|
+
handle.style.cursor = "grab";
|
|
26485
|
+
handle.releasePointerCapture(event.pointerId);
|
|
26486
|
+
const ruler = handle.parentElement;
|
|
26487
|
+
if (!ruler) return;
|
|
26488
|
+
const rulerRect = ruler.getBoundingClientRect();
|
|
26489
|
+
const finalX = event.clientX - rulerRect.left - offsetX;
|
|
26490
|
+
options.onDragEnd?.(side, finalX, event);
|
|
26491
|
+
};
|
|
26492
|
+
handle.addEventListener("pointerdown", onPointerDown);
|
|
26493
|
+
handle.addEventListener("pointermove", onPointerMove);
|
|
26494
|
+
handle.addEventListener("pointerup", onPointerUp);
|
|
26495
|
+
handle.addEventListener("pointercancel", onPointerUp);
|
|
26496
|
+
}
|
|
26497
|
+
const RULER_STYLES = `
|
|
26498
|
+
/* Ruler container */
|
|
26499
|
+
.${RULER_CLASS_NAMES.ruler} {
|
|
26500
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
26501
|
+
background-color: transparent;
|
|
26502
|
+
}
|
|
26503
|
+
|
|
26504
|
+
/* Tick marks base styling */
|
|
26505
|
+
.${RULER_CLASS_NAMES.tick} {
|
|
26506
|
+
flex-shrink: 0;
|
|
26507
|
+
}
|
|
26508
|
+
|
|
26509
|
+
/* Handle hover and active states */
|
|
26510
|
+
.${RULER_CLASS_NAMES.handle}:hover {
|
|
26511
|
+
background-color: rgba(37, 99, 235, 0.4) !important;
|
|
26512
|
+
}
|
|
26513
|
+
|
|
26514
|
+
.${RULER_CLASS_NAMES.handle}:active,
|
|
26515
|
+
.${RULER_CLASS_NAMES.handle}[data-dragging="true"] {
|
|
26516
|
+
background-color: rgba(37, 99, 235, 0.6) !important;
|
|
26517
|
+
cursor: grabbing !important;
|
|
26518
|
+
}
|
|
26519
|
+
|
|
26520
|
+
/* Vertical indicator animation */
|
|
26521
|
+
.${RULER_CLASS_NAMES.indicator} {
|
|
26522
|
+
transition: left 16ms linear;
|
|
26523
|
+
}
|
|
26524
|
+
|
|
26525
|
+
/* Print mode: hide rulers */
|
|
26526
|
+
@media print {
|
|
26527
|
+
.${RULER_CLASS_NAMES.ruler} {
|
|
26528
|
+
display: none !important;
|
|
26529
|
+
}
|
|
26530
|
+
}
|
|
26531
|
+
|
|
26532
|
+
/* High contrast mode support */
|
|
26533
|
+
@media (prefers-contrast: high) {
|
|
26534
|
+
.${RULER_CLASS_NAMES.tick} {
|
|
26535
|
+
background-color: #000 !important;
|
|
26536
|
+
}
|
|
26537
|
+
|
|
26538
|
+
.${RULER_CLASS_NAMES.label} {
|
|
26539
|
+
color: #000 !important;
|
|
26540
|
+
}
|
|
26541
|
+
|
|
26542
|
+
.${RULER_CLASS_NAMES.handle} {
|
|
26543
|
+
background-color: #666 !important;
|
|
26544
|
+
border: 1px solid #000;
|
|
26545
|
+
}
|
|
26546
|
+
|
|
26547
|
+
.${RULER_CLASS_NAMES.handle}:hover,
|
|
26548
|
+
.${RULER_CLASS_NAMES.handle}:active {
|
|
26549
|
+
background-color: #0066cc !important;
|
|
26550
|
+
}
|
|
26551
|
+
}
|
|
26552
|
+
|
|
26553
|
+
/* Reduced motion support */
|
|
26554
|
+
@media (prefers-reduced-motion: reduce) {
|
|
26555
|
+
.${RULER_CLASS_NAMES.handle} {
|
|
26556
|
+
transition: none !important;
|
|
26557
|
+
}
|
|
26558
|
+
|
|
26559
|
+
.${RULER_CLASS_NAMES.indicator} {
|
|
26560
|
+
transition: none !important;
|
|
26561
|
+
}
|
|
26562
|
+
}
|
|
26563
|
+
`;
|
|
26564
|
+
let rulerStylesInjected = false;
|
|
26565
|
+
function ensureRulerStyles(doc2) {
|
|
26566
|
+
if (rulerStylesInjected || !doc2) return;
|
|
26567
|
+
const styleEl = doc2.createElement("style");
|
|
26568
|
+
styleEl.setAttribute("data-superdoc-ruler-styles", "true");
|
|
26569
|
+
styleEl.textContent = RULER_STYLES;
|
|
26570
|
+
doc2.head?.appendChild(styleEl);
|
|
26571
|
+
rulerStylesInjected = true;
|
|
26572
|
+
}
|
|
26177
26573
|
function isMinimalWordLayout(value) {
|
|
26178
26574
|
if (typeof value !== "object" || value === null) {
|
|
26179
26575
|
return false;
|
|
@@ -26220,6 +26616,7 @@ function isMinimalWordLayout(value) {
|
|
|
26220
26616
|
}
|
|
26221
26617
|
const LIST_MARKER_GAP$1 = 8;
|
|
26222
26618
|
const DEFAULT_TAB_INTERVAL_PX$1 = 48;
|
|
26619
|
+
const DEFAULT_PAGE_HEIGHT_PX = 1056;
|
|
26223
26620
|
const COMMENT_EXTERNAL_COLOR = "#B1124B";
|
|
26224
26621
|
const COMMENT_INTERNAL_COLOR = "#078383";
|
|
26225
26622
|
const COMMENT_INACTIVE_ALPHA = "22";
|
|
@@ -26462,6 +26859,9 @@ const _DomPainter = class _DomPainter {
|
|
|
26462
26859
|
ensureFieldAnnotationStyles(doc2);
|
|
26463
26860
|
ensureSdtContainerStyles(doc2);
|
|
26464
26861
|
ensureImageSelectionStyles(doc2);
|
|
26862
|
+
if (this.options.ruler?.enabled) {
|
|
26863
|
+
ensureRulerStyles(doc2);
|
|
26864
|
+
}
|
|
26465
26865
|
mount.classList.add(CLASS_NAMES$1.container);
|
|
26466
26866
|
if (this.mount && this.mount !== mount) {
|
|
26467
26867
|
this.resetState();
|
|
@@ -26719,6 +27119,12 @@ const _DomPainter = class _DomPainter {
|
|
|
26719
27119
|
const el = this.doc.createElement("div");
|
|
26720
27120
|
el.classList.add(CLASS_NAMES$1.page);
|
|
26721
27121
|
applyStyles$2(el, pageStyles(width, height, this.getEffectivePageStyles()));
|
|
27122
|
+
if (this.options.ruler?.enabled) {
|
|
27123
|
+
const rulerEl = this.renderPageRuler(width, page);
|
|
27124
|
+
if (rulerEl) {
|
|
27125
|
+
el.appendChild(rulerEl);
|
|
27126
|
+
}
|
|
27127
|
+
}
|
|
26722
27128
|
const contextBase = {
|
|
26723
27129
|
pageNumber: page.number,
|
|
26724
27130
|
totalPages: this.totalPages,
|
|
@@ -26731,6 +27137,70 @@ const _DomPainter = class _DomPainter {
|
|
|
26731
27137
|
this.renderDecorationsForPage(el, page);
|
|
26732
27138
|
return el;
|
|
26733
27139
|
}
|
|
27140
|
+
/**
|
|
27141
|
+
* Render a ruler element for a page.
|
|
27142
|
+
*
|
|
27143
|
+
* Creates a horizontal ruler with tick marks and optional interactive margin handles.
|
|
27144
|
+
* The ruler is positioned at the top of the page and displays inch measurements.
|
|
27145
|
+
*
|
|
27146
|
+
* @param pageWidthPx - Page width in pixels
|
|
27147
|
+
* @param page - Page data containing margins and optional size information
|
|
27148
|
+
* @returns Ruler element, or null if this.doc is unavailable or page margins are missing
|
|
27149
|
+
*
|
|
27150
|
+
* Side effects:
|
|
27151
|
+
* - Creates DOM elements and applies inline styles
|
|
27152
|
+
* - May invoke the onMarginChange callback if interactive mode is enabled
|
|
27153
|
+
*
|
|
27154
|
+
* Fallback behavior:
|
|
27155
|
+
* - Uses DEFAULT_PAGE_HEIGHT_PX (1056px = 11 inches) if page.size.h is not available
|
|
27156
|
+
* - Defaults margins to 0 if not explicitly provided
|
|
27157
|
+
*/
|
|
27158
|
+
renderPageRuler(pageWidthPx, page) {
|
|
27159
|
+
if (!this.doc) {
|
|
27160
|
+
console.warn("[renderPageRuler] Cannot render ruler: document is not available.");
|
|
27161
|
+
return null;
|
|
27162
|
+
}
|
|
27163
|
+
if (!page.margins) {
|
|
27164
|
+
console.warn(`[renderPageRuler] Cannot render ruler for page ${page.number}: margins not available.`);
|
|
27165
|
+
return null;
|
|
27166
|
+
}
|
|
27167
|
+
const margins = page.margins;
|
|
27168
|
+
const leftMargin = margins.left ?? 0;
|
|
27169
|
+
const rightMargin = margins.right ?? 0;
|
|
27170
|
+
try {
|
|
27171
|
+
const rulerDefinition = generateRulerDefinitionFromPx({
|
|
27172
|
+
pageWidthPx,
|
|
27173
|
+
pageHeightPx: page.size?.h ?? DEFAULT_PAGE_HEIGHT_PX,
|
|
27174
|
+
leftMarginPx: leftMargin,
|
|
27175
|
+
rightMarginPx: rightMargin
|
|
27176
|
+
});
|
|
27177
|
+
const interactive = this.options.ruler?.interactive ?? false;
|
|
27178
|
+
const onMarginChange = this.options.ruler?.onMarginChange;
|
|
27179
|
+
const rulerEl = createRulerElement({
|
|
27180
|
+
definition: rulerDefinition,
|
|
27181
|
+
doc: this.doc,
|
|
27182
|
+
interactive,
|
|
27183
|
+
onDragEnd: interactive && onMarginChange ? (side, x) => {
|
|
27184
|
+
try {
|
|
27185
|
+
const ppi = 96;
|
|
27186
|
+
const marginInches = side === "left" ? x / ppi : (pageWidthPx - x) / ppi;
|
|
27187
|
+
onMarginChange(side, marginInches);
|
|
27188
|
+
} catch (error) {
|
|
27189
|
+
console.error("[renderPageRuler] Error in onMarginChange callback:", error);
|
|
27190
|
+
}
|
|
27191
|
+
} : void 0
|
|
27192
|
+
});
|
|
27193
|
+
rulerEl.style.position = "absolute";
|
|
27194
|
+
rulerEl.style.top = "0";
|
|
27195
|
+
rulerEl.style.left = "0";
|
|
27196
|
+
rulerEl.style.zIndex = "20";
|
|
27197
|
+
rulerEl.dataset.pageNumber = String(page.number);
|
|
27198
|
+
return rulerEl;
|
|
27199
|
+
} catch (error) {
|
|
27200
|
+
console.error(`[renderPageRuler] Failed to create ruler for page ${page.number}:`, error);
|
|
27201
|
+
return null;
|
|
27202
|
+
}
|
|
27203
|
+
}
|
|
26734
27204
|
renderDecorationsForPage(pageEl, page) {
|
|
26735
27205
|
this.renderDecorationSection(pageEl, page, "header");
|
|
26736
27206
|
this.renderDecorationSection(pageEl, page, "footer");
|
|
@@ -26762,6 +27232,7 @@ const _DomPainter = class _DomPainter {
|
|
|
26762
27232
|
container.style.height = `${data.height}px`;
|
|
26763
27233
|
container.style.top = `${Math.max(0, offset2)}px`;
|
|
26764
27234
|
container.style.zIndex = "1";
|
|
27235
|
+
container.style.overflow = "visible";
|
|
26765
27236
|
let footerYOffset = 0;
|
|
26766
27237
|
if (kind === "footer" && data.fragments.length > 0) {
|
|
26767
27238
|
const contentHeight = typeof data.contentHeight === "number" ? data.contentHeight : data.fragments.reduce((max2, f2) => {
|
|
@@ -29531,7 +30002,8 @@ const createDomPainter = (options) => {
|
|
|
29531
30002
|
layoutMode: options.layoutMode,
|
|
29532
30003
|
headerProvider: options.headerProvider,
|
|
29533
30004
|
footerProvider: options.footerProvider,
|
|
29534
|
-
virtualization: options.virtualization
|
|
30005
|
+
virtualization: options.virtualization,
|
|
30006
|
+
ruler: options.ruler
|
|
29535
30007
|
});
|
|
29536
30008
|
return {
|
|
29537
30009
|
paint(layout, mount) {
|
|
@@ -35773,7 +36245,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
35773
36245
|
leftJustifiedMarkerSpace = markerBoxWidth + gutterWidth;
|
|
35774
36246
|
}
|
|
35775
36247
|
}
|
|
35776
|
-
|
|
36248
|
+
let initialAvailableWidth;
|
|
36249
|
+
const isFirstLineIndentMode = wordLayout?.firstLineIndentMode === true;
|
|
36250
|
+
const textStartPx = wordLayout?.textStartPx;
|
|
36251
|
+
if (isFirstLineIndentMode && typeof textStartPx === "number" && textStartPx > 0) {
|
|
36252
|
+
initialAvailableWidth = Math.max(1, maxWidth - textStartPx - indentRight);
|
|
36253
|
+
} else {
|
|
36254
|
+
initialAvailableWidth = Math.max(1, contentWidth - firstLineOffset - leftJustifiedMarkerSpace);
|
|
36255
|
+
}
|
|
35777
36256
|
const tabStops = buildTabStopsPx(
|
|
35778
36257
|
indent,
|
|
35779
36258
|
block.attrs?.tabs,
|
|
@@ -37796,7 +38275,9 @@ class HeaderFooterLayoutAdapter {
|
|
|
37796
38275
|
const batch = {};
|
|
37797
38276
|
let hasBlocks = false;
|
|
37798
38277
|
descriptors.forEach((descriptor) => {
|
|
37799
|
-
if (!descriptor.variant)
|
|
38278
|
+
if (!descriptor.variant) {
|
|
38279
|
+
return;
|
|
38280
|
+
}
|
|
37800
38281
|
const blocks = __privateMethod(this, _HeaderFooterLayoutAdapter_instances, getBlocks_fn).call(this, descriptor);
|
|
37801
38282
|
if (blocks && blocks.length > 0) {
|
|
37802
38283
|
batch[descriptor.variant] = blocks;
|
|
@@ -40273,9 +40754,11 @@ updateLocalAwarenessCursor_fn = function() {
|
|
|
40273
40754
|
if (typeof provider.awareness.setLocalStateField !== "function") {
|
|
40274
40755
|
return;
|
|
40275
40756
|
}
|
|
40276
|
-
const
|
|
40757
|
+
const editorState = __privateGet(this, _editor3)?.state;
|
|
40758
|
+
if (!editorState) return;
|
|
40759
|
+
const ystate = ySyncPluginKey.getState(editorState);
|
|
40277
40760
|
if (!ystate?.binding?.mapping) return;
|
|
40278
|
-
const { selection } =
|
|
40761
|
+
const { selection } = editorState;
|
|
40279
40762
|
const { anchor, head } = selection;
|
|
40280
40763
|
try {
|
|
40281
40764
|
const relAnchor = absolutePositionToRelativePosition(anchor, ystate.type, ystate.binding.mapping);
|
|
@@ -40298,7 +40781,9 @@ updateLocalAwarenessCursor_fn = function() {
|
|
|
40298
40781
|
normalizeAwarenessStates_fn = function() {
|
|
40299
40782
|
const provider = __privateGet(this, _options).collaborationProvider;
|
|
40300
40783
|
if (!provider?.awareness) return /* @__PURE__ */ new Map();
|
|
40301
|
-
const
|
|
40784
|
+
const editorState = __privateGet(this, _editor3)?.state;
|
|
40785
|
+
if (!editorState) return /* @__PURE__ */ new Map();
|
|
40786
|
+
const ystate = ySyncPluginKey.getState(editorState);
|
|
40302
40787
|
if (!ystate) return /* @__PURE__ */ new Map();
|
|
40303
40788
|
const states = provider.awareness?.getStates();
|
|
40304
40789
|
const normalized = /* @__PURE__ */ new Map();
|
|
@@ -41305,7 +41790,8 @@ ensurePainter_fn = function(blocks, measures) {
|
|
|
41305
41790
|
virtualization: __privateGet(this, _layoutOptions).virtualization,
|
|
41306
41791
|
pageStyles: __privateGet(this, _layoutOptions).pageStyles,
|
|
41307
41792
|
headerProvider: __privateGet(this, _headerDecorationProvider),
|
|
41308
|
-
footerProvider: __privateGet(this, _footerDecorationProvider)
|
|
41793
|
+
footerProvider: __privateGet(this, _footerDecorationProvider),
|
|
41794
|
+
ruler: __privateGet(this, _layoutOptions).ruler
|
|
41309
41795
|
}));
|
|
41310
41796
|
}
|
|
41311
41797
|
return __privateGet(this, _domPainter);
|
|
@@ -41511,14 +41997,20 @@ computeHeaderFooterConstraints_fn = function() {
|
|
|
41511
41997
|
const margins = __privateGet(this, _layoutOptions).margins ?? DEFAULT_MARGINS;
|
|
41512
41998
|
const marginLeft = margins.left ?? DEFAULT_MARGINS.left;
|
|
41513
41999
|
const marginRight = margins.right ?? DEFAULT_MARGINS.right;
|
|
41514
|
-
const
|
|
41515
|
-
if (!Number.isFinite(
|
|
42000
|
+
const bodyContentWidth = pageSize.w - (marginLeft + marginRight);
|
|
42001
|
+
if (!Number.isFinite(bodyContentWidth) || bodyContentWidth <= 0) {
|
|
41516
42002
|
return null;
|
|
41517
42003
|
}
|
|
41518
|
-
const
|
|
41519
|
-
const
|
|
42004
|
+
const measurementWidth = bodyContentWidth;
|
|
42005
|
+
const marginTop = margins.top ?? DEFAULT_MARGINS.top;
|
|
42006
|
+
const marginBottom = margins.bottom ?? DEFAULT_MARGINS.bottom;
|
|
42007
|
+
const headerMargin = margins.header ?? 0;
|
|
42008
|
+
const footerMargin = margins.footer ?? 0;
|
|
42009
|
+
const headerContentSpace = Math.max(marginTop - headerMargin, 0);
|
|
42010
|
+
const footerContentSpace = Math.max(marginBottom - footerMargin, 0);
|
|
42011
|
+
const height = Math.max(headerContentSpace, footerContentSpace, 1);
|
|
41520
42012
|
return {
|
|
41521
|
-
width,
|
|
42013
|
+
width: measurementWidth,
|
|
41522
42014
|
height,
|
|
41523
42015
|
// Pass actual page dimensions for page-relative anchor positioning in headers/footers
|
|
41524
42016
|
pageWidth: pageSize.w,
|
|
@@ -62420,11 +62912,14 @@ const getStarterExtensions = () => {
|
|
|
62420
62912
|
};
|
|
62421
62913
|
export {
|
|
62422
62914
|
Attribute as A,
|
|
62423
|
-
|
|
62424
|
-
|
|
62915
|
+
index$1 as B,
|
|
62916
|
+
index as C,
|
|
62425
62917
|
DecorationSet as D,
|
|
62426
62918
|
Editor as E,
|
|
62427
|
-
|
|
62919
|
+
AnnotatorHelpers as F,
|
|
62920
|
+
SectionHelpers as G,
|
|
62921
|
+
getAllowedImageDimensions as H,
|
|
62922
|
+
CommentsPluginKey as I,
|
|
62428
62923
|
Mark as M,
|
|
62429
62924
|
Node$1 as N,
|
|
62430
62925
|
PresentationEditor as P,
|
|
@@ -62443,18 +62938,18 @@ export {
|
|
|
62443
62938
|
redoDepth as j,
|
|
62444
62939
|
getEditorSurfaceElement as k,
|
|
62445
62940
|
collectTrackedChangesForContext as l,
|
|
62446
|
-
|
|
62447
|
-
|
|
62448
|
-
|
|
62449
|
-
|
|
62450
|
-
|
|
62941
|
+
generateRulerDefinition as m,
|
|
62942
|
+
clampHandlePosition as n,
|
|
62943
|
+
calculateMarginFromHandle as o,
|
|
62944
|
+
measureCache as p,
|
|
62945
|
+
isHeadless as q,
|
|
62451
62946
|
replaceSelectionWithImagePlaceholder as r,
|
|
62452
62947
|
shouldBypassContextMenu as s,
|
|
62453
|
-
|
|
62948
|
+
getStarterExtensions as t,
|
|
62454
62949
|
useHighContrastMode as u,
|
|
62455
|
-
|
|
62456
|
-
|
|
62457
|
-
|
|
62950
|
+
Placeholder as v,
|
|
62951
|
+
getRichTextExtensions as w,
|
|
62952
|
+
Decoration as x,
|
|
62458
62953
|
yUndoPluginKey as y,
|
|
62459
|
-
|
|
62954
|
+
Extension as z
|
|
62460
62955
|
};
|