@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.10.1",
3
+ "version": "3.11.1",
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
  });
@@ -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
 
@@ -9,7 +8,7 @@ export interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreEleme
9
8
 
10
9
  export default function Markdown(props: MarkdownProps) {
11
10
  const { prefixCls } = props;
12
- const { markdown = '', highlightEnable, dispatch } = useContext(EditorContext);
11
+ const { markdown = '', dispatch } = useContext(EditorContext);
13
12
  const preRef = React.createRef<HTMLPreElement>();
14
13
  useEffect(() => {
15
14
  if (preRef.current && dispatch) {
@@ -32,7 +31,7 @@ export default function Markdown(props: MarkdownProps) {
32
31
  }
33
32
 
34
33
  return useMemo(() => {
35
- if (!highlightEnable || !markdown) {
34
+ if (!markdown) {
36
35
  return <pre children={markdown || ''} ref={preRef} className={`${prefixCls}-text-pre wmde-markdown-color`} />;
37
36
  }
38
37
  const str = rehype()
@@ -47,5 +46,5 @@ export default function Markdown(props: MarkdownProps) {
47
46
  className: 'wmde-markdown-color',
48
47
  dangerouslySetInnerHTML: { __html: str.value as string },
49
48
  });
50
- }, [highlightEnable, markdown, preRef, prefixCls]);
49
+ }, [markdown, preRef, prefixCls]);
51
50
  }
@@ -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
  }
@@ -42,7 +42,7 @@ export type TextAreaRef = {
42
42
 
43
43
  export default function TextArea(props: ITextAreaProps) {
44
44
  const { prefixCls, className, onScroll, renderTextarea, ...otherProps } = props || {};
45
- const { markdown, scrollTop, commands, extraCommands, dispatch } = useContext(EditorContext);
45
+ const { markdown, scrollTop, commands, highlightEnable, extraCommands, dispatch } = useContext(EditorContext);
46
46
  const textRef = React.useRef<HTMLTextAreaElement>(null);
47
47
  const executeRef = React.useRef<TextAreaCommandOrchestrator>();
48
48
  const warp = React.createRef<HTMLDivElement>();
@@ -67,6 +67,9 @@ export default function TextArea(props: ITextAreaProps) {
67
67
  // eslint-disable-next-line react-hooks/exhaustive-deps
68
68
  }, []);
69
69
 
70
+ // @ts-ignore
71
+ const textStyle: React.CSSProperties = highlightEnable ? {} : { '-webkit-text-fill-color': 'inherit' };
72
+
70
73
  return (
71
74
  <div ref={warp} className={`${prefixCls}-aree ${className || ''}`} onScroll={onScroll}>
72
75
  <div className={`${prefixCls}-text`}>
@@ -99,8 +102,8 @@ export default function TextArea(props: ITextAreaProps) {
99
102
  )
100
103
  ) : (
101
104
  <Fragment>
102
- <Markdown prefixCls={prefixCls} />
103
- <Textarea prefixCls={prefixCls} {...otherProps} />
105
+ {highlightEnable && <Markdown prefixCls={prefixCls} />}
106
+ <Textarea prefixCls={prefixCls} {...otherProps} style={textStyle} />
104
107
  </Fragment>
105
108
  )}
106
109
  </div>
@@ -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/src/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%;