oasis-editor 0.0.131 → 0.0.132
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/{OasisEditorApp-Dn2I2b-M.js → OasisEditorApp-D-v1-Asf.js} +708 -682
- package/dist/adapters/mountController.d.ts +12 -0
- package/dist/adapters/vue.d.ts +5 -5
- package/dist/app/controllers/EditorCommandRegistry.d.ts +2 -1
- package/dist/app/controllers/tableResize/tableResizeUnits.d.ts +3 -1
- package/dist/assets/{importDocxWorker-DdpdjbOY.js → importDocxWorker-CCwhxVSR.js} +1 -1
- package/dist/core/commands/builtinCommands.d.ts +1 -1
- package/dist/core/editorState/defaultStyles.d.ts +3 -0
- package/dist/core/editorState/documentFactories.d.ts +8 -0
- package/dist/core/editorState/nodeFactories.d.ts +35 -0
- package/dist/core/editorState/stateFactories.d.ts +26 -0
- package/dist/core/editorState.d.ts +4 -66
- package/dist/core/units/parseUnitToPt.d.ts +6 -0
- package/dist/export/docx/xmlUtils.d.ts +2 -0
- package/dist/import/docx/runs/drawingAnchorLayout.d.ts +12 -0
- package/dist/{index-BXo_oqOC.js → index-DEBNBBUG.js} +2015 -1977
- package/dist/layoutProjection/presetGeometry/families/arrows.d.ts +3 -0
- package/dist/layoutProjection/presetGeometry/families/banners.d.ts +5 -0
- package/dist/layoutProjection/presetGeometry/families/bracesBrackets.d.ts +4 -0
- package/dist/layoutProjection/presetGeometry/families/callouts.d.ts +3 -0
- package/dist/layoutProjection/presetGeometry/families/connectors.d.ts +3 -0
- package/dist/layoutProjection/presetGeometry/families/containers3d.d.ts +11 -0
- package/dist/layoutProjection/presetGeometry/families/decorative.d.ts +9 -0
- package/dist/layoutProjection/presetGeometry/families/flowchart.d.ts +4 -0
- package/dist/layoutProjection/presetGeometry/families/mathSymbols.d.ts +8 -0
- package/dist/layoutProjection/presetGeometry/families/rectVariants.d.ts +5 -0
- package/dist/mountController-D2srsZ5t.js +15 -0
- package/dist/mountController.d.ts +12 -0
- package/dist/oasis-editor.js +54 -54
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/plugins/internal/essentialsCapabilities.d.ts +2 -1
- package/dist/plugins/internal/essentialsCommandBuilders.d.ts +8 -7
- package/dist/plugins/internal/essentialsCommandGroups/coreFormatting.d.ts +17 -0
- package/dist/plugins/internal/essentialsCommandGroups/documentAndBrowser.d.ts +15 -0
- package/dist/plugins/internal/essentialsCommandGroups/paragraphAndSection.d.ts +13 -0
- package/dist/plugins/internal/essentialsCommandGroups/table.d.ts +11 -0
- package/dist/react.js +14 -15
- package/dist/text/fontMetricsUtil.d.ts +16 -0
- package/dist/text/fonts/opentype/extensionLookup.d.ts +9 -0
- package/dist/ui/EditorImportProgressOverlay.d.ts +7 -0
- package/dist/ui/EditorStatusBar.d.ts +13 -0
- package/dist/ui/OasisEditorEditor.d.ts +3 -117
- package/dist/ui/OasisEditorEditorProps.d.ts +118 -0
- package/dist/ui/app/createEditorEssentialsPlugin.d.ts +2 -41
- package/dist/ui/app/essentials/browser.d.ts +3 -0
- package/dist/ui/app/essentials/document.d.ts +4 -0
- package/dist/ui/app/essentials/formatting.d.ts +9 -0
- package/dist/ui/app/essentials/gate.d.ts +4 -0
- package/dist/ui/app/essentials/history.d.ts +4 -0
- package/dist/ui/app/essentials/image.d.ts +4 -0
- package/dist/ui/app/essentials/link.d.ts +4 -0
- package/dist/ui/app/essentials/paragraph.d.ts +4 -0
- package/dist/ui/app/essentials/section.d.ts +4 -0
- package/dist/ui/app/essentials/selection.d.ts +4 -0
- package/dist/ui/app/essentials/style.d.ts +4 -0
- package/dist/ui/app/essentials/table.d.ts +4 -0
- package/dist/ui/app/essentials/types.d.ts +41 -0
- package/dist/ui/canvas/canvasLineSlotLookup.d.ts +8 -0
- package/dist/ui/canvas/canvasSnapshotLines.d.ts +22 -0
- package/dist/ui/canvas/canvasSnapshotWalkers.d.ts +41 -0
- package/dist/ui/canvas/canvasTheme.d.ts +6 -0
- package/dist/ui/components/Dialogs/ParagraphDialog.d.ts +2 -69
- package/dist/ui/components/Dialogs/paragraph-dialog/ParagraphDialogTypes.d.ts +82 -0
- package/dist/ui/components/Dialogs/paragraph-dialog/useParagraphDialogController.d.ts +66 -0
- package/dist/ui/components/Dialogs/table-properties/TablePropertiesTypes.d.ts +0 -1
- package/dist/ui/components/Toolbar/presets/defaultToolbar/buttonSpecs.d.ts +27 -0
- package/dist/ui/components/Toolbar/presets/defaultToolbar/optionBuilders.d.ts +10 -0
- package/dist/ui/components/Toolbar/presets/defaultToolbar/ribbonPlacements.d.ts +3 -0
- package/dist/utils/parseNumber.d.ts +5 -0
- package/dist/vue.d.ts +5 -5
- package/dist/vue.js +10 -12
- package/package.json +1 -1
- package/dist/layoutProjection/presetGeometry/families.d.ts +0 -37
- package/dist/plugins/internal/essentialsCommandGroups.d.ts +0 -41
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as
|
|
4
|
+
import { E as EMPTY_PROJECTION_CONTEXT, d as domTextMeasurer, g as getProjectedParagraphBlockHeight, e as estimateTableBlockHeight, p as projectParagraphLayout, a as getPageBodyBottom, b as getPageBodyTop, c as getPageContentWidth, F as FOOTNOTE_MARKER_GUTTER_PX, f as getParagraphText, h as getBlockParagraphs, i as getRunFootnoteReference, l as listReferencedEndnotes, j as getFootnoteDisplayMarker, k as createProjectionContext, m as getDocumentSections, n as getRunField, o as projectBlocksLayout, v as visitRun, q as assertNever, r as createSignal, s as createEditorStateFromDocument, t as createInitialEditorState, S as STANDARD_FONT_SIZES_PT, u as fontSizePxToPt, w as probeLocalFontFamilies, x as createEditorParagraphFromRuns, y as isInlineObjectRun, z as createEditorStyledRun, A as getParagraphLength, B as getActiveZone, C as getActiveSectionIndex, D as getParagraphs, G as normalizeSelection, H as positionToParagraphOffset, I as paragraphOffsetToPosition, J as clampPosition, K as findParagraphIndex, L as createCollapsedSelection, M as isSelectionCollapsed, N as parseFontSizePtToPx, O as formatFontSizePt, P as createEditorParagraph, Q as resolveDefaultParagraphStyleId, R as findParagraphTableLocation, T as buildTableCellLayout, U as PT_PER_PX, V as createEditorTableCell, W as createEditorTableRow, X as createEditorTable, Y as PX_PER_POINT, Z as underlineStyleToCssDecorationStyle, _ as resolveImageSrc, $ as listKindForTag, a0 as isParagraphTag, a1 as collectInlineRuns, a2 as parseParagraphStyle, a3 as getRunImage, a4 as InlineShell, a5 as BalloonShell, a6 as DocumentShell, a7 as createMemo, a8 as getCaretRectFromSnapshot, a9 as getParagraphRectFromSnapshot, aa as createComponent, ab as CaretOverlay, ac as Show, ad as createRenderEffect, ae as style, af as setStyleProperty, ag as setAttribute, ah as memo, ai as template, aj as Button, ak as useI18n, al as createEffect, am as TextField, an as Dialog, ao as insert, ap as className, aq as Grid, ar as SelectField, as as StatusText, at as ColorField, au as UNDERLINE_STYLE_OPTIONS, av as Stack, aw as For, ax as ToggleChip, ay as FormField, az as Checkbox, aA as FieldGroup, aB as Tabs, aC as NumberField, aD as parseNumber, aE as createStore, aF as reconcile, aG as RadioGroup, aH as Radio$1, aI as TextAreaField, aJ as Text, aK as SurfaceButton, aL as delegateEvents, aM as onMount, aN as onCleanup, aO as use, aP as PluginUiHost, aQ as OasisEditorEditor, aR as OasisBrandMark, aS as setPreciseFontPreference, aT as setWelcomeSeen, aU as enablePreciseFontMode, aV as TWIPS_PER_POINT, aW as PX_PER_INCH, aX as TWIPS_PER_INCH, aY as normalizeHex6, aZ as TABLE_CONDITIONAL_FLAG_ATTRIBUTES, a_ as TABLE_BORDER_EDGE_KEYS, a$ as resolveEffectiveParagraphStyle, b0 as resolveEffectiveTextStyleForParagraph, b1 as EMU_PER_PT, b2 as OOXML_ROTATION_UNITS, b3 as OOXML_PERCENT_DENOMINATOR, b4 as parseHexColorToRgb255, b5 as EMU_PER_PX, b6 as getRunEndnoteReference, b7 as iterateFootnoteReferenceRuns, b8 as iterateEndnoteReferenceRuns, b9 as imageContentTypeDefaults, ba as getRunFieldChar, bb as getRunFieldInstruction, bc as createEditorRun, bd as JSZip, be as imageExtensionFromMime, bf as pxToPt$1, bg as resolveFloatingObjectRect, bh as getTextBoxFloatingGeometry, bi as getPresetPathSegments, bj as buildListLabels, bk as DEFAULT_FONT_SIZE_PX, bl as resolveGradientAxis, bm as isDoubleUnderlineStyle, bn as isWavyUnderlineStyle, bo as underlineStyleLineWidthPx, bp as WAVY_UNDERLINE_WAVELENGTH_PX, bq as WAVY_UNDERLINE_AMPLITUDE_PX, br as DOUBLE_UNDERLINE_OFFSET_PX, bs as underlineStyleDashArray, bt as EMPHASIS_GLYPH, bu as rgb255ToHex, bv as getImageFloatingGeometry, bw as textStyleToFontSizePt, bx as resolveTextAlignmentBaselineOffset, by as TEXT_BASELINE_RATIO, bz as resolveOpenTypeFeatureTags, bA as resolveDecorationLineY, bB as DOUBLE_STRIKE_OFFSET_PX, bC as resolveListLabel, bD as getListLabelInset, bE as getAlignedListLabelInset, bF as getParagraphBorderInsets, bG as buildSegmentTable, bH as buildCanvasTableLayout, bI as resolveCanvasTableWidth, bJ as resolveFloatingTableRect, bK as paragraphBetweenBorderMatches, bL as normalizeFamily, bM as ROBOTO_FONT_FILES, bN as loadFontAsset, bO as OFFICE_COMPAT_FONT_FAMILIES, bP as BinaryReader, bQ as buildSfnt, bR as defaultFontDecoderRegistry, bS as SfntFontProgram, bT as collectPdfFontFamilies, bU as outlineFrom, bV as getPageHeaderZoneTop, bW as getPageColumnRects, bX as findFootnoteReference, bY as resolveImporterForFile, bZ as roundTo, b_ as getDocumentSectionsCanonical, b$ as getDocumentParagraphsCanonical, c0 as getDocumentParagraphs, c1 as getDocumentPageSettings, c2 as getTableCellContentWidthForParagraph, c3 as layoutMetricsEpoch, c4 as bumpLayoutMetricsEpoch, c5 as createCanvasLayoutSnapshotProvider, c6 as on, c7 as debounce, c8 as unwrap, c9 as perfTimer, ca as getRunTextBox, cb as createEditorDocument, cc as resolveResizedDimensions, cd as resolveTextBoxRenderHeight, ce as getToolbarStyleState, cf as VERTICAL_HIT_WEIGHT, cg as getCachedCanvasImage, ch as measureParagraphMinContentWidthPx, ci as getEditableBlocksForZone, cj as findParagraphLocation, ck as createSectionBoundaryParagraph, cl as normalizePageSettings, cm as DEFAULT_EDITOR_PAGE_SETTINGS, cn as markStart, co as markEnd, cp as getParagraphEntries, cq as getParagraphById, cr as createEditorFootnote, cs as createFootnoteReferenceRun, ct as renumberFootnotes, cu as preciseFontModeVersion, cv as isPreciseFontModeEnabled, cw as getHeadingLevel, cx as togglePreciseFontMode, cy as nextFontSizePt, cz as previousFontSizePt, cA as fontSizePtToPx, cB as resolveNamedTextStyle, cC as createDefaultToolbarPreset, cD as MenuRegistry, cE as createToolbarRegistry, cF as Editor, cG as resolveCommandRef, cH as commandRefName, cI as createOasisEditorClient, cJ as createEditorZoom, cK as startLongTaskObserver, cL as installGlobalReport, cM as applyStoredPreciseFontPreference, cN as getWelcomeSeen, cO as isLocalFontAccessSupported, cP as EDITOR_SCROLL_PADDING_PX, cQ as Toolbar, cR as OasisEditorLoading, cS as I18nProvider, cT as createTranslator, cU as registerDomStatsSurface, cV as createEditorLogger } from "./index-DEBNBBUG.js";
|
|
5
5
|
function projectHeaderFooterBlocksWithDependencies(blocks, deps, context = {}) {
|
|
6
6
|
const {
|
|
7
7
|
pageIndex,
|
|
@@ -29808,8 +29808,7 @@ function distributeSelectedTableRows(state) {
|
|
|
29808
29808
|
return { ...table, rows: nextRows };
|
|
29809
29809
|
});
|
|
29810
29810
|
}
|
|
29811
|
-
|
|
29812
|
-
function parseWidthToPt(value) {
|
|
29811
|
+
function parseUnitToPt(value) {
|
|
29813
29812
|
if (typeof value === "number" && Number.isFinite(value)) {
|
|
29814
29813
|
return value;
|
|
29815
29814
|
}
|
|
@@ -29834,6 +29833,7 @@ function parseWidthToPt(value) {
|
|
|
29834
29833
|
const parsed = Number.parseFloat(trimmed);
|
|
29835
29834
|
return Number.isFinite(parsed) ? parsed : null;
|
|
29836
29835
|
}
|
|
29836
|
+
const DEFAULT_DISTRIBUTED_COLUMN_PT = 120;
|
|
29837
29837
|
function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableIndentLeft) {
|
|
29838
29838
|
const updateTable = (table) => {
|
|
29839
29839
|
var _a2;
|
|
@@ -29849,7 +29849,7 @@ function setTableColumnWidths(state, tableId, columnWidths, tableWidth, tableInd
|
|
|
29849
29849
|
let hasGridOverride = false;
|
|
29850
29850
|
let canResolveGrid = true;
|
|
29851
29851
|
for (let columnIndex = 0; columnIndex < visualColumnCount; columnIndex += 1) {
|
|
29852
|
-
const override =
|
|
29852
|
+
const override = parseUnitToPt(columnWidths[columnIndex]);
|
|
29853
29853
|
if (override !== null) {
|
|
29854
29854
|
nextGridCols[columnIndex] = Math.max(1, override);
|
|
29855
29855
|
hasGridOverride = true;
|
|
@@ -33335,47 +33335,22 @@ function TabStopsDialog(props) {
|
|
|
33335
33335
|
}
|
|
33336
33336
|
});
|
|
33337
33337
|
}
|
|
33338
|
-
var _tmpl$$a = /* @__PURE__ */ template(`<div class=oasis-editor-paragraph-dialog-panel>`), _tmpl$2$2 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>`), _tmpl$3$1 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>`);
|
|
33339
33338
|
const PT_TO_PX = 96 / 72;
|
|
33340
33339
|
const DEFAULT_BORDER_WIDTH_PT$1 = 0.5;
|
|
33341
33340
|
const DEFAULT_BORDER_COLOR$1 = "#000000";
|
|
33342
33341
|
const OUTLINE_BODY = "";
|
|
33343
|
-
function parseNumber$1(value) {
|
|
33344
|
-
if (value.trim() === "") return null;
|
|
33345
|
-
const num = Number(value);
|
|
33346
|
-
return Number.isFinite(num) ? num : null;
|
|
33347
|
-
}
|
|
33348
33342
|
function deriveLineSpacing(lineRule, lineHeight) {
|
|
33349
33343
|
if (lineRule === "exact" || lineRule === "atLeast") {
|
|
33350
33344
|
const pt = lineHeight !== null ? Math.round(lineHeight / PT_TO_PX) : null;
|
|
33351
|
-
return {
|
|
33352
|
-
mode: lineRule,
|
|
33353
|
-
at: pt
|
|
33354
|
-
};
|
|
33345
|
+
return { mode: lineRule, at: pt };
|
|
33355
33346
|
}
|
|
33356
|
-
if (lineHeight === null) return {
|
|
33357
|
-
|
|
33358
|
-
|
|
33359
|
-
};
|
|
33360
|
-
|
|
33361
|
-
mode: "single",
|
|
33362
|
-
at: null
|
|
33363
|
-
};
|
|
33364
|
-
if (lineHeight === 1.5) return {
|
|
33365
|
-
mode: "onePointFive",
|
|
33366
|
-
at: null
|
|
33367
|
-
};
|
|
33368
|
-
if (lineHeight === 2) return {
|
|
33369
|
-
mode: "double",
|
|
33370
|
-
at: null
|
|
33371
|
-
};
|
|
33372
|
-
return {
|
|
33373
|
-
mode: "multiple",
|
|
33374
|
-
at: lineHeight
|
|
33375
|
-
};
|
|
33347
|
+
if (lineHeight === null) return { mode: "multiple", at: null };
|
|
33348
|
+
if (lineHeight === 1) return { mode: "single", at: null };
|
|
33349
|
+
if (lineHeight === 1.5) return { mode: "onePointFive", at: null };
|
|
33350
|
+
if (lineHeight === 2) return { mode: "double", at: null };
|
|
33351
|
+
return { mode: "multiple", at: lineHeight };
|
|
33376
33352
|
}
|
|
33377
|
-
function
|
|
33378
|
-
const t = useI18n();
|
|
33353
|
+
function useParagraphDialogController(props) {
|
|
33379
33354
|
const [align, setAlign] = createSignal("");
|
|
33380
33355
|
const [outlineLevel, setOutlineLevel] = createSignal(OUTLINE_BODY);
|
|
33381
33356
|
const [indentLeft, setIndentLeft] = createSignal(null);
|
|
@@ -33401,27 +33376,28 @@ function ParagraphDialog(props) {
|
|
|
33401
33376
|
const [keepLinesTogether, setKeepLinesTogether] = createSignal(false);
|
|
33402
33377
|
const [widowControl, setWidowControl] = createSignal(true);
|
|
33403
33378
|
const [tabs, setTabs] = createSignal([]);
|
|
33404
|
-
const [tabsDialogOpen, setTabsDialogOpen] = createSignal(false);
|
|
33405
33379
|
createEffect(() => {
|
|
33406
33380
|
if (props.isOpen) {
|
|
33407
33381
|
setAlign(props.initial.align ?? "");
|
|
33408
33382
|
setOutlineLevel(props.initial.outlineLevel ?? OUTLINE_BODY);
|
|
33409
|
-
setIndentLeft(parseNumber
|
|
33410
|
-
setIndentRight(parseNumber
|
|
33383
|
+
setIndentLeft(parseNumber(props.initial.indentLeft ?? ""));
|
|
33384
|
+
setIndentRight(parseNumber(props.initial.indentRight ?? ""));
|
|
33411
33385
|
setMirrorIndents(props.initial.mirrorIndents ?? false);
|
|
33412
|
-
setSpacingBefore(parseNumber
|
|
33413
|
-
setSpacingAfter(parseNumber
|
|
33386
|
+
setSpacingBefore(parseNumber(props.initial.spacingBefore ?? ""));
|
|
33387
|
+
setSpacingAfter(parseNumber(props.initial.spacingAfter ?? ""));
|
|
33414
33388
|
setContextualSpacing(props.initial.contextualSpacing ?? false);
|
|
33415
33389
|
setShading(props.initial.shading ?? "");
|
|
33416
|
-
const {
|
|
33417
|
-
|
|
33418
|
-
|
|
33419
|
-
|
|
33390
|
+
const { mode, at } = deriveLineSpacing(
|
|
33391
|
+
props.initial.lineRule ?? "",
|
|
33392
|
+
parseNumber(props.initial.lineHeight ?? "")
|
|
33393
|
+
);
|
|
33420
33394
|
setLineMode(mode);
|
|
33421
33395
|
setLineAt(at);
|
|
33422
33396
|
const initialBorderStyle = props.initial.borderStyle;
|
|
33423
|
-
setBorderStyle(
|
|
33424
|
-
|
|
33397
|
+
setBorderStyle(
|
|
33398
|
+
initialBorderStyle === "solid" || initialBorderStyle === "dashed" || initialBorderStyle === "dotted" ? initialBorderStyle : "none"
|
|
33399
|
+
);
|
|
33400
|
+
setBorderWidth(parseNumber(props.initial.borderWidth ?? ""));
|
|
33425
33401
|
setBorderColor(props.initial.borderColor ?? "");
|
|
33426
33402
|
setSideTop(props.initial.borderSideTop ?? false);
|
|
33427
33403
|
setSideRight(props.initial.borderSideRight ?? false);
|
|
@@ -33432,8 +33408,8 @@ function ParagraphDialog(props) {
|
|
|
33432
33408
|
setKeepLinesTogether(props.initial.keepLinesTogether ?? false);
|
|
33433
33409
|
setWidowControl(props.initial.widowControl ?? true);
|
|
33434
33410
|
setTabs(props.initial.tabs ?? []);
|
|
33435
|
-
const firstLine = parseNumber
|
|
33436
|
-
const hanging = parseNumber
|
|
33411
|
+
const firstLine = parseNumber(props.initial.indentFirstLine ?? "");
|
|
33412
|
+
const hanging = parseNumber(props.initial.indentHanging ?? "");
|
|
33437
33413
|
if (hanging !== null && hanging > 0) {
|
|
33438
33414
|
setSpecial("hanging");
|
|
33439
33415
|
setSpecialBy(hanging);
|
|
@@ -33450,25 +33426,13 @@ function ParagraphDialog(props) {
|
|
|
33450
33426
|
const resolveLineSpacing = () => {
|
|
33451
33427
|
switch (lineMode()) {
|
|
33452
33428
|
case "single":
|
|
33453
|
-
return {
|
|
33454
|
-
lineHeight: 1,
|
|
33455
|
-
lineRule: null
|
|
33456
|
-
};
|
|
33429
|
+
return { lineHeight: 1, lineRule: null };
|
|
33457
33430
|
case "onePointFive":
|
|
33458
|
-
return {
|
|
33459
|
-
lineHeight: 1.5,
|
|
33460
|
-
lineRule: null
|
|
33461
|
-
};
|
|
33431
|
+
return { lineHeight: 1.5, lineRule: null };
|
|
33462
33432
|
case "double":
|
|
33463
|
-
return {
|
|
33464
|
-
lineHeight: 2,
|
|
33465
|
-
lineRule: null
|
|
33466
|
-
};
|
|
33433
|
+
return { lineHeight: 2, lineRule: null };
|
|
33467
33434
|
case "multiple":
|
|
33468
|
-
return {
|
|
33469
|
-
lineHeight: lineAt(),
|
|
33470
|
-
lineRule: null
|
|
33471
|
-
};
|
|
33435
|
+
return { lineHeight: lineAt(), lineRule: null };
|
|
33472
33436
|
case "atLeast":
|
|
33473
33437
|
return {
|
|
33474
33438
|
lineHeight: lineAt() !== null ? lineAt() * PT_TO_PX : null,
|
|
@@ -33488,10 +33452,7 @@ function ParagraphDialog(props) {
|
|
|
33488
33452
|
const hanging = special() === "hanging" ? specialBy() : null;
|
|
33489
33453
|
const textIndent = firstLine !== null ? firstLine : hanging !== null ? -hanging : null;
|
|
33490
33454
|
const borderCss = borderStyle() !== "none" ? `${borderWidth() ?? DEFAULT_BORDER_WIDTH_PT$1}pt ${borderStyle()} ${borderColor().trim() || DEFAULT_BORDER_COLOR$1}` : void 0;
|
|
33491
|
-
const {
|
|
33492
|
-
lineHeight,
|
|
33493
|
-
lineRule
|
|
33494
|
-
} = resolveLineSpacing();
|
|
33455
|
+
const { lineHeight, lineRule } = resolveLineSpacing();
|
|
33495
33456
|
const lineHeightCss = lineHeight === null ? void 0 : lineRule === "exact" || lineRule === "atLeast" ? `${lineHeight}px` : String(lineHeight);
|
|
33496
33457
|
return {
|
|
33497
33458
|
"text-align": align() || void 0,
|
|
@@ -33509,12 +33470,7 @@ function ParagraphDialog(props) {
|
|
|
33509
33470
|
const resolveBorders = () => {
|
|
33510
33471
|
const style2 = borderStyle();
|
|
33511
33472
|
if (style2 === "none") {
|
|
33512
|
-
return {
|
|
33513
|
-
top: null,
|
|
33514
|
-
right: null,
|
|
33515
|
-
bottom: null,
|
|
33516
|
-
left: null
|
|
33517
|
-
};
|
|
33473
|
+
return { top: null, right: null, bottom: null, left: null };
|
|
33518
33474
|
}
|
|
33519
33475
|
const width = borderWidth();
|
|
33520
33476
|
const border = {
|
|
@@ -33531,10 +33487,7 @@ function ParagraphDialog(props) {
|
|
|
33531
33487
|
};
|
|
33532
33488
|
const collectValues = () => {
|
|
33533
33489
|
const by = specialBy();
|
|
33534
|
-
const {
|
|
33535
|
-
lineHeight,
|
|
33536
|
-
lineRule
|
|
33537
|
-
} = resolveLineSpacing();
|
|
33490
|
+
const { lineHeight, lineRule } = resolveLineSpacing();
|
|
33538
33491
|
const outline = outlineLevel();
|
|
33539
33492
|
return {
|
|
33540
33493
|
align: align() || null,
|
|
@@ -33567,6 +33520,123 @@ function ParagraphDialog(props) {
|
|
|
33567
33520
|
(_a2 = props.onSetDefault) == null ? void 0 : _a2.call(props, collectValues());
|
|
33568
33521
|
props.onClose();
|
|
33569
33522
|
};
|
|
33523
|
+
return {
|
|
33524
|
+
align,
|
|
33525
|
+
setAlign,
|
|
33526
|
+
outlineLevel,
|
|
33527
|
+
setOutlineLevel,
|
|
33528
|
+
indentLeft,
|
|
33529
|
+
setIndentLeft,
|
|
33530
|
+
indentRight,
|
|
33531
|
+
setIndentRight,
|
|
33532
|
+
special,
|
|
33533
|
+
setSpecial,
|
|
33534
|
+
specialBy,
|
|
33535
|
+
setSpecialBy,
|
|
33536
|
+
mirrorIndents,
|
|
33537
|
+
setMirrorIndents,
|
|
33538
|
+
spacingBefore,
|
|
33539
|
+
setSpacingBefore,
|
|
33540
|
+
spacingAfter,
|
|
33541
|
+
setSpacingAfter,
|
|
33542
|
+
lineMode,
|
|
33543
|
+
setLineMode,
|
|
33544
|
+
lineAt,
|
|
33545
|
+
setLineAt,
|
|
33546
|
+
contextualSpacing,
|
|
33547
|
+
setContextualSpacing,
|
|
33548
|
+
shading,
|
|
33549
|
+
setShading,
|
|
33550
|
+
borderStyle,
|
|
33551
|
+
setBorderStyle,
|
|
33552
|
+
borderWidth,
|
|
33553
|
+
setBorderWidth,
|
|
33554
|
+
borderColor,
|
|
33555
|
+
setBorderColor,
|
|
33556
|
+
sideTop,
|
|
33557
|
+
setSideTop,
|
|
33558
|
+
sideRight,
|
|
33559
|
+
setSideRight,
|
|
33560
|
+
sideBottom,
|
|
33561
|
+
setSideBottom,
|
|
33562
|
+
sideLeft,
|
|
33563
|
+
setSideLeft,
|
|
33564
|
+
pageBreakBefore,
|
|
33565
|
+
setPageBreakBefore,
|
|
33566
|
+
keepWithNext,
|
|
33567
|
+
setKeepWithNext,
|
|
33568
|
+
keepLinesTogether,
|
|
33569
|
+
setKeepLinesTogether,
|
|
33570
|
+
widowControl,
|
|
33571
|
+
setWidowControl,
|
|
33572
|
+
tabs,
|
|
33573
|
+
setTabs,
|
|
33574
|
+
atEnabled,
|
|
33575
|
+
previewStyle,
|
|
33576
|
+
handleApply,
|
|
33577
|
+
handleSetDefault
|
|
33578
|
+
};
|
|
33579
|
+
}
|
|
33580
|
+
var _tmpl$$a = /* @__PURE__ */ template(`<div class=oasis-editor-paragraph-dialog-panel>`), _tmpl$2$2 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-preview data-testid=editor-paragraph-dialog-preview>`), _tmpl$3$1 = /* @__PURE__ */ template(`<div class=oasis-editor-dialog-footer-split><div class=oasis-editor-dialog-footer-start></div><div class=oasis-editor-dialog-footer-end>`);
|
|
33581
|
+
function ParagraphDialog(props) {
|
|
33582
|
+
const t = useI18n();
|
|
33583
|
+
const [tabsDialogOpen, setTabsDialogOpen] = createSignal(false);
|
|
33584
|
+
const {
|
|
33585
|
+
align,
|
|
33586
|
+
setAlign,
|
|
33587
|
+
outlineLevel,
|
|
33588
|
+
setOutlineLevel,
|
|
33589
|
+
indentLeft,
|
|
33590
|
+
setIndentLeft,
|
|
33591
|
+
indentRight,
|
|
33592
|
+
setIndentRight,
|
|
33593
|
+
special,
|
|
33594
|
+
setSpecial,
|
|
33595
|
+
specialBy,
|
|
33596
|
+
setSpecialBy,
|
|
33597
|
+
mirrorIndents,
|
|
33598
|
+
setMirrorIndents,
|
|
33599
|
+
spacingBefore,
|
|
33600
|
+
setSpacingBefore,
|
|
33601
|
+
spacingAfter,
|
|
33602
|
+
setSpacingAfter,
|
|
33603
|
+
lineMode,
|
|
33604
|
+
setLineMode,
|
|
33605
|
+
lineAt,
|
|
33606
|
+
setLineAt,
|
|
33607
|
+
contextualSpacing,
|
|
33608
|
+
setContextualSpacing,
|
|
33609
|
+
shading,
|
|
33610
|
+
setShading,
|
|
33611
|
+
borderStyle,
|
|
33612
|
+
setBorderStyle,
|
|
33613
|
+
borderWidth,
|
|
33614
|
+
setBorderWidth,
|
|
33615
|
+
borderColor,
|
|
33616
|
+
setBorderColor,
|
|
33617
|
+
sideTop,
|
|
33618
|
+
setSideTop,
|
|
33619
|
+
sideRight,
|
|
33620
|
+
setSideRight,
|
|
33621
|
+
sideBottom,
|
|
33622
|
+
setSideBottom,
|
|
33623
|
+
sideLeft,
|
|
33624
|
+
setSideLeft,
|
|
33625
|
+
pageBreakBefore,
|
|
33626
|
+
setPageBreakBefore,
|
|
33627
|
+
keepWithNext,
|
|
33628
|
+
setKeepWithNext,
|
|
33629
|
+
keepLinesTogether,
|
|
33630
|
+
setKeepLinesTogether,
|
|
33631
|
+
widowControl,
|
|
33632
|
+
setWidowControl,
|
|
33633
|
+
tabs,
|
|
33634
|
+
setTabs,
|
|
33635
|
+
atEnabled,
|
|
33636
|
+
previewStyle,
|
|
33637
|
+
handleApply,
|
|
33638
|
+
handleSetDefault
|
|
33639
|
+
} = useParagraphDialogController(props);
|
|
33570
33640
|
const alignField = createComponent(SelectField, {
|
|
33571
33641
|
get label() {
|
|
33572
33642
|
return t("paragraph.alignLabel");
|
|
@@ -34236,11 +34306,6 @@ function ParagraphDialog(props) {
|
|
|
34236
34306
|
}
|
|
34237
34307
|
const DEFAULT_BORDER_WIDTH_PT = 0.5;
|
|
34238
34308
|
const DEFAULT_BORDER_COLOR = "#000000";
|
|
34239
|
-
function parseNumber(value) {
|
|
34240
|
-
if (value.trim() === "") return null;
|
|
34241
|
-
const parsed = Number(value);
|
|
34242
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
34243
|
-
}
|
|
34244
34309
|
function parseWidth(value, unit) {
|
|
34245
34310
|
const parsed = parseNumber(value);
|
|
34246
34311
|
if (parsed === null) return null;
|
|
@@ -36161,6 +36226,9 @@ function pointsToTwips(value) {
|
|
|
36161
36226
|
function normalizeDocxColor(color, fallback = "000000") {
|
|
36162
36227
|
return normalizeHex6(color) ?? fallback;
|
|
36163
36228
|
}
|
|
36229
|
+
function serializeShading(fill) {
|
|
36230
|
+
return `<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(fill, "FFFFFF")}"/>`;
|
|
36231
|
+
}
|
|
36164
36232
|
function buildBookmarkExportPlan(document2) {
|
|
36165
36233
|
const registry = document2.bookmarks;
|
|
36166
36234
|
if (!registry || registry.order.length === 0) {
|
|
@@ -36501,9 +36569,7 @@ function serializeTableCellProperties(cell, fallbackWidthPt) {
|
|
|
36501
36569
|
parts.push("<w:vMerge/>");
|
|
36502
36570
|
}
|
|
36503
36571
|
if ((_b2 = cell.style) == null ? void 0 : _b2.shading) {
|
|
36504
|
-
parts.push(
|
|
36505
|
-
`<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(cell.style.shading, "FFFFFF")}"/>`
|
|
36506
|
-
);
|
|
36572
|
+
parts.push(serializeShading(cell.style.shading));
|
|
36507
36573
|
}
|
|
36508
36574
|
const noWrap = serializeOnOffElement("noWrap", (_c = cell.style) == null ? void 0 : _c.noWrap);
|
|
36509
36575
|
if (noWrap) {
|
|
@@ -37068,9 +37134,7 @@ function serializeParagraphStyleXml(style2) {
|
|
|
37068
37134
|
parts.push(paragraphBorders);
|
|
37069
37135
|
}
|
|
37070
37136
|
if (style2.shading) {
|
|
37071
|
-
parts.push(
|
|
37072
|
-
`<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(style2.shading, "FFFFFF")}"/>`
|
|
37073
|
-
);
|
|
37137
|
+
parts.push(serializeShading(style2.shading));
|
|
37074
37138
|
}
|
|
37075
37139
|
if (style2.textDirection) {
|
|
37076
37140
|
parts.push(`<w:textDirection w:val="${style2.textDirection}"/>`);
|
|
@@ -37134,9 +37198,7 @@ function serializeParagraphProperties(paragraph, numberingInfo, styles, override
|
|
|
37134
37198
|
parts.push(paragraphBorders);
|
|
37135
37199
|
}
|
|
37136
37200
|
if (style2.shading) {
|
|
37137
|
-
parts.push(
|
|
37138
|
-
`<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(style2.shading, "FFFFFF")}"/>`
|
|
37139
|
-
);
|
|
37201
|
+
parts.push(serializeShading(style2.shading));
|
|
37140
37202
|
}
|
|
37141
37203
|
if (style2.textDirection) {
|
|
37142
37204
|
parts.push(`<w:textDirection w:val="${style2.textDirection}"/>`);
|
|
@@ -37427,9 +37489,7 @@ function serializeRunProperties(styles) {
|
|
|
37427
37489
|
);
|
|
37428
37490
|
}
|
|
37429
37491
|
if (styles.shading) {
|
|
37430
|
-
parts.push(
|
|
37431
|
-
`<w:shd w:val="clear" w:color="auto" w:fill="${normalizeDocxColor(styles.shading, "FFFFFF")}"/>`
|
|
37432
|
-
);
|
|
37492
|
+
parts.push(serializeShading(styles.shading));
|
|
37433
37493
|
}
|
|
37434
37494
|
if (styles.fitText !== void 0 && styles.fitText !== null && Number.isFinite(styles.fitText)) {
|
|
37435
37495
|
const twips = pointsToSignedTwips(styles.fitText);
|
|
@@ -41258,6 +41318,14 @@ class PdfContentStream {
|
|
|
41258
41318
|
);
|
|
41259
41319
|
}
|
|
41260
41320
|
}
|
|
41321
|
+
function parseExtensionLookup(reader, offset, parseSubtable2) {
|
|
41322
|
+
reader.seek(offset);
|
|
41323
|
+
const format = reader.u16();
|
|
41324
|
+
if (format !== 1) return null;
|
|
41325
|
+
const extensionType = reader.u16();
|
|
41326
|
+
const extensionOffset = offset + reader.u32();
|
|
41327
|
+
return parseSubtable2(reader, extensionOffset, extensionType);
|
|
41328
|
+
}
|
|
41261
41329
|
function readU16Array(reader, count) {
|
|
41262
41330
|
const array = new Array(count);
|
|
41263
41331
|
for (let i = 0; i < count; i += 1) array[i] = reader.u16();
|
|
@@ -41769,14 +41837,8 @@ function parseSubtable$1(reader, offset, lookupType) {
|
|
|
41769
41837
|
return parseLigatureSubst(reader, offset);
|
|
41770
41838
|
case 6:
|
|
41771
41839
|
return parseChainContextSubst(reader, offset);
|
|
41772
|
-
case 7:
|
|
41773
|
-
reader
|
|
41774
|
-
const format = reader.u16();
|
|
41775
|
-
if (format !== 1) return null;
|
|
41776
|
-
const extensionType = reader.u16();
|
|
41777
|
-
const extensionOffset = offset + reader.u32();
|
|
41778
|
-
return parseSubtable$1(reader, extensionOffset, extensionType);
|
|
41779
|
-
}
|
|
41840
|
+
case 7:
|
|
41841
|
+
return parseExtensionLookup(reader, offset, parseSubtable$1);
|
|
41780
41842
|
default:
|
|
41781
41843
|
return null;
|
|
41782
41844
|
}
|
|
@@ -41999,14 +42061,8 @@ function parseSubtable(reader, offset, lookupType) {
|
|
|
41999
42061
|
return parseSinglePos(reader, offset);
|
|
42000
42062
|
case 2:
|
|
42001
42063
|
return parsePairPos(reader, offset);
|
|
42002
|
-
case 9:
|
|
42003
|
-
reader
|
|
42004
|
-
const format = reader.u16();
|
|
42005
|
-
if (format !== 1) return null;
|
|
42006
|
-
const extensionType = reader.u16();
|
|
42007
|
-
const extensionOffset = offset + reader.u32();
|
|
42008
|
-
return parseSubtable(reader, extensionOffset, extensionType);
|
|
42009
|
-
}
|
|
42064
|
+
case 9:
|
|
42065
|
+
return parseExtensionLookup(reader, offset, parseSubtable);
|
|
42010
42066
|
default:
|
|
42011
42067
|
return null;
|
|
42012
42068
|
}
|
|
@@ -46880,12 +46936,23 @@ function createTableCellSpanOperationsImpl(deps) {
|
|
|
46880
46936
|
splitSelectedTable
|
|
46881
46937
|
};
|
|
46882
46938
|
}
|
|
46939
|
+
function markTableRevision(target, type) {
|
|
46940
|
+
target.style = {
|
|
46941
|
+
...target.style ?? {},
|
|
46942
|
+
revision: { ...createTableRevisionMetadata(), type }
|
|
46943
|
+
};
|
|
46944
|
+
}
|
|
46945
|
+
function resolveNextTableParagraph(tableBlock, targetCell, fallbackRow) {
|
|
46946
|
+
var _a2;
|
|
46947
|
+
return (targetCell == null ? void 0 : targetCell.blocks[0]) ?? ((_a2 = fallbackRow == null ? void 0 : fallbackRow.cells.find(
|
|
46948
|
+
(cell) => cell.vMerge !== "continue" && cell.blocks[0]
|
|
46949
|
+
)) == null ? void 0 : _a2.blocks[0]) ?? findFirstNavigableParagraphInTable(tableBlock);
|
|
46950
|
+
}
|
|
46883
46951
|
function createTableRowColumnOperations(deps) {
|
|
46884
46952
|
return createTableRowColumnOperationsImpl(deps);
|
|
46885
46953
|
}
|
|
46886
46954
|
function createTableRowColumnOperationsImpl(deps) {
|
|
46887
46955
|
const insertSelectedTableRow = (current, direction) => {
|
|
46888
|
-
var _a2, _b2;
|
|
46889
46956
|
const mut = resolveLocationTableMutation(current, deps.getTargetBlocks);
|
|
46890
46957
|
if (!mut) return current;
|
|
46891
46958
|
const { tableBlock, location, targetBlocks } = mut;
|
|
@@ -46940,20 +47007,16 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
46940
47007
|
})
|
|
46941
47008
|
);
|
|
46942
47009
|
if (current.trackChangesEnabled) {
|
|
46943
|
-
blankRow
|
|
46944
|
-
...blankRow.style ?? {},
|
|
46945
|
-
revision: {
|
|
46946
|
-
...createTableRevisionMetadata(),
|
|
46947
|
-
type: "insert"
|
|
46948
|
-
}
|
|
46949
|
-
};
|
|
47010
|
+
markTableRevision(blankRow, "insert");
|
|
46950
47011
|
}
|
|
46951
47012
|
tableBlock.rows.splice(insertIndex, 0, blankRow);
|
|
46952
47013
|
const targetVisualColumn = (selectedEntry == null ? void 0 : selectedEntry.visualColumnIndex) ?? location.cellIndex;
|
|
46953
47014
|
const targetCell2 = findCellAtVisualColumn(blankRow, targetVisualColumn);
|
|
46954
|
-
const nextParagraph2 = (
|
|
46955
|
-
|
|
46956
|
-
|
|
47015
|
+
const nextParagraph2 = resolveNextTableParagraph(
|
|
47016
|
+
tableBlock,
|
|
47017
|
+
targetCell2,
|
|
47018
|
+
blankRow
|
|
47019
|
+
);
|
|
46957
47020
|
return commitTableMutation(
|
|
46958
47021
|
current,
|
|
46959
47022
|
targetBlocks,
|
|
@@ -46970,19 +47033,15 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
46970
47033
|
)
|
|
46971
47034
|
);
|
|
46972
47035
|
if (current.trackChangesEnabled) {
|
|
46973
|
-
blankRow
|
|
46974
|
-
...blankRow.style ?? {},
|
|
46975
|
-
revision: {
|
|
46976
|
-
...createTableRevisionMetadata(),
|
|
46977
|
-
type: "insert"
|
|
46978
|
-
}
|
|
46979
|
-
};
|
|
47036
|
+
markTableRevision(blankRow, "insert");
|
|
46980
47037
|
}
|
|
46981
47038
|
tableBlock.rows.splice(insertIndex, 0, blankRow);
|
|
46982
47039
|
const targetCell = blankRow.cells[Math.min(location.cellIndex, blankRow.cells.length - 1)];
|
|
46983
|
-
const nextParagraph = (
|
|
46984
|
-
|
|
46985
|
-
|
|
47040
|
+
const nextParagraph = resolveNextTableParagraph(
|
|
47041
|
+
tableBlock,
|
|
47042
|
+
targetCell,
|
|
47043
|
+
blankRow
|
|
47044
|
+
);
|
|
46986
47045
|
return commitTableMutation(
|
|
46987
47046
|
current,
|
|
46988
47047
|
targetBlocks,
|
|
@@ -47002,13 +47061,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47002
47061
|
return current;
|
|
47003
47062
|
}
|
|
47004
47063
|
if (current.trackChangesEnabled) {
|
|
47005
|
-
rowToDelete
|
|
47006
|
-
...rowToDelete.style ?? {},
|
|
47007
|
-
revision: {
|
|
47008
|
-
...createTableRevisionMetadata(),
|
|
47009
|
-
type: "delete"
|
|
47010
|
-
}
|
|
47011
|
-
};
|
|
47064
|
+
markTableRevision(rowToDelete, "delete");
|
|
47012
47065
|
return commitTableMutation(current, targetBlocks, location.zone, null);
|
|
47013
47066
|
}
|
|
47014
47067
|
const blockedByRestartCell = rowToDelete.cells.some(
|
|
@@ -47048,7 +47101,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47048
47101
|
Math.max(0, getRowVisualWidth(nextRow) - 1)
|
|
47049
47102
|
)
|
|
47050
47103
|
) : null;
|
|
47051
|
-
const nextParagraph = (
|
|
47104
|
+
const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
|
|
47052
47105
|
return commitTableMutation(
|
|
47053
47106
|
current,
|
|
47054
47107
|
targetBlocks,
|
|
@@ -47081,12 +47134,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47081
47134
|
createEditorParagraph("")
|
|
47082
47135
|
]);
|
|
47083
47136
|
if (current.trackChangesEnabled) {
|
|
47084
|
-
insertedCell
|
|
47085
|
-
revision: {
|
|
47086
|
-
...createTableRevisionMetadata(),
|
|
47087
|
-
type: "insert"
|
|
47088
|
-
}
|
|
47089
|
-
};
|
|
47137
|
+
markTableRevision(insertedCell, "insert");
|
|
47090
47138
|
}
|
|
47091
47139
|
nextCells.push(insertedCell);
|
|
47092
47140
|
inserted = true;
|
|
@@ -47117,12 +47165,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47117
47165
|
createEditorParagraph("")
|
|
47118
47166
|
]);
|
|
47119
47167
|
if (current.trackChangesEnabled) {
|
|
47120
|
-
insertedCell
|
|
47121
|
-
revision: {
|
|
47122
|
-
...createTableRevisionMetadata(),
|
|
47123
|
-
type: "insert"
|
|
47124
|
-
}
|
|
47125
|
-
};
|
|
47168
|
+
markTableRevision(insertedCell, "insert");
|
|
47126
47169
|
}
|
|
47127
47170
|
nextCells.push(insertedCell);
|
|
47128
47171
|
}
|
|
@@ -47130,7 +47173,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47130
47173
|
}
|
|
47131
47174
|
const targetRow2 = tableBlock.rows[location.rowIndex];
|
|
47132
47175
|
const targetCell2 = targetRow2 ? findCellAtVisualColumn(targetRow2, insertVisualColumn) : null;
|
|
47133
|
-
const nextParagraph2 = (
|
|
47176
|
+
const nextParagraph2 = resolveNextTableParagraph(tableBlock, targetCell2);
|
|
47134
47177
|
return commitTableMutation(
|
|
47135
47178
|
current,
|
|
47136
47179
|
targetBlocks,
|
|
@@ -47148,18 +47191,13 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47148
47191
|
for (const row of tableBlock.rows) {
|
|
47149
47192
|
const insertedCell = createEditorTableCell([createEditorParagraph("")]);
|
|
47150
47193
|
if (current.trackChangesEnabled) {
|
|
47151
|
-
insertedCell
|
|
47152
|
-
revision: {
|
|
47153
|
-
...createTableRevisionMetadata(),
|
|
47154
|
-
type: "insert"
|
|
47155
|
-
}
|
|
47156
|
-
};
|
|
47194
|
+
markTableRevision(insertedCell, "insert");
|
|
47157
47195
|
}
|
|
47158
47196
|
row.cells.splice(insertIndex, 0, insertedCell);
|
|
47159
47197
|
}
|
|
47160
47198
|
const targetRow = tableBlock.rows[location.rowIndex];
|
|
47161
47199
|
const targetCell = targetRow == null ? void 0 : targetRow.cells[insertIndex];
|
|
47162
|
-
const nextParagraph = (
|
|
47200
|
+
const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
|
|
47163
47201
|
return commitTableMutation(
|
|
47164
47202
|
current,
|
|
47165
47203
|
targetBlocks,
|
|
@@ -47184,13 +47222,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47184
47222
|
for (const row of tableBlock.rows) {
|
|
47185
47223
|
const cell = findCellAtVisualColumn(row, visualColumn);
|
|
47186
47224
|
if (cell) {
|
|
47187
|
-
cell
|
|
47188
|
-
...cell.style ?? {},
|
|
47189
|
-
revision: {
|
|
47190
|
-
...createTableRevisionMetadata(),
|
|
47191
|
-
type: "delete"
|
|
47192
|
-
}
|
|
47193
|
-
};
|
|
47225
|
+
markTableRevision(cell, "delete");
|
|
47194
47226
|
}
|
|
47195
47227
|
}
|
|
47196
47228
|
return commitTableMutation(current, targetBlocks, location.zone, null);
|
|
@@ -47231,7 +47263,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47231
47263
|
Math.max(0, getRowVisualWidth(targetRow2) - 1)
|
|
47232
47264
|
)
|
|
47233
47265
|
);
|
|
47234
|
-
const nextParagraph2 = (
|
|
47266
|
+
const nextParagraph2 = resolveNextTableParagraph(tableBlock, targetCell2);
|
|
47235
47267
|
return commitTableMutation(
|
|
47236
47268
|
current,
|
|
47237
47269
|
targetBlocks,
|
|
@@ -47247,7 +47279,7 @@ function createTableRowColumnOperationsImpl(deps) {
|
|
|
47247
47279
|
}
|
|
47248
47280
|
const targetRow = tableBlock.rows[location.rowIndex];
|
|
47249
47281
|
const targetCell = targetRow == null ? void 0 : targetRow.cells[Math.min(location.cellIndex, targetRow.cells.length - 1)];
|
|
47250
|
-
const nextParagraph = (
|
|
47282
|
+
const nextParagraph = resolveNextTableParagraph(tableBlock, targetCell);
|
|
47251
47283
|
return commitTableMutation(
|
|
47252
47284
|
current,
|
|
47253
47285
|
targetBlocks,
|
|
@@ -49179,34 +49211,7 @@ function pxToPt(px) {
|
|
|
49179
49211
|
function ptToPx(pt) {
|
|
49180
49212
|
return pt * PIXELS_PER_POINT;
|
|
49181
49213
|
}
|
|
49182
|
-
|
|
49183
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
49184
|
-
return value;
|
|
49185
|
-
}
|
|
49186
|
-
if (typeof value !== "string") {
|
|
49187
|
-
return null;
|
|
49188
|
-
}
|
|
49189
|
-
const trimmed = value.trim().toLowerCase();
|
|
49190
|
-
if (!trimmed) {
|
|
49191
|
-
return null;
|
|
49192
|
-
}
|
|
49193
|
-
if (trimmed.endsWith("pt")) {
|
|
49194
|
-
const parsed2 = Number.parseFloat(trimmed.slice(0, -2));
|
|
49195
|
-
return Number.isFinite(parsed2) ? parsed2 : null;
|
|
49196
|
-
}
|
|
49197
|
-
if (trimmed.endsWith("px")) {
|
|
49198
|
-
const parsed2 = Number.parseFloat(trimmed.slice(0, -2));
|
|
49199
|
-
return Number.isFinite(parsed2) ? pxToPt(parsed2) : null;
|
|
49200
|
-
}
|
|
49201
|
-
if (trimmed.includes("%")) {
|
|
49202
|
-
return null;
|
|
49203
|
-
}
|
|
49204
|
-
if (!/^[+-]?\d+(\.\d+)?$/.test(trimmed)) {
|
|
49205
|
-
return null;
|
|
49206
|
-
}
|
|
49207
|
-
const parsed = Number.parseFloat(trimmed);
|
|
49208
|
-
return Number.isFinite(parsed) ? parsed : null;
|
|
49209
|
-
}
|
|
49214
|
+
const parseSizeToPt = parseUnitToPt;
|
|
49210
49215
|
const CONTENT_MIN_WIDTH_GUARD_PX = 12;
|
|
49211
49216
|
const CONTENT_MIN_HEIGHT_GUARD_PX = 4;
|
|
49212
49217
|
const DEFAULT_CELL_PADDING_LEFT_RIGHT_PX = 7.2;
|
|
@@ -49963,6 +49968,15 @@ function findNextWordBoundary(text, offset) {
|
|
|
49963
49968
|
}
|
|
49964
49969
|
const REUSE_MOUSE_DOWN_HIT_MAX_AGE_MS = 600;
|
|
49965
49970
|
const REUSE_MOUSE_DOWN_HIT_MAX_DISTANCE_PX = 8;
|
|
49971
|
+
function resolveZoneFirstParagraph(blocks, zone) {
|
|
49972
|
+
if (!blocks || blocks.length === 0) {
|
|
49973
|
+
const paragraph2 = createSectionBoundaryParagraph(zone);
|
|
49974
|
+
return { paragraph: paragraph2, blocks: [paragraph2] };
|
|
49975
|
+
}
|
|
49976
|
+
const firstBlock = blocks[0];
|
|
49977
|
+
const paragraph = firstBlock.type === "paragraph" ? firstBlock : getBlockParagraphs(firstBlock)[0] ?? null;
|
|
49978
|
+
return { paragraph, blocks };
|
|
49979
|
+
}
|
|
49966
49980
|
function resolveTripleClickParagraphRange(state, paragraph, targetZone) {
|
|
49967
49981
|
const zoneParagraphs = getDocumentParagraphs(state.document).filter(
|
|
49968
49982
|
(candidate) => {
|
|
@@ -50043,21 +50057,13 @@ function createEditorSurfaceEventsImpl(deps) {
|
|
|
50043
50057
|
let newFooter = section.footer;
|
|
50044
50058
|
let zoneParagraph = null;
|
|
50045
50059
|
if (targetZone === "header") {
|
|
50046
|
-
|
|
50047
|
-
|
|
50048
|
-
|
|
50049
|
-
} else {
|
|
50050
|
-
const firstBlock = newHeader[0];
|
|
50051
|
-
zoneParagraph = firstBlock.type === "paragraph" ? firstBlock : getBlockParagraphs(firstBlock)[0] ?? null;
|
|
50052
|
-
}
|
|
50060
|
+
const resolved = resolveZoneFirstParagraph(newHeader, "header");
|
|
50061
|
+
zoneParagraph = resolved.paragraph;
|
|
50062
|
+
newHeader = resolved.blocks;
|
|
50053
50063
|
} else if (targetZone === "footer") {
|
|
50054
|
-
|
|
50055
|
-
|
|
50056
|
-
|
|
50057
|
-
} else {
|
|
50058
|
-
const firstBlock = newFooter[0];
|
|
50059
|
-
zoneParagraph = firstBlock.type === "paragraph" ? firstBlock : getBlockParagraphs(firstBlock)[0] ?? null;
|
|
50060
|
-
}
|
|
50064
|
+
const resolved = resolveZoneFirstParagraph(newFooter, "footer");
|
|
50065
|
+
zoneParagraph = resolved.paragraph;
|
|
50066
|
+
newFooter = resolved.blocks;
|
|
50061
50067
|
}
|
|
50062
50068
|
if (newHeader !== section.header || newFooter !== section.footer) {
|
|
50063
50069
|
const newSections = [...sections];
|
|
@@ -53015,224 +53021,6 @@ function connectEditorClientHost(controller, deps) {
|
|
|
53015
53021
|
exportPdf: () => Promise.resolve(deps.docIO.handleExportPdf())
|
|
53016
53022
|
});
|
|
53017
53023
|
}
|
|
53018
|
-
const SHAPE_DEFAULT_WIDTH = 150;
|
|
53019
|
-
const SHAPE_DEFAULT_HEIGHT = 100;
|
|
53020
|
-
const SHAPE_DEFAULT_FILL = "#4472C4";
|
|
53021
|
-
const SHAPE_DEFAULT_BORDER_COLOR = "#2F528F";
|
|
53022
|
-
const SHAPE_DEFAULT_BORDER_WIDTH_PT = 1;
|
|
53023
|
-
function insertShapeAtSelection(state, preset) {
|
|
53024
|
-
const collapsedState = isSelectionCollapsed(state.selection) ? state : deleteSelectionRange(state);
|
|
53025
|
-
const { paragraph, index, offset } = getFocusParagraph(collapsedState);
|
|
53026
|
-
const textBox = {
|
|
53027
|
-
width: SHAPE_DEFAULT_WIDTH,
|
|
53028
|
-
height: SHAPE_DEFAULT_HEIGHT,
|
|
53029
|
-
blocks: [createEditorParagraph("")],
|
|
53030
|
-
shape: {
|
|
53031
|
-
preset,
|
|
53032
|
-
fill: SHAPE_DEFAULT_FILL,
|
|
53033
|
-
borderColor: SHAPE_DEFAULT_BORDER_COLOR,
|
|
53034
|
-
borderWidthPt: SHAPE_DEFAULT_BORDER_WIDTH_PT
|
|
53035
|
-
},
|
|
53036
|
-
floating: wrapPresetToFloating(void 0, "front")
|
|
53037
|
-
};
|
|
53038
|
-
const insertedRun = createEditorStyledRun(
|
|
53039
|
-
"",
|
|
53040
|
-
getStyleAtOffset(paragraph, offset),
|
|
53041
|
-
void 0,
|
|
53042
|
-
textBox
|
|
53043
|
-
);
|
|
53044
|
-
const nextParagraph = insertRunsAtOffset(paragraph, offset, [insertedRun]);
|
|
53045
|
-
const paragraphs = getParagraphs(collapsedState);
|
|
53046
|
-
const nextParagraphs = paragraphs.map(
|
|
53047
|
-
(candidate, candidateIndex) => candidateIndex === index ? nextParagraph : cloneParagraph(candidate)
|
|
53048
|
-
);
|
|
53049
|
-
return cloneStateWithParagraphs(
|
|
53050
|
-
collapsedState,
|
|
53051
|
-
nextParagraphs,
|
|
53052
|
-
withSelection(paragraphOffsetToPosition(nextParagraph, offset + 1))
|
|
53053
|
-
);
|
|
53054
|
-
}
|
|
53055
|
-
const DEFAULT_TOC_MAX_LEVEL = 3;
|
|
53056
|
-
const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
|
|
53057
|
-
const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
|
|
53058
|
-
function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
53059
|
-
var _a2;
|
|
53060
|
-
const headings = [];
|
|
53061
|
-
for (const paragraph of getDocumentParagraphs(state.document)) {
|
|
53062
|
-
const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
|
|
53063
|
-
if (level === null || level > maxLevel) continue;
|
|
53064
|
-
const text = getParagraphText(paragraph).trim();
|
|
53065
|
-
if (!text) continue;
|
|
53066
|
-
headings.push({ id: paragraph.id, level, text });
|
|
53067
|
-
}
|
|
53068
|
-
return headings;
|
|
53069
|
-
}
|
|
53070
|
-
function makeRun(partial) {
|
|
53071
|
-
const id = createEditorRun(partial.text).id;
|
|
53072
|
-
if (partial.fieldChar) {
|
|
53073
|
-
return {
|
|
53074
|
-
id,
|
|
53075
|
-
text: partial.text,
|
|
53076
|
-
kind: "fieldChar",
|
|
53077
|
-
fieldChar: partial.fieldChar
|
|
53078
|
-
};
|
|
53079
|
-
}
|
|
53080
|
-
if (partial.fieldInstruction !== void 0) {
|
|
53081
|
-
return {
|
|
53082
|
-
id,
|
|
53083
|
-
text: partial.text,
|
|
53084
|
-
kind: "fieldInstruction",
|
|
53085
|
-
fieldInstruction: partial.fieldInstruction
|
|
53086
|
-
};
|
|
53087
|
-
}
|
|
53088
|
-
return { id, text: partial.text, kind: "text" };
|
|
53089
|
-
}
|
|
53090
|
-
function makeParagraph(runs, style2) {
|
|
53091
|
-
const paragraph = createEditorParagraph("");
|
|
53092
|
-
paragraph.runs = runs;
|
|
53093
|
-
if (style2) paragraph.style = style2;
|
|
53094
|
-
return paragraph;
|
|
53095
|
-
}
|
|
53096
|
-
function buildEntryParagraph(heading, pageNumber, rightTabPositionPt) {
|
|
53097
|
-
const pageLabel = pageNumber !== void 0 ? String(pageNumber) : "";
|
|
53098
|
-
const run = makeRun({ text: `${heading.text} ${pageLabel}` });
|
|
53099
|
-
const style2 = {
|
|
53100
|
-
tabs: [{ position: rightTabPositionPt, type: "right", leader: "dot" }],
|
|
53101
|
-
spacingAfter: twipsToPx(40),
|
|
53102
|
-
indentLeft: twipsToPx((heading.level - 1) * 397)
|
|
53103
|
-
};
|
|
53104
|
-
return makeParagraph([run], style2);
|
|
53105
|
-
}
|
|
53106
|
-
function rightTabPositionForSection(section) {
|
|
53107
|
-
const { width, margins } = section.pageSettings;
|
|
53108
|
-
const contentWidthPx = Math.max(0, width - margins.left - margins.right);
|
|
53109
|
-
return roundTo(contentWidthPx * PT_PER_PX, 2);
|
|
53110
|
-
}
|
|
53111
|
-
function buildStartMarkerParagraph() {
|
|
53112
|
-
return makeParagraph([
|
|
53113
|
-
makeRun({ text: "", fieldChar: { kind: "begin" } }),
|
|
53114
|
-
makeRun({ text: "", fieldInstruction: TOC_INSTRUCTION }),
|
|
53115
|
-
makeRun({ text: "", fieldChar: { kind: "separate" } })
|
|
53116
|
-
]);
|
|
53117
|
-
}
|
|
53118
|
-
function buildEndMarkerParagraph() {
|
|
53119
|
-
return makeParagraph([makeRun({ text: "", fieldChar: { kind: "end" } })]);
|
|
53120
|
-
}
|
|
53121
|
-
function buildTocBlocks(headings, resolvePage, rightTabPositionPt) {
|
|
53122
|
-
const entries = headings.map(
|
|
53123
|
-
(heading) => buildEntryParagraph(heading, resolvePage(heading.id), rightTabPositionPt)
|
|
53124
|
-
);
|
|
53125
|
-
return [buildStartMarkerParagraph(), ...entries, buildEndMarkerParagraph()];
|
|
53126
|
-
}
|
|
53127
|
-
function replaceSectionBlocks(state, sectionIndex, nextBlocks, selectionParagraph) {
|
|
53128
|
-
const sections = getDocumentSections(state.document);
|
|
53129
|
-
const section = sections[sectionIndex];
|
|
53130
|
-
if (!section) return state;
|
|
53131
|
-
const nextSections = [...sections];
|
|
53132
|
-
nextSections[sectionIndex] = { ...section, blocks: nextBlocks };
|
|
53133
|
-
return {
|
|
53134
|
-
...state,
|
|
53135
|
-
document: { ...state.document, sections: nextSections },
|
|
53136
|
-
selection: withSelection(paragraphOffsetToPosition(selectionParagraph, 0))
|
|
53137
|
-
};
|
|
53138
|
-
}
|
|
53139
|
-
function insertTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
53140
|
-
const zone = getActiveZone(state);
|
|
53141
|
-
if (zone !== "main") return state;
|
|
53142
|
-
const sectionIndex = getActiveSectionIndex(state);
|
|
53143
|
-
const sections = getDocumentSections(state.document);
|
|
53144
|
-
const section = sections[sectionIndex];
|
|
53145
|
-
if (!section) return state;
|
|
53146
|
-
const headings = collectTocHeadings(state, maxLevel);
|
|
53147
|
-
const tocBlocks = buildTocBlocks(
|
|
53148
|
-
headings,
|
|
53149
|
-
resolvePage,
|
|
53150
|
-
rightTabPositionForSection(section)
|
|
53151
|
-
);
|
|
53152
|
-
const focus = clampPosition(state, state.selection.focus);
|
|
53153
|
-
const blockIndex = section.blocks.findIndex((block) => {
|
|
53154
|
-
if (block.id === focus.paragraphId) return true;
|
|
53155
|
-
if (block.type === "paragraph") return false;
|
|
53156
|
-
return getBlockParagraphs(block).some(
|
|
53157
|
-
(p) => p.id === focus.paragraphId
|
|
53158
|
-
);
|
|
53159
|
-
});
|
|
53160
|
-
const insertAt = blockIndex === -1 ? section.blocks.length : blockIndex + 1;
|
|
53161
|
-
const nextBlocks = [
|
|
53162
|
-
...section.blocks.slice(0, insertAt),
|
|
53163
|
-
...tocBlocks,
|
|
53164
|
-
...section.blocks.slice(insertAt)
|
|
53165
|
-
];
|
|
53166
|
-
return replaceSectionBlocks(state, sectionIndex, nextBlocks, tocBlocks[0]);
|
|
53167
|
-
}
|
|
53168
|
-
function findTocRegion(blocks) {
|
|
53169
|
-
let depth = 0;
|
|
53170
|
-
let instruction = "";
|
|
53171
|
-
let separateBlockIndex = -1;
|
|
53172
|
-
let beginBlockIndex = -1;
|
|
53173
|
-
let isToc = false;
|
|
53174
|
-
for (let i = 0; i < blocks.length; i += 1) {
|
|
53175
|
-
const block = blocks[i];
|
|
53176
|
-
if (block.type !== "paragraph") continue;
|
|
53177
|
-
for (const run of block.runs) {
|
|
53178
|
-
const fieldChar = getRunFieldChar(run);
|
|
53179
|
-
const fieldInstruction = getRunFieldInstruction(run);
|
|
53180
|
-
if ((fieldChar == null ? void 0 : fieldChar.kind) === "begin") {
|
|
53181
|
-
depth += 1;
|
|
53182
|
-
if (depth === 1) {
|
|
53183
|
-
beginBlockIndex = i;
|
|
53184
|
-
instruction = "";
|
|
53185
|
-
isToc = false;
|
|
53186
|
-
separateBlockIndex = -1;
|
|
53187
|
-
}
|
|
53188
|
-
} else if (depth === 1 && fieldInstruction !== void 0) {
|
|
53189
|
-
instruction += fieldInstruction;
|
|
53190
|
-
if (/\bTOC\b/i.test(instruction)) isToc = true;
|
|
53191
|
-
} else if ((fieldChar == null ? void 0 : fieldChar.kind) === "separate") {
|
|
53192
|
-
if (depth === 1) separateBlockIndex = i;
|
|
53193
|
-
} else if ((fieldChar == null ? void 0 : fieldChar.kind) === "end") {
|
|
53194
|
-
if (depth === 1) {
|
|
53195
|
-
if (isToc) {
|
|
53196
|
-
return {
|
|
53197
|
-
startBlockIndex: separateBlockIndex >= 0 ? separateBlockIndex : beginBlockIndex,
|
|
53198
|
-
endBlockIndex: i
|
|
53199
|
-
};
|
|
53200
|
-
}
|
|
53201
|
-
}
|
|
53202
|
-
depth = Math.max(0, depth - 1);
|
|
53203
|
-
}
|
|
53204
|
-
}
|
|
53205
|
-
}
|
|
53206
|
-
return null;
|
|
53207
|
-
}
|
|
53208
|
-
function updateTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
53209
|
-
const sectionIndex = getActiveSectionIndex(state);
|
|
53210
|
-
const sections = getDocumentSections(state.document);
|
|
53211
|
-
const section = sections[sectionIndex];
|
|
53212
|
-
if (!section) return state;
|
|
53213
|
-
const region = findTocRegion(section.blocks);
|
|
53214
|
-
if (!region) return state;
|
|
53215
|
-
const headings = collectTocHeadings(state, maxLevel);
|
|
53216
|
-
const entries = headings.map(
|
|
53217
|
-
(heading) => buildEntryParagraph(
|
|
53218
|
-
heading,
|
|
53219
|
-
resolvePage(heading.id),
|
|
53220
|
-
rightTabPositionForSection(section)
|
|
53221
|
-
)
|
|
53222
|
-
);
|
|
53223
|
-
const nextBlocks = [
|
|
53224
|
-
...section.blocks.slice(0, region.startBlockIndex + 1),
|
|
53225
|
-
...entries,
|
|
53226
|
-
...section.blocks.slice(region.endBlockIndex)
|
|
53227
|
-
];
|
|
53228
|
-
const selectionParagraph = entries[0] ?? section.blocks[region.startBlockIndex];
|
|
53229
|
-
return replaceSectionBlocks(
|
|
53230
|
-
state,
|
|
53231
|
-
sectionIndex,
|
|
53232
|
-
nextBlocks,
|
|
53233
|
-
selectionParagraph
|
|
53234
|
-
);
|
|
53235
|
-
}
|
|
53236
53024
|
function createCommandBuilder(isCommandEnabled) {
|
|
53237
53025
|
return (name, execute, state) => ({
|
|
53238
53026
|
execute,
|
|
@@ -53894,16 +53682,211 @@ function createEssentialsPlugin(deps) {
|
|
|
53894
53682
|
}
|
|
53895
53683
|
};
|
|
53896
53684
|
}
|
|
53897
|
-
function
|
|
53898
|
-
|
|
53685
|
+
function buildEssentialsGate(options) {
|
|
53686
|
+
return {
|
|
53899
53687
|
isCommandEnabled: (commandName) => !options.isReadOnly() && (commandName !== "insertFootnote" || options.commandsController.canInsertFootnoteCommand())
|
|
53900
53688
|
};
|
|
53901
|
-
|
|
53689
|
+
}
|
|
53690
|
+
function buildEssentialsStyle(options) {
|
|
53691
|
+
return {
|
|
53902
53692
|
state: () => options.styleController.toolbarStyleState()
|
|
53903
53693
|
};
|
|
53904
|
-
|
|
53694
|
+
}
|
|
53695
|
+
function buildEssentialsSelection(options) {
|
|
53696
|
+
return {
|
|
53905
53697
|
isCollapsed: () => isSelectionCollapsed(options.state().selection)
|
|
53906
53698
|
};
|
|
53699
|
+
}
|
|
53700
|
+
function buildEssentialsHistory(options) {
|
|
53701
|
+
return {
|
|
53702
|
+
canUndo: () => options.undoStack().length > 0,
|
|
53703
|
+
canRedo: () => options.redoStack().length > 0,
|
|
53704
|
+
undo: () => (options.historyActions.performUndo(), true),
|
|
53705
|
+
redo: () => (options.historyActions.performRedo(), true)
|
|
53706
|
+
};
|
|
53707
|
+
}
|
|
53708
|
+
const DEFAULT_TOC_MAX_LEVEL = 3;
|
|
53709
|
+
const TOC_INSTRUCTION = ' TOC \\o "1-3" \\h \\z \\u ';
|
|
53710
|
+
const twipsToPx = (twips) => Math.round(twips / TWIPS_PER_INCH * PX_PER_INCH);
|
|
53711
|
+
function collectTocHeadings(state, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
53712
|
+
var _a2;
|
|
53713
|
+
const headings = [];
|
|
53714
|
+
for (const paragraph of getDocumentParagraphs(state.document)) {
|
|
53715
|
+
const level = getHeadingLevel((_a2 = paragraph.style) == null ? void 0 : _a2.styleId);
|
|
53716
|
+
if (level === null || level > maxLevel) continue;
|
|
53717
|
+
const text = getParagraphText(paragraph).trim();
|
|
53718
|
+
if (!text) continue;
|
|
53719
|
+
headings.push({ id: paragraph.id, level, text });
|
|
53720
|
+
}
|
|
53721
|
+
return headings;
|
|
53722
|
+
}
|
|
53723
|
+
function makeRun(partial) {
|
|
53724
|
+
const id = createEditorRun(partial.text).id;
|
|
53725
|
+
if (partial.fieldChar) {
|
|
53726
|
+
return {
|
|
53727
|
+
id,
|
|
53728
|
+
text: partial.text,
|
|
53729
|
+
kind: "fieldChar",
|
|
53730
|
+
fieldChar: partial.fieldChar
|
|
53731
|
+
};
|
|
53732
|
+
}
|
|
53733
|
+
if (partial.fieldInstruction !== void 0) {
|
|
53734
|
+
return {
|
|
53735
|
+
id,
|
|
53736
|
+
text: partial.text,
|
|
53737
|
+
kind: "fieldInstruction",
|
|
53738
|
+
fieldInstruction: partial.fieldInstruction
|
|
53739
|
+
};
|
|
53740
|
+
}
|
|
53741
|
+
return { id, text: partial.text, kind: "text" };
|
|
53742
|
+
}
|
|
53743
|
+
function makeParagraph(runs, style2) {
|
|
53744
|
+
const paragraph = createEditorParagraph("");
|
|
53745
|
+
paragraph.runs = runs;
|
|
53746
|
+
if (style2) paragraph.style = style2;
|
|
53747
|
+
return paragraph;
|
|
53748
|
+
}
|
|
53749
|
+
function buildEntryParagraph(heading, pageNumber, rightTabPositionPt) {
|
|
53750
|
+
const pageLabel = pageNumber !== void 0 ? String(pageNumber) : "";
|
|
53751
|
+
const run = makeRun({ text: `${heading.text} ${pageLabel}` });
|
|
53752
|
+
const style2 = {
|
|
53753
|
+
tabs: [{ position: rightTabPositionPt, type: "right", leader: "dot" }],
|
|
53754
|
+
spacingAfter: twipsToPx(40),
|
|
53755
|
+
indentLeft: twipsToPx((heading.level - 1) * 397)
|
|
53756
|
+
};
|
|
53757
|
+
return makeParagraph([run], style2);
|
|
53758
|
+
}
|
|
53759
|
+
function rightTabPositionForSection(section) {
|
|
53760
|
+
const { width, margins } = section.pageSettings;
|
|
53761
|
+
const contentWidthPx = Math.max(0, width - margins.left - margins.right);
|
|
53762
|
+
return roundTo(contentWidthPx * PT_PER_PX, 2);
|
|
53763
|
+
}
|
|
53764
|
+
function buildStartMarkerParagraph() {
|
|
53765
|
+
return makeParagraph([
|
|
53766
|
+
makeRun({ text: "", fieldChar: { kind: "begin" } }),
|
|
53767
|
+
makeRun({ text: "", fieldInstruction: TOC_INSTRUCTION }),
|
|
53768
|
+
makeRun({ text: "", fieldChar: { kind: "separate" } })
|
|
53769
|
+
]);
|
|
53770
|
+
}
|
|
53771
|
+
function buildEndMarkerParagraph() {
|
|
53772
|
+
return makeParagraph([makeRun({ text: "", fieldChar: { kind: "end" } })]);
|
|
53773
|
+
}
|
|
53774
|
+
function buildTocBlocks(headings, resolvePage, rightTabPositionPt) {
|
|
53775
|
+
const entries = headings.map(
|
|
53776
|
+
(heading) => buildEntryParagraph(heading, resolvePage(heading.id), rightTabPositionPt)
|
|
53777
|
+
);
|
|
53778
|
+
return [buildStartMarkerParagraph(), ...entries, buildEndMarkerParagraph()];
|
|
53779
|
+
}
|
|
53780
|
+
function replaceSectionBlocks(state, sectionIndex, nextBlocks, selectionParagraph) {
|
|
53781
|
+
const sections = getDocumentSections(state.document);
|
|
53782
|
+
const section = sections[sectionIndex];
|
|
53783
|
+
if (!section) return state;
|
|
53784
|
+
const nextSections = [...sections];
|
|
53785
|
+
nextSections[sectionIndex] = { ...section, blocks: nextBlocks };
|
|
53786
|
+
return {
|
|
53787
|
+
...state,
|
|
53788
|
+
document: { ...state.document, sections: nextSections },
|
|
53789
|
+
selection: withSelection(paragraphOffsetToPosition(selectionParagraph, 0))
|
|
53790
|
+
};
|
|
53791
|
+
}
|
|
53792
|
+
function insertTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
53793
|
+
const zone = getActiveZone(state);
|
|
53794
|
+
if (zone !== "main") return state;
|
|
53795
|
+
const sectionIndex = getActiveSectionIndex(state);
|
|
53796
|
+
const sections = getDocumentSections(state.document);
|
|
53797
|
+
const section = sections[sectionIndex];
|
|
53798
|
+
if (!section) return state;
|
|
53799
|
+
const headings = collectTocHeadings(state, maxLevel);
|
|
53800
|
+
const tocBlocks = buildTocBlocks(
|
|
53801
|
+
headings,
|
|
53802
|
+
resolvePage,
|
|
53803
|
+
rightTabPositionForSection(section)
|
|
53804
|
+
);
|
|
53805
|
+
const focus = clampPosition(state, state.selection.focus);
|
|
53806
|
+
const blockIndex = section.blocks.findIndex((block) => {
|
|
53807
|
+
if (block.id === focus.paragraphId) return true;
|
|
53808
|
+
if (block.type === "paragraph") return false;
|
|
53809
|
+
return getBlockParagraphs(block).some(
|
|
53810
|
+
(p) => p.id === focus.paragraphId
|
|
53811
|
+
);
|
|
53812
|
+
});
|
|
53813
|
+
const insertAt = blockIndex === -1 ? section.blocks.length : blockIndex + 1;
|
|
53814
|
+
const nextBlocks = [
|
|
53815
|
+
...section.blocks.slice(0, insertAt),
|
|
53816
|
+
...tocBlocks,
|
|
53817
|
+
...section.blocks.slice(insertAt)
|
|
53818
|
+
];
|
|
53819
|
+
return replaceSectionBlocks(state, sectionIndex, nextBlocks, tocBlocks[0]);
|
|
53820
|
+
}
|
|
53821
|
+
function findTocRegion(blocks) {
|
|
53822
|
+
let depth = 0;
|
|
53823
|
+
let instruction = "";
|
|
53824
|
+
let separateBlockIndex = -1;
|
|
53825
|
+
let beginBlockIndex = -1;
|
|
53826
|
+
let isToc = false;
|
|
53827
|
+
for (let i = 0; i < blocks.length; i += 1) {
|
|
53828
|
+
const block = blocks[i];
|
|
53829
|
+
if (block.type !== "paragraph") continue;
|
|
53830
|
+
for (const run of block.runs) {
|
|
53831
|
+
const fieldChar = getRunFieldChar(run);
|
|
53832
|
+
const fieldInstruction = getRunFieldInstruction(run);
|
|
53833
|
+
if ((fieldChar == null ? void 0 : fieldChar.kind) === "begin") {
|
|
53834
|
+
depth += 1;
|
|
53835
|
+
if (depth === 1) {
|
|
53836
|
+
beginBlockIndex = i;
|
|
53837
|
+
instruction = "";
|
|
53838
|
+
isToc = false;
|
|
53839
|
+
separateBlockIndex = -1;
|
|
53840
|
+
}
|
|
53841
|
+
} else if (depth === 1 && fieldInstruction !== void 0) {
|
|
53842
|
+
instruction += fieldInstruction;
|
|
53843
|
+
if (/\bTOC\b/i.test(instruction)) isToc = true;
|
|
53844
|
+
} else if ((fieldChar == null ? void 0 : fieldChar.kind) === "separate") {
|
|
53845
|
+
if (depth === 1) separateBlockIndex = i;
|
|
53846
|
+
} else if ((fieldChar == null ? void 0 : fieldChar.kind) === "end") {
|
|
53847
|
+
if (depth === 1) {
|
|
53848
|
+
if (isToc) {
|
|
53849
|
+
return {
|
|
53850
|
+
startBlockIndex: separateBlockIndex >= 0 ? separateBlockIndex : beginBlockIndex,
|
|
53851
|
+
endBlockIndex: i
|
|
53852
|
+
};
|
|
53853
|
+
}
|
|
53854
|
+
}
|
|
53855
|
+
depth = Math.max(0, depth - 1);
|
|
53856
|
+
}
|
|
53857
|
+
}
|
|
53858
|
+
}
|
|
53859
|
+
return null;
|
|
53860
|
+
}
|
|
53861
|
+
function updateTableOfContents(state, resolvePage = () => void 0, maxLevel = DEFAULT_TOC_MAX_LEVEL) {
|
|
53862
|
+
const sectionIndex = getActiveSectionIndex(state);
|
|
53863
|
+
const sections = getDocumentSections(state.document);
|
|
53864
|
+
const section = sections[sectionIndex];
|
|
53865
|
+
if (!section) return state;
|
|
53866
|
+
const region = findTocRegion(section.blocks);
|
|
53867
|
+
if (!region) return state;
|
|
53868
|
+
const headings = collectTocHeadings(state, maxLevel);
|
|
53869
|
+
const entries = headings.map(
|
|
53870
|
+
(heading) => buildEntryParagraph(
|
|
53871
|
+
heading,
|
|
53872
|
+
resolvePage(heading.id),
|
|
53873
|
+
rightTabPositionForSection(section)
|
|
53874
|
+
)
|
|
53875
|
+
);
|
|
53876
|
+
const nextBlocks = [
|
|
53877
|
+
...section.blocks.slice(0, region.startBlockIndex + 1),
|
|
53878
|
+
...entries,
|
|
53879
|
+
...section.blocks.slice(region.endBlockIndex)
|
|
53880
|
+
];
|
|
53881
|
+
const selectionParagraph = entries[0] ?? section.blocks[region.startBlockIndex];
|
|
53882
|
+
return replaceSectionBlocks(
|
|
53883
|
+
state,
|
|
53884
|
+
sectionIndex,
|
|
53885
|
+
nextBlocks,
|
|
53886
|
+
selectionParagraph
|
|
53887
|
+
);
|
|
53888
|
+
}
|
|
53889
|
+
function buildEssentialsFormatting(options) {
|
|
53907
53890
|
const stepFontSize = (direction) => {
|
|
53908
53891
|
const currentPx = Number(
|
|
53909
53892
|
options.styleController.toolbarStyleState().fontSize
|
|
@@ -53916,12 +53899,6 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
53916
53899
|
);
|
|
53917
53900
|
return true;
|
|
53918
53901
|
};
|
|
53919
|
-
const essentialsHistory = {
|
|
53920
|
-
canUndo: () => options.undoStack().length > 0,
|
|
53921
|
-
canRedo: () => options.redoStack().length > 0,
|
|
53922
|
-
undo: () => (options.historyActions.performUndo(), true),
|
|
53923
|
-
redo: () => (options.historyActions.performRedo(), true)
|
|
53924
|
-
};
|
|
53925
53902
|
const buildTocPageResolver = (state) => {
|
|
53926
53903
|
const layout = projectDocumentLayout(state.document);
|
|
53927
53904
|
const pageByParagraph = /* @__PURE__ */ new Map();
|
|
@@ -53935,7 +53912,7 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
53935
53912
|
}
|
|
53936
53913
|
return (headingId) => pageByParagraph.get(headingId);
|
|
53937
53914
|
};
|
|
53938
|
-
|
|
53915
|
+
return {
|
|
53939
53916
|
selectAll: () => {
|
|
53940
53917
|
const paragraphs = getDocumentParagraphs(options.state().document);
|
|
53941
53918
|
if (paragraphs.length === 0) return false;
|
|
@@ -54054,7 +54031,46 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
54054
54031
|
), true),
|
|
54055
54032
|
setUnderlineStyle: (value) => options.styleController.applyToolbarValueStyleCommand("underlineStyle", value)
|
|
54056
54033
|
};
|
|
54057
|
-
|
|
54034
|
+
}
|
|
54035
|
+
const SHAPE_DEFAULT_WIDTH = 150;
|
|
54036
|
+
const SHAPE_DEFAULT_HEIGHT = 100;
|
|
54037
|
+
const SHAPE_DEFAULT_FILL = "#4472C4";
|
|
54038
|
+
const SHAPE_DEFAULT_BORDER_COLOR = "#2F528F";
|
|
54039
|
+
const SHAPE_DEFAULT_BORDER_WIDTH_PT = 1;
|
|
54040
|
+
function insertShapeAtSelection(state, preset) {
|
|
54041
|
+
const collapsedState = isSelectionCollapsed(state.selection) ? state : deleteSelectionRange(state);
|
|
54042
|
+
const { paragraph, index, offset } = getFocusParagraph(collapsedState);
|
|
54043
|
+
const textBox = {
|
|
54044
|
+
width: SHAPE_DEFAULT_WIDTH,
|
|
54045
|
+
height: SHAPE_DEFAULT_HEIGHT,
|
|
54046
|
+
blocks: [createEditorParagraph("")],
|
|
54047
|
+
shape: {
|
|
54048
|
+
preset,
|
|
54049
|
+
fill: SHAPE_DEFAULT_FILL,
|
|
54050
|
+
borderColor: SHAPE_DEFAULT_BORDER_COLOR,
|
|
54051
|
+
borderWidthPt: SHAPE_DEFAULT_BORDER_WIDTH_PT
|
|
54052
|
+
},
|
|
54053
|
+
floating: wrapPresetToFloating(void 0, "front")
|
|
54054
|
+
};
|
|
54055
|
+
const insertedRun = createEditorStyledRun(
|
|
54056
|
+
"",
|
|
54057
|
+
getStyleAtOffset(paragraph, offset),
|
|
54058
|
+
void 0,
|
|
54059
|
+
textBox
|
|
54060
|
+
);
|
|
54061
|
+
const nextParagraph = insertRunsAtOffset(paragraph, offset, [insertedRun]);
|
|
54062
|
+
const paragraphs = getParagraphs(collapsedState);
|
|
54063
|
+
const nextParagraphs = paragraphs.map(
|
|
54064
|
+
(candidate, candidateIndex) => candidateIndex === index ? nextParagraph : cloneParagraph(candidate)
|
|
54065
|
+
);
|
|
54066
|
+
return cloneStateWithParagraphs(
|
|
54067
|
+
collapsedState,
|
|
54068
|
+
nextParagraphs,
|
|
54069
|
+
withSelection(paragraphOffsetToPosition(nextParagraph, offset + 1))
|
|
54070
|
+
);
|
|
54071
|
+
}
|
|
54072
|
+
function buildEssentialsDocument(options) {
|
|
54073
|
+
return {
|
|
54058
54074
|
documentStyles: () => {
|
|
54059
54075
|
var _a2, _b2;
|
|
54060
54076
|
const document2 = options.state().document;
|
|
@@ -54100,23 +54116,31 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
54100
54116
|
(current) => insertShapeAtSelection(current, preset)
|
|
54101
54117
|
)
|
|
54102
54118
|
};
|
|
54103
|
-
|
|
54119
|
+
}
|
|
54120
|
+
function buildEssentialsLink(options) {
|
|
54121
|
+
return {
|
|
54104
54122
|
prompt: () => options.commandsController.promptForLink(),
|
|
54105
54123
|
remove: () => options.commandsController.removeLinkCommand(),
|
|
54106
54124
|
canPrompt: () => !isSelectionCollapsed(options.state().selection) || Boolean(options.styleController.toolbarStyleState().link)
|
|
54107
54125
|
};
|
|
54108
|
-
|
|
54126
|
+
}
|
|
54127
|
+
function buildEssentialsImage(options) {
|
|
54128
|
+
return {
|
|
54109
54129
|
promptAlt: () => options.commandsController.promptForImageAlt(),
|
|
54110
54130
|
promptCaption: () => options.commandsController.promptForImageCaption(),
|
|
54111
54131
|
isSelected: () => Boolean(options.selectedImageRun())
|
|
54112
54132
|
};
|
|
54113
|
-
|
|
54133
|
+
}
|
|
54134
|
+
function buildEssentialsBrowser() {
|
|
54135
|
+
return {
|
|
54114
54136
|
print: () => window.print(),
|
|
54115
54137
|
copy: () => {
|
|
54116
54138
|
document.execCommand("copy");
|
|
54117
54139
|
}
|
|
54118
54140
|
};
|
|
54119
|
-
|
|
54141
|
+
}
|
|
54142
|
+
function buildEssentialsParagraph(options) {
|
|
54143
|
+
return {
|
|
54120
54144
|
togglePageBreakBefore: () => options.commandsController.toggleParagraphFlagCommand("pageBreakBefore"),
|
|
54121
54145
|
toggleKeepWithNext: () => options.commandsController.toggleParagraphFlagCommand("keepWithNext"),
|
|
54122
54146
|
setSpacingAfter: (value) => options.commandsController.applyParagraphStyleCommand(
|
|
@@ -54190,21 +54214,23 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
54190
54214
|
outdent: () => void options.commandsController.handleListTab("outdent"),
|
|
54191
54215
|
indent: () => void options.commandsController.handleListTab("indent")
|
|
54192
54216
|
};
|
|
54193
|
-
|
|
54217
|
+
}
|
|
54218
|
+
function buildEssentialsSection(options) {
|
|
54219
|
+
const section = {
|
|
54194
54220
|
isLandscape: () => {
|
|
54195
54221
|
var _a2, _b2;
|
|
54196
54222
|
const idx = getActiveSectionIndex(options.state());
|
|
54197
|
-
const
|
|
54198
|
-
return ((_b2 =
|
|
54223
|
+
const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
54224
|
+
return ((_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.orientation) === "landscape";
|
|
54199
54225
|
},
|
|
54200
54226
|
setOrientation: (orientation) => {
|
|
54201
54227
|
var _a2;
|
|
54202
54228
|
const idx = getActiveSectionIndex(options.state());
|
|
54203
|
-
const
|
|
54204
|
-
if (!
|
|
54229
|
+
const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
54230
|
+
if (!target) return;
|
|
54205
54231
|
options.commandsController.applyUpdateSectionSettingsCommand(idx, {
|
|
54206
54232
|
pageSettings: {
|
|
54207
|
-
...
|
|
54233
|
+
...target.pageSettings,
|
|
54208
54234
|
orientation
|
|
54209
54235
|
}
|
|
54210
54236
|
});
|
|
@@ -54212,259 +54238,259 @@ function createEditorEssentialsRuntimePlugin(options) {
|
|
|
54212
54238
|
toggleOrientation: () => {
|
|
54213
54239
|
var _a2, _b2;
|
|
54214
54240
|
const idx = getActiveSectionIndex(options.state());
|
|
54215
|
-
const
|
|
54216
|
-
if (!
|
|
54217
|
-
const current = ((_b2 =
|
|
54218
|
-
|
|
54219
|
-
current === "portrait" ? "landscape" : "portrait"
|
|
54220
|
-
);
|
|
54241
|
+
const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
54242
|
+
if (!target) return;
|
|
54243
|
+
const current = ((_b2 = target.pageSettings) == null ? void 0 : _b2.orientation) ?? "portrait";
|
|
54244
|
+
section.setOrientation(current === "portrait" ? "landscape" : "portrait");
|
|
54221
54245
|
},
|
|
54222
54246
|
breakNextPage: () => options.commandsController.applyInsertSectionBreakCommand("nextPage"),
|
|
54223
54247
|
breakContinuous: () => options.commandsController.applyInsertSectionBreakCommand("continuous"),
|
|
54224
54248
|
getMargins: () => {
|
|
54225
54249
|
var _a2, _b2;
|
|
54226
54250
|
const idx = getActiveSectionIndex(options.state());
|
|
54227
|
-
const
|
|
54228
|
-
return (_b2 =
|
|
54251
|
+
const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
54252
|
+
return (_b2 = target == null ? void 0 : target.pageSettings) == null ? void 0 : _b2.margins;
|
|
54229
54253
|
},
|
|
54230
54254
|
setPageMargins: (margins) => {
|
|
54231
54255
|
var _a2;
|
|
54232
54256
|
const idx = getActiveSectionIndex(options.state());
|
|
54233
|
-
const
|
|
54234
|
-
if (!(
|
|
54257
|
+
const target = ((_a2 = options.state().document.sections) == null ? void 0 : _a2[idx]) ?? options.state().document;
|
|
54258
|
+
if (!(target == null ? void 0 : target.pageSettings)) return;
|
|
54235
54259
|
options.commandsController.applyUpdateSectionSettingsCommand(idx, {
|
|
54236
54260
|
pageSettings: {
|
|
54237
|
-
...
|
|
54261
|
+
...target.pageSettings,
|
|
54238
54262
|
margins: {
|
|
54239
|
-
...
|
|
54263
|
+
...target.pageSettings.margins,
|
|
54240
54264
|
...margins
|
|
54241
54265
|
}
|
|
54242
54266
|
}
|
|
54243
54267
|
});
|
|
54244
54268
|
}
|
|
54245
54269
|
};
|
|
54246
|
-
|
|
54247
|
-
|
|
54248
|
-
|
|
54249
|
-
|
|
54250
|
-
|
|
54251
|
-
|
|
54252
|
-
)
|
|
54270
|
+
return section;
|
|
54271
|
+
}
|
|
54272
|
+
function buildEssentialsTable(options) {
|
|
54273
|
+
const insideTable = () => Boolean(
|
|
54274
|
+
findParagraphTableLocation(
|
|
54275
|
+
options.state().document,
|
|
54276
|
+
options.state().selection.focus.paragraphId,
|
|
54277
|
+
getActiveSectionIndex(options.state())
|
|
54278
|
+
)
|
|
54279
|
+
);
|
|
54280
|
+
const apply = (producer, mergeKey) => {
|
|
54281
|
+
options.applyTransactionalState(producer, { mergeKey });
|
|
54282
|
+
options.focusInput();
|
|
54283
|
+
};
|
|
54284
|
+
const RAW_TBL_LOOK_DEFAULTS = {
|
|
54285
|
+
firstRow: false,
|
|
54286
|
+
lastRow: false,
|
|
54287
|
+
firstCol: false,
|
|
54288
|
+
lastCol: false,
|
|
54289
|
+
noHBand: false,
|
|
54290
|
+
noVBand: false
|
|
54291
|
+
};
|
|
54292
|
+
const selectedTableIn = (state) => {
|
|
54293
|
+
const secIdx = getActiveSectionIndex(state);
|
|
54294
|
+
const loc = findParagraphTableLocation(
|
|
54295
|
+
state.document,
|
|
54296
|
+
state.selection.focus.paragraphId,
|
|
54297
|
+
secIdx
|
|
54253
54298
|
);
|
|
54254
|
-
|
|
54255
|
-
|
|
54256
|
-
|
|
54257
|
-
|
|
54258
|
-
const
|
|
54259
|
-
|
|
54260
|
-
|
|
54261
|
-
|
|
54262
|
-
|
|
54263
|
-
|
|
54264
|
-
|
|
54265
|
-
};
|
|
54266
|
-
|
|
54267
|
-
|
|
54268
|
-
|
|
54269
|
-
|
|
54270
|
-
|
|
54271
|
-
|
|
54272
|
-
)
|
|
54273
|
-
|
|
54274
|
-
|
|
54275
|
-
|
|
54276
|
-
|
|
54277
|
-
|
|
54278
|
-
|
|
54279
|
-
|
|
54280
|
-
|
|
54281
|
-
|
|
54282
|
-
|
|
54283
|
-
|
|
54284
|
-
|
|
54285
|
-
|
|
54286
|
-
|
|
54287
|
-
|
|
54288
|
-
|
|
54289
|
-
|
|
54290
|
-
|
|
54291
|
-
|
|
54292
|
-
|
|
54293
|
-
|
|
54294
|
-
|
|
54295
|
-
|
|
54296
|
-
|
|
54297
|
-
|
|
54298
|
-
|
|
54299
|
-
|
|
54300
|
-
|
|
54301
|
-
|
|
54299
|
+
if (!loc) return null;
|
|
54300
|
+
const section = getDocumentSections(state.document)[secIdx];
|
|
54301
|
+
if (!section) return null;
|
|
54302
|
+
const blocks = loc.zone === "header" ? section.header ?? [] : loc.zone === "footer" ? section.footer ?? [] : section.blocks;
|
|
54303
|
+
const table = blocks[loc.blockIndex];
|
|
54304
|
+
return table && table.type === "table" ? table : null;
|
|
54305
|
+
};
|
|
54306
|
+
const rawTblLookIn = (state) => {
|
|
54307
|
+
var _a2;
|
|
54308
|
+
const table = selectedTableIn(state);
|
|
54309
|
+
if (!table) return null;
|
|
54310
|
+
return { ...RAW_TBL_LOOK_DEFAULTS, ...((_a2 = table.style) == null ? void 0 : _a2.tblLook) ?? {} };
|
|
54311
|
+
};
|
|
54312
|
+
const selectionLabel = () => {
|
|
54313
|
+
const normalized = normalizeSelection(options.state());
|
|
54314
|
+
if (normalized.isCollapsed) return null;
|
|
54315
|
+
const secIdx = getActiveSectionIndex(options.state());
|
|
54316
|
+
const anchorLoc = findParagraphTableLocation(
|
|
54317
|
+
options.state().document,
|
|
54318
|
+
options.state().selection.anchor.paragraphId,
|
|
54319
|
+
secIdx
|
|
54320
|
+
);
|
|
54321
|
+
const focusLoc = findParagraphTableLocation(
|
|
54322
|
+
options.state().document,
|
|
54323
|
+
options.state().selection.focus.paragraphId,
|
|
54324
|
+
secIdx
|
|
54325
|
+
);
|
|
54326
|
+
if (!anchorLoc || !focusLoc || anchorLoc.blockIndex !== focusLoc.blockIndex || anchorLoc.rowIndex === focusLoc.rowIndex && anchorLoc.cellIndex === focusLoc.cellIndex) {
|
|
54327
|
+
return null;
|
|
54328
|
+
}
|
|
54329
|
+
const count = options.selectionBoxes().length;
|
|
54330
|
+
if (count === 0) return null;
|
|
54331
|
+
return `Table selection: ${count} cell${count === 1 ? "" : "s"}`;
|
|
54332
|
+
};
|
|
54333
|
+
return {
|
|
54334
|
+
insideTable,
|
|
54335
|
+
selectionLabel,
|
|
54336
|
+
getTblLook: () => {
|
|
54337
|
+
const raw = rawTblLookIn(options.state());
|
|
54338
|
+
if (!raw) return null;
|
|
54339
|
+
return {
|
|
54340
|
+
firstRow: raw.firstRow,
|
|
54341
|
+
lastRow: raw.lastRow,
|
|
54342
|
+
firstCol: raw.firstCol,
|
|
54343
|
+
lastCol: raw.lastCol,
|
|
54344
|
+
// Banding is stored as the negated "no band" flags in OOXML.
|
|
54345
|
+
bandedRows: !raw.noHBand,
|
|
54346
|
+
bandedCols: !raw.noVBand
|
|
54347
|
+
};
|
|
54348
|
+
},
|
|
54349
|
+
toggleTblLook: (flag) => apply((current) => {
|
|
54350
|
+
const raw = rawTblLookIn(current);
|
|
54351
|
+
if (!raw) return current;
|
|
54352
|
+
const next = { ...raw };
|
|
54353
|
+
switch (flag) {
|
|
54354
|
+
case "firstRow":
|
|
54355
|
+
next.firstRow = !raw.firstRow;
|
|
54356
|
+
break;
|
|
54357
|
+
case "lastRow":
|
|
54358
|
+
next.lastRow = !raw.lastRow;
|
|
54359
|
+
break;
|
|
54360
|
+
case "firstCol":
|
|
54361
|
+
next.firstCol = !raw.firstCol;
|
|
54362
|
+
break;
|
|
54363
|
+
case "lastCol":
|
|
54364
|
+
next.lastCol = !raw.lastCol;
|
|
54365
|
+
break;
|
|
54366
|
+
case "bandedRows":
|
|
54367
|
+
next.noHBand = !raw.noHBand;
|
|
54368
|
+
break;
|
|
54369
|
+
case "bandedCols":
|
|
54370
|
+
next.noVBand = !raw.noVBand;
|
|
54371
|
+
break;
|
|
54302
54372
|
}
|
|
54303
|
-
|
|
54304
|
-
|
|
54305
|
-
|
|
54306
|
-
|
|
54307
|
-
|
|
54308
|
-
|
|
54309
|
-
|
|
54310
|
-
|
|
54311
|
-
|
|
54312
|
-
|
|
54313
|
-
|
|
54314
|
-
|
|
54315
|
-
|
|
54316
|
-
|
|
54317
|
-
|
|
54318
|
-
|
|
54319
|
-
|
|
54320
|
-
|
|
54321
|
-
|
|
54322
|
-
|
|
54323
|
-
|
|
54324
|
-
|
|
54325
|
-
|
|
54326
|
-
|
|
54327
|
-
|
|
54328
|
-
|
|
54329
|
-
|
|
54330
|
-
|
|
54331
|
-
|
|
54332
|
-
|
|
54333
|
-
|
|
54334
|
-
|
|
54335
|
-
|
|
54336
|
-
|
|
54337
|
-
|
|
54338
|
-
|
|
54339
|
-
|
|
54340
|
-
|
|
54341
|
-
|
|
54342
|
-
|
|
54343
|
-
|
|
54344
|
-
|
|
54345
|
-
|
|
54346
|
-
|
|
54347
|
-
|
|
54348
|
-
|
|
54349
|
-
|
|
54350
|
-
|
|
54351
|
-
|
|
54352
|
-
|
|
54353
|
-
|
|
54354
|
-
|
|
54355
|
-
|
|
54356
|
-
),
|
|
54357
|
-
|
|
54358
|
-
|
|
54359
|
-
|
|
54360
|
-
|
|
54361
|
-
|
|
54362
|
-
|
|
54363
|
-
|
|
54364
|
-
|
|
54365
|
-
|
|
54366
|
-
|
|
54367
|
-
|
|
54368
|
-
|
|
54369
|
-
|
|
54370
|
-
|
|
54371
|
-
|
|
54372
|
-
|
|
54373
|
-
|
|
54374
|
-
|
|
54375
|
-
|
|
54376
|
-
|
|
54377
|
-
|
|
54378
|
-
|
|
54379
|
-
|
|
54380
|
-
|
|
54381
|
-
|
|
54382
|
-
|
|
54383
|
-
|
|
54384
|
-
|
|
54385
|
-
|
|
54386
|
-
|
|
54387
|
-
|
|
54388
|
-
|
|
54389
|
-
|
|
54390
|
-
|
|
54391
|
-
|
|
54392
|
-
|
|
54393
|
-
|
|
54394
|
-
|
|
54395
|
-
|
|
54396
|
-
|
|
54397
|
-
|
|
54398
|
-
|
|
54399
|
-
|
|
54400
|
-
|
|
54401
|
-
|
|
54402
|
-
|
|
54403
|
-
|
|
54404
|
-
|
|
54405
|
-
|
|
54406
|
-
|
|
54407
|
-
|
|
54408
|
-
(current) => options.tableOps.deleteSelectedTableRow(current),
|
|
54409
|
-
MERGE_KEYS.deleteTableRow
|
|
54410
|
-
),
|
|
54411
|
-
cellShading: (color) => apply(
|
|
54412
|
-
(current) => setTableCellStyleValue(current, "shading", color || null),
|
|
54413
|
-
MERGE_KEYS.tableShading
|
|
54414
|
-
),
|
|
54415
|
-
cellBorders: () => apply(
|
|
54416
|
-
(current) => setTableCellBorders(current, {
|
|
54417
|
-
width: 1,
|
|
54418
|
-
type: "solid",
|
|
54419
|
-
color: "#64748b"
|
|
54420
|
-
}),
|
|
54421
|
-
MERGE_KEYS.tableBorders
|
|
54422
|
-
),
|
|
54423
|
-
cellNoBorders: () => apply(
|
|
54424
|
-
(current) => setTableCellBorders(current, {
|
|
54425
|
-
width: 0,
|
|
54426
|
-
type: "none",
|
|
54427
|
-
color: "transparent"
|
|
54428
|
-
}),
|
|
54429
|
-
MERGE_KEYS.tableBorders
|
|
54430
|
-
),
|
|
54431
|
-
width100: () => apply(
|
|
54432
|
-
(current) => setTableStyleValue(current, "width", "100%"),
|
|
54433
|
-
MERGE_KEYS.tableWidth
|
|
54434
|
-
),
|
|
54435
|
-
alignLeft: () => apply(
|
|
54436
|
-
(current) => setTableCellStyleValue(current, "horizontalAlign", "left"),
|
|
54437
|
-
MERGE_KEYS.tableAlign
|
|
54438
|
-
),
|
|
54439
|
-
alignCenter: () => apply(
|
|
54440
|
-
(current) => setTableCellStyleValue(current, "horizontalAlign", "center"),
|
|
54441
|
-
MERGE_KEYS.tableAlign
|
|
54442
|
-
),
|
|
54443
|
-
alignRight: () => apply(
|
|
54444
|
-
(current) => setTableCellStyleValue(current, "horizontalAlign", "right"),
|
|
54445
|
-
MERGE_KEYS.tableAlign
|
|
54446
|
-
),
|
|
54447
|
-
setCellWidth: (width) => apply(
|
|
54448
|
-
(current) => setTableCellWidth(current, width),
|
|
54449
|
-
MERGE_KEYS.tableCellWidth
|
|
54450
|
-
),
|
|
54451
|
-
insert: (rows, cols) => options.tableOps.insertTableCommand(rows, cols)
|
|
54452
|
-
};
|
|
54373
|
+
return setTableStyleValue(current, "tblLook", next);
|
|
54374
|
+
}, MERGE_KEYS.tableStyleOptions),
|
|
54375
|
+
getStyleId: () => {
|
|
54376
|
+
var _a2, _b2;
|
|
54377
|
+
return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.styleId) ?? null;
|
|
54378
|
+
},
|
|
54379
|
+
setStyleId: (styleId) => apply(
|
|
54380
|
+
(current) => setTableStyleValue(current, "styleId", styleId || null),
|
|
54381
|
+
MERGE_KEYS.tableStyleGallery
|
|
54382
|
+
),
|
|
54383
|
+
getLayout: () => {
|
|
54384
|
+
var _a2, _b2;
|
|
54385
|
+
return ((_b2 = (_a2 = selectedTableIn(options.state())) == null ? void 0 : _a2.style) == null ? void 0 : _b2.layout) ?? null;
|
|
54386
|
+
},
|
|
54387
|
+
toggleAutoFit: () => apply((current) => {
|
|
54388
|
+
var _a2;
|
|
54389
|
+
const table = selectedTableIn(current);
|
|
54390
|
+
const nextLayout = ((_a2 = table == null ? void 0 : table.style) == null ? void 0 : _a2.layout) === "autofit" ? "fixed" : "autofit";
|
|
54391
|
+
return setTableStyleValue(current, "layout", nextLayout);
|
|
54392
|
+
}, MERGE_KEYS.tableDistribute),
|
|
54393
|
+
distributeColumns: () => apply(
|
|
54394
|
+
(current) => distributeSelectedTableColumns(current),
|
|
54395
|
+
MERGE_KEYS.tableDistribute
|
|
54396
|
+
),
|
|
54397
|
+
distributeRows: () => apply(
|
|
54398
|
+
(current) => distributeSelectedTableRows(current),
|
|
54399
|
+
MERGE_KEYS.tableDistribute
|
|
54400
|
+
),
|
|
54401
|
+
canMerge: () => options.tableOps.canMergeSelectedTable(options.state()),
|
|
54402
|
+
canSplit: () => options.tableOps.canSplitSelectedTable(options.state()),
|
|
54403
|
+
canEditColumn: () => options.tableOps.canEditSelectedTableColumn(options.state()),
|
|
54404
|
+
canEditRow: () => options.tableOps.canEditSelectedTableRow(options.state()),
|
|
54405
|
+
merge: () => apply(
|
|
54406
|
+
(current) => options.tableOps.mergeSelectedTable(current),
|
|
54407
|
+
MERGE_KEYS.mergeTable
|
|
54408
|
+
),
|
|
54409
|
+
split: () => apply(
|
|
54410
|
+
(current) => options.tableOps.splitSelectedTable(current),
|
|
54411
|
+
MERGE_KEYS.splitTable
|
|
54412
|
+
),
|
|
54413
|
+
insertColumnBefore: () => apply(
|
|
54414
|
+
(current) => options.tableOps.insertSelectedTableColumn(current, -1),
|
|
54415
|
+
MERGE_KEYS.insertTableColumn
|
|
54416
|
+
),
|
|
54417
|
+
insertColumnAfter: () => apply(
|
|
54418
|
+
(current) => options.tableOps.insertSelectedTableColumn(current, 1),
|
|
54419
|
+
MERGE_KEYS.insertTableColumn
|
|
54420
|
+
),
|
|
54421
|
+
deleteColumn: () => apply(
|
|
54422
|
+
(current) => options.tableOps.deleteSelectedTableColumn(current),
|
|
54423
|
+
MERGE_KEYS.deleteTableColumn
|
|
54424
|
+
),
|
|
54425
|
+
insertRowBefore: () => apply(
|
|
54426
|
+
(current) => options.tableOps.insertSelectedTableRow(current, -1),
|
|
54427
|
+
MERGE_KEYS.insertTableRow
|
|
54428
|
+
),
|
|
54429
|
+
insertRowAfter: () => apply(
|
|
54430
|
+
(current) => options.tableOps.insertSelectedTableRow(current, 1),
|
|
54431
|
+
MERGE_KEYS.insertTableRow
|
|
54432
|
+
),
|
|
54433
|
+
deleteRow: () => apply(
|
|
54434
|
+
(current) => options.tableOps.deleteSelectedTableRow(current),
|
|
54435
|
+
MERGE_KEYS.deleteTableRow
|
|
54436
|
+
),
|
|
54437
|
+
cellShading: (color) => apply(
|
|
54438
|
+
(current) => setTableCellStyleValue(current, "shading", color || null),
|
|
54439
|
+
MERGE_KEYS.tableShading
|
|
54440
|
+
),
|
|
54441
|
+
cellBorders: () => apply(
|
|
54442
|
+
(current) => setTableCellBorders(current, {
|
|
54443
|
+
width: 1,
|
|
54444
|
+
type: "solid",
|
|
54445
|
+
color: "#64748b"
|
|
54446
|
+
}),
|
|
54447
|
+
MERGE_KEYS.tableBorders
|
|
54448
|
+
),
|
|
54449
|
+
cellNoBorders: () => apply(
|
|
54450
|
+
(current) => setTableCellBorders(current, {
|
|
54451
|
+
width: 0,
|
|
54452
|
+
type: "none",
|
|
54453
|
+
color: "transparent"
|
|
54454
|
+
}),
|
|
54455
|
+
MERGE_KEYS.tableBorders
|
|
54456
|
+
),
|
|
54457
|
+
width100: () => apply(
|
|
54458
|
+
(current) => setTableStyleValue(current, "width", "100%"),
|
|
54459
|
+
MERGE_KEYS.tableWidth
|
|
54460
|
+
),
|
|
54461
|
+
alignLeft: () => apply(
|
|
54462
|
+
(current) => setTableCellStyleValue(current, "horizontalAlign", "left"),
|
|
54463
|
+
MERGE_KEYS.tableAlign
|
|
54464
|
+
),
|
|
54465
|
+
alignCenter: () => apply(
|
|
54466
|
+
(current) => setTableCellStyleValue(current, "horizontalAlign", "center"),
|
|
54467
|
+
MERGE_KEYS.tableAlign
|
|
54468
|
+
),
|
|
54469
|
+
alignRight: () => apply(
|
|
54470
|
+
(current) => setTableCellStyleValue(current, "horizontalAlign", "right"),
|
|
54471
|
+
MERGE_KEYS.tableAlign
|
|
54472
|
+
),
|
|
54473
|
+
setCellWidth: (width) => apply(
|
|
54474
|
+
(current) => setTableCellWidth(current, width),
|
|
54475
|
+
MERGE_KEYS.tableCellWidth
|
|
54476
|
+
),
|
|
54477
|
+
insert: (rows, cols) => options.tableOps.insertTableCommand(rows, cols)
|
|
54453
54478
|
};
|
|
54454
|
-
|
|
54479
|
+
}
|
|
54480
|
+
function createEditorEssentialsRuntimePlugin(options) {
|
|
54455
54481
|
return createEssentialsPlugin({
|
|
54456
|
-
gate:
|
|
54457
|
-
style:
|
|
54458
|
-
selection:
|
|
54459
|
-
history:
|
|
54460
|
-
formatting:
|
|
54461
|
-
document:
|
|
54462
|
-
link:
|
|
54463
|
-
image:
|
|
54464
|
-
browser:
|
|
54465
|
-
paragraph:
|
|
54466
|
-
section:
|
|
54467
|
-
table:
|
|
54482
|
+
gate: buildEssentialsGate(options),
|
|
54483
|
+
style: buildEssentialsStyle(options),
|
|
54484
|
+
selection: buildEssentialsSelection(options),
|
|
54485
|
+
history: buildEssentialsHistory(options),
|
|
54486
|
+
formatting: buildEssentialsFormatting(options),
|
|
54487
|
+
document: buildEssentialsDocument(options),
|
|
54488
|
+
link: buildEssentialsLink(options),
|
|
54489
|
+
image: buildEssentialsImage(options),
|
|
54490
|
+
browser: buildEssentialsBrowser(),
|
|
54491
|
+
paragraph: buildEssentialsParagraph(options),
|
|
54492
|
+
section: buildEssentialsSection(options),
|
|
54493
|
+
table: buildEssentialsTable(options)
|
|
54468
54494
|
});
|
|
54469
54495
|
}
|
|
54470
54496
|
const defaultMenuItems = [
|