UNPKG

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...

103 lines (102 loc) 2.88 kB
import { jsx as s } from "react/jsx-runtime"; import { useImperativeHandle as y, forwardRef as F, useState as z, useRef as K, useEffect as V } from "react"; import { u as $, g as k, a as G } from "./chunks/ContentPreview.mjs"; import { c as O } from "./chunks/index3.mjs"; import { d as e, p as n } from "./chunks/config.mjs"; import { E as Z } from "./chunks/context.mjs"; import { b as g, g as j } from "./chunks/event-name.mjs"; const D = (o, r) => { const { editorId: a } = o; y(r, () => ({ rerender() { g.emit(a, j); } }), [a]); }, Q = F((o, r) => { const { value: a = o.modelValue || e.modelValue, onChange: l = e.onChange, theme: m = e.theme, className: c = e.className, showCodeRowNumber: h = e.showCodeRowNumber, previewTheme: f = e.previewTheme, noMermaid: I = e.noMermaid, noKatex: x = e.noKatex, onHtmlChanged: C = e.onHtmlChanged, onGetCatalog: v = e.onGetCatalog, sanitize: w = e.sanitize, mdHeadingId: p = e.mdHeadingId, noHighlight: R = e.noHighlight, noImgZoomIn: H = e.noImgZoomIn, language: b = e.language, sanitizeMermaid: E = e.sanitizeMermaid, codeFoldable: M = e.codeFoldable, autoFoldThreshold: P = e.autoFoldThreshold } = o, i = $(o), [t] = z(() => ({ editorId: i, noKatex: x, noMermaid: I, noHighlight: R })), u = K(null), [T, N, d] = k(o); return D(t, r), V(() => () => { g.clear(i); }, [i]), /* @__PURE__ */ s( Z.Provider, { value: { editorId: t.editorId, tabWidth: 2, theme: m, language: b, highlight: T, showCodeRowNumber: h, usedLanguageText: N, previewTheme: f, customIcon: o.customIcon || {}, rootRef: u, disabled: !1 }, children: /* @__PURE__ */ s( "div", { id: t.editorId, className: O([ n, c, m === "dark" && `${n}-dark`, d.fullscreen || d.pageFullscreen ? `${n}-fullscreen` : "", `${n}-previewOnly` ]), style: o.style, ref: u, children: /* @__PURE__ */ s( G, { modelValue: a, onChange: l, setting: d, mdHeadingId: p, onHtmlChanged: C, onGetCatalog: v, sanitize: w, noMermaid: t.noMermaid, noHighlight: t.noHighlight, noKatex: t.noKatex, formatCopiedText: o.formatCopiedText, noImgZoomIn: H, previewOnly: !0, sanitizeMermaid: E, codeFoldable: M, autoFoldThreshold: P, onRemount: o.onRemount }, "preview-only" ) } ) } ); }); export { Q as default };