sanity-plugin-markdown 3.0.1 → 4.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/index.esm.js CHANGED
@@ -1,2 +1,3 @@
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(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}import{jsx as r}from"react/jsx-runtime";import n from"@uiw/react-md-editor";import{useState as o,useEffect as a,forwardRef as i,useCallback as c}from"react";import{useClient as s,PatchEvent as l,unset as u,set as p,defineType as m,definePlugin as f}from"sanity";import{useTheme as d,Card as y}from"@sanity/ui";import b from"rehype-sanitize";const g=i((function(e,t){const{value:i="",onChange:m,elementProps:{onBlur:f,onFocus:g},readOnly:w}=e,[h,P]=o(i),j=function(e,t){const[r,n]=o(e);return a((()=>{const r=setTimeout((()=>{n(e)}),t);return()=>clearTimeout(r)}),[e,t]),r}(h,100),v=s({apiVersion:"2022-01-01"});a((()=>{P(i)}),[i]),a((()=>{!j&&i?m(l.from([u()])):j!==i&&m(l.from([p(j)]))}),[j,m]);const{sanity:k}=d(),D=c((async e=>{await O(e.clipboardData,P,v)}),[P,v]),E=c((async e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&await O(e.dataTransfer,P,v)}),[P,v]);return r("div",{ref:t,"data-color-mode":k.color.dark?"dark":"light",children:w?r(y,{border:!0,padding:3,children:r(n.Markdown,{source:i,rehypePlugins:[[b]]})}):r(n,{value:h,onChange:P,onBlur:f,onFocus:g,previewOptions:{rehypePlugins:[[b]]},preview:"edit",onPaste:D,onDrop:E})})}));async function O(e,t,r){const n=[];for(let t=0;t<e.items.length;t+=1){const r=e.files.item(t);r&&n.push(r)}await Promise.all(n.map((async e=>{const n=await r.assets.upload("image",e).then((e=>"".concat(e.url,"?w=450"))),o=function(e){const t=document.querySelector("textarea");if(!t)return null;let r=t.value;const n=r.length,o=t.selectionStart,a=t.selectionEnd,i=r.slice(0,o),c=r.slice(o,n);return r=i+e+c,t.value=r,t.selectionEnd=a+e.length,r}("![](".concat(n,")"));o&&t(o)})))}const w=m(function(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?e(Object(o),!0).forEach((function(e){t(r,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}({type:"string",name:"markdown",title:"Markdown"},{components:{input:g}})),h=g,P=f({name:"markdown-editor",schema:{types:[w]}});export{h as MarkdownEditor,P as markdownSchema,w as markdownSchemaType};
1
+ import 'easymde/dist/easymde.min.css';
2
+ export { MarkdownInput, defaultMdeTools, markdownSchema, markdownSchemaType } from './_chunks/plugin-ca10aa4c.js';
2
3
  //# sourceMappingURL=index.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":["../src/components/Editor.tsx","../src/hooks/useDebounce.ts","../src/schema.ts","../src/index.ts"],"sourcesContent":["import MDEditor from '@uiw/react-md-editor'\nimport useDebounce from '../hooks/useDebounce'\nimport {PatchEvent, SanityClient, set, StringInputProps, unset, useClient} from 'sanity'\nimport React, {\n ClipboardEvent,\n forwardRef,\n Ref,\n SetStateAction,\n useCallback,\n useEffect,\n useState,\n DragEvent,\n} from 'react'\nimport {Card, useTheme} from '@sanity/ui'\nimport rehypeSanitize from 'rehype-sanitize'\n\nexport const MarkdownEditor = forwardRef(function MarkdownEditor(\n props: StringInputProps,\n ref: Ref<any>\n) {\n const {\n value = '',\n onChange,\n elementProps: {onBlur, onFocus},\n readOnly,\n } = props\n const [editedValue, setEditedValue] = useState<string | undefined>(value)\n const debouncedValue = useDebounce(editedValue, 100)\n // const client = useClient({apiVersion: '2021-03-25'})\n const client = useClient({apiVersion: '2022-01-01'})\n useEffect(() => {\n setEditedValue(value)\n }, [value])\n\n useEffect(() => {\n if (!debouncedValue && value) {\n onChange(PatchEvent.from([unset()]))\n } else if (debouncedValue !== value) {\n onChange(PatchEvent.from([set(debouncedValue)]))\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [debouncedValue, onChange])\n\n const {sanity: studioTheme} = useTheme()\n const onPaste = useCallback(\n async (event: ClipboardEvent<HTMLDivElement>) => {\n await onImagePasted(event.clipboardData, setEditedValue, client)\n },\n [setEditedValue, client]\n )\n\n const onDrop = useCallback(\n async (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault()\n event.stopPropagation()\n if (event.dataTransfer) {\n await onImagePasted(event.dataTransfer, setEditedValue, client)\n }\n },\n [setEditedValue, client]\n )\n\n return (\n <div ref={ref} data-color-mode={studioTheme.color.dark ? 'dark' : 'light'}>\n {readOnly ? (\n <Card border padding={3}>\n <MDEditor.Markdown source={value} rehypePlugins={[[rehypeSanitize]]} />\n </Card>\n ) : (\n <MDEditor\n value={editedValue}\n onChange={setEditedValue}\n onBlur={onBlur}\n onFocus={onFocus}\n previewOptions={{\n rehypePlugins: [[rehypeSanitize]],\n }}\n preview=\"edit\"\n onPaste={onPaste}\n onDrop={onDrop}\n />\n )}\n </div>\n )\n})\n\n// https://github.com/uiwjs/react-md-editor/issues/83#issuecomment-1185471844\nasync function onImagePasted(\n dataTransfer: DataTransfer,\n setMarkdown: (value: SetStateAction<string | undefined>) => void,\n client: SanityClient\n) {\n const files: File[] = []\n for (let index = 0; index < dataTransfer.items.length; index += 1) {\n const file = dataTransfer.files.item(index)\n\n if (file) {\n files.push(file)\n }\n }\n\n await Promise.all(\n files.map(async (file) => {\n const url = await client.assets.upload('image', file).then((doc) => `${doc.url}?w=450`)\n const insertedMarkdown = insertToTextArea(`![](${url})`)\n if (!insertedMarkdown) {\n return\n }\n setMarkdown(insertedMarkdown)\n })\n )\n}\n\nfunction insertToTextArea(insertString: string) {\n const textarea = document.querySelector('textarea')\n if (!textarea) {\n return null\n }\n\n let sentence = textarea.value\n const len = sentence.length\n const pos = textarea.selectionStart\n const end = textarea.selectionEnd\n\n const front = sentence.slice(0, pos)\n const back = sentence.slice(pos, len)\n\n sentence = front + insertString + back\n\n textarea.value = sentence\n textarea.selectionEnd = end + insertString.length\n\n return sentence\n}\n","import {useState, useEffect} from 'react'\n\nexport default function useDebounce(value: unknown, delay: number) {\n const [debouncedValue, setDebouncedValue] = useState(value)\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value)\n }, delay)\n\n return () => clearTimeout(handler)\n }, [value, delay])\n\n return debouncedValue\n}\n","import {defineType, StringDefinition} from 'sanity'\nimport {MarkdownEditor} from './components/Editor'\n\nconst markdownTypeName = 'markdown' as const\n\n/**\n * @public\n */\nexport interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {\n type: typeof markdownTypeName\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'markdown' narrow correctly when using defineType/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n markdown: MarkdownDefinition\n }\n}\n\nexport const markdownSchemaType = defineType({\n type: 'string',\n name: markdownTypeName,\n title: 'Markdown',\n ...({components: {input: MarkdownEditor}} as {}), //TODO revert when rc.1 ships\n})\n","import {MarkdownEditor as Editor} from './components/Editor'\nimport {definePlugin} from 'sanity'\nimport {markdownSchemaType, MarkdownDefinition} from './schema'\n\n// re-exporting MarkdownEditor directly explodes @parcel/transformer-typescript-types :shrug:\nconst MarkdownEditor = Editor\n\nexport {MarkdownEditor, markdownSchemaType}\nexport type {MarkdownDefinition}\n\nexport const markdownSchema = definePlugin({\n name: 'markdown-editor',\n schema: {\n types: [markdownSchemaType],\n },\n})\n"],"names":["MarkdownEditor","forwardRef","props","ref","value","onChange","elementProps","onBlur","onFocus","readOnly","editedValue","setEditedValue","useState","debouncedValue","delay","setDebouncedValue","useEffect","handler","setTimeout","clearTimeout","useDebounce","client","useClient","apiVersion","PatchEvent","from","unset","set","sanity","studioTheme","useTheme","onPaste","useCallback","async","onImagePasted","event","clipboardData","onDrop","preventDefault","stopPropagation","dataTransfer","jsx","color","dark","children","Card","border","padding","MDEditor","Markdown","source","rehypePlugins","rehypeSanitize","previewOptions","preview","setMarkdown","files","index","items","length","file","item","push","Promise","all","map","url","assets","upload","then","doc","insertedMarkdown","insertString","textarea","document","querySelector","sentence","len","pos","selectionStart","end","selectionEnd","front","slice","back","insertToTextArea","concat","markdownSchemaType","defineType","_objectSpread","type","name","title","components","input","Editor","markdownSchema","definePlugin","schema","types"],"mappings":"2qBAgBO,MAAMA,EAAiBC,GAAW,SACvCC,EACAC,GAEM,MAAAC,MACJA,EAAQ,GAAAC,SACRA,EACAC,cAAcC,OAACA,EAAAC,QAAQA,GAAOC,SAC9BA,GACEP,GACGQ,EAAaC,GAAkBC,EAA6BR,GAC7DS,ECzBgB,SAAYT,EAAgBU,GAClD,MAAOD,EAAgBE,GAAqBH,EAASR,GAS9C,OARPY,GAAU,KACF,MAAAC,EAAUC,YAAW,KACzBH,EAAkBX,EAAK,GACtBU,GAEI,MAAA,IAAMK,aAAaF,EAAO,GAChC,CAACb,EAAOU,IAEJD,CACT,CDcyBO,CAAYV,EAAa,KAE1CW,EAASC,EAAU,CAACC,WAAY,eACtCP,GAAU,KACRL,EAAeP,EAAK,GACnB,CAACA,IAEJY,GAAU,MACHH,GAAkBT,EACrBC,EAASmB,EAAWC,KAAK,CAACC,OACjBb,IAAmBT,GAC5BC,EAASmB,EAAWC,KAAK,CAACE,EAAId,KAChC,GAEC,CAACA,EAAgBR,IAEpB,MAAOuB,OAAQC,GAAeC,IACxBC,EAAUC,GACdC,gBACQC,EAAcC,EAAMC,cAAezB,EAAgBU,EAAM,GAEjE,CAACV,EAAgBU,IAGbgB,EAASL,GACbC,UACEE,EAAMG,iBACNH,EAAMI,kBACFJ,EAAMK,oBACFN,EAAcC,EAAMK,aAAc7B,EAAgBU,EAC1D,GAEF,CAACV,EAAgBU,IAGnB,OACGoB,EAAA,MAAA,CAAItC,MAAU,kBAAiB0B,EAAYa,MAAMC,KAAO,OAAS,QAC/DC,WACEH,EAAAI,EAAA,CAAKC,QAAM,EAACC,QAAS,EACpBH,SAAAH,EAACO,EAASC,SAAT,CAAkBC,OAAQ9C,EAAO+C,cAAe,CAAC,CAACC,QAGpDX,EAAAO,EAAA,CACC5C,MAAOM,EACPL,SAAUM,EACVJ,SACAC,UACA6C,eAAgB,CACdF,cAAe,CAAC,CAACC,KAEnBE,QAAQ,OACRvB,UACAM,YAKV,IAGAJ,eAAeC,EACbM,EACAe,EACAlC,GAEA,MAAMmC,EAAgB,GACtB,IAAA,IAASC,EAAQ,EAAGA,EAAQjB,EAAakB,MAAMC,OAAQF,GAAS,EAAG,CACjE,MAAMG,EAAOpB,EAAagB,MAAMK,KAAKJ,GAEjCG,GACFJ,EAAMM,KAAKF,EAEf,OAEMG,QAAQC,IACZR,EAAMS,KAAIhC,UACR,MAAMiC,QAAY7C,EAAO8C,OAAOC,OAAO,QAASR,GAAMS,MAAMC,aAAWA,EAAIJ,IAAW,YAChFK,EASZ,SAA0BC,GAClB,MAAAC,EAAWC,SAASC,cAAc,YACxC,IAAKF,EACI,OAAA,KAGT,IAAIG,EAAWH,EAASrE,MACxB,MAAMyE,EAAMD,EAASjB,OACfmB,EAAML,EAASM,eACfC,EAAMP,EAASQ,aAEfC,EAAQN,EAASO,MAAM,EAAGL,GAC1BM,EAAOR,EAASO,MAAML,EAAKD,GAO1B,OALPD,EAAWM,EAAQV,EAAeY,EAElCX,EAASrE,MAAQwE,EACRH,EAAAQ,aAAeD,EAAMR,EAAab,OAEpCiB,CACT,CA7B+BS,CAAiB,OAAAC,OAAOpB,EAAM,MAClDK,GAGLhB,EAAYgB,EAAgB,IAGlC,CE5GA,MAgBagB,EAAqBC,iWAAWC,CAAA,CAC3CC,KAAM,SACNC,KAlBuB,WAmBvBC,MAAO,YACH,CAACC,WAAY,CAACC,MAAO9F,MClBrBA,EAAiB+F,EAKVC,EAAiBC,EAAa,CACzCN,KAAM,kBACNO,OAAQ,CACNC,MAAO,CAACZ"}
1
+ {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
package/lib/index.js CHANGED
@@ -1,2 +1,12 @@
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(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 r=require("react/jsx-runtime"),n=require("@uiw/react-md-editor"),o=require("react"),a=require("sanity"),i=require("@sanity/ui"),c=require("rehype-sanitize");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(n),l=s(c);const f=o.forwardRef((function(e,t){const{value:n="",onChange:c,elementProps:{onBlur:s,onFocus:f},readOnly:p}=e,[y,m]=o.useState(n),b=function(e,t){const[r,n]=o.useState(e);return o.useEffect((()=>{const r=setTimeout((()=>{n(e)}),t);return()=>clearTimeout(r)}),[e,t]),r}(y,100),h=a.useClient({apiVersion:"2022-01-01"});o.useEffect((()=>{m(n)}),[n]),o.useEffect((()=>{!b&&n?c(a.PatchEvent.from([a.unset()])):b!==n&&c(a.PatchEvent.from([a.set(b)]))}),[b,c]);const{sanity:w}=i.useTheme(),g=o.useCallback((async e=>{await d(e.clipboardData,m,h)}),[m,h]),O=o.useCallback((async e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&await d(e.dataTransfer,m,h)}),[m,h]);return r.jsx("div",{ref:t,"data-color-mode":w.color.dark?"dark":"light",children:p?r.jsx(i.Card,{border:!0,padding:3,children:r.jsx(u.default.Markdown,{source:n,rehypePlugins:[[l.default]]})}):r.jsx(u.default,{value:y,onChange:m,onBlur:s,onFocus:f,previewOptions:{rehypePlugins:[[l.default]]},preview:"edit",onPaste:g,onDrop:O})})}));async function d(e,t,r){const n=[];for(let t=0;t<e.items.length;t+=1){const r=e.files.item(t);r&&n.push(r)}await Promise.all(n.map((async e=>{const n=await r.assets.upload("image",e).then((e=>"".concat(e.url,"?w=450"))),o=function(e){const t=document.querySelector("textarea");if(!t)return null;let r=t.value;const n=r.length,o=t.selectionStart,a=t.selectionEnd,i=r.slice(0,o),c=r.slice(o,n);return r=i+e+c,t.value=r,t.selectionEnd=a+e.length,r}("![](".concat(n,")"));o&&t(o)})))}const p=a.defineType(function(r){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?e(Object(o),!0).forEach((function(e){t(r,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(o)):e(Object(o)).forEach((function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(o,e))}))}return r}({type:"string",name:"markdown",title:"Markdown"},{components:{input:f}})),y=f,m=a.definePlugin({name:"markdown-editor",schema:{types:[p]}});exports.MarkdownEditor=y,exports.markdownSchema=m,exports.markdownSchemaType=p;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ });
6
+ require('easymde/dist/easymde.min.css');
7
+ var plugin = require('./_chunks/plugin-b7a179e6.js');
8
+ exports.MarkdownInput = plugin.MarkdownInput;
9
+ exports.defaultMdeTools = plugin.defaultMdeTools;
10
+ exports.markdownSchema = plugin.markdownSchema;
11
+ exports.markdownSchemaType = plugin.markdownSchemaType;
2
12
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/components/Editor.tsx","../src/hooks/useDebounce.ts","../src/schema.ts","../src/index.ts"],"sourcesContent":["import MDEditor from '@uiw/react-md-editor'\nimport useDebounce from '../hooks/useDebounce'\nimport {PatchEvent, SanityClient, set, StringInputProps, unset, useClient} from 'sanity'\nimport React, {\n ClipboardEvent,\n forwardRef,\n Ref,\n SetStateAction,\n useCallback,\n useEffect,\n useState,\n DragEvent,\n} from 'react'\nimport {Card, useTheme} from '@sanity/ui'\nimport rehypeSanitize from 'rehype-sanitize'\n\nexport const MarkdownEditor = forwardRef(function MarkdownEditor(\n props: StringInputProps,\n ref: Ref<any>\n) {\n const {\n value = '',\n onChange,\n elementProps: {onBlur, onFocus},\n readOnly,\n } = props\n const [editedValue, setEditedValue] = useState<string | undefined>(value)\n const debouncedValue = useDebounce(editedValue, 100)\n // const client = useClient({apiVersion: '2021-03-25'})\n const client = useClient({apiVersion: '2022-01-01'})\n useEffect(() => {\n setEditedValue(value)\n }, [value])\n\n useEffect(() => {\n if (!debouncedValue && value) {\n onChange(PatchEvent.from([unset()]))\n } else if (debouncedValue !== value) {\n onChange(PatchEvent.from([set(debouncedValue)]))\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [debouncedValue, onChange])\n\n const {sanity: studioTheme} = useTheme()\n const onPaste = useCallback(\n async (event: ClipboardEvent<HTMLDivElement>) => {\n await onImagePasted(event.clipboardData, setEditedValue, client)\n },\n [setEditedValue, client]\n )\n\n const onDrop = useCallback(\n async (event: DragEvent<HTMLDivElement>) => {\n event.preventDefault()\n event.stopPropagation()\n if (event.dataTransfer) {\n await onImagePasted(event.dataTransfer, setEditedValue, client)\n }\n },\n [setEditedValue, client]\n )\n\n return (\n <div ref={ref} data-color-mode={studioTheme.color.dark ? 'dark' : 'light'}>\n {readOnly ? (\n <Card border padding={3}>\n <MDEditor.Markdown source={value} rehypePlugins={[[rehypeSanitize]]} />\n </Card>\n ) : (\n <MDEditor\n value={editedValue}\n onChange={setEditedValue}\n onBlur={onBlur}\n onFocus={onFocus}\n previewOptions={{\n rehypePlugins: [[rehypeSanitize]],\n }}\n preview=\"edit\"\n onPaste={onPaste}\n onDrop={onDrop}\n />\n )}\n </div>\n )\n})\n\n// https://github.com/uiwjs/react-md-editor/issues/83#issuecomment-1185471844\nasync function onImagePasted(\n dataTransfer: DataTransfer,\n setMarkdown: (value: SetStateAction<string | undefined>) => void,\n client: SanityClient\n) {\n const files: File[] = []\n for (let index = 0; index < dataTransfer.items.length; index += 1) {\n const file = dataTransfer.files.item(index)\n\n if (file) {\n files.push(file)\n }\n }\n\n await Promise.all(\n files.map(async (file) => {\n const url = await client.assets.upload('image', file).then((doc) => `${doc.url}?w=450`)\n const insertedMarkdown = insertToTextArea(`![](${url})`)\n if (!insertedMarkdown) {\n return\n }\n setMarkdown(insertedMarkdown)\n })\n )\n}\n\nfunction insertToTextArea(insertString: string) {\n const textarea = document.querySelector('textarea')\n if (!textarea) {\n return null\n }\n\n let sentence = textarea.value\n const len = sentence.length\n const pos = textarea.selectionStart\n const end = textarea.selectionEnd\n\n const front = sentence.slice(0, pos)\n const back = sentence.slice(pos, len)\n\n sentence = front + insertString + back\n\n textarea.value = sentence\n textarea.selectionEnd = end + insertString.length\n\n return sentence\n}\n","import {useState, useEffect} from 'react'\n\nexport default function useDebounce(value: unknown, delay: number) {\n const [debouncedValue, setDebouncedValue] = useState(value)\n useEffect(() => {\n const handler = setTimeout(() => {\n setDebouncedValue(value)\n }, delay)\n\n return () => clearTimeout(handler)\n }, [value, delay])\n\n return debouncedValue\n}\n","import {defineType, StringDefinition} from 'sanity'\nimport {MarkdownEditor} from './components/Editor'\n\nconst markdownTypeName = 'markdown' as const\n\n/**\n * @public\n */\nexport interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {\n type: typeof markdownTypeName\n}\n\ndeclare module '@sanity/types' {\n // makes type: 'markdown' narrow correctly when using defineType/defineField/defineArrayMember\n export interface IntrinsicDefinitions {\n markdown: MarkdownDefinition\n }\n}\n\nexport const markdownSchemaType = defineType({\n type: 'string',\n name: markdownTypeName,\n title: 'Markdown',\n ...({components: {input: MarkdownEditor}} as {}), //TODO revert when rc.1 ships\n})\n","import {MarkdownEditor as Editor} from './components/Editor'\nimport {definePlugin} from 'sanity'\nimport {markdownSchemaType, MarkdownDefinition} from './schema'\n\n// re-exporting MarkdownEditor directly explodes @parcel/transformer-typescript-types :shrug:\nconst MarkdownEditor = Editor\n\nexport {MarkdownEditor, markdownSchemaType}\nexport type {MarkdownDefinition}\n\nexport const markdownSchema = definePlugin({\n name: 'markdown-editor',\n schema: {\n types: [markdownSchemaType],\n },\n})\n"],"names":["MarkdownEditor","forwardRef","props","ref","value","onChange","elementProps","onBlur","onFocus","readOnly","editedValue","setEditedValue","useState","debouncedValue","delay","setDebouncedValue","useEffect","handler","setTimeout","clearTimeout","useDebounce","client","useClient","apiVersion","PatchEvent","from","unset","set","sanity","studioTheme","useTheme","onPaste","useCallback","async","onImagePasted","event","clipboardData","onDrop","preventDefault","stopPropagation","dataTransfer","jsx","color","dark","children","Card","border","padding","MDEditor","Markdown","source","rehypePlugins","rehypeSanitize","previewOptions","preview","setMarkdown","files","index","items","length","file","item","push","Promise","all","map","url","assets","upload","then","doc","insertedMarkdown","insertString","textarea","document","querySelector","sentence","len","pos","selectionStart","end","selectionEnd","front","slice","back","insertToTextArea","concat","markdownSchemaType","defineType","_objectSpread","type","name","title","components","input","Editor","markdownSchema","definePlugin","schema","types"],"mappings":"qpBAgBO,MAAMA,EAAiBC,EAAAA,YAAW,SACvCC,EACAC,GAEM,MAAAC,MACJA,EAAQ,GAAAC,SACRA,EACAC,cAAcC,OAACA,EAAAC,QAAQA,GAAOC,SAC9BA,GACEP,GACGQ,EAAaC,GAAkBC,WAA6BR,GAC7DS,ECzBgB,SAAYT,EAAgBU,GAClD,MAAOD,EAAgBE,GAAqBH,WAASR,GAS9C,OARPY,EAAAA,WAAU,KACF,MAAAC,EAAUC,YAAW,KACzBH,EAAkBX,EAAK,GACtBU,GAEI,MAAA,IAAMK,aAAaF,EAAO,GAChC,CAACb,EAAOU,IAEJD,CACT,CDcyBO,CAAYV,EAAa,KAE1CW,EAASC,EAAAA,UAAU,CAACC,WAAY,eACtCP,EAAAA,WAAU,KACRL,EAAeP,EAAK,GACnB,CAACA,IAEJY,EAAAA,WAAU,MACHH,GAAkBT,EACrBC,EAASmB,aAAWC,KAAK,CAACC,EAAAA,WACjBb,IAAmBT,GAC5BC,EAASmB,aAAWC,KAAK,CAACE,MAAId,KAChC,GAEC,CAACA,EAAgBR,IAEpB,MAAOuB,OAAQC,GAAeC,EAASA,WACjCC,EAAUC,EAAAA,aACdC,gBACQC,EAAcC,EAAMC,cAAezB,EAAgBU,EAAM,GAEjE,CAACV,EAAgBU,IAGbgB,EAASL,EAAAA,aACbC,UACEE,EAAMG,iBACNH,EAAMI,kBACFJ,EAAMK,oBACFN,EAAcC,EAAMK,aAAc7B,EAAgBU,EAC1D,GAEF,CAACV,EAAgBU,IAGnB,OACGoB,EAAAA,IAAA,MAAA,CAAItC,MAAU,kBAAiB0B,EAAYa,MAAMC,KAAO,OAAS,QAC/DC,WACEH,EAAAA,IAAAI,OAAA,CAAKC,QAAM,EAACC,QAAS,EACpBH,SAAAH,EAAAA,IAACO,UAASC,SAAT,CAAkBC,OAAQ9C,EAAO+C,cAAe,CAAC,CAACC,EAAAA,cAGpDX,EAAAA,IAAAO,UAAA,CACC5C,MAAOM,EACPL,SAAUM,EACVJ,SACAC,UACA6C,eAAgB,CACdF,cAAe,CAAC,CAACC,EAAAA,WAEnBE,QAAQ,OACRvB,UACAM,YAKV,IAGAJ,eAAeC,EACbM,EACAe,EACAlC,GAEA,MAAMmC,EAAgB,GACtB,IAAA,IAASC,EAAQ,EAAGA,EAAQjB,EAAakB,MAAMC,OAAQF,GAAS,EAAG,CACjE,MAAMG,EAAOpB,EAAagB,MAAMK,KAAKJ,GAEjCG,GACFJ,EAAMM,KAAKF,EAEf,OAEMG,QAAQC,IACZR,EAAMS,KAAIhC,UACR,MAAMiC,QAAY7C,EAAO8C,OAAOC,OAAO,QAASR,GAAMS,MAAMC,aAAWA,EAAIJ,IAAW,YAChFK,EASZ,SAA0BC,GAClB,MAAAC,EAAWC,SAASC,cAAc,YACxC,IAAKF,EACI,OAAA,KAGT,IAAIG,EAAWH,EAASrE,MACxB,MAAMyE,EAAMD,EAASjB,OACfmB,EAAML,EAASM,eACfC,EAAMP,EAASQ,aAEfC,EAAQN,EAASO,MAAM,EAAGL,GAC1BM,EAAOR,EAASO,MAAML,EAAKD,GAO1B,OALPD,EAAWM,EAAQV,EAAeY,EAElCX,EAASrE,MAAQwE,EACRH,EAAAQ,aAAeD,EAAMR,EAAab,OAEpCiB,CACT,CA7B+BS,CAAiB,OAAAC,OAAOpB,EAAM,MAClDK,GAGLhB,EAAYgB,EAAgB,IAGlC,CE5GA,MAgBagB,EAAqBC,EAAAA,0WAAWC,CAAA,CAC3CC,KAAM,SACNC,KAlBuB,WAmBvBC,MAAO,YACH,CAACC,WAAY,CAACC,MAAO9F,MClBrBA,EAAiB+F,EAKVC,EAAiBC,EAAAA,aAAa,CACzCN,KAAM,kBACNO,OAAQ,CACNC,MAAO,CAACZ"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,2 @@
1
+ export { MarkdownInput, defaultMdeTools, markdownSchema, markdownSchemaType } from './_chunks/plugin-ca10aa4c.js';
2
+ //# sourceMappingURL=indexNext.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexNext.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ });
6
+ var plugin = require('./_chunks/plugin-b7a179e6.js');
7
+ exports.MarkdownInput = plugin.MarkdownInput;
8
+ exports.defaultMdeTools = plugin.defaultMdeTools;
9
+ exports.markdownSchema = plugin.markdownSchema;
10
+ exports.markdownSchemaType = plugin.markdownSchemaType;
11
+ //# sourceMappingURL=indexNext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexNext.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sanity-plugin-markdown",
3
- "version": "3.0.1",
3
+ "version": "4.1.0",
4
4
  "description": "Markdown fields in Sanity Studio. Supports Github flavored Markdown and image uploads.",
5
5
  "keywords": [
6
6
  "sanity",
@@ -15,76 +15,95 @@
15
15
  },
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "https://github.com/sanity-io/sanity-plugin-markdown.git"
18
+ "url": "git@github.com:sanity-io/sanity-plugin-markdown.git"
19
19
  },
20
20
  "license": "MIT",
21
21
  "author": "Sanity.io <hello@sanity.io>",
22
22
  "exports": {
23
23
  ".": {
24
- "types": "./lib/src/index.d.ts",
24
+ "types": "./lib/index.d.ts",
25
25
  "source": "./src/index.ts",
26
- "import": "./lib/index.esm.js",
27
26
  "require": "./lib/index.js",
27
+ "import": "./lib/index.esm.js",
28
28
  "default": "./lib/index.esm.js"
29
29
  },
30
+ "./next": {
31
+ "types": "./lib/index.d.ts",
32
+ "source": "./src/indexNext.ts",
33
+ "require": "./lib/indexNext.js",
34
+ "import": "./lib/indexNext.esm.js",
35
+ "default": "./lib/indexNext.esm.js"
36
+ },
30
37
  "./package.json": "./package.json"
31
38
  },
32
39
  "main": "./lib/index.js",
33
40
  "module": "./lib/index.esm.js",
34
41
  "source": "./src/index.ts",
35
- "types": "./lib/src/index.d.ts",
42
+ "types": "./lib/index.d.ts",
43
+ "typesVersions": {
44
+ "*": {
45
+ "next": [
46
+ "./lib/index.d.ts"
47
+ ]
48
+ }
49
+ },
36
50
  "files": [
37
- "src",
38
51
  "lib",
39
- "v2-incompatible.js",
40
- "sanity.json"
52
+ "sanity.json",
53
+ "src",
54
+ "v2-incompatible.js"
41
55
  ],
42
56
  "scripts": {
43
57
  "prebuild": "npm run clean && plugin-kit verify-package --silent && pkg-utils",
44
- "build": "pkg-utils build --strict",
58
+ "build": "run-s clean && plugin-kit verify-package --silent && pkg-utils build --strict && pkg-utils --strict",
45
59
  "clean": "rimraf lib",
46
60
  "compile": "tsc --noEmit",
47
- "format": "prettier src -w",
61
+ "format": "prettier --write --cache --ignore-unknown .",
48
62
  "link-watch": "plugin-kit link-watch",
49
63
  "lint": "eslint .",
50
64
  "prepare": "husky install",
51
- "prepublishOnly": " npm run build",
52
- "watch": "pkg-utils watch"
65
+ "prepublishOnly": "run-s build",
66
+ "watch": "pkg-utils watch --strict"
53
67
  },
54
68
  "dependencies": {
55
69
  "@sanity/incompatible-plugin": "^1.0.4",
56
70
  "@sanity/ui": "^1.0.0",
57
- "@uiw/react-md-editor": "^3.19.7",
58
- "rehype-sanitize": "^5.0.1"
71
+ "react-simplemde-editor": "^5.2.0"
59
72
  },
60
73
  "devDependencies": {
61
74
  "@commitlint/cli": "^17.2.0",
62
75
  "@commitlint/config-conventional": "^17.2.0",
63
- "@sanity/pkg-utils": "^1.18.0",
64
- "@sanity/plugin-kit": "^2.1.16",
76
+ "@sanity/pkg-utils": "^2.2.6",
77
+ "@sanity/plugin-kit": "^3.1.7",
65
78
  "@sanity/semantic-release-preset": "^2.0.2",
79
+ "@types/react": "^18.0.26",
66
80
  "@types/styled-components": "^5.1.26",
67
- "@typescript-eslint/eslint-plugin": "^5.42.0",
68
- "@typescript-eslint/parser": "^5.42.0",
69
- "eslint": "^8.26.0",
70
- "eslint-config-prettier": "^8.5.0",
81
+ "@typescript-eslint/eslint-plugin": "^5.48.0",
82
+ "@typescript-eslint/parser": "^5.48.0",
83
+ "easymde": "^2.18.0",
84
+ "eslint": "^8.31.0",
85
+ "eslint-config-prettier": "^8.6.0",
71
86
  "eslint-config-sanity": "^6.0.0",
72
87
  "eslint-plugin-prettier": "^4.2.1",
73
- "eslint-plugin-react": "^7.31.10",
88
+ "eslint-plugin-react": "^7.31.11",
74
89
  "eslint-plugin-react-hooks": "^4.6.0",
75
90
  "husky": "^8.0.1",
76
91
  "lint-staged": "^13.0.3",
77
- "prettier": "^2.7.1",
92
+ "npm-run-all": "^4.1.5",
93
+ "prettier": "^2.8.1",
78
94
  "prettier-plugin-packagejson": "^2.3.0",
79
- "react": "^18",
95
+ "react": "^18.2.0",
96
+ "react-dom": "^18.2.0",
97
+ "react-is": "^18.2.0",
80
98
  "rimraf": "^3.0.2",
81
- "sanity": "^3.0.0",
99
+ "sanity": "^3.1.4",
82
100
  "styled-components": "^5.3.6",
83
- "typescript": "^4.8.4"
101
+ "typescript": "^4.9.4"
84
102
  },
85
103
  "peerDependencies": {
104
+ "easymde": "^2",
86
105
  "react": "^18",
87
- "sanity": "^3.0.0",
106
+ "sanity": "^3",
88
107
  "styled-components": "^5.2"
89
108
  },
90
109
  "engines": {
@@ -0,0 +1,4 @@
1
+ export {markdownSchemaType, type MarkdownDefinition} from './schema'
2
+ export {MarkdownInput, defaultMdeTools, type MarkdownInputProps} from './components/MarkdownInput'
3
+
4
+ export {markdownSchema, type MarkdownConfig} from './plugin'
@@ -0,0 +1,108 @@
1
+ import {type Options as EasyMdeOptions} from 'easymde'
2
+ import React, {Suspense, useCallback, useMemo} from 'react'
3
+ // dont import non-types here, it will break SSR on next
4
+ import type {SimpleMDEReactProps} from 'react-simplemde-editor'
5
+ import {PatchEvent, set, StringInputProps, unset, useClient} from 'sanity'
6
+ import {MarkdownOptions} from '../schema'
7
+ import {MarkdownInputStyles} from './MarkdownInputStyles'
8
+ import {useSimpleMdeReact} from './useSimpleMdeReact'
9
+ import {Box, Text} from '@sanity/ui'
10
+
11
+ export interface MarkdownInputProps extends StringInputProps {
12
+ /**
13
+ * These are passed along directly to
14
+ *
15
+ * Note: MarkdownInput sets certain reactMdeProps.options by default.
16
+ * These will be merged with any custom options.
17
+ * */
18
+ reactMdeProps?: Omit<SimpleMDEReactProps, 'value' | 'onChange'>
19
+ }
20
+
21
+ export const defaultMdeTools: EasyMdeOptions['toolbar'] = [
22
+ 'heading',
23
+ 'bold',
24
+ 'italic',
25
+ '|',
26
+ 'quote',
27
+ 'unordered-list',
28
+ 'ordered-list',
29
+ '|',
30
+ 'link',
31
+ 'image',
32
+ 'code',
33
+ '|',
34
+ 'preview',
35
+ 'side-by-side',
36
+ ]
37
+
38
+ export function MarkdownInput(props: MarkdownInputProps) {
39
+ const {
40
+ value = '',
41
+ onChange,
42
+ elementProps: {onBlur, onFocus, ref},
43
+ reactMdeProps: {options: mdeCustomOptions, ...reactMdeProps} = {},
44
+ schemaType,
45
+ } = props
46
+ const client = useClient({apiVersion: '2022-01-01'})
47
+ const {imageUrl} = (schemaType.options as MarkdownOptions | undefined) ?? {}
48
+
49
+ const imageUpload = useCallback(
50
+ (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => {
51
+ client.assets
52
+ .upload('image', file)
53
+ .then((doc) => onSuccess(imageUrl ? imageUrl(doc) : `${doc.url}?w=450`))
54
+ .catch((e) => {
55
+ console.error(e)
56
+ onError(e.message)
57
+ })
58
+ },
59
+ [client, imageUrl]
60
+ )
61
+
62
+ const mdeOptions: EasyMdeOptions = useMemo(() => {
63
+ return {
64
+ autofocus: false,
65
+ spellChecker: false,
66
+ sideBySideFullscreen: false,
67
+ uploadImage: true,
68
+ imageUploadFunction: imageUpload,
69
+ toolbar: defaultMdeTools,
70
+ status: false,
71
+ ...mdeCustomOptions,
72
+ }
73
+ }, [imageUpload, mdeCustomOptions])
74
+
75
+ const handleChange = useCallback(
76
+ (newValue: string) => {
77
+ onChange(PatchEvent.from(newValue ? set(newValue) : unset()))
78
+ },
79
+ [onChange]
80
+ )
81
+
82
+ const SimpleMdeReact = useSimpleMdeReact()
83
+
84
+ return (
85
+ <MarkdownInputStyles>
86
+ {SimpleMdeReact && (
87
+ <Suspense
88
+ fallback={
89
+ <Box padding={3}>
90
+ <Text>Loading editor...</Text>
91
+ </Box>
92
+ }
93
+ >
94
+ <SimpleMdeReact
95
+ {...reactMdeProps}
96
+ ref={ref}
97
+ value={value}
98
+ onChange={handleChange}
99
+ onBlur={onBlur}
100
+ onFocus={onFocus}
101
+ options={mdeOptions}
102
+ spellCheck={false}
103
+ />
104
+ </Suspense>
105
+ )}
106
+ </MarkdownInputStyles>
107
+ )
108
+ }
@@ -0,0 +1,61 @@
1
+ import styled from 'styled-components'
2
+ import {Box} from '@sanity/ui'
3
+
4
+ export const MarkdownInputStyles = styled(Box)`
5
+ & .CodeMirror.CodeMirror {
6
+ color: ${({theme}) => theme.sanity.color.card.enabled.fg};
7
+ border-color: ${({theme}) => theme.sanity.color.card.enabled.border};
8
+ background-color: inherit;
9
+ }
10
+
11
+ & .cm-s-easymde .CodeMirror-cursor {
12
+ border-color: ${({theme}) => theme.sanity.color.card.enabled.fg};
13
+ }
14
+
15
+ & .editor-toolbar,
16
+ .editor-preview-side {
17
+ border-color: ${({theme}) => theme.sanity.color.card.enabled.border};
18
+ }
19
+
20
+ & .CodeMirror-focused .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {
21
+ background-color: ${({theme}) => theme.sanity.color.selectable.primary.hovered.bg};
22
+ }
23
+
24
+ & .CodeMirror-selected.CodeMirror-selected.CodeMirror-selected {
25
+ background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};
26
+ }
27
+
28
+ & .editor-toolbar > * {
29
+ color: ${({theme}) => theme.sanity.color.card.enabled.fg};
30
+ }
31
+
32
+ & .editor-toolbar > .active,
33
+ .editor-toolbar > button:hover,
34
+ .editor-preview pre,
35
+ .cm-s-easymde .cm-comment {
36
+ background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};
37
+ }
38
+
39
+ & .editor-preview {
40
+ background-color: ${({theme}) => theme.sanity.color.card.enabled.bg};
41
+
42
+ & h1,
43
+ h2,
44
+ h3,
45
+ h4,
46
+ h5,
47
+ h6 {
48
+ font-size: revert;
49
+ }
50
+
51
+ & ul,
52
+ li {
53
+ list-style: revert;
54
+ padding: revert;
55
+ }
56
+
57
+ & a {
58
+ text-decoration: revert;
59
+ }
60
+ }
61
+ `
@@ -0,0 +1,12 @@
1
+ import {lazy, useEffect, useState} from 'react'
2
+
3
+ export const SimpleMdeReact = lazy(() => import('react-simplemde-editor'))
4
+
5
+ export function useSimpleMdeReact() {
6
+ const [mounted, setMounted] = useState(false)
7
+ useEffect(() => {
8
+ requestAnimationFrame(() => setMounted(true))
9
+ }, [])
10
+
11
+ return mounted ? SimpleMdeReact : null
12
+ }
package/src/index.ts CHANGED
@@ -1,16 +1,3 @@
1
- import {MarkdownEditor as Editor} from './components/Editor'
2
- import {definePlugin} from 'sanity'
3
- import {markdownSchemaType, MarkdownDefinition} from './schema'
1
+ import 'easymde/dist/easymde.min.css'
4
2
 
5
- // re-exporting MarkdownEditor directly explodes @parcel/transformer-typescript-types :shrug:
6
- const MarkdownEditor = Editor
7
-
8
- export {MarkdownEditor, markdownSchemaType}
9
- export type {MarkdownDefinition}
10
-
11
- export const markdownSchema = definePlugin({
12
- name: 'markdown-editor',
13
- schema: {
14
- types: [markdownSchemaType],
15
- },
16
- })
3
+ export * from './commonExports'
@@ -0,0 +1 @@
1
+ export * from './commonExports'
package/src/plugin.tsx ADDED
@@ -0,0 +1,54 @@
1
+ import {definePlugin, StringInputProps} from 'sanity'
2
+ import {markdownSchemaType} from './schema'
3
+ import {ReactElement} from 'react'
4
+
5
+ export interface MarkdownConfig {
6
+ /**
7
+ * When provided, will replace the default input component.
8
+ *
9
+ * Use this to customize MarkdownInput by wrapping it in a custom component,
10
+ * and provide any custom props for https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor
11
+ * via the `reactMdeProps` prop.
12
+ *
13
+ * ### Example
14
+ *
15
+ * ```tsx
16
+ * // CustomMarkdownInput.tsx
17
+ * import { MarkdownInput, MarkdownInputProps } from 'sanity-plugin-markdown'
18
+ *
19
+ * export function CustomMarkdownInput(props) {
20
+ * const reactMdeProps: MarkdownInputProps['reactMdeProps'] =
21
+ * useMemo(() => {
22
+ * return {
23
+ * options: {
24
+ * toolbar: ['bold', 'italic'],
25
+ * // more options available, see:
26
+ * // https://github.com/Ionaru/easy-markdown-editor#options-list
27
+ * },
28
+ * // more props available, see:
29
+ * // https://github.com/RIP21/react-simplemde-editor#react-simplemde-easymde-markdown-editor
30
+ * }
31
+ * }, [])
32
+ *
33
+ * return <MarkdownInput {...props} reactMdeProps={reactMdeProps} />
34
+ * }
35
+ *
36
+ * // studio.config.ts
37
+ * markdownSchema({input: CustomMarkdownInput})
38
+ * ```
39
+ */
40
+ input?: (props: StringInputProps) => ReactElement
41
+ }
42
+
43
+ export const markdownSchema = definePlugin((config: MarkdownConfig | void) => {
44
+ return {
45
+ name: 'markdown-editor',
46
+ schema: {
47
+ types: [
48
+ config && config.input
49
+ ? {...markdownSchemaType, components: {input: config.input}}
50
+ : markdownSchemaType,
51
+ ],
52
+ },
53
+ }
54
+ })
package/src/schema.ts CHANGED
@@ -1,13 +1,36 @@
1
1
  import {defineType, StringDefinition} from 'sanity'
2
- import {MarkdownEditor} from './components/Editor'
2
+ import {MarkdownInput} from './components/MarkdownInput'
3
+ import {SanityImageAssetDocument} from '@sanity/client'
3
4
 
4
- const markdownTypeName = 'markdown' as const
5
+ export const markdownTypeName = 'markdown' as const
6
+
7
+ export interface MarkdownOptions {
8
+ /**
9
+ * Used to create image url for any uploaded image.
10
+ * The function will be invoked whenever an image is pasted or dragged into the
11
+ * markdown editor, after upload completes.
12
+ *
13
+ * The default implementation uses
14
+ * ```js
15
+ * imageAsset => `${imageAsset.url}?w=450`
16
+ * ```
17
+ * ## Example
18
+ * ```js
19
+ * {
20
+ * imageUrl: imageAsset => `${imageAsset.url}?w=400&h=400`
21
+ * }
22
+ * ```
23
+ * @param imageAsset
24
+ */
25
+ imageUrl?: (imageAsset: SanityImageAssetDocument) => string
26
+ }
5
27
 
6
28
  /**
7
29
  * @public
8
30
  */
9
31
  export interface MarkdownDefinition extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {
10
32
  type: typeof markdownTypeName
33
+ options?: MarkdownOptions
11
34
  }
12
35
 
13
36
  declare module '@sanity/types' {
@@ -21,5 +44,5 @@ export const markdownSchemaType = defineType({
21
44
  type: 'string',
22
45
  name: markdownTypeName,
23
46
  title: 'Markdown',
24
- ...({components: {input: MarkdownEditor}} as {}), //TODO revert when rc.1 ships
47
+ components: {input: MarkdownInput},
25
48
  })
@@ -1,37 +0,0 @@
1
- /// <reference types="react" />
2
-
3
- import {ForwardRefExoticComponent} from 'react'
4
- import {Plugin as Plugin_2} from 'sanity'
5
- import {RefAttributes} from 'react'
6
- import {StringDefinition} from 'sanity'
7
- import {StringInputProps} from 'sanity'
8
- import {StringSchemaType} from 'sanity'
9
-
10
- /**
11
- * @public
12
- */
13
- export declare interface MarkdownDefinition
14
- extends Omit<StringDefinition, 'type' | 'fields' | 'options'> {
15
- type: typeof markdownTypeName
16
- }
17
-
18
- export declare const MarkdownEditor: ForwardRefExoticComponent<
19
- StringInputProps<StringSchemaType> & RefAttributes<any>
20
- >
21
-
22
- export declare const markdownSchema: Plugin_2<void>
23
-
24
- export declare const markdownSchemaType: {
25
- type: 'string'
26
- name: 'markdown'
27
- } & Omit<StringDefinition, 'preview'>
28
-
29
- declare const markdownTypeName: 'markdown'
30
-
31
- export {}
32
-
33
- declare module '@sanity/types' {
34
- interface IntrinsicDefinitions {
35
- markdown: MarkdownDefinition
36
- }
37
- }