@uiw/react-md-editor 3.10.2 → 3.11.2

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.
Files changed (39) hide show
  1. package/README.md +36 -9
  2. package/dist/mdeditor.css +962 -321
  3. package/dist/mdeditor.js +43730 -57798
  4. package/dist/mdeditor.min.css +1 -1
  5. package/dist/mdeditor.min.js +1 -1
  6. package/esm/Editor.js +1 -1
  7. package/esm/Editor.js.map +2 -2
  8. package/esm/commands/code.js +4 -0
  9. package/esm/commands/code.js.map +2 -2
  10. package/esm/components/TextArea/Markdown.js +2 -3
  11. package/esm/components/TextArea/Markdown.js.map +2 -2
  12. package/esm/components/TextArea/index.css +17 -25
  13. package/esm/components/TextArea/index.less +17 -27
  14. package/esm/components/Toolbar/Child.css +2 -2
  15. package/esm/components/Toolbar/Child.less +3 -2
  16. package/esm/components/Toolbar/index.css +12 -12
  17. package/esm/components/Toolbar/index.less +12 -12
  18. package/esm/index.css +8 -5
  19. package/esm/index.less +9 -5
  20. package/lib/Editor.js +1 -1
  21. package/lib/Editor.js.map +2 -2
  22. package/lib/commands/code.js +4 -0
  23. package/lib/commands/code.js.map +2 -2
  24. package/lib/components/TextArea/Markdown.js +2 -3
  25. package/lib/components/TextArea/Markdown.js.map +2 -2
  26. package/lib/components/TextArea/index.less +17 -27
  27. package/lib/components/Toolbar/Child.less +3 -2
  28. package/lib/components/Toolbar/index.less +12 -12
  29. package/lib/index.less +9 -5
  30. package/markdown-editor.css +39 -44
  31. package/package.json +4 -3
  32. package/src/Editor.tsx +1 -0
  33. package/src/__test__/editor.test.tsx +1 -1
  34. package/src/commands/code.tsx +2 -0
  35. package/src/components/TextArea/Markdown.tsx +1 -2
  36. package/src/components/TextArea/index.less +17 -27
  37. package/src/components/Toolbar/Child.less +3 -2
  38. package/src/components/Toolbar/index.less +12 -12
  39. package/src/index.less +9 -5
package/lib/Editor.js.map CHANGED
@@ -89,8 +89,8 @@
89
89
  "Markdown",
90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AD,CAAR;AACD;AAPH,QAtCJ;AAAA;AADF,IADF;AAqDD,CArND;;AAuNA,IAAMC,QAAQ,gBAAGC,eAAMC,UAAN,CAA8C3E,gBAA9C,CAAjB;;AAMCyE,QAAD,CAAuBG,QAAvB,GAAkCC,6BAAlC;eAEeJ,Q",
93
93
  "sourcesContent": [
94
- "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';\nimport MarkdownPreview, { MarkdownPreviewProps, MarkdownPreviewRef } from '@uiw/react-markdown-preview';\nimport TextArea, { ITextAreaProps } from './components/TextArea';\nimport Toolbar from './components/Toolbar';\nimport DragBar from './components/DragBar';\nimport { getCommands, getExtraCommands, ICommand } from './commands';\nimport { reducer, EditorContext, ContextStore, PreviewType } from './Context';\nimport './index.less';\n\nexport interface IProps {\n prefixCls?: string;\n className?: string;\n}\n\nexport interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>, IProps {\n /**\n * The Markdown value.\n */\n value?: string;\n /**\n * Event handler for the `onChange` event.\n */\n onChange?: (value?: string) => void;\n /**\n * Can be used to make `Markdown Editor` focus itself on initialization. Defaults to on.\n * it will be set to true when either the source `textarea` is focused,\n * or it has an `autofocus` attribute and no other element is focused.\n */\n autoFocus?: ITextAreaProps['autoFocus'];\n /**\n * The height of the editor.\n */\n height?: number;\n /**\n * Custom toolbar heigth\n * @default 29px\n */\n toolbarHeight?: number;\n /**\n * Show drag and drop tool. Set the height of the editor.\n */\n visiableDragbar?: boolean;\n /**\n * Show markdown preview.\n */\n preview?: PreviewType;\n /**\n * Full screen display editor.\n */\n fullscreen?: boolean;\n /**\n * Disable `fullscreen` setting body styles\n */\n overflow?: boolean;\n /**\n * Maximum drag height. `visiableDragbar=true`\n */\n maxHeight?: number;\n /**\n * Minimum drag height. `visiableDragbar=true`\n */\n minHeight?: number;\n /**\n * This is reset [react-markdown](https://github.com/rexxars/react-markdown) settings.\n */\n previewOptions?: Omit<MarkdownPreviewProps, 'source'>;\n /**\n * Set the `textarea` related props.\n */\n textareaProps?: ITextAreaProps;\n /** Use div to replace TextArea or re-render TextArea */\n renderTextarea?: ITextAreaProps['renderTextarea'];\n /**\n * Disable editing area code highlighting. The value is `false`, which increases the editing speed.\n * @default true\n */\n highlightEnable?: boolean;\n /**\n * The number of characters to insert when pressing tab key.\n * Default `2` spaces.\n */\n tabSize?: number;\n /**\n * If `false`, the `tab` key inserts a tab character into the textarea. If `true`, the `tab` key executes default behavior e.g. focus shifts to next element.\n */\n defaultTabEnable?: boolean;\n /**\n * You can create your own commands or reuse existing commands.\n */\n commands?: ICommand[];\n /**\n * Filter or modify your commands.\n * https://github.com/uiwjs/react-md-editor/issues/296\n */\n commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand;\n /**\n * You can create your own commands or reuse existing commands.\n */\n extraCommands?: ICommand[];\n /**\n * Hide the tool bar\n */\n hideToolbar?: boolean;\n /** Whether to enable scrolling */\n enableScroll?: boolean;\n}\n\nfunction setGroupPopFalse(data: Record<string, boolean> = {}) {\n Object.keys(data).forEach((keyname) => {\n data[keyname] = false;\n });\n return data;\n}\n\nconst InternalMDEditor = (\n props: MDEditorProps,\n ref?: ((instance: ContextStore) => void) | React.RefObject<ContextStore> | null,\n) => {\n const {\n prefixCls = 'w-md-editor',\n className,\n value: propsValue,\n commands = getCommands(),\n commandsFilter,\n extraCommands = getExtraCommands(),\n height = 200,\n toolbarHeight = 29,\n enableScroll = true,\n visiableDragbar = true,\n highlightEnable = true,\n preview: previewType = 'live',\n fullscreen = false,\n overflow = true,\n previewOptions = {},\n textareaProps,\n maxHeight = 1200,\n minHeight = 100,\n autoFocus,\n tabSize = 2,\n defaultTabEnable = false,\n onChange,\n hideToolbar,\n renderTextarea,\n ...other\n } = props || {};\n const cmds = commands\n .map((item) => (commandsFilter ? commandsFilter(item, false) : item))\n .filter(Boolean) as ICommand[];\n const extraCmds = extraCommands\n .map((item) => (commandsFilter ? commandsFilter(item, true) : item))\n .filter(Boolean) as ICommand[];\n let [state, dispatch] = useReducer(reducer, {\n markdown: propsValue,\n preview: previewType,\n height,\n highlightEnable,\n tabSize,\n defaultTabEnable,\n scrollTop: 0,\n scrollTopPreview: 0,\n commands: cmds,\n extraCommands: extraCmds,\n fullscreen,\n barPopup: {},\n });\n const container = useRef<HTMLDivElement>(null);\n const previewRef = useRef<MarkdownPreviewRef>(null);\n const enableScrollRef = useRef(enableScroll);\n\n useImperativeHandle(ref, () => ({ ...state }));\n useMemo(() => (enableScrollRef.current = enableScroll), [enableScroll]);\n useEffect(() => {\n const stateInit: ContextStore = {};\n if (container.current) {\n stateInit.container = container.current || undefined;\n }\n stateInit.markdown = propsValue || '';\n stateInit.barPopup = {};\n if (dispatch) {\n dispatch({ ...state, ...stateInit });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const cls = [\n className,\n prefixCls,\n state.preview ? `${prefixCls}-show-${state.preview}` : null,\n state.fullscreen ? `${prefixCls}-fullscreen` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n useMemo(\n () => propsValue !== state.markdown && dispatch({ markdown: propsValue || '' }),\n [propsValue, state.markdown],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => previewType !== state.preview && dispatch({ preview: previewType }), [previewType]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => height !== state.height && dispatch({ height: height }), [height]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => tabSize !== state.tabSize && dispatch({ tabSize }), [tabSize]);\n useMemo(\n () => highlightEnable !== state.highlightEnable && dispatch({ highlightEnable }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [highlightEnable],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => autoFocus !== state.autoFocus && dispatch({ autoFocus: autoFocus }), [autoFocus]);\n useMemo(\n () => fullscreen !== state.fullscreen && dispatch({ fullscreen: fullscreen }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [fullscreen],\n );\n\n const textareaDomRef = useRef<HTMLDivElement>();\n const active = useRef<'text' | 'preview'>('preview');\n const initScroll = useRef(false);\n\n useMemo(() => {\n textareaDomRef.current = state.textareaWarp;\n if (state.textareaWarp) {\n state.textareaWarp.addEventListener('mouseover', () => {\n active.current = 'text';\n });\n state.textareaWarp.addEventListener('mouseleave', () => {\n active.current = 'preview';\n });\n }\n }, [state.textareaWarp]);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>, type: 'text' | 'preview') => {\n if (!enableScrollRef.current) return;\n const textareaDom = textareaDomRef.current;\n const previewDom = previewRef.current ? previewRef.current.mdp.current : undefined;\n if (!initScroll.current) {\n active.current = type;\n initScroll.current = true;\n }\n if (textareaDom && previewDom) {\n const scale =\n (textareaDom.scrollHeight - textareaDom.offsetHeight) / (previewDom.scrollHeight - previewDom.offsetHeight);\n if (e.target === textareaDom && active.current === 'text') {\n previewDom.scrollTop = textareaDom.scrollTop / scale;\n }\n if (e.target === previewDom && active.current === 'preview') {\n textareaDom.scrollTop = previewDom.scrollTop * scale;\n }\n let scrollTop = 0;\n if (active.current === 'text') {\n scrollTop = textareaDom.scrollTop || 0;\n } else if (active.current === 'preview') {\n scrollTop = previewDom.scrollTop || 0;\n }\n dispatch({ scrollTop });\n }\n };\n\n const mdPreview = useMemo(\n () => (\n <MarkdownPreview\n {...previewOptions}\n onScroll={(e) => handleScroll(e, 'preview')}\n ref={previewRef}\n source={state.markdown || ''}\n className={`${prefixCls}-preview ${previewOptions.className || ''}`}\n />\n ),\n [prefixCls, previewOptions, state.markdown],\n );\n\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div\n ref={container}\n className={cls}\n {...other}\n onClick={() => {\n dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n }}\n style={{\n ...other.style,\n height: state.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height,\n }}\n >\n {!hideToolbar && <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} />}\n <div\n className={`${prefixCls}-content`}\n style={{\n height: state.fullscreen ? `calc(100% - ${toolbarHeight}px)` : Number(state.height) - toolbarHeight,\n }}\n >\n {/(edit|live)/.test(state.preview || '') && (\n <TextArea\n className={`${prefixCls}-input`}\n prefixCls={prefixCls}\n autoFocus={autoFocus}\n {...textareaProps}\n onChange={(evn) => {\n onChange && onChange(evn.target.value);\n if (textareaProps && textareaProps.onChange) {\n textareaProps.onChange(evn);\n }\n }}\n renderTextarea={renderTextarea}\n onScroll={(e) => handleScroll(e, 'text')}\n />\n )}\n {/(live|preview)/.test(state.preview || '') && mdPreview}\n </div>\n {visiableDragbar && !state.fullscreen && (\n <DragBar\n prefixCls={prefixCls}\n height={state.height as number}\n maxHeight={maxHeight!}\n minHeight={minHeight!}\n onChange={(newHeight) => {\n dispatch({ height: newHeight });\n }}\n />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\nconst mdEditor = React.forwardRef<ContextStore, MDEditorProps>(InternalMDEditor);\n\ntype MDEditor = typeof mdEditor & {\n Markdown: typeof MarkdownPreview;\n};\n\n(mdEditor as MDEditor).Markdown = MarkdownPreview;\n\nexport default mdEditor as MDEditor;\n"
94
+ "import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';\nimport MarkdownPreview, { MarkdownPreviewProps, MarkdownPreviewRef } from '@uiw/react-markdown-preview';\nimport TextArea, { ITextAreaProps } from './components/TextArea';\nimport Toolbar from './components/Toolbar';\nimport DragBar from './components/DragBar';\nimport { getCommands, getExtraCommands, ICommand } from './commands';\nimport { reducer, EditorContext, ContextStore, PreviewType } from './Context';\nimport './index.less';\n\nexport interface IProps {\n prefixCls?: string;\n className?: string;\n}\n\nexport interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'>, IProps {\n /**\n * The Markdown value.\n */\n value?: string;\n /**\n * Event handler for the `onChange` event.\n */\n onChange?: (value?: string) => void;\n /**\n * Can be used to make `Markdown Editor` focus itself on initialization. Defaults to on.\n * it will be set to true when either the source `textarea` is focused,\n * or it has an `autofocus` attribute and no other element is focused.\n */\n autoFocus?: ITextAreaProps['autoFocus'];\n /**\n * The height of the editor.\n */\n height?: number;\n /**\n * Custom toolbar heigth\n * @default 29px\n */\n toolbarHeight?: number;\n /**\n * Show drag and drop tool. Set the height of the editor.\n */\n visiableDragbar?: boolean;\n /**\n * Show markdown preview.\n */\n preview?: PreviewType;\n /**\n * Full screen display editor.\n */\n fullscreen?: boolean;\n /**\n * Disable `fullscreen` setting body styles\n */\n overflow?: boolean;\n /**\n * Maximum drag height. `visiableDragbar=true`\n */\n maxHeight?: number;\n /**\n * Minimum drag height. `visiableDragbar=true`\n */\n minHeight?: number;\n /**\n * This is reset [react-markdown](https://github.com/rexxars/react-markdown) settings.\n */\n previewOptions?: Omit<MarkdownPreviewProps, 'source'>;\n /**\n * Set the `textarea` related props.\n */\n textareaProps?: ITextAreaProps;\n /** Use div to replace TextArea or re-render TextArea */\n renderTextarea?: ITextAreaProps['renderTextarea'];\n /**\n * Disable editing area code highlighting. The value is `false`, which increases the editing speed.\n * @default true\n */\n highlightEnable?: boolean;\n /**\n * The number of characters to insert when pressing tab key.\n * Default `2` spaces.\n */\n tabSize?: number;\n /**\n * If `false`, the `tab` key inserts a tab character into the textarea. If `true`, the `tab` key executes default behavior e.g. focus shifts to next element.\n */\n defaultTabEnable?: boolean;\n /**\n * You can create your own commands or reuse existing commands.\n */\n commands?: ICommand[];\n /**\n * Filter or modify your commands.\n * https://github.com/uiwjs/react-md-editor/issues/296\n */\n commandsFilter?: (command: ICommand, isExtra: boolean) => false | ICommand;\n /**\n * You can create your own commands or reuse existing commands.\n */\n extraCommands?: ICommand[];\n /**\n * Hide the tool bar\n */\n hideToolbar?: boolean;\n /** Whether to enable scrolling */\n enableScroll?: boolean;\n}\n\nfunction setGroupPopFalse(data: Record<string, boolean> = {}) {\n Object.keys(data).forEach((keyname) => {\n data[keyname] = false;\n });\n return data;\n}\n\nconst InternalMDEditor = (\n props: MDEditorProps,\n ref?: ((instance: ContextStore) => void) | React.RefObject<ContextStore> | null,\n) => {\n const {\n prefixCls = 'w-md-editor',\n className,\n value: propsValue,\n commands = getCommands(),\n commandsFilter,\n extraCommands = getExtraCommands(),\n height = 200,\n toolbarHeight = 29,\n enableScroll = true,\n visiableDragbar = true,\n highlightEnable = true,\n preview: previewType = 'live',\n fullscreen = false,\n overflow = true,\n previewOptions = {},\n textareaProps,\n maxHeight = 1200,\n minHeight = 100,\n autoFocus,\n tabSize = 2,\n defaultTabEnable = false,\n onChange,\n hideToolbar,\n renderTextarea,\n ...other\n } = props || {};\n const cmds = commands\n .map((item) => (commandsFilter ? commandsFilter(item, false) : item))\n .filter(Boolean) as ICommand[];\n const extraCmds = extraCommands\n .map((item) => (commandsFilter ? commandsFilter(item, true) : item))\n .filter(Boolean) as ICommand[];\n let [state, dispatch] = useReducer(reducer, {\n markdown: propsValue,\n preview: previewType,\n height,\n highlightEnable,\n tabSize,\n defaultTabEnable,\n scrollTop: 0,\n scrollTopPreview: 0,\n commands: cmds,\n extraCommands: extraCmds,\n fullscreen,\n barPopup: {},\n });\n const container = useRef<HTMLDivElement>(null);\n const previewRef = useRef<MarkdownPreviewRef>(null);\n const enableScrollRef = useRef(enableScroll);\n\n useImperativeHandle(ref, () => ({ ...state }));\n useMemo(() => (enableScrollRef.current = enableScroll), [enableScroll]);\n useEffect(() => {\n const stateInit: ContextStore = {};\n if (container.current) {\n stateInit.container = container.current || undefined;\n }\n stateInit.markdown = propsValue || '';\n stateInit.barPopup = {};\n if (dispatch) {\n dispatch({ ...state, ...stateInit });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const cls = [\n className,\n 'wmde-markdown-var',\n prefixCls,\n state.preview ? `${prefixCls}-show-${state.preview}` : null,\n state.fullscreen ? `${prefixCls}-fullscreen` : null,\n ]\n .filter(Boolean)\n .join(' ')\n .trim();\n\n useMemo(\n () => propsValue !== state.markdown && dispatch({ markdown: propsValue || '' }),\n [propsValue, state.markdown],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => previewType !== state.preview && dispatch({ preview: previewType }), [previewType]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => height !== state.height && dispatch({ height: height }), [height]);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => tabSize !== state.tabSize && dispatch({ tabSize }), [tabSize]);\n useMemo(\n () => highlightEnable !== state.highlightEnable && dispatch({ highlightEnable }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [highlightEnable],\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useMemo(() => autoFocus !== state.autoFocus && dispatch({ autoFocus: autoFocus }), [autoFocus]);\n useMemo(\n () => fullscreen !== state.fullscreen && dispatch({ fullscreen: fullscreen }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [fullscreen],\n );\n\n const textareaDomRef = useRef<HTMLDivElement>();\n const active = useRef<'text' | 'preview'>('preview');\n const initScroll = useRef(false);\n\n useMemo(() => {\n textareaDomRef.current = state.textareaWarp;\n if (state.textareaWarp) {\n state.textareaWarp.addEventListener('mouseover', () => {\n active.current = 'text';\n });\n state.textareaWarp.addEventListener('mouseleave', () => {\n active.current = 'preview';\n });\n }\n }, [state.textareaWarp]);\n\n const handleScroll = (e: React.UIEvent<HTMLDivElement>, type: 'text' | 'preview') => {\n if (!enableScrollRef.current) return;\n const textareaDom = textareaDomRef.current;\n const previewDom = previewRef.current ? previewRef.current.mdp.current : undefined;\n if (!initScroll.current) {\n active.current = type;\n initScroll.current = true;\n }\n if (textareaDom && previewDom) {\n const scale =\n (textareaDom.scrollHeight - textareaDom.offsetHeight) / (previewDom.scrollHeight - previewDom.offsetHeight);\n if (e.target === textareaDom && active.current === 'text') {\n previewDom.scrollTop = textareaDom.scrollTop / scale;\n }\n if (e.target === previewDom && active.current === 'preview') {\n textareaDom.scrollTop = previewDom.scrollTop * scale;\n }\n let scrollTop = 0;\n if (active.current === 'text') {\n scrollTop = textareaDom.scrollTop || 0;\n } else if (active.current === 'preview') {\n scrollTop = previewDom.scrollTop || 0;\n }\n dispatch({ scrollTop });\n }\n };\n\n const mdPreview = useMemo(\n () => (\n <MarkdownPreview\n {...previewOptions}\n onScroll={(e) => handleScroll(e, 'preview')}\n ref={previewRef}\n source={state.markdown || ''}\n className={`${prefixCls}-preview ${previewOptions.className || ''}`}\n />\n ),\n [prefixCls, previewOptions, state.markdown],\n );\n\n return (\n <EditorContext.Provider value={{ ...state, dispatch }}>\n <div\n ref={container}\n className={cls}\n {...other}\n onClick={() => {\n dispatch({ barPopup: { ...setGroupPopFalse(state.barPopup) } });\n }}\n style={{\n ...other.style,\n height: state.fullscreen ? '100%' : hideToolbar ? Number(state.height) - toolbarHeight : state.height,\n }}\n >\n {!hideToolbar && <Toolbar prefixCls={prefixCls} height={toolbarHeight} overflow={overflow} />}\n <div\n className={`${prefixCls}-content`}\n style={{\n height: state.fullscreen ? `calc(100% - ${toolbarHeight}px)` : Number(state.height) - toolbarHeight,\n }}\n >\n {/(edit|live)/.test(state.preview || '') && (\n <TextArea\n className={`${prefixCls}-input`}\n prefixCls={prefixCls}\n autoFocus={autoFocus}\n {...textareaProps}\n onChange={(evn) => {\n onChange && onChange(evn.target.value);\n if (textareaProps && textareaProps.onChange) {\n textareaProps.onChange(evn);\n }\n }}\n renderTextarea={renderTextarea}\n onScroll={(e) => handleScroll(e, 'text')}\n />\n )}\n {/(live|preview)/.test(state.preview || '') && mdPreview}\n </div>\n {visiableDragbar && !state.fullscreen && (\n <DragBar\n prefixCls={prefixCls}\n height={state.height as number}\n maxHeight={maxHeight!}\n minHeight={minHeight!}\n onChange={(newHeight) => {\n dispatch({ height: newHeight });\n }}\n />\n )}\n </div>\n </EditorContext.Provider>\n );\n};\n\nconst mdEditor = React.forwardRef<ContextStore, MDEditorProps>(InternalMDEditor);\n\ntype MDEditor = typeof mdEditor & {\n Markdown: typeof MarkdownPreview;\n};\n\n(mdEditor as MDEditor).Markdown = MarkdownPreview;\n\nexport default mdEditor as MDEditor;\n"
95
95
  ]
96
96
  }
@@ -70,6 +70,10 @@ var codeBlock = {
70
70
  name: 'codeBlock',
71
71
  keyCommand: 'codeBlock',
72
72
  shortcuts: 'ctrlcmd+shift+j',
73
+ icon: code['icon'],
74
+ buttonProps: {
75
+ 'aria-label': 'Insert Code Block'
76
+ },
73
77
  execute: function execute(tate, api) {
74
78
  // Adjust the selection to encompass the whole word if the caret is inside one
75
79
  var newSelectionRange = (0, _markdownUtils.selectWord)({
@@ -34,8 +34,8 @@
34
34
  "breaksAfter",
35
35
  "codeBlock"
36
36
  ],
37
- "mappings": ";;;;;;;;;AAAA;;AAEA;;;;AAMO,IAAMA,IAAc,GAAG;AAC5BC,EAAAA,IAAI,EAAE,MADsB;AAE5BC,EAAAA,UAAU,EAAE,MAFgB;AAG5BC,EAAAA,SAAS,EAAE,WAHiB;AAI5BC,EAAAA,WAAW,EAAE;AAAE,kBAAc;AAAhB,GAJe;AAK5BC,EAAAA,IAAI,eACF;AAAK,IAAA,KAAK,EAAC,IAAX;AAAgB,IAAA,MAAM,EAAC,IAAvB;AAA4B,IAAA,IAAI,EAAC,KAAjC;AAAuC,IAAA,OAAO,EAAC,aAA/C;AAAA,2BACE;AACE,MAAA,IAAI,EAAC,cADP;AAEE,MAAA,CAAC,EAAC;AAFJ;AADF,IAN0B;AAa5BC,EAAAA,OAAO,EAAE,iBAACC,IAAD,EAAkBC,GAAlB,EAA2C;AAClD;AACA,QAAMC,iBAAiB,GAAG,+BAAW;AAAEC,MAAAA,IAAI,EAAEH,IAAI,CAACG,IAAb;AAAmBC,MAAAA,SAAS,EAAEJ,IAAI,CAACI;AAAnC,KAAX,CAA1B;AACA,QAAMC,MAAM,GAAGJ,GAAG,CAACK,iBAAJ,CAAsBJ,iBAAtB,CAAf,CAHkD,CAIlD;;AACA,QAAIG,MAAM,CAACE,YAAP,CAAoBC,OAApB,CAA4B,IAA5B,MAAsC,CAAC,CAA3C,EAA8C;AAC5CP,MAA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AEA,QAAMa,iBAAiB,GAAG,sDAAkCV,MAAM,CAACF,IAAzC,EAA+CE,MAAM,CAACD,SAAP,CAAiBO,KAAhE,CAA1B;AACA,QAAMK,YAAY,GAAGC,KAAK,CAACF,iBAAiB,GAAG,CAArB,CAAL,CAA6BG,IAA7B,CAAkC,IAAlC,CAArB;AAEA,QAAMC,gBAAgB,GAAG,qDAAiCd,MAAM,CAACF,IAAxC,EAA8CE,MAAM,CAACD,SAAP,CAAiBU,GAA/D,CAAzB;AACA,QAAMM,WAAW,GAAGH,KAAK,CAACE,gBAAgB,GAAG,CAApB,CAAL,CAA4BD,IAA5B,CAAiC,IAAjC,CAApB;AAEAjB,IAAAA,GAAG,CAACQ,gBAAJ,WAAwBO,YAAxB,kBAA+CX,MAAM,CAACE,YAAtD,kBAA6Ea,WAA7E;AAEA,QAAMV,cAAc,GAAGL,MAAM,CAACD,SAAP,CAAiBO,KAAjB,GAAyBI,iBAAzB,GAA6C,CAApE;AACA,QAAMH,YAAY,GAAGF,cAAc,GAAGL,MAAM,CAACE,YAAP,CAAoBM,MAA1D;AAEAZ,IAAAA,GAAG,CAACK,iBAAJ,CAAsB;AACpBK,MAAAA,KAAK,EAAED,cADa;AAEpBI,MAAAA,GAAG,EAAEF;AAFe,KAAtB;AAID;AA1BgC,CAA5B",
38
38
  "sourcesContent": [
39
- "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport {\n selectWord,\n getBreaksNeededForEmptyLineBefore,\n getBreaksNeededForEmptyLineAfter,\n} from '../utils/markdownUtils';\n\nexport const code: ICommand = {\n name: 'code',\n keyCommand: 'code',\n shortcuts: 'ctrlcmd+j',\n buttonProps: { 'aria-label': 'Insert code' },\n icon: (\n <svg width=\"12\" height=\"12\" role=\"img\" viewBox=\"0 0 640 512\">\n <path\n fill=\"currentColor\"\n d=\"M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z\"\n />\n </svg>\n ),\n execute: (tate: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // when there's no breaking line\n if (state1.selectedText.indexOf('\\n') === -1) {\n api.replaceSelection(`\\`${state1.selectedText}\\``);\n // Adjust the selection to not contain the **\n\n const selectionStart = state1.selection.start + 1;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n return;\n }\n\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n api.replaceSelection(`${breaksBefore}\\`\\`\\`\\n${state1.selectedText}\\n\\`\\`\\`${breaksAfter}`);\n\n const selectionStart = state1.selection.start + breaksBeforeCount + 4;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n },\n};\n\nexport const codeBlock: ICommand = {\n name: 'codeBlock',\n keyCommand: 'codeBlock',\n shortcuts: 'ctrlcmd+shift+j',\n execute: (tate: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n api.replaceSelection(`${breaksBefore}\\`\\`\\`\\n${state1.selectedText}\\n\\`\\`\\`${breaksAfter}`);\n\n const selectionStart = state1.selection.start + breaksBeforeCount + 4;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n },\n};\n"
39
+ "import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport {\n selectWord,\n getBreaksNeededForEmptyLineBefore,\n getBreaksNeededForEmptyLineAfter,\n} from '../utils/markdownUtils';\n\nexport const code: ICommand = {\n name: 'code',\n keyCommand: 'code',\n shortcuts: 'ctrlcmd+j',\n buttonProps: { 'aria-label': 'Insert code' },\n icon: (\n <svg width=\"12\" height=\"12\" role=\"img\" viewBox=\"0 0 640 512\">\n <path\n fill=\"currentColor\"\n d=\"M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z\"\n />\n </svg>\n ),\n execute: (tate: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // when there's no breaking line\n if (state1.selectedText.indexOf('\\n') === -1) {\n api.replaceSelection(`\\`${state1.selectedText}\\``);\n // Adjust the selection to not contain the **\n\n const selectionStart = state1.selection.start + 1;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n return;\n }\n\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n api.replaceSelection(`${breaksBefore}\\`\\`\\`\\n${state1.selectedText}\\n\\`\\`\\`${breaksAfter}`);\n\n const selectionStart = state1.selection.start + breaksBeforeCount + 4;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n },\n};\n\nexport const codeBlock: ICommand = {\n name: 'codeBlock',\n keyCommand: 'codeBlock',\n shortcuts: 'ctrlcmd+shift+j',\n icon: code['icon'],\n buttonProps: { 'aria-label': 'Insert Code Block' },\n execute: (tate: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n api.replaceSelection(`${breaksBefore}\\`\\`\\`\\n${state1.selectedText}\\n\\`\\`\\`${breaksAfter}`);\n\n const selectionStart = state1.selection.start + breaksBeforeCount + 4;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n },\n};\n"
40
40
  ]
41
41
  }
@@ -13,13 +13,12 @@ var _react = _interopRequireWildcard(require("react"));
13
13
 
14
14
  var _rehype = require("rehype");
15
15
 
16
- var _rehypePrism = _interopRequireDefault(require("@mapbox/rehype-prism"));
16
+ var _rehypePrismPlus = _interopRequireDefault(require("rehype-prism-plus"));
17
17
 
18
18
  var _Context = require("../../Context");
19
19
 
20
20
  var _jsxRuntime = require("react/jsx-runtime");
21
21
 
22
- // @ts-ignore
23
22
  function Markdown(props) {
24
23
  var prefixCls = props.prefixCls;
25
24
 
@@ -70,7 +69,7 @@ function Markdown(props) {
70
69
 
71
70
  var str = (0, _rehype.rehype)().data('settings', {
72
71
  fragment: true
73
- }).use(_rehypePrism.default, {
72
+ }).use(_rehypePrismPlus.default, {
74
73
  ignoreMissing: true
75
74
  }).processSync("<pre class=\"language-markdown ".concat(prefixCls, "-text-pre wmde-markdown-color\"><code class=\"language-markdown\">").concat(html2Escape(markdown), "\n</code></pre>"));
76
75
  return /*#__PURE__*/_react.default.createElement('div', {
@@ -32,8 +32,8 @@
32
32
  "__html",
33
33
  "value"
34
34
  ],
35
- "mappings": ";;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;AAHA;AAOe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;AACrD,MAAQC,SAAR,GAAsBD,KAAtB,CAAQC,SAAR;;AACA,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AAAE,aAAK,MAAP;AAAe,aAAK,MAApB;AAA4B,aAAK,OAAjC;AAA0C,aAAK;AAA/C,OAAD,CAAsFA,CAAtF,CAAhB;AAAA,KATG,CAAP;AAWD;;AAED,SAAO,oBAAQ,YAAM;AACnB,QAAI,CAACX,QAAL,EAAe;AACb,0BAAO;AAAK,QAAA,QAAQ,EAAEA,QAAQ,IAAI,EAA3B;AAA+B,QAAA,GAAG,EAAEE,MAApC;AAA4C,QAAA,SAAS,YAAKJ,SAAL;AAArD,QAAP;AACD;;AACD,QAAMY,GAAG,GAAG,sBACTE,IADS,CACJ,UADI,EACQ;AAAEC,MAAAA,QAAQ,EAAE;AAAZ,KADR,EAETC,GAFS,CAELC,wBAFK,EAEQ;AAAEC,MAAAA,aAAa,EAAE;AAAjB,KAFR,EAGTC,WAHS,0CAIyBnB,SAJzB,+EAIoGS,WAAW,CACrHP,QADqH,CAJ/G,qBAAZ;AAQA,wBAAOG,eAAMe,aAAN,CAAoB,KAApB,EAA2B;AAChCC,MAAAA,SAAS,EAAE,qBADqB;AAEhCC,MAAAA,uBAAuB,EAAE;AAAEC,QAAAA,MAAM,EAAEX,GAAG,CAACY;AAAd;AAFO,KAA3B,CAAP;AAID,GAhBM,EAgBJ,CAACtB,QAAD,EAAWE,MAAX,EAAmBJ,SAAnB,CAhBI,CAAP;AAiBD",
36
36
  "sourcesContent": [
37
- "import React, { useContext, useEffect, useMemo } from 'react';\nimport { rehype } from 'rehype';\n// @ts-ignore\nimport rehypePrism from '@mapbox/rehype-prism';\nimport { IProps } from '../../Editor';\nimport { EditorContext } from '../../Context';\n\nexport interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {}\n\nexport default function Markdown(props: MarkdownProps) {\n const { prefixCls } = props;\n const { markdown = '', dispatch } = useContext(EditorContext);\n const preRef = React.createRef<HTMLPreElement>();\n useEffect(() => {\n if (preRef.current && dispatch) {\n dispatch({ textareaPre: preRef.current });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n function html2Escape(sHtml: string) {\n return sHtml\n .replace(/```(tsx?|jsx?|html|xml)(.*)\\s+([\\s\\S]*?)(\\s.+)?```/g, (str: string) => {\n return str.replace(\n /[<&\"]/g,\n (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '\"': '&quot;' } as Record<string, string>)[c]),\n );\n })\n .replace(\n /[<&\"]/g,\n (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '\"': '&quot;' } as Record<string, string>)[c]),\n );\n }\n\n return useMemo(() => {\n if (!markdown) {\n return <pre children={markdown || ''} ref={preRef} className={`${prefixCls}-text-pre wmde-markdown-color`} />;\n }\n const str = rehype()\n .data('settings', { fragment: true })\n .use(rehypePrism, { ignoreMissing: true })\n .processSync(\n `<pre class=\"language-markdown ${prefixCls}-text-pre wmde-markdown-color\"><code class=\"language-markdown\">${html2Escape(\n markdown,\n )}\\n</code></pre>`,\n );\n return React.createElement('div', {\n className: 'wmde-markdown-color',\n dangerouslySetInnerHTML: { __html: str.value as string },\n });\n }, [markdown, preRef, prefixCls]);\n}\n"
37
+ "import React, { useContext, useEffect, useMemo } from 'react';\nimport { rehype } from 'rehype';\nimport rehypePrism from 'rehype-prism-plus';\nimport { IProps } from '../../Editor';\nimport { EditorContext } from '../../Context';\n\nexport interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {}\n\nexport default function Markdown(props: MarkdownProps) {\n const { prefixCls } = props;\n const { markdown = '', dispatch } = useContext(EditorContext);\n const preRef = React.createRef<HTMLPreElement>();\n useEffect(() => {\n if (preRef.current && dispatch) {\n dispatch({ textareaPre: preRef.current });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n function html2Escape(sHtml: string) {\n return sHtml\n .replace(/```(tsx?|jsx?|html|xml)(.*)\\s+([\\s\\S]*?)(\\s.+)?```/g, (str: string) => {\n return str.replace(\n /[<&\"]/g,\n (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '\"': '&quot;' } as Record<string, string>)[c]),\n );\n })\n .replace(\n /[<&\"]/g,\n (c: string) => (({ '<': '&lt;', '>': '&gt;', '&': '&amp;', '\"': '&quot;' } as Record<string, string>)[c]),\n );\n }\n\n return useMemo(() => {\n if (!markdown) {\n return <pre children={markdown || ''} ref={preRef} className={`${prefixCls}-text-pre wmde-markdown-color`} />;\n }\n const str = rehype()\n .data('settings', { fragment: true })\n .use(rehypePrism, { ignoreMissing: true })\n .processSync(\n `<pre class=\"language-markdown ${prefixCls}-text-pre wmde-markdown-color\"><code class=\"language-markdown\">${html2Escape(\n markdown,\n )}\\n</code></pre>`,\n );\n return React.createElement('div', {\n className: 'wmde-markdown-color',\n dangerouslySetInnerHTML: { __html: str.value as string },\n });\n }, [markdown, preRef, prefixCls]);\n}\n"
38
38
  ]
39
39
  }
@@ -95,42 +95,32 @@
95
95
  }
96
96
 
97
97
  .@{md-editor}-text-pre {
98
- color: #333;
99
- .table {
100
- .punctuation {
101
- color: #c3c3c3;
102
- }
103
- .table-header {
104
- color: #000;
105
- }
98
+ .punctuation {
99
+ color: var(--color-prettylights-syntax-comment) !important;
106
100
  }
107
-
108
- .url {
109
- color: #032f62 !important;
110
- .content {
111
- color: #0366d6;
112
- }
101
+ .token.url,
102
+ .token.content {
103
+ color: var(--color-prettylights-syntax-constant) !important;
113
104
  }
114
-
115
- .hr {
116
- color: #999;
105
+ .token.title.important {
106
+ color: var(--color-prettylights-syntax-markup-bold);
117
107
  }
118
- .blockquote {
119
- color: #a6a6a6;
108
+ .token.code-block .function {
109
+ color: var(--color-prettylights-syntax-entity);
120
110
  }
121
- .title,
122
- .bold {
123
- color: #000 !important;
111
+ .token.bold {
112
+ font-weight: unset !important;
124
113
  }
125
- .title {
114
+ .token.title {
126
115
  line-height: unset !important;
127
116
  font-size: unset !important;
128
117
  font-weight: unset !important;
129
118
  }
130
- .code.keyword {
131
- color: #596394 !important;
119
+ .token.code.keyword {
120
+ color: var(--color-prettylights-syntax-constant) !important;
132
121
  }
133
- .strike {
134
- color: #bf4ca0;
122
+ .token.strike,
123
+ .token.strike .content {
124
+ color: var(--color-prettylights-syntax-markup-deleted-text) !important;
135
125
  }
136
126
  }
@@ -4,8 +4,9 @@
4
4
  &-toolbar-child {
5
5
  position: absolute;
6
6
  border-radius: 3px;
7
- box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1), 0 0 0 rgba(16, 22, 26, 0), 0 1px 1px rgba(16, 22, 26, 0.2);
8
- background-color: #fff;
7
+ box-shadow: 0 0 0 1px var(--color-border-default), 0 0 0 var(--color-border-default),
8
+ 0 1px 1px var(--color-border-default);
9
+ background-color: var(--color-canvas-default);
9
10
  z-index: 1;
10
11
  display: none;
11
12
  &.active {
@@ -2,8 +2,8 @@
2
2
 
3
3
  .@{md-editor} {
4
4
  &-toolbar {
5
- border-bottom: 1px solid #dfdfe0;
6
- background-color: #fbfbfb;
5
+ border-bottom: 1px solid var(--color-border-default);
6
+ background-color: var(--color-canvas-default);
7
7
  padding: 0 5px 0 5px;
8
8
  display: flex;
9
9
  justify-content: space-between;
@@ -24,7 +24,6 @@
24
24
  height: 20px;
25
25
  line-height: 14px;
26
26
  background: none;
27
- color: #586069;
28
27
  padding: 4px;
29
28
  margin: 0 1px;
30
29
  border-radius: 2px;
@@ -35,27 +34,28 @@
35
34
  cursor: pointer;
36
35
  transition: all 0.3s;
37
36
  white-space: nowrap;
37
+ color: var(--color-fg-default);
38
38
  &:hover,
39
39
  &:focus {
40
- color: #06c;
41
- background-color: #dcdcdc;
40
+ background-color: var(--color-neutral-muted);
41
+ color: var(--color-accent-fg);
42
42
  }
43
43
  &:active {
44
- color: #6a57ff;
45
- background-color: #dcdcdc;
44
+ background-color: var(--color-neutral-muted);
45
+ color: var(--color-danger-fg);
46
46
  }
47
47
  &:disabled {
48
- color: #ccc;
48
+ color: var(--color-border-default);
49
49
  cursor: not-allowed;
50
50
  &:hover {
51
51
  background-color: transparent;
52
- color: #ccc;
52
+ color: var(--color-border-default);
53
53
  }
54
54
  }
55
55
  }
56
56
  &.active > button {
57
- color: #06c;
58
- background-color: #e8e8e8;
57
+ color: var(--color-accent-fg);
58
+ background-color: var(--color-neutral-muted);
59
59
  }
60
60
  }
61
61
  &-divider {
@@ -63,7 +63,7 @@
63
63
  width: 1px;
64
64
  margin: -3px 3px 0 3px !important;
65
65
  vertical-align: middle;
66
- background-color: #ccc;
66
+ background-color: var(--color-border-default);
67
67
  }
68
68
  }
69
69
  }
package/lib/index.less CHANGED
@@ -1,14 +1,18 @@
1
1
  @md-editor:~ "w-md-editor";
2
2
 
3
3
  .@{md-editor} {
4
- color: #24292e;
5
4
  text-align: left;
6
- box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1), 0 0 0 rgba(16, 22, 26, 0), 0 1px 1px rgba(16, 22, 26, 0.2);
7
5
  border-radius: 3px;
8
6
  padding-bottom: 1px;
9
7
  position: relative;
10
- background-color: #fff;
8
+ color: var(--color-fg-default);
9
+ box-shadow: 0 0 0 1px var(--color-border-default), 0 0 0 var(--color-border-default),
10
+ 0 1px 1px var(--color-border-default);
11
+ background-color: var(--color-canvas-default);
11
12
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
13
+ .copied {
14
+ display: none !important;
15
+ }
12
16
  &-content {
13
17
  position: relative;
14
18
  border-radius: 0 0 3px 0;
@@ -21,7 +25,7 @@
21
25
  &-preview {
22
26
  width: 50%;
23
27
  box-sizing: border-box;
24
- box-shadow: inset 1px 0 0 0 #dfdfe0;
28
+ box-shadow: inset 1px 0 0 0 var(--color-border-default);
25
29
  position: absolute;
26
30
  padding: 10px 20px;
27
31
  overflow: auto;
@@ -38,7 +42,7 @@
38
42
  &-show-preview &-input {
39
43
  width: 0%;
40
44
  overflow: hidden;
41
- background-color: #fdfdfd;
45
+ background-color: var(--color-canvas-default);
42
46
  }
43
47
  &-show-preview &-preview {
44
48
  width: 100%;
@@ -110,47 +110,39 @@
110
110
  color: transparent !important;
111
111
  }
112
112
  }
113
- .w-md-editor-text-pre {
114
- color: #333;
115
- }
116
- .w-md-editor-text-pre .table .punctuation {
117
- color: #c3c3c3;
118
- }
119
- .w-md-editor-text-pre .table .table-header {
120
- color: #000;
113
+ .w-md-editor-text-pre .punctuation {
114
+ color: var(--color-prettylights-syntax-comment) !important;
121
115
  }
122
- .w-md-editor-text-pre .url {
123
- color: #032f62 !important;
116
+ .w-md-editor-text-pre .token.url,
117
+ .w-md-editor-text-pre .token.content {
118
+ color: var(--color-prettylights-syntax-constant) !important;
124
119
  }
125
- .w-md-editor-text-pre .url .content {
126
- color: #0366d6;
120
+ .w-md-editor-text-pre .token.title.important {
121
+ color: var(--color-prettylights-syntax-markup-bold);
127
122
  }
128
- .w-md-editor-text-pre .hr {
129
- color: #999;
123
+ .w-md-editor-text-pre .token.code-block .function {
124
+ color: var(--color-prettylights-syntax-entity);
130
125
  }
131
- .w-md-editor-text-pre .blockquote {
132
- color: #a6a6a6;
133
- }
134
- .w-md-editor-text-pre .title,
135
- .w-md-editor-text-pre .bold {
136
- color: #000 !important;
126
+ .w-md-editor-text-pre .token.bold {
127
+ font-weight: unset !important;
137
128
  }
138
- .w-md-editor-text-pre .title {
129
+ .w-md-editor-text-pre .token.title {
139
130
  line-height: unset !important;
140
131
  font-size: unset !important;
141
132
  font-weight: unset !important;
142
133
  }
143
- .w-md-editor-text-pre .code.keyword {
144
- color: #596394 !important;
134
+ .w-md-editor-text-pre .token.code.keyword {
135
+ color: var(--color-prettylights-syntax-constant) !important;
145
136
  }
146
- .w-md-editor-text-pre .strike {
147
- color: #bf4ca0;
137
+ .w-md-editor-text-pre .token.strike,
138
+ .w-md-editor-text-pre .token.strike .content {
139
+ color: var(--color-prettylights-syntax-markup-deleted-text) !important;
148
140
  }
149
141
  .w-md-editor-toolbar-child {
150
142
  position: absolute;
151
143
  border-radius: 3px;
152
- box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1), 0 0 0 rgba(16, 22, 26, 0), 0 1px 1px rgba(16, 22, 26, 0.2);
153
- background-color: #fff;
144
+ box-shadow: 0 0 0 1px var(--color-border-default), 0 0 0 var(--color-border-default), 0 1px 1px var(--color-border-default);
145
+ background-color: var(--color-canvas-default);
154
146
  z-index: 1;
155
147
  display: none;
156
148
  }
@@ -173,8 +165,8 @@
173
165
  margin: 0;
174
166
  }
175
167
  .w-md-editor-toolbar {
176
- border-bottom: 1px solid #dfdfe0;
177
- background-color: #fbfbfb;
168
+ border-bottom: 1px solid var(--color-border-default);
169
+ background-color: var(--color-canvas-default);
178
170
  padding: 0 5px 0 5px;
179
171
  display: flex;
180
172
  justify-content: space-between;
@@ -198,7 +190,6 @@
198
190
  height: 20px;
199
191
  line-height: 14px;
200
192
  background: none;
201
- color: #586069;
202
193
  padding: 4px;
203
194
  margin: 0 1px;
204
195
  border-radius: 2px;
@@ -209,45 +200,49 @@
209
200
  cursor: pointer;
210
201
  transition: all 0.3s;
211
202
  white-space: nowrap;
203
+ color: var(--color-fg-default);
212
204
  }
213
205
  .w-md-editor-toolbar li > button:hover,
214
206
  .w-md-editor-toolbar li > button:focus {
215
- color: #06c;
216
- background-color: #dcdcdc;
207
+ background-color: var(--color-neutral-muted);
208
+ color: var(--color-accent-fg);
217
209
  }
218
210
  .w-md-editor-toolbar li > button:active {
219
- color: #6a57ff;
220
- background-color: #dcdcdc;
211
+ background-color: var(--color-neutral-muted);
212
+ color: var(--color-danger-fg);
221
213
  }
222
214
  .w-md-editor-toolbar li > button:disabled {
223
- color: #ccc;
215
+ color: var(--color-border-default);
224
216
  cursor: not-allowed;
225
217
  }
226
218
  .w-md-editor-toolbar li > button:disabled:hover {
227
219
  background-color: transparent;
228
- color: #ccc;
220
+ color: var(--color-border-default);
229
221
  }
230
222
  .w-md-editor-toolbar li.active > button {
231
- color: #06c;
232
- background-color: #e8e8e8;
223
+ color: var(--color-accent-fg);
224
+ background-color: var(--color-neutral-muted);
233
225
  }
234
226
  .w-md-editor-toolbar-divider {
235
227
  height: 14px;
236
228
  width: 1px;
237
229
  margin: -3px 3px 0 3px !important;
238
230
  vertical-align: middle;
239
- background-color: #ccc;
231
+ background-color: var(--color-border-default);
240
232
  }
241
233
  .w-md-editor {
242
- color: #24292e;
243
234
  text-align: left;
244
- box-shadow: 0 0 0 1px rgba(16, 22, 26, 0.1), 0 0 0 rgba(16, 22, 26, 0), 0 1px 1px rgba(16, 22, 26, 0.2);
245
235
  border-radius: 3px;
246
236
  padding-bottom: 1px;
247
237
  position: relative;
248
- background-color: #fff;
238
+ color: var(--color-fg-default);
239
+ box-shadow: 0 0 0 1px var(--color-border-default), 0 0 0 var(--color-border-default), 0 1px 1px var(--color-border-default);
240
+ background-color: var(--color-canvas-default);
249
241
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
250
242
  }
243
+ .w-md-editor .copied {
244
+ display: none !important;
245
+ }
251
246
  .w-md-editor-content {
252
247
  position: relative;
253
248
  border-radius: 0 0 3px 0;
@@ -260,7 +255,7 @@
260
255
  .w-md-editor-preview {
261
256
  width: 50%;
262
257
  box-sizing: border-box;
263
- box-shadow: inset 1px 0 0 0 #dfdfe0;
258
+ box-shadow: inset 1px 0 0 0 var(--color-border-default);
264
259
  position: absolute;
265
260
  padding: 10px 20px;
266
261
  overflow: auto;
@@ -277,7 +272,7 @@
277
272
  .w-md-editor-show-preview .w-md-editor-input {
278
273
  width: 0%;
279
274
  overflow: hidden;
280
- background-color: #fdfdfd;
275
+ background-color: var(--color-canvas-default);
281
276
  }
282
277
  .w-md-editor-show-preview .w-md-editor-preview {
283
278
  width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.10.2",
3
+ "version": "3.11.2",
4
4
  "description": "A markdown editor with preview, implemented with React.js and TypeScript.",
5
5
  "homepage": "https://uiwjs.github.io/react-md-editor/",
6
6
  "author": "kenny wang <wowohoo@qq.com>",
@@ -51,13 +51,14 @@
51
51
  "@types/react-test-renderer": "~17.0.1",
52
52
  "@uiw/react-github-corners": "~1.5.3",
53
53
  "@uiw/react-shields": "~1.1.2",
54
+ "@wcj/dark-mode": "~1.0.9",
54
55
  "compile-less-cli": "~1.8.11",
55
56
  "katex": "~0.15.2",
56
57
  "husky": "~7.0.4",
57
58
  "kkt": "~7.1.5",
58
59
  "lint-staged": "~12.3.4",
59
60
  "mermaid": "~8.14.0",
60
- "prettier": "~2.5.1",
61
+ "prettier": "~2.6.0",
61
62
  "react": "~17.0.2",
62
63
  "react-dom": "~17.0.2",
63
64
  "react-test-renderer": "~17.0.2",
@@ -66,7 +67,7 @@
66
67
  },
67
68
  "dependencies": {
68
69
  "@babel/runtime": "^7.14.6",
69
- "@uiw/react-markdown-preview": "~3.5.0",
70
+ "@uiw/react-markdown-preview": "~4.0.5",
70
71
  "rehype-sanitize": "~5.0.1",
71
72
  "rehype": "~12.0.1"
72
73
  },
package/src/Editor.tsx CHANGED
@@ -184,6 +184,7 @@ const InternalMDEditor = (
184
184
 
185
185
  const cls = [
186
186
  className,
187
+ 'wmde-markdown-var',
187
188
  prefixCls,
188
189
  state.preview ? `${prefixCls}-show-${state.preview}` : null,
189
190
  state.fullscreen ? `${prefixCls}-fullscreen` : null,
@@ -14,7 +14,7 @@ it('MDEditor', () => {
14
14
  let tree = component.toJSON();
15
15
  if (tree && !Array.isArray(tree)) {
16
16
  expect(tree.type).toEqual('div');
17
- expect(tree.props.className).toEqual('w-md-editor w-md-editor-show-live');
17
+ expect(tree.props.className).toEqual('wmde-markdown-var w-md-editor w-md-editor-show-live');
18
18
  expect(tree.props.style).toMatchObject({
19
19
  height: 200,
20
20
  });
@@ -60,6 +60,8 @@ export const codeBlock: ICommand = {
60
60
  name: 'codeBlock',
61
61
  keyCommand: 'codeBlock',
62
62
  shortcuts: 'ctrlcmd+shift+j',
63
+ icon: code['icon'],
64
+ buttonProps: { 'aria-label': 'Insert Code Block' },
63
65
  execute: (tate: TextState, api: TextAreaTextApi) => {
64
66
  // Adjust the selection to encompass the whole word if the caret is inside one
65
67
  const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });
@@ -1,7 +1,6 @@
1
1
  import React, { useContext, useEffect, useMemo } from 'react';
2
2
  import { rehype } from 'rehype';
3
- // @ts-ignore
4
- import rehypePrism from '@mapbox/rehype-prism';
3
+ import rehypePrism from 'rehype-prism-plus';
5
4
  import { IProps } from '../../Editor';
6
5
  import { EditorContext } from '../../Context';
7
6