@sanity/code-input 6.0.0 → 6.0.2
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/README.md +1 -9
- package/lib/_chunks-cjs/CodeMirrorProxy.cjs +2 -2
- package/lib/_chunks-cjs/CodeMirrorProxy.cjs.map +1 -1
- package/lib/_chunks-cjs/index.cjs +19 -23
- package/lib/_chunks-cjs/index.cjs.map +1 -1
- package/lib/_chunks-es/CodeMirrorProxy.js +2 -2
- package/lib/_chunks-es/CodeMirrorProxy.js.map +1 -1
- package/lib/_chunks-es/index.js +17 -17
- package/lib/_chunks-es/index.js.map +1 -1
- package/lib/index.d.cts +5 -5
- package/lib/index.d.ts +5 -5
- package/package.json +41 -41
- package/src/CodeInput.tsx +21 -14
- package/src/LanguageField.tsx +1 -1
- package/src/LanguageInput.tsx +1 -1
- package/src/PreviewCode.tsx +7 -7
- package/src/codemirror/CodeMirrorProxy.tsx +2 -0
- package/src/codemirror/extensions/highlightLineExtension.ts +3 -4
- package/src/codemirror/extensions/useFontSize.ts +1 -1
- package/src/codemirror/useCodeMirror-client.test.tsx +5 -6
- package/src/codemirror/useCodeMirror-server.test.tsx +3 -3
- package/src/codemirror/useCodeMirror.tsx +4 -5
- package/src/config.ts +1 -1
- package/src/index.ts +1 -1
- package/src/plugin.tsx +1 -1
- package/src/sanity-ui.d.ts +0 -1
- package/src/schema.tsx +3 -3
- package/src/types.ts +1 -1
- package/src/useFieldMember.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/code-input",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "Sanity input component for code, powered by CodeMirror",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"author": "Sanity.io <hello@sanity.io>",
|
|
25
|
+
"sideEffects": false,
|
|
25
26
|
"type": "module",
|
|
26
27
|
"exports": {
|
|
27
28
|
".": {
|
|
@@ -41,21 +42,8 @@
|
|
|
41
42
|
"src",
|
|
42
43
|
"v2-incompatible.js"
|
|
43
44
|
],
|
|
44
|
-
"sideEffects": false,
|
|
45
45
|
"browserslist": "extends @sanity/browserslist-config",
|
|
46
|
-
"
|
|
47
|
-
"build": "plugin-kit verify-package --silent && pkg-utils build --strict --check --clean",
|
|
48
|
-
"clean": "rimraf lib",
|
|
49
|
-
"compile": "tsc --noEmit",
|
|
50
|
-
"dev": "sanity dev",
|
|
51
|
-
"format": "prettier --write --cache --ignore-unknown .",
|
|
52
|
-
"link-watch": "plugin-kit link-watch",
|
|
53
|
-
"lint": "eslint .",
|
|
54
|
-
"prepare": "husky install",
|
|
55
|
-
"prepublishOnly": "npm run build",
|
|
56
|
-
"test": "jest",
|
|
57
|
-
"watch": "pkg-utils watch --strict"
|
|
58
|
-
},
|
|
46
|
+
"prettier": "@sanity/prettier-config",
|
|
59
47
|
"dependencies": {
|
|
60
48
|
"@codemirror/autocomplete": "^6.18.3",
|
|
61
49
|
"@codemirror/commands": "^6.7.1",
|
|
@@ -83,40 +71,40 @@
|
|
|
83
71
|
"@babel/core": "^7.23.6",
|
|
84
72
|
"@babel/preset-env": "^7.23.6",
|
|
85
73
|
"@babel/preset-react": "^7.23.3",
|
|
86
|
-
"@
|
|
87
|
-
"@
|
|
88
|
-
"@
|
|
74
|
+
"@changesets/changelog-github": "^0.5.1",
|
|
75
|
+
"@changesets/cli": "^2.29.7",
|
|
76
|
+
"@eslint/js": "^9.37.0",
|
|
77
|
+
"@sanity/browserslist-config": "^1.0.5",
|
|
78
|
+
"@sanity/pkg-utils": "^8.1.21",
|
|
89
79
|
"@sanity/plugin-kit": "^4.0.19",
|
|
90
|
-
"@sanity/
|
|
80
|
+
"@sanity/prettier-config": "^2.0.1",
|
|
81
|
+
"@sanity/vision": "^4.10.3",
|
|
91
82
|
"@testing-library/jest-dom": "^6.1.5",
|
|
92
83
|
"@testing-library/react": "^14.1.2",
|
|
93
84
|
"@types/jest": "^29.5.11",
|
|
94
85
|
"@types/react": "^18.2.45",
|
|
95
|
-
"@types/
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"eslint": "^
|
|
99
|
-
"eslint-
|
|
100
|
-
"eslint-
|
|
101
|
-
"eslint-plugin-
|
|
102
|
-
"
|
|
103
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
86
|
+
"@types/react-dom": "^18.2.0",
|
|
87
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
88
|
+
"eslint": "^9.37.0",
|
|
89
|
+
"eslint-config-prettier": "^10.1.8",
|
|
90
|
+
"eslint-formatter-gha": "^1.6.0",
|
|
91
|
+
"eslint-plugin-react": "^7.37.5",
|
|
92
|
+
"eslint-plugin-react-hooks": "^7.0.0",
|
|
93
|
+
"globals": "^16.4.0",
|
|
104
94
|
"husky": "^8.0.1",
|
|
105
95
|
"jest": "^29.7.0",
|
|
106
96
|
"jest-environment-jsdom": "^29.7.0",
|
|
107
97
|
"lint-staged": "^15.2.0",
|
|
108
98
|
"npm-run-all": "^4.1.5",
|
|
109
|
-
"prettier": "^3.
|
|
110
|
-
"
|
|
111
|
-
"react": "^
|
|
112
|
-
"react-dom": "^18.2.0",
|
|
113
|
-
"react-is": "^18.2.0",
|
|
99
|
+
"prettier": "^3.6.2",
|
|
100
|
+
"react": "^19.2.0",
|
|
101
|
+
"react-dom": "^19.2.0",
|
|
114
102
|
"rimraf": "^5.0.5",
|
|
115
|
-
"sanity": "^4.3
|
|
116
|
-
"semantic-release": "^24.2.0",
|
|
103
|
+
"sanity": "^4.10.3",
|
|
117
104
|
"styled-components": "^6.1.19",
|
|
118
105
|
"ts-jest": "^29.1.1",
|
|
119
|
-
"typescript": "5.9.2"
|
|
106
|
+
"typescript": "5.9.2",
|
|
107
|
+
"typescript-eslint": "^8.46.1"
|
|
120
108
|
},
|
|
121
109
|
"peerDependencies": {
|
|
122
110
|
"react": "^18 || >=19.0.0-0",
|
|
@@ -125,16 +113,28 @@
|
|
|
125
113
|
"styled-components": "^5.2 || ^6"
|
|
126
114
|
},
|
|
127
115
|
"engines": {
|
|
128
|
-
"node": ">=20.19 >=22.12
|
|
116
|
+
"node": ">=20.19 <22 || >=22.12"
|
|
129
117
|
},
|
|
130
118
|
"sanityExchangeUrl": "https://www.sanity.io/plugins/code-input",
|
|
131
119
|
"sanityPlugin": {
|
|
132
120
|
"verifyPackage": {
|
|
133
121
|
"babelConfig": false,
|
|
134
|
-
"
|
|
122
|
+
"tsconfig": false,
|
|
123
|
+
"tsc": false,
|
|
124
|
+
"nodeEngine": false,
|
|
125
|
+
"eslintImports": false
|
|
135
126
|
}
|
|
136
127
|
},
|
|
137
|
-
"
|
|
138
|
-
"
|
|
128
|
+
"scripts": {
|
|
129
|
+
"build": "plugin-kit verify-package --silent && pkg-utils build --strict --check --clean",
|
|
130
|
+
"clean": "rimraf lib",
|
|
131
|
+
"dev": "sanity dev",
|
|
132
|
+
"format": "prettier --write .",
|
|
133
|
+
"link-watch": "plugin-kit link-watch",
|
|
134
|
+
"lint": "eslint .",
|
|
135
|
+
"release": "changeset publish",
|
|
136
|
+
"test": "jest",
|
|
137
|
+
"type-check": "tsc --noEmit",
|
|
138
|
+
"watch": "pkg-utils watch --strict"
|
|
139
139
|
}
|
|
140
|
-
}
|
|
140
|
+
}
|
package/src/CodeInput.tsx
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import {Box, Card, Stack, Text} from '@sanity/ui'
|
|
2
2
|
import {Suspense, useCallback} from 'react'
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import {
|
|
4
|
+
MemberField,
|
|
5
|
+
type ObjectInputProps,
|
|
6
|
+
type RenderInputCallback,
|
|
7
|
+
set,
|
|
8
|
+
setIfMissing,
|
|
9
|
+
unset,
|
|
10
|
+
} from 'sanity'
|
|
11
|
+
import {css, styled} from 'styled-components'
|
|
12
|
+
|
|
13
|
+
import {CodeMirrorProxy, useMounted} from './codemirror/useCodeMirror'
|
|
7
14
|
import {useLanguageMode} from './codemirror/useLanguageMode'
|
|
8
15
|
import {PATH_CODE} from './config'
|
|
9
16
|
import {LanguageField} from './LanguageField'
|
|
10
|
-
import {CodeInputValue, CodeSchemaType} from './types'
|
|
17
|
+
import type {CodeInputValue, CodeSchemaType} from './types'
|
|
11
18
|
import {focusRingBorderStyle, focusRingStyle} from './ui/focusRingStyle'
|
|
12
19
|
import {useFieldMember} from './useFieldMember'
|
|
13
20
|
|
|
@@ -53,7 +60,7 @@ const EditorContainer = styled(Card)(({theme}) => {
|
|
|
53
60
|
})
|
|
54
61
|
|
|
55
62
|
/** @public */
|
|
56
|
-
export function CodeInput(props: CodeInputProps) {
|
|
63
|
+
export function CodeInput(props: CodeInputProps): React.JSX.Element {
|
|
57
64
|
const {
|
|
58
65
|
members,
|
|
59
66
|
elementProps,
|
|
@@ -95,13 +102,13 @@ export function CodeInput(props: CodeInputProps) {
|
|
|
95
102
|
)
|
|
96
103
|
const {languages, language, languageMode} = useLanguageMode(props.schemaType, props.value)
|
|
97
104
|
|
|
98
|
-
const
|
|
105
|
+
const mounted = useMounted()
|
|
99
106
|
|
|
100
107
|
const renderCodeInput: RenderInputCallback = useCallback(
|
|
101
108
|
(inputProps) => {
|
|
102
109
|
return (
|
|
103
110
|
<EditorContainer border overflow="hidden" radius={1} sizing="border" readOnly={readOnly}>
|
|
104
|
-
{
|
|
111
|
+
{mounted && (
|
|
105
112
|
<Suspense
|
|
106
113
|
fallback={
|
|
107
114
|
<Box padding={3}>
|
|
@@ -109,7 +116,7 @@ export function CodeInput(props: CodeInputProps) {
|
|
|
109
116
|
</Box>
|
|
110
117
|
}
|
|
111
118
|
>
|
|
112
|
-
<
|
|
119
|
+
<CodeMirrorProxy
|
|
113
120
|
languageMode={languageMode}
|
|
114
121
|
onChange={handleCodeChange}
|
|
115
122
|
value={inputProps.value as string}
|
|
@@ -125,14 +132,14 @@ export function CodeInput(props: CodeInputProps) {
|
|
|
125
132
|
)
|
|
126
133
|
},
|
|
127
134
|
[
|
|
128
|
-
|
|
135
|
+
readOnly,
|
|
136
|
+
mounted,
|
|
137
|
+
languageMode,
|
|
129
138
|
handleCodeChange,
|
|
130
|
-
|
|
139
|
+
value?.highlightedLines,
|
|
131
140
|
onHighlightChange,
|
|
132
|
-
|
|
141
|
+
handleCodeFocus,
|
|
133
142
|
elementProps.onBlur,
|
|
134
|
-
readOnly,
|
|
135
|
-
value,
|
|
136
143
|
],
|
|
137
144
|
)
|
|
138
145
|
|
package/src/LanguageField.tsx
CHANGED
package/src/LanguageInput.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import {Select} from '@sanity/ui'
|
|
|
2
2
|
import {type ChangeEvent, useCallback} from 'react'
|
|
3
3
|
import {set, type StringInputProps, unset} from 'sanity'
|
|
4
4
|
|
|
5
|
-
import {CodeInputLanguage} from './types'
|
|
5
|
+
import type {CodeInputLanguage} from './types'
|
|
6
6
|
|
|
7
7
|
export interface LanguageInputProps {
|
|
8
8
|
language: string
|
package/src/PreviewCode.tsx
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {Box, Card, Flex, Label, Text} from '@sanity/ui'
|
|
2
2
|
import {Suspense} from 'react'
|
|
3
|
-
import {PreviewProps} from 'sanity'
|
|
4
|
-
import styled from 'styled-components'
|
|
3
|
+
import type {PreviewProps} from 'sanity'
|
|
4
|
+
import {styled} from 'styled-components'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {CodeMirrorProxy, useMounted} from './codemirror/useCodeMirror'
|
|
7
7
|
import {useLanguageMode} from './codemirror/useLanguageMode'
|
|
8
|
-
import {CodeInputValue, CodeSchemaType} from './types'
|
|
8
|
+
import type {CodeInputValue, CodeSchemaType} from './types'
|
|
9
9
|
|
|
10
10
|
const PreviewContainer = styled(Box)`
|
|
11
11
|
position: relative;
|
|
@@ -25,7 +25,7 @@ export function PreviewCode(props: PreviewCodeProps) {
|
|
|
25
25
|
const {selection, schemaType: type} = props
|
|
26
26
|
const {languageMode} = useLanguageMode(type as CodeSchemaType, props.selection)
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const mounted = useMounted()
|
|
29
29
|
return (
|
|
30
30
|
<PreviewContainer>
|
|
31
31
|
<Card padding={4}>
|
|
@@ -47,9 +47,9 @@ export function PreviewCode(props: PreviewCodeProps) {
|
|
|
47
47
|
</Flex>
|
|
48
48
|
</Card>
|
|
49
49
|
) : null}
|
|
50
|
-
{
|
|
50
|
+
{mounted && (
|
|
51
51
|
<Suspense fallback={<Card padding={2}>Loading code preview...</Card>}>
|
|
52
|
-
<
|
|
52
|
+
<CodeMirrorProxy
|
|
53
53
|
readOnly
|
|
54
54
|
editable={false}
|
|
55
55
|
value={selection?.code || ''}
|
|
@@ -129,6 +129,7 @@ function useLanguageExtension(mode?: string) {
|
|
|
129
129
|
|
|
130
130
|
const codeMode = modes.find((m) => m.name === mode)
|
|
131
131
|
if (!codeMode?.loader) {
|
|
132
|
+
// eslint-disable-next-line no-console
|
|
132
133
|
console.warn(
|
|
133
134
|
`Found no codeMode for language mode ${mode}, syntax highlighting will be disabled.`,
|
|
134
135
|
)
|
|
@@ -141,6 +142,7 @@ function useLanguageExtension(mode?: string) {
|
|
|
141
142
|
}
|
|
142
143
|
})
|
|
143
144
|
.catch((e) => {
|
|
145
|
+
// eslint-disable-next-line no-console
|
|
144
146
|
console.error(`Failed to load language mode ${mode}`, e)
|
|
145
147
|
if (active) {
|
|
146
148
|
setLanguageExtension(undefined)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable no-param-reassign */
|
|
2
|
-
|
|
3
1
|
import {type Extension, StateEffect, StateField} from '@codemirror/state'
|
|
4
2
|
import {Decoration, type DecorationSet, EditorView, lineNumbers} from '@codemirror/view'
|
|
5
3
|
import type {ThemeContextValue} from '@sanity/ui'
|
|
@@ -56,6 +54,7 @@ export const lineHighlightField = StateField.define({
|
|
|
56
54
|
add: highlights,
|
|
57
55
|
})
|
|
58
56
|
} catch (e) {
|
|
57
|
+
// eslint-disable-next-line no-console
|
|
59
58
|
console.error(e)
|
|
60
59
|
return Decoration.none
|
|
61
60
|
}
|
|
@@ -130,7 +129,7 @@ export const highlightLine = (config: HighlightLineConfig): Extension => {
|
|
|
130
129
|
let isHighlighted = false
|
|
131
130
|
editorView.state
|
|
132
131
|
.field(lineHighlightField)
|
|
133
|
-
.between(line.from, line.to, (
|
|
132
|
+
.between(line.from, line.to, (_from, _to, value) => {
|
|
134
133
|
if (value) {
|
|
135
134
|
isHighlighted = true
|
|
136
135
|
return false // stop iteration
|
|
@@ -163,7 +162,7 @@ export function setHighlightedLines(view: EditorView, highlightLines: number[]):
|
|
|
163
162
|
const doc = view.state.doc
|
|
164
163
|
const lines = doc.lines
|
|
165
164
|
//1-based line numbers
|
|
166
|
-
const allLineNumbers = Array.from({length: lines}, (
|
|
165
|
+
const allLineNumbers = Array.from({length: lines}, (_x, i) => i + 1)
|
|
167
166
|
view.dispatch({
|
|
168
167
|
effects: allLineNumbers.map((lineNumber) => {
|
|
169
168
|
const line = doc.line(lineNumber)
|
|
@@ -9,7 +9,7 @@ export function useFontSizeExtension(props: {fontSize: number}): Extension {
|
|
|
9
9
|
|
|
10
10
|
return useMemo(() => {
|
|
11
11
|
const {code: codeFont} = theme.sanity.fonts
|
|
12
|
-
const {fontSize, lineHeight} = codeFont.sizes[fontSizeProp] || codeFont.sizes[2]
|
|
12
|
+
const {fontSize, lineHeight} = codeFont.sizes[fontSizeProp] || codeFont.sizes[2]!
|
|
13
13
|
|
|
14
14
|
return EditorView.baseTheme({
|
|
15
15
|
'&': {
|
|
@@ -4,7 +4,7 @@ import {studioTheme, ThemeProvider} from '@sanity/ui'
|
|
|
4
4
|
import {act, render} from '@testing-library/react'
|
|
5
5
|
import {Suspense} from 'react'
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {CodeMirrorProxy, useMounted} from './useCodeMirror'
|
|
8
8
|
|
|
9
9
|
describe('useCodeMirror - client', () => {
|
|
10
10
|
let rafMock: jest.SpyInstance<number, [FrameRequestCallback]>
|
|
@@ -14,9 +14,8 @@ describe('useCodeMirror - client', () => {
|
|
|
14
14
|
.spyOn(window, 'requestAnimationFrame')
|
|
15
15
|
.mockImplementation((callback: FrameRequestCallback): number => {
|
|
16
16
|
try {
|
|
17
|
-
// eslint-disable-next-line callback-return
|
|
18
17
|
callback(0)
|
|
19
|
-
} catch
|
|
18
|
+
} catch {
|
|
20
19
|
// CodeMirror does some mesurement shenanigance that json dont support
|
|
21
20
|
// we just let it crash silently
|
|
22
21
|
}
|
|
@@ -30,12 +29,12 @@ describe('useCodeMirror - client', () => {
|
|
|
30
29
|
|
|
31
30
|
it('should render suspended codemirror editor', async () => {
|
|
32
31
|
const TestComponent = () => {
|
|
33
|
-
const
|
|
32
|
+
const mounted = useMounted()
|
|
34
33
|
return (
|
|
35
34
|
<Suspense fallback={'loading'}>
|
|
36
|
-
{
|
|
35
|
+
{mounted && (
|
|
37
36
|
<ThemeProvider theme={studioTheme}>
|
|
38
|
-
<
|
|
37
|
+
<CodeMirrorProxy languageMode={'tsx'} />
|
|
39
38
|
</ThemeProvider>
|
|
40
39
|
)}
|
|
41
40
|
</Suspense>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {renderToString} from 'react-dom/server'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {useMounted} from './useCodeMirror'
|
|
4
4
|
|
|
5
5
|
describe('useCodeMirror - server', () => {
|
|
6
6
|
it('should render null to string (and not throw and Error)', () => {
|
|
7
7
|
const TestComponent = () => {
|
|
8
|
-
const
|
|
9
|
-
if (!
|
|
8
|
+
const mounted = useMounted()
|
|
9
|
+
if (!mounted) {
|
|
10
10
|
return null
|
|
11
11
|
}
|
|
12
12
|
throw new Error('editor should always be null in envs without window')
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {lazy, useEffect, useState} from 'react'
|
|
1
|
+
import {lazy, startTransition, useEffect, useState} from 'react'
|
|
2
2
|
|
|
3
3
|
export const CodeMirrorProxy = lazy(() => import('./CodeMirrorProxy'))
|
|
4
4
|
|
|
5
|
-
export function
|
|
5
|
+
export function useMounted() {
|
|
6
6
|
const [mounted, setMounted] = useState(false)
|
|
7
7
|
useEffect(() => {
|
|
8
|
-
requestAnimationFrame(() => setMounted(true))
|
|
8
|
+
requestAnimationFrame(() => startTransition(() => setMounted(true)))
|
|
9
9
|
}, [])
|
|
10
|
-
|
|
11
|
-
return mounted ? CodeMirrorProxy : null
|
|
10
|
+
return mounted
|
|
12
11
|
}
|
package/src/config.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {CodeDefinition, codeSchema, codeTypeName} from './schema'
|
|
1
|
+
import {type CodeDefinition, codeSchema, codeTypeName} from './schema'
|
|
2
2
|
export {type CodeInput, type CodeInputProps} from './CodeInput'
|
|
3
3
|
export {PreviewCode, type PreviewCodeProps} from './PreviewCode'
|
|
4
4
|
export type {CodeInputLanguage, CodeInputValue, CodeOptions, CodeSchemaType} from './types'
|
package/src/plugin.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {definePlugin} from 'sanity'
|
|
2
2
|
|
|
3
3
|
import {CodeInputConfigContext} from './codemirror/CodeModeContext'
|
|
4
|
-
import {CodeMode} from './codemirror/defaultCodeModes'
|
|
4
|
+
import type {CodeMode} from './codemirror/defaultCodeModes'
|
|
5
5
|
import {codeSchema} from './schema'
|
|
6
6
|
|
|
7
7
|
export interface CodeInputConfig {
|
package/src/sanity-ui.d.ts
CHANGED
package/src/schema.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {CodeBlockIcon} from '@sanity/icons'
|
|
2
|
-
import {defineType, ObjectDefinition} from 'sanity'
|
|
2
|
+
import {defineType, type ObjectDefinition} from 'sanity'
|
|
3
3
|
|
|
4
4
|
import {CodeInput} from './CodeInput'
|
|
5
5
|
import {getMedia} from './getMedia'
|
|
6
6
|
import {PreviewCode} from './PreviewCode'
|
|
7
|
-
import {CodeOptions} from './types'
|
|
7
|
+
import type {CodeOptions} from './types'
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @public
|
|
@@ -19,7 +19,7 @@ export interface CodeDefinition extends Omit<ObjectDefinition, 'type' | 'fields'
|
|
|
19
19
|
options?: CodeOptions
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
declare module '
|
|
22
|
+
declare module 'sanity' {
|
|
23
23
|
// makes type: 'code' narrow correctly when using defineType/defineField/defineArrayMember
|
|
24
24
|
export interface IntrinsicDefinitions {
|
|
25
25
|
code: CodeDefinition
|
package/src/types.ts
CHANGED
package/src/useFieldMember.ts
CHANGED