@sanity/code-input 6.0.4 → 7.0.1
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 -16
- package/assets/all-options.png +0 -0
- package/assets/basic-input.png +0 -0
- package/dist/_chunks-es/CodeMirrorProxy.js +510 -0
- package/dist/_chunks-es/CodeMirrorProxy.js.map +1 -0
- package/dist/_chunks-es/index.js +427 -0
- package/dist/_chunks-es/index.js.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/package.json +37 -94
- package/lib/_chunks-cjs/CodeMirrorProxy.cjs +0 -407
- package/lib/_chunks-cjs/CodeMirrorProxy.cjs.map +0 -1
- package/lib/_chunks-cjs/index.cjs +0 -433
- package/lib/_chunks-cjs/index.cjs.map +0 -1
- package/lib/_chunks-es/CodeMirrorProxy.js +0 -395
- package/lib/_chunks-es/CodeMirrorProxy.js.map +0 -1
- package/lib/_chunks-es/index.js +0 -437
- package/lib/_chunks-es/index.js.map +0 -1
- package/lib/index.cjs +0 -8
- package/lib/index.cjs.map +0 -1
- package/lib/index.d.cts +0 -121
- package/lib/index.d.ts +0 -121
- package/sanity.json +0 -8
- package/src/CodeInput.tsx +0 -181
- package/src/LanguageField.tsx +0 -41
- package/src/LanguageInput.tsx +0 -35
- package/src/PreviewCode.tsx +0 -71
- package/src/codemirror/CodeMirrorProxy.tsx +0 -159
- package/src/codemirror/CodeModeContext.tsx +0 -5
- package/src/codemirror/defaultCodeModes.ts +0 -109
- package/src/codemirror/extensions/backwardsCompatibleTone.ts +0 -19
- package/src/codemirror/extensions/highlightLineExtension.ts +0 -175
- package/src/codemirror/extensions/theme.ts +0 -65
- package/src/codemirror/extensions/useCodeMirrorTheme.ts +0 -64
- package/src/codemirror/extensions/useFontSize.ts +0 -24
- package/src/codemirror/useCodeMirror-client.test.tsx +0 -51
- package/src/codemirror/useCodeMirror-server.test.tsx +0 -18
- package/src/codemirror/useCodeMirror.tsx +0 -11
- package/src/codemirror/useLanguageMode.tsx +0 -60
- package/src/config.ts +0 -35
- package/src/getMedia.tsx +0 -93
- package/src/index.ts +0 -8
- package/src/plugin.tsx +0 -40
- package/src/sanity-ui.d.ts +0 -5
- package/src/schema.tsx +0 -86
- package/src/types.ts +0 -35
- package/src/ui/focusRingStyle.ts +0 -27
- package/src/useFieldMember.ts +0 -16
- package/v2-incompatible.js +0 -11
- /package/{lib → dist}/index.js +0 -0
- /package/{lib → dist}/index.js.map +0 -0
package/src/getMedia.tsx
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
export function getMedia(language?: string) {
|
|
2
|
-
if (language === 'jsx') {
|
|
3
|
-
return (
|
|
4
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
|
|
5
|
-
<g fill="#61DAFB">
|
|
6
|
-
<circle cx="64" cy="64" r="11.4" />
|
|
7
|
-
<path d="M107.3 45.2c-2.2-.8-4.5-1.6-6.9-2.3.6-2.4 1.1-4.8 1.5-7.1 2.1-13.2-.2-22.5-6.6-26.1-1.9-1.1-4-1.6-6.4-1.6-7 0-15.9 5.2-24.9 13.9-9-8.7-17.9-13.9-24.9-13.9-2.4 0-4.5.5-6.4 1.6-6.4 3.7-8.7 13-6.6 26.1.4 2.3.9 4.7 1.5 7.1-2.4.7-4.7 1.4-6.9 2.3C8.2 50 1.4 56.6 1.4 64s6.9 14 19.3 18.8c2.2.8 4.5 1.6 6.9 2.3-.6 2.4-1.1 4.8-1.5 7.1-2.1 13.2.2 22.5 6.6 26.1 1.9 1.1 4 1.6 6.4 1.6 7.1 0 16-5.2 24.9-13.9 9 8.7 17.9 13.9 24.9 13.9 2.4 0 4.5-.5 6.4-1.6 6.4-3.7 8.7-13 6.6-26.1-.4-2.3-.9-4.7-1.5-7.1 2.4-.7 4.7-1.4 6.9-2.3 12.5-4.8 19.3-11.4 19.3-18.8s-6.8-14-19.3-18.8zM92.5 14.7c4.1 2.4 5.5 9.8 3.8 20.3-.3 2.1-.8 4.3-1.4 6.6-5.2-1.2-10.7-2-16.5-2.5-3.4-4.8-6.9-9.1-10.4-13 7.4-7.3 14.9-12.3 21-12.3 1.3 0 2.5.3 3.5.9zM81.3 74c-1.8 3.2-3.9 6.4-6.1 9.6-3.7.3-7.4.4-11.2.4-3.9 0-7.6-.1-11.2-.4-2.2-3.2-4.2-6.4-6-9.6-1.9-3.3-3.7-6.7-5.3-10 1.6-3.3 3.4-6.7 5.3-10 1.8-3.2 3.9-6.4 6.1-9.6 3.7-.3 7.4-.4 11.2-.4 3.9 0 7.6.1 11.2.4 2.2 3.2 4.2 6.4 6 9.6 1.9 3.3 3.7 6.7 5.3 10-1.7 3.3-3.4 6.6-5.3 10zm8.3-3.3c1.5 3.5 2.7 6.9 3.8 10.3-3.4.8-7 1.4-10.8 1.9 1.2-1.9 2.5-3.9 3.6-6 1.2-2.1 2.3-4.2 3.4-6.2zM64 97.8c-2.4-2.6-4.7-5.4-6.9-8.3 2.3.1 4.6.2 6.9.2 2.3 0 4.6-.1 6.9-.2-2.2 2.9-4.5 5.7-6.9 8.3zm-18.6-15c-3.8-.5-7.4-1.1-10.8-1.9 1.1-3.3 2.3-6.8 3.8-10.3 1.1 2 2.2 4.1 3.4 6.1 1.2 2.2 2.4 4.1 3.6 6.1zm-7-25.5c-1.5-3.5-2.7-6.9-3.8-10.3 3.4-.8 7-1.4 10.8-1.9-1.2 1.9-2.5 3.9-3.6 6-1.2 2.1-2.3 4.2-3.4 6.2zM64 30.2c2.4 2.6 4.7 5.4 6.9 8.3-2.3-.1-4.6-.2-6.9-.2-2.3 0-4.6.1-6.9.2 2.2-2.9 4.5-5.7 6.9-8.3zm22.2 21l-3.6-6c3.8.5 7.4 1.1 10.8 1.9-1.1 3.3-2.3 6.8-3.8 10.3-1.1-2.1-2.2-4.2-3.4-6.2zM31.7 35c-1.7-10.5-.3-17.9 3.8-20.3 1-.6 2.2-.9 3.5-.9 6 0 13.5 4.9 21 12.3-3.5 3.8-7 8.2-10.4 13-5.8.5-11.3 1.4-16.5 2.5-.6-2.3-1-4.5-1.4-6.6zM7 64c0-4.7 5.7-9.7 15.7-13.4 2-.8 4.2-1.5 6.4-2.1 1.6 5 3.6 10.3 6 15.6-2.4 5.3-4.5 10.5-6 15.5C15.3 75.6 7 69.6 7 64zm28.5 49.3c-4.1-2.4-5.5-9.8-3.8-20.3.3-2.1.8-4.3 1.4-6.6 5.2 1.2 10.7 2 16.5 2.5 3.4 4.8 6.9 9.1 10.4 13-7.4 7.3-14.9 12.3-21 12.3-1.3 0-2.5-.3-3.5-.9zM96.3 93c1.7 10.5.3 17.9-3.8 20.3-1 .6-2.2.9-3.5.9-6 0-13.5-4.9-21-12.3 3.5-3.8 7-8.2 10.4-13 5.8-.5 11.3-1.4 16.5-2.5.6 2.3 1 4.5 1.4 6.6zm9-15.6c-2 .8-4.2 1.5-6.4 2.1-1.6-5-3.6-10.3-6-15.6 2.4-5.3 4.5-10.5 6-15.5 13.8 4 22.1 10 22.1 15.6 0 4.7-5.8 9.7-15.7 13.4z" />
|
|
8
|
-
</g>
|
|
9
|
-
</svg>
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (language === 'javascript') {
|
|
14
|
-
return (
|
|
15
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128">
|
|
16
|
-
<path fill="#F0DB4F" d="M1.408 1.408h125.184v125.185H1.408z" />
|
|
17
|
-
<path
|
|
18
|
-
fill="#323330"
|
|
19
|
-
d="M116.347 96.736c-.917-5.711-4.641-10.508-15.672-14.981-3.832-1.761-8.104-3.022-9.377-5.926-.452-1.69-.512-2.642-.226-3.665.821-3.32 4.784-4.355 7.925-3.403 2.023.678 3.938 2.237 5.093 4.724 5.402-3.498 5.391-3.475 9.163-5.879-1.381-2.141-2.118-3.129-3.022-4.045-3.249-3.629-7.676-5.498-14.756-5.355l-3.688.477c-3.534.893-6.902 2.748-8.877 5.235-5.926 6.724-4.236 18.492 2.975 23.335 7.104 5.332 17.54 6.545 18.873 11.531 1.297 6.104-4.486 8.08-10.234 7.378-4.236-.881-6.592-3.034-9.139-6.949-4.688 2.713-4.688 2.713-9.508 5.485 1.143 2.499 2.344 3.63 4.26 5.795 9.068 9.198 31.76 8.746 35.83-5.176.165-.478 1.261-3.666.38-8.581zM69.462 58.943H57.753l-.048 30.272c0 6.438.333 12.34-.714 14.149-1.713 3.558-6.152 3.117-8.175 2.427-2.059-1.012-3.106-2.451-4.319-4.485-.333-.584-.583-1.036-.667-1.071l-9.52 5.83c1.583 3.249 3.915 6.069 6.902 7.901 4.462 2.678 10.459 3.499 16.731 2.059 4.082-1.189 7.604-3.652 9.448-7.401 2.666-4.915 2.094-10.864 2.07-17.444.06-10.735.001-21.468.001-32.237z"
|
|
20
|
-
/>
|
|
21
|
-
</svg>
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (language === 'php') {
|
|
26
|
-
return (
|
|
27
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 400">
|
|
28
|
-
<g transform="translate(-44.632 -141.55)">
|
|
29
|
-
<g transform="matrix(8.3528 0 0 8.3119 -727.13 -3759.5)">
|
|
30
|
-
<path d="m99.974 479.48h14.204c4.1693 0.0354 7.1903 1.2367 9.063 3.604 1.8726 2.3674 2.491 5.6004 1.855 9.699-0.24737 1.8727-0.79504 3.71-1.643 5.512-0.8127 1.802-1.9434 3.4273-3.392 4.876-1.7667 1.8373-3.657 3.0033-5.671 3.498-2.014 0.49467-4.0987 0.742-6.254 0.742h-6.36l-2.014 10.07h-7.367l7.579-38.001m6.201 6.042-3.18 15.9c0.21198 0.0353 0.42398 0.053 0.636 0.053h0.742c3.392 0.0353 6.2186-0.30033 8.48-1.007 2.2613-0.74199 3.7806-3.3213 4.558-7.738 0.63597-3.71-0.00003-5.8476-1.908-6.413-1.8727-0.56531-4.2224-0.83031-7.049-0.795-0.42402 0.0353-0.83035 0.053-1.219 0.053-0.35335 0.00002-0.72435 0.00002-1.113 0l0.053-0.053" />
|
|
31
|
-
<path d="m133.49 469.36h7.314l-2.067 10.123h6.572c3.604 0.0707 6.2893 0.81269 8.056 2.226 1.802 1.4134 2.332 4.0987 1.59 8.056l-3.551 17.649h-7.42l3.392-16.854c0.35328-1.7666 0.2473-3.021-0.318-3.763-0.56536-0.74198-1.7844-1.113-3.657-1.113l-5.883-0.053-4.346 21.783h-7.314l7.632-38.054" />
|
|
32
|
-
<path d="m162.81 479.48h14.204c4.1693 0.0354 7.1903 1.2367 9.063 3.604 1.8726 2.3674 2.491 5.6004 1.855 9.699-0.24737 1.8727-0.79503 3.71-1.643 5.512-0.8127 1.802-1.9434 3.4273-3.392 4.876-1.7667 1.8373-3.657 3.0033-5.671 3.498-2.014 0.49467-4.0987 0.742-6.254 0.742h-6.36l-2.014 10.07h-7.367l7.579-38.001m6.201 6.042-3.18 15.9c0.21199 0.0353 0.42399 0.053 0.636 0.053h0.742c3.392 0.0353 6.2186-0.30033 8.48-1.007 2.2613-0.74199 3.7806-3.3213 4.558-7.738 0.63597-3.71-0.00003-5.8476-1.908-6.413-1.8727-0.56531-4.2224-0.83031-7.049-0.795-0.42402 0.0353-0.83035 0.053-1.219 0.053-0.35335 0.00002-0.72435 0.00002-1.113 0l0.053-0.053" />
|
|
33
|
-
</g>
|
|
34
|
-
</g>
|
|
35
|
-
</svg>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (language === 'json') {
|
|
40
|
-
return (
|
|
41
|
-
<svg
|
|
42
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
43
|
-
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
44
|
-
viewBox="0 0 160 160"
|
|
45
|
-
>
|
|
46
|
-
<defs>
|
|
47
|
-
<linearGradient id="a">
|
|
48
|
-
<stop offset="0" />
|
|
49
|
-
<stop offset="1" stopColor="#fff" />
|
|
50
|
-
</linearGradient>
|
|
51
|
-
<linearGradient
|
|
52
|
-
x1="-553.27"
|
|
53
|
-
y1="525.908"
|
|
54
|
-
x2="-666.116"
|
|
55
|
-
y2="413.045"
|
|
56
|
-
id="c"
|
|
57
|
-
xlinkHref="#a"
|
|
58
|
-
gradientUnits="userSpaceOnUse"
|
|
59
|
-
gradientTransform="matrix(.99884 0 0 .9987 689.008 -388.844)"
|
|
60
|
-
/>
|
|
61
|
-
<linearGradient
|
|
62
|
-
x1="-666.117"
|
|
63
|
-
y1="413.045"
|
|
64
|
-
x2="-553.27"
|
|
65
|
-
y2="525.908"
|
|
66
|
-
id="b"
|
|
67
|
-
xlinkHref="#a"
|
|
68
|
-
gradientUnits="userSpaceOnUse"
|
|
69
|
-
gradientTransform="matrix(.99884 0 0 .9987 689.008 -388.844)"
|
|
70
|
-
/>
|
|
71
|
-
</defs>
|
|
72
|
-
<path
|
|
73
|
-
d="M79.865 119.1c35.397 48.255 70.04-13.469 69.988-50.587-.06-43.886-44.54-68.414-70.017-68.414C38.943.1 0 33.895 0 80.135 0 131.531 44.64 160 79.836 160c-7.965-1.147-34.507-6.834-34.863-67.967-.24-41.346 13.487-57.865 34.805-50.599.477.177 23.514 9.265 23.514 38.95 0 29.56-23.427 38.716-23.427 38.716z"
|
|
74
|
-
style={{marker: 'none'}}
|
|
75
|
-
color="#000"
|
|
76
|
-
fill="url(#b)"
|
|
77
|
-
fillRule="evenodd"
|
|
78
|
-
overflow="visible"
|
|
79
|
-
/>
|
|
80
|
-
<path
|
|
81
|
-
d="M79.823 41.4C56.433 33.34 27.78 52.618 27.78 91.23c0 63.048 46.72 68.77 52.384 68.77C121.057 160 160 126.204 160 79.964 160 28.568 115.36.1 80.164.1c9.749-1.35 52.541 10.55 52.541 69.037 0 38.141-31.953 58.905-52.735 50.033-.478-.177-23.514-9.264-23.514-38.95 0-29.56 23.367-38.818 23.367-38.818z"
|
|
82
|
-
style={{marker: 'none'}}
|
|
83
|
-
color="#000"
|
|
84
|
-
fill="url(#c)"
|
|
85
|
-
fillRule="evenodd"
|
|
86
|
-
overflow="visible"
|
|
87
|
-
/>
|
|
88
|
-
</svg>
|
|
89
|
-
)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return undefined
|
|
93
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import {type CodeDefinition, codeSchema, codeTypeName} from './schema'
|
|
2
|
-
export {type CodeInput, type CodeInputProps} from './CodeInput'
|
|
3
|
-
export {PreviewCode, type PreviewCodeProps} from './PreviewCode'
|
|
4
|
-
export type {CodeInputLanguage, CodeInputValue, CodeOptions, CodeSchemaType} from './types'
|
|
5
|
-
export {codeSchema, codeTypeName}
|
|
6
|
-
export type {CodeDefinition}
|
|
7
|
-
|
|
8
|
-
export {codeInput} from './plugin'
|
package/src/plugin.tsx
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {definePlugin} from 'sanity'
|
|
2
|
-
|
|
3
|
-
import {CodeInputConfigContext} from './codemirror/CodeModeContext'
|
|
4
|
-
import type {CodeMode} from './codemirror/defaultCodeModes'
|
|
5
|
-
import {codeSchema} from './schema'
|
|
6
|
-
|
|
7
|
-
export interface CodeInputConfig {
|
|
8
|
-
codeModes?: CodeMode[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
export const codeInput = definePlugin<CodeInputConfig | void>((config) => {
|
|
15
|
-
const codeModes = config && config.codeModes
|
|
16
|
-
const basePlugin = {
|
|
17
|
-
name: '@sanity/code-input',
|
|
18
|
-
schema: {types: [codeSchema]},
|
|
19
|
-
}
|
|
20
|
-
if (!codeModes) {
|
|
21
|
-
return basePlugin
|
|
22
|
-
}
|
|
23
|
-
return {
|
|
24
|
-
...basePlugin,
|
|
25
|
-
form: {
|
|
26
|
-
components: {
|
|
27
|
-
input: (props) => {
|
|
28
|
-
if (props.id !== 'root') {
|
|
29
|
-
return props.renderDefault(props)
|
|
30
|
-
}
|
|
31
|
-
return (
|
|
32
|
-
<CodeInputConfigContext.Provider value={config}>
|
|
33
|
-
{props.renderDefault(props)}
|
|
34
|
-
</CodeInputConfigContext.Provider>
|
|
35
|
-
)
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
})
|
package/src/sanity-ui.d.ts
DELETED
package/src/schema.tsx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import {CodeBlockIcon} from '@sanity/icons'
|
|
2
|
-
import {defineType, type ObjectDefinition} from 'sanity'
|
|
3
|
-
|
|
4
|
-
import {CodeInput} from './CodeInput'
|
|
5
|
-
import {getMedia} from './getMedia'
|
|
6
|
-
import {PreviewCode} from './PreviewCode'
|
|
7
|
-
import type {CodeOptions} from './types'
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export const codeTypeName = 'code' as const
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @public
|
|
16
|
-
*/
|
|
17
|
-
export interface CodeDefinition extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {
|
|
18
|
-
type: typeof codeTypeName
|
|
19
|
-
options?: CodeOptions
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
declare module 'sanity' {
|
|
23
|
-
// makes type: 'code' narrow correctly when using defineType/defineField/defineArrayMember
|
|
24
|
-
export interface IntrinsicDefinitions {
|
|
25
|
-
code: CodeDefinition
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @public
|
|
31
|
-
*/
|
|
32
|
-
export const codeSchema = defineType({
|
|
33
|
-
name: 'code',
|
|
34
|
-
type: 'object',
|
|
35
|
-
title: 'Code',
|
|
36
|
-
components: {input: CodeInput, preview: PreviewCode},
|
|
37
|
-
icon: CodeBlockIcon,
|
|
38
|
-
fields: [
|
|
39
|
-
{
|
|
40
|
-
name: 'language',
|
|
41
|
-
title: 'Language',
|
|
42
|
-
type: 'string',
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: 'filename',
|
|
46
|
-
title: 'Filename',
|
|
47
|
-
type: 'string',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
title: 'Code',
|
|
51
|
-
name: 'code',
|
|
52
|
-
type: 'text',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
title: 'Highlighted lines',
|
|
56
|
-
name: 'highlightedLines',
|
|
57
|
-
type: 'array',
|
|
58
|
-
of: [
|
|
59
|
-
{
|
|
60
|
-
type: 'number',
|
|
61
|
-
title: 'Highlighted line',
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
preview: {
|
|
67
|
-
select: {
|
|
68
|
-
language: 'language',
|
|
69
|
-
code: 'code',
|
|
70
|
-
filename: 'filename',
|
|
71
|
-
highlightedLines: 'highlightedLines',
|
|
72
|
-
},
|
|
73
|
-
prepare: (value: {
|
|
74
|
-
language?: string
|
|
75
|
-
code?: string
|
|
76
|
-
filename?: string
|
|
77
|
-
highlightedLines?: number[]
|
|
78
|
-
}) => {
|
|
79
|
-
return {
|
|
80
|
-
title: value.filename || (value.language || 'unknown').toUpperCase(),
|
|
81
|
-
media: getMedia(value?.language),
|
|
82
|
-
selection: value,
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
})
|
package/src/types.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type {ObjectSchemaType} from 'sanity'
|
|
2
|
-
|
|
3
|
-
export interface CodeInputLanguage {
|
|
4
|
-
title: string
|
|
5
|
-
value: string
|
|
6
|
-
mode?: string
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export interface CodeInputValue {
|
|
13
|
-
_type?: 'code'
|
|
14
|
-
code?: string
|
|
15
|
-
filename?: string
|
|
16
|
-
language?: string
|
|
17
|
-
highlightedLines?: number[]
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
export interface CodeOptions {
|
|
23
|
-
theme?: string
|
|
24
|
-
darkTheme?: string
|
|
25
|
-
languageAlternatives?: CodeInputLanguage[]
|
|
26
|
-
language?: string
|
|
27
|
-
withFilename?: boolean
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* @public
|
|
32
|
-
*/
|
|
33
|
-
export interface CodeSchemaType extends Omit<ObjectSchemaType, 'options'> {
|
|
34
|
-
options?: CodeOptions
|
|
35
|
-
}
|
package/src/ui/focusRingStyle.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** @internal */
|
|
2
|
-
// todo: import from @sanity/ui instead
|
|
3
|
-
export function focusRingBorderStyle(border: {color: string; width: number}): string {
|
|
4
|
-
return `inset 0 0 0 ${border.width}px ${border.color}`
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
/** @internal */
|
|
8
|
-
// todo: import from @sanity/ui instead
|
|
9
|
-
export function focusRingStyle(opts: {
|
|
10
|
-
base?: {bg: string}
|
|
11
|
-
border?: {color: string; width: number}
|
|
12
|
-
focusRing: {offset: number; width: number}
|
|
13
|
-
}): string {
|
|
14
|
-
const {base, border, focusRing} = opts
|
|
15
|
-
const focusRingOutsetWidth = focusRing.offset + focusRing.width
|
|
16
|
-
const focusRingInsetWidth = 0 - focusRing.offset
|
|
17
|
-
const bgColor = base ? base.bg : 'var(--card-bg-color)'
|
|
18
|
-
|
|
19
|
-
return [
|
|
20
|
-
focusRingInsetWidth > 0 && `inset 0 0 0 ${focusRingInsetWidth}px var(--card-focus-ring-color)`,
|
|
21
|
-
border && focusRingBorderStyle(border),
|
|
22
|
-
focusRingInsetWidth < 0 && `0 0 0 ${0 - focusRingInsetWidth}px ${bgColor}`,
|
|
23
|
-
focusRingOutsetWidth > 0 && `0 0 0 ${focusRingOutsetWidth}px var(--card-focus-ring-color)`,
|
|
24
|
-
]
|
|
25
|
-
.filter(Boolean)
|
|
26
|
-
.join(',')
|
|
27
|
-
}
|
package/src/useFieldMember.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import {useMemo} from 'react'
|
|
2
|
-
import type {FieldMember, ObjectMember} from 'sanity'
|
|
3
|
-
|
|
4
|
-
/** @internal */
|
|
5
|
-
export function useFieldMember(
|
|
6
|
-
members: ObjectMember[],
|
|
7
|
-
fieldName: string,
|
|
8
|
-
): FieldMember | undefined {
|
|
9
|
-
return useMemo(
|
|
10
|
-
() =>
|
|
11
|
-
members.find(
|
|
12
|
-
(member): member is FieldMember => member.kind === 'field' && member.name === fieldName,
|
|
13
|
-
),
|
|
14
|
-
[members, fieldName],
|
|
15
|
-
)
|
|
16
|
-
}
|
package/v2-incompatible.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const {showIncompatiblePluginDialog} = require('@sanity/incompatible-plugin')
|
|
2
|
-
const {name, version, sanityExchangeUrl} = require('./package.json')
|
|
3
|
-
|
|
4
|
-
export default showIncompatiblePluginDialog({
|
|
5
|
-
name: name,
|
|
6
|
-
versions: {
|
|
7
|
-
v3: version,
|
|
8
|
-
v2: '^2.30.0',
|
|
9
|
-
},
|
|
10
|
-
sanityExchangeUrl,
|
|
11
|
-
})
|
/package/{lib → dist}/index.js
RENAMED
|
File without changes
|
|
File without changes
|