sanity-plugin-latex-input 0.3.0-v3-studio.0 → 0.3.0-v3-studio.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/LICENSE +1 -1
- package/README.md +8 -15
- package/lib/cjs/index.js +29 -22
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.js +29 -23
- package/lib/esm/index.js.map +1 -1
- package/lib/types/index.d.ts +21 -0
- package/lib/types/index.d.ts.map +1 -1
- package/package.json +17 -16
- package/src/index.tsx +9 -26
- package/src/schema.ts +42 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -79,22 +79,15 @@ MIT-licensed. See LICENSE.
|
|
|
79
79
|
|
|
80
80
|
## Develop & test
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
npm run link-watch
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
In another shell, `cd` to your test studio and run:
|
|
82
|
+
This plugin uses [@sanity/plugin-kit](https://github.com/sanity-io/plugin-kit)
|
|
83
|
+
with default configuration for build & watch scripts.
|
|
89
84
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```
|
|
85
|
+
See [Testing a plugin in Sanity Studio](https://github.com/sanity-io/plugin-kit#testing-a-plugin-in-sanity-studio)
|
|
86
|
+
on how to run this plugin with hotreload in the studio.
|
|
93
87
|
|
|
94
|
-
|
|
95
|
-
triggering hotreload. Yalc avoids issues with react-hooks that are typical when using yarn/npm link.
|
|
88
|
+
### Release new version
|
|
96
89
|
|
|
97
|
-
|
|
90
|
+
Run ["CI & Release" workflow](https://github.com/sanity-io/latex-input/actions/workflows/main.yml).
|
|
91
|
+
Make sure to select the v3 branch and check "Release new version".
|
|
98
92
|
|
|
99
|
-
|
|
100
|
-
with default configuration for build & watch scripts.
|
|
93
|
+
Semantic release will only release on configured branches, so it is safe to run release on any branch.
|
package/lib/cjs/index.js
CHANGED
|
@@ -13,6 +13,7 @@ function $parcel$interopDefault(a) {
|
|
|
13
13
|
|
|
14
14
|
$parcel$export(module.exports, "latexInput", () => $329a1cedcedb1349$export$17b0a661cd4afef9);
|
|
15
15
|
$parcel$export(module.exports, "LatexPreview", () => $a18100092750648b$export$2e2bcd8739ae039);
|
|
16
|
+
$parcel$export(module.exports, "latexSchema", () => $83686b2c306f69a9$export$23dad2d6284ed503);
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
|
|
@@ -49,32 +50,38 @@ var $a18100092750648b$export$2e2bcd8739ae039 = $a18100092750648b$var$LatexPrevie
|
|
|
49
50
|
|
|
50
51
|
|
|
51
52
|
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
const $83686b2c306f69a9$var$latexTypeName = "latex";
|
|
56
|
+
const $83686b2c306f69a9$export$23dad2d6284ed503 = (0, $dyHF6$sanity.defineType)({
|
|
57
|
+
type: "object",
|
|
58
|
+
name: "latex",
|
|
59
|
+
components: {
|
|
60
|
+
preview: (0, $a18100092750648b$export$2e2bcd8739ae039)
|
|
61
|
+
},
|
|
62
|
+
fields: [
|
|
63
|
+
{
|
|
64
|
+
title: "LaTeX content",
|
|
65
|
+
name: "body",
|
|
66
|
+
type: "text"
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
preview: {
|
|
70
|
+
select: {
|
|
71
|
+
body: "body"
|
|
72
|
+
},
|
|
73
|
+
prepare (selection) {
|
|
74
|
+
return selection;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
|
|
52
80
|
const $329a1cedcedb1349$export$17b0a661cd4afef9 = (0, $dyHF6$sanity.createPlugin)({
|
|
53
81
|
name: "latex-block-plugin",
|
|
54
82
|
schema: {
|
|
55
83
|
types: [
|
|
56
|
-
(0, $
|
|
57
|
-
type: "object",
|
|
58
|
-
name: "latex",
|
|
59
|
-
components: {
|
|
60
|
-
preview: (0, $a18100092750648b$export$2e2bcd8739ae039)
|
|
61
|
-
},
|
|
62
|
-
fields: [
|
|
63
|
-
{
|
|
64
|
-
title: "LaTeX content",
|
|
65
|
-
name: "body",
|
|
66
|
-
type: "text"
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
preview: {
|
|
70
|
-
select: {
|
|
71
|
-
body: "body"
|
|
72
|
-
},
|
|
73
|
-
prepare (selection) {
|
|
74
|
-
return selection;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}),
|
|
84
|
+
(0, $83686b2c306f69a9$export$23dad2d6284ed503)
|
|
78
85
|
]
|
|
79
86
|
}
|
|
80
87
|
});
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;ACAA;;;;AAaA,MAAM,kCAAY,GAAG,CAAC,KAAwB,GAAK;IACjD,MAAM,KAAK,GAAG,AAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,IAAK,EAAE,AAAC;IACtD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,KAAK,QAAQ,AAAC;IAC3C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,CAAA,GAAA,qBAAQ,CAAA,CAAS,EAAE,CAAC,AAAC;IAC7C,MAAM,UAAU,GAAG,IAAM;QACvB,OAAO,CACL,CAAA,GAAA,sCAAK,CAAA,CAAC,cAAc,CAAC,KAAK,EAAE;YAC1B,WAAW,EAAE,CAAC,QAAQ;YACtB,YAAY,EAAE,KAAK;SACpB,CAAC,CACH,CAAC;KACH,AAAC;IAEF,CAAA,GAAA,oBAAO,CAAA,CAAC,UAAU,EAAE;QAAC,KAAK;QAAE,QAAQ;KAAC,CAAC,CAAC;IACvC,qBACE;kBACG,QAAQ,GACP,2CAA2C;sBAC3C,gCAAC,MAAI;YAAC,uBAAuB,EAAE;gBAAE,MAAM,EAAE,IAAI;aAAE;UAAI,GAEnD,2CAA2C;sBAC3C,gCAAC,KAAG;YAAC,uBAAuB,EAAE;gBAAE,MAAM,EAAE,IAAI;aAAE;UAAI,AACnD;MACA,CACH;CACH,AAAC;IAEF,wCAA4B,GAAb,kCAAY;;ADxC3B;;AEAA;;AAGA,MAAM,mCAAa,GAAG,OAAO,AAAS,AAAC;AAiBhC,MAAM,yCAAW,GAAG,CAAA,GAAA,wBAAU,CAAA,CAAC;IACpC,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,OAAO;IACb,UAAU,EAAE;QACV,OAAO,EAAE,CAAA,GAAA,wCAAY,CAAA;KACtB;IACD,MAAM,EAAE;QACN;YACE,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;SACb;KACF;IACD,OAAO,EAAE;QACP,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;SACb;QACD,OAAO,EAAC,SAAS,EAAE;YACjB,OAAO,SAAS,CAA4B;SAC7C;KACF;CACF,CAAC,AAAC;;;AF9BI,MAAM,yCAAU,GAAG,CAAA,GAAA,0BAAY,CAAA,CAAC;IACrC,IAAI,EAAE,oBAAoB;IAC1B,MAAM,EAAE;QACN,KAAK,EAAE;YAAC,CAAA,GAAA,yCAAW,CAAA;SAAC;KACrB;CACF,CAAC,AAAC","sources":["src/index.tsx","src/components/LatexPreview.tsx","src/schema.ts"],"sourcesContent":["import LatexPreview, { LatexPreviewProps } from './components/LatexPreview';\nimport { createPlugin } from 'sanity';\nimport { latexSchema, LatexDefinition } from './schema';\n\nexport {\n LatexPreview,\n latexSchema,\n type LatexPreviewProps,\n type LatexDefinition,\n};\n\nexport const latexInput = createPlugin({\n name: 'latex-block-plugin',\n schema: {\n types: [latexSchema],\n },\n});\n","import React, { useMemo, useState } from 'react';\nimport KaTeX from 'katex';\nimport 'katex/dist/katex.min.css';\n\ntype SchemaDefinition = {\n body?: string;\n};\n\nexport type LatexPreviewProps = {\n value?: SchemaDefinition;\n layout?: string;\n};\n\nconst LatexPreview = (props: LatexPreviewProps) => {\n const latex = (props.value && props.value.body) || '';\n const isInline = props.layout === 'inline';\n const [html, setHtml] = useState<string>('');\n const createHtml = () => {\n setHtml(\n KaTeX.renderToString(latex, {\n displayMode: !isInline,\n throwOnError: false,\n })\n );\n };\n\n useMemo(createHtml, [latex, isInline]);\n return (\n <>\n {isInline ? (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: html }} />\n ) : (\n // eslint-disable-next-line react/no-danger\n <div dangerouslySetInnerHTML={{ __html: html }} />\n )}\n </>\n );\n};\n\nexport default LatexPreview;\n","import { defineType, ObjectDefinition, type PreviewValue } from 'sanity';\nimport LatexPreview from './components/LatexPreview';\n\nconst latexTypeName = 'latex' as const;\n\n/**\n * @public\n */\nexport interface LatexDefinition\n extends Omit<ObjectDefinition, 'type' | 'fields'> {\n type: typeof latexTypeName;\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'latex' narrow correctly when using defineType/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n latex: LatexDefinition;\n }\n}\n\nexport const latexSchema = defineType({\n type: 'object',\n name: 'latex',\n components: {\n preview: LatexPreview,\n },\n fields: [\n {\n title: 'LaTeX content',\n name: 'body',\n type: 'text',\n },\n ],\n preview: {\n select: {\n body: 'body',\n },\n prepare(selection) {\n return selection as unknown as PreviewValue;\n },\n },\n});\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
package/lib/esm/index.js
CHANGED
|
@@ -40,36 +40,42 @@ var $7dfe52883a1c33dd$export$2e2bcd8739ae039 = $7dfe52883a1c33dd$var$LatexPrevie
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const $12cb8b58be9d76a6$var$latexTypeName = "latex";
|
|
46
|
+
const $12cb8b58be9d76a6$export$23dad2d6284ed503 = (0, $7XdDa$defineType)({
|
|
47
|
+
type: "object",
|
|
48
|
+
name: "latex",
|
|
49
|
+
components: {
|
|
50
|
+
preview: (0, $7dfe52883a1c33dd$export$2e2bcd8739ae039)
|
|
51
|
+
},
|
|
52
|
+
fields: [
|
|
53
|
+
{
|
|
54
|
+
title: "LaTeX content",
|
|
55
|
+
name: "body",
|
|
56
|
+
type: "text"
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
preview: {
|
|
60
|
+
select: {
|
|
61
|
+
body: "body"
|
|
62
|
+
},
|
|
63
|
+
prepare (selection) {
|
|
64
|
+
return selection;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
|
|
43
70
|
const $357f50a17451fe9f$export$17b0a661cd4afef9 = (0, $7XdDa$createPlugin)({
|
|
44
71
|
name: "latex-block-plugin",
|
|
45
72
|
schema: {
|
|
46
73
|
types: [
|
|
47
|
-
(0, $
|
|
48
|
-
type: "object",
|
|
49
|
-
name: "latex",
|
|
50
|
-
components: {
|
|
51
|
-
preview: (0, $7dfe52883a1c33dd$export$2e2bcd8739ae039)
|
|
52
|
-
},
|
|
53
|
-
fields: [
|
|
54
|
-
{
|
|
55
|
-
title: "LaTeX content",
|
|
56
|
-
name: "body",
|
|
57
|
-
type: "text"
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
preview: {
|
|
61
|
-
select: {
|
|
62
|
-
body: "body"
|
|
63
|
-
},
|
|
64
|
-
prepare (selection) {
|
|
65
|
-
return selection;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}),
|
|
74
|
+
(0, $12cb8b58be9d76a6$export$23dad2d6284ed503)
|
|
69
75
|
]
|
|
70
76
|
}
|
|
71
77
|
});
|
|
72
78
|
|
|
73
79
|
|
|
74
|
-
export {$357f50a17451fe9f$export$17b0a661cd4afef9 as latexInput, $7dfe52883a1c33dd$export$2e2bcd8739ae039 as LatexPreview};
|
|
80
|
+
export {$357f50a17451fe9f$export$17b0a661cd4afef9 as latexInput, $7dfe52883a1c33dd$export$2e2bcd8739ae039 as LatexPreview, $12cb8b58be9d76a6$export$23dad2d6284ed503 as lat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AM,EAAE;QACN,KAAK,EAAE;YAAC,CAAA,GAAA,yCAAW,CAAA;SAAC;KACrB;CACF,CAAC,AAAC","sources":["src/index.tsx","src/components/LatexPreview.tsx","src/schema.ts"],"sourcesContent":["import LatexPreview, { LatexPreviewProps } from './components/LatexPreview';\nimport { createPlugin } from 'sanity';\nimport { latexSchema, LatexDefinition } from './schema';\n\nexport {\n LatexPreview,\n latexSchema,\n type LatexPreviewProps,\n type LatexDefinition,\n};\n\nexport const latexInput = createPlugin({\n name: 'latex-block-plugin',\n schema: {\n types: [latexSchema],\n },\n});\n","import React, { useMemo, useState } from 'react';\nimport KaTeX from 'katex';\nimport 'katex/dist/katex.min.css';\n\ntype SchemaDefinition = {\n body?: string;\n};\n\nexport type LatexPreviewProps = {\n value?: SchemaDefinition;\n layout?: string;\n};\n\nconst LatexPreview = (props: LatexPreviewProps) => {\n const latex = (props.value && props.value.body) || '';\n const isInline = props.layout === 'inline';\n const [html, setHtml] = useState<string>('');\n const createHtml = () => {\n setHtml(\n KaTeX.renderToString(latex, {\n displayMode: !isInline,\n throwOnError: false,\n })\n );\n };\n\n useMemo(createHtml, [latex, isInline]);\n return (\n <>\n {isInline ? (\n // eslint-disable-next-line react/no-danger\n <span dangerouslySetInnerHTML={{ __html: html }} />\n ) : (\n // eslint-disable-next-line react/no-danger\n <div dangerouslySetInnerHTML={{ __html: html }} />\n )}\n </>\n );\n};\n\nexport default LatexPreview;\n","import { defineType, ObjectDefinition, type PreviewValue } from 'sanity';\nimport LatexPreview from './components/LatexPreview';\n\nconst latexTypeName = 'latex' as const;\n\n/**\n * @public\n */\nexport interface LatexDefinition\n extends Omit<ObjectDefinition, 'type' | 'fields'> {\n type: typeof latexTypeName;\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'latex' narrow correctly when using defineType/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n latex: LatexDefinition;\n }\n}\n\nexport const latexSchema = defineType({\n type: 'object',\n name: 'latex',\n components: {\n preview: LatexPreview,\n },\n fields: [\n {\n title: 'LaTeX content',\n name: 'body',\n type: 'text',\n },\n ],\n preview: {\n select: {\n body: 'body',\n },\n prepare(selection) {\n return selection as unknown as PreviewValue;\n },\n },\n});\n"],"names":[],"version":3,"file":"index.js.map","sourceRoot":"../../"}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ObjectDefinition } from "sanity";
|
|
1
2
|
type SchemaDefinition = {
|
|
2
3
|
body?: string;
|
|
3
4
|
};
|
|
@@ -6,6 +7,26 @@ export type LatexPreviewProps = {
|
|
|
6
7
|
layout?: string;
|
|
7
8
|
};
|
|
8
9
|
export default LatexPreview;
|
|
10
|
+
declare const latexTypeName: "latex";
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
export interface LatexDefinition extends Omit<ObjectDefinition, 'type' | 'fields'> {
|
|
15
|
+
type: typeof latexTypeName;
|
|
16
|
+
}
|
|
17
|
+
declare module '@sanity/types' {
|
|
18
|
+
interface IntrinsicDefinitions {
|
|
19
|
+
latex: LatexDefinition;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export const latexSchema: {
|
|
23
|
+
type: "object";
|
|
24
|
+
name: "latex";
|
|
25
|
+
} & Omit<ObjectDefinition, "preview"> & {
|
|
26
|
+
preview?: import("sanity").PreviewConfig<{
|
|
27
|
+
body: string;
|
|
28
|
+
}, Record<"body", any>> | undefined;
|
|
29
|
+
};
|
|
9
30
|
export const latexInput: import("sanity").Plugin<void>;
|
|
10
31
|
|
|
11
32
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AAIA,wBAAwB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,gCAAgC;IAC9B,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA6BF,4BAA4B;
|
|
1
|
+
{"mappings":";AAIA,wBAAwB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,gCAAgC;IAC9B,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA6BF,4BAA4B;ACrC5B,QAAA,MAAM,sBAAgC,CAAC;AAEvC;;GAEG;AACH,gCACE,SAAQ,IAAI,CAAC,gBAAgB,EAAE,MAAM,GAAG,QAAQ,CAAC;IACjD,IAAI,EAAE,oBAAoB,CAAC;CAC5B;AAED,eAAe,eAAe,CAAC;IAE7B,UAAiB,oBAAoB;QACnC,KAAK,EAAE,eAAe,CAAC;KACxB;CACF;AAED,OAAO,MAAM;;;;;;;CAqBX,CAAC;AC9BH,OAAO,MAAM,yCAKX,CAAC","sources":["src/src/components/LatexPreview.tsx","src/src/schema.ts","src/src/index.tsx","src/index.tsx"],"sourcesContent":[null,null,null,"import LatexPreview, { LatexPreviewProps } from './components/LatexPreview';\nimport { createPlugin } from 'sanity';\nimport { latexSchema, LatexDefinition } from './schema';\n\nexport {\n LatexPreview,\n latexSchema,\n type LatexPreviewProps,\n type LatexDefinition,\n};\n\nexport const latexInput = createPlugin({\n name: 'latex-block-plugin',\n schema: {\n types: [latexSchema],\n },\n});\n"],"names":[],"version":3,"file":"index.d.ts.map","sourceRoot":"../../"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sanity-plugin-latex-input",
|
|
3
3
|
"author": "Sanity.io <hello@sanity.io>",
|
|
4
|
-
"version": "0.3.0-v3-studio.
|
|
4
|
+
"version": "0.3.0-v3-studio.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/sanity-io/
|
|
8
|
+
"url": "git+https://github.com/sanity-io/latex-input.git"
|
|
9
9
|
},
|
|
10
10
|
"source": "./src/index.tsx",
|
|
11
11
|
"exports": {
|
|
@@ -55,26 +55,27 @@
|
|
|
55
55
|
],
|
|
56
56
|
"homepage": "https://github.com/sanity-io/latex-input#readme",
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"react": "^
|
|
59
|
-
"react-dom": "^
|
|
58
|
+
"react": "^18.0.0",
|
|
59
|
+
"react-dom": "^18.0.0",
|
|
60
60
|
"sanity": "dev-preview",
|
|
61
61
|
"styled-components": "^5.3.5"
|
|
62
62
|
},
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@sanity/incompatible-plugin": "^
|
|
64
|
+
"@sanity/incompatible-plugin": "^1.0.4",
|
|
65
65
|
"@types/katex": "^0.11.0",
|
|
66
66
|
"@types/styled-components": "^5.1.25",
|
|
67
67
|
"katex": "^0.11.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@commitlint/cli": "^
|
|
71
|
-
"@commitlint/config-conventional": "^
|
|
70
|
+
"@commitlint/cli": "^17.1.2",
|
|
71
|
+
"@commitlint/config-conventional": "^17.1.0",
|
|
72
72
|
"@parcel/packager-ts": "^2.6.0",
|
|
73
73
|
"@parcel/transformer-typescript-types": "^2.6.0",
|
|
74
|
-
"@sanity/plugin-kit": "^
|
|
74
|
+
"@sanity/plugin-kit": "^1.1.0-ecosystem-preset.5",
|
|
75
|
+
"@sanity/semantic-release-preset": "^2.0.1",
|
|
75
76
|
"@types/jest": "^27.5.0",
|
|
76
|
-
"@types/react": "^
|
|
77
|
-
"@types/react-dom": "^
|
|
77
|
+
"@types/react": "^18.0.0",
|
|
78
|
+
"@types/react-dom": "^18.0.0",
|
|
78
79
|
"@typescript-eslint/eslint-plugin": "^5.12.0",
|
|
79
80
|
"@typescript-eslint/parser": "^5.12.0",
|
|
80
81
|
"eslint": "^8.7.0",
|
|
@@ -82,16 +83,16 @@
|
|
|
82
83
|
"eslint-config-sanity": "^5.1.0",
|
|
83
84
|
"eslint-plugin-prettier": "4.0.0",
|
|
84
85
|
"eslint-plugin-react": "^7.28.0",
|
|
85
|
-
"husky": "^
|
|
86
|
-
"lint-staged": "^
|
|
86
|
+
"husky": "^8.0.1",
|
|
87
|
+
"lint-staged": "^13.0.3",
|
|
87
88
|
"parcel": "^2.6.0",
|
|
88
89
|
"prettier": "^2.5.1",
|
|
89
|
-
"react": "^
|
|
90
|
-
"react-dom": "^
|
|
90
|
+
"react": "^18.0.0",
|
|
91
|
+
"react-dom": "^18.0.0",
|
|
91
92
|
"rimraf": "^3.0.2",
|
|
92
|
-
"sanity": "
|
|
93
|
+
"sanity": "3.0.0-dev-preview.21",
|
|
93
94
|
"standard-version": "^9.3.2",
|
|
94
95
|
"styled-components": "^5.3.5",
|
|
95
|
-
"typescript": "
|
|
96
|
+
"typescript": "4.7.4"
|
|
96
97
|
}
|
|
97
98
|
}
|
package/src/index.tsx
CHANGED
|
@@ -1,34 +1,17 @@
|
|
|
1
1
|
import LatexPreview, { LatexPreviewProps } from './components/LatexPreview';
|
|
2
|
-
import { createPlugin
|
|
2
|
+
import { createPlugin } from 'sanity';
|
|
3
|
+
import { latexSchema, LatexDefinition } from './schema';
|
|
3
4
|
|
|
4
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
LatexPreview,
|
|
7
|
+
latexSchema,
|
|
8
|
+
type LatexPreviewProps,
|
|
9
|
+
type LatexDefinition,
|
|
10
|
+
};
|
|
5
11
|
|
|
6
12
|
export const latexInput = createPlugin({
|
|
7
13
|
name: 'latex-block-plugin',
|
|
8
14
|
schema: {
|
|
9
|
-
types: [
|
|
10
|
-
defineType({
|
|
11
|
-
type: 'object',
|
|
12
|
-
name: 'latex',
|
|
13
|
-
components: {
|
|
14
|
-
preview: LatexPreview,
|
|
15
|
-
},
|
|
16
|
-
fields: [
|
|
17
|
-
{
|
|
18
|
-
title: 'LaTeX content',
|
|
19
|
-
name: 'body',
|
|
20
|
-
type: 'text',
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
preview: {
|
|
24
|
-
select: {
|
|
25
|
-
body: 'body',
|
|
26
|
-
},
|
|
27
|
-
prepare(selection: PreviewValue) {
|
|
28
|
-
return selection;
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
}),
|
|
32
|
-
],
|
|
15
|
+
types: [latexSchema],
|
|
33
16
|
},
|
|
34
17
|
});
|
package/src/schema.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defineType, ObjectDefinition, type PreviewValue } from 'sanity';
|
|
2
|
+
import LatexPreview from './components/LatexPreview';
|
|
3
|
+
|
|
4
|
+
const latexTypeName = 'latex' as const;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export interface LatexDefinition
|
|
10
|
+
extends Omit<ObjectDefinition, 'type' | 'fields'> {
|
|
11
|
+
type: typeof latexTypeName;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '@sanity/types' {
|
|
15
|
+
// makes type: 'latex' narrow correctly when using defineType/defineField/defineArrayMember
|
|
16
|
+
export interface IntrinsicDefinitions {
|
|
17
|
+
latex: LatexDefinition;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const latexSchema = defineType({
|
|
22
|
+
type: 'object',
|
|
23
|
+
name: 'latex',
|
|
24
|
+
components: {
|
|
25
|
+
preview: LatexPreview,
|
|
26
|
+
},
|
|
27
|
+
fields: [
|
|
28
|
+
{
|
|
29
|
+
title: 'LaTeX content',
|
|
30
|
+
name: 'body',
|
|
31
|
+
type: 'text',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
preview: {
|
|
35
|
+
select: {
|
|
36
|
+
body: 'body',
|
|
37
|
+
},
|
|
38
|
+
prepare(selection) {
|
|
39
|
+
return selection as unknown as PreviewValue;
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
});
|