@sanity/code-input 3.0.0-v3-studio.12 → 3.0.0-v3-studio.14

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.
@@ -0,0 +1,116 @@
1
+ /// <reference types="react" />
2
+
3
+ import {ObjectDefinition} from 'sanity'
4
+ import {ObjectInputProps} from 'sanity'
5
+ import {ObjectSchemaType} from 'sanity'
6
+ import {Plugin as Plugin_2} from 'sanity'
7
+ import {PreviewConfig} from 'sanity'
8
+ import {ThemeColorSchemeKey} from '@sanity/ui'
9
+
10
+ /**
11
+ * @public
12
+ */
13
+ export declare interface CodeDefinition
14
+ extends Omit<ObjectDefinition, 'type' | 'fields' | 'options'> {
15
+ type: typeof codeTypeName
16
+ options?: CodeOptions
17
+ }
18
+
19
+ /**
20
+ * @public
21
+ */
22
+ export declare const codeInput: Plugin_2<void>
23
+
24
+ /**
25
+ * @public
26
+ */
27
+ export declare interface CodeInputLanguage {
28
+ title: string
29
+ value: string
30
+ mode?: string
31
+ }
32
+
33
+ /**
34
+ * @public
35
+ */
36
+ export declare type CodeInputProps = ObjectInputProps<CodeInputValue, CodeSchemaType> & {
37
+ /** @internal */
38
+ colorScheme?: ThemeColorSchemeKey
39
+ }
40
+
41
+ /**
42
+ * @public
43
+ */
44
+ export declare interface CodeInputValue {
45
+ _type?: 'code'
46
+ code?: string
47
+ filename?: string
48
+ language?: string
49
+ highlightedLines?: number[]
50
+ }
51
+
52
+ /**
53
+ * @public
54
+ */
55
+ export declare interface CodeOptions {
56
+ theme?: string
57
+ darkTheme?: string
58
+ languageAlternatives?: CodeInputLanguage[]
59
+ language?: string
60
+ withFilename?: boolean
61
+ }
62
+
63
+ /**
64
+ * @public
65
+ */
66
+ export declare const codeSchema: {
67
+ type: 'object'
68
+ name: 'code'
69
+ } & Omit<ObjectDefinition, 'preview'> & {
70
+ preview?:
71
+ | PreviewConfig<
72
+ {
73
+ language: string
74
+ code: string
75
+ filename: string
76
+ highlightedLines: string
77
+ },
78
+ Record<'code' | 'language' | 'filename' | 'highlightedLines', any>
79
+ >
80
+ | undefined
81
+ }
82
+
83
+ /**
84
+ * @public
85
+ */
86
+ export declare type CodeSchemaType = Omit<ObjectSchemaType, 'options'> & {
87
+ options?: CodeOptions
88
+ }
89
+
90
+ /**
91
+ * @public
92
+ */
93
+ export declare const codeTypeName: 'code'
94
+
95
+ /**
96
+ * @public
97
+ */
98
+ export declare function PreviewCode(props: PreviewCodeProps): JSX.Element
99
+
100
+ /**
101
+ * @public
102
+ */
103
+ export declare interface PreviewCodeProps {
104
+ type?: CodeSchemaType
105
+ value?: {
106
+ selection?: CodeInputValue
107
+ }
108
+ }
109
+
110
+ export {}
111
+
112
+ declare module '@sanity/types' {
113
+ interface IntrinsicDefinitions {
114
+ code: CodeDefinition;
115
+ }
116
+ }
package/package.json CHANGED
@@ -1,31 +1,34 @@
1
1
  {
2
2
  "name": "@sanity/code-input",
3
- "version": "3.0.0-v3-studio.12",
3
+ "version": "3.0.0-v3-studio.14",
4
4
  "description": "Ace editor for editing code",
5
+ "author": "Sanity.io <hello@sanity.io>",
6
+ "license": "MIT",
5
7
  "source": "./src/index.ts",
6
8
  "exports": {
7
9
  ".": {
8
- "require": "./lib/cjs/index.js",
9
- "default": "./lib/esm/index.js"
10
+ "types": "./lib/src/index.d.ts",
11
+ "source": "./src/index.ts",
12
+ "import": "./lib/index.esm.js",
13
+ "require": "./lib/index.js",
14
+ "default": "./lib/index.esm.js"
10
15
  }
11
16
  },
12
- "main": "./lib/cjs/index.js",
13
- "module": "./lib/esm/index.js",
14
- "types": "./lib/types/index.d.ts",
17
+ "main": "./lib/index.js",
18
+ "module": "./lib/index.esm.js",
19
+ "types": "./lib/src/index.d.ts",
15
20
  "files": [
16
21
  "src",
17
22
  "lib",
18
23
  "v2-incompatible.js",
19
24
  "sanity.json"
20
25
  ],
21
- "author": "Sanity.io <hello@sanity.io>",
22
- "license": "MIT",
23
26
  "scripts": {
24
27
  "clean": "rimraf lib",
25
- "prebuild": "npm run clean && plugin-kit verify-package --silent",
26
- "build": "parcel build --no-cache",
28
+ "prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils",
29
+ "build": "pkg-utils build",
27
30
  "link-watch": "plugin-kit link-watch",
28
- "watch": "parcel watch",
31
+ "watch": "pkg-utils watch",
29
32
  "prepublishOnly": "npm run build",
30
33
  "compile": "tsc --noEmit",
31
34
  "lint": "eslint .",
@@ -44,61 +47,62 @@
44
47
  "code-editor"
45
48
  ],
46
49
  "dependencies": {
47
- "@sanity/icons": "^1.2.8",
50
+ "@sanity/icons": "1.3.9-beta.3",
48
51
  "@sanity/incompatible-plugin": "^1.0.4",
49
- "@sanity/ui": "^1.0.0-beta.31",
50
- "ace-builds": "^1.9.5",
52
+ "@sanity/ui": "1.0.0-beta.32",
53
+ "ace-builds": "^1.12.5",
51
54
  "react-ace": "^10.1.0"
52
55
  },
53
56
  "devDependencies": {
54
57
  "@babel/preset-env": "^7.18.10",
55
58
  "@babel/preset-react": "^7.18.6",
56
- "@commitlint/cli": "^17.1.2",
57
- "@commitlint/config-conventional": "^17.1.0",
59
+ "@commitlint/cli": "^17.2.0",
60
+ "@commitlint/config-conventional": "^17.2.0",
58
61
  "@parcel/packager-ts": "2.6.2",
59
62
  "@parcel/transformer-typescript-types": "2.6.2",
60
- "@sanity/plugin-kit": "^1.1.0-ecosystem-preset.5",
61
- "@sanity/semantic-release-preset": "^2.0.1",
63
+ "@sanity/pkg-utils": "^1.16.2",
64
+ "@sanity/plugin-kit": "^2.0.5",
65
+ "@sanity/semantic-release-preset": "^2.0.2",
62
66
  "@testing-library/jest-dom": "^5.16.5",
63
67
  "@testing-library/react": "^13.4.0",
64
68
  "@types/jest": "^29.1.2",
65
69
  "@types/styled-components": "^5.1.25",
66
- "@typescript-eslint/eslint-plugin": "^5.12.0",
67
- "@typescript-eslint/parser": "^5.12.0",
68
- "eslint": "^8.7.0",
69
- "eslint-config-prettier": "^8.3.0",
70
- "eslint-config-sanity": "^5.1.0",
71
- "eslint-plugin-prettier": "4.0.0",
72
- "eslint-plugin-react": "^7.28.0",
73
- "eslint-plugin-react-hooks": "^4.5.0",
70
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
71
+ "@typescript-eslint/parser": "^5.42.0",
72
+ "eslint": "^8.26.0",
73
+ "eslint-config-prettier": "^8.5.0",
74
+ "eslint-config-sanity": "^6.0.0",
75
+ "eslint-plugin-prettier": "^4.2.1",
76
+ "eslint-plugin-react": "^7.31.10",
77
+ "eslint-plugin-react-hooks": "^4.6.0",
74
78
  "husky": "^8.0.1",
75
- "jest": "^28.1.3",
76
- "jest-environment-jsdom": "^28.1.3",
79
+ "jest": "^29.2.2",
80
+ "jest-environment-jsdom": "^29.2.2",
77
81
  "lint-staged": "^13.0.3",
78
- "parcel": "2.6.2",
79
- "prettier": "^2.6.2",
82
+ "parcel": "~2.6.0",
83
+ "prettier": "^2.7.1",
80
84
  "react": "^18.0.0",
81
85
  "react-dom": "^18.0.0",
82
86
  "rimraf": "^3.0.2",
83
- "sanity": "3.0.0-dev-preview.22",
87
+ "sanity": "3.0.0-rc.0",
84
88
  "styled-components": "^5.2.0",
85
- "ts-jest": "^28.0.7",
86
- "typescript": "4.7.4"
89
+ "ts-jest": "^29.0.3",
90
+ "typescript": "^4.8.4"
87
91
  },
88
92
  "peerDependencies": {
89
93
  "react": "^18.0.0",
90
94
  "react-dom": "^18.0.0",
91
- "sanity": "dev-preview || 3.0.0-dev-preview.22",
95
+ "sanity": "dev-preview || 3.0.0-rc.0",
92
96
  "styled-components": "^5.2.0"
93
97
  },
94
98
  "bugs": {
95
99
  "url": "https://github.com/sanity-io/code-input/issues"
96
100
  },
97
- "homepage": "https://www.sanity.io/",
101
+ "homepage": "https://github.com/sanity-io/code-input#readme",
98
102
  "sanityExchangeUrl": "https://www.sanity.io/plugins/code-input",
99
103
  "repository": {
100
104
  "type": "git",
101
- "url": "git+https://github.com/sanity-io/code-input.git"
105
+ "url": "git@github.com:sanity-io/code-input.git"
102
106
  },
103
107
  "engines": {
104
108
  "node": ">=14.0.0"
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {createPlugin} from 'sanity'
1
+ import {definePlugin} from 'sanity'
2
2
 
3
3
  import {codeSchema, codeTypeName, CodeDefinition} from './schema'
4
4
  import PreviewCode, {PreviewCodeProps} from './PreviewCode'
@@ -12,7 +12,7 @@ export type {CodeDefinition}
12
12
  /**
13
13
  * @public
14
14
  */
15
- export const codeInput = createPlugin({
15
+ export const codeInput = definePlugin({
16
16
  name: '@sanity/code-input',
17
17
  schema: {types: [codeSchema]},
18
18
  })
package/src/schema.tsx CHANGED
@@ -36,7 +36,7 @@ export const codeSchema = defineType({
36
36
  name: 'code',
37
37
  type: 'object',
38
38
  title: 'Code',
39
- components: {input: CodeInput, preview: PreviewCode},
39
+ ...({components: {input: CodeInput, preview: PreviewCode}} as {}), //TODO rollback change when rc.1 is released
40
40
  icon: CodeBlockIcon,
41
41
  fields: [
42
42
  {