@sanity/code-input 5.0.0 → 5.1.0
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/lib/_chunks-cjs/CodeMirrorProxy.cjs +429 -0
- package/lib/_chunks-cjs/CodeMirrorProxy.cjs.map +1 -0
- package/lib/_chunks-cjs/index.cjs +5971 -0
- package/lib/_chunks-cjs/index.cjs.map +1 -0
- package/lib/_chunks-es/CodeMirrorProxy.js +417 -0
- package/lib/_chunks-es/CodeMirrorProxy.js.map +1 -0
- package/lib/_chunks-es/index.js +5970 -0
- package/lib/_chunks-es/index.js.map +1 -0
- package/lib/_legacy/CodeMirrorProxy.esm.js +417 -0
- package/lib/_legacy/CodeMirrorProxy.esm.js.map +1 -0
- package/lib/_legacy/index.esm.js +5970 -0
- package/lib/_legacy/index.esm.js.map +1 -0
- package/lib/index.cjs +3 -6
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +121 -0
- package/lib/index.d.ts +2 -2
- package/lib/index.esm.js +8 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/package.json +37 -42
- package/src/CodeInput.tsx +4 -3
- package/src/LanguageField.tsx +2 -1
- package/src/LanguageInput.tsx +3 -2
- package/src/PreviewCode.tsx +5 -4
- package/src/codemirror/CodeMirrorProxy.tsx +7 -6
- package/src/codemirror/CodeModeContext.tsx +2 -1
- package/src/codemirror/defaultCodeModes.ts +1 -1
- package/src/codemirror/extensions/backwardsCompatibleTone.ts +19 -0
- package/src/codemirror/extensions/highlightLineExtension.ts +12 -6
- package/src/codemirror/extensions/theme.ts +8 -4
- package/src/codemirror/extensions/useCodeMirrorTheme.ts +5 -4
- package/src/codemirror/extensions/useFontSize.ts +1 -1
- package/src/codemirror/useCodeMirror-client.test.tsx +10 -7
- package/src/codemirror/useCodeMirror-server.test.tsx +1 -0
- package/src/codemirror/useLanguageMode.tsx +11 -3
- package/src/index.ts +4 -7
- package/src/plugin.tsx +3 -2
- package/src/schema.tsx +3 -2
- package/lib/_chunks/CodeMirrorProxy-A8RWnbXx.js +0 -615
- package/lib/_chunks/CodeMirrorProxy-A8RWnbXx.js.map +0 -1
- package/lib/_chunks/CodeMirrorProxy-tci8hAnf.cjs +0 -623
- package/lib/_chunks/CodeMirrorProxy-tci8hAnf.cjs.map +0 -1
- package/lib/_chunks/index-0LQQ9tED.cjs +0 -4686
- package/lib/_chunks/index-0LQQ9tED.cjs.map +0 -1
- package/lib/_chunks/index-4cT0QYPN.js +0 -4672
- package/lib/_chunks/index-4cT0QYPN.js.map +0 -1
- package/lib/index.cjs.js +0 -7
- package/src/__workshop__/index.ts +0 -22
- package/src/__workshop__/lazy.tsx +0 -54
- package/src/__workshop__/preview.tsx +0 -24
- package/src/__workshop__/props.tsx +0 -24
package/lib/index.cjs.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import {defineScope} from '@sanity/ui-workshop'
|
|
2
|
-
import {lazy} from 'react'
|
|
3
|
-
|
|
4
|
-
export default defineScope({
|
|
5
|
-
stories: [
|
|
6
|
-
{
|
|
7
|
-
name: 'props',
|
|
8
|
-
title: 'Props',
|
|
9
|
-
component: lazy(() => import('./props')),
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
name: 'preview',
|
|
13
|
-
title: 'Preview',
|
|
14
|
-
component: lazy(() => import('./preview')),
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
name: 'lazy',
|
|
18
|
-
title: 'Lazy',
|
|
19
|
-
component: lazy(() => import('./lazy')),
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
})
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {Box, Card, Container, Text} from '@sanity/ui'
|
|
2
|
-
import {Suspense, useState} from 'react'
|
|
3
|
-
import {useCodeMirror} from '../codemirror/useCodeMirror'
|
|
4
|
-
import {SUPPORTED_LANGUAGES} from '../config'
|
|
5
|
-
import {useSelect} from '@sanity/ui-workshop'
|
|
6
|
-
import styled from 'styled-components'
|
|
7
|
-
|
|
8
|
-
const langs = {
|
|
9
|
-
...Object.fromEntries(SUPPORTED_LANGUAGES.map((l) => [l.title, l.mode ?? l.value])),
|
|
10
|
-
'Not supported': 'not-supported',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const defaultSnippet = `
|
|
14
|
-
<Card border padding={2}>
|
|
15
|
-
{variable}
|
|
16
|
-
</Card>
|
|
17
|
-
`.trim()
|
|
18
|
-
|
|
19
|
-
const Root = styled(Card)`
|
|
20
|
-
& > .cm-theme {
|
|
21
|
-
height: 100%;
|
|
22
|
-
}
|
|
23
|
-
`
|
|
24
|
-
|
|
25
|
-
export default function CodeMirrorStory() {
|
|
26
|
-
const language = useSelect('Language mode', langs, 'tsx')
|
|
27
|
-
const [code, setCode] = useState(defaultSnippet)
|
|
28
|
-
const [highlights, setHighlights] = useState<number[]>([])
|
|
29
|
-
const CodeMirror = useCodeMirror()
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<Container padding={4} sizing="border" width={1}>
|
|
33
|
-
<Root border overflow="hidden" radius={3} style={{height: 300}}>
|
|
34
|
-
{CodeMirror && (
|
|
35
|
-
<Suspense
|
|
36
|
-
fallback={
|
|
37
|
-
<Box padding={3}>
|
|
38
|
-
<Text>Loading code editor...</Text>
|
|
39
|
-
</Box>
|
|
40
|
-
}
|
|
41
|
-
>
|
|
42
|
-
<CodeMirror
|
|
43
|
-
value={code}
|
|
44
|
-
onChange={setCode}
|
|
45
|
-
highlightLines={highlights}
|
|
46
|
-
onHighlightChange={setHighlights}
|
|
47
|
-
languageMode={language}
|
|
48
|
-
/>
|
|
49
|
-
</Suspense>
|
|
50
|
-
)}
|
|
51
|
-
</Root>
|
|
52
|
-
</Container>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {Box, Container} from '@sanity/ui'
|
|
2
|
-
import {useWorkshopSanity} from '@sanity/ui-workshop-plugin-sanity'
|
|
3
|
-
import {isObjectSchemaType, useSchema} from 'sanity'
|
|
4
|
-
import {DocumentFormProvider, SelectedInput} from 'sanity-extra'
|
|
5
|
-
|
|
6
|
-
export default function PreviewStory() {
|
|
7
|
-
const {onPatchEvent} = useWorkshopSanity()
|
|
8
|
-
const schema = useSchema()
|
|
9
|
-
const schemaType = schema.get('test')
|
|
10
|
-
|
|
11
|
-
if (!isObjectSchemaType(schemaType)) {
|
|
12
|
-
return <>Not an object type</>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<DocumentFormProvider documentId="test" onPatchEvent={onPatchEvent} schemaType={schemaType}>
|
|
17
|
-
<Container width={1}>
|
|
18
|
-
<Box paddingX={4} paddingY={[5, 6, 7]}>
|
|
19
|
-
<SelectedInput selectedPath={['content']} />
|
|
20
|
-
</Box>
|
|
21
|
-
</Container>
|
|
22
|
-
</DocumentFormProvider>
|
|
23
|
-
)
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import {Box, Container} from '@sanity/ui'
|
|
2
|
-
import {useWorkshopSanity} from '@sanity/ui-workshop-plugin-sanity'
|
|
3
|
-
import {isObjectSchemaType, useSchema} from 'sanity'
|
|
4
|
-
import {DocumentFormProvider, SelectedInput} from 'sanity-extra'
|
|
5
|
-
|
|
6
|
-
export default function PropsStory() {
|
|
7
|
-
const {onPatchEvent} = useWorkshopSanity()
|
|
8
|
-
const schema = useSchema()
|
|
9
|
-
const schemaType = schema.get('test')
|
|
10
|
-
|
|
11
|
-
if (!isObjectSchemaType(schemaType)) {
|
|
12
|
-
return <>Not an object type</>
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<DocumentFormProvider documentId="test" onPatchEvent={onPatchEvent} schemaType={schemaType}>
|
|
17
|
-
<Container width={1}>
|
|
18
|
-
<Box paddingX={4} paddingY={[5, 6, 7]}>
|
|
19
|
-
<SelectedInput selectedPath={['code']} />
|
|
20
|
-
</Box>
|
|
21
|
-
</Container>
|
|
22
|
-
</DocumentFormProvider>
|
|
23
|
-
)
|
|
24
|
-
}
|