@stll/folio-core 0.22.3 → 0.23.0
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/ai-edits/apply.d.ts +1 -1
- package/dist/document-operations.d.ts +4 -4
- package/dist/document-operations.js +17 -1
- package/dist/docx/rezip.d.ts +1 -1
- package/dist/docx/rezip.js +12 -31
- package/dist/layout-bridge/convert/toFlowBlocks.js +35 -61
- package/dist/layout-painter/imageLayout.d.ts +1 -1
- package/dist/managers/AutoSaveManager.js +8 -40
- package/dist/managers/TableSelectionManager.d.ts +1 -1
- package/dist/managers/autoSaveCodec.d.ts +17 -0
- package/dist/managers/autoSaveCodec.js +109 -0
- package/dist/prosemirror/attrs/index.js +273 -25
- package/dist/prosemirror/commands/comments.js +3 -3
- package/dist/prosemirror/commands/formatting.js +19 -19
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/paragraph.js +32 -32
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +4 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +8 -8
- package/dist/prosemirror/commands/table.d.ts +10 -52
- package/dist/prosemirror/commands/table.js +34 -34
- package/dist/prosemirror/conversion/fromProseDoc.js +20 -17
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +2 -1
- package/dist/prosemirror/conversion/sdtAttrs.js +9 -4
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +6 -3
- package/dist/prosemirror/extensions/ExtensionManager.js +5 -3
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +4 -4
- package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/types.d.ts +134 -1
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/plugins/selectionTracker.js +25 -99
- package/dist/prosemirror/revisionCarriers.js +3 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +87 -0
- package/dist/prosemirror/schema/nodes.d.ts +13 -2
- package/dist/prosemirror/selectionState.d.ts +11 -5
- package/dist/prosemirror/selectionState.js +94 -57
- package/dist/utils/tableOperations.d.ts +7 -6
- package/package.json +3 -3
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { TablePropertiesCommand } from "../../utils/tableOperations.js";
|
|
1
2
|
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
|
|
3
|
+
import { TableBorderCommandSpec, TableCellBorderCommandSpec, TableCellMarginsCommand, TableStyleCommand } from "../extensions/types.js";
|
|
2
4
|
import { EditorState, Transaction } from "prosemirror-state";
|
|
3
5
|
//#region src/prosemirror/commands/table.d.ts
|
|
4
6
|
declare function insertTable(rows: number, cols: number): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
@@ -14,67 +16,23 @@ declare function selectRow(state: EditorState, dispatch?: (tr: Transaction) => v
|
|
|
14
16
|
declare function selectColumn(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
15
17
|
declare function mergeCells(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
16
18
|
declare function splitCell(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
17
|
-
declare function setCellBorder(side: "top" | "bottom" | "left" | "right" | "all", spec:
|
|
18
|
-
style: string;
|
|
19
|
-
size?: number;
|
|
20
|
-
color?: {
|
|
21
|
-
rgb: string;
|
|
22
|
-
};
|
|
23
|
-
} | null, clearOthers?: boolean): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
19
|
+
declare function setCellBorder(side: "top" | "bottom" | "left" | "right" | "all", spec: TableCellBorderCommandSpec | null, clearOthers?: boolean): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
24
20
|
declare function setTableBorderPreset(preset: TableBorderPreset): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
25
|
-
declare function setTableBorders(preset: BorderPreset, borderSpec?:
|
|
26
|
-
style: string;
|
|
27
|
-
size: number;
|
|
28
|
-
color: {
|
|
29
|
-
rgb: string;
|
|
30
|
-
};
|
|
31
|
-
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
21
|
+
declare function setTableBorders(preset: BorderPreset, borderSpec?: TableBorderCommandSpec): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
32
22
|
declare function removeTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void): boolean;
|
|
33
|
-
declare function setAllTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?:
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
color: {
|
|
37
|
-
rgb: string;
|
|
38
|
-
};
|
|
39
|
-
}): boolean;
|
|
40
|
-
declare function setOutsideTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: {
|
|
41
|
-
style: string;
|
|
42
|
-
size: number;
|
|
43
|
-
color: {
|
|
44
|
-
rgb: string;
|
|
45
|
-
};
|
|
46
|
-
}): boolean;
|
|
47
|
-
declare function setInsideTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: {
|
|
48
|
-
style: string;
|
|
49
|
-
size: number;
|
|
50
|
-
color: {
|
|
51
|
-
rgb: string;
|
|
52
|
-
};
|
|
53
|
-
}): boolean;
|
|
23
|
+
declare function setAllTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: TableBorderCommandSpec): boolean;
|
|
24
|
+
declare function setOutsideTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: TableBorderCommandSpec): boolean;
|
|
25
|
+
declare function setInsideTableBorders(state: EditorState, dispatch?: (tr: Transaction) => void, borderSpec?: TableBorderCommandSpec): boolean;
|
|
54
26
|
declare function setCellVerticalAlign(align: "top" | "center" | "bottom"): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
55
|
-
declare function setCellMargins(margins:
|
|
56
|
-
top?: number;
|
|
57
|
-
bottom?: number;
|
|
58
|
-
left?: number;
|
|
59
|
-
right?: number;
|
|
60
|
-
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
27
|
+
declare function setCellMargins(margins: TableCellMarginsCommand): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
61
28
|
declare function setCellTextDirection(direction: string | null): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
62
29
|
declare function toggleNoWrap(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
63
30
|
declare function setRowHeight(height: number | null, rule?: "auto" | "atLeast" | "exact"): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
64
31
|
declare function toggleHeaderRow(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
65
32
|
declare function distributeColumns(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
66
33
|
declare function autoFitContents(): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
67
|
-
declare function setTableProperties(props:
|
|
68
|
-
|
|
69
|
-
widthType?: string | null;
|
|
70
|
-
justification?: "left" | "center" | "right" | null;
|
|
71
|
-
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
72
|
-
declare function applyTableStyle(styleData: {
|
|
73
|
-
styleId: string;
|
|
74
|
-
tableBorders?: Record<string, unknown>;
|
|
75
|
-
conditionals?: Record<string, unknown>;
|
|
76
|
-
look?: Record<string, boolean>;
|
|
77
|
-
}): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
34
|
+
declare function setTableProperties(props: TablePropertiesCommand): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
35
|
+
declare function applyTableStyle(styleData: TableStyleCommand): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
78
36
|
declare function setCellFillColor(color: string | null): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
79
37
|
declare function setTableBorderColor(color: string): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
80
38
|
declare function setTableBorderWidth(size: number): (state: EditorState, dispatch?: (tr: Transaction) => void) => boolean;
|
|
@@ -1,105 +1,105 @@
|
|
|
1
1
|
import { getTableContext, isInTable as isInTableCell } from "../extensions/nodes/TableExtension.js";
|
|
2
2
|
import { singletonManager } from "../schema/index.js";
|
|
3
3
|
//#region src/prosemirror/commands/table.ts
|
|
4
|
-
const cmds = singletonManager
|
|
4
|
+
const cmds = singletonManager;
|
|
5
5
|
function insertTable(rows, cols) {
|
|
6
|
-
return cmds
|
|
6
|
+
return cmds.requireCommand("insertTable")(rows, cols);
|
|
7
7
|
}
|
|
8
8
|
function addRowAbove(state, dispatch) {
|
|
9
|
-
return cmds
|
|
9
|
+
return cmds.requireCommand("addRowAbove")()(state, dispatch);
|
|
10
10
|
}
|
|
11
11
|
function addRowBelow(state, dispatch) {
|
|
12
|
-
return cmds
|
|
12
|
+
return cmds.requireCommand("addRowBelow")()(state, dispatch);
|
|
13
13
|
}
|
|
14
14
|
function deleteRow(state, dispatch) {
|
|
15
|
-
return cmds
|
|
15
|
+
return cmds.requireCommand("deleteRow")()(state, dispatch);
|
|
16
16
|
}
|
|
17
17
|
function addColumnLeft(state, dispatch) {
|
|
18
|
-
return cmds
|
|
18
|
+
return cmds.requireCommand("addColumnLeft")()(state, dispatch);
|
|
19
19
|
}
|
|
20
20
|
function addColumnRight(state, dispatch) {
|
|
21
|
-
return cmds
|
|
21
|
+
return cmds.requireCommand("addColumnRight")()(state, dispatch);
|
|
22
22
|
}
|
|
23
23
|
function deleteColumn(state, dispatch) {
|
|
24
|
-
return cmds
|
|
24
|
+
return cmds.requireCommand("deleteColumn")()(state, dispatch);
|
|
25
25
|
}
|
|
26
26
|
function deleteTable(state, dispatch) {
|
|
27
|
-
return cmds
|
|
27
|
+
return cmds.requireCommand("deleteTable")()(state, dispatch);
|
|
28
28
|
}
|
|
29
29
|
function selectTable(state, dispatch) {
|
|
30
|
-
return cmds
|
|
30
|
+
return cmds.requireCommand("selectTable")()(state, dispatch);
|
|
31
31
|
}
|
|
32
32
|
function selectRow(state, dispatch) {
|
|
33
|
-
return cmds
|
|
33
|
+
return cmds.requireCommand("selectRow")()(state, dispatch);
|
|
34
34
|
}
|
|
35
35
|
function selectColumn(state, dispatch) {
|
|
36
|
-
return cmds
|
|
36
|
+
return cmds.requireCommand("selectColumn")()(state, dispatch);
|
|
37
37
|
}
|
|
38
38
|
function mergeCells(state, dispatch) {
|
|
39
|
-
return cmds
|
|
39
|
+
return cmds.requireCommand("mergeCells")()(state, dispatch);
|
|
40
40
|
}
|
|
41
41
|
function splitCell(state, dispatch) {
|
|
42
|
-
return cmds
|
|
42
|
+
return cmds.requireCommand("splitCell")()(state, dispatch);
|
|
43
43
|
}
|
|
44
44
|
function setCellBorder(side, spec, clearOthers) {
|
|
45
|
-
return cmds
|
|
45
|
+
return cmds.requireCommand("setCellBorder")(side, spec, clearOthers);
|
|
46
46
|
}
|
|
47
47
|
function setTableBorderPreset(preset) {
|
|
48
|
-
return cmds
|
|
48
|
+
return cmds.requireCommand("setTableBorderPreset")(preset);
|
|
49
49
|
}
|
|
50
50
|
function setTableBorders(preset, borderSpec) {
|
|
51
|
-
return cmds
|
|
51
|
+
return cmds.requireCommand("setTableBorders")(preset, borderSpec);
|
|
52
52
|
}
|
|
53
53
|
function removeTableBorders(state, dispatch) {
|
|
54
|
-
return cmds
|
|
54
|
+
return cmds.requireCommand("removeTableBorders")()(state, dispatch);
|
|
55
55
|
}
|
|
56
56
|
function setAllTableBorders(state, dispatch, borderSpec) {
|
|
57
|
-
return cmds
|
|
57
|
+
return cmds.requireCommand("setAllTableBorders")(borderSpec)(state, dispatch);
|
|
58
58
|
}
|
|
59
59
|
function setOutsideTableBorders(state, dispatch, borderSpec) {
|
|
60
|
-
return cmds
|
|
60
|
+
return cmds.requireCommand("setOutsideTableBorders")(borderSpec)(state, dispatch);
|
|
61
61
|
}
|
|
62
62
|
function setInsideTableBorders(state, dispatch, borderSpec) {
|
|
63
|
-
return cmds
|
|
63
|
+
return cmds.requireCommand("setInsideTableBorders")(borderSpec)(state, dispatch);
|
|
64
64
|
}
|
|
65
65
|
function setCellVerticalAlign(align) {
|
|
66
|
-
return cmds
|
|
66
|
+
return cmds.requireCommand("setCellVerticalAlign")(align);
|
|
67
67
|
}
|
|
68
68
|
function setCellMargins(margins) {
|
|
69
|
-
return cmds
|
|
69
|
+
return cmds.requireCommand("setCellMargins")(margins);
|
|
70
70
|
}
|
|
71
71
|
function setCellTextDirection(direction) {
|
|
72
|
-
return cmds
|
|
72
|
+
return cmds.requireCommand("setCellTextDirection")(direction);
|
|
73
73
|
}
|
|
74
74
|
function toggleNoWrap() {
|
|
75
|
-
return cmds
|
|
75
|
+
return cmds.requireCommand("toggleNoWrap")();
|
|
76
76
|
}
|
|
77
77
|
function setRowHeight(height, rule) {
|
|
78
|
-
return cmds
|
|
78
|
+
return cmds.requireCommand("setRowHeight")(height, rule);
|
|
79
79
|
}
|
|
80
80
|
function toggleHeaderRow() {
|
|
81
|
-
return cmds
|
|
81
|
+
return cmds.requireCommand("toggleHeaderRow")();
|
|
82
82
|
}
|
|
83
83
|
function distributeColumns() {
|
|
84
|
-
return cmds
|
|
84
|
+
return cmds.requireCommand("distributeColumns")();
|
|
85
85
|
}
|
|
86
86
|
function autoFitContents() {
|
|
87
|
-
return cmds
|
|
87
|
+
return cmds.requireCommand("autoFitContents")();
|
|
88
88
|
}
|
|
89
89
|
function setTableProperties(props) {
|
|
90
|
-
return cmds
|
|
90
|
+
return cmds.requireCommand("setTableProperties")(props);
|
|
91
91
|
}
|
|
92
92
|
function applyTableStyle(styleData) {
|
|
93
|
-
return cmds
|
|
93
|
+
return cmds.requireCommand("applyTableStyle")(styleData);
|
|
94
94
|
}
|
|
95
95
|
function setCellFillColor(color) {
|
|
96
|
-
return cmds
|
|
96
|
+
return cmds.requireCommand("setCellFillColor")(color);
|
|
97
97
|
}
|
|
98
98
|
function setTableBorderColor(color) {
|
|
99
|
-
return cmds
|
|
99
|
+
return cmds.requireCommand("setTableBorderColor")(color);
|
|
100
100
|
}
|
|
101
101
|
function setTableBorderWidth(size) {
|
|
102
|
-
return cmds
|
|
102
|
+
return cmds.requireCommand("setTableBorderWidth")(size);
|
|
103
103
|
}
|
|
104
104
|
//#endregion
|
|
105
105
|
export { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, getTableContext, insertTable, isInTableCell as isInTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap };
|
|
@@ -9,7 +9,7 @@ import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
|
|
|
9
9
|
import { expectTextBoxAnchorAttrs } from "../textBoxAnchorAttrs.js";
|
|
10
10
|
import { assertValidProseMirrorDocument } from "../validation.js";
|
|
11
11
|
import { runShadingAttrsToShading } from "./runShadingMark.js";
|
|
12
|
-
import { sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs } from "./sdtAttrs.js";
|
|
12
|
+
import { decodeSdtListItems, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs } from "./sdtAttrs.js";
|
|
13
13
|
import { textFormattingToMarks } from "./toProseDoc.js";
|
|
14
14
|
import { Fragment } from "prosemirror-model";
|
|
15
15
|
//#region src/prosemirror/conversion/fromProseDoc.ts
|
|
@@ -248,10 +248,7 @@ function convertPMBlockSdt(node) {
|
|
|
248
248
|
if (attrs.showingPlaceholder !== void 0) properties.showingPlaceholder = attrs.showingPlaceholder;
|
|
249
249
|
if (attrs.dateFormat) properties.dateFormat = attrs.dateFormat;
|
|
250
250
|
if (attrs.dateValueISO) properties.dateValueISO = attrs.dateValueISO;
|
|
251
|
-
if (attrs.listItems)
|
|
252
|
-
const items = parseListItemsJson(attrs.listItems);
|
|
253
|
-
if (items) properties.listItems = items;
|
|
254
|
-
}
|
|
251
|
+
if (attrs.listItems) properties.listItems = decodeSdtListItems(attrs.listItems);
|
|
255
252
|
if (typeof attrs.dropdownLastValue === "string") properties.dropdownLastValue = attrs.dropdownLastValue;
|
|
256
253
|
if (typeof attrs.checked === "boolean") properties.checked = attrs.checked;
|
|
257
254
|
if (attrs.rawPropertiesXml) properties.rawPropertiesXml = attrs.rawPropertiesXml;
|
|
@@ -276,17 +273,6 @@ function isStillSyntheticFiller(blocks) {
|
|
|
276
273
|
if (block.pPrMark !== void 0) return false;
|
|
277
274
|
return true;
|
|
278
275
|
}
|
|
279
|
-
function parseListItemsJson(raw) {
|
|
280
|
-
try {
|
|
281
|
-
const parsed = JSON.parse(raw);
|
|
282
|
-
if (!Array.isArray(parsed)) return;
|
|
283
|
-
const items = [];
|
|
284
|
-
for (const entry of parsed) if (entry !== null && typeof entry === "object" && "displayText" in entry && "value" in entry && typeof entry.displayText === "string" && typeof entry.value === "string") items.push(entry);
|
|
285
|
-
return items.length > 0 ? items : void 0;
|
|
286
|
-
} catch {
|
|
287
|
-
return;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
276
|
function appendTextBoxBlock(blocks, node, options) {
|
|
291
277
|
const attrs = expectTextBoxAttrs(node);
|
|
292
278
|
const paragraph = convertPMTextBox(node);
|
|
@@ -513,10 +499,27 @@ function convertPMParagraph(node, documentCounts, textBoxAnchorMarkers) {
|
|
|
513
499
|
if (attrs.renderedPageBreakBefore) paragraph.renderedPageBreakBefore = true;
|
|
514
500
|
if (attrs._sectionProperties) paragraph.sectionProperties = attrs._sectionProperties;
|
|
515
501
|
else if (attrs.sectionBreakType) paragraph.sectionProperties = { sectionStart: attrs.sectionBreakType };
|
|
516
|
-
if (
|
|
502
|
+
if (attrs._propertyChanges && attrs._propertyChanges.length > 0) paragraph.propertyChanges = attrs._propertyChanges.map(propertyChangeFromAttrs);
|
|
517
503
|
if (attrs.pPrMark) paragraph.pPrMark = attrs.pPrMark;
|
|
518
504
|
return paragraph;
|
|
519
505
|
}
|
|
506
|
+
const propertyChangeFromAttrs = (change) => {
|
|
507
|
+
const { previousFormatting, currentFormatting, ...info } = change;
|
|
508
|
+
if (previousFormatting === void 0) return currentFormatting === void 0 ? info : {
|
|
509
|
+
...info,
|
|
510
|
+
currentFormatting
|
|
511
|
+
};
|
|
512
|
+
const { numPr, ...previousWithoutNumPr } = previousFormatting;
|
|
513
|
+
const normalizedPrevious = numPr === null || numPr === void 0 ? previousWithoutNumPr : {
|
|
514
|
+
...previousWithoutNumPr,
|
|
515
|
+
numPr
|
|
516
|
+
};
|
|
517
|
+
return {
|
|
518
|
+
...info,
|
|
519
|
+
previousFormatting: normalizedPrevious,
|
|
520
|
+
...currentFormatting !== void 0 && { currentFormatting }
|
|
521
|
+
};
|
|
522
|
+
};
|
|
520
523
|
/**
|
|
521
524
|
* Whether the paragraph's numbering still comes verbatim from its style —
|
|
522
525
|
* serialize no direct `<w:numPr>` then. The moment a list command changes
|
|
@@ -4,5 +4,6 @@ import { SdtAttrs } from "../schema/nodes.js";
|
|
|
4
4
|
declare const sdtAttrsFromProperties: (properties: document_d_exports.SdtProperties) => SdtAttrs;
|
|
5
5
|
declare const sdtPropertiesFromAttrs: (attrs: SdtAttrs) => document_d_exports.SdtProperties;
|
|
6
6
|
declare const sdtPropertiesMatchAttrs: (properties: document_d_exports.SdtProperties, attrs: SdtAttrs) => boolean;
|
|
7
|
+
declare const decodeSdtListItems: (rawItems: string) => NonNullable<document_d_exports.SdtProperties["listItems"]>;
|
|
7
8
|
//#endregion
|
|
8
|
-
export { sdtAttrsFromProperties, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs };
|
|
9
|
+
export { decodeSdtListItems, sdtAttrsFromProperties, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs };
|
|
@@ -25,7 +25,7 @@ const sdtPropertiesFromAttrs = (attrs) => {
|
|
|
25
25
|
if (attrs.showingPlaceholder !== void 0) properties.showingPlaceholder = attrs.showingPlaceholder;
|
|
26
26
|
if (attrs.dateFormat) properties.dateFormat = attrs.dateFormat;
|
|
27
27
|
if (attrs.dateValueISO) properties.dateValueISO = attrs.dateValueISO;
|
|
28
|
-
if (attrs.listItems) properties.listItems =
|
|
28
|
+
if (attrs.listItems) properties.listItems = decodeSdtListItems(attrs.listItems);
|
|
29
29
|
if (typeof attrs.dropdownLastValue === "string") properties.dropdownLastValue = attrs.dropdownLastValue;
|
|
30
30
|
if (typeof attrs.checked === "boolean") properties.checked = attrs.checked;
|
|
31
31
|
if (attrs.rawPropertiesXml) properties.rawPropertiesXml = attrs.rawPropertiesXml;
|
|
@@ -33,8 +33,13 @@ const sdtPropertiesFromAttrs = (attrs) => {
|
|
|
33
33
|
return properties;
|
|
34
34
|
};
|
|
35
35
|
const sdtPropertiesMatchAttrs = (properties, attrs) => JSON.stringify(sdtAttrsFromProperties(properties)) === JSON.stringify(sdtAttrsFromProperties(sdtPropertiesFromAttrs(attrs)));
|
|
36
|
-
const
|
|
37
|
-
|
|
36
|
+
const decodeSdtListItems = (rawItems) => {
|
|
37
|
+
let parsed;
|
|
38
|
+
try {
|
|
39
|
+
parsed = JSON.parse(rawItems);
|
|
40
|
+
} catch {
|
|
41
|
+
throw new TypeError("Invalid ProseMirror sdt attrs: listItems is not valid JSON");
|
|
42
|
+
}
|
|
38
43
|
if (!Array.isArray(parsed)) throw new TypeError("Invalid ProseMirror sdt attrs: listItems is not an array");
|
|
39
44
|
return parsed.map((item) => {
|
|
40
45
|
if (!item || typeof item !== "object" || Array.isArray(item)) throw new TypeError("Invalid ProseMirror sdt attrs: listItems contains an invalid item");
|
|
@@ -46,4 +51,4 @@ const parseSdtListItems = (rawItems) => {
|
|
|
46
51
|
});
|
|
47
52
|
};
|
|
48
53
|
//#endregion
|
|
49
|
-
export { sdtAttrsFromProperties, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs };
|
|
54
|
+
export { decodeSdtListItems, sdtAttrsFromProperties, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AnyExtension, CommandMap } from "./types.js";
|
|
2
|
-
import {
|
|
1
|
+
import { AnyExtension, CommandFactory, CommandMap, FolioCommandArguments, FolioCommandName } from "./types.js";
|
|
2
|
+
import { Plugin } from "prosemirror-state";
|
|
3
3
|
import { Schema } from "prosemirror-model";
|
|
4
4
|
//#region src/prosemirror/extensions/ExtensionManager.d.ts
|
|
5
5
|
declare class ExtensionManager {
|
|
@@ -32,7 +32,10 @@ declare class ExtensionManager {
|
|
|
32
32
|
/**
|
|
33
33
|
* Get a specific command by name
|
|
34
34
|
*/
|
|
35
|
-
getCommand(name:
|
|
35
|
+
getCommand<Name extends FolioCommandName>(name: Name): CommandFactory<FolioCommandArguments[Name]> | undefined;
|
|
36
|
+
getCommand(name: string): CommandFactory | undefined;
|
|
37
|
+
requireCommand<Name extends FolioCommandName>(name: Name): CommandFactory<FolioCommandArguments[Name]>;
|
|
38
|
+
requireCommand(name: string): CommandFactory;
|
|
36
39
|
/**
|
|
37
40
|
* Lifecycle: destroy
|
|
38
41
|
*/
|
|
@@ -68,12 +68,14 @@ var ExtensionManager = class {
|
|
|
68
68
|
getCommands() {
|
|
69
69
|
return this.commands;
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Get a specific command by name
|
|
73
|
-
*/
|
|
74
71
|
getCommand(name) {
|
|
75
72
|
return this.commands[name];
|
|
76
73
|
}
|
|
74
|
+
requireCommand(name) {
|
|
75
|
+
const command = this.getCommand(name);
|
|
76
|
+
if (!command) panic(`ExtensionManager: command "${name}" is not registered`);
|
|
77
|
+
return command;
|
|
78
|
+
}
|
|
77
79
|
/**
|
|
78
80
|
* Lifecycle: destroy
|
|
79
81
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../../../types/document.js";
|
|
2
|
-
import { NodeExtension } from "../types.js";
|
|
3
2
|
import { NumberingMap } from "../../../docx/numberingParser.js";
|
|
3
|
+
import { NodeExtension } from "../types.js";
|
|
4
4
|
import { EditorState } from "prosemirror-state";
|
|
5
5
|
//#region src/prosemirror/extensions/core/ParagraphExtension.d.ts
|
|
6
6
|
type ResolvedStyleAttrs = {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { expectParagraphAttrs } from "../../attrs/index.js";
|
|
1
2
|
import { PPR_CHANGE_SCOPED_ATTR_KEYS } from "../../commands/propertyChangeScope.js";
|
|
2
3
|
import { SUGGESTION_META, makeRevisionInfo } from "../../plugins/suggestionMode.js";
|
|
3
4
|
import { createExtension } from "../create.js";
|
|
@@ -10,11 +11,10 @@ function chainCommands(...commands) {
|
|
|
10
11
|
return false;
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
|
-
function appendParagraphPropertyChange(attrs, previousFormatting, rev) {
|
|
14
|
-
const existing = Array.isArray(attrs["_propertyChanges"]) ? attrs["_propertyChanges"] : [];
|
|
14
|
+
function appendParagraphPropertyChange(attrs, existing, previousFormatting, rev) {
|
|
15
15
|
return {
|
|
16
16
|
...attrs,
|
|
17
|
-
_propertyChanges: [...existing, {
|
|
17
|
+
_propertyChanges: [...existing ?? [], {
|
|
18
18
|
type: "paragraphPropertyChange",
|
|
19
19
|
info: {
|
|
20
20
|
id: rev.id,
|
|
@@ -85,7 +85,7 @@ function toggleList(numId) {
|
|
|
85
85
|
listMarker: null
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
|
-
if (rev) nextAttrs = appendParagraphPropertyChange(nextAttrs, getPreviousListFormatting(node.attrs), rev);
|
|
88
|
+
if (rev) nextAttrs = appendParagraphPropertyChange(nextAttrs, expectParagraphAttrs(node)._propertyChanges, getPreviousListFormatting(node.attrs), rev);
|
|
89
89
|
tr = tr.setNodeMarkup(pos, void 0, nextAttrs);
|
|
90
90
|
}
|
|
91
91
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { NodeExtension } from "../types.js";
|
|
2
1
|
import { ShapeAttrs as ShapeAttrs$1 } from "../../schema/nodes.js";
|
|
2
|
+
import { NodeExtension } from "../types.js";
|
|
3
3
|
//#region src/prosemirror/extensions/nodes/ShapeExtension.d.ts
|
|
4
4
|
type ShapeAttrs = ShapeAttrs$1;
|
|
5
5
|
declare function sanitizeColor(value: string | null | undefined): string | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../../../types/document.js";
|
|
2
2
|
import { OutlineStyleAttr } from "../../../types/documentEnumValues.js";
|
|
3
|
-
import { NodeExtension } from "../types.js";
|
|
4
3
|
import { ImagePositionAttrs, TextBoxAttrs as TextBoxAttrs$1 } from "../../schema/nodes.js";
|
|
4
|
+
import { NodeExtension } from "../types.js";
|
|
5
5
|
//#region src/prosemirror/extensions/nodes/TextBoxExtension.d.ts
|
|
6
6
|
type TextBoxAttrs = {
|
|
7
7
|
/** Width in pixels */
|
|
@@ -1,6 +1,50 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { TextColorAttrs } from "../schema/marks.js";
|
|
3
|
+
import "../schema/index.js";
|
|
4
|
+
import { TablePropertiesCommand } from "../../utils/tableOperations.js";
|
|
5
|
+
import { ResolvedStyleAttrs } from "./core/ParagraphExtension.js";
|
|
6
|
+
import { BorderPreset, TableBorderPreset } from "./nodes/TableExtension.js";
|
|
1
7
|
import { Command, Plugin } from "prosemirror-state";
|
|
2
8
|
import { MarkSpec, NodeSpec, Schema } from "prosemirror-model";
|
|
3
9
|
//#region src/prosemirror/extensions/types.d.ts
|
|
10
|
+
type TableCellBorderCommandSpec = {
|
|
11
|
+
style: string;
|
|
12
|
+
size?: number;
|
|
13
|
+
color?: {
|
|
14
|
+
rgb: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type TableBorderCommandSpec = {
|
|
18
|
+
style: string;
|
|
19
|
+
size: number;
|
|
20
|
+
color: {
|
|
21
|
+
rgb: string;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
type TableCellMarginsCommand = {
|
|
25
|
+
top?: number;
|
|
26
|
+
bottom?: number;
|
|
27
|
+
left?: number;
|
|
28
|
+
right?: number;
|
|
29
|
+
};
|
|
30
|
+
type TableStyleCommand = {
|
|
31
|
+
styleId: string;
|
|
32
|
+
tableBorders?: Partial<Record<"top" | "bottom" | "left" | "right" | "insideH" | "insideV", TableCellBorderCommandSpec>>;
|
|
33
|
+
conditionals?: Record<string, {
|
|
34
|
+
backgroundColor?: string;
|
|
35
|
+
borders?: Partial<Record<"top" | "bottom" | "left" | "right", TableCellBorderCommandSpec | null>>;
|
|
36
|
+
bold?: boolean;
|
|
37
|
+
color?: string;
|
|
38
|
+
}>;
|
|
39
|
+
look?: {
|
|
40
|
+
firstRow?: boolean;
|
|
41
|
+
lastRow?: boolean;
|
|
42
|
+
firstCol?: boolean;
|
|
43
|
+
lastCol?: boolean;
|
|
44
|
+
noHBand?: boolean;
|
|
45
|
+
noVBand?: boolean;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
4
48
|
type ExtensionPriority = number;
|
|
5
49
|
declare const Priority: {
|
|
6
50
|
readonly Highest: 0;
|
|
@@ -12,7 +56,96 @@ declare const Priority: {
|
|
|
12
56
|
type ExtensionContext = {
|
|
13
57
|
schema: Schema;
|
|
14
58
|
};
|
|
59
|
+
type FolioCommandArguments = {
|
|
60
|
+
toggleBold: [];
|
|
61
|
+
toggleItalic: [];
|
|
62
|
+
toggleUnderline: [];
|
|
63
|
+
toggleStrike: [];
|
|
64
|
+
toggleSuperscript: [];
|
|
65
|
+
toggleSubscript: [];
|
|
66
|
+
setTextColor: [attrs: TextColorAttrs];
|
|
67
|
+
clearTextColor: [];
|
|
68
|
+
setHighlight: [color: string];
|
|
69
|
+
clearHighlight: [];
|
|
70
|
+
setFontSize: [size: number];
|
|
71
|
+
clearFontSize: [];
|
|
72
|
+
setFontFamily: [fontName: string];
|
|
73
|
+
clearFontFamily: [];
|
|
74
|
+
setUnderlineStyle: [style: string, color?: TextColorAttrs];
|
|
75
|
+
setHyperlink: [href: string, tooltip?: string];
|
|
76
|
+
removeHyperlink: [];
|
|
77
|
+
insertHyperlink: [text: string, href: string, tooltip?: string];
|
|
78
|
+
setAlignment: [alignment: document_d_exports.ParagraphAlignment];
|
|
79
|
+
alignLeft: [];
|
|
80
|
+
alignCenter: [];
|
|
81
|
+
alignRight: [];
|
|
82
|
+
alignJustify: [];
|
|
83
|
+
setLineSpacing: [value: number, rule?: document_d_exports.LineSpacingRule];
|
|
84
|
+
singleSpacing: [];
|
|
85
|
+
oneAndHalfSpacing: [];
|
|
86
|
+
doubleSpacing: [];
|
|
87
|
+
increaseIndent: [amount?: number];
|
|
88
|
+
decreaseIndent: [amount?: number];
|
|
89
|
+
setIndentLeft: [twips: number];
|
|
90
|
+
setIndentRight: [twips: number];
|
|
91
|
+
setIndentFirstLine: [twips: number, hanging?: boolean];
|
|
92
|
+
toggleBulletList: [];
|
|
93
|
+
toggleNumberedList: [];
|
|
94
|
+
increaseListLevel: [];
|
|
95
|
+
decreaseListLevel: [];
|
|
96
|
+
removeList: [];
|
|
97
|
+
setSpaceBefore: [twips: number];
|
|
98
|
+
setSpaceAfter: [twips: number];
|
|
99
|
+
applyStyle: [styleId: string, resolvedAttrs?: ResolvedStyleAttrs];
|
|
100
|
+
clearStyle: [];
|
|
101
|
+
insertSectionBreak: [breakType: "nextPage" | "continuous" | "oddPage" | "evenPage"];
|
|
102
|
+
removeSectionBreak: [];
|
|
103
|
+
addTabStop: [position: number, alignment?: document_d_exports.TabStopAlignment, leader?: document_d_exports.TabLeader];
|
|
104
|
+
removeTabStop: [position: number];
|
|
105
|
+
toggleBidi: [];
|
|
106
|
+
setRtl: [];
|
|
107
|
+
setLtr: [];
|
|
108
|
+
setTabs: [tabs: document_d_exports.TabStop[]];
|
|
109
|
+
generateTOC: [];
|
|
110
|
+
insertTable: [rows: number, cols: number];
|
|
111
|
+
addRowAbove: [];
|
|
112
|
+
addRowBelow: [];
|
|
113
|
+
deleteRow: [];
|
|
114
|
+
addColumnLeft: [];
|
|
115
|
+
addColumnRight: [];
|
|
116
|
+
deleteColumn: [];
|
|
117
|
+
deleteTable: [];
|
|
118
|
+
selectTable: [];
|
|
119
|
+
selectRow: [];
|
|
120
|
+
selectColumn: [];
|
|
121
|
+
mergeCells: [];
|
|
122
|
+
splitCell: [];
|
|
123
|
+
setCellBorder: [side: "top" | "bottom" | "left" | "right" | "all", spec: TableCellBorderCommandSpec | null, clearOthers?: boolean];
|
|
124
|
+
setTableBorderPreset: [preset: TableBorderPreset];
|
|
125
|
+
setTableBorders: [preset: BorderPreset, borderSpec?: TableBorderCommandSpec];
|
|
126
|
+
removeTableBorders: [];
|
|
127
|
+
setAllTableBorders: [borderSpec?: TableBorderCommandSpec];
|
|
128
|
+
setOutsideTableBorders: [borderSpec?: TableBorderCommandSpec];
|
|
129
|
+
setInsideTableBorders: [borderSpec?: TableBorderCommandSpec];
|
|
130
|
+
setCellVerticalAlign: [align: "top" | "center" | "bottom"];
|
|
131
|
+
setCellMargins: [margins: TableCellMarginsCommand];
|
|
132
|
+
setCellTextDirection: [direction: string | null];
|
|
133
|
+
toggleNoWrap: [];
|
|
134
|
+
setRowHeight: [height: number | null, rule?: "auto" | "atLeast" | "exact"];
|
|
135
|
+
toggleHeaderRow: [];
|
|
136
|
+
distributeColumns: [];
|
|
137
|
+
autoFitContents: [];
|
|
138
|
+
setTableProperties: [props: TablePropertiesCommand];
|
|
139
|
+
applyTableStyle: [styleData: TableStyleCommand];
|
|
140
|
+
setCellFillColor: [color: string | null];
|
|
141
|
+
setTableBorderColor: [color: string];
|
|
142
|
+
setTableBorderWidth: [size: number];
|
|
143
|
+
};
|
|
144
|
+
type FolioCommandName = keyof FolioCommandArguments;
|
|
145
|
+
type CommandFactory<Args extends readonly unknown[] = readonly unknown[]> = (...args: Args) => Command;
|
|
146
|
+
type FolioCommandMap = Partial<{ [Name in FolioCommandName]: CommandFactory<FolioCommandArguments[Name]>; }>;
|
|
15
147
|
type CommandMap = Record<string, (...args: any[]) => Command>;
|
|
148
|
+
type ExtensionCommandMap = CommandMap & FolioCommandMap;
|
|
16
149
|
type KeyboardShortcutMap = Record<string, Command>;
|
|
17
150
|
type ExtensionRuntime = {
|
|
18
151
|
commands?: CommandMap;
|
|
@@ -97,4 +230,4 @@ type MarkExtensionDefinitionWithoutDefaults<TOptions extends ExtensionOptions =
|
|
|
97
230
|
};
|
|
98
231
|
type MarkExtensionDefinition<TOptions extends ExtensionOptions = ExtensionOptions> = MarkExtensionDefinitionWithDefaults<TOptions> | MarkExtensionDefinitionWithoutDefaults<TOptions>;
|
|
99
232
|
//#endregion
|
|
100
|
-
export { AnyExtension, CommandMap, Extension, ExtensionConfig, ExtensionContext, ExtensionDefinition, ExtensionPriority, ExtensionRuntime, KeyboardShortcutMap, MarkExtension, MarkExtensionConfig, MarkExtensionDefinition, NodeExtension, NodeExtensionConfig, NodeExtensionDefinition, Priority };
|
|
233
|
+
export { AnyExtension, CommandFactory, CommandMap, Extension, ExtensionCommandMap, ExtensionConfig, ExtensionContext, ExtensionDefinition, ExtensionPriority, ExtensionRuntime, FolioCommandArguments, FolioCommandMap, FolioCommandName, KeyboardShortcutMap, MarkExtension, MarkExtensionConfig, MarkExtensionDefinition, NodeExtension, NodeExtensionConfig, NodeExtensionDefinition, Priority, TableBorderCommandSpec, TableCellBorderCommandSpec, TableCellMarginsCommand, type TablePropertiesCommand, TableStyleCommand };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { FontFamilyAttrs, FontSizeAttrs, HyperlinkAttrs, TextColorAttrs, UnderlineAttrs } from "./schema/marks.js";
|
|
2
2
|
import { ImageAttrs, ParagraphAttrs } from "./schema/nodes.js";
|
|
3
3
|
import { schema, singletonManager } from "./schema/index.js";
|
|
4
|
+
import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
|
|
5
|
+
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
4
6
|
import { PAINTABLE_MARK_NAMES, applyFormatMarks, captureFormatMarks } from "./commands/formatPainter.js";
|
|
5
7
|
import { clearFormatting, getMarkAttr, isMarkActive } from "./extensions/marks/markUtils.js";
|
|
6
8
|
import { getHyperlinkAttrs, getSelectedText, isHyperlinkActive } from "./extensions/marks/HyperlinkExtension.js";
|
|
7
9
|
import { clearFontFamily, clearFontSize, clearHighlight, clearTextColor, insertHyperlink, removeHyperlink, setFontFamily, setFontSize, setHighlight, setHyperlink, setTextColor, toggleBold, toggleItalic, toggleStrike, toggleSubscript, toggleSuperscript, toggleUnderline } from "./commands/formatting.js";
|
|
8
10
|
import { insertImageFromFile } from "./commands/image.js";
|
|
9
|
-
import { getParagraphAlignment, getParagraphBidi, getStyleId } from "./extensions/core/ParagraphExtension.js";
|
|
10
11
|
import { getListInfo, isInList } from "./extensions/features/ListExtension.js";
|
|
11
12
|
import { addTabStop, alignCenter, alignJustify, alignLeft, alignRight, applyStyle, clearStyle, decreaseIndent, decreaseListLevel, generateTOC, increaseIndent, increaseListLevel, removeList, removeTabStop, setAlignment, setIndentFirstLine, setIndentLeft, setIndentRight, setLineSpacing, setLtr, setRtl, toggleBidi, toggleBulletList, toggleNumberedList } from "./commands/paragraph.js";
|
|
12
|
-
import { BorderPreset, TableBorderPreset, TableContextInfo, getTableContext, isInTable as isInTableCell } from "./extensions/nodes/TableExtension.js";
|
|
13
13
|
import { addColumnLeft, addColumnRight, addRowAbove, addRowBelow, applyTableStyle, autoFitContents, deleteColumn, deleteRow, deleteTable, distributeColumns, insertTable, mergeCells, removeTableBorders, selectColumn, selectRow, selectTable, setAllTableBorders, setCellBorder, setCellFillColor, setCellMargins, setCellTextDirection, setCellVerticalAlign, setInsideTableBorders, setOutsideTableBorders, setRowHeight, setTableBorderColor, setTableBorderPreset, setTableBorderWidth, setTableBorders, setTableProperties, splitCell, toggleHeaderRow, toggleNoWrap } from "./commands/table.js";
|
|
14
14
|
import { insertPageBreak } from "./commands/pageBreak.js";
|
|
15
15
|
import "./commands/index.js";
|