@superdoc-dev/cli 0.2.0-next.58 → 0.2.0-next.59
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/index.js +354 -74
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -2918,6 +2918,47 @@ var init_operation_definitions = __esm(() => {
|
|
|
2918
2918
|
referenceDocPath: "tables/get-properties.mdx",
|
|
2919
2919
|
referenceGroup: "tables"
|
|
2920
2920
|
},
|
|
2921
|
+
"tables.getStyles": {
|
|
2922
|
+
memberPath: "tables.getStyles",
|
|
2923
|
+
description: "List all table styles and the document-level default table style setting.",
|
|
2924
|
+
expectedResult: "Returns a TablesGetStylesOutput with the style catalog, explicit default, and effective default.",
|
|
2925
|
+
requiresDocumentContext: true,
|
|
2926
|
+
metadata: readOperation({ idempotency: "idempotent" }),
|
|
2927
|
+
referenceDocPath: "tables/get-styles.mdx",
|
|
2928
|
+
referenceGroup: "tables"
|
|
2929
|
+
},
|
|
2930
|
+
"tables.setDefaultStyle": {
|
|
2931
|
+
memberPath: "tables.setDefaultStyle",
|
|
2932
|
+
description: "Set the document-level default table style (w:defaultTableStyle in settings.xml).",
|
|
2933
|
+
expectedResult: "Returns a DocumentMutationResult; reports NO_OP if the default already matches.",
|
|
2934
|
+
requiresDocumentContext: true,
|
|
2935
|
+
metadata: mutationOperation({
|
|
2936
|
+
idempotency: "idempotent",
|
|
2937
|
+
supportsDryRun: true,
|
|
2938
|
+
supportsTrackedMode: false,
|
|
2939
|
+
possibleFailureCodes: ["NO_OP", "INVALID_INPUT"],
|
|
2940
|
+
throws: ["CAPABILITY_UNAVAILABLE", "INVALID_INPUT"],
|
|
2941
|
+
historyUnsafe: true
|
|
2942
|
+
}),
|
|
2943
|
+
referenceDocPath: "tables/set-default-style.mdx",
|
|
2944
|
+
referenceGroup: "tables"
|
|
2945
|
+
},
|
|
2946
|
+
"tables.clearDefaultStyle": {
|
|
2947
|
+
memberPath: "tables.clearDefaultStyle",
|
|
2948
|
+
description: "Remove the document-level default table style setting.",
|
|
2949
|
+
expectedResult: "Returns a DocumentMutationResult; reports NO_OP if no default is set.",
|
|
2950
|
+
requiresDocumentContext: true,
|
|
2951
|
+
metadata: mutationOperation({
|
|
2952
|
+
idempotency: "conditional",
|
|
2953
|
+
supportsDryRun: true,
|
|
2954
|
+
supportsTrackedMode: false,
|
|
2955
|
+
possibleFailureCodes: ["NO_OP"],
|
|
2956
|
+
throws: ["CAPABILITY_UNAVAILABLE"],
|
|
2957
|
+
historyUnsafe: true
|
|
2958
|
+
}),
|
|
2959
|
+
referenceDocPath: "tables/clear-default-style.mdx",
|
|
2960
|
+
referenceGroup: "tables"
|
|
2961
|
+
},
|
|
2921
2962
|
"create.tableOfContents": {
|
|
2922
2963
|
memberPath: "create.tableOfContents",
|
|
2923
2964
|
description: "Insert a new table of contents at the target position.",
|
|
@@ -6051,6 +6092,47 @@ var init_schemas = __esm(() => {
|
|
|
6051
6092
|
})
|
|
6052
6093
|
}, ["nodeId"])
|
|
6053
6094
|
},
|
|
6095
|
+
"tables.getStyles": {
|
|
6096
|
+
input: strictEmptyObjectSchema,
|
|
6097
|
+
output: objectSchema({
|
|
6098
|
+
explicitDefaultStyleId: { type: ["string", "null"] },
|
|
6099
|
+
effectiveDefaultStyleId: { type: ["string", "null"] },
|
|
6100
|
+
effectiveDefaultSource: { type: "string" },
|
|
6101
|
+
styles: arraySchema(objectSchema({
|
|
6102
|
+
id: { type: "string" },
|
|
6103
|
+
name: { type: ["string", "null"] },
|
|
6104
|
+
basedOn: { type: ["string", "null"] },
|
|
6105
|
+
isDefault: { type: "boolean" },
|
|
6106
|
+
isCustom: { type: "boolean" },
|
|
6107
|
+
uiPriority: { type: ["integer", "null"] },
|
|
6108
|
+
hidden: { type: "boolean" },
|
|
6109
|
+
quickFormat: { type: "boolean" },
|
|
6110
|
+
conditionalRegions: arraySchema({ type: "string" })
|
|
6111
|
+
}, [
|
|
6112
|
+
"id",
|
|
6113
|
+
"name",
|
|
6114
|
+
"basedOn",
|
|
6115
|
+
"isDefault",
|
|
6116
|
+
"isCustom",
|
|
6117
|
+
"uiPriority",
|
|
6118
|
+
"hidden",
|
|
6119
|
+
"quickFormat",
|
|
6120
|
+
"conditionalRegions"
|
|
6121
|
+
]))
|
|
6122
|
+
}, ["explicitDefaultStyleId", "effectiveDefaultStyleId", "effectiveDefaultSource", "styles"])
|
|
6123
|
+
},
|
|
6124
|
+
"tables.setDefaultStyle": {
|
|
6125
|
+
input: objectSchema({ styleId: { type: "string" } }, ["styleId"]),
|
|
6126
|
+
output: documentMutationResultSchemaFor("tables.setDefaultStyle"),
|
|
6127
|
+
success: documentMutationSuccessSchema,
|
|
6128
|
+
failure: sectionMutationFailureSchemaFor("tables.setDefaultStyle")
|
|
6129
|
+
},
|
|
6130
|
+
"tables.clearDefaultStyle": {
|
|
6131
|
+
input: strictEmptyObjectSchema,
|
|
6132
|
+
output: documentMutationResultSchemaFor("tables.clearDefaultStyle"),
|
|
6133
|
+
success: documentMutationSuccessSchema,
|
|
6134
|
+
failure: sectionMutationFailureSchemaFor("tables.clearDefaultStyle")
|
|
6135
|
+
},
|
|
6054
6136
|
"history.get": {
|
|
6055
6137
|
input: strictEmptyObjectSchema,
|
|
6056
6138
|
output: objectSchema({
|
|
@@ -7498,6 +7580,9 @@ function buildDispatchTable(api) {
|
|
|
7498
7580
|
"tables.get": (input) => api.tables.get(input),
|
|
7499
7581
|
"tables.getCells": (input) => api.tables.getCells(input),
|
|
7500
7582
|
"tables.getProperties": (input) => api.tables.getProperties(input),
|
|
7583
|
+
"tables.getStyles": (input) => api.tables.getStyles(input),
|
|
7584
|
+
"tables.setDefaultStyle": (input, options) => api.tables.setDefaultStyle(input, options),
|
|
7585
|
+
"tables.clearDefaultStyle": (input, options) => api.tables.clearDefaultStyle(input, options),
|
|
7501
7586
|
"create.tableOfContents": (input, options) => api.create.tableOfContents(input, options),
|
|
7502
7587
|
"toc.list": (input) => api.toc.list(input),
|
|
7503
7588
|
"toc.get": (input) => api.toc.get(input),
|
|
@@ -8406,6 +8491,15 @@ function createDocumentApi(adapters) {
|
|
|
8406
8491
|
},
|
|
8407
8492
|
getProperties(input) {
|
|
8408
8493
|
return adapters.tables.getProperties(input);
|
|
8494
|
+
},
|
|
8495
|
+
getStyles(input) {
|
|
8496
|
+
return adapters.tables.getStyles(input);
|
|
8497
|
+
},
|
|
8498
|
+
setDefaultStyle(input, options) {
|
|
8499
|
+
return adapters.tables.setDefaultStyle(input, options);
|
|
8500
|
+
},
|
|
8501
|
+
clearDefaultStyle(input, options) {
|
|
8502
|
+
return adapters.tables.clearDefaultStyle(input, options);
|
|
8409
8503
|
}
|
|
8410
8504
|
},
|
|
8411
8505
|
toc: {
|
|
@@ -9279,6 +9373,9 @@ var init_operation_hints = __esm(() => {
|
|
|
9279
9373
|
"tables.get": "resolved table",
|
|
9280
9374
|
"tables.getCells": "listed cells",
|
|
9281
9375
|
"tables.getProperties": "resolved table properties",
|
|
9376
|
+
"tables.getStyles": "listed table styles",
|
|
9377
|
+
"tables.setDefaultStyle": "set default table style",
|
|
9378
|
+
"tables.clearDefaultStyle": "cleared default table style",
|
|
9282
9379
|
"history.get": "retrieved history state",
|
|
9283
9380
|
"history.undo": "undid last change",
|
|
9284
9381
|
"history.redo": "redid last change"
|
|
@@ -9379,6 +9476,9 @@ var init_operation_hints = __esm(() => {
|
|
|
9379
9476
|
"tables.get": "tableInfo",
|
|
9380
9477
|
"tables.getCells": "tableCellList",
|
|
9381
9478
|
"tables.getProperties": "tablePropertiesInfo",
|
|
9479
|
+
"tables.getStyles": "plain",
|
|
9480
|
+
"tables.setDefaultStyle": "plain",
|
|
9481
|
+
"tables.clearDefaultStyle": "plain",
|
|
9382
9482
|
"history.get": "plain",
|
|
9383
9483
|
"history.undo": "plain",
|
|
9384
9484
|
"history.redo": "plain"
|
|
@@ -9479,6 +9579,9 @@ var init_operation_hints = __esm(() => {
|
|
|
9479
9579
|
"tables.get": "result",
|
|
9480
9580
|
"tables.getCells": "result",
|
|
9481
9581
|
"tables.getProperties": "result",
|
|
9582
|
+
"tables.getStyles": "result",
|
|
9583
|
+
"tables.setDefaultStyle": "result",
|
|
9584
|
+
"tables.clearDefaultStyle": "result",
|
|
9482
9585
|
"history.get": "result",
|
|
9483
9586
|
"history.undo": "result",
|
|
9484
9587
|
"history.redo": "result"
|
|
@@ -9586,6 +9689,9 @@ var init_operation_hints = __esm(() => {
|
|
|
9586
9689
|
"tables.get": "tables",
|
|
9587
9690
|
"tables.getCells": "tables",
|
|
9588
9691
|
"tables.getProperties": "tables",
|
|
9692
|
+
"tables.getStyles": "tables",
|
|
9693
|
+
"tables.setDefaultStyle": "tables",
|
|
9694
|
+
"tables.clearDefaultStyle": "tables",
|
|
9589
9695
|
"history.get": "query",
|
|
9590
9696
|
"history.undo": "general",
|
|
9591
9697
|
"history.redo": "general"
|
|
@@ -12630,7 +12736,9 @@ var init_capabilities_adapter = __esm(() => {
|
|
|
12630
12736
|
REQUIRED_HELPERS = {
|
|
12631
12737
|
"blocks.delete": (editor) => typeof editor.helpers?.blockNode?.getBlockNodeById === "function",
|
|
12632
12738
|
"sections.setOddEvenHeadersFooters": (editor) => Boolean(editor.converter),
|
|
12633
|
-
"sections.setHeaderFooterRef": (editor) => Boolean(editor.converter)
|
|
12739
|
+
"sections.setHeaderFooterRef": (editor) => Boolean(editor.converter),
|
|
12740
|
+
"tables.setDefaultStyle": (editor) => Boolean(editor.converter),
|
|
12741
|
+
"tables.clearDefaultStyle": (editor) => Boolean(editor.converter)
|
|
12634
12742
|
};
|
|
12635
12743
|
SUPPORTED_STEP_OPS = [
|
|
12636
12744
|
"text.rewrite",
|
|
@@ -56602,7 +56710,36 @@ function combineIndentProperties(indentChain) {
|
|
|
56602
56710
|
}
|
|
56603
56711
|
|
|
56604
56712
|
// ../../packages/layout-engine/style-engine/src/ooxml/table-style-selection.ts
|
|
56605
|
-
|
|
56713
|
+
function isKnownTableStyleId(styleId, translatedLinkedStyles) {
|
|
56714
|
+
if (!styleId || !translatedLinkedStyles?.styles)
|
|
56715
|
+
return false;
|
|
56716
|
+
const def = translatedLinkedStyles.styles[styleId];
|
|
56717
|
+
return def != null && def.type === "table";
|
|
56718
|
+
}
|
|
56719
|
+
function findTypeDefaultTableStyleId(translatedLinkedStyles) {
|
|
56720
|
+
if (!translatedLinkedStyles?.styles)
|
|
56721
|
+
return null;
|
|
56722
|
+
for (const [styleId, def] of Object.entries(translatedLinkedStyles.styles)) {
|
|
56723
|
+
if (def.type === "table" && def.default === true) {
|
|
56724
|
+
return styleId;
|
|
56725
|
+
}
|
|
56726
|
+
}
|
|
56727
|
+
return null;
|
|
56728
|
+
}
|
|
56729
|
+
function resolvePreferredNewTableStyleId(settingsDefaultTableStyleId, translatedLinkedStyles) {
|
|
56730
|
+
if (settingsDefaultTableStyleId && isKnownTableStyleId(settingsDefaultTableStyleId, translatedLinkedStyles)) {
|
|
56731
|
+
return { styleId: settingsDefaultTableStyleId, source: "settings-default" };
|
|
56732
|
+
}
|
|
56733
|
+
const typeDefault = findTypeDefaultTableStyleId(translatedLinkedStyles);
|
|
56734
|
+
if (typeDefault && typeDefault !== TABLE_STYLE_ID_TABLE_NORMAL) {
|
|
56735
|
+
return { styleId: typeDefault, source: "type-default" };
|
|
56736
|
+
}
|
|
56737
|
+
if (isKnownTableStyleId(TABLE_STYLE_ID_TABLE_GRID, translatedLinkedStyles)) {
|
|
56738
|
+
return { styleId: TABLE_STYLE_ID_TABLE_GRID, source: "builtin-fallback" };
|
|
56739
|
+
}
|
|
56740
|
+
return { styleId: null, source: "none" };
|
|
56741
|
+
}
|
|
56742
|
+
var TABLE_STYLE_ID_TABLE_GRID = "TableGrid", TABLE_STYLE_ID_TABLE_NORMAL = "TableNormal", TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS;
|
|
56606
56743
|
var init_table_style_selection = __esm(() => {
|
|
56607
56744
|
TABLE_FALLBACK_BORDER = { val: "single", size: 4, color: "#000000" };
|
|
56608
56745
|
TABLE_FALLBACK_BORDERS = {
|
|
@@ -76460,6 +76597,103 @@ var init_table_target_resolver = __esm(() => {
|
|
|
76460
76597
|
init_errors3();
|
|
76461
76598
|
});
|
|
76462
76599
|
|
|
76600
|
+
// ../../packages/super-editor/src/document-api-adapters/document-settings.ts
|
|
76601
|
+
function createSettingsPart() {
|
|
76602
|
+
return {
|
|
76603
|
+
type: "element",
|
|
76604
|
+
name: "document",
|
|
76605
|
+
elements: [
|
|
76606
|
+
{
|
|
76607
|
+
type: "element",
|
|
76608
|
+
name: "w:settings",
|
|
76609
|
+
elements: []
|
|
76610
|
+
}
|
|
76611
|
+
]
|
|
76612
|
+
};
|
|
76613
|
+
}
|
|
76614
|
+
function findSettingsRoot(part) {
|
|
76615
|
+
if (part.name === "w:settings")
|
|
76616
|
+
return part;
|
|
76617
|
+
if (!Array.isArray(part.elements))
|
|
76618
|
+
return null;
|
|
76619
|
+
return part.elements.find((entry) => entry.name === "w:settings") ?? null;
|
|
76620
|
+
}
|
|
76621
|
+
function ensureSettingsRootElements(settingsRoot) {
|
|
76622
|
+
if (!Array.isArray(settingsRoot.elements))
|
|
76623
|
+
settingsRoot.elements = [];
|
|
76624
|
+
return settingsRoot.elements;
|
|
76625
|
+
}
|
|
76626
|
+
function readSettingsRoot(converter) {
|
|
76627
|
+
const part = converter.convertedXml?.[SETTINGS_PART_PATH];
|
|
76628
|
+
if (!part)
|
|
76629
|
+
return null;
|
|
76630
|
+
return findSettingsRoot(part);
|
|
76631
|
+
}
|
|
76632
|
+
function ensureSettingsRoot(converter) {
|
|
76633
|
+
if (!converter.convertedXml)
|
|
76634
|
+
converter.convertedXml = {};
|
|
76635
|
+
let part = converter.convertedXml[SETTINGS_PART_PATH];
|
|
76636
|
+
if (!part) {
|
|
76637
|
+
part = createSettingsPart();
|
|
76638
|
+
converter.convertedXml[SETTINGS_PART_PATH] = part;
|
|
76639
|
+
}
|
|
76640
|
+
const settingsRoot = findSettingsRoot(part);
|
|
76641
|
+
if (settingsRoot)
|
|
76642
|
+
return settingsRoot;
|
|
76643
|
+
const fallbackRoot = {
|
|
76644
|
+
type: "element",
|
|
76645
|
+
name: "w:settings",
|
|
76646
|
+
elements: []
|
|
76647
|
+
};
|
|
76648
|
+
if (!Array.isArray(part.elements))
|
|
76649
|
+
part.elements = [];
|
|
76650
|
+
part.elements.push(fallbackRoot);
|
|
76651
|
+
return fallbackRoot;
|
|
76652
|
+
}
|
|
76653
|
+
function readDefaultTableStyle(settingsRoot) {
|
|
76654
|
+
const el = settingsRoot.elements?.find((entry) => entry.name === "w:defaultTableStyle");
|
|
76655
|
+
if (!el)
|
|
76656
|
+
return null;
|
|
76657
|
+
const val = el.attributes?.["w:val"];
|
|
76658
|
+
return typeof val === "string" && val.length > 0 ? val : null;
|
|
76659
|
+
}
|
|
76660
|
+
function setDefaultTableStyle(settingsRoot, styleId) {
|
|
76661
|
+
const elements = ensureSettingsRootElements(settingsRoot);
|
|
76662
|
+
const idx = elements.findIndex((entry) => entry.name === "w:defaultTableStyle");
|
|
76663
|
+
const newEl = {
|
|
76664
|
+
type: "element",
|
|
76665
|
+
name: "w:defaultTableStyle",
|
|
76666
|
+
attributes: { "w:val": styleId },
|
|
76667
|
+
elements: []
|
|
76668
|
+
};
|
|
76669
|
+
if (idx !== -1) {
|
|
76670
|
+
elements[idx] = newEl;
|
|
76671
|
+
} else {
|
|
76672
|
+
elements.push(newEl);
|
|
76673
|
+
}
|
|
76674
|
+
}
|
|
76675
|
+
function removeDefaultTableStyle(settingsRoot) {
|
|
76676
|
+
const elements = ensureSettingsRootElements(settingsRoot);
|
|
76677
|
+
settingsRoot.elements = elements.filter((entry) => entry.name !== "w:defaultTableStyle");
|
|
76678
|
+
}
|
|
76679
|
+
function hasOddEvenHeadersFooters(settingsRoot) {
|
|
76680
|
+
return settingsRoot.elements?.some((entry) => entry.name === "w:evenAndOddHeaders") === true;
|
|
76681
|
+
}
|
|
76682
|
+
function setOddEvenHeadersFooters(settingsRoot, enabled) {
|
|
76683
|
+
const elements = ensureSettingsRootElements(settingsRoot);
|
|
76684
|
+
const hadFlag = hasOddEvenHeadersFooters(settingsRoot);
|
|
76685
|
+
if (enabled) {
|
|
76686
|
+
if (!hadFlag) {
|
|
76687
|
+
elements.push({ type: "element", name: "w:evenAndOddHeaders", elements: [] });
|
|
76688
|
+
}
|
|
76689
|
+
} else {
|
|
76690
|
+
settingsRoot.elements = elements.filter((entry) => entry.name !== "w:evenAndOddHeaders");
|
|
76691
|
+
}
|
|
76692
|
+
const hasFlag = hasOddEvenHeadersFooters(settingsRoot);
|
|
76693
|
+
return hadFlag !== hasFlag;
|
|
76694
|
+
}
|
|
76695
|
+
var SETTINGS_PART_PATH = "word/settings.xml";
|
|
76696
|
+
|
|
76463
76697
|
// ../../packages/super-editor/src/document-api-adapters/tables-adapter.ts
|
|
76464
76698
|
function generateParaId() {
|
|
76465
76699
|
return Array.from({ length: 8 }, () => Math.floor(Math.random() * 16).toString(16)).join("").toUpperCase();
|
|
@@ -78932,6 +79166,118 @@ function tablesGetPropertiesAdapter(editor, input) {
|
|
|
78932
79166
|
}
|
|
78933
79167
|
return result;
|
|
78934
79168
|
}
|
|
79169
|
+
function getConverterForStyles(editor) {
|
|
79170
|
+
return editor.converter;
|
|
79171
|
+
}
|
|
79172
|
+
function toDocumentMutationFailure(code4, message) {
|
|
79173
|
+
return {
|
|
79174
|
+
success: false,
|
|
79175
|
+
failure: { code: code4, message }
|
|
79176
|
+
};
|
|
79177
|
+
}
|
|
79178
|
+
function toDocumentMutationSuccess() {
|
|
79179
|
+
return { success: true };
|
|
79180
|
+
}
|
|
79181
|
+
function tablesGetStylesAdapter(editor, _input) {
|
|
79182
|
+
const converter = getConverterForStyles(editor);
|
|
79183
|
+
if (!converter) {
|
|
79184
|
+
return {
|
|
79185
|
+
explicitDefaultStyleId: null,
|
|
79186
|
+
effectiveDefaultStyleId: null,
|
|
79187
|
+
effectiveDefaultSource: "none",
|
|
79188
|
+
styles: []
|
|
79189
|
+
};
|
|
79190
|
+
}
|
|
79191
|
+
const translatedLinkedStyles = converter.translatedLinkedStyles ?? null;
|
|
79192
|
+
const allStyles = translatedLinkedStyles?.styles ?? {};
|
|
79193
|
+
const styles = [];
|
|
79194
|
+
for (const [id2, def] of Object.entries(allStyles)) {
|
|
79195
|
+
if (def.type !== "table")
|
|
79196
|
+
continue;
|
|
79197
|
+
styles.push({
|
|
79198
|
+
id: id2,
|
|
79199
|
+
name: def.name ?? null,
|
|
79200
|
+
basedOn: def.basedOn ?? null,
|
|
79201
|
+
isDefault: def.default === true,
|
|
79202
|
+
isCustom: def.customStyle === true,
|
|
79203
|
+
uiPriority: def.uiPriority ?? null,
|
|
79204
|
+
hidden: def.hidden === true || def.semiHidden === true,
|
|
79205
|
+
quickFormat: def.qFormat === true,
|
|
79206
|
+
conditionalRegions: def.tableStyleProperties ? Object.keys(def.tableStyleProperties) : []
|
|
79207
|
+
});
|
|
79208
|
+
}
|
|
79209
|
+
let explicitDefaultStyleId = null;
|
|
79210
|
+
const settingsRoot = readSettingsRoot(converter);
|
|
79211
|
+
if (settingsRoot) {
|
|
79212
|
+
explicitDefaultStyleId = readDefaultTableStyle(settingsRoot);
|
|
79213
|
+
}
|
|
79214
|
+
const resolved = resolvePreferredNewTableStyleId(explicitDefaultStyleId, translatedLinkedStyles);
|
|
79215
|
+
return {
|
|
79216
|
+
explicitDefaultStyleId,
|
|
79217
|
+
effectiveDefaultStyleId: resolved.styleId,
|
|
79218
|
+
effectiveDefaultSource: resolved.source,
|
|
79219
|
+
styles
|
|
79220
|
+
};
|
|
79221
|
+
}
|
|
79222
|
+
function tablesSetDefaultStyleAdapter(editor, input, options) {
|
|
79223
|
+
rejectTrackedMode("tables.setDefaultStyle", options);
|
|
79224
|
+
const converter = getConverterForStyles(editor);
|
|
79225
|
+
if (!converter) {
|
|
79226
|
+
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "tables.setDefaultStyle requires an active document converter.");
|
|
79227
|
+
}
|
|
79228
|
+
if (!isKnownTableStyleId(input.styleId, converter.translatedLinkedStyles)) {
|
|
79229
|
+
throw new DocumentApiAdapterError("INVALID_INPUT", `tables.setDefaultStyle: "${input.styleId}" is not a known table style.`);
|
|
79230
|
+
}
|
|
79231
|
+
return executeOutOfBandMutation(editor, (dryRun) => {
|
|
79232
|
+
const existingRoot = readSettingsRoot(converter);
|
|
79233
|
+
const current = existingRoot ? readDefaultTableStyle(existingRoot) : null;
|
|
79234
|
+
if (current === input.styleId) {
|
|
79235
|
+
return {
|
|
79236
|
+
changed: false,
|
|
79237
|
+
payload: toDocumentMutationFailure("NO_OP", "tables.setDefaultStyle did not produce a document settings change.")
|
|
79238
|
+
};
|
|
79239
|
+
}
|
|
79240
|
+
if (!dryRun) {
|
|
79241
|
+
const settingsRoot = ensureSettingsRoot(converter);
|
|
79242
|
+
setDefaultTableStyle(settingsRoot, input.styleId);
|
|
79243
|
+
}
|
|
79244
|
+
return {
|
|
79245
|
+
changed: true,
|
|
79246
|
+
payload: toDocumentMutationSuccess()
|
|
79247
|
+
};
|
|
79248
|
+
}, {
|
|
79249
|
+
dryRun: options?.dryRun === true,
|
|
79250
|
+
expectedRevision: options?.expectedRevision
|
|
79251
|
+
});
|
|
79252
|
+
}
|
|
79253
|
+
function tablesClearDefaultStyleAdapter(editor, _input, options) {
|
|
79254
|
+
rejectTrackedMode("tables.clearDefaultStyle", options);
|
|
79255
|
+
const converter = getConverterForStyles(editor);
|
|
79256
|
+
if (!converter) {
|
|
79257
|
+
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", "tables.clearDefaultStyle requires an active document converter.");
|
|
79258
|
+
}
|
|
79259
|
+
return executeOutOfBandMutation(editor, (dryRun) => {
|
|
79260
|
+
const existingRoot = readSettingsRoot(converter);
|
|
79261
|
+
const current = existingRoot ? readDefaultTableStyle(existingRoot) : null;
|
|
79262
|
+
if (current === null) {
|
|
79263
|
+
return {
|
|
79264
|
+
changed: false,
|
|
79265
|
+
payload: toDocumentMutationFailure("NO_OP", "tables.clearDefaultStyle did not produce a document settings change.")
|
|
79266
|
+
};
|
|
79267
|
+
}
|
|
79268
|
+
if (!dryRun) {
|
|
79269
|
+
const settingsRoot = ensureSettingsRoot(converter);
|
|
79270
|
+
removeDefaultTableStyle(settingsRoot);
|
|
79271
|
+
}
|
|
79272
|
+
return {
|
|
79273
|
+
changed: true,
|
|
79274
|
+
payload: toDocumentMutationSuccess()
|
|
79275
|
+
};
|
|
79276
|
+
}, {
|
|
79277
|
+
dryRun: options?.dryRun === true,
|
|
79278
|
+
expectedRevision: options?.expectedRevision
|
|
79279
|
+
});
|
|
79280
|
+
}
|
|
78935
79281
|
var POINTS_TO_PIXELS, POINTS_TO_TWIPS = 20, PIXELS_TO_TWIPS, DEFAULT_TABLE_GRID_WIDTH_TWIPS = 1500;
|
|
78936
79282
|
var init_tables_adapter = __esm(() => {
|
|
78937
79283
|
init_wrapper();
|
|
@@ -78943,6 +79289,8 @@ var init_tables_adapter = __esm(() => {
|
|
|
78943
79289
|
init_errors3();
|
|
78944
79290
|
init_node_address_resolver();
|
|
78945
79291
|
init_helpers();
|
|
79292
|
+
init_ooxml();
|
|
79293
|
+
init_out_of_band_mutation();
|
|
78946
79294
|
POINTS_TO_PIXELS = 96 / 72;
|
|
78947
79295
|
PIXELS_TO_TWIPS = 1440 / 96;
|
|
78948
79296
|
});
|
|
@@ -79272,77 +79620,6 @@ var init_create_table_wrapper = __esm(() => {
|
|
|
79272
79620
|
init_tables_adapter();
|
|
79273
79621
|
});
|
|
79274
79622
|
|
|
79275
|
-
// ../../packages/super-editor/src/document-api-adapters/document-settings.ts
|
|
79276
|
-
function createSettingsPart() {
|
|
79277
|
-
return {
|
|
79278
|
-
type: "element",
|
|
79279
|
-
name: "document",
|
|
79280
|
-
elements: [
|
|
79281
|
-
{
|
|
79282
|
-
type: "element",
|
|
79283
|
-
name: "w:settings",
|
|
79284
|
-
elements: []
|
|
79285
|
-
}
|
|
79286
|
-
]
|
|
79287
|
-
};
|
|
79288
|
-
}
|
|
79289
|
-
function findSettingsRoot(part) {
|
|
79290
|
-
if (part.name === "w:settings")
|
|
79291
|
-
return part;
|
|
79292
|
-
if (!Array.isArray(part.elements))
|
|
79293
|
-
return null;
|
|
79294
|
-
return part.elements.find((entry) => entry.name === "w:settings") ?? null;
|
|
79295
|
-
}
|
|
79296
|
-
function ensureSettingsRootElements(settingsRoot) {
|
|
79297
|
-
if (!Array.isArray(settingsRoot.elements))
|
|
79298
|
-
settingsRoot.elements = [];
|
|
79299
|
-
return settingsRoot.elements;
|
|
79300
|
-
}
|
|
79301
|
-
function readSettingsRoot(converter) {
|
|
79302
|
-
const part = converter.convertedXml?.[SETTINGS_PART_PATH];
|
|
79303
|
-
if (!part)
|
|
79304
|
-
return null;
|
|
79305
|
-
return findSettingsRoot(part);
|
|
79306
|
-
}
|
|
79307
|
-
function ensureSettingsRoot(converter) {
|
|
79308
|
-
if (!converter.convertedXml)
|
|
79309
|
-
converter.convertedXml = {};
|
|
79310
|
-
let part = converter.convertedXml[SETTINGS_PART_PATH];
|
|
79311
|
-
if (!part) {
|
|
79312
|
-
part = createSettingsPart();
|
|
79313
|
-
converter.convertedXml[SETTINGS_PART_PATH] = part;
|
|
79314
|
-
}
|
|
79315
|
-
const settingsRoot = findSettingsRoot(part);
|
|
79316
|
-
if (settingsRoot)
|
|
79317
|
-
return settingsRoot;
|
|
79318
|
-
const fallbackRoot = {
|
|
79319
|
-
type: "element",
|
|
79320
|
-
name: "w:settings",
|
|
79321
|
-
elements: []
|
|
79322
|
-
};
|
|
79323
|
-
if (!Array.isArray(part.elements))
|
|
79324
|
-
part.elements = [];
|
|
79325
|
-
part.elements.push(fallbackRoot);
|
|
79326
|
-
return fallbackRoot;
|
|
79327
|
-
}
|
|
79328
|
-
function hasOddEvenHeadersFooters(settingsRoot) {
|
|
79329
|
-
return settingsRoot.elements?.some((entry) => entry.name === "w:evenAndOddHeaders") === true;
|
|
79330
|
-
}
|
|
79331
|
-
function setOddEvenHeadersFooters(settingsRoot, enabled) {
|
|
79332
|
-
const elements = ensureSettingsRootElements(settingsRoot);
|
|
79333
|
-
const hadFlag = hasOddEvenHeadersFooters(settingsRoot);
|
|
79334
|
-
if (enabled) {
|
|
79335
|
-
if (!hadFlag) {
|
|
79336
|
-
elements.push({ type: "element", name: "w:evenAndOddHeaders", elements: [] });
|
|
79337
|
-
}
|
|
79338
|
-
} else {
|
|
79339
|
-
settingsRoot.elements = elements.filter((entry) => entry.name !== "w:evenAndOddHeaders");
|
|
79340
|
-
}
|
|
79341
|
-
const hasFlag = hasOddEvenHeadersFooters(settingsRoot);
|
|
79342
|
-
return hadFlag !== hasFlag;
|
|
79343
|
-
}
|
|
79344
|
-
var SETTINGS_PART_PATH = "word/settings.xml";
|
|
79345
|
-
|
|
79346
79623
|
// ../../packages/layout-engine/pm-adapter/src/sections/types.ts
|
|
79347
79624
|
var DEFAULT_PARAGRAPH_SECTION_TYPE = "nextPage" /* NEXT_PAGE */, DEFAULT_BODY_SECTION_TYPE = "continuous" /* CONTINUOUS */;
|
|
79348
79625
|
var init_types5 = () => {};
|
|
@@ -82396,7 +82673,10 @@ function assembleDocumentApiAdapters(editor) {
|
|
|
82396
82673
|
clearCellSpacing: (input, options) => tablesClearCellSpacingWrapper(editor, input, options),
|
|
82397
82674
|
get: (input) => tablesGetAdapter(editor, input),
|
|
82398
82675
|
getCells: (input) => tablesGetCellsAdapter(editor, input),
|
|
82399
|
-
getProperties: (input) => tablesGetPropertiesAdapter(editor, input)
|
|
82676
|
+
getProperties: (input) => tablesGetPropertiesAdapter(editor, input),
|
|
82677
|
+
getStyles: (input) => tablesGetStylesAdapter(editor, input),
|
|
82678
|
+
setDefaultStyle: (input, options) => tablesSetDefaultStyleAdapter(editor, input, options),
|
|
82679
|
+
clearDefaultStyle: (input, options) => tablesClearDefaultStyleAdapter(editor, input, options)
|
|
82400
82680
|
},
|
|
82401
82681
|
toc: {
|
|
82402
82682
|
list: (query2) => tocListWrapper(editor, query2),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/cli",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.59",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"@superdoc-dev/cli-darwin-arm64": "0.2.0-next.
|
|
33
|
-
"@superdoc-dev/cli-darwin-x64": "0.2.0-next.
|
|
34
|
-
"@superdoc-dev/cli-linux-
|
|
35
|
-
"@superdoc-dev/cli-windows-x64": "0.2.0-next.
|
|
36
|
-
"@superdoc-dev/cli-linux-
|
|
32
|
+
"@superdoc-dev/cli-darwin-arm64": "0.2.0-next.59",
|
|
33
|
+
"@superdoc-dev/cli-darwin-x64": "0.2.0-next.59",
|
|
34
|
+
"@superdoc-dev/cli-linux-x64": "0.2.0-next.59",
|
|
35
|
+
"@superdoc-dev/cli-windows-x64": "0.2.0-next.59",
|
|
36
|
+
"@superdoc-dev/cli-linux-arm64": "0.2.0-next.59"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"dev": "bun run src/index.ts",
|