superdoc 2.27.0 → 2.28.0-next.1
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/{create-super-doc-ui-cHUUipYM.es.js → create-super-doc-ui-B29zw5qD.es.js} +155 -2
- package/dist/chunks/{create-super-doc-ui-DpVh2nQH.cjs → create-super-doc-ui-D1eOhAjv.cjs} +155 -2
- package/dist/collaboration-upgrade-engine.cjs +1 -1
- package/dist/collaboration-upgrade-engine.es.js +1 -1
- package/dist/document-api/src/contract/operation-definitions.d.ts +2 -2
- package/dist/document-api/src/index.d.ts +3 -3
- package/dist/document-api/src/styles/apply.d.ts +26 -2
- package/dist/document-api/src/styles/index.d.ts +3 -3
- package/dist/document-api/src/styles/schema.d.ts +3 -1
- package/dist/document-api/src/styles/validation.d.ts +10 -9
- package/dist/document-api/src/types/mutation-plan.types.d.ts +11 -4
- package/dist/document-api/src/types/temporary-mutation.d.ts +5 -1
- package/dist/layout-engine/contracts/src/index.d.ts +1 -1
- package/dist/layout-engine/contracts/src/run-helpers.d.ts +7 -0
- package/dist/layout-engine/painters/dom/src/page-content.d.ts +1 -0
- package/dist/layout-engine/painters/dom/src/review-markers.d.ts +3 -0
- package/dist/layout-engine/painters/dom/src/table/renderTableCell.d.ts +1 -0
- package/dist/public/ui-react.cjs +1 -1
- package/dist/public/ui-react.es.js +1 -1
- package/dist/public/ui-vue.cjs +1 -1
- package/dist/public/ui-vue.es.js +1 -1
- package/dist/public/ui.cjs +1 -1
- package/dist/public/ui.es.js +1 -1
- package/dist/style.css +1 -1
- package/dist/style.layered.css +1 -1
- package/dist/superdoc/src/internal/toolbar/built-in/LinkedStyle.vue.d.ts +3 -1
- package/dist/superdoc/src/internal/toolbar/built-in/toolbarTexts.d.ts +1 -0
- package/dist/superdoc/src/internal/toolbar/built-in-toolbar.d.ts +1 -0
- package/dist/superdoc/src/public/ui/style-match-patch.d.ts +7 -0
- package/dist/superdoc/src/public/ui/types.d.ts +5 -1
- package/dist/superdoc/src/public/ui.d.cts +4 -0
- package/dist/superdoc/src/public/ui.d.ts +1 -1
- package/dist/superdoc.cjs +118 -62
- package/dist/superdoc.es.js +115 -61
- package/dist-cdn/style.layered.css +1 -1
- package/dist-cdn/superdoc.min.css +1 -1
- package/dist-cdn/superdoc.min.js +38 -38
- package/package.json +2 -2
package/dist/chunks/{create-super-doc-ui-cHUUipYM.es.js → create-super-doc-ui-B29zw5qD.es.js}
RENAMED
|
@@ -2458,6 +2458,69 @@ function createDialogWorkflow(editor, options, onSuccess) {
|
|
|
2458
2458
|
};
|
|
2459
2459
|
}
|
|
2460
2460
|
//#endregion
|
|
2461
|
+
//#region src/public/ui/style-match-patch.ts
|
|
2462
|
+
var STYLE_MATCH_KEYS = [
|
|
2463
|
+
["bold", "bold"],
|
|
2464
|
+
["italic", "italic"],
|
|
2465
|
+
["underline", "underline"],
|
|
2466
|
+
["color", "color"],
|
|
2467
|
+
["fontSize", "fontSize"],
|
|
2468
|
+
["rFonts", "fontFamily"]
|
|
2469
|
+
];
|
|
2470
|
+
var STYLE_MATCH_READ_KEYS = [...STYLE_MATCH_KEYS.map(([readKey]) => readKey), "rStyle"];
|
|
2471
|
+
function buildStyleMatchPatch(effective, direct, options) {
|
|
2472
|
+
const patch = {};
|
|
2473
|
+
const characterStyle = direct.properties.rStyle;
|
|
2474
|
+
const hasCharacterStyle = characterStyle != null && characterStyle.state !== "unset";
|
|
2475
|
+
for (const [readKey, styleKey] of STYLE_MATCH_KEYS) {
|
|
2476
|
+
const read = effective.properties[readKey];
|
|
2477
|
+
if (read?.state !== "uniform") continue;
|
|
2478
|
+
if (options.selectionUsesStyle && !hasCharacterStyle && direct.properties[readKey]?.state === "unset") continue;
|
|
2479
|
+
patch[styleKey] = toStyleValue(readKey, read.value);
|
|
2480
|
+
}
|
|
2481
|
+
return patch;
|
|
2482
|
+
}
|
|
2483
|
+
function toStyleValue(key, value) {
|
|
2484
|
+
switch (key) {
|
|
2485
|
+
case "bold":
|
|
2486
|
+
case "italic": return value === true;
|
|
2487
|
+
case "underline": return underlineValue(value);
|
|
2488
|
+
case "color": return typeof value === "string" && value.length > 0 ? { val: value.replace(/^#/, "") } : null;
|
|
2489
|
+
case "fontSize": return typeof value === "number" && Number.isFinite(value) ? Math.round(value * 2) : null;
|
|
2490
|
+
case "rFonts": return fontsValue(value);
|
|
2491
|
+
default: return null;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
function underlineValue(value) {
|
|
2495
|
+
if (value === true) return { val: "single" };
|
|
2496
|
+
if (!value || typeof value !== "object") return { val: "none" };
|
|
2497
|
+
const underline = value;
|
|
2498
|
+
const result = { val: typeof underline.style === "string" && underline.style ? underline.style : "single" };
|
|
2499
|
+
if (typeof underline.color === "string") result.color = underline.color;
|
|
2500
|
+
if (typeof underline.themeColor === "string") result.themeColor = underline.themeColor;
|
|
2501
|
+
return result;
|
|
2502
|
+
}
|
|
2503
|
+
var FONT_SLOTS = {
|
|
2504
|
+
ascii: "ascii",
|
|
2505
|
+
hAnsi: "hAnsi",
|
|
2506
|
+
eastAsia: "eastAsia",
|
|
2507
|
+
cs: "cs",
|
|
2508
|
+
asciiTheme: "asciiTheme",
|
|
2509
|
+
hAnsiTheme: "hAnsiTheme",
|
|
2510
|
+
eastAsiaTheme: "eastAsiaTheme",
|
|
2511
|
+
csTheme: "cstheme",
|
|
2512
|
+
hint: "hint"
|
|
2513
|
+
};
|
|
2514
|
+
function fontsValue(value) {
|
|
2515
|
+
if (!value || typeof value !== "object") return null;
|
|
2516
|
+
const result = {};
|
|
2517
|
+
for (const [slot, styleSlot] of Object.entries(FONT_SLOTS)) {
|
|
2518
|
+
const font = value[slot];
|
|
2519
|
+
if (typeof font === "string" && font.length > 0) result[styleSlot] = font;
|
|
2520
|
+
}
|
|
2521
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
2522
|
+
}
|
|
2523
|
+
//#endregion
|
|
2461
2524
|
//#region src/public/ui/format-painter-helpers.js
|
|
2462
2525
|
/**
|
|
2463
2526
|
* Maps SDRunProps field names to InlineRunPatch field names.
|
|
@@ -7099,7 +7162,7 @@ function createSuperDocUI(options) {
|
|
|
7099
7162
|
failureCount: retryingSameToken ? prev.failureCount ?? 0 : 0,
|
|
7100
7163
|
retryAtMs: 0
|
|
7101
7164
|
});
|
|
7102
|
-
Promise.resolve(raw).then((resolved) => {
|
|
7165
|
+
const settled = Promise.resolve(raw).then((resolved) => {
|
|
7103
7166
|
const entry = asyncReads.get(key);
|
|
7104
7167
|
if (!entry || entry.inflightToken !== token) return;
|
|
7105
7168
|
asyncReads.set(key, {
|
|
@@ -7138,6 +7201,7 @@ function createSuperDocUI(options) {
|
|
|
7138
7201
|
const retryAtMs = Date.now() + retryDelayMs;
|
|
7139
7202
|
asyncReads.set(key, {
|
|
7140
7203
|
...entry,
|
|
7204
|
+
settled: void 0,
|
|
7141
7205
|
inflightToken: null,
|
|
7142
7206
|
failedToken: token,
|
|
7143
7207
|
failureCount,
|
|
@@ -7145,6 +7209,8 @@ function createSuperDocUI(options) {
|
|
|
7145
7209
|
});
|
|
7146
7210
|
scheduleAsyncReadFailureRetry(retryAtMs);
|
|
7147
7211
|
});
|
|
7212
|
+
const entry = asyncReads.get(key);
|
|
7213
|
+
if (entry?.inflightToken === token) entry.settled = settled;
|
|
7148
7214
|
return null;
|
|
7149
7215
|
};
|
|
7150
7216
|
/**
|
|
@@ -14730,6 +14796,92 @@ function createSuperDocUI(options) {
|
|
|
14730
14796
|
}
|
|
14731
14797
|
}, 120);
|
|
14732
14798
|
};
|
|
14799
|
+
const updateStyleToMatchSelection = (input) => {
|
|
14800
|
+
const mode = readDocumentMode();
|
|
14801
|
+
if (mode === "viewing") return failedReceipt("The document is read-only.", "DOCUMENT_READONLY");
|
|
14802
|
+
if (mode === "suggesting") return failedReceipt("A style definition cannot be changed as a tracked suggestion.", "PRECONDITION_FAILED");
|
|
14803
|
+
const sourceToken = contentToken();
|
|
14804
|
+
const readPositionKey = () => {
|
|
14805
|
+
const snapshot = readHostSelectionSnapshot();
|
|
14806
|
+
if (!snapshot) return null;
|
|
14807
|
+
return JSON.stringify({
|
|
14808
|
+
story: snapshot.story,
|
|
14809
|
+
tableCells: snapshot.tableCells,
|
|
14810
|
+
points: ["anchor", "focus"].map((side) => {
|
|
14811
|
+
const point = snapshot[side];
|
|
14812
|
+
return point ? [
|
|
14813
|
+
point.blockId,
|
|
14814
|
+
point.blockOffset,
|
|
14815
|
+
point.trackedBlockOffset,
|
|
14816
|
+
point.story,
|
|
14817
|
+
point.inlineAffinity,
|
|
14818
|
+
point.outsideContentControl,
|
|
14819
|
+
point.visualCaret
|
|
14820
|
+
] : null;
|
|
14821
|
+
})
|
|
14822
|
+
});
|
|
14823
|
+
};
|
|
14824
|
+
const requestedPosition = readPositionKey();
|
|
14825
|
+
const stale = failedReceipt("The selection or document changed while reading its style.", "REVISION_MISMATCH");
|
|
14826
|
+
return readSelectionInfoFresh().then((selection) => {
|
|
14827
|
+
const selectionToken = selectionKey(selection);
|
|
14828
|
+
const isCurrent = () => !disposed && contentToken() === sourceToken && readPositionKey() === requestedPosition && selectionKey(state.selection) === selectionToken && readDocumentMode() === mode;
|
|
14829
|
+
if (!isCurrent()) return stale;
|
|
14830
|
+
const active = computeActiveParagraphStyle(selection, getStyleCatalog().cache).style;
|
|
14831
|
+
const story = storyLocatorSignature(selectionStory(selection));
|
|
14832
|
+
const keys = [styleCatalogReadKey({ includePreview: true }), ...selectionBlockIds(selection).map((id) => `node:${story}:${id}`)];
|
|
14833
|
+
const unreadable = failedReceipt("The selection formatting could not be read.", "PRECONDITION_FAILED");
|
|
14834
|
+
const run = (active) => {
|
|
14835
|
+
if (keys.some((key) => {
|
|
14836
|
+
const entry = asyncReads.get(key);
|
|
14837
|
+
return entry && (!entry.hasSettled || entry.token !== sourceToken || entry.failedToken === sourceToken);
|
|
14838
|
+
})) return unreadable;
|
|
14839
|
+
const styleId = input?.styleId ?? active.styleId;
|
|
14840
|
+
if (!styleId) return failedReceipt("Choose a style to update: the selection does not have a single paragraph style.", "INVALID_TARGET");
|
|
14841
|
+
const doc = getDoc();
|
|
14842
|
+
const readSelection = resolveDocOperation(doc, "format.readSelection");
|
|
14843
|
+
const apply = resolveDocOperation(doc, "styles.apply");
|
|
14844
|
+
if (!readSelection || !apply) return failedReceipt("Updating a style to match the selection is unavailable.");
|
|
14845
|
+
let reads;
|
|
14846
|
+
try {
|
|
14847
|
+
reads = [readSelection({
|
|
14848
|
+
selection: "current",
|
|
14849
|
+
keys: STYLE_MATCH_READ_KEYS,
|
|
14850
|
+
view: "effective"
|
|
14851
|
+
}), readSelection({
|
|
14852
|
+
selection: "current",
|
|
14853
|
+
keys: STYLE_MATCH_READ_KEYS,
|
|
14854
|
+
view: "direct"
|
|
14855
|
+
})];
|
|
14856
|
+
} catch {
|
|
14857
|
+
return unreadable;
|
|
14858
|
+
}
|
|
14859
|
+
return Promise.all(reads).then(([effective, direct]) => {
|
|
14860
|
+
if (!isCurrent()) return stale;
|
|
14861
|
+
const patch = buildStyleMatchPatch(effective, direct, { selectionUsesStyle: !active.mixed && active.styleId === styleId });
|
|
14862
|
+
if (Object.keys(patch).length === 0) return failedReceipt("The selection already matches the style.", "NO_OP");
|
|
14863
|
+
const fallback = failedReceipt("Updating the style failed.");
|
|
14864
|
+
return safeCall(() => settleWorkflowReceipt(apply({
|
|
14865
|
+
target: {
|
|
14866
|
+
scope: "style",
|
|
14867
|
+
styleId,
|
|
14868
|
+
channel: "run"
|
|
14869
|
+
},
|
|
14870
|
+
patch
|
|
14871
|
+
}), fallback), fallback);
|
|
14872
|
+
}, () => unreadable);
|
|
14873
|
+
};
|
|
14874
|
+
const pending = keys.flatMap((key) => {
|
|
14875
|
+
const entry = asyncReads.get(key);
|
|
14876
|
+
return entry?.inflightToken === sourceToken && entry.settled ? [entry.settled] : [];
|
|
14877
|
+
});
|
|
14878
|
+
if (pending.length === 0) return run(active);
|
|
14879
|
+
return Promise.all(pending).then(() => {
|
|
14880
|
+
if (!isCurrent()) return stale;
|
|
14881
|
+
return run(computeActiveParagraphStyle(selection, getStyleCatalog().cache).style);
|
|
14882
|
+
});
|
|
14883
|
+
});
|
|
14884
|
+
};
|
|
14733
14885
|
const stylesSub = sliceHandle((s) => s.styles);
|
|
14734
14886
|
const stylesSnap = snapshotHandle(stylesSub);
|
|
14735
14887
|
const styles = {
|
|
@@ -14742,7 +14894,8 @@ function createSuperDocUI(options) {
|
|
|
14742
14894
|
return readStyleCatalogLive(options).value;
|
|
14743
14895
|
},
|
|
14744
14896
|
getQuickGallery: () => stylesSub.get().quickGallery,
|
|
14745
|
-
getActiveParagraphStyle: () => computeActiveParagraphStyle(state.selection, getStyleCatalog().cache).style
|
|
14897
|
+
getActiveParagraphStyle: () => computeActiveParagraphStyle(state.selection, getStyleCatalog().cache).style,
|
|
14898
|
+
updateToMatchSelection: (input) => updateStyleToMatchSelection(input)
|
|
14746
14899
|
};
|
|
14747
14900
|
const openWatermarkSurface = hostMethod(superdoc, "openSurface");
|
|
14748
14901
|
const watermark = createWatermarkController({
|
|
@@ -2459,6 +2459,69 @@ function createDialogWorkflow(editor, options, onSuccess) {
|
|
|
2459
2459
|
};
|
|
2460
2460
|
}
|
|
2461
2461
|
//#endregion
|
|
2462
|
+
//#region src/public/ui/style-match-patch.ts
|
|
2463
|
+
var STYLE_MATCH_KEYS = [
|
|
2464
|
+
["bold", "bold"],
|
|
2465
|
+
["italic", "italic"],
|
|
2466
|
+
["underline", "underline"],
|
|
2467
|
+
["color", "color"],
|
|
2468
|
+
["fontSize", "fontSize"],
|
|
2469
|
+
["rFonts", "fontFamily"]
|
|
2470
|
+
];
|
|
2471
|
+
var STYLE_MATCH_READ_KEYS = [...STYLE_MATCH_KEYS.map(([readKey]) => readKey), "rStyle"];
|
|
2472
|
+
function buildStyleMatchPatch(effective, direct, options) {
|
|
2473
|
+
const patch = {};
|
|
2474
|
+
const characterStyle = direct.properties.rStyle;
|
|
2475
|
+
const hasCharacterStyle = characterStyle != null && characterStyle.state !== "unset";
|
|
2476
|
+
for (const [readKey, styleKey] of STYLE_MATCH_KEYS) {
|
|
2477
|
+
const read = effective.properties[readKey];
|
|
2478
|
+
if (read?.state !== "uniform") continue;
|
|
2479
|
+
if (options.selectionUsesStyle && !hasCharacterStyle && direct.properties[readKey]?.state === "unset") continue;
|
|
2480
|
+
patch[styleKey] = toStyleValue(readKey, read.value);
|
|
2481
|
+
}
|
|
2482
|
+
return patch;
|
|
2483
|
+
}
|
|
2484
|
+
function toStyleValue(key, value) {
|
|
2485
|
+
switch (key) {
|
|
2486
|
+
case "bold":
|
|
2487
|
+
case "italic": return value === true;
|
|
2488
|
+
case "underline": return underlineValue(value);
|
|
2489
|
+
case "color": return typeof value === "string" && value.length > 0 ? { val: value.replace(/^#/, "") } : null;
|
|
2490
|
+
case "fontSize": return typeof value === "number" && Number.isFinite(value) ? Math.round(value * 2) : null;
|
|
2491
|
+
case "rFonts": return fontsValue(value);
|
|
2492
|
+
default: return null;
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
function underlineValue(value) {
|
|
2496
|
+
if (value === true) return { val: "single" };
|
|
2497
|
+
if (!value || typeof value !== "object") return { val: "none" };
|
|
2498
|
+
const underline = value;
|
|
2499
|
+
const result = { val: typeof underline.style === "string" && underline.style ? underline.style : "single" };
|
|
2500
|
+
if (typeof underline.color === "string") result.color = underline.color;
|
|
2501
|
+
if (typeof underline.themeColor === "string") result.themeColor = underline.themeColor;
|
|
2502
|
+
return result;
|
|
2503
|
+
}
|
|
2504
|
+
var FONT_SLOTS = {
|
|
2505
|
+
ascii: "ascii",
|
|
2506
|
+
hAnsi: "hAnsi",
|
|
2507
|
+
eastAsia: "eastAsia",
|
|
2508
|
+
cs: "cs",
|
|
2509
|
+
asciiTheme: "asciiTheme",
|
|
2510
|
+
hAnsiTheme: "hAnsiTheme",
|
|
2511
|
+
eastAsiaTheme: "eastAsiaTheme",
|
|
2512
|
+
csTheme: "cstheme",
|
|
2513
|
+
hint: "hint"
|
|
2514
|
+
};
|
|
2515
|
+
function fontsValue(value) {
|
|
2516
|
+
if (!value || typeof value !== "object") return null;
|
|
2517
|
+
const result = {};
|
|
2518
|
+
for (const [slot, styleSlot] of Object.entries(FONT_SLOTS)) {
|
|
2519
|
+
const font = value[slot];
|
|
2520
|
+
if (typeof font === "string" && font.length > 0) result[styleSlot] = font;
|
|
2521
|
+
}
|
|
2522
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
2523
|
+
}
|
|
2524
|
+
//#endregion
|
|
2462
2525
|
//#region src/public/ui/format-painter-helpers.js
|
|
2463
2526
|
/**
|
|
2464
2527
|
* Maps SDRunProps field names to InlineRunPatch field names.
|
|
@@ -7100,7 +7163,7 @@ function createSuperDocUI(options) {
|
|
|
7100
7163
|
failureCount: retryingSameToken ? prev.failureCount ?? 0 : 0,
|
|
7101
7164
|
retryAtMs: 0
|
|
7102
7165
|
});
|
|
7103
|
-
Promise.resolve(raw).then((resolved) => {
|
|
7166
|
+
const settled = Promise.resolve(raw).then((resolved) => {
|
|
7104
7167
|
const entry = asyncReads.get(key);
|
|
7105
7168
|
if (!entry || entry.inflightToken !== token) return;
|
|
7106
7169
|
asyncReads.set(key, {
|
|
@@ -7139,6 +7202,7 @@ function createSuperDocUI(options) {
|
|
|
7139
7202
|
const retryAtMs = Date.now() + retryDelayMs;
|
|
7140
7203
|
asyncReads.set(key, {
|
|
7141
7204
|
...entry,
|
|
7205
|
+
settled: void 0,
|
|
7142
7206
|
inflightToken: null,
|
|
7143
7207
|
failedToken: token,
|
|
7144
7208
|
failureCount,
|
|
@@ -7146,6 +7210,8 @@ function createSuperDocUI(options) {
|
|
|
7146
7210
|
});
|
|
7147
7211
|
scheduleAsyncReadFailureRetry(retryAtMs);
|
|
7148
7212
|
});
|
|
7213
|
+
const entry = asyncReads.get(key);
|
|
7214
|
+
if (entry?.inflightToken === token) entry.settled = settled;
|
|
7149
7215
|
return null;
|
|
7150
7216
|
};
|
|
7151
7217
|
/**
|
|
@@ -14731,6 +14797,92 @@ function createSuperDocUI(options) {
|
|
|
14731
14797
|
}
|
|
14732
14798
|
}, 120);
|
|
14733
14799
|
};
|
|
14800
|
+
const updateStyleToMatchSelection = (input) => {
|
|
14801
|
+
const mode = readDocumentMode();
|
|
14802
|
+
if (mode === "viewing") return failedReceipt("The document is read-only.", "DOCUMENT_READONLY");
|
|
14803
|
+
if (mode === "suggesting") return failedReceipt("A style definition cannot be changed as a tracked suggestion.", "PRECONDITION_FAILED");
|
|
14804
|
+
const sourceToken = contentToken();
|
|
14805
|
+
const readPositionKey = () => {
|
|
14806
|
+
const snapshot = readHostSelectionSnapshot();
|
|
14807
|
+
if (!snapshot) return null;
|
|
14808
|
+
return JSON.stringify({
|
|
14809
|
+
story: snapshot.story,
|
|
14810
|
+
tableCells: snapshot.tableCells,
|
|
14811
|
+
points: ["anchor", "focus"].map((side) => {
|
|
14812
|
+
const point = snapshot[side];
|
|
14813
|
+
return point ? [
|
|
14814
|
+
point.blockId,
|
|
14815
|
+
point.blockOffset,
|
|
14816
|
+
point.trackedBlockOffset,
|
|
14817
|
+
point.story,
|
|
14818
|
+
point.inlineAffinity,
|
|
14819
|
+
point.outsideContentControl,
|
|
14820
|
+
point.visualCaret
|
|
14821
|
+
] : null;
|
|
14822
|
+
})
|
|
14823
|
+
});
|
|
14824
|
+
};
|
|
14825
|
+
const requestedPosition = readPositionKey();
|
|
14826
|
+
const stale = failedReceipt("The selection or document changed while reading its style.", "REVISION_MISMATCH");
|
|
14827
|
+
return readSelectionInfoFresh().then((selection) => {
|
|
14828
|
+
const selectionToken = selectionKey(selection);
|
|
14829
|
+
const isCurrent = () => !disposed && contentToken() === sourceToken && readPositionKey() === requestedPosition && selectionKey(state.selection) === selectionToken && readDocumentMode() === mode;
|
|
14830
|
+
if (!isCurrent()) return stale;
|
|
14831
|
+
const active = computeActiveParagraphStyle(selection, getStyleCatalog().cache).style;
|
|
14832
|
+
const story = storyLocatorSignature(selectionStory(selection));
|
|
14833
|
+
const keys = [styleCatalogReadKey({ includePreview: true }), ...selectionBlockIds(selection).map((id) => `node:${story}:${id}`)];
|
|
14834
|
+
const unreadable = failedReceipt("The selection formatting could not be read.", "PRECONDITION_FAILED");
|
|
14835
|
+
const run = (active) => {
|
|
14836
|
+
if (keys.some((key) => {
|
|
14837
|
+
const entry = asyncReads.get(key);
|
|
14838
|
+
return entry && (!entry.hasSettled || entry.token !== sourceToken || entry.failedToken === sourceToken);
|
|
14839
|
+
})) return unreadable;
|
|
14840
|
+
const styleId = input?.styleId ?? active.styleId;
|
|
14841
|
+
if (!styleId) return failedReceipt("Choose a style to update: the selection does not have a single paragraph style.", "INVALID_TARGET");
|
|
14842
|
+
const doc = getDoc();
|
|
14843
|
+
const readSelection = resolveDocOperation(doc, "format.readSelection");
|
|
14844
|
+
const apply = resolveDocOperation(doc, "styles.apply");
|
|
14845
|
+
if (!readSelection || !apply) return failedReceipt("Updating a style to match the selection is unavailable.");
|
|
14846
|
+
let reads;
|
|
14847
|
+
try {
|
|
14848
|
+
reads = [readSelection({
|
|
14849
|
+
selection: "current",
|
|
14850
|
+
keys: STYLE_MATCH_READ_KEYS,
|
|
14851
|
+
view: "effective"
|
|
14852
|
+
}), readSelection({
|
|
14853
|
+
selection: "current",
|
|
14854
|
+
keys: STYLE_MATCH_READ_KEYS,
|
|
14855
|
+
view: "direct"
|
|
14856
|
+
})];
|
|
14857
|
+
} catch {
|
|
14858
|
+
return unreadable;
|
|
14859
|
+
}
|
|
14860
|
+
return Promise.all(reads).then(([effective, direct]) => {
|
|
14861
|
+
if (!isCurrent()) return stale;
|
|
14862
|
+
const patch = buildStyleMatchPatch(effective, direct, { selectionUsesStyle: !active.mixed && active.styleId === styleId });
|
|
14863
|
+
if (Object.keys(patch).length === 0) return failedReceipt("The selection already matches the style.", "NO_OP");
|
|
14864
|
+
const fallback = failedReceipt("Updating the style failed.");
|
|
14865
|
+
return safeCall(() => settleWorkflowReceipt(apply({
|
|
14866
|
+
target: {
|
|
14867
|
+
scope: "style",
|
|
14868
|
+
styleId,
|
|
14869
|
+
channel: "run"
|
|
14870
|
+
},
|
|
14871
|
+
patch
|
|
14872
|
+
}), fallback), fallback);
|
|
14873
|
+
}, () => unreadable);
|
|
14874
|
+
};
|
|
14875
|
+
const pending = keys.flatMap((key) => {
|
|
14876
|
+
const entry = asyncReads.get(key);
|
|
14877
|
+
return entry?.inflightToken === sourceToken && entry.settled ? [entry.settled] : [];
|
|
14878
|
+
});
|
|
14879
|
+
if (pending.length === 0) return run(active);
|
|
14880
|
+
return Promise.all(pending).then(() => {
|
|
14881
|
+
if (!isCurrent()) return stale;
|
|
14882
|
+
return run(computeActiveParagraphStyle(selection, getStyleCatalog().cache).style);
|
|
14883
|
+
});
|
|
14884
|
+
});
|
|
14885
|
+
};
|
|
14734
14886
|
const stylesSub = sliceHandle((s) => s.styles);
|
|
14735
14887
|
const stylesSnap = snapshotHandle(stylesSub);
|
|
14736
14888
|
const styles = {
|
|
@@ -14743,7 +14895,8 @@ function createSuperDocUI(options) {
|
|
|
14743
14895
|
return readStyleCatalogLive(options).value;
|
|
14744
14896
|
},
|
|
14745
14897
|
getQuickGallery: () => stylesSub.get().quickGallery,
|
|
14746
|
-
getActiveParagraphStyle: () => computeActiveParagraphStyle(state.selection, getStyleCatalog().cache).style
|
|
14898
|
+
getActiveParagraphStyle: () => computeActiveParagraphStyle(state.selection, getStyleCatalog().cache).style,
|
|
14899
|
+
updateToMatchSelection: (input) => updateStyleToMatchSelection(input)
|
|
14747
14900
|
};
|
|
14748
14901
|
const openWatermarkSurface = hostMethod(superdoc, "openSurface");
|
|
14749
14902
|
const watermark = createWatermarkController({
|
|
@@ -19,7 +19,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
|
|
|
19
19
|
var PRIVATE_ENGINE_INFO = (0, _superdoc_docx_engine_collaboration_upgrade_engine.getCollaborationUpgradeEngineInfo)();
|
|
20
20
|
var ENGINE_INFO = Object.freeze({
|
|
21
21
|
...PRIVATE_ENGINE_INFO,
|
|
22
|
-
superdocVersion: "2.
|
|
22
|
+
superdocVersion: "2.28.0-next.1",
|
|
23
23
|
roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
|
|
24
24
|
supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
|
|
25
25
|
supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
|
|
@@ -18,7 +18,7 @@ var COLLABORATION_UPGRADE_ENGINE_MINIMUM_NODE_MAJOR = 20;
|
|
|
18
18
|
var PRIVATE_ENGINE_INFO = getCollaborationUpgradeEngineInfo$1();
|
|
19
19
|
var ENGINE_INFO = Object.freeze({
|
|
20
20
|
...PRIVATE_ENGINE_INFO,
|
|
21
|
-
superdocVersion: "2.
|
|
21
|
+
superdocVersion: "2.28.0-next.1",
|
|
22
22
|
roomSchemaVersion: Object.freeze({ ...PRIVATE_ENGINE_INFO.roomSchemaVersion }),
|
|
23
23
|
supportedBundleVersions: SUPPORTED_COLLABORATION_UPGRADE_BUNDLE_VERSIONS,
|
|
24
24
|
supportedV1ReaderContractVersions: SUPPORTED_V1_READER_CONTRACT_VERSIONS
|
|
@@ -42,7 +42,7 @@ export declare const OPERATION_DEFINITIONS: {
|
|
|
42
42
|
};
|
|
43
43
|
readonly 'styles.apply': {
|
|
44
44
|
readonly memberPath: "styles.apply";
|
|
45
|
-
readonly description: "Apply
|
|
45
|
+
readonly description: "Apply style changes to the active Style Definitions part. Targets docDefaults run and paragraph channels, or the run properties of an existing named paragraph style (scope \"style\"), with set-style patch semantics. Redefining a named style updates every paragraph that references it; its linked character style receives the same patch, null removes a property so the style inherits it again, and an object value replaces that property whole.";
|
|
46
46
|
readonly expectedResult: "Returns a StylesApplyReceipt with per-channel success/failure details for each property change.";
|
|
47
47
|
readonly requiresDocumentContext: true;
|
|
48
48
|
readonly metadata: CommandStaticMetadata;
|
|
@@ -2523,7 +2523,7 @@ export declare const OPERATION_DEFINITIONS: {
|
|
|
2523
2523
|
readonly 'contentControls.validateWordCompatibility': {
|
|
2524
2524
|
readonly memberPath: "contentControls.validateWordCompatibility";
|
|
2525
2525
|
readonly description: "Validate a content control for Word compatibility issues.";
|
|
2526
|
-
readonly expectedResult: "Returns a
|
|
2526
|
+
readonly expectedResult: "Returns read-only diagnostics for incompatible content structure and metadata or configuration issues. `compatible` is false only when a diagnostic has error severity; warnings leave it true.";
|
|
2527
2527
|
readonly requiresDocumentContext: true;
|
|
2528
2528
|
readonly metadata: CommandStaticMetadata;
|
|
2529
2529
|
readonly referenceDocPath: "content-controls/validate-word-compatibility.mdx";
|
|
@@ -64,7 +64,7 @@ import { CaptionsApi, CaptionsAdapter } from './captions/captions.js';
|
|
|
64
64
|
import { FieldsApi, FieldsAdapter } from './fields/fields.js';
|
|
65
65
|
import { CitationsApi, CitationsAdapter } from './citations/citations.js';
|
|
66
66
|
import { AuthoritiesApi, AuthoritiesAdapter } from './authorities/authorities.js';
|
|
67
|
-
export type { TemporaryMutationInput, TemporaryMutationHandleInput, TemporaryMutationCommitInput, TemporaryMutationReplaceInput, TemporaryMutationReceipt, TemporaryMutationMetadata, TemporaryMutationOperation, TemporaryOperationResultTarget, } from './types/temporary-mutation.js';
|
|
67
|
+
export type { TemporaryMutationInput, TemporaryMutationHandleInput, TemporaryMutationCommitInput, TemporaryMutationReplaceInput, TemporaryMutationReceipt, TemporaryMutationMetadata, TemporaryMutationOperation, TemporaryOperationResultTarget, TemporaryOperationEffects, } from './types/temporary-mutation.js';
|
|
68
68
|
export * from './types/index.js';
|
|
69
69
|
export * from './contract/index.js';
|
|
70
70
|
export * from './capabilities/capabilities.js';
|
|
@@ -116,10 +116,10 @@ export type { FormatReadSelectionAdapter, FormatReadSelectionInput, FormatReadSe
|
|
|
116
116
|
export type { InlineRunPatch, InlineRunPatchKey, InlinePropertyStorage, InlinePropertyType, InlinePropertyCarrier, InlinePropertyRegistryEntry, UnderlinePatch, ShadingPatch, BorderPatch, FitTextPatch, LangPatch, RFontsPatch, EastAsianLayoutPatch, StylisticSetPatch, } from './format/inline-run-patch.js';
|
|
117
117
|
export { CLEAR_INLINE_FORMATTING_KEYS, INLINE_PROPERTY_REGISTRY, INLINE_PROPERTY_KEY_SET, INLINE_PROPERTY_BY_KEY, INLINE_PROPERTY_KEYS_BY_STORAGE, validateInlineRunPatch, buildInlineRunPatchSchema, } from './format/inline-run-patch.js';
|
|
118
118
|
export { PROPERTY_REGISTRY, EXCLUDED_KEYS, ALLOWED_KEYS_BY_CHANNEL, getPropertyDefinition, toJsonSchema, buildPatchSchema, buildStateSchema, } from './styles/index.js';
|
|
119
|
-
export type { ValueSchema, MergeStrategy, PropertyDefinition, StylesAdapter, StylesApplyInput, StylesApplyRunInput, StylesApplyParagraphInput, StylesApplyOptions, StylesApplyReceipt, StylesBooleanState, StylesNumberState, StylesEnumState, StylesObjectState, StylesArrayState, StylesStateMap, StylesChannel, StylesRunPatch, StylesParagraphPatch, StylesTargetResolution, StylesApplyReceiptSuccess, StylesApplyReceiptFailure, NormalizedStylesApplyOptions, StyleCatalogView, StyleCatalogItemType, StyleCatalogFilterType, StyleProvenance, StyleCatalogDiagnosticSeverity, StyleSourcePartStatus, StyleCatalogUsageStatus, StyleCatalogPreviewStatus, StyleCatalogViewStatus, StyleCatalogItemVisibility, StyleCatalogItemUsage, StyleCatalogItemPreview, StyleCatalogPreviewFontSource, StyleCatalogPreviewColorSource, StyleCatalogPreviewSources, StyleCatalogItem, StyleCatalogDefaults, StyleCatalogDiagnostic, StyleCatalogSourceStatus, StylesGetCatalogInput, StylesGetCatalogResult, StylesGetCatalogAdapter, StylesGetThemeInput, StylesThemeSourceStatus, StylesGetThemeResult, StylesGetThemeAdapter, } from './styles/index.js';
|
|
119
|
+
export type { ValueSchema, MergeStrategy, PropertyDefinition, StylesAdapter, StylesApplyInput, StylesApplyRunInput, StylesApplyParagraphInput, StylesApplyStyleRunInput, StylesStyleRunPatch, StylesDocDefaultsResolution, StylesStyleResolution, StylesApplyOptions, StylesApplyReceipt, StylesBooleanState, StylesNumberState, StylesEnumState, StylesObjectState, StylesArrayState, StylesStateMap, StylesChannel, StylesRunPatch, StylesParagraphPatch, StylesTargetResolution, StylesApplyReceiptSuccess, StylesApplyReceiptFailure, NormalizedStylesApplyOptions, StyleCatalogView, StyleCatalogItemType, StyleCatalogFilterType, StyleProvenance, StyleCatalogDiagnosticSeverity, StyleSourcePartStatus, StyleCatalogUsageStatus, StyleCatalogPreviewStatus, StyleCatalogViewStatus, StyleCatalogItemVisibility, StyleCatalogItemUsage, StyleCatalogItemPreview, StyleCatalogPreviewFontSource, StyleCatalogPreviewColorSource, StyleCatalogPreviewSources, StyleCatalogItem, StyleCatalogDefaults, StyleCatalogDiagnostic, StyleCatalogSourceStatus, StylesGetCatalogInput, StylesGetCatalogResult, StylesGetCatalogAdapter, StylesGetThemeInput, StylesThemeSourceStatus, StylesGetThemeResult, StylesGetThemeAdapter, } from './styles/index.js';
|
|
120
120
|
export { STYLE_CATALOG_VIEWS, STYLE_CATALOG_FILTER_TYPES, executeStylesGetCatalog, validateStylesGetCatalogInput, executeStylesGetTheme, validateStylesGetThemeInput, } from './styles/index.js';
|
|
121
121
|
export type { StylesScope, StyleRunPatch, StyleConflictPolicy, StyleChannelState, StylesCreateAdapter, StylesCreateApi, StylesCreateInput, StylesCreateParagraphInput, StylesCreateCharacterInput, StylesCreateOptions, NormalizedStylesCreateOptions, StylesCreateResolution, StylesCreateReceipt, StylesCreateReceiptSuccess, StylesCreateReceiptFailure, } from './styles/index.js';
|
|
122
|
-
export { STYLE_EXCLUDED_KEYS, EXCLUDED_KEYS_BY_SCOPE, SCOPE_LABEL, STYLE_XML_PATH, executeStylesCreate, validateStylesCreateInput, validateStylesCreateOptions, validatePatchObject, } from './styles/index.js';
|
|
122
|
+
export { STYLE_EXCLUDED_KEYS, EXCLUDED_KEYS_BY_SCOPE, SCOPE_LABEL, STYLE_XML_PATH, STYLE_RUN_XML_PATH, validateStylesApplyInput, executeStylesCreate, validateStylesCreateInput, validateStylesCreateOptions, validatePatchObject, } from './styles/index.js';
|
|
123
123
|
export type { TemplatesAdapter, TemplatesApi, TemplatesApplyInput, TemplatesApplyOptions, TemplatesApplySource, TemplatesApplySourcePath, TemplatesApplySourceBase64, TemplateBodyPolicy, TemplateScope, NormalizedTemplatesApplyOptions, TemplateScopeReport, TemplateSkipReason, TemplateScopeSkip, TemplateUnsupportedItem, TemplateChangeKind, TemplateChangedPart, TemplateIdMapping, TemplateApplyWarning, TemplatesApplySourceInfo, TemplatesApplyReceiptSuccess, TemplatesApplyFailureCode, TemplatesApplyReceiptFailure, TemplatesApplyReceipt, } from './templates/index.js';
|
|
124
124
|
export { executeTemplatesApply } from './templates/index.js';
|
|
125
125
|
export type { CreateAdapter, CreateApi } from './create/create.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReceiptFailure } from '../types/receipt.js';
|
|
2
2
|
import { StylesChannel } from './registry.js';
|
|
3
3
|
import { StylesGetCatalogInput, StylesGetCatalogResult } from './catalog.js';
|
|
4
|
+
import { StyleRunPatch } from './create.js';
|
|
4
5
|
import { StylesGetThemeInput, StylesGetThemeResult } from './theme.js';
|
|
5
6
|
/** Tri-state for OOXML boolean style properties. */
|
|
6
7
|
export type StylesBooleanState = 'on' | 'off' | 'inherit';
|
|
@@ -78,12 +79,22 @@ export interface StylesParagraphPatch {
|
|
|
78
79
|
borders?: Record<string, unknown>;
|
|
79
80
|
tabStops?: unknown[];
|
|
80
81
|
}
|
|
81
|
-
export interface
|
|
82
|
+
export interface StylesDocDefaultsResolution {
|
|
82
83
|
scope: 'docDefaults';
|
|
83
84
|
channel: StylesChannel;
|
|
84
85
|
xmlPart: string;
|
|
85
86
|
xmlPath: string;
|
|
86
87
|
}
|
|
88
|
+
export interface StylesStyleResolution {
|
|
89
|
+
scope: 'style';
|
|
90
|
+
styleId: string;
|
|
91
|
+
channel: 'run';
|
|
92
|
+
xmlPart: string;
|
|
93
|
+
xmlPath: typeof STYLE_RUN_XML_PATH;
|
|
94
|
+
linkedStyleId?: string;
|
|
95
|
+
}
|
|
96
|
+
export type StylesTargetResolution = StylesDocDefaultsResolution | StylesStyleResolution;
|
|
97
|
+
export declare const STYLE_RUN_XML_PATH = "w:styles/w:style/w:rPr";
|
|
87
98
|
export interface StylesApplyRunInput {
|
|
88
99
|
target: {
|
|
89
100
|
scope: 'docDefaults';
|
|
@@ -98,7 +109,18 @@ export interface StylesApplyParagraphInput {
|
|
|
98
109
|
};
|
|
99
110
|
patch: StylesParagraphPatch;
|
|
100
111
|
}
|
|
101
|
-
export type
|
|
112
|
+
export type StylesStyleRunPatch = {
|
|
113
|
+
[K in keyof StyleRunPatch]?: StyleRunPatch[K] | null;
|
|
114
|
+
};
|
|
115
|
+
export interface StylesApplyStyleRunInput {
|
|
116
|
+
target: {
|
|
117
|
+
scope: 'style';
|
|
118
|
+
styleId: string;
|
|
119
|
+
channel: 'run';
|
|
120
|
+
};
|
|
121
|
+
patch: StylesStyleRunPatch;
|
|
122
|
+
}
|
|
123
|
+
export type StylesApplyInput = StylesApplyRunInput | StylesApplyParagraphInput | StylesApplyStyleRunInput;
|
|
102
124
|
export interface StylesApplyOptions {
|
|
103
125
|
dryRun?: boolean;
|
|
104
126
|
expectedRevision?: string;
|
|
@@ -121,6 +143,7 @@ export type StylesApplyReceipt = StylesApplyReceiptSuccess | StylesApplyReceiptF
|
|
|
121
143
|
export interface StylesAdapter {
|
|
122
144
|
apply(input: StylesApplyRunInput, options: NormalizedStylesApplyOptions): StylesApplyReceipt;
|
|
123
145
|
apply(input: StylesApplyParagraphInput, options: NormalizedStylesApplyOptions): StylesApplyReceipt;
|
|
146
|
+
apply(input: StylesApplyStyleRunInput, options: NormalizedStylesApplyOptions): StylesApplyReceipt;
|
|
124
147
|
apply(input: StylesApplyInput, options: NormalizedStylesApplyOptions): StylesApplyReceipt;
|
|
125
148
|
/** Read the normalized style catalogue. See `styles/catalog.ts`. */
|
|
126
149
|
getCatalog?(input?: StylesGetCatalogInput): StylesGetCatalogResult;
|
|
@@ -134,6 +157,7 @@ export interface NormalizedStylesApplyOptions {
|
|
|
134
157
|
export interface StylesApi {
|
|
135
158
|
apply(input: StylesApplyRunInput, options?: StylesApplyOptions): StylesApplyReceipt;
|
|
136
159
|
apply(input: StylesApplyParagraphInput, options?: StylesApplyOptions): StylesApplyReceipt;
|
|
160
|
+
apply(input: StylesApplyStyleRunInput, options?: StylesApplyOptions): StylesApplyReceipt;
|
|
137
161
|
apply(input: StylesApplyInput, options?: StylesApplyOptions): StylesApplyReceipt;
|
|
138
162
|
/** Read the normalized style catalogue for discovery and quick-gallery UI. */
|
|
139
163
|
getCatalog(input?: StylesGetCatalogInput): StylesGetCatalogResult;
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
export type { ValueSchema, StylesChannel, StylesScope, MergeStrategy, PropertyDefinition } from './registry.js';
|
|
7
7
|
export { PROPERTY_REGISTRY, ALLOWED_KEYS_BY_CHANNEL, EXCLUDED_KEYS, STYLE_EXCLUDED_KEYS, EXCLUDED_KEYS_BY_SCOPE, SCOPE_LABEL, XML_PATH_BY_CHANNEL, getPropertyDefinition, ST_VERTICAL_ALIGN_RUN, ST_EM, ST_TEXT_ALIGNMENT, ST_TEXT_DIRECTION, ST_TEXTBOX_TIGHT_WRAP, ST_TEXT_TRANSFORM, ST_JUSTIFICATION, } from './registry.js';
|
|
8
8
|
export { toJsonSchema, buildPatchSchema, buildStateSchema } from './schema.js';
|
|
9
|
-
export type { StylesBooleanState, StylesNumberState, StylesEnumState, StylesObjectState, StylesArrayState, StylesRunPatch, StylesParagraphPatch, StylesTargetResolution, StylesApplyRunInput, StylesApplyParagraphInput, StylesApplyInput, StylesApplyOptions, StylesStateMap, StylesApplyReceiptSuccess, StylesApplyReceiptFailure, StylesApplyReceipt, StylesAdapter, NormalizedStylesApplyOptions, StylesApi, } from './apply.js';
|
|
10
|
-
export { executeStylesApply } from './apply.js';
|
|
9
|
+
export type { StylesBooleanState, StylesNumberState, StylesEnumState, StylesObjectState, StylesArrayState, StylesRunPatch, StylesParagraphPatch, StylesTargetResolution, StylesApplyRunInput, StylesApplyParagraphInput, StylesApplyStyleRunInput, StylesStyleRunPatch, StylesDocDefaultsResolution, StylesStyleResolution, StylesApplyInput, StylesApplyOptions, StylesStateMap, StylesApplyReceiptSuccess, StylesApplyReceiptFailure, StylesApplyReceipt, StylesAdapter, NormalizedStylesApplyOptions, StylesApi, } from './apply.js';
|
|
10
|
+
export { STYLE_RUN_XML_PATH, executeStylesApply } from './apply.js';
|
|
11
11
|
export type { StyleRunPatch, StyleConflictPolicy, StyleChannelState, StylesCreateParagraphInput, StylesCreateCharacterInput, StylesCreateInput, StylesCreateOptions, NormalizedStylesCreateOptions, StylesCreateResolution, StylesCreateReceiptSuccess, StylesCreateReceiptFailure, StylesCreateReceipt, StylesCreateAdapter, StylesCreateApi, } from './create.js';
|
|
12
12
|
export { STYLE_XML_PATH, executeStylesCreate, validateStylesCreateInput, validateStylesCreateOptions, } from './create.js';
|
|
13
13
|
export type { StyleCatalogView, StyleCatalogItemType, StyleCatalogFilterType, StyleProvenance, StyleCatalogDiagnosticSeverity, StyleSourcePartStatus, StyleCatalogUsageStatus, StyleCatalogPreviewStatus, StyleCatalogViewStatus, StyleCatalogItemVisibility, StyleCatalogItemUsage, StyleCatalogItemPreview, StyleCatalogPreviewFontSource, StyleCatalogPreviewColorSource, StyleCatalogPreviewSources, StyleCatalogItem, StyleCatalogDefaults, StyleCatalogDiagnostic, StyleCatalogSourceStatus, StylesGetCatalogInput, StylesGetCatalogResult, StylesGetCatalogAdapter, } from './catalog.js';
|
|
@@ -15,4 +15,4 @@ export { STYLE_CATALOG_VIEWS, STYLE_CATALOG_FILTER_TYPES, executeStylesGetCatalo
|
|
|
15
15
|
export type { StylesGetThemeInput, StylesThemeSourceStatus, StylesGetThemeResult, StylesGetThemeAdapter, } from './theme.js';
|
|
16
16
|
export { executeStylesGetTheme, validateStylesGetThemeInput } from './theme.js';
|
|
17
17
|
export type { PatchKeyClassification } from './validation.js';
|
|
18
|
-
export { validateValue, classifyPatchKey, validatePatchObject } from './validation.js';
|
|
18
|
+
export { validateValue, classifyPatchKey, validatePatchObject, validateStylesApplyInput } from './validation.js';
|
|
@@ -10,7 +10,9 @@ export declare function toJsonSchema(schema: ValueSchema): JsonSchema;
|
|
|
10
10
|
* a schema that advertised them on `docDefaults` would describe an input the
|
|
11
11
|
* validator rejects.
|
|
12
12
|
*/
|
|
13
|
-
export declare function buildPatchSchema(channel: StylesChannel, scope?: StylesScope
|
|
13
|
+
export declare function buildPatchSchema(channel: StylesChannel, scope?: StylesScope, options?: {
|
|
14
|
+
nullable?: boolean;
|
|
15
|
+
}): JsonSchema;
|
|
14
16
|
/**
|
|
15
17
|
* Builds a JSON Schema for the before/after state map of a given scope.
|
|
16
18
|
*
|
|
@@ -13,6 +13,13 @@ export type StylesApplyInputShape = {
|
|
|
13
13
|
channel: StylesChannel;
|
|
14
14
|
};
|
|
15
15
|
patch: Record<string, unknown>;
|
|
16
|
+
} | {
|
|
17
|
+
target: {
|
|
18
|
+
scope: 'style';
|
|
19
|
+
styleId: string;
|
|
20
|
+
channel: 'run';
|
|
21
|
+
};
|
|
22
|
+
patch: Record<string, unknown>;
|
|
16
23
|
};
|
|
17
24
|
export declare function validateStylesApplyInput(input: unknown): asserts input is StylesApplyInputShape;
|
|
18
25
|
export declare function validateStylesApplyOptions(options: unknown): void;
|
|
@@ -36,12 +43,6 @@ export type PatchKeyClassification = {
|
|
|
36
43
|
* cross-channel lookups.
|
|
37
44
|
*/
|
|
38
45
|
export declare function classifyPatchKey(key: string, channel: StylesChannel, scope?: StylesScope): PatchKeyClassification;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* Shared by `styles.apply` (scope `docDefaults`) and `styles.create` (scope
|
|
43
|
-
* `style`); `field` names the caller's own input path so the error points at
|
|
44
|
-
* `patch` or at `run` / `paragraph` rather than at whichever one happened to
|
|
45
|
-
* write this code.
|
|
46
|
-
*/
|
|
47
|
-
export declare function validatePatchObject(patch: Record<string, unknown>, channel: StylesChannel, scope: StylesScope, field: string): void;
|
|
46
|
+
export declare function validatePatchObject(patch: Record<string, unknown>, channel: StylesChannel, scope: StylesScope, field: string, options?: {
|
|
47
|
+
allowNull?: boolean;
|
|
48
|
+
}): void;
|
|
@@ -173,27 +173,34 @@ export type DomainStep = {
|
|
|
173
173
|
};
|
|
174
174
|
export type MutationStep = TextRewriteStep | TextInsertStep | TextDeleteStep | StyleApplyStep | StructuralInsertStep | StructuralReplaceStep | AssertStep | DomainStep | ReviewMutationStep;
|
|
175
175
|
export type { ChangeMode } from '../write/write.js';
|
|
176
|
+
type MutationPlanAttribution = {
|
|
177
|
+
changeMode: 'direct';
|
|
178
|
+
author?: never;
|
|
179
|
+
} | {
|
|
180
|
+
changeMode: 'tracked';
|
|
181
|
+
author?: {
|
|
182
|
+
name: string;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
176
185
|
export type MutationsApplyInput = {
|
|
177
186
|
/** Target story for the mutation plan. Omit for body (backward compatible). */
|
|
178
187
|
in?: StoryLocator;
|
|
179
188
|
expectedRevision?: string;
|
|
180
189
|
atomic: true;
|
|
181
|
-
changeMode: ChangeMode;
|
|
182
190
|
steps: MutationStep[];
|
|
183
|
-
};
|
|
191
|
+
} & MutationPlanAttribution;
|
|
184
192
|
export type MutationsPreviewInput = {
|
|
185
193
|
/** Target story for the mutation preview. Omit for body (backward compatible). */
|
|
186
194
|
in?: StoryLocator;
|
|
187
195
|
expectedRevision?: string;
|
|
188
196
|
atomic: true;
|
|
189
|
-
changeMode: ChangeMode;
|
|
190
197
|
steps: MutationStep[];
|
|
191
198
|
/** Optional page over verbose resolved-target details. Defaults to the first 100 targets. */
|
|
192
199
|
detail?: {
|
|
193
200
|
offset?: number;
|
|
194
201
|
limit?: number;
|
|
195
202
|
};
|
|
196
|
-
};
|
|
203
|
+
} & MutationPlanAttribution;
|
|
197
204
|
/** Maximum number of steps per mutation plan. */
|
|
198
205
|
export declare const MAX_PLAN_STEPS = 200;
|
|
199
206
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocumentApiSurface } from '../index.js';
|
|
2
|
-
import { ReceiptFailureResult, ReceiptSuccess } from './receipt.js';
|
|
2
|
+
import { ReceiptEntity, ReceiptFailureResult, ReceiptSuccess } from './receipt.js';
|
|
3
3
|
import { PlainTextInsertInput } from '../insert/insert.js';
|
|
4
4
|
import { ParagraphTextReplaceInput, ReplaceMutationOptions, TextReplaceInput } from '../replace/replace.js';
|
|
5
5
|
import { MutationOptions, TrackedTextMutationOptions } from '../write/write.js';
|
|
@@ -74,11 +74,15 @@ export interface TemporaryMutationMetadata {
|
|
|
74
74
|
tag: string;
|
|
75
75
|
onNativeEdit?: 'cancel' | 'preserve';
|
|
76
76
|
}
|
|
77
|
+
export type TemporaryOperationEffects = Partial<Record<string, {
|
|
78
|
+
inserted: ReceiptEntity[];
|
|
79
|
+
}>>;
|
|
77
80
|
export type TemporaryMutationReceipt = (ReceiptSuccess & {
|
|
78
81
|
temporary: TemporaryMutationMetadata;
|
|
79
82
|
revision: {
|
|
80
83
|
before: string;
|
|
81
84
|
after: string;
|
|
82
85
|
};
|
|
86
|
+
operationEffects?: TemporaryOperationEffects;
|
|
83
87
|
}) | ReceiptFailureResult;
|
|
84
88
|
export {};
|