diff --git a/package.json b/package.json index bab0f9c69..a5bef089a 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "@types/koa": "^2.13.1", "@types/koa-mount": "^4.0.1", "@types/lodash": "^4.14.169", + "@types/marked": "^4.0.1", "@types/mockjs": "^1.0.3", "@types/node": "^12.6.8", "@types/react": "^17.0.0", diff --git a/packages/client/package.json b/packages/client/package.json index e2754cc11..b0b864232 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -33,7 +33,7 @@ "flat": "^5.0.2", "html-react-parser": "^1.2.7", "lodash": "^4.17.21", - "micromark": "~2.11.0", + "marked": "^4.0.5", "monaco-editor": "^0.25.2", "react-big-calendar": "^0.33.6", "react-helmet": "^6.1.0", diff --git a/packages/client/src/schemas/markdown/index.tsx b/packages/client/src/schemas/markdown/index.tsx index 98f07c613..ab133f2be 100644 --- a/packages/client/src/schemas/markdown/index.tsx +++ b/packages/client/src/schemas/markdown/index.tsx @@ -11,7 +11,6 @@ import { Button, Dropdown, Input as AntdInput, Menu, Modal, Space } from 'antd'; import { InputProps, TextAreaProps } from 'antd/lib/input'; import { Display } from '../display'; import { LoadingOutlined, MenuOutlined, DragOutlined } from '@ant-design/icons'; -import micromark from 'micromark'; import { useDesignable } from '../../components/schema-renderer'; import { useContext, useState } from 'react'; import AddNew from '../add-new'; @@ -23,6 +22,14 @@ import { isGridRowOrCol } from '../grid'; import './style.less'; import { DragHandle } from '../../components/Sortable'; import { useTranslation } from 'react-i18next'; +import { marked } from 'marked'; + +export function markdown(text) { + if (!text) { + return ''; + } + return marked.parse(text); +} export const Markdown: any = connect( AntdInput.TextArea, @@ -45,7 +52,7 @@ export const Markdown: any = connect( let value = (
); return ; @@ -93,7 +100,7 @@ Markdown.Void = observer((props: any) => { let value = (
); return field?.pattern !== 'readPretty' ? ( diff --git a/yarn.lock b/yarn.lock index 6b4e8d854..7dbc148f3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3884,6 +3884,11 @@ resolved "https://registry.npmmirror.com/@types/lodash/download/@types/lodash-4.14.176.tgz?cache=0&sync_timestamp=1634771944515&other_urls=https%3A%2F%2Fregistry.npmmirror.com%2F%40types%2Flodash%2Fdownload%2F%40types%2Flodash-4.14.176.tgz#641150fc1cda36fbfa329de603bbb175d7ee20c0" integrity sha1-ZBFQ/BzaNvv6Mp3mA7uxddfuIMA= +"@types/marked@^4.0.1": + version "4.0.1" + resolved "https://registry.npmjs.org/@types/marked/-/marked-4.0.1.tgz#d588a7bbc4d6551c5e75249bc106ffda96ae33c5" + integrity sha512-ZigEmCWdNUU7IjZEuQ/iaimYdDHWHfTe3kg8ORfKjyGYd9RWumPoOJRQXB0bO+XLkNwzCthW3wUIQtANaEZ1ag== + "@types/mathjax@^0.0.36": version "0.0.36" resolved "https://registry.nlark.com/@types/mathjax/download/@types/mathjax-0.0.36.tgz?cache=0&sync_timestamp=1629708335229&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fmathjax%2Fdownload%2F%40types%2Fmathjax-0.0.36.tgz#18cf766f88ac0cd4e7ee8282b1286049bb6aa682" @@ -13159,6 +13164,11 @@ markdown-table@^2.0.0: dependencies: repeat-string "^1.0.0" +marked@^4.0.5: + version "4.0.5" + resolved "https://registry.npmjs.org/marked/-/marked-4.0.5.tgz#85f46937f6a4616de7cbe0e1433e1640c320c729" + integrity sha512-eUToMA5d5lunnipkCN7zFD0RiunCF2Uo6bImEt/Qx8LZMW7oPXTw7R+f+M5V3eS7164HjEDPfW8/TrefuFhDfw== + mathjax-full@^3.0.0: version "3.2.0" resolved "https://registry.nlark.com/mathjax-full/download/mathjax-full-3.2.0.tgz#e53269842a943d4df10502937518991268996c5c"