superdoc 1.0.0-beta.5 → 1.0.0-beta.6
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-Ebg4DPUi.es.js → PdfViewer-CdGAVn-4.es.js} +1 -1
- package/dist/chunks/{PdfViewer-B2yJpudB.cjs → PdfViewer-DmPiOFJ8.cjs} +1 -1
- package/dist/chunks/{index-DcKcwu3F.cjs → index-QulG3CF7.cjs} +3 -3
- package/dist/chunks/{index-D653XgvV-BN--CbY4.cjs → index-hjUbJ86s-BLl65XJn.cjs} +1 -1
- package/dist/chunks/{index-D653XgvV-B-4_BIjA.es.js → index-hjUbJ86s-BMiwCR8J.es.js} +1 -1
- package/dist/chunks/{index-6_t69RiQ.es.js → index-nXifzD54.es.js} +3 -3
- package/dist/chunks/{super-editor.es-Bt9VCC9D.cjs → super-editor.es-0GatZWs9.cjs} +402 -173
- package/dist/chunks/{super-editor.es-0TS__OEc.es.js → super-editor.es-BYVEYLjl.es.js} +402 -173
- package/dist/super-editor/ai-writer.es.js +2 -2
- package/dist/super-editor/chunks/{converter-BiUZIOjP.js → converter-CZF9SnYh.js} +1 -1
- package/dist/super-editor/chunks/{docx-zipper-Dz6dcXS4.js → docx-zipper-DWypbE0V.js} +1 -1
- package/dist/super-editor/chunks/{editor-BtePjrrv.js → editor-BdXHlHt-.js} +390 -166
- package/dist/super-editor/chunks/{index-D653XgvV.js → index-hjUbJ86s.js} +1 -1
- package/dist/super-editor/chunks/{toolbar-D6JNBgna.js → toolbar-CmelvLTd.js} +2 -2
- package/dist/super-editor/converter.es.js +1 -1
- package/dist/super-editor/docx-zipper.es.js +2 -2
- package/dist/super-editor/editor.es.js +3 -3
- package/dist/super-editor/file-zipper.es.js +1 -1
- package/dist/super-editor/super-editor.es.js +19 -14
- 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 +404 -175
- package/dist/superdoc.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -35580,7 +35580,7 @@ const _SuperConverter = class _SuperConverter2 {
|
|
|
35580
35580
|
static getStoredSuperdocVersion(docx) {
|
|
35581
35581
|
return _SuperConverter2.getStoredCustomProperty(docx, "SuperdocVersion");
|
|
35582
35582
|
}
|
|
35583
|
-
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.
|
|
35583
|
+
static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.0.0-beta.6") {
|
|
35584
35584
|
return _SuperConverter2.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
|
|
35585
35585
|
}
|
|
35586
35586
|
/**
|
|
@@ -52287,7 +52287,7 @@ const isHeadless = (editor) => {
|
|
|
52287
52287
|
const shouldSkipNodeView = (editor) => {
|
|
52288
52288
|
return isHeadless(editor);
|
|
52289
52289
|
};
|
|
52290
|
-
const summaryVersion = "1.0.0-beta.
|
|
52290
|
+
const summaryVersion = "1.0.0-beta.6";
|
|
52291
52291
|
const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
|
|
52292
52292
|
const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
|
|
52293
52293
|
function mapAttributes(attrs) {
|
|
@@ -53066,7 +53066,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53066
53066
|
{ default: remarkStringify },
|
|
53067
53067
|
{ default: remarkGfm }
|
|
53068
53068
|
] = await Promise.all([
|
|
53069
|
-
Promise.resolve().then(() => require("./index-
|
|
53069
|
+
Promise.resolve().then(() => require("./index-hjUbJ86s-BLl65XJn.cjs")),
|
|
53070
53070
|
Promise.resolve().then(() => require("./index-DRCvimau-H4Ck3S9a.cjs")),
|
|
53071
53071
|
Promise.resolve().then(() => require("./index-C_x_N6Uh-Db3CUJMX.cjs")),
|
|
53072
53072
|
Promise.resolve().then(() => require("./index-D_sWOSiG-BtDZzJ6I.cjs")),
|
|
@@ -53271,7 +53271,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
|
|
|
53271
53271
|
* Process collaboration migrations
|
|
53272
53272
|
*/
|
|
53273
53273
|
processCollaborationMigrations() {
|
|
53274
|
-
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.
|
|
53274
|
+
console.debug("[checkVersionMigrations] Current editor version", "1.0.0-beta.6");
|
|
53275
53275
|
if (!this.options.ydoc) return;
|
|
53276
53276
|
const metaMap = this.options.ydoc.getMap("meta");
|
|
53277
53277
|
let docVersion = metaMap.get("version");
|
|
@@ -55403,9 +55403,10 @@ function extractTableBorders(bordersInput) {
|
|
|
55403
55403
|
}
|
|
55404
55404
|
function extractCellBorders(cellAttrs) {
|
|
55405
55405
|
if (!cellAttrs?.borders) return void 0;
|
|
55406
|
+
const bordersData = cellAttrs.borders;
|
|
55406
55407
|
const borders = {};
|
|
55407
55408
|
for (const side of ["top", "right", "bottom", "left"]) {
|
|
55408
|
-
const spec = convertBorderSpec(
|
|
55409
|
+
const spec = convertBorderSpec(bordersData[side]);
|
|
55409
55410
|
if (spec) {
|
|
55410
55411
|
borders[side] = spec;
|
|
55411
55412
|
}
|
|
@@ -55509,7 +55510,7 @@ const normalizeString = (value) => {
|
|
|
55509
55510
|
return trimmed ? trimmed : void 0;
|
|
55510
55511
|
};
|
|
55511
55512
|
const MAX_AUTO_LINE_MULTIPLIER = 10;
|
|
55512
|
-
const TWIPS_THRESHOLD = 50;
|
|
55513
|
+
const TWIPS_THRESHOLD$1 = 50;
|
|
55513
55514
|
const spacingPxToPt = (spacing) => {
|
|
55514
55515
|
const result = {};
|
|
55515
55516
|
if (spacing.before != null) result.before = pxToPt(spacing.before);
|
|
@@ -55649,7 +55650,7 @@ const normalizeParagraphIndent = (value) => {
|
|
|
55649
55650
|
const convert = (value2) => {
|
|
55650
55651
|
const num = pickNumber(value2);
|
|
55651
55652
|
if (num == null) return void 0;
|
|
55652
|
-
if (Math.abs(num) <= TWIPS_THRESHOLD) {
|
|
55653
|
+
if (Math.abs(num) <= TWIPS_THRESHOLD$1) {
|
|
55653
55654
|
return num;
|
|
55654
55655
|
}
|
|
55655
55656
|
return twipsToPx$1(Number(num));
|
|
@@ -55664,24 +55665,18 @@ const normalizeParagraphIndent = (value) => {
|
|
|
55664
55665
|
if (hanging != null) indent.hanging = hanging;
|
|
55665
55666
|
return Object.keys(indent).length > 0 ? indent : void 0;
|
|
55666
55667
|
};
|
|
55668
|
+
const PX_TO_TWIPS = 15;
|
|
55669
|
+
const TWIPS_THRESHOLD = 1e3;
|
|
55667
55670
|
const normalizeOoxmlTabs = (tabs) => {
|
|
55668
55671
|
if (!Array.isArray(tabs)) return void 0;
|
|
55669
55672
|
const normalized = [];
|
|
55670
55673
|
for (const entry of tabs) {
|
|
55671
55674
|
if (!entry || typeof entry !== "object") continue;
|
|
55672
|
-
const
|
|
55673
|
-
|
|
55674
|
-
const
|
|
55675
|
-
if (originalPos != null) {
|
|
55676
|
-
posTwips = originalPos;
|
|
55677
|
-
} else {
|
|
55678
|
-
const posPx = pickNumber(source.pos ?? source.position ?? source.offset);
|
|
55679
|
-
if (posPx != null) {
|
|
55680
|
-
posTwips = Math.round(posPx * 15);
|
|
55681
|
-
}
|
|
55682
|
-
}
|
|
55675
|
+
const rawEntry = entry;
|
|
55676
|
+
const source = rawEntry.tab && typeof rawEntry.tab === "object" ? rawEntry.tab : rawEntry;
|
|
55677
|
+
const posTwips = resolveTabPosition(source);
|
|
55683
55678
|
if (posTwips == null) continue;
|
|
55684
|
-
const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type);
|
|
55679
|
+
const val = normalizeTabVal(source.val ?? source.align ?? source.alignment ?? source.type ?? source.tabType);
|
|
55685
55680
|
if (!val) continue;
|
|
55686
55681
|
const tab = {
|
|
55687
55682
|
val,
|
|
@@ -55693,6 +55688,21 @@ const normalizeOoxmlTabs = (tabs) => {
|
|
|
55693
55688
|
}
|
|
55694
55689
|
return normalized.length > 0 ? normalized : void 0;
|
|
55695
55690
|
};
|
|
55691
|
+
const resolveTabPosition = (source) => {
|
|
55692
|
+
const originalPos = pickNumber(source.originalPos);
|
|
55693
|
+
if (originalPos != null) {
|
|
55694
|
+
return originalPos;
|
|
55695
|
+
}
|
|
55696
|
+
const posValue = pickNumber(source.pos ?? source.position ?? source.offset);
|
|
55697
|
+
if (posValue == null) {
|
|
55698
|
+
return void 0;
|
|
55699
|
+
}
|
|
55700
|
+
if (posValue > TWIPS_THRESHOLD) {
|
|
55701
|
+
return posValue;
|
|
55702
|
+
} else {
|
|
55703
|
+
return Math.round(posValue * PX_TO_TWIPS);
|
|
55704
|
+
}
|
|
55705
|
+
};
|
|
55696
55706
|
const normalizeTabVal = (value) => {
|
|
55697
55707
|
switch (value) {
|
|
55698
55708
|
case "start":
|
|
@@ -55704,12 +55714,13 @@ const normalizeTabVal = (value) => {
|
|
|
55704
55714
|
return value;
|
|
55705
55715
|
case "left":
|
|
55706
55716
|
return "start";
|
|
55707
|
-
// Legacy mapping
|
|
55717
|
+
// Legacy mapping for RTL support
|
|
55708
55718
|
case "right":
|
|
55709
55719
|
return "end";
|
|
55710
|
-
// Legacy mapping
|
|
55720
|
+
// Legacy mapping for RTL support
|
|
55711
55721
|
case "dec":
|
|
55712
55722
|
return "decimal";
|
|
55723
|
+
// Abbreviation mapping
|
|
55713
55724
|
default:
|
|
55714
55725
|
return void 0;
|
|
55715
55726
|
}
|
|
@@ -55725,7 +55736,7 @@ const normalizeTabLeader = (value) => {
|
|
|
55725
55736
|
return value;
|
|
55726
55737
|
case "thick":
|
|
55727
55738
|
return "heavy";
|
|
55728
|
-
//
|
|
55739
|
+
// Legacy mapping
|
|
55729
55740
|
default:
|
|
55730
55741
|
return void 0;
|
|
55731
55742
|
}
|
|
@@ -56653,29 +56664,6 @@ const normalizeSuffix = (suffix2) => {
|
|
|
56653
56664
|
}
|
|
56654
56665
|
return void 0;
|
|
56655
56666
|
};
|
|
56656
|
-
function resolveSpacingIndent$1(style2, numbering) {
|
|
56657
|
-
const spacing = {
|
|
56658
|
-
before: style2.spacing?.before ?? 0,
|
|
56659
|
-
after: style2.spacing?.after ?? 0,
|
|
56660
|
-
line: style2.spacing?.line ?? 12,
|
|
56661
|
-
// Default line spacing
|
|
56662
|
-
lineRule: style2.spacing?.lineRule ?? "auto"
|
|
56663
|
-
};
|
|
56664
|
-
let indent = {
|
|
56665
|
-
left: style2.indent?.left ?? 0,
|
|
56666
|
-
right: style2.indent?.right ?? 0,
|
|
56667
|
-
firstLine: style2.indent?.firstLine ?? 0,
|
|
56668
|
-
hanging: style2.indent?.hanging ?? 0
|
|
56669
|
-
};
|
|
56670
|
-
if (numbering?.indent) {
|
|
56671
|
-
indent = {
|
|
56672
|
-
...indent,
|
|
56673
|
-
left: numbering.indent.left ?? indent.left,
|
|
56674
|
-
hanging: numbering.indent.hanging ?? indent.hanging
|
|
56675
|
-
};
|
|
56676
|
-
}
|
|
56677
|
-
return { spacing, indent };
|
|
56678
|
-
}
|
|
56679
56667
|
function computeTabStops$1(context) {
|
|
56680
56668
|
const { explicitStops, defaultTabInterval, paragraphIndent } = context;
|
|
56681
56669
|
const leftIndent = paragraphIndent.left ?? 0;
|
|
@@ -56787,6 +56775,90 @@ function computeEndAlignedX(entry, stop) {
|
|
|
56787
56775
|
const targetX = stop.pos - width;
|
|
56788
56776
|
return targetX < 0 ? 0 : targetX;
|
|
56789
56777
|
}
|
|
56778
|
+
function calculateTabWidth(params2) {
|
|
56779
|
+
const {
|
|
56780
|
+
currentX,
|
|
56781
|
+
tabStops,
|
|
56782
|
+
paragraphWidth,
|
|
56783
|
+
defaultTabDistance: defaultTabDistance2,
|
|
56784
|
+
defaultLineLength: defaultLineLength2,
|
|
56785
|
+
followingText = "",
|
|
56786
|
+
measureText: measureText2,
|
|
56787
|
+
decimalSeparator = "."
|
|
56788
|
+
} = params2;
|
|
56789
|
+
const nextStop = tabStops.find((stop) => stop.val !== "clear" && stop.pos > currentX);
|
|
56790
|
+
const fallbackWidth = () => {
|
|
56791
|
+
let tabWidth = defaultTabDistance2 - currentX % defaultLineLength2 % defaultTabDistance2;
|
|
56792
|
+
if (tabWidth <= 0) tabWidth = defaultTabDistance2;
|
|
56793
|
+
return {
|
|
56794
|
+
width: tabWidth,
|
|
56795
|
+
alignment: "default",
|
|
56796
|
+
tabStopPosUsed: "default"
|
|
56797
|
+
};
|
|
56798
|
+
};
|
|
56799
|
+
if (!nextStop) {
|
|
56800
|
+
return fallbackWidth();
|
|
56801
|
+
}
|
|
56802
|
+
let width = Math.min(nextStop.pos, paragraphWidth) - currentX;
|
|
56803
|
+
const alignment2 = nextStop.val;
|
|
56804
|
+
if (alignment2 === "bar") {
|
|
56805
|
+
return {
|
|
56806
|
+
width: 0,
|
|
56807
|
+
leader: nextStop.leader,
|
|
56808
|
+
alignment: alignment2,
|
|
56809
|
+
tabStopPosUsed: nextStop.pos
|
|
56810
|
+
};
|
|
56811
|
+
}
|
|
56812
|
+
if (alignment2 === "center" || alignment2 === "end") {
|
|
56813
|
+
const textWidth = measureText2 ? measureText2(followingText) : 0;
|
|
56814
|
+
if (alignment2 === "center") {
|
|
56815
|
+
width -= textWidth / 2;
|
|
56816
|
+
} else {
|
|
56817
|
+
width -= textWidth;
|
|
56818
|
+
}
|
|
56819
|
+
} else if (alignment2 === "decimal") {
|
|
56820
|
+
const decimalIndex = followingText.indexOf(decimalSeparator);
|
|
56821
|
+
if (decimalIndex >= 0) {
|
|
56822
|
+
const before = followingText.slice(0, decimalIndex);
|
|
56823
|
+
const beforeWidth = measureText2 ? measureText2(before) : 0;
|
|
56824
|
+
width -= beforeWidth;
|
|
56825
|
+
}
|
|
56826
|
+
} else if (alignment2 === "bar") {
|
|
56827
|
+
width = 0;
|
|
56828
|
+
}
|
|
56829
|
+
if (width < 1) {
|
|
56830
|
+
return fallbackWidth();
|
|
56831
|
+
}
|
|
56832
|
+
return {
|
|
56833
|
+
width,
|
|
56834
|
+
leader: nextStop.leader,
|
|
56835
|
+
alignment: alignment2,
|
|
56836
|
+
tabStopPosUsed: nextStop.pos
|
|
56837
|
+
};
|
|
56838
|
+
}
|
|
56839
|
+
function resolveSpacingIndent$1(style2, numbering) {
|
|
56840
|
+
const spacing = {
|
|
56841
|
+
before: style2.spacing?.before ?? 0,
|
|
56842
|
+
after: style2.spacing?.after ?? 0,
|
|
56843
|
+
line: style2.spacing?.line ?? 12,
|
|
56844
|
+
// Default line spacing
|
|
56845
|
+
lineRule: style2.spacing?.lineRule ?? "auto"
|
|
56846
|
+
};
|
|
56847
|
+
let indent = {
|
|
56848
|
+
left: style2.indent?.left ?? 0,
|
|
56849
|
+
right: style2.indent?.right ?? 0,
|
|
56850
|
+
firstLine: style2.indent?.firstLine ?? 0,
|
|
56851
|
+
hanging: style2.indent?.hanging ?? 0
|
|
56852
|
+
};
|
|
56853
|
+
if (numbering?.indent) {
|
|
56854
|
+
indent = {
|
|
56855
|
+
...indent,
|
|
56856
|
+
left: numbering.indent.left ?? indent.left,
|
|
56857
|
+
hanging: numbering.indent.hanging ?? indent.hanging
|
|
56858
|
+
};
|
|
56859
|
+
}
|
|
56860
|
+
return { spacing, indent };
|
|
56861
|
+
}
|
|
56790
56862
|
function formatListLabel(level, indices) {
|
|
56791
56863
|
const { format, text: template, start: start2 } = level;
|
|
56792
56864
|
if (format === "bullet" || format === "custom") {
|
|
@@ -56952,6 +57024,7 @@ function measureRowHeights(cells, _columnWidths) {
|
|
|
56952
57024
|
}
|
|
56953
57025
|
const Engines = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
56954
57026
|
__proto__: null,
|
|
57027
|
+
calculateTabWidth,
|
|
56955
57028
|
computeListIndent,
|
|
56956
57029
|
computeTabStops: computeTabStops$1,
|
|
56957
57030
|
computeWrapExclusion,
|
|
@@ -57000,17 +57073,18 @@ const hydrateParagraphStyleAttrs = (para, context, preResolved) => {
|
|
|
57000
57073
|
return null;
|
|
57001
57074
|
}
|
|
57002
57075
|
const resolvedExtended = resolved;
|
|
57076
|
+
const resolvedAsRecord = resolved;
|
|
57003
57077
|
const hydrated = {
|
|
57004
57078
|
resolved,
|
|
57005
|
-
spacing: cloneIfObject(
|
|
57006
|
-
indent: cloneIfObject(
|
|
57079
|
+
spacing: cloneIfObject(resolvedAsRecord.spacing),
|
|
57080
|
+
indent: cloneIfObject(resolvedAsRecord.indent),
|
|
57007
57081
|
borders: cloneIfObject(resolvedExtended.borders),
|
|
57008
57082
|
shading: cloneIfObject(resolvedExtended.shading),
|
|
57009
57083
|
alignment: resolvedExtended.justification,
|
|
57010
57084
|
tabStops: cloneIfObject(resolvedExtended.tabStops),
|
|
57011
57085
|
keepLines: resolvedExtended.keepLines,
|
|
57012
57086
|
keepNext: resolvedExtended.keepNext,
|
|
57013
|
-
numberingProperties: cloneIfObject(
|
|
57087
|
+
numberingProperties: cloneIfObject(resolvedAsRecord.numberingProperties)
|
|
57014
57088
|
};
|
|
57015
57089
|
return hydrated;
|
|
57016
57090
|
};
|
|
@@ -57223,6 +57297,9 @@ const normalizeResolvedTabAlignment = (value) => {
|
|
|
57223
57297
|
}
|
|
57224
57298
|
};
|
|
57225
57299
|
const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleContext) => {
|
|
57300
|
+
if (numberingProps === null) {
|
|
57301
|
+
return null;
|
|
57302
|
+
}
|
|
57226
57303
|
try {
|
|
57227
57304
|
let effectiveIndent = paragraphAttrs.indent;
|
|
57228
57305
|
if (numberingProps?.resolvedLevelIndent) {
|
|
@@ -57257,7 +57334,7 @@ const computeWordLayoutForParagraph = (paragraphAttrs, numberingProps, styleCont
|
|
|
57257
57334
|
return computeWordParagraphLayout({
|
|
57258
57335
|
paragraph: resolvedParagraph,
|
|
57259
57336
|
numbering: numberingProps,
|
|
57260
|
-
markerRun: numberingProps
|
|
57337
|
+
markerRun: numberingProps?.resolvedMarkerRpr,
|
|
57261
57338
|
// Use cached if available
|
|
57262
57339
|
docDefaults
|
|
57263
57340
|
});
|
|
@@ -57703,7 +57780,7 @@ function processImageChild(child, sectionMetadata, context, output, converters)
|
|
|
57703
57780
|
function processNestedStructuredContent(child, sectionMetadata, context, output, converters) {
|
|
57704
57781
|
const { getListCounter, incrementListCounter, resetListCounter } = context.listCounterContext;
|
|
57705
57782
|
const nestedMetadata = resolveNodeSdtMetadata(child, "structuredContentBlock");
|
|
57706
|
-
child.content
|
|
57783
|
+
child.content?.forEach((grandchild) => {
|
|
57707
57784
|
if (grandchild.type === "paragraph") {
|
|
57708
57785
|
const paragraphBlocks = converters.paragraphToFlowBlocks(
|
|
57709
57786
|
grandchild,
|
|
@@ -57755,7 +57832,7 @@ function processDocumentPartObject(child, sectionMetadata, context, output, conv
|
|
|
57755
57832
|
if (docPartGallery === "Table of Contents") {
|
|
57756
57833
|
const blocksBeforeToc = output.blocks.length;
|
|
57757
57834
|
processTocChildren(
|
|
57758
|
-
Array.from(child.content),
|
|
57835
|
+
Array.from(child.content ?? []),
|
|
57759
57836
|
{ docPartGallery, docPartObjectId, tocInstruction, sdtMetadata: docPartSdtMetadata },
|
|
57760
57837
|
{
|
|
57761
57838
|
nextBlockId: context.nextBlockId,
|
|
@@ -58433,7 +58510,8 @@ function paragraphToFlowBlocks$1(para, nextBlockId, positions, defaultFont, defa
|
|
|
58433
58510
|
trackedChanges,
|
|
58434
58511
|
bookmarks,
|
|
58435
58512
|
hyperlinkConfig,
|
|
58436
|
-
|
|
58513
|
+
themeColors,
|
|
58514
|
+
...converterContext !== void 0 ? [converterContext] : []
|
|
58437
58515
|
);
|
|
58438
58516
|
if (tableBlock) {
|
|
58439
58517
|
blocks.push(tableBlock);
|
|
@@ -58559,6 +58637,8 @@ function handleParagraphNode(node, context) {
|
|
|
58559
58637
|
trackedChangesConfig,
|
|
58560
58638
|
bookmarks,
|
|
58561
58639
|
hyperlinkConfig,
|
|
58640
|
+
void 0,
|
|
58641
|
+
// themeColors - not available in NodeHandlerContext
|
|
58562
58642
|
context.converterContext
|
|
58563
58643
|
);
|
|
58564
58644
|
paragraphBlocks.forEach((block) => {
|
|
@@ -59068,9 +59148,9 @@ const parseTableCell = (args) => {
|
|
|
59068
59148
|
const paragraph = paragraphBlocks.find((b2) => b2.kind === "paragraph");
|
|
59069
59149
|
if (!paragraph) return null;
|
|
59070
59150
|
const cellAttrs = {};
|
|
59071
|
-
const borders = extractCellBorders(cellNode.attrs);
|
|
59151
|
+
const borders = extractCellBorders(cellNode.attrs ?? {});
|
|
59072
59152
|
if (borders) cellAttrs.borders = borders;
|
|
59073
|
-
const padding = extractCellPadding(cellNode.attrs) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
|
|
59153
|
+
const padding = extractCellPadding(cellNode.attrs ?? {}) ?? (defaultCellPadding ? { ...defaultCellPadding } : void 0);
|
|
59074
59154
|
if (padding) cellAttrs.padding = padding;
|
|
59075
59155
|
const verticalAlign = cellNode.attrs?.verticalAlign;
|
|
59076
59156
|
if (verticalAlign === "top" || verticalAlign === "middle" || verticalAlign === "bottom") {
|
|
@@ -59407,7 +59487,7 @@ function toFlowBlocks(pmDoc, options) {
|
|
|
59407
59487
|
themeColors,
|
|
59408
59488
|
converterContext
|
|
59409
59489
|
);
|
|
59410
|
-
const tableConverter = (node, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2) => tableNodeToBlock(
|
|
59490
|
+
const tableConverter = (node, nextBlockId2, positions2, defaultFont2, defaultSize2, context, trackedChanges, bookmarks2, hyperlinkConfig2, themeColorsParam, converterCtx) => tableNodeToBlock(
|
|
59411
59491
|
node,
|
|
59412
59492
|
nextBlockId2,
|
|
59413
59493
|
positions2,
|
|
@@ -59417,8 +59497,8 @@ function toFlowBlocks(pmDoc, options) {
|
|
|
59417
59497
|
trackedChanges,
|
|
59418
59498
|
bookmarks2,
|
|
59419
59499
|
hyperlinkConfig2,
|
|
59420
|
-
themeColors,
|
|
59421
|
-
converterContext
|
|
59500
|
+
themeColorsParam ?? themeColors,
|
|
59501
|
+
converterCtx ?? converterContext
|
|
59422
59502
|
);
|
|
59423
59503
|
const handlerContext = {
|
|
59424
59504
|
blocks,
|
|
@@ -66100,7 +66180,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
66100
66180
|
markerEl.style.display = "inline-block";
|
|
66101
66181
|
markerEl.style.width = `${Math.max(0, fragment.markerWidth - LIST_MARKER_GAP$1)}px`;
|
|
66102
66182
|
markerEl.style.paddingRight = `${LIST_MARKER_GAP$1}px`;
|
|
66103
|
-
markerEl.style.textAlign = marker.justification ?? "";
|
|
66183
|
+
markerEl.style.textAlign = marker.justification ?? "left";
|
|
66104
66184
|
markerEl.style.fontFamily = marker.run.fontFamily;
|
|
66105
66185
|
markerEl.style.fontSize = `${marker.run.fontSize}px`;
|
|
66106
66186
|
if (marker.run.bold) markerEl.style.fontWeight = "bold";
|
|
@@ -66488,7 +66568,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
66488
66568
|
buildLinkRenderData(link) {
|
|
66489
66569
|
const dataset = buildLinkDataset(link);
|
|
66490
66570
|
const sanitized = typeof link.href === "string" ? sanitizeHref(link.href) : null;
|
|
66491
|
-
const anchorHref = normalizeAnchor(link.anchor ?? link.name ??
|
|
66571
|
+
const anchorHref = normalizeAnchor(link.anchor ?? link.name ?? "");
|
|
66492
66572
|
let href = sanitized?.href ?? anchorHref;
|
|
66493
66573
|
if (link.version === 2) {
|
|
66494
66574
|
href = appendDocLocation(href, link.docLocation ?? null);
|
|
@@ -66666,6 +66746,10 @@ const _DomPainter = class _DomPainter2 {
|
|
|
66666
66746
|
const el = this.doc.createElement("div");
|
|
66667
66747
|
el.classList.add(CLASS_NAMES.line);
|
|
66668
66748
|
applyStyles$2(el, lineStyles(line.lineHeight));
|
|
66749
|
+
const styleId = block.attrs?.styleId;
|
|
66750
|
+
if (styleId) {
|
|
66751
|
+
el.setAttribute("styleid", styleId);
|
|
66752
|
+
}
|
|
66669
66753
|
const lineRange = computeLinePmRange(block, line);
|
|
66670
66754
|
if (lineRange.pmStart != null) {
|
|
66671
66755
|
el.dataset.pmStart = String(lineRange.pmStart);
|
|
@@ -66693,7 +66777,7 @@ const _DomPainter = class _DomPainter2 {
|
|
|
66693
66777
|
leaderEl.style.height = ld.style === "heavy" ? "2px" : "1px";
|
|
66694
66778
|
leaderEl.style.pointerEvents = "none";
|
|
66695
66779
|
leaderEl.style.zIndex = "0";
|
|
66696
|
-
if (ld.style === "dot") {
|
|
66780
|
+
if (ld.style === "dot" || ld.style === "middleDot") {
|
|
66697
66781
|
leaderEl.style.borderBottom = "1px dotted currentColor";
|
|
66698
66782
|
} else if (ld.style === "hyphen") {
|
|
66699
66783
|
leaderEl.style.borderBottom = "1px dashed currentColor";
|
|
@@ -66730,6 +66814,9 @@ const _DomPainter = class _DomPainter2 {
|
|
|
66730
66814
|
const segmentRun = { ...baseRun, text: segmentText };
|
|
66731
66815
|
const elem = this.renderRun(segmentRun, context, trackedConfig);
|
|
66732
66816
|
if (elem) {
|
|
66817
|
+
if (styleId) {
|
|
66818
|
+
elem.setAttribute("styleid", styleId);
|
|
66819
|
+
}
|
|
66733
66820
|
let xPos;
|
|
66734
66821
|
if (segment.x !== void 0) {
|
|
66735
66822
|
xPos = segment.x;
|
|
@@ -66755,6 +66842,9 @@ const _DomPainter = class _DomPainter2 {
|
|
|
66755
66842
|
runs.forEach((run2) => {
|
|
66756
66843
|
const elem = this.renderRun(run2, context, trackedConfig);
|
|
66757
66844
|
if (elem) {
|
|
66845
|
+
if (styleId) {
|
|
66846
|
+
elem.setAttribute("styleid", styleId);
|
|
66847
|
+
}
|
|
66758
66848
|
el.appendChild(elem);
|
|
66759
66849
|
}
|
|
66760
66850
|
});
|
|
@@ -67174,6 +67264,9 @@ const applyRunDataAttributes = (element, dataAttrs) => {
|
|
|
67174
67264
|
};
|
|
67175
67265
|
const applyParagraphBlockStyles = (element, attrs) => {
|
|
67176
67266
|
if (!attrs) return;
|
|
67267
|
+
if (attrs.styleId) {
|
|
67268
|
+
element.setAttribute("styleid", attrs.styleId);
|
|
67269
|
+
}
|
|
67177
67270
|
if (attrs.alignment) {
|
|
67178
67271
|
element.style.textAlign = attrs.alignment;
|
|
67179
67272
|
}
|
|
@@ -67395,6 +67488,7 @@ const pxToTwips = (px) => Math.round(px * TWIPS_PER_PX);
|
|
|
67395
67488
|
const DEFAULT_TAB_INTERVAL_PX = twipsToPx(DEFAULT_TAB_INTERVAL_TWIPS);
|
|
67396
67489
|
const TAB_EPSILON = 0.1;
|
|
67397
67490
|
const DEFAULT_DECIMAL_SEPARATOR = ".";
|
|
67491
|
+
const ALLOWED_TAB_VALS = /* @__PURE__ */ new Set(["start", "center", "end", "decimal", "bar", "clear"]);
|
|
67398
67492
|
const roundValue = (value) => value;
|
|
67399
67493
|
function getCanvasContext() {
|
|
67400
67494
|
if (!canvasContext) {
|
|
@@ -67517,6 +67611,14 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
67517
67611
|
let tabStopCursor = 0;
|
|
67518
67612
|
let pendingTabAlignment = null;
|
|
67519
67613
|
let lastAppliedTabAlign = null;
|
|
67614
|
+
const warnedTabVals = /* @__PURE__ */ new Set();
|
|
67615
|
+
const validateTabStopVal = (stop) => {
|
|
67616
|
+
if (!ALLOWED_TAB_VALS.has(stop.val) && !warnedTabVals.has(stop.val)) {
|
|
67617
|
+
warnedTabVals.add(stop.val);
|
|
67618
|
+
return false;
|
|
67619
|
+
}
|
|
67620
|
+
return true;
|
|
67621
|
+
};
|
|
67520
67622
|
const alignSegmentAtTab = (segmentText, font, runContext) => {
|
|
67521
67623
|
if (!pendingTabAlignment || !currentLine) return;
|
|
67522
67624
|
const { target, val } = pendingTabAlignment;
|
|
@@ -67565,8 +67667,13 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
67565
67667
|
currentLine.maxFontSize = Math.max(currentLine.maxFontSize, 12);
|
|
67566
67668
|
currentLine.toRun = runIndex;
|
|
67567
67669
|
currentLine.toChar = 1;
|
|
67568
|
-
|
|
67569
|
-
|
|
67670
|
+
if (stop) {
|
|
67671
|
+
validateTabStopVal(stop);
|
|
67672
|
+
pendingTabAlignment = { target, val: stop.val };
|
|
67673
|
+
} else {
|
|
67674
|
+
pendingTabAlignment = null;
|
|
67675
|
+
}
|
|
67676
|
+
if (stop && stop.leader && stop.leader !== "none") {
|
|
67570
67677
|
const leaderStyle = stop.leader;
|
|
67571
67678
|
const from2 = Math.min(originX, target);
|
|
67572
67679
|
const to = Math.max(originX, target);
|
|
@@ -67712,7 +67819,12 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
67712
67819
|
currentLine.toRun = runIndex;
|
|
67713
67820
|
currentLine.toChar = charPosInRun;
|
|
67714
67821
|
charPosInRun += 1;
|
|
67715
|
-
|
|
67822
|
+
if (stop) {
|
|
67823
|
+
validateTabStopVal(stop);
|
|
67824
|
+
pendingTabAlignment = { target, val: stop.val };
|
|
67825
|
+
} else {
|
|
67826
|
+
pendingTabAlignment = null;
|
|
67827
|
+
}
|
|
67716
67828
|
if (stop && stop.leader && stop.leader !== "none" && stop.leader !== "middleDot") {
|
|
67717
67829
|
const leaderStyle = stop.leader;
|
|
67718
67830
|
const from2 = Math.min(originX, target);
|
|
@@ -67764,10 +67876,6 @@ async function measureParagraphBlock(block, maxWidth) {
|
|
|
67764
67876
|
markerTextWidth: glyphWidth,
|
|
67765
67877
|
indentLeft: wordLayout.indentLeftPx ?? 0
|
|
67766
67878
|
};
|
|
67767
|
-
console.log(
|
|
67768
|
-
"[measure] Marker:",
|
|
67769
|
-
JSON.stringify({ text: markerText, width: markerInfo.markerWidth, indent: markerInfo.indentLeft })
|
|
67770
|
-
);
|
|
67771
67879
|
}
|
|
67772
67880
|
return {
|
|
67773
67881
|
kind: "paragraph",
|
|
@@ -74596,29 +74704,6 @@ const restartNumbering = ({ editor, tr, state: state2, dispatch }) => {
|
|
|
74596
74704
|
};
|
|
74597
74705
|
const defaultTabDistance = 48;
|
|
74598
74706
|
const defaultLineLength = 816;
|
|
74599
|
-
const getTabDecorations = (doc2, view, helpers2, from2 = 0, to = null) => {
|
|
74600
|
-
const decorations = [];
|
|
74601
|
-
const paragraphCache = /* @__PURE__ */ new Map();
|
|
74602
|
-
const coordCache = /* @__PURE__ */ new Map();
|
|
74603
|
-
const domPosCache = /* @__PURE__ */ new Map();
|
|
74604
|
-
const end2 = to ?? doc2.content.size;
|
|
74605
|
-
doc2.nodesBetween(from2, end2, (node, pos) => {
|
|
74606
|
-
if (node.type.name !== "tab") return;
|
|
74607
|
-
const $pos = doc2.resolve(pos);
|
|
74608
|
-
const paragraphContext = findParagraphContext($pos, paragraphCache, helpers2);
|
|
74609
|
-
if (!paragraphContext) return;
|
|
74610
|
-
const blockParent2 = $pos.node(paragraphContext.paragraphDepth);
|
|
74611
|
-
const style2 = calculateTabStyle(node.nodeSize, view, pos, blockParent2, paragraphContext, coordCache, domPosCache);
|
|
74612
|
-
if (style2) {
|
|
74613
|
-
decorations.push(
|
|
74614
|
-
Decoration.node(pos, pos + node.nodeSize, {
|
|
74615
|
-
style: style2
|
|
74616
|
-
})
|
|
74617
|
-
);
|
|
74618
|
-
}
|
|
74619
|
-
});
|
|
74620
|
-
return decorations;
|
|
74621
|
-
};
|
|
74622
74707
|
function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext, coordCache = null, domPosCache = null) {
|
|
74623
74708
|
let extraStyles = "";
|
|
74624
74709
|
try {
|
|
@@ -74670,14 +74755,14 @@ function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext,
|
|
|
74670
74755
|
tabWidth -= integralWidth;
|
|
74671
74756
|
}
|
|
74672
74757
|
if (tabStop.leader) {
|
|
74673
|
-
const
|
|
74758
|
+
const leaderStyles2 = {
|
|
74674
74759
|
dot: "border-bottom: 1px dotted black;",
|
|
74675
74760
|
heavy: "border-bottom: 2px solid black;",
|
|
74676
74761
|
hyphen: "border-bottom: 1px solid black;",
|
|
74677
74762
|
middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
|
|
74678
74763
|
underscore: "border-bottom: 1px solid black;"
|
|
74679
74764
|
};
|
|
74680
|
-
extraStyles +=
|
|
74765
|
+
extraStyles += leaderStyles2[tabStop.leader] || "";
|
|
74681
74766
|
}
|
|
74682
74767
|
}
|
|
74683
74768
|
}
|
|
@@ -74689,7 +74774,7 @@ function calculateTabStyle(nodeSize2, view, pos, blockParent2, paragraphContext,
|
|
|
74689
74774
|
paragraphContext.accumulatedTabWidth = accumulatedTabWidth + tabWidth;
|
|
74690
74775
|
return `width: ${tabWidth}px; height: ${tabHeight}; ${extraStyles}`;
|
|
74691
74776
|
} catch (error) {
|
|
74692
|
-
|
|
74777
|
+
return null;
|
|
74693
74778
|
}
|
|
74694
74779
|
}
|
|
74695
74780
|
function findParagraphContext($pos, cache2, helpers2) {
|
|
@@ -74708,13 +74793,16 @@ function findParagraphContext($pos, cache2, helpers2) {
|
|
|
74708
74793
|
}
|
|
74709
74794
|
function extractParagraphContext(node, startPos, helpers2, depth = 0) {
|
|
74710
74795
|
const paragraphProperties = getResolvedParagraphProperties(node);
|
|
74796
|
+
const alignmentAliases = { left: "start", right: "end" };
|
|
74711
74797
|
let tabStops = [];
|
|
74712
74798
|
if (Array.isArray(paragraphProperties.tabStops)) {
|
|
74713
74799
|
tabStops = paragraphProperties.tabStops.map((stop) => {
|
|
74714
74800
|
const ref2 = stop?.tab;
|
|
74715
74801
|
if (!ref2) return stop || null;
|
|
74802
|
+
const rawType = ref2.tabType || "start";
|
|
74803
|
+
const mappedVal = alignmentAliases[rawType] || rawType;
|
|
74716
74804
|
return {
|
|
74717
|
-
val:
|
|
74805
|
+
val: mappedVal,
|
|
74718
74806
|
pos: twipsToPixels(Number(ref2.pos) || 0),
|
|
74719
74807
|
leader: ref2.leader
|
|
74720
74808
|
};
|
|
@@ -75779,6 +75867,184 @@ const CommentsMark = Mark2.create({
|
|
|
75779
75867
|
return [CommentMarkName, Attribute2.mergeAttributes(this.options.htmlAttributes, htmlAttributes)];
|
|
75780
75868
|
}
|
|
75781
75869
|
});
|
|
75870
|
+
const leaderStyles = {
|
|
75871
|
+
dot: "border-bottom: 1px dotted black;",
|
|
75872
|
+
heavy: "border-bottom: 2px solid black;",
|
|
75873
|
+
hyphen: "border-bottom: 1px solid black;",
|
|
75874
|
+
middleDot: "border-bottom: 1px dotted black; margin-bottom: 2px;",
|
|
75875
|
+
underscore: "border-bottom: 1px solid black;"
|
|
75876
|
+
};
|
|
75877
|
+
const paragraphIdFromPos = (startPos) => `para-${startPos}`;
|
|
75878
|
+
const tabIdForIndex = (paragraphId, index2) => `${paragraphId}-tab-${index2}`;
|
|
75879
|
+
function createLayoutRequest(doc2, paragraphPos, view, helpers2, revision, paragraphWidthOverride) {
|
|
75880
|
+
const $pos = doc2.resolve(paragraphPos);
|
|
75881
|
+
const paragraphCache = /* @__PURE__ */ new Map();
|
|
75882
|
+
const paragraphContext = findParagraphContext($pos, paragraphCache, helpers2);
|
|
75883
|
+
if (!paragraphContext) return null;
|
|
75884
|
+
const paragraphId = paragraphIdFromPos(paragraphContext.startPos);
|
|
75885
|
+
const paragraphNode = paragraphContext.paragraph;
|
|
75886
|
+
const { entries } = flattenParagraph(paragraphNode, paragraphContext.startPos);
|
|
75887
|
+
const spans = [];
|
|
75888
|
+
let tabIndex = 0;
|
|
75889
|
+
entries.forEach((entry, idx) => {
|
|
75890
|
+
const node = entry.node;
|
|
75891
|
+
const spanId = `${paragraphId}-span-${idx}`;
|
|
75892
|
+
const from2 = entry.pos;
|
|
75893
|
+
const to = entry.pos + node.nodeSize;
|
|
75894
|
+
if (node.type.name === "tab") {
|
|
75895
|
+
spans.push({
|
|
75896
|
+
type: "tab",
|
|
75897
|
+
spanId,
|
|
75898
|
+
tabId: tabIdForIndex(paragraphId, tabIndex++),
|
|
75899
|
+
pos: entry.pos,
|
|
75900
|
+
nodeSize: node.nodeSize
|
|
75901
|
+
});
|
|
75902
|
+
} else if (node.type.name === "text") {
|
|
75903
|
+
spans.push({
|
|
75904
|
+
type: "text",
|
|
75905
|
+
spanId,
|
|
75906
|
+
text: node.text || "",
|
|
75907
|
+
style: node.marks?.find((mark) => mark.type.name === "textStyle")?.attrs || {},
|
|
75908
|
+
from: from2,
|
|
75909
|
+
to
|
|
75910
|
+
});
|
|
75911
|
+
}
|
|
75912
|
+
});
|
|
75913
|
+
const tabStops = Array.isArray(paragraphContext.tabStops) ? [...paragraphContext.tabStops] : [];
|
|
75914
|
+
const hangingPx = twipsToPixels(Number(paragraphContext.indent?.hanging) || 0);
|
|
75915
|
+
if (hangingPx > 0 && paragraphContext.indentWidth != null) {
|
|
75916
|
+
tabStops.unshift({ val: "start", pos: paragraphContext.indentWidth + hangingPx, leader: "none" });
|
|
75917
|
+
}
|
|
75918
|
+
const paragraphWidth = getBlockNodeWidth(view, paragraphContext.startPos) ?? defaultLineLength;
|
|
75919
|
+
const indentWidth = paragraphContext.indentWidth ?? getIndentWidth(view, paragraphContext.startPos, paragraphContext.indent);
|
|
75920
|
+
return {
|
|
75921
|
+
paragraphId,
|
|
75922
|
+
revision,
|
|
75923
|
+
paragraphWidth,
|
|
75924
|
+
defaultTabDistance,
|
|
75925
|
+
defaultLineLength,
|
|
75926
|
+
indents: {
|
|
75927
|
+
left: twipsToPixels(Number(paragraphContext.indent?.left) || 0),
|
|
75928
|
+
right: twipsToPixels(Number(paragraphContext.indent?.right) || 0),
|
|
75929
|
+
firstLine: twipsToPixels(Number(paragraphContext.indent?.firstLine) || 0),
|
|
75930
|
+
hanging: hangingPx
|
|
75931
|
+
},
|
|
75932
|
+
tabStops,
|
|
75933
|
+
spans,
|
|
75934
|
+
indentWidth,
|
|
75935
|
+
paragraphNode
|
|
75936
|
+
};
|
|
75937
|
+
}
|
|
75938
|
+
function calculateTabLayout(request, measurement, view) {
|
|
75939
|
+
const {
|
|
75940
|
+
spans,
|
|
75941
|
+
tabStops,
|
|
75942
|
+
paragraphWidth,
|
|
75943
|
+
defaultTabDistance: defaultTabDistance2,
|
|
75944
|
+
defaultLineLength: defaultLineLength2,
|
|
75945
|
+
paragraphId,
|
|
75946
|
+
revision,
|
|
75947
|
+
indentWidth = 0,
|
|
75948
|
+
paragraphNode
|
|
75949
|
+
} = request;
|
|
75950
|
+
const tabs = {};
|
|
75951
|
+
let currentX = indentWidth;
|
|
75952
|
+
const measureText2 = (span) => {
|
|
75953
|
+
if (view && typeof span.from === "number" && typeof span.to === "number") {
|
|
75954
|
+
return measureRangeWidth(view, span.from, span.to);
|
|
75955
|
+
}
|
|
75956
|
+
return 0;
|
|
75957
|
+
};
|
|
75958
|
+
const tabHeight = paragraphNode ? calcTabHeight(paragraphNode) : void 0;
|
|
75959
|
+
for (let i = 0; i < spans.length; i++) {
|
|
75960
|
+
const span = spans[i];
|
|
75961
|
+
if (span.type === "text") {
|
|
75962
|
+
currentX += measureText2(span);
|
|
75963
|
+
} else if (span.type === "tab") {
|
|
75964
|
+
const followingText = collectFollowingText(spans, i + 1);
|
|
75965
|
+
let measureTextCallback;
|
|
75966
|
+
if (view) {
|
|
75967
|
+
const followingRange = getFollowingTextRange(spans, i + 1);
|
|
75968
|
+
if (followingRange) {
|
|
75969
|
+
const fullWidth = measureRangeWidth(view, followingRange.from, followingRange.to);
|
|
75970
|
+
const fullText = followingText;
|
|
75971
|
+
measureTextCallback = (text) => {
|
|
75972
|
+
if (text === fullText) return fullWidth;
|
|
75973
|
+
if (fullText.length > 0) {
|
|
75974
|
+
return text.length / fullText.length * fullWidth;
|
|
75975
|
+
}
|
|
75976
|
+
return 0;
|
|
75977
|
+
};
|
|
75978
|
+
}
|
|
75979
|
+
}
|
|
75980
|
+
const result = calculateTabWidth({
|
|
75981
|
+
currentX,
|
|
75982
|
+
tabStops,
|
|
75983
|
+
paragraphWidth,
|
|
75984
|
+
defaultTabDistance: defaultTabDistance2,
|
|
75985
|
+
defaultLineLength: defaultLineLength2,
|
|
75986
|
+
followingText,
|
|
75987
|
+
measureText: measureTextCallback
|
|
75988
|
+
});
|
|
75989
|
+
tabs[span.tabId] = {
|
|
75990
|
+
width: result.width,
|
|
75991
|
+
height: tabHeight,
|
|
75992
|
+
leader: result.leader,
|
|
75993
|
+
alignment: result.alignment,
|
|
75994
|
+
tabStopPosUsed: result.tabStopPosUsed
|
|
75995
|
+
};
|
|
75996
|
+
currentX += result.width;
|
|
75997
|
+
}
|
|
75998
|
+
}
|
|
75999
|
+
return {
|
|
76000
|
+
paragraphId,
|
|
76001
|
+
revision,
|
|
76002
|
+
tabs
|
|
76003
|
+
};
|
|
76004
|
+
}
|
|
76005
|
+
function applyLayoutResult(result, paragraph, paragraphPos) {
|
|
76006
|
+
const decorations = [];
|
|
76007
|
+
let tabIndex = 0;
|
|
76008
|
+
paragraph.forEach((node, offset2) => {
|
|
76009
|
+
if (node.type.name !== "tab") return;
|
|
76010
|
+
const pos = paragraphPos + offset2 + 1;
|
|
76011
|
+
const tabId = tabIdForIndex(result.paragraphId, tabIndex++);
|
|
76012
|
+
const layout = result.tabs[tabId];
|
|
76013
|
+
if (!layout) return;
|
|
76014
|
+
let style2 = `width: ${layout.width}px;`;
|
|
76015
|
+
if (layout.height) style2 += ` height: ${layout.height};`;
|
|
76016
|
+
if (layout.leader && leaderStyles[layout.leader]) {
|
|
76017
|
+
style2 += ` ${leaderStyles[layout.leader]}`;
|
|
76018
|
+
}
|
|
76019
|
+
decorations.push(Decoration.node(pos, pos + node.nodeSize, { style: style2 }));
|
|
76020
|
+
});
|
|
76021
|
+
return decorations;
|
|
76022
|
+
}
|
|
76023
|
+
function collectFollowingText(spans, startIndex) {
|
|
76024
|
+
let text = "";
|
|
76025
|
+
for (let i = startIndex; i < spans.length; i++) {
|
|
76026
|
+
const span = spans[i];
|
|
76027
|
+
if (span.type === "tab") break;
|
|
76028
|
+
if (span.type === "text") text += span.text || "";
|
|
76029
|
+
}
|
|
76030
|
+
return text;
|
|
76031
|
+
}
|
|
76032
|
+
function getFollowingTextRange(spans, startIndex) {
|
|
76033
|
+
let from2 = null;
|
|
76034
|
+
let to = null;
|
|
76035
|
+
for (let i = startIndex; i < spans.length; i++) {
|
|
76036
|
+
const span = spans[i];
|
|
76037
|
+
if (span.type === "tab") break;
|
|
76038
|
+
if (span.type === "text" && typeof span.from === "number" && typeof span.to === "number") {
|
|
76039
|
+
if (from2 === null) from2 = span.from;
|
|
76040
|
+
to = span.to;
|
|
76041
|
+
}
|
|
76042
|
+
}
|
|
76043
|
+
if (from2 !== null && to !== null) {
|
|
76044
|
+
return { from: from2, to };
|
|
76045
|
+
}
|
|
76046
|
+
return null;
|
|
76047
|
+
}
|
|
75782
76048
|
const TabNode = Node$1.create({
|
|
75783
76049
|
name: "tab",
|
|
75784
76050
|
group: "inline",
|
|
@@ -75820,87 +76086,24 @@ const TabNode = Node$1.create({
|
|
|
75820
76086
|
return [];
|
|
75821
76087
|
}
|
|
75822
76088
|
const { view, helpers: helpers2 } = this.editor;
|
|
75823
|
-
const mergeRanges2 = (ranges) => {
|
|
75824
|
-
if (ranges.length === 0) return [];
|
|
75825
|
-
const sorted = ranges.slice().sort((a, b2) => a[0] - b2[0]);
|
|
75826
|
-
const merged = [sorted[0]];
|
|
75827
|
-
for (let i = 1; i < sorted.length; i++) {
|
|
75828
|
-
const [start2, end2] = sorted[i];
|
|
75829
|
-
const last = merged[merged.length - 1];
|
|
75830
|
-
if (start2 <= last[1]) {
|
|
75831
|
-
last[1] = Math.max(last[1], end2);
|
|
75832
|
-
} else {
|
|
75833
|
-
merged.push([start2, end2]);
|
|
75834
|
-
}
|
|
75835
|
-
}
|
|
75836
|
-
return merged;
|
|
75837
|
-
};
|
|
75838
76089
|
const tabPlugin = new Plugin({
|
|
75839
76090
|
name: "tabPlugin",
|
|
75840
76091
|
key: new PluginKey("tabPlugin"),
|
|
75841
76092
|
state: {
|
|
75842
76093
|
init() {
|
|
75843
|
-
return { decorations: false };
|
|
76094
|
+
return { decorations: false, revision: 0 };
|
|
75844
76095
|
},
|
|
75845
|
-
apply(tr, { decorations }, _oldState, newState) {
|
|
76096
|
+
apply(tr, { decorations, revision }, _oldState, newState) {
|
|
75846
76097
|
if (!decorations) {
|
|
75847
|
-
|
|
75848
|
-
return { decorations };
|
|
76098
|
+
const newDecorations2 = buildDecorations(newState.doc, view, helpers2, 0);
|
|
76099
|
+
return { decorations: newDecorations2, revision: 0 };
|
|
75849
76100
|
}
|
|
75850
76101
|
if (!tr.docChanged || tr.getMeta("blockNodeInitialUpdate")) {
|
|
75851
|
-
return { decorations };
|
|
76102
|
+
return { decorations, revision };
|
|
75852
76103
|
}
|
|
75853
|
-
|
|
75854
|
-
const
|
|
75855
|
-
|
|
75856
|
-
tr.steps.forEach((step, index2) => {
|
|
75857
|
-
if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep$1)) {
|
|
75858
|
-
return;
|
|
75859
|
-
}
|
|
75860
|
-
let hasTabInRange = false;
|
|
75861
|
-
if (step.slice?.content) {
|
|
75862
|
-
step.slice.content.descendants((node) => {
|
|
75863
|
-
if (containsTab(node)) {
|
|
75864
|
-
hasTabInRange = true;
|
|
75865
|
-
return false;
|
|
75866
|
-
}
|
|
75867
|
-
});
|
|
75868
|
-
}
|
|
75869
|
-
if (!hasTabInRange) {
|
|
75870
|
-
tr.docs[index2].nodesBetween(step.from, step.to, (node) => {
|
|
75871
|
-
if (containsTab(node)) {
|
|
75872
|
-
hasTabInRange = true;
|
|
75873
|
-
return false;
|
|
75874
|
-
}
|
|
75875
|
-
});
|
|
75876
|
-
}
|
|
75877
|
-
if (!hasTabInRange) {
|
|
75878
|
-
return;
|
|
75879
|
-
}
|
|
75880
|
-
let fromPos = step.from;
|
|
75881
|
-
let toPos = step.to;
|
|
75882
|
-
for (let i = index2; i < tr.steps.length; i++) {
|
|
75883
|
-
const stepMap = tr.steps[i].getMap();
|
|
75884
|
-
fromPos = stepMap.map(fromPos, -1);
|
|
75885
|
-
toPos = stepMap.map(toPos, 1);
|
|
75886
|
-
}
|
|
75887
|
-
const $from = newState.doc.resolve(fromPos);
|
|
75888
|
-
const $to = newState.doc.resolve(toPos);
|
|
75889
|
-
const start2 = $from.start(Math.min($from.depth, 1));
|
|
75890
|
-
const end2 = $to.end(Math.min($to.depth, 1));
|
|
75891
|
-
rangesToRecalculate.push([start2, end2]);
|
|
75892
|
-
});
|
|
75893
|
-
if (rangesToRecalculate.length === 0) {
|
|
75894
|
-
return { decorations };
|
|
75895
|
-
}
|
|
75896
|
-
const mergedRanges = mergeRanges2(rangesToRecalculate);
|
|
75897
|
-
mergedRanges.forEach(([start2, end2]) => {
|
|
75898
|
-
const oldDecorations = decorations.find(start2, end2);
|
|
75899
|
-
decorations = decorations.remove(oldDecorations);
|
|
75900
|
-
const newDecorations = getTabDecorations(newState.doc, view, helpers2, start2, end2);
|
|
75901
|
-
decorations = decorations.add(newState.doc, newDecorations);
|
|
75902
|
-
});
|
|
75903
|
-
return { decorations };
|
|
76104
|
+
const nextRevision = revision + 1;
|
|
76105
|
+
const newDecorations = buildDecorations(newState.doc, view, helpers2, nextRevision);
|
|
76106
|
+
return { decorations: newDecorations, revision: nextRevision };
|
|
75904
76107
|
}
|
|
75905
76108
|
},
|
|
75906
76109
|
props: {
|
|
@@ -75912,6 +76115,27 @@ const TabNode = Node$1.create({
|
|
|
75912
76115
|
return [tabPlugin];
|
|
75913
76116
|
}
|
|
75914
76117
|
});
|
|
76118
|
+
function buildDecorations(doc2, view, helpers2, revision) {
|
|
76119
|
+
const decorations = [];
|
|
76120
|
+
doc2.descendants((node, pos) => {
|
|
76121
|
+
if (node.type.name !== "paragraph") return;
|
|
76122
|
+
let hasTab = false;
|
|
76123
|
+
node.descendants((child) => {
|
|
76124
|
+
if (child.type.name === "tab") {
|
|
76125
|
+
hasTab = true;
|
|
76126
|
+
return false;
|
|
76127
|
+
}
|
|
76128
|
+
return true;
|
|
76129
|
+
});
|
|
76130
|
+
if (!hasTab) return;
|
|
76131
|
+
const request = createLayoutRequest(doc2, pos + 1, view, helpers2, revision);
|
|
76132
|
+
if (!request) return;
|
|
76133
|
+
const result = calculateTabLayout(request, void 0, view);
|
|
76134
|
+
const paragraphDecorations = applyLayoutResult(result, node, pos);
|
|
76135
|
+
decorations.push(...paragraphDecorations);
|
|
76136
|
+
});
|
|
76137
|
+
return DecorationSet.create(doc2, decorations);
|
|
76138
|
+
}
|
|
75915
76139
|
const LineBreak = Node$1.create({
|
|
75916
76140
|
name: "lineBreak",
|
|
75917
76141
|
group: "inline",
|
|
@@ -103896,14 +104120,19 @@ deactivateAll_fn = function() {
|
|
|
103896
104120
|
});
|
|
103897
104121
|
};
|
|
103898
104122
|
updateToolbarHistory_fn = function() {
|
|
103899
|
-
if (!this.activeEditor) return;
|
|
103900
|
-
|
|
103901
|
-
|
|
103902
|
-
|
|
103903
|
-
|
|
103904
|
-
|
|
103905
|
-
|
|
103906
|
-
|
|
104123
|
+
if (!this.activeEditor?.state) return;
|
|
104124
|
+
try {
|
|
104125
|
+
if (this.activeEditor.options.ydoc) {
|
|
104126
|
+
const undoManager = yUndoPluginKey.getState(this.activeEditor.state)?.undoManager;
|
|
104127
|
+
this.undoDepth = undoManager?.undoStack.length || 0;
|
|
104128
|
+
this.redoDepth = undoManager?.redoStack.length || 0;
|
|
104129
|
+
} else {
|
|
104130
|
+
this.undoDepth = undoDepth(this.activeEditor.state);
|
|
104131
|
+
this.redoDepth = redoDepth(this.activeEditor.state);
|
|
104132
|
+
}
|
|
104133
|
+
} catch {
|
|
104134
|
+
this.undoDepth = 0;
|
|
104135
|
+
this.redoDepth = 0;
|
|
103907
104136
|
}
|
|
103908
104137
|
};
|
|
103909
104138
|
enrichTrackedChanges_fn = function(trackedChanges = []) {
|