sanity-plugin-latex-input 0.3.0-v3-studio.2 → 0.3.0-v3-studio.4

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 CHANGED
@@ -32,7 +32,7 @@ Import and add the plugin to your studio config in sanity.config.ts (or .js):
32
32
  ```ts
33
33
  import { latexBlock } from "sanity-plugin-latex-input";
34
34
 
35
- export default createConfig({
35
+ export default defineConfig({
36
36
  /* ... */
37
37
 
38
38
  plugins: [
@@ -0,0 +1,2 @@
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
@@ -0,0 +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"}
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
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
@@ -0,0 +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"}
@@ -0,0 +1,50 @@
1
+ /// <reference types="react" />
2
+
3
+ import { ObjectDefinition } from 'sanity';
4
+ import { Plugin as Plugin_2 } from 'sanity';
5
+ import { PreviewConfig } from 'sanity';
6
+
7
+ /**
8
+ * @public
9
+ */
10
+ export declare interface LatexDefinition
11
+ extends Omit<ObjectDefinition, 'type' | 'fields'> {
12
+ type: typeof latexTypeName;
13
+ }
14
+
15
+ export declare const latexInput: Plugin_2<void>;
16
+
17
+ export declare const LatexPreview: (props: LatexPreviewProps) => JSX.Element;
18
+
19
+ export declare interface LatexPreviewProps {
20
+ value?: SchemaDefinition;
21
+ layout?: string;
22
+ }
23
+
24
+ export declare const latexSchema: {
25
+ type: 'object';
26
+ name: 'latex';
27
+ } & Omit<ObjectDefinition, 'preview'> & {
28
+ preview?:
29
+ | PreviewConfig<
30
+ {
31
+ body: string;
32
+ },
33
+ Record<'body', any>
34
+ >
35
+ | undefined;
36
+ };
37
+
38
+ declare const latexTypeName: 'latex';
39
+
40
+ declare interface SchemaDefinition {
41
+ body?: string;
42
+ }
43
+
44
+ export {};
45
+
46
+ declare module '@sanity/types' {
47
+ interface IntrinsicDefinitions {
48
+ latex: LatexDefinition;
49
+ }
50
+ }
package/package.json CHANGED
@@ -1,22 +1,26 @@
1
1
  {
2
2
  "name": "sanity-plugin-latex-input",
3
+ "version": "0.3.0-v3-studio.4",
4
+ "description": "> **NOTE**",
3
5
  "author": "Sanity.io <hello@sanity.io>",
4
- "version": "0.3.0-v3-studio.2",
5
6
  "license": "MIT",
6
7
  "repository": {
7
8
  "type": "git",
8
- "url": "git+https://github.com/sanity-io/latex-input.git"
9
+ "url": "git@github.com:sanity-io/latex-input.git"
9
10
  },
10
- "source": "./src/index.tsx",
11
+ "source": "./src/index.ts",
11
12
  "exports": {
12
13
  ".": {
13
- "require": "./lib/cjs/index.js",
14
- "default": "./lib/esm/index.js"
14
+ "types": "./lib/src/index.d.ts",
15
+ "source": "./src/index.ts",
16
+ "import": "./lib/index.esm.js",
17
+ "require": "./lib/index.js",
18
+ "default": "./lib/index.esm.js"
15
19
  }
16
20
  },
17
- "main": "./lib/cjs/index.js",
18
- "module": "./lib/esm/index.js",
19
- "types": "./lib/types/index.d.ts",
21
+ "main": "./lib/index.js",
22
+ "module": "./lib/index.esm.js",
23
+ "types": "./lib/src/index.d.ts",
20
24
  "files": [
21
25
  "src",
22
26
  "lib",
@@ -28,9 +32,9 @@
28
32
  },
29
33
  "scripts": {
30
34
  "clean": "rimraf lib",
31
- "prebuild": "npm run clean && plugin-kit verify-package --silent",
32
- "build": "parcel build --no-cache",
33
- "watch": "parcel watch",
35
+ "prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils",
36
+ "build": "pkg-utils build",
37
+ "watch": "pkg-utils watch",
34
38
  "link-watch": "plugin-kit link-watch",
35
39
  "prepublishOnly": "npm run build",
36
40
  "compile": "tsc --noEmit",
@@ -46,7 +50,7 @@
46
50
  "trailingComma": "es5"
47
51
  },
48
52
  "bugs": {
49
- "url": "https://github.com/sanity-io/latex-input"
53
+ "url": "https://github.com/sanity-io/latex-input/issues"
50
54
  },
51
55
  "keywords": [
52
56
  "sanity",
@@ -57,7 +61,7 @@
57
61
  "peerDependencies": {
58
62
  "react": "^18.0.0",
59
63
  "react-dom": "^18.0.0",
60
- "sanity": "dev-preview",
64
+ "sanity": "dev-preview || 3.0.0-rc.0",
61
65
  "styled-components": "^5.3.5"
62
66
  },
63
67
  "dependencies": {
@@ -67,32 +71,31 @@
67
71
  "katex": "^0.11.1"
68
72
  },
69
73
  "devDependencies": {
70
- "@commitlint/cli": "^17.1.2",
71
- "@commitlint/config-conventional": "^17.1.0",
72
- "@parcel/packager-ts": "^2.6.0",
73
- "@parcel/transformer-typescript-types": "^2.6.0",
74
- "@sanity/plugin-kit": "^1.1.0-ecosystem-preset.5",
75
- "@sanity/semantic-release-preset": "^2.0.1",
74
+ "@commitlint/cli": "^17.2.0",
75
+ "@commitlint/config-conventional": "^17.2.0",
76
+ "@sanity/pkg-utils": "^1.16.2",
77
+ "@sanity/plugin-kit": "^2.0.7",
78
+ "@sanity/semantic-release-preset": "^2.0.2",
76
79
  "@types/jest": "^27.5.0",
77
80
  "@types/react": "^18.0.0",
78
81
  "@types/react-dom": "^18.0.0",
79
- "@typescript-eslint/eslint-plugin": "^5.12.0",
80
- "@typescript-eslint/parser": "^5.12.0",
81
- "eslint": "^8.7.0",
82
- "eslint-config-prettier": "^8.3.0",
83
- "eslint-config-sanity": "^5.1.0",
84
- "eslint-plugin-prettier": "4.0.0",
85
- "eslint-plugin-react": "^7.28.0",
82
+ "@typescript-eslint/eslint-plugin": "^5.42.0",
83
+ "@typescript-eslint/parser": "^5.42.0",
84
+ "eslint": "^8.26.0",
85
+ "eslint-config-prettier": "^8.5.0",
86
+ "eslint-config-sanity": "^6.0.0",
87
+ "eslint-plugin-prettier": "^4.2.1",
88
+ "eslint-plugin-react": "^7.31.10",
89
+ "eslint-plugin-react-hooks": "^4.6.0",
86
90
  "husky": "^8.0.1",
87
91
  "lint-staged": "^13.0.3",
88
- "parcel": "^2.6.0",
89
- "prettier": "^2.5.1",
92
+ "prettier": "^2.7.1",
90
93
  "react": "^18.0.0",
91
94
  "react-dom": "^18.0.0",
92
95
  "rimraf": "^3.0.2",
93
- "sanity": "3.0.0-dev-preview.21",
96
+ "sanity": "dev-preview || 3.0.0-rc.0",
94
97
  "standard-version": "^9.3.2",
95
98
  "styled-components": "^5.3.5",
96
- "typescript": "4.7.4"
99
+ "typescript": "^4.8.4"
97
100
  }
98
101
  }
@@ -2,16 +2,16 @@ import React, { useMemo, useState } from 'react';
2
2
  import KaTeX from 'katex';
3
3
  import 'katex/dist/katex.min.css';
4
4
 
5
- type SchemaDefinition = {
5
+ interface SchemaDefinition {
6
6
  body?: string;
7
- };
7
+ }
8
8
 
9
- export type LatexPreviewProps = {
9
+ export interface LatexPreviewProps {
10
10
  value?: SchemaDefinition;
11
11
  layout?: string;
12
- };
12
+ }
13
13
 
14
- const LatexPreview = (props: LatexPreviewProps) => {
14
+ export const LatexPreview = (props: LatexPreviewProps) => {
15
15
  const latex = (props.value && props.value.body) || '';
16
16
  const isInline = props.layout === 'inline';
17
17
  const [html, setHtml] = useState<string>('');
@@ -37,5 +37,3 @@ const LatexPreview = (props: LatexPreviewProps) => {
37
37
  </>
38
38
  );
39
39
  };
40
-
41
- export default LatexPreview;
package/src/index.ts ADDED
@@ -0,0 +1,8 @@
1
+ export { latexInput } from './plugin';
2
+
3
+ export {
4
+ LatexPreview,
5
+ type LatexPreviewProps,
6
+ } from './components/LatexPreview';
7
+
8
+ export { latexSchema, type LatexDefinition } from './schema';
package/src/plugin.tsx ADDED
@@ -0,0 +1,9 @@
1
+ import { definePlugin } from 'sanity';
2
+ import { latexSchema } from './schema';
3
+
4
+ export const latexInput = definePlugin({
5
+ name: 'latex-block-plugin',
6
+ schema: {
7
+ types: [latexSchema],
8
+ },
9
+ });
package/src/schema.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { defineType, ObjectDefinition, type PreviewValue } from 'sanity';
2
- import LatexPreview from './components/LatexPreview';
2
+ import { LatexPreview } from './components/LatexPreview';
3
3
 
4
4
  const latexTypeName = 'latex' as const;
5
5
 
@@ -21,9 +21,7 @@ declare module '@sanity/types' {
21
21
  export const latexSchema = defineType({
22
22
  type: 'object',
23
23
  name: 'latex',
24
- components: {
25
- preview: LatexPreview,
26
- },
24
+ ...({ components: { preview: LatexPreview } } as {}), //TODO revert this change when rc.1 is released
27
25
  fields: [
28
26
  {
29
27
  title: 'LaTeX content',
package/lib/cjs/index.js DELETED
@@ -1,90 +0,0 @@
1
- var $dyHF6$sanity = require("sanity");
2
- var $dyHF6$reactjsxruntime = require("react/jsx-runtime");
3
- var $dyHF6$react = require("react");
4
- var $dyHF6$katex = require("katex");
5
- require("katex/dist/katex.min.css");
6
-
7
- function $parcel$export(e, n, v, s) {
8
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
9
- }
10
- function $parcel$interopDefault(a) {
11
- return a && a.__esModule ? a.default : a;
12
- }
13
-
14
- $parcel$export(module.exports, "latexInput", () => $329a1cedcedb1349$export$17b0a661cd4afef9);
15
- $parcel$export(module.exports, "LatexPreview", () => $a18100092750648b$export$2e2bcd8739ae039);
16
- $parcel$export(module.exports, "latexSchema", () => $83686b2c306f69a9$export$23dad2d6284ed503);
17
-
18
-
19
-
20
-
21
- const $a18100092750648b$var$LatexPreview = (props)=>{
22
- const latex = props.value && props.value.body || "";
23
- const isInline = props.layout === "inline";
24
- const [html, setHtml] = (0, $dyHF6$react.useState)("");
25
- const createHtml = ()=>{
26
- setHtml((0, ($parcel$interopDefault($dyHF6$katex))).renderToString(latex, {
27
- displayMode: !isInline,
28
- throwOnError: false
29
- }));
30
- };
31
- (0, $dyHF6$react.useMemo)(createHtml, [
32
- latex,
33
- isInline
34
- ]);
35
- return /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)((0, $dyHF6$reactjsxruntime.Fragment), {
36
- children: isInline ? // eslint-disable-next-line react/no-danger
37
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("span", {
38
- dangerouslySetInnerHTML: {
39
- __html: html
40
- }
41
- }) : // eslint-disable-next-line react/no-danger
42
- /*#__PURE__*/ (0, $dyHF6$reactjsxruntime.jsx)("div", {
43
- dangerouslySetInnerHTML: {
44
- __html: html
45
- }
46
- })
47
- });
48
- };
49
- var $a18100092750648b$export$2e2bcd8739ae039 = $a18100092750648b$var$LatexPreview;
50
-
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
-
80
- const $329a1cedcedb1349$export$17b0a661cd4afef9 = (0, $dyHF6$sanity.createPlugin)({
81
- name: "latex-block-plugin",
82
- schema: {
83
- types: [
84
- (0, $83686b2c306f69a9$export$23dad2d6284ed503)
85
- ]
86
- }
87
- });
88
-
89
-
90
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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 DELETED
@@ -1,81 +0,0 @@
1
- import {createPlugin as $7XdDa$createPlugin, defineType as $7XdDa$defineType} from "sanity";
2
- import {jsx as $7XdDa$jsx, Fragment as $7XdDa$Fragment} from "react/jsx-runtime";
3
- import {useState as $7XdDa$useState, useMemo as $7XdDa$useMemo} from "react";
4
- import $7XdDa$katex from "katex";
5
- import "katex/dist/katex.min.css";
6
-
7
-
8
-
9
-
10
-
11
- const $7dfe52883a1c33dd$var$LatexPreview = (props)=>{
12
- const latex = props.value && props.value.body || "";
13
- const isInline = props.layout === "inline";
14
- const [html, setHtml] = (0, $7XdDa$useState)("");
15
- const createHtml = ()=>{
16
- setHtml((0, $7XdDa$katex).renderToString(latex, {
17
- displayMode: !isInline,
18
- throwOnError: false
19
- }));
20
- };
21
- (0, $7XdDa$useMemo)(createHtml, [
22
- latex,
23
- isInline
24
- ]);
25
- return /*#__PURE__*/ (0, $7XdDa$jsx)((0, $7XdDa$Fragment), {
26
- children: isInline ? // eslint-disable-next-line react/no-danger
27
- /*#__PURE__*/ (0, $7XdDa$jsx)("span", {
28
- dangerouslySetInnerHTML: {
29
- __html: html
30
- }
31
- }) : // eslint-disable-next-line react/no-danger
32
- /*#__PURE__*/ (0, $7XdDa$jsx)("div", {
33
- dangerouslySetInnerHTML: {
34
- __html: html
35
- }
36
- })
37
- });
38
- };
39
- var $7dfe52883a1c33dd$export$2e2bcd8739ae039 = $7dfe52883a1c33dd$var$LatexPreview;
40
-
41
-
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
-
70
- const $357f50a17451fe9f$export$17b0a661cd4afef9 = (0, $7XdDa$createPlugin)({
71
- name: "latex-block-plugin",
72
- schema: {
73
- types: [
74
- (0, $12cb8b58be9d76a6$export$23dad2d6284ed503)
75
- ]
76
- }
77
- });
78
-
79
-
80
- export {$357f50a17451fe9f$export$17b0a661cd4afef9 as latexInput, $7dfe52883a1c33dd$export$2e2bcd8739ae039 as LatexPreview, $12cb8b58be9d76a6$export$23dad2d6284ed503 as latexSchema};
81
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
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,eAAQ,CAAA,CAAS,EAAE,CAAC,AAAC;IAC7C,MAAM,UAAU,GAAG,IAAM;QACvB,OAAO,CACL,CAAA,GAAA,YAAK,CAAA,CAAC,cAAc,CAAC,KAAK,EAAE;YAC1B,WAAW,EAAE,CAAC,QAAQ;YACtB,YAAY,EAAE,KAAK;SACpB,CAAC,CACH,CAAC;KACH,AAAC;IAEF,CAAA,GAAA,cAAO,CAAA,CAAC,UAAU,EAAE;QAAC,KAAK;QAAE,QAAQ;KAAC,CAAC,CAAC;IACvC,qBACE;kBACG,QAAQ,GACP,2CAA2C;sBAC3C,gBAAC,MAAI;YAAC,uBAAuB,EAAE;gBAAE,MAAM,EAAE,IAAI;aAAE;UAAI,GAEnD,2CAA2C;sBAC3C,gBAAC,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,iBAAU,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,mBAAY,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":"../../"}
@@ -1,32 +0,0 @@
1
- import { ObjectDefinition } from "sanity";
2
- type SchemaDefinition = {
3
- body?: string;
4
- };
5
- export type LatexPreviewProps = {
6
- value?: SchemaDefinition;
7
- layout?: string;
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
- };
30
- export const latexInput: import("sanity").Plugin<void>;
31
-
32
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
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/src/index.tsx DELETED
@@ -1,17 +0,0 @@
1
- import LatexPreview, { LatexPreviewProps } from './components/LatexPreview';
2
- import { createPlugin } from 'sanity';
3
- import { latexSchema, LatexDefinition } from './schema';
4
-
5
- export {
6
- LatexPreview,
7
- latexSchema,
8
- type LatexPreviewProps,
9
- type LatexDefinition,
10
- };
11
-
12
- export const latexInput = createPlugin({
13
- name: 'latex-block-plugin',
14
- schema: {
15
- types: [latexSchema],
16
- },
17
- });