@uiw/react-md-editor 3.10.1 → 3.11.1

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 +35 -9
  2. package/dist/mdeditor.css +962 -321
  3. package/dist/mdeditor.js +43808 -57874
  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/components/TextArea/Markdown.js +4 -6
  9. package/esm/components/TextArea/Markdown.js.map +2 -3
  10. package/esm/components/TextArea/index.css +17 -25
  11. package/esm/components/TextArea/index.js +10 -3
  12. package/esm/components/TextArea/index.js.map +4 -2
  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/components/TextArea/Markdown.js +4 -6
  23. package/lib/components/TextArea/Markdown.js.map +2 -3
  24. package/lib/components/TextArea/index.js +11 -4
  25. package/lib/components/TextArea/index.js.map +4 -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/components/TextArea/Markdown.tsx +4 -5
  35. package/src/components/TextArea/index.less +17 -27
  36. package/src/components/TextArea/index.tsx +6 -3
  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 +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,MAAM,EAAE8D;AAAV,WAAD,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
  }
@@ -13,20 +13,18 @@ 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
 
26
25
  var _useContext = (0, _react.useContext)(_Context.EditorContext),
27
26
  _useContext$markdown = _useContext.markdown,
28
27
  markdown = _useContext$markdown === void 0 ? '' : _useContext$markdown,
29
- highlightEnable = _useContext.highlightEnable,
30
28
  dispatch = _useContext.dispatch;
31
29
 
32
30
  var preRef = /*#__PURE__*/_react.default.createRef();
@@ -61,7 +59,7 @@ function Markdown(props) {
61
59
  }
62
60
 
63
61
  return (0, _react.useMemo)(function () {
64
- if (!highlightEnable || !markdown) {
62
+ if (!markdown) {
65
63
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("pre", {
66
64
  children: markdown || '',
67
65
  ref: preRef,
@@ -71,7 +69,7 @@ function Markdown(props) {
71
69
 
72
70
  var str = (0, _rehype.rehype)().data('settings', {
73
71
  fragment: true
74
- }).use(_rehypePrism.default, {
72
+ }).use(_rehypePrismPlus.default, {
75
73
  ignoreMissing: true
76
74
  }).processSync("<pre class=\"language-markdown ".concat(prefixCls, "-text-pre wmde-markdown-color\"><code class=\"language-markdown\">").concat(html2Escape(markdown), "\n</code></pre>"));
77
75
  return /*#__PURE__*/_react.default.createElement('div', {
@@ -80,7 +78,7 @@ function Markdown(props) {
80
78
  __html: str.value
81
79
  }
82
80
  });
83
- }, [highlightEnable, markdown, preRef, prefixCls]);
81
+ }, [markdown, preRef, prefixCls]);
84
82
  }
85
83
 
86
84
  module.exports = exports.default;
@@ -9,7 +9,6 @@
9
9
  "prefixCls",
10
10
  "EditorContext",
11
11
  "markdown",
12
- "highlightEnable",
13
12
  "dispatch",
14
13
  "preRef",
15
14
  "React",
@@ -33,8 +32,8 @@
33
32
  "__html",
34
33
  "value"
35
34
  ],
36
- "mappings": ";;;;;;;;;;;AAAA;;AACA;;AAEA;;AAEA;;;;AAHA;AAOe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;AACrD,MAAQC,SAAR,GAAsBD,KAAtB,CAAQC,SAAR;;AACA,oBAAqD,uBAAWC,sBAAX,CAArD;AAAA,yCAAQC,QAAR;AAAA,MAAQA,QAAR,qCAAmB,EAAnB;AAAA,MAAuBC,eAAvB,eAAuBA,eAAvB;AAAA,MAAwCC,QAAxC,eAAwCA,QAAxC;;AACA,MAAMC,MAAM,gBAAGC,eAAMC,SAAN,EAAf;;AACA,wBAAU,YAAM;AACd,QAAIF,MAAM,CAACG,OAAP,IAAkBJ,QAAtB,EAAgC;AAC9BA,MAAAA,QAAQ,CAAC;AAAEK,QAAAA,WAAW,EAAEJ,MAAM,CAACG;AAAtB,OAAD,CAAR;AACD,KAHa,CAId;;AACD,GALD,EAKG,EALH;;AAMA,WAASE,WAAT,CAAqBC,KAArB,EAAoC;AAClC,WAAOA,KAAK,CACTC,OADI,CACI,qDADJ,EAC2D,UAACC,GAAD,EAAiB;AAC/E,aAAOA,GAAG,CAACD,OAAJ,CACL,QADK,EAEL,UAACE,CAAD;AAAA,eAAiB;AAAE,eAAK,MAAP;AAAe,eAAK,MAApB;AAA4B,eAAK,OAAjC;AAA0C,eAAK;AAA/C,SAAD,CAAsFA,CAAtF,CAAhB;AAAA,OAFK,CAAP;AAID,KANI,EAOJF,OAPI,CAQH,QARG,EASH,UAACE,CAAD;AAAA,aAAiB;AAAE,aAAK,MAAP;AAAe,aAAK,MAApB;AAA4B,aAAK,OAAjC;AAA0C,aAAK;AAA/C,OAAD,CAAsFA,CAAtF,CAAhB;AAAA,KATG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AAP;AAiBD",
37
36
  "sourcesContent": [
38
- "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 = '', highlightEnable, 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 (!highlightEnable || !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 }, [highlightEnable, 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"
39
38
  ]
40
39
  }
@@ -41,6 +41,7 @@ function TextArea(props) {
41
41
  markdown = _useContext.markdown,
42
42
  scrollTop = _useContext.scrollTop,
43
43
  commands = _useContext.commands,
44
+ highlightEnable = _useContext.highlightEnable,
44
45
  extraCommands = _useContext.extraCommands,
45
46
  dispatch = _useContext.dispatch;
46
47
 
@@ -74,7 +75,11 @@ function TextArea(props) {
74
75
  });
75
76
  } // eslint-disable-next-line react-hooks/exhaustive-deps
76
77
 
77
- }, []);
78
+ }, []); // @ts-ignore
79
+
80
+ var textStyle = highlightEnable ? {} : {
81
+ '-webkit-text-fill-color': 'inherit'
82
+ };
78
83
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
79
84
  ref: warp,
80
85
  className: "".concat(prefixCls, "-aree ").concat(className || ''),
@@ -104,11 +109,13 @@ function TextArea(props) {
104
109
  }), {
105
110
  ref: textRef
106
111
  }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
107
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Markdown.default, {
112
+ children: [highlightEnable && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Markdown.default, {
108
113
  prefixCls: prefixCls
109
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Textarea.default, (0, _objectSpread2.default)({
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Textarea.default, (0, _objectSpread2.default)((0, _objectSpread2.default)({
110
115
  prefixCls: prefixCls
111
- }, otherProps))]
116
+ }, otherProps), {}, {
117
+ style: textStyle
118
+ }))]
112
119
  })
113
120
  })
114
121
  });
@@ -15,6 +15,7 @@
15
15
  "markdown",
16
16
  "scrollTop",
17
17
  "commands",
18
+ "highlightEnable",
18
19
  "extraCommands",
19
20
  "dispatch",
20
21
  "textRef",
@@ -30,6 +31,7 @@
30
31
  "commandOrchestrator",
31
32
  "TextAreaCommandOrchestrator",
32
33
  "textarea",
34
+ "textStyle",
33
35
  "cloneElement",
34
36
  "value",
35
37
  "autoComplete",
@@ -44,8 +46,8 @@
44
46
  "useContext",
45
47
  "ref"
46
48
  ],
47
- "mappings": ";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAoCe,SAASA,QAAT,CAAkBC,KAAlB,EAAyC;AACtD,aAA0EA,KAAK,IAAI,EAAnF;AAAA,MAAQC,SAAR,QAAQA,SAAR;AAAA,MAAmBC,SAAnB,QAAmBA,SAAnB;AAAA,MAA8BC,QAA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A7BJ;AADF,IADF;AAuCD",
48
50
  "sourcesContent": [
49
- "import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea, { TextAreaProps } from './Textarea';\nimport { IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: TextAreaProps['onChange'];\n useContext?: {\n commands: ContextStore['commands'];\n extraCommands: ContextStore['extraCommands'];\n commandOrchestrator?: TextAreaCommandOrchestrator;\n };\n shortcuts?: (\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n ) => void;\n};\n\nexport interface ITextAreaProps\n extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>,\n IProps {\n value?: string;\n onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;\n renderTextarea?: (\n props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>,\n opts: RenderTextareaHandle,\n ) => JSX.Element;\n}\n\nexport type TextAreaRef = {\n text?: HTMLTextAreaElement;\n warp?: HTMLDivElement;\n};\n\nexport default function TextArea(props: ITextAreaProps) {\n const { prefixCls, className, onScroll, renderTextarea, ...otherProps } = props || {};\n const { markdown, scrollTop, commands, extraCommands, dispatch } = useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const warp = React.createRef<HTMLDivElement>();\n useEffect(() => {\n const state: ContextStore = {};\n if (warp.current) {\n state.textareaWarp = warp.current || undefined;\n warp.current.scrollTop = scrollTop || 0;\n }\n if (dispatch) {\n dispatch({ ...state });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (textRef.current && dispatch) {\n const commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);\n executeRef.current = commandOrchestrator;\n dispatch({ textarea: textRef.current, commandOrchestrator });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <div ref={warp} className={`${prefixCls}-aree ${className || ''}`} onScroll={onScroll}>\n <div className={`${prefixCls}-text`}>\n {renderTextarea ? (\n React.cloneElement(\n renderTextarea(\n {\n ...otherProps,\n value: markdown,\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: 'false',\n autoCapitalize: 'off',\n className: `${prefixCls}-text-input`,\n style: {\n WebkitTextFillColor: 'inherit',\n overflow: 'auto',\n },\n },\n {\n dispatch,\n onChange: otherProps.onChange,\n shortcuts,\n useContext: { commands, extraCommands, commandOrchestrator: executeRef.current },\n },\n ),\n {\n ref: textRef,\n },\n )\n ) : (\n <Fragment>\n <Markdown prefixCls={prefixCls} />\n <Textarea prefixCls={prefixCls} {...otherProps} />\n </Fragment>\n )}\n </div>\n </div>\n );\n}\n"
51
+ "import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea, { TextAreaProps } from './Textarea';\nimport { IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: TextAreaProps['onChange'];\n useContext?: {\n commands: ContextStore['commands'];\n extraCommands: ContextStore['extraCommands'];\n commandOrchestrator?: TextAreaCommandOrchestrator;\n };\n shortcuts?: (\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n ) => void;\n};\n\nexport interface ITextAreaProps\n extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>,\n IProps {\n value?: string;\n onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;\n renderTextarea?: (\n props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>,\n opts: RenderTextareaHandle,\n ) => JSX.Element;\n}\n\nexport type TextAreaRef = {\n text?: HTMLTextAreaElement;\n warp?: HTMLDivElement;\n};\n\nexport default function TextArea(props: ITextAreaProps) {\n const { prefixCls, className, onScroll, renderTextarea, ...otherProps } = props || {};\n const { markdown, scrollTop, commands, highlightEnable, extraCommands, dispatch } = useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const warp = React.createRef<HTMLDivElement>();\n useEffect(() => {\n const state: ContextStore = {};\n if (warp.current) {\n state.textareaWarp = warp.current || undefined;\n warp.current.scrollTop = scrollTop || 0;\n }\n if (dispatch) {\n dispatch({ ...state });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (textRef.current && dispatch) {\n const commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);\n executeRef.current = commandOrchestrator;\n dispatch({ textarea: textRef.current, commandOrchestrator });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // @ts-ignore\n const textStyle: React.CSSProperties = highlightEnable ? {} : { '-webkit-text-fill-color': 'inherit' };\n\n return (\n <div ref={warp} className={`${prefixCls}-aree ${className || ''}`} onScroll={onScroll}>\n <div className={`${prefixCls}-text`}>\n {renderTextarea ? (\n React.cloneElement(\n renderTextarea(\n {\n ...otherProps,\n value: markdown,\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: 'false',\n autoCapitalize: 'off',\n className: `${prefixCls}-text-input`,\n style: {\n WebkitTextFillColor: 'inherit',\n overflow: 'auto',\n },\n },\n {\n dispatch,\n onChange: otherProps.onChange,\n shortcuts,\n useContext: { commands, extraCommands, commandOrchestrator: executeRef.current },\n },\n ),\n {\n ref: textRef,\n },\n )\n ) : (\n <Fragment>\n {highlightEnable && <Markdown prefixCls={prefixCls} />}\n <Textarea prefixCls={prefixCls} {...otherProps} style={textStyle} />\n </Fragment>\n )}\n </div>\n </div>\n );\n}\n"
50
52
  ]
51
53
  }
@@ -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%;