@sanity/assist 2.0.2 → 2.0.3
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 +7 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/ImageContext.tsx +26 -3
package/dist/index.js
CHANGED
|
@@ -6186,11 +6186,12 @@ function PrivateIcon() {
|
|
|
6186
6186
|
}
|
|
6187
6187
|
const ImageContext = react.createContext({});
|
|
6188
6188
|
function ImageContextProvider(props) {
|
|
6189
|
-
var _a;
|
|
6189
|
+
var _a, _b;
|
|
6190
6190
|
const {
|
|
6191
6191
|
schemaType,
|
|
6192
6192
|
path,
|
|
6193
|
-
value
|
|
6193
|
+
value,
|
|
6194
|
+
readOnly
|
|
6194
6195
|
} = props;
|
|
6195
6196
|
const assetRef = (_a = value == null ? void 0 : value.asset) == null ? void 0 : _a._ref;
|
|
6196
6197
|
const [assetRefState, setAssetRefState] = react.useState(assetRef);
|
|
@@ -6209,9 +6210,11 @@ function ImageContextProvider(props) {
|
|
|
6209
6210
|
const {
|
|
6210
6211
|
isSyncing
|
|
6211
6212
|
} = sanity.useSyncState(publicId(documentId), documentSchemaType.name);
|
|
6213
|
+
const router = desk.usePaneRouter();
|
|
6214
|
+
const isShowingOlderRevision = !!((_b = router.params) == null ? void 0 : _b.rev);
|
|
6212
6215
|
react.useEffect(() => {
|
|
6213
6216
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
6214
|
-
if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing) {
|
|
6217
|
+
if (assetRef && documentId && descriptionField && assetRef !== assetRefState && !isSyncing && !isShowingOlderRevision && !readOnly) {
|
|
6215
6218
|
setAssetRefState(assetRef);
|
|
6216
6219
|
if (canUseAssist(status)) {
|
|
6217
6220
|
generateCaption({
|
|
@@ -6220,7 +6223,7 @@ function ImageContextProvider(props) {
|
|
|
6220
6223
|
});
|
|
6221
6224
|
}
|
|
6222
6225
|
}
|
|
6223
|
-
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status]);
|
|
6226
|
+
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing, status, readOnly, isShowingOlderRevision]);
|
|
6224
6227
|
const context = react.useMemo(() => {
|
|
6225
6228
|
const descriptionField = getDescriptionFieldOption(schemaType);
|
|
6226
6229
|
const imageInstructionField = getImageInstructionFieldOption(schemaType);
|