@sanity/assist 4.1.0 → 4.2.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/README.md +10 -0
- package/dist/index.d.mts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.esm.js +13 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +13 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/ImageContext.tsx +4 -4
- package/src/helpers/typeUtils.ts +13 -3
- package/src/schemas/typeDefExtensions.ts +12 -1
package/dist/index.mjs
CHANGED
|
@@ -221,7 +221,16 @@ function isImage(schemaType) {
|
|
|
221
221
|
return isType(schemaType, "image");
|
|
222
222
|
}
|
|
223
223
|
function getDescriptionFieldOption(schemaType) {
|
|
224
|
-
|
|
224
|
+
if (!schemaType)
|
|
225
|
+
return;
|
|
226
|
+
const descriptionField = schemaType.options?.aiAssist?.imageDescriptionField;
|
|
227
|
+
return typeof descriptionField == "string" ? {
|
|
228
|
+
path: descriptionField,
|
|
229
|
+
updateOnImageChange: !0
|
|
230
|
+
} : descriptionField ? {
|
|
231
|
+
path: descriptionField.path,
|
|
232
|
+
updateOnImageChange: descriptionField.updateOnImageChange ?? !0
|
|
233
|
+
} : getDescriptionFieldOption(schemaType.type);
|
|
225
234
|
}
|
|
226
235
|
function getImageInstructionFieldOption(schemaType) {
|
|
227
236
|
return schemaType ? schemaType.options?.aiAssist?.imageInstructionField || getImageInstructionFieldOption(schemaType.type) : void 0;
|
|
@@ -2574,8 +2583,8 @@ function ImageContextProvider(props) {
|
|
|
2574
2583
|
), isShowingOlderRevision = !!usePaneRouter().params?.rev;
|
|
2575
2584
|
useEffect(() => {
|
|
2576
2585
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
2577
|
-
assetRef && assistableDocumentId && descriptionField && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly && (setAssetRefState(assetRef), canUseAssist(status) && generateCaption({
|
|
2578
|
-
path: pathToString([...path, descriptionField]),
|
|
2586
|
+
assetRef && assistableDocumentId && descriptionField?.updateOnImageChange && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly && (setAssetRefState(assetRef), canUseAssist(status) && generateCaption({
|
|
2587
|
+
path: pathToString([...path, descriptionField.path]),
|
|
2579
2588
|
documentId: assistableDocumentId
|
|
2580
2589
|
}));
|
|
2581
2590
|
}, [
|
|
@@ -2593,7 +2602,7 @@ function ImageContextProvider(props) {
|
|
|
2593
2602
|
const context = useMemo(() => {
|
|
2594
2603
|
const descriptionField = getDescriptionFieldOption(schemaType), imageInstructionField = getImageInstructionFieldOption(schemaType);
|
|
2595
2604
|
return {
|
|
2596
|
-
imageDescriptionPath: descriptionField ? pathToString([...path, descriptionField]) : void 0,
|
|
2605
|
+
imageDescriptionPath: descriptionField?.path ? pathToString([...path, descriptionField.path]) : void 0,
|
|
2597
2606
|
imageInstructionPath: imageInstructionField ? pathToString([...path, imageInstructionField]) : void 0,
|
|
2598
2607
|
assetRef
|
|
2599
2608
|
};
|