@sanity/assist 1.2.9 → 1.2.11
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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { useClient, typed, useSchema, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, pathToString, isObjectSchemaType, stringToPath, isKeySegment, useEditState, useCurrentUser, useValidationStatus, StatusButton, FormFieldHeaderText, PatchEvent, unset, set, useFormCallbacks, FormCallbacksProvider, FormInput, setIfMissing, insert, PresenceOverlay, VirtualizerScrollInstanceProvider, useColorSchemeValue, isArraySchemaType, ObjectInputMember, defineType, defineField, defineArrayMember, getPublishedId, definePlugin } from 'sanity';
|
|
2
|
+
import { useClient, typed, useSchema, useDocumentStore, useDocumentPresence, createPatchChannel, FormBuilder, fromMutationPatches, pathToString, isObjectSchemaType, stringToPath, isKeySegment, useEditState, useCurrentUser, useValidationStatus, StatusButton, FormFieldHeaderText, PatchEvent, unset, set, useFormCallbacks, FormCallbacksProvider, FormInput, setIfMissing, insert, PresenceOverlay, VirtualizerScrollInstanceProvider, useColorSchemeValue, isArraySchemaType, ObjectInputMember, defineType, defineField, defineArrayMember, getPublishedId, useSyncState, definePlugin } from 'sanity';
|
|
3
3
|
import { Card, Stack, Box, Button, Spinner, Flex, Label, focusFirstDescendant, Text, useClickOutside, Popover, useLayer, useGlobalKeyDown, useToast, Dialog, Tooltip, TextArea, Container, Autocomplete, Breadcrumbs, Badge, useTheme, rgba, ThemeProvider, ErrorBoundary, Switch, MenuButton, Menu, MenuItem } from '@sanity/ui';
|
|
4
4
|
import { useState, useRef, useEffect, useMemo, useCallback, createContext, useReducer, forwardRef, createElement, useContext, useId } from 'react';
|
|
5
5
|
import { SyncIcon, DocumentIcon, LinkIcon, ImageIcon, BlockContentIcon, OlistIcon, BlockquoteIcon, StringIcon, ErrorOutlineIcon, CheckmarkCircleIcon, CloseCircleIcon, ClockIcon, PlayIcon, SparklesIcon, ArrowLeftIcon, SearchIcon, RetryIcon, ArrowRightIcon, CloseIcon, CheckmarkIcon, icons, TokenIcon, DocumentTextIcon, ThListIcon, CodeIcon, ComposeIcon, LockIcon, ControlsIcon } from '@sanity/icons';
|
|
@@ -3574,9 +3574,13 @@ function FieldRefPathInput(props) {
|
|
|
3574
3574
|
if (!field.key.includes("|") || !typePath) {
|
|
3575
3575
|
return true;
|
|
3576
3576
|
}
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3577
|
+
if (field.key.includes("|") && !typePath.includes("|")) {
|
|
3578
|
+
return false;
|
|
3579
|
+
}
|
|
3580
|
+
const fieldSegments = field.key.split(".");
|
|
3581
|
+
const lastArrayItemIndex = fieldSegments.findLastIndex(s => s.includes("|"));
|
|
3582
|
+
const mustStartWith = fieldSegments.slice(0, lastArrayItemIndex + 1).join(".");
|
|
3583
|
+
return typePath.startsWith(mustStartWith);
|
|
3580
3584
|
}, [typePath]);
|
|
3581
3585
|
if (!documentSchema) {
|
|
3582
3586
|
return props.renderDefault(props);
|
|
@@ -4294,7 +4298,8 @@ function ImageContextProvider(props) {
|
|
|
4294
4298
|
const assetRef = (_a = value == null ? void 0 : value.asset) == null ? void 0 : _a._ref;
|
|
4295
4299
|
const [assetRefState, setAssetRefState] = useState(assetRef);
|
|
4296
4300
|
const {
|
|
4297
|
-
documentId
|
|
4301
|
+
documentId,
|
|
4302
|
+
documentSchemaType
|
|
4298
4303
|
} = useAssistDocumentContext();
|
|
4299
4304
|
const {
|
|
4300
4305
|
config
|
|
@@ -4303,16 +4308,19 @@ function ImageContextProvider(props) {
|
|
|
4303
4308
|
const {
|
|
4304
4309
|
generateCaption
|
|
4305
4310
|
} = useGenerateCaption(apiClient);
|
|
4311
|
+
const {
|
|
4312
|
+
isSyncing
|
|
4313
|
+
} = useSyncState(publicId(documentId), documentSchemaType.name);
|
|
4306
4314
|
useEffect(() => {
|
|
4307
4315
|
const captionField = getCaptionFieldOption(schemaType);
|
|
4308
|
-
if (assetRef && documentId && captionField && assetRef !== assetRefState) {
|
|
4316
|
+
if (assetRef && documentId && captionField && assetRef !== assetRefState && !isSyncing) {
|
|
4309
4317
|
setAssetRefState(assetRef);
|
|
4310
4318
|
generateCaption({
|
|
4311
4319
|
path: pathToString([...path, captionField]),
|
|
4312
4320
|
documentId
|
|
4313
4321
|
});
|
|
4314
4322
|
}
|
|
4315
|
-
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption]);
|
|
4323
|
+
}, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing]);
|
|
4316
4324
|
const context = useMemo(() => {
|
|
4317
4325
|
const captionField = getCaptionFieldOption(schemaType);
|
|
4318
4326
|
return captionField ? {
|