@sanity/assist 2.0.2 → 2.0.4-canary.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/index.esm.js +30 -21
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +30 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ImageContext.tsx +26 -3
- package/src/schemas/assistDocumentSchema.tsx +28 -24
- package/src/schemas/index.ts +4 -0
package/dist/index.js
CHANGED
|
@@ -5813,6 +5813,26 @@ const prompt = sanity.defineType({
|
|
|
5813
5813
|
type: userInput.name,
|
|
5814
5814
|
}),*/]
|
|
5815
5815
|
});
|
|
5816
|
+
const outputFieldType = sanity.defineType({
|
|
5817
|
+
type: "object",
|
|
5818
|
+
name: outputFieldTypeName,
|
|
5819
|
+
title: "Output field",
|
|
5820
|
+
fields: [sanity.defineField({
|
|
5821
|
+
type: "string",
|
|
5822
|
+
name: "path",
|
|
5823
|
+
title: "Path"
|
|
5824
|
+
})]
|
|
5825
|
+
});
|
|
5826
|
+
const outputTypeType = sanity.defineType({
|
|
5827
|
+
type: "object",
|
|
5828
|
+
name: outputTypeTypeName,
|
|
5829
|
+
title: "Output type",
|
|
5830
|
+
fields: [sanity.defineField({
|
|
5831
|
+
type: "string",
|
|
5832
|
+
name: "type",
|
|
5833
|
+
title: "Type"
|
|
5834
|
+
})]
|
|
5835
|
+
});
|
|
5816
5836
|
const instruction = sanity.defineType({
|
|
5817
5837
|
type: "object",
|
|
5818
5838
|
name: instructionTypeName,
|
|
@@ -5950,23 +5970,9 @@ const instruction = sanity.defineType({
|
|
|
5950
5970
|
field: InstructionOutputField
|
|
5951
5971
|
},
|
|
5952
5972
|
of: [sanity.defineArrayMember({
|
|
5953
|
-
type:
|
|
5954
|
-
name: outputFieldTypeName,
|
|
5955
|
-
title: "Output field",
|
|
5956
|
-
fields: [{
|
|
5957
|
-
type: "string",
|
|
5958
|
-
name: "path",
|
|
5959
|
-
title: "Path"
|
|
5960
|
-
}]
|
|
5973
|
+
type: outputFieldType.name
|
|
5961
5974
|
}), sanity.defineArrayMember({
|
|
5962
|
-
type:
|
|
5963
|
-
name: outputTypeTypeName,
|
|
5964
|
-
title: "Output type",
|
|
5965
|
-
fields: [{
|
|
5966
|
-
type: "string",
|
|
5967
|
-
name: "type",
|
|
5968
|
-
title: "Type"
|
|
5969
|
-
}]
|
|
5975
|
+
type: outputTypeType.name
|
|
5970
5976
|
})]
|
|
5971
5977
|
})]
|
|
5972
5978
|
});
|
|
@@ -6114,7 +6120,7 @@ function excludeComments(type) {
|
|
|
6114
6120
|
};
|
|
6115
6121
|
}
|
|
6116
6122
|
const instructionForm = [fieldInstructions, instruction, fieldReference, prompt, userInput, promptContext].map(excludeComments);
|
|
6117
|
-
const schemaTypes = [...instructionForm, assistDocumentSchema, documentInstructionStatus, instructionTask, contextDocumentSchema];
|
|
6123
|
+
const schemaTypes = [...instructionForm, outputFieldType, outputTypeType, assistDocumentSchema, documentInstructionStatus, instructionTask, contextDocumentSchema];
|
|
6118
6124
|
function useAssistSupported(path, schemaType) {
|
|
6119
6125
|
return react.useMemo(() => isAssistSupported(schemaType), [schemaType]);
|
|
6120
6126
|
}
|
|
@@ -6186,11 +6192,12 @@ function PrivateIcon() {
|
|
|
6186
6192
|
}
|
|
6187
6193
|
const ImageContext = react.createContext({});
|
|
6188
6194
|
function ImageContextProvider(props) {
|
|
6189
|
-
var _a;
|
|
6195
|
+
var _a, _b;
|
|
6190
6196
|
const {
|
|
6191
6197
|
schemaType,
|
|
6192
6198
|
path,
|
|
6193
|
-
value
|
|
6199
|
+
value,
|
|
6200
|
+
readOnly
|
|
6194
6201
|
} = props;
|
|
6195
6202
|
const assetRef = (_a = value == null ? void 0 : value.asset) == null ? void 0 : _a._ref;
|
|
6196
6203
|
const [assetRefState, setAssetRefState] = react.useState(assetRef);
|
|
@@ -6209,9 +6216,11 @@ function ImageContextProvider(props) {
|
|
|
6209
6216
|
const {
|
|
6210
6217
|
isSyncing
|
|
6211
6218
|
} = sanity.useSyncState(publicId(documentId), documentSchemaType.name);
|
|
6219
|
+
const router = desk.usePaneRouter();
|
|
6220
|
+
const isShowingOlderRevision = !!((_b = router.params) == null ? void 0 : _b.rev);
|
|
6212
6221
|
react.useEffect(() => {
|
|
6213
6222
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
6214
|
-
if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing) {
|
|
6223
|
+
if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly) {
|
|
6215
6224
|
setAssetRefState(assetRef);
|
|
6216
6225
|
if (canUseAssist(status)) {
|
|
6217
6226
|
generateCaption({
|
|
@@ -6220,7 +6229,7 @@ function ImageContextProvider(props) {
|
|
|
6220
6229
|
});
|
|
6221
6230
|
}
|
|
6222
6231
|
}
|
|
6223
|
-
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status]);
|
|
6232
|
+
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status, readOnly, isShowingOlderRevision]);
|
|
6224
6233
|
const context = react.useMemo(() => {
|
|
6225
6234
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
6226
6235
|
const imageInstructionField = getImageInstructionFieldOption(schemaType);
|