@sanity/assist 2.0.1 → 2.0.2
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.esm.js
CHANGED
|
@@ -1865,6 +1865,7 @@ function FieldsInitializer(_ref9) {
|
|
|
1865
1865
|
}, [documentPresets, pathKey, existingField]);
|
|
1866
1866
|
const initialized = useRef(false);
|
|
1867
1867
|
useEffect(() => {
|
|
1868
|
+
var _a;
|
|
1868
1869
|
if (initialized.current || !pathKey) {
|
|
1869
1870
|
return;
|
|
1870
1871
|
}
|
|
@@ -1876,16 +1877,22 @@ function FieldsInitializer(_ref9) {
|
|
|
1876
1877
|
event = event.append(insert([typed({
|
|
1877
1878
|
_key: pathKey,
|
|
1878
1879
|
_type: assistFieldTypeName,
|
|
1879
|
-
path: pathKey
|
|
1880
|
+
path: pathKey,
|
|
1881
|
+
instructions: []
|
|
1880
1882
|
})], "after", ["fields", -1]));
|
|
1881
1883
|
}
|
|
1884
|
+
if (!((_a = existingField == null ? void 0 : existingField.instructions) == null ? void 0 : _a.length)) {
|
|
1885
|
+
event = event.append([setIfMissing([], ["fields", {
|
|
1886
|
+
_key: pathKey
|
|
1887
|
+
}, "instructions"])]);
|
|
1888
|
+
}
|
|
1882
1889
|
if (missingPresetInstructions == null ? void 0 : missingPresetInstructions.length) {
|
|
1883
1890
|
event = event.append(insert(missingPresetInstructions.map(preset => {
|
|
1884
|
-
var
|
|
1891
|
+
var _a2;
|
|
1885
1892
|
return {
|
|
1886
1893
|
...preset,
|
|
1887
1894
|
_type: "sanity.assist.instruction",
|
|
1888
|
-
prompt: (
|
|
1895
|
+
prompt: (_a2 = preset.prompt) == null ? void 0 : _a2.map(p => ({
|
|
1889
1896
|
markDefs: [],
|
|
1890
1897
|
...p
|
|
1891
1898
|
}))
|
|
@@ -6191,12 +6198,14 @@ function ImageContextProvider(props) {
|
|
|
6191
6198
|
} = useSyncState(publicId(documentId), documentSchemaType.name);
|
|
6192
6199
|
useEffect(() => {
|
|
6193
6200
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
6194
|
-
if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing
|
|
6201
|
+
if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing) {
|
|
6195
6202
|
setAssetRefState(assetRef);
|
|
6196
|
-
|
|
6197
|
-
|
|
6198
|
-
|
|
6199
|
-
|
|
6203
|
+
if (canUseAssist(status)) {
|
|
6204
|
+
generateCaption({
|
|
6205
|
+
path: pathToString([...path, descriptionField]),
|
|
6206
|
+
documentId
|
|
6207
|
+
});
|
|
6208
|
+
}
|
|
6200
6209
|
}
|
|
6201
6210
|
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status]);
|
|
6202
6211
|
const context = useMemo(() => {
|