md-editor-rt
Version:
Markdown editor for react, developed in jsx and typescript, dark theme、beautify content by prettier、render articles directly、paste or clip the picture and upload it...
2 lines (1 loc) • 2.39 kB
JavaScript
const d=require("react/jsx-runtime"),a=require("react"),e=require("./chunks/config.cjs"),F=require("./chunks/context.cjs"),l=require("./chunks/hooks.cjs"),V=require("./chunks/index2.cjs"),i=require("./chunks/event-bus.cjs"),j=(o,n)=>{const{editorId:r}=o;a.useImperativeHandle(n,()=>({rerender(){i.bus.emit(r,i.RERENDER)}}),[r])},z=a.forwardRef((o,n)=>{const{value:r=o.modelValue||e.defaultProps.modelValue,onChange:u=e.defaultProps.onChange,theme:m=e.defaultProps.theme,className:v=e.defaultProps.className,showCodeRowNumber:c=e.defaultProps.showCodeRowNumber,previewTheme:f=e.defaultProps.previewTheme,noMermaid:I=e.defaultProps.noMermaid,noKatex:w=e.defaultProps.noKatex,onHtmlChanged:b=e.defaultProps.onHtmlChanged,onGetCatalog:C=e.defaultProps.onGetCatalog,sanitize:T=e.defaultProps.sanitize,mdHeadingId:R=e.defaultProps.mdHeadingId,noHighlight:E=e.defaultProps.noHighlight,noImgZoomIn:H=e.defaultProps.noImgZoomIn,language:h=e.defaultProps.language,sanitizeMermaid:M=e.defaultProps.sanitizeMermaid,codeFoldable:q=e.defaultProps.codeFoldable,autoFoldThreshold:N=e.defaultProps.autoFoldThreshold,codeTheme:g=e.defaultProps.codeTheme}=o,s=l.useEditorId(o),[t]=a.useState(()=>({editorId:s,noKatex:w,noMermaid:I,noHighlight:E})),P=a.useRef(null),[p,x]=l.useMdPreviewConfig(o);j(t,n),a.useEffect(()=>()=>{i.bus.clear(s)},[s]);const y=a.useMemo(()=>({editorId:t.editorId,tabWidth:2,theme:m,language:h,highlight:p,showCodeRowNumber:c,usedLanguageText:x,previewTheme:f,customIcon:o.customIcon||{},rootRef:P,disabled:!1,showToolbarName:!1,setting:{preview:!0,htmlPreview:!1,previewOnly:!1,pageFullscreen:!1,fullscreen:!1},updateSetting:()=>{},tableShape:[6,4],catalogVisible:!1,noUploadImg:!0,noPrettier:!0,codeTheme:g,defToolbars:[],floatingToolbars:[]}),[g,p,h,f,o.customIcon,c,t.editorId,m,x]);return d.jsx(F.EditorContext.Provider,{value:y,children:d.jsx("div",{id:t.editorId,className:V.classnames([e.prefix,v,o.theme==="dark"&&`${e.prefix}-dark`,`${e.prefix}-previewOnly`]),style:o.style,ref:P,children:d.jsx(l.ContentPreview,{modelValue:r,onChange:u,mdHeadingId:R,onHtmlChanged:b,onGetCatalog:C,sanitize:T,noMermaid:t.noMermaid,noHighlight:t.noHighlight,noKatex:t.noKatex,formatCopiedText:o.formatCopiedText,noImgZoomIn:H,previewOnly:!0,sanitizeMermaid:M,codeFoldable:q,autoFoldThreshold:N,onRemount:o.onRemount,noEcharts:o.noEcharts},"preview-only")})})});module.exports=z;
;