sanity-plugin-latex-input 2.0.3 → 2.0.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Sanity.io
3
+ Copyright (c) 2024 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -27,7 +27,7 @@ yarn add sanity-plugin-latex-input
27
27
  Import and add the plugin to your studio config in sanity.config.ts (or .js):
28
28
 
29
29
  ```ts
30
- import { latexBlock } from "sanity-plugin-latex-input";
30
+ import { latexInput } from "sanity-plugin-latex-input";
31
31
 
32
32
  export default defineConfig({
33
33
  /* ... */
package/lib/index.esm.js CHANGED
@@ -1,2 +1 @@
1
- function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function t(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?e(Object(o),!0).forEach((function(e){r(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}import{defineType as n,definePlugin as o}from"sanity";import{jsx as i,Fragment as c}from"react/jsx-runtime";import{useState as p,useMemo as a}from"react";import l from"katex";import"katex/dist/katex.min.css";const s=e=>{const t=e.value&&e.value.body||"",r="inline"===e.layout,[n,o]=p("");return a((()=>{o(l.renderToString(t,{displayMode:!r,throwOnError:!1}))}),[t,r]),i(c,{children:i(r?"span":"div",{dangerouslySetInnerHTML:{__html:n}})})},b=n(t(t({type:"object",name:"latex"},{components:{preview:s}}),{},{fields:[{title:"LaTeX content",name:"body",type:"text"}],preview:{select:{body:"body"},prepare:e=>e}})),u=o({name:"latex-block-plugin",schema:{types:[b]}});export{s as LatexPreview,u as latexInput,b as latexSchema};
2
- //# sourceMappingURL=index.esm.js.map
1
+ import{defineType as e,definePlugin as t}from"sanity";import{jsx as o,Fragment as r}from"react/jsx-runtime";import{useState as n,useMemo as i}from"react";import a from"katex";import"katex/dist/katex.min.css";const m=e=>{const t=(null==e?void 0:e.body)||"",m="inline"===e.layout,[l,p]=n("");return i((()=>{p(a.renderToString(t,{displayMode:!m,throwOnError:!1}))}),[t,m]),o(r,{children:o(m?"span":"div",{dangerouslySetInnerHTML:{__html:l}})})},l=e({type:"object",name:"latex",components:{preview:m},fields:[{title:"LaTeX content",name:"body",type:"text"}],preview:{select:{body:"body"}}}),p=t({name:"latex-block-plugin",schema:{types:[l]}});export{m as LatexPreview,p as latexInput,l as latexSchema};//# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/components/LatexPreview.tsx","../src/schema.ts","../src/plugin.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react';\nimport KaTeX from 'katex';\nimport 'katex/dist/katex.min.css';\n\ninterface SchemaDefinition {\n body?: string;\n}\n\nexport interface LatexPreviewProps {\n value?: SchemaDefinition;\n layout?: string;\n}\n\nexport const 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","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: { preview: LatexPreview } } as {}), //TODO revert this change when rc.1 is released\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","import { definePlugin } from 'sanity';\nimport { latexSchema } from './schema';\n\nexport const latexInput = definePlugin({\n name: 'latex-block-plugin',\n schema: {\n types: [latexSchema],\n },\n});\n"],"names":["LatexPreview","props","latex","value","body","isInline","layout","html","setHtml","useState","useMemo","KaTeX","renderToString","displayMode","throwOnError","jsx","Fragment","children","dangerouslySetInnerHTML","__html","latexSchema","defineType","_objectSpread","type","name","components","preview","fields","title","select","prepare","selection","latexInput","definePlugin","schema","types"],"mappings":"u4BAaa,MAAAA,EAAgBC,IAC3B,MAAMC,EAASD,EAAME,OAASF,EAAME,MAAMC,MAAS,GAC7CC,EAA4B,WAAjBJ,EAAMK,QAChBC,EAAMC,GAAWC,EAAiB,IAYvC,OAFFC,GATmB,KACjBF,EACEG,EAAMC,eAAeV,EAAO,CAC1BW,aAAcR,EACdS,cAAc,IAElB,GAGkB,CAACZ,EAAOG,IAE1BU,EAAAC,EAAA,CACGC,SAEEF,IAAA,OAGA,MAHA,CAAKG,wBAAyB,CAAEC,OAAQZ,MAK7C,EChBSa,EAAcC,EAAWC,EAAAA,EAAA,CACpCC,KAAM,SACNC,KAAM,SACF,CAAEC,WAAY,CAAEC,QAAS1B,KAAe,CAAA,EAAA,CAC5C2B,OAAQ,CACN,CACEC,MAAO,gBACPJ,KAAM,OACND,KAAM,SAGVG,QAAS,CACPG,OAAQ,CACNzB,KAAM,QAER0B,QAAQC,GACCA,MCjCAC,EAAaC,EAAa,CACrCT,KAAM,qBACNU,OAAQ,CACNC,MAAO,CAACf"}
1
+ {"version":3,"file":"index.esm.js","sources":["../src/components/LatexPreview.tsx","../src/schema.ts","../src/plugin.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react';\nimport KaTeX from 'katex';\nimport 'katex/dist/katex.min.css';\n\nexport interface LatexPreviewProps {\n body?: string;\n layout?: string;\n}\n\nexport const LatexPreview = (props: LatexPreviewProps) => {\n const latex = props?.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","import { defineType, ObjectDefinition } 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: { preview: LatexPreview },\n fields: [\n {\n title: 'LaTeX content',\n name: 'body',\n type: 'text',\n },\n ],\n preview: {\n select: {\n body: 'body',\n },\n },\n});\n","import { definePlugin } from 'sanity';\nimport { latexSchema } from './schema';\n\nexport const latexInput = definePlugin({\n name: 'latex-block-plugin',\n schema: {\n types: [latexSchema],\n },\n});\n"],"names":["defineType","definePlugin","jsx","Fragment","useState","useMemo","KaTeX","LatexPreview","props","latex","body","isInline","layout","html","setHtml","createHtml","renderToString","displayMode","throwOnError","children","dangerouslySetInnerHTML","__html","latexSchema","type","name","components","preview","fields","title","select","latexInput","schema","types"],"mappings":"qBASaA,kBAAAC,MAAA,uBAAAC,cAAAC,MAAA,uCAAAC,aAAAC,MAAA,eAAAC,MAAA,cAAA,2BAAA,MAAAC,EAAgBC,IACrB,MAAAC,SAAQD,WAAOE,OAAQ,GACvBC,EAA4B,WAAjBH,EAAMI,QAChBC,EAAMC,GAAWV,EAAiB,IAWzC,OADAC,GATmBU,KACjBD,EACER,EAAMU,eAAeP,EAAO,CAC1BQ,aAAcN,EACdO,cAAc,IAElB,GAGkB,CAACT,EAAOE,IAGvBT,EAAAC,EAAA,CAAAgB,WAAAR,EAEE,OAGA,MAHK,CAAAS,wBAAyB,CAAEC,OAAQR,MAK7C,ECZSS,EAActB,EAAW,CACpCuB,KAAM,SACNC,KAAM,QACNC,WAAY,CAAEC,QAASnB,GACvBoB,OAAQ,CACN,CACEC,MAAO,gBACPJ,KAAM,OACND,KAAM,SAGVG,QAAS,CACPG,OAAQ,CACNnB,KAAM,WC9BCoB,EAAa7B,EAAa,CACrCuB,KAAM,qBACNO,OAAQ,CACNC,MAAO,CAACV,aAEXf,kBAAAuB,gBAAAR"}
package/lib/index.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";function e(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function t(t){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?e(Object(o),!0).forEach((function(e){r(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function r(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("sanity"),o=require("react/jsx-runtime"),i=require("react"),a=require("katex");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("katex/dist/katex.min.css");var u=c(a);const s=e=>{const t=e.value&&e.value.body||"",r="inline"===e.layout,[n,a]=i.useState("");return i.useMemo((()=>{a(u.default.renderToString(t,{displayMode:!r,throwOnError:!1}))}),[t,r]),o.jsx(o.Fragment,{children:r?o.jsx("span",{dangerouslySetInnerHTML:{__html:n}}):o.jsx("div",{dangerouslySetInnerHTML:{__html:n}})})},l=n.defineType(t(t({type:"object",name:"latex"},{components:{preview:s}}),{},{fields:[{title:"LaTeX content",name:"body",type:"text"}],preview:{select:{body:"body"},prepare:e=>e}})),p=n.definePlugin({name:"latex-block-plugin",schema:{types:[l]}});exports.LatexPreview=s,exports.latexInput=p,exports.latexSchema=l;
2
- //# sourceMappingURL=index.js.map
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("sanity"),t=require("react/jsx-runtime"),r=require("react"),n=require("katex");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("katex/dist/katex.min.css");var i=a(n);const o=e=>{const n=(null==e?void 0:e.body)||"",a="inline"===e.layout,[o,s]=r.useState("");return r.useMemo((()=>{s(i.default.renderToString(n,{displayMode:!a,throwOnError:!1}))}),[n,a]),t.jsx(t.Fragment,{children:a?t.jsx("span",{dangerouslySetInnerHTML:{__html:o}}):t.jsx("div",{dangerouslySetInnerHTML:{__html:o}})})},s=e.defineType({type:"object",name:"latex",components:{preview:o},fields:[{title:"LaTeX content",name:"body",type:"text"}],preview:{select:{body:"body"}}}),l=e.definePlugin({name:"latex-block-plugin",schema:{types:[s]}});exports.LatexPreview=o,exports.latexInput=l,exports.latexSchema=s;//# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/components/LatexPreview.tsx","../src/schema.ts","../src/plugin.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react';\nimport KaTeX from 'katex';\nimport 'katex/dist/katex.min.css';\n\ninterface SchemaDefinition {\n body?: string;\n}\n\nexport interface LatexPreviewProps {\n value?: SchemaDefinition;\n layout?: string;\n}\n\nexport const 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","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: { preview: LatexPreview } } as {}), //TODO revert this change when rc.1 is released\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","import { definePlugin } from 'sanity';\nimport { latexSchema } from './schema';\n\nexport const latexInput = definePlugin({\n name: 'latex-block-plugin',\n schema: {\n types: [latexSchema],\n },\n});\n"],"names":["LatexPreview","props","latex","value","body","isInline","layout","html","setHtml","useState","useMemo","KaTeX","renderToString","displayMode","throwOnError","jsx","Fragment","children","dangerouslySetInnerHTML","__html","latexSchema","defineType","_objectSpread","type","name","components","preview","fields","title","select","prepare","selection","latexInput","definePlugin","schema","types"],"mappings":"+8BAaa,MAAAA,EAAgBC,IAC3B,MAAMC,EAASD,EAAME,OAASF,EAAME,MAAMC,MAAS,GAC7CC,EAA4B,WAAjBJ,EAAMK,QAChBC,EAAMC,GAAWC,WAAiB,IAYvC,OAFFC,EAAAA,SATmB,KACjBF,EACEG,EAAA,QAAMC,eAAeV,EAAO,CAC1BW,aAAcR,EACdS,cAAc,IAElB,GAGkB,CAACZ,EAAOG,IAE1BU,EAAAA,IAAAC,EAAAA,SAAA,CACGC,WAEEF,EAAAA,IAAA,OAAA,CAAKG,wBAAyB,CAAEC,OAAQZ,KAGxCQ,EAAAA,IAAA,MAAA,CAAIG,wBAAyB,CAAEC,OAAQZ,MAE5C,EChBSa,EAAcC,EAAAA,WAAWC,EAAAA,EAAA,CACpCC,KAAM,SACNC,KAAM,SACF,CAAEC,WAAY,CAAEC,QAAS1B,KAAe,CAAA,EAAA,CAC5C2B,OAAQ,CACN,CACEC,MAAO,gBACPJ,KAAM,OACND,KAAM,SAGVG,QAAS,CACPG,OAAQ,CACNzB,KAAM,QAER0B,QAAQC,GACCA,MCjCAC,EAAaC,EAAAA,aAAa,CACrCT,KAAM,qBACNU,OAAQ,CACNC,MAAO,CAACf"}
1
+ {"version":3,"file":"index.js","sources":["../src/components/LatexPreview.tsx","../src/schema.ts","../src/plugin.tsx"],"sourcesContent":["import React, { useMemo, useState } from 'react';\nimport KaTeX from 'katex';\nimport 'katex/dist/katex.min.css';\n\nexport interface LatexPreviewProps {\n body?: string;\n layout?: string;\n}\n\nexport const LatexPreview = (props: LatexPreviewProps) => {\n const latex = props?.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","import { defineType, ObjectDefinition } 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: { preview: LatexPreview },\n fields: [\n {\n title: 'LaTeX content',\n name: 'body',\n type: 'text',\n },\n ],\n preview: {\n select: {\n body: 'body',\n },\n },\n});\n","import { definePlugin } from 'sanity';\nimport { latexSchema } from './schema';\n\nexport const latexInput = definePlugin({\n name: 'latex-block-plugin',\n schema: {\n types: [latexSchema],\n },\n});\n"],"names":["Object","defineProperty","exports","value","sanity","require","jsxRuntime","react","KaTeX","_interopDefaultCompat","e","default","KaTeX__default","LatexPreview","props","latex","body","isInline","layout","html","setHtml","useState","useMemo","createHtml","renderToString","displayMode","throwOnError","jsx","Fragment","children","dangerouslySetInnerHTML","__html","latexSchema","defineType","type","name","components","preview","fields","title","select","latexInput","definePlugin","schema","types"],"mappings":"AASa,aAAAA,OAAAC,eAAAC,QAAA,aAAA,CAAAC,OAAA,IAAA,IAAAC,EAAAC,QAAA,UAAAC,EAAAD,QAAA,qBAAAE,EAAAF,QAAA,SAAAG,EAAAH,QAAA,SAAA,SAAAI,EAAAC,GAAA,OAAAA,GAAA,iBAAAA,GAAA,YAAAA,EAAAA,EAAA,CAAAC,QAAAD,EAAA,CAAAL,QAAA,4BAAA,IAAAO,EAAAH,EAAAD,GAAA,MAAAK,EAAgBC,IACrB,MAAAC,SAAQD,WAAOE,OAAQ,GACvBC,EAA4B,WAAjBH,EAAMI,QAChBC,EAAMC,GAAWC,WAAiB,IAWzC,OADAC,EAAAA,SATmBC,KACjBH,EACEZ,EAAAG,QAAMa,eAAeT,EAAO,CAC1BU,aAAcR,EACdS,cAAc,IAElB,GAGkB,CAACX,EAAOE,IAGvBU,MAAAC,EAAAA,SAAA,CAAAC,SAAAZ,QAEE,OAAK,CAAAa,wBAAyB,CAAEC,OAAQZ,WAGxC,MAAI,CAAAW,wBAAyB,CAAEC,OAAQZ,MAE5C,ECZSa,EAAcC,EAAAA,WAAW,CACpCC,KAAM,SACNC,KAAM,QACNC,WAAY,CAAEC,QAASxB,GACvByB,OAAQ,CACN,CACEC,MAAO,gBACPJ,KAAM,OACND,KAAM,SAGVG,QAAS,CACPG,OAAQ,CACNxB,KAAM,WC9BCyB,EAAaC,eAAa,CACrCP,KAAM,qBACNQ,OAAQ,CACNC,MAAO,CAACZ,MAEX9B,QAAAW,aAAAA,EAAAX,QAAAuC,WAAAA,EAAAvC,QAAA8B,YAAAA"}
@@ -1,8 +1,7 @@
1
- /// <reference types="react" />
2
-
3
1
  import { ObjectDefinition } from 'sanity';
4
2
  import { Plugin as Plugin_2 } from 'sanity';
5
3
  import { PreviewConfig } from 'sanity';
4
+ import { default as React_2 } from 'react';
6
5
 
7
6
  /**
8
7
  * @public
@@ -14,10 +13,12 @@ export declare interface LatexDefinition
14
13
 
15
14
  export declare const latexInput: Plugin_2<void>;
16
15
 
17
- export declare const LatexPreview: (props: LatexPreviewProps) => JSX.Element;
16
+ export declare const LatexPreview: (
17
+ props: LatexPreviewProps
18
+ ) => React_2.JSX.Element;
18
19
 
19
20
  export declare interface LatexPreviewProps {
20
- value?: SchemaDefinition;
21
+ body?: string;
21
22
  layout?: string;
22
23
  }
23
24
 
@@ -37,14 +38,10 @@ export declare const latexSchema: {
37
38
 
38
39
  declare const latexTypeName: 'latex';
39
40
 
40
- declare interface SchemaDefinition {
41
- body?: string;
42
- }
43
-
44
41
  export {};
45
42
 
46
43
  declare module '@sanity/types' {
47
- interface IntrinsicDefinitions {
48
- latex: LatexDefinition;
49
- }
50
- }
44
+ interface IntrinsicDefinitions {
45
+ latex: LatexDefinition;
46
+ }
47
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity-plugin-latex-input",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "Latex input for Portable Text Editor in Sanity Studio V3.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -58,15 +58,14 @@
58
58
  },
59
59
  "dependencies": {
60
60
  "@sanity/incompatible-plugin": "^1.0.4",
61
- "@types/katex": "^0.11.0",
62
- "@types/styled-components": "^5.1.25",
63
- "katex": "^0.11.1"
61
+ "@types/katex": "^0.16.0",
62
+ "katex": "^0.16.0"
64
63
  },
65
64
  "devDependencies": {
66
65
  "@commitlint/cli": "^17.2.0",
67
66
  "@commitlint/config-conventional": "^17.2.0",
68
- "@sanity/pkg-utils": "^1.17.2",
69
- "@sanity/plugin-kit": "^2.1.6",
67
+ "@sanity/pkg-utils": "^2.4.9",
68
+ "@sanity/plugin-kit": "^2.1.19",
70
69
  "@sanity/semantic-release-preset": "^2.0.2",
71
70
  "@types/jest": "^27.5.0",
72
71
  "@types/react": "^18",
@@ -86,16 +85,14 @@
86
85
  "react": "^18",
87
86
  "react-dom": "^18",
88
87
  "rimraf": "^3.0.2",
89
- "sanity": "^3.0.0",
88
+ "sanity": "^3.0.1",
90
89
  "standard-version": "^9.3.2",
91
- "styled-components": "^5.3.5",
92
90
  "typescript": "^4.8.4"
93
91
  },
94
92
  "peerDependencies": {
95
93
  "react": "^18",
96
94
  "react-dom": "^18",
97
- "sanity": "^3.0.0",
98
- "styled-components": "^5.3.5"
95
+ "sanity": "^3.0.0"
99
96
  },
100
97
  "engines": {
101
98
  "node": ">=14"
@@ -2,17 +2,13 @@ import React, { useMemo, useState } from 'react';
2
2
  import KaTeX from 'katex';
3
3
  import 'katex/dist/katex.min.css';
4
4
 
5
- interface SchemaDefinition {
6
- body?: string;
7
- }
8
-
9
5
  export interface LatexPreviewProps {
10
- value?: SchemaDefinition;
6
+ body?: string;
11
7
  layout?: string;
12
8
  }
13
9
 
14
10
  export const LatexPreview = (props: LatexPreviewProps) => {
15
- const latex = (props.value && props.value.body) || '';
11
+ const latex = props?.body || '';
16
12
  const isInline = props.layout === 'inline';
17
13
  const [html, setHtml] = useState<string>('');
18
14
  const createHtml = () => {
package/src/schema.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { defineType, ObjectDefinition, type PreviewValue } from 'sanity';
1
+ import { defineType, ObjectDefinition } from 'sanity';
2
2
  import { LatexPreview } from './components/LatexPreview';
3
3
 
4
4
  const latexTypeName = 'latex' as const;
@@ -21,7 +21,7 @@ declare module '@sanity/types' {
21
21
  export const latexSchema = defineType({
22
22
  type: 'object',
23
23
  name: 'latex',
24
- ...({ components: { preview: LatexPreview } } as {}), //TODO revert this change when rc.1 is released
24
+ components: { preview: LatexPreview },
25
25
  fields: [
26
26
  {
27
27
  title: 'LaTeX content',
@@ -33,8 +33,5 @@ export const latexSchema = defineType({
33
33
  select: {
34
34
  body: 'body',
35
35
  },
36
- prepare(selection) {
37
- return selection as unknown as PreviewValue;
38
- },
39
36
  },
40
37
  });