@sanity/assist 1.2.10 → 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';
@@ -4298,7 +4298,8 @@ function ImageContextProvider(props) {
4298
4298
  const assetRef = (_a = value == null ? void 0 : value.asset) == null ? void 0 : _a._ref;
4299
4299
  const [assetRefState, setAssetRefState] = useState(assetRef);
4300
4300
  const {
4301
- documentId
4301
+ documentId,
4302
+ documentSchemaType
4302
4303
  } = useAssistDocumentContext();
4303
4304
  const {
4304
4305
  config
@@ -4307,16 +4308,19 @@ function ImageContextProvider(props) {
4307
4308
  const {
4308
4309
  generateCaption
4309
4310
  } = useGenerateCaption(apiClient);
4311
+ const {
4312
+ isSyncing
4313
+ } = useSyncState(publicId(documentId), documentSchemaType.name);
4310
4314
  useEffect(() => {
4311
4315
  const captionField = getCaptionFieldOption(schemaType);
4312
- if (assetRef && documentId && captionField && assetRef !== assetRefState) {
4316
+ if (assetRef && documentId && captionField && assetRef !== assetRefState && !isSyncing) {
4313
4317
  setAssetRefState(assetRef);
4314
4318
  generateCaption({
4315
4319
  path: pathToString([...path, captionField]),
4316
4320
  documentId
4317
4321
  });
4318
4322
  }
4319
- }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption]);
4323
+ }, [schemaType, path, assetRef, assetRefState, documentId, generateCaption, isSyncing]);
4320
4324
  const context = useMemo(() => {
4321
4325
  const captionField = getCaptionFieldOption(schemaType);
4322
4326
  return captionField ? {