@sanity/assist 1.2.11 → 1.2.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/assist",
3
- "version": "1.2.11",
3
+ "version": "1.2.13",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "sanity",
@@ -85,7 +85,7 @@
85
85
  "react": "^18.2.0",
86
86
  "react-dom": "^18.2.0",
87
87
  "rimraf": "^4.4.0",
88
- "sanity": "^3.17.0",
88
+ "sanity": "^3.19.1",
89
89
  "semantic-release": "^21.1.2",
90
90
  "styled-components": "^5.3.11",
91
91
  "typescript": "^5.2.2",
@@ -1,5 +1,4 @@
1
1
  import {BlockProps} from 'sanity'
2
- import {Box} from '@sanity/ui'
3
2
  import {createContext} from 'react'
4
3
 
5
4
  // workaround for preview value sometimes lagging behind
@@ -8,7 +7,7 @@ export const InlineBlockValueContext = createContext<unknown>(undefined)
8
7
  export function AssistInlineFormBlock(props: BlockProps) {
9
8
  return (
10
9
  <InlineBlockValueContext.Provider value={props.value}>
11
- <Box flex={1}>{props.renderDefault(props)}</Box>
10
+ <>{props.renderDefault(props)}</>
12
11
  </InlineBlockValueContext.Provider>
13
12
  )
14
13
  }
@@ -1,3 +1,4 @@
1
+ /* eslint-disable camelcase */
1
2
  import {
2
3
  assistDocumentSchema,
3
4
  documentInstructionStatus,
@@ -10,16 +11,54 @@ import {
10
11
  userInput,
11
12
  } from './assistDocumentSchema'
12
13
  import {contextDocumentSchema} from './contextDocumentSchema'
14
+ import {FieldProps, SchemaTypeDefinition, ArrayOfType} from 'sanity'
13
15
 
14
- export const schemaTypes = [
16
+ function excludeComments<T extends SchemaTypeDefinition | ArrayOfType>(type: T): T {
17
+ const existingRender = (type as any)?.components?.field
18
+ return {
19
+ ...type,
20
+ ...('components' in type
21
+ ? {
22
+ components: {
23
+ ...type.components,
24
+ field: (props: FieldProps) => {
25
+ const newProps = {...props, ...{__internal_comments: undefined}}
26
+ if (typeof existingRender === 'function') {
27
+ return existingRender(newProps)
28
+ }
29
+ return props.renderDefault(newProps)
30
+ },
31
+ },
32
+ }
33
+ : {}),
34
+ ...('fields' in type
35
+ ? {
36
+ // recursively disable comments in fields
37
+ fields: type.fields?.map((field) => excludeComments(field)),
38
+ }
39
+ : {}),
40
+ ...('of' in type
41
+ ? {
42
+ // recursively disable comments in array items
43
+ of: type.of?.map((arrayItemType) => excludeComments(arrayItemType)),
44
+ }
45
+ : {}),
46
+ }
47
+ }
48
+
49
+ const instructionForm = [
15
50
  fieldInstructions,
16
- assistDocumentSchema,
17
- prompt,
18
- fieldReference,
19
51
  instruction,
52
+ fieldReference,
53
+ prompt,
54
+ userInput,
55
+ promptContext,
56
+ ].map(excludeComments)
57
+
58
+ export const schemaTypes = [
59
+ ...instructionForm,
60
+ assistDocumentSchema,
20
61
  documentInstructionStatus,
21
62
  instructionTask,
22
63
  contextDocumentSchema,
23
- userInput,
24
- promptContext,
25
64
  ]