@uiw/react-md-editor 4.0.3 → 4.0.5

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 (46) hide show
  1. package/README.md +93 -75
  2. package/commands-cn.d.ts +65 -0
  3. package/dist/mdeditor.css +136 -50
  4. package/dist/mdeditor.js +65641 -66215
  5. package/dist/mdeditor.min.css +1 -1
  6. package/dist/mdeditor.min.js +1 -1
  7. package/dist/mdeditor.min.js.LICENSE.txt +2 -2
  8. package/esm/Context.d.ts +20 -33
  9. package/esm/Editor.js +1 -2
  10. package/esm/Editor.nohighlight.js +1 -2
  11. package/esm/Types.d.ts +1 -1
  12. package/esm/commands/comment.js +1 -2
  13. package/esm/commands/group.d.ts +1 -1
  14. package/esm/commands/index.cn.d.ts +33 -0
  15. package/esm/commands/index.cn.js +197 -0
  16. package/esm/commands/issue.js +2 -2
  17. package/esm/commands/preview.js +1 -2
  18. package/esm/components/TextArea/handleKeyDown.d.ts +0 -1
  19. package/esm/components/TextArea/index.d.ts +1 -1
  20. package/esm/components/TextArea/index.js +5 -6
  21. package/esm/components/TextArea/index.nohighlight.d.ts +1 -1
  22. package/esm/components/TextArea/index.nohighlight.js +4 -4
  23. package/esm/components/TextArea/shortcuts.d.ts +0 -1
  24. package/esm/components/Toolbar/Child.d.ts +1 -1
  25. package/esm/components/Toolbar/index.js +1 -2
  26. package/lib/Context.d.ts +20 -33
  27. package/lib/Types.d.ts +1 -1
  28. package/lib/commands/group.d.ts +1 -1
  29. package/lib/commands/index.cn.d.ts +33 -0
  30. package/lib/commands/index.cn.js +221 -0
  31. package/lib/commands/index.js +2 -4
  32. package/lib/commands/issue.js +2 -2
  33. package/lib/components/TextArea/handleKeyDown.d.ts +0 -1
  34. package/lib/components/TextArea/index.d.ts +1 -1
  35. package/lib/components/TextArea/index.js +4 -4
  36. package/lib/components/TextArea/index.nohighlight.d.ts +1 -1
  37. package/lib/components/TextArea/index.nohighlight.js +4 -4
  38. package/lib/components/TextArea/shortcuts.d.ts +0 -1
  39. package/lib/components/Toolbar/Child.d.ts +1 -1
  40. package/package.json +7 -1
  41. package/src/Types.ts +1 -1
  42. package/src/commands/index.cn.ts +187 -0
  43. package/src/commands/issue.tsx +2 -2
  44. package/src/components/TextArea/index.nohighlight.tsx +1 -1
  45. package/src/components/TextArea/index.tsx +1 -1
  46. package/src/components/Toolbar/Child.tsx +1 -1
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.comment = exports.codePreview = exports.codeLive = exports.codeEdit = exports.codeBlock = exports.code = exports.checkedListCommand = exports.bold = void 0;
8
+ Object.defineProperty(exports, "divider", {
9
+ enumerable: true,
10
+ get: function get() {
11
+ return _divider.divider;
12
+ }
13
+ });
14
+ exports.getExtraCommands = exports.getCommands = exports.fullscreen = void 0;
15
+ Object.defineProperty(exports, "group", {
16
+ enumerable: true,
17
+ get: function get() {
18
+ return _group.group;
19
+ }
20
+ });
21
+ exports.unorderedListCommand = exports.title6 = exports.title5 = exports.title4 = exports.title3 = exports.title2 = exports.title1 = exports.title = exports.table = exports.strikethrough = exports.quote = exports.orderedListCommand = exports.link = exports.italic = exports.issue = exports.image = exports.hr = exports.help = void 0;
22
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
23
+ var _divider = require("./divider");
24
+ var _group = require("./group");
25
+ var _bold = require("./bold");
26
+ var _code = require("./code");
27
+ var _comment = require("./comment");
28
+ var _fullscreen = require("./fullscreen");
29
+ var _hr = require("./hr");
30
+ var _image = require("./image");
31
+ var _italic = require("./italic");
32
+ var _link = require("./link");
33
+ var _list = require("./list");
34
+ var _preview = require("./preview");
35
+ var _quote = require("./quote");
36
+ var _strikeThrough = require("./strikeThrough");
37
+ var _issue = require("./issue");
38
+ var _title = require("./title");
39
+ var _title2 = require("./title1");
40
+ var _title3 = require("./title2");
41
+ var _title4 = require("./title3");
42
+ var _title5 = require("./title4");
43
+ var _title6 = require("./title5");
44
+ var _title7 = require("./title6");
45
+ var _table = require("./table");
46
+ var _help = require("./help");
47
+ var bold = exports.bold = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _bold.bold), {}, {
48
+ buttonProps: {
49
+ 'aria-label': '添加粗体文本(ctrl + b)',
50
+ title: '添加粗体文本(ctrl + b)'
51
+ }
52
+ });
53
+ var code = exports.code = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _code.code), {}, {
54
+ buttonProps: {
55
+ 'aria-label': '插入代码(ctrl + j)',
56
+ title: '插入代码(ctrl + j)'
57
+ }
58
+ });
59
+ var codeBlock = exports.codeBlock = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _code.codeBlock), {}, {
60
+ buttonProps: {
61
+ 'aria-label': '插入代码块(ctrl + shift + j)',
62
+ title: '插入代码块(ctrl + shift + j)'
63
+ }
64
+ });
65
+ var comment = exports.comment = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _comment.comment), {}, {
66
+ buttonProps: {
67
+ 'aria-label': '插入注释(ctrl + /)',
68
+ title: '插入注释(ctrl + /)'
69
+ }
70
+ });
71
+ var fullscreen = exports.fullscreen = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _fullscreen.fullscreen), {}, {
72
+ buttonProps: {
73
+ 'aria-label': '切换全屏(ctrl + 0)',
74
+ title: '切换全屏(ctrl + 0)'
75
+ }
76
+ });
77
+ var hr = exports.hr = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _hr.hr), {}, {
78
+ buttonProps: {
79
+ 'aria-label': '插入HR (ctrl + h)',
80
+ title: '插入HR (ctrl + h)'
81
+ }
82
+ });
83
+ var image = exports.image = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _image.image), {}, {
84
+ buttonProps: {
85
+ 'aria-label': '添加图像(ctrl + k)',
86
+ title: '添加图像(ctrl + k)'
87
+ }
88
+ });
89
+ var italic = exports.italic = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _italic.italic), {}, {
90
+ buttonProps: {
91
+ 'aria-label': '添加斜体文本(ctrl + i)',
92
+ title: '添加斜体文本(ctrl + i)'
93
+ }
94
+ });
95
+ var link = exports.link = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _link.link), {}, {
96
+ buttonProps: {
97
+ 'aria-label': '添加链接(ctrl + l)',
98
+ title: '添加链接(ctrl + l)'
99
+ }
100
+ });
101
+ var checkedListCommand = exports.checkedListCommand = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _list.checkedListCommand), {}, {
102
+ buttonProps: {
103
+ 'aria-label': '添加检查列表(ctrl + shift + c)',
104
+ title: '添加检查列表(ctrl + shift + c)'
105
+ }
106
+ });
107
+ var orderedListCommand = exports.orderedListCommand = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _list.orderedListCommand), {}, {
108
+ buttonProps: {
109
+ 'aria-label': '添加有序列表(ctrl + shift + o)',
110
+ title: '添加有序列表(ctrl + shift + o)'
111
+ }
112
+ });
113
+ var unorderedListCommand = exports.unorderedListCommand = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _list.unorderedListCommand), {}, {
114
+ buttonProps: {
115
+ 'aria-label': '添加无序列表(ctrl + shift + u)',
116
+ title: '添加无序列表(ctrl + shift + u)'
117
+ }
118
+ });
119
+ var codeEdit = exports.codeEdit = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _preview.codeEdit), {}, {
120
+ buttonProps: {
121
+ 'aria-label': '编辑代码(ctrl + 7)',
122
+ title: '编辑代码(ctrl + 7)'
123
+ }
124
+ });
125
+ var codeLive = exports.codeLive = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _preview.codeLive), {}, {
126
+ buttonProps: {
127
+ 'aria-label': '实时代码(ctrl + 8)',
128
+ title: '实时代码(ctrl + 8)'
129
+ }
130
+ });
131
+ var codePreview = exports.codePreview = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _preview.codePreview), {}, {
132
+ buttonProps: {
133
+ 'aria-label': '预览代码(ctrl + 9)',
134
+ title: '预览代码(ctrl + 9)'
135
+ }
136
+ });
137
+ var quote = exports.quote = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _quote.quote), {}, {
138
+ buttonProps: {
139
+ 'aria-label': '预览代码(ctrl + 9)',
140
+ title: '预览代码(ctrl + 9)'
141
+ }
142
+ });
143
+ var strikethrough = exports.strikethrough = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _strikeThrough.strikethrough), {}, {
144
+ buttonProps: {
145
+ 'aria-label': 'Add strikethrough text (ctrl + shift + x)',
146
+ title: 'Add strikethrough text (ctrl + shift + x)'
147
+ }
148
+ });
149
+ var issue = exports.issue = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _issue.issue), {}, {
150
+ buttonProps: {
151
+ 'aria-label': '添加 issue',
152
+ title: '添加 issue'
153
+ }
154
+ });
155
+ var title = exports.title = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _title.title), {}, {
156
+ buttonProps: {
157
+ 'aria-label': '插入 title (ctrl + 1)',
158
+ title: '插入 title (ctrl + 1)'
159
+ }
160
+ });
161
+ var title1 = exports.title1 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _title2.title1), {}, {
162
+ buttonProps: {
163
+ 'aria-label': '插入 title1 (ctrl + 1)',
164
+ title: '插入 title1 (ctrl + 1)'
165
+ }
166
+ });
167
+ var title2 = exports.title2 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _title3.title2), {}, {
168
+ buttonProps: {
169
+ 'aria-label': '插入 title2 (ctrl + 2)',
170
+ title: '插入 title2 (ctrl + 2)'
171
+ }
172
+ });
173
+ var title3 = exports.title3 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _title4.title3), {}, {
174
+ buttonProps: {
175
+ 'aria-label': '插入 title3 (ctrl + 3)',
176
+ title: '插入 title3 (ctrl + 3)'
177
+ }
178
+ });
179
+ var title4 = exports.title4 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _title5.title4), {}, {
180
+ buttonProps: {
181
+ 'aria-label': '插入 title4 (ctrl + 4)',
182
+ title: '插入 title4 (ctrl + 4)'
183
+ }
184
+ });
185
+ var title5 = exports.title5 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _title6.title5), {}, {
186
+ buttonProps: {
187
+ 'aria-label': '插入 title5 (ctrl + 5)',
188
+ title: '插入 title5 (ctrl + 5)'
189
+ }
190
+ });
191
+ var title6 = exports.title6 = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _title7.title6), {}, {
192
+ buttonProps: {
193
+ 'aria-label': '插入 title6 (ctrl + 6)',
194
+ title: '插入 title6 (ctrl + 6)'
195
+ }
196
+ });
197
+ var table = exports.table = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _table.table), {}, {
198
+ buttonProps: {
199
+ 'aria-label': '添加表格',
200
+ title: '添加表格'
201
+ }
202
+ });
203
+ var help = exports.help = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _help.help), {}, {
204
+ buttonProps: {
205
+ 'aria-label': '打开帮助',
206
+ title: '打开帮助'
207
+ }
208
+ });
209
+ var getCommands = exports.getCommands = function getCommands() {
210
+ return [bold, italic, strikethrough, hr, (0, _group.group)([title1, title2, title3, title4, title5, title6], {
211
+ name: 'title',
212
+ groupName: 'title',
213
+ buttonProps: {
214
+ 'aria-label': '插入标题',
215
+ title: 'I插入标题'
216
+ }
217
+ }), _divider.divider, link, quote, code, codeBlock, comment, image, table, _divider.divider, unorderedListCommand, orderedListCommand, checkedListCommand, _divider.divider, help];
218
+ };
219
+ var getExtraCommands = exports.getExtraCommands = function getExtraCommands() {
220
+ return [codeEdit, codeLive, codePreview, _divider.divider, fullscreen];
221
+ };
@@ -246,7 +246,7 @@ var TextAreaTextApi = exports.TextAreaTextApi = /*#__PURE__*/function () {
246
246
  * selection start and selection end will be the same and will both point to the end
247
247
  * @param text Text that should replace the current selection
248
248
  */
249
- (0, _createClass2["default"])(TextAreaTextApi, [{
249
+ return (0, _createClass2["default"])(TextAreaTextApi, [{
250
250
  key: "replaceSelection",
251
251
  value: function replaceSelection(text) {
252
252
  (0, _InsertTextAtPosition.insertTextAtPosition)(this.textArea, text);
@@ -266,7 +266,6 @@ var TextAreaTextApi = exports.TextAreaTextApi = /*#__PURE__*/function () {
266
266
  return getStateFromTextArea(this.textArea);
267
267
  }
268
268
  }]);
269
- return TextAreaTextApi;
270
269
  }();
271
270
  var TextAreaCommandOrchestrator = exports.TextAreaCommandOrchestrator = /*#__PURE__*/function () {
272
271
  function TextAreaCommandOrchestrator(textArea) {
@@ -276,7 +275,7 @@ var TextAreaCommandOrchestrator = exports.TextAreaCommandOrchestrator = /*#__PUR
276
275
  this.textArea = textArea;
277
276
  this.textApi = new TextAreaTextApi(textArea);
278
277
  }
279
- (0, _createClass2["default"])(TextAreaCommandOrchestrator, [{
278
+ return (0, _createClass2["default"])(TextAreaCommandOrchestrator, [{
280
279
  key: "getState",
281
280
  value: function getState() {
282
281
  if (!this.textArea) return false;
@@ -290,5 +289,4 @@ var TextAreaCommandOrchestrator = exports.TextAreaCommandOrchestrator = /*#__PUR
290
289
  }, getStateFromTextArea(this.textArea)), this.textApi, dispatch, state, shortcuts);
291
290
  }
292
291
  }]);
293
- return TextAreaCommandOrchestrator;
294
292
  }();
@@ -24,8 +24,8 @@ var issue = exports.issue = {
24
24
  viewBox: "0 0 448 512",
25
25
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
26
26
  fill: "currentColor",
27
- d: "M181.3 32.4c17.4 2.9 29.2 19.4 26.3 36.8L197.8 128h95.1l11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3s29.2 19.4 26.3 36.8L357.8 128H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H347.1L325.8 320H384c17.7 0 32 14.3 32 32s-14.3 32-32 32H315.1l-11.5 69.3c-2.9 17.4-19.4 29.2-36.826.3s-29.2-19.4-26.3-36.8l9.8-58.7H155.1l-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8L90.2 384H32c-17.7 0-32-14.3-32-32s14.3-32 32-32h68.9l21.3-128H64c-17.7 0-32-14.3-32-32s14.3-32 32-32h68.9l11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3zM187.1 192L165.8320h95.1l21.3-128H187.1z"
28
- //Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
27
+ d: "M181.3 32.4c17.4 2.9 29.2 19.4 26.3 36.8L197.8 128l95.1 0 11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3s29.2 19.4 26.3 36.8L357.8 128l58.2 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-68.9 0L325.8 320l58.2 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-68.9 0-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8l9.8-58.7-95.1 0-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8L90.2 384 32 384c-17.7 0-32-14.3-32-32s14.3-32 32-32l68.9 0 21.3-128L64 192c-17.7 0-32-14.3-32-32s14.3-32 32-32l68.9 0 11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3zM187.1 192L165.8 320l95.1 0 21.3-128-95.1 0z"
28
+ //Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com
29
29
  })
30
30
  }),
31
31
  execute: function execute(state, api) {
@@ -1,2 +1 @@
1
- /// <reference types="react" />
2
1
  export default function handleKeyDown(e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, tabSize?: number, defaultTabEnable?: boolean): void;
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { JSX } from 'react';
2
2
  import { ContextStore, ExecuteCommandState } from '../../Context';
3
3
  import { TextAreaProps } from './Textarea';
4
4
  import { IProps } from '../../Types';
@@ -47,11 +47,11 @@ function TextArea(props) {
47
47
  }, []);
48
48
  (0, _react.useEffect)(function () {
49
49
  if (textRef.current && dispatch) {
50
- var _commandOrchestrator = new _commands.TextAreaCommandOrchestrator(textRef.current);
51
- executeRef.current = _commandOrchestrator;
50
+ var commandOrchestrator = new _commands.TextAreaCommandOrchestrator(textRef.current);
51
+ executeRef.current = commandOrchestrator;
52
52
  dispatch({
53
53
  textarea: textRef.current,
54
- commandOrchestrator: _commandOrchestrator
54
+ commandOrchestrator: commandOrchestrator
55
55
  });
56
56
  }
57
57
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -69,7 +69,7 @@ function TextArea(props) {
69
69
  style: {
70
70
  minHeight: minHeight
71
71
  },
72
- children: renderTextarea ? ( /*#__PURE__*/_react["default"].cloneElement(renderTextarea((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, otherProps), {}, {
72
+ children: renderTextarea ? (/*#__PURE__*/_react["default"].cloneElement(renderTextarea((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, otherProps), {}, {
73
73
  value: markdown,
74
74
  autoComplete: 'off',
75
75
  autoCorrect: 'off',
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { JSX } from 'react';
2
2
  import { ContextStore, ExecuteCommandState } from '../../Context';
3
3
  import { TextAreaProps } from './Textarea';
4
4
  import { IProps } from '../../Types';
@@ -44,11 +44,11 @@ function TextArea(props) {
44
44
  }, []);
45
45
  (0, _react.useEffect)(function () {
46
46
  if (textRef.current && dispatch) {
47
- var _commandOrchestrator = new _commands.TextAreaCommandOrchestrator(textRef.current);
48
- executeRef.current = _commandOrchestrator;
47
+ var commandOrchestrator = new _commands.TextAreaCommandOrchestrator(textRef.current);
48
+ executeRef.current = commandOrchestrator;
49
49
  dispatch({
50
50
  textarea: textRef.current,
51
- commandOrchestrator: _commandOrchestrator
51
+ commandOrchestrator: commandOrchestrator
52
52
  });
53
53
  }
54
54
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -63,7 +63,7 @@ function TextArea(props) {
63
63
  onScroll: onScroll,
64
64
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
65
65
  className: "".concat(prefixCls, "-text"),
66
- children: renderTextarea ? ( /*#__PURE__*/_react["default"].cloneElement(renderTextarea((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, otherProps), {}, {
66
+ children: renderTextarea ? (/*#__PURE__*/_react["default"].cloneElement(renderTextarea((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, otherProps), {}, {
67
67
  value: markdown,
68
68
  autoComplete: 'off',
69
69
  autoCorrect: 'off',
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ICommand, TextAreaCommandOrchestrator } from '../../commands';
3
2
  import { ContextStore, ExecuteCommandState } from '../../Context';
4
3
  export default function shortcutsHandle(e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands?: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState): void;
@@ -1,4 +1,4 @@
1
- /// <reference types="react" />
1
+ import { JSX } from 'react';
2
2
  import './Child.less';
3
3
  import { type IToolbarProps } from './';
4
4
  export type ChildProps = IToolbarProps & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
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
  "funding": "https://jaywcjlove.github.io/#/sponsor",
@@ -25,6 +25,11 @@
25
25
  "import": "./esm/commands/index.js",
26
26
  "types": "./lib/commands/index.d.ts",
27
27
  "require": "./lib/commands/index.js"
28
+ },
29
+ "./commands-cn": {
30
+ "import": "./esm/commands/index.cn.js",
31
+ "types": "./lib/commands/index.cn.d.ts",
32
+ "require": "./lib/commands/index.cn.js"
28
33
  }
29
34
  },
30
35
  "repository": {
@@ -38,6 +43,7 @@
38
43
  "markdown-editor.css",
39
44
  "nohighlight.d.ts",
40
45
  "commands.d.ts",
46
+ "commands-cn.d.ts",
41
47
  "lib",
42
48
  "dist",
43
49
  "esm",
package/src/Types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { CSSProperties } from 'react';
1
+ import type { CSSProperties, JSX } from 'react';
2
2
  import type { MarkdownPreviewProps } from '@uiw/react-markdown-preview/nohighlight';
3
3
  import type { ITextAreaProps } from './components/TextArea/index.nohighlight';
4
4
  import type { ICommand, TextState } from './commands';
@@ -0,0 +1,187 @@
1
+ import { type ICommand } from './';
2
+ import { divider } from './divider';
3
+ import { group } from './group';
4
+
5
+ import { bold as boldInit } from './bold';
6
+ import { code as codeInit, codeBlock as codeBlockInit } from './code';
7
+ import { comment as commentInit } from './comment';
8
+ import { fullscreen as fullscreenInit } from './fullscreen';
9
+ import { hr as hrInit } from './hr';
10
+ import { image as imageInit } from './image';
11
+ import { italic as italicInit } from './italic';
12
+ import { link as linkInit } from './link';
13
+ import {
14
+ checkedListCommand as checkedListCommandInit,
15
+ orderedListCommand as orderedListCommandInit,
16
+ unorderedListCommand as unorderedListCommandInit,
17
+ } from './list';
18
+ import { codeEdit as codeEditInit, codeLive as codeLiveInit, codePreview as codePreviewInit } from './preview';
19
+ import { quote as quoteInit } from './quote';
20
+ import { strikethrough as strikethroughInit } from './strikeThrough';
21
+ import { issue as issueInit } from './issue';
22
+ import { title as titleInit } from './title';
23
+ import { title1 as title1Init } from './title1';
24
+ import { title2 as title2Init } from './title2';
25
+ import { title3 as title3Init } from './title3';
26
+ import { title4 as title4Init } from './title4';
27
+ import { title5 as title5Init } from './title5';
28
+ import { title6 as title6Init } from './title6';
29
+ import { table as tableInit } from './table';
30
+ import { help as helpInit } from './help';
31
+
32
+ let bold: ICommand = {
33
+ ...boldInit,
34
+ buttonProps: { 'aria-label': '添加粗体文本(ctrl + b)', title: '添加粗体文本(ctrl + b)' },
35
+ };
36
+ let code: ICommand = { ...codeInit, buttonProps: { 'aria-label': '插入代码(ctrl + j)', title: '插入代码(ctrl + j)' } };
37
+ let codeBlock: ICommand = {
38
+ ...codeBlockInit,
39
+ buttonProps: { 'aria-label': '插入代码块(ctrl + shift + j)', title: '插入代码块(ctrl + shift + j)' },
40
+ };
41
+ let comment: ICommand = {
42
+ ...commentInit,
43
+ buttonProps: { 'aria-label': '插入注释(ctrl + /)', title: '插入注释(ctrl + /)' },
44
+ };
45
+ let fullscreen: ICommand = {
46
+ ...fullscreenInit,
47
+ buttonProps: { 'aria-label': '切换全屏(ctrl + 0)', title: '切换全屏(ctrl + 0)' },
48
+ };
49
+ let hr: ICommand = { ...hrInit, buttonProps: { 'aria-label': '插入HR (ctrl + h)', title: '插入HR (ctrl + h)' } };
50
+ let image: ICommand = {
51
+ ...imageInit,
52
+ buttonProps: { 'aria-label': '添加图像(ctrl + k)', title: '添加图像(ctrl + k)' },
53
+ };
54
+ let italic: ICommand = {
55
+ ...italicInit,
56
+ buttonProps: { 'aria-label': '添加斜体文本(ctrl + i)', title: '添加斜体文本(ctrl + i)' },
57
+ };
58
+ let link: ICommand = { ...linkInit, buttonProps: { 'aria-label': '添加链接(ctrl + l)', title: '添加链接(ctrl + l)' } };
59
+ let checkedListCommand: ICommand = {
60
+ ...checkedListCommandInit,
61
+ buttonProps: { 'aria-label': '添加检查列表(ctrl + shift + c)', title: '添加检查列表(ctrl + shift + c)' },
62
+ };
63
+ let orderedListCommand: ICommand = {
64
+ ...orderedListCommandInit,
65
+ buttonProps: { 'aria-label': '添加有序列表(ctrl + shift + o)', title: '添加有序列表(ctrl + shift + o)' },
66
+ };
67
+ let unorderedListCommand: ICommand = {
68
+ ...unorderedListCommandInit,
69
+ buttonProps: {
70
+ 'aria-label': '添加无序列表(ctrl + shift + u)',
71
+ title: '添加无序列表(ctrl + shift + u)',
72
+ },
73
+ };
74
+ let codeEdit: ICommand = {
75
+ ...codeEditInit,
76
+ buttonProps: { 'aria-label': '编辑代码(ctrl + 7)', title: '编辑代码(ctrl + 7)' },
77
+ };
78
+ let codeLive: ICommand = {
79
+ ...codeLiveInit,
80
+ buttonProps: { 'aria-label': '实时代码(ctrl + 8)', title: '实时代码(ctrl + 8)' },
81
+ };
82
+ let codePreview: ICommand = {
83
+ ...codePreviewInit,
84
+ buttonProps: { 'aria-label': '预览代码(ctrl + 9)', title: '预览代码(ctrl + 9)' },
85
+ };
86
+ let quote: ICommand = {
87
+ ...quoteInit,
88
+ buttonProps: { 'aria-label': '预览代码(ctrl + 9)', title: '预览代码(ctrl + 9)' },
89
+ };
90
+
91
+ let strikethrough: ICommand = {
92
+ ...strikethroughInit,
93
+ buttonProps: {
94
+ 'aria-label': 'Add strikethrough text (ctrl + shift + x)',
95
+ title: 'Add strikethrough text (ctrl + shift + x)',
96
+ },
97
+ };
98
+ let issue: ICommand = { ...issueInit, buttonProps: { 'aria-label': '添加 issue', title: '添加 issue' } };
99
+ let title: ICommand = {
100
+ ...titleInit,
101
+ buttonProps: { 'aria-label': '插入 title (ctrl + 1)', title: '插入 title (ctrl + 1)' },
102
+ };
103
+ let title1: ICommand = {
104
+ ...title1Init,
105
+ buttonProps: { 'aria-label': '插入 title1 (ctrl + 1)', title: '插入 title1 (ctrl + 1)' },
106
+ };
107
+ let title2: ICommand = {
108
+ ...title2Init,
109
+ buttonProps: { 'aria-label': '插入 title2 (ctrl + 2)', title: '插入 title2 (ctrl + 2)' },
110
+ };
111
+ let title3: ICommand = {
112
+ ...title3Init,
113
+ buttonProps: { 'aria-label': '插入 title3 (ctrl + 3)', title: '插入 title3 (ctrl + 3)' },
114
+ };
115
+ let title4: ICommand = {
116
+ ...title4Init,
117
+ buttonProps: { 'aria-label': '插入 title4 (ctrl + 4)', title: '插入 title4 (ctrl + 4)' },
118
+ };
119
+ let title5: ICommand = {
120
+ ...title5Init,
121
+ buttonProps: { 'aria-label': '插入 title5 (ctrl + 5)', title: '插入 title5 (ctrl + 5)' },
122
+ };
123
+ let title6: ICommand = {
124
+ ...title6Init,
125
+ buttonProps: { 'aria-label': '插入 title6 (ctrl + 6)', title: '插入 title6 (ctrl + 6)' },
126
+ };
127
+ let table: ICommand = { ...tableInit, buttonProps: { 'aria-label': '添加表格', title: '添加表格' } };
128
+ let help: ICommand = { ...helpInit, buttonProps: { 'aria-label': '打开帮助', title: '打开帮助' } };
129
+
130
+ export const getCommands: () => ICommand[] = () => [
131
+ bold,
132
+ italic,
133
+ strikethrough,
134
+ hr,
135
+ group([title1, title2, title3, title4, title5, title6], {
136
+ name: 'title',
137
+ groupName: 'title',
138
+ buttonProps: { 'aria-label': '插入标题', title: 'I插入标题' },
139
+ }),
140
+ divider,
141
+ link,
142
+ quote,
143
+ code,
144
+ codeBlock,
145
+ comment,
146
+ image,
147
+ table,
148
+ divider,
149
+ unorderedListCommand,
150
+ orderedListCommand,
151
+ checkedListCommand,
152
+ divider,
153
+ help,
154
+ ];
155
+
156
+ export const getExtraCommands: () => ICommand[] = () => [codeEdit, codeLive, codePreview, divider, fullscreen];
157
+ export {
158
+ title,
159
+ title1,
160
+ title2,
161
+ title3,
162
+ title4,
163
+ title5,
164
+ title6,
165
+ bold,
166
+ codeBlock,
167
+ comment,
168
+ italic,
169
+ strikethrough,
170
+ hr,
171
+ group,
172
+ divider,
173
+ link,
174
+ quote,
175
+ code,
176
+ image,
177
+ unorderedListCommand,
178
+ orderedListCommand,
179
+ checkedListCommand,
180
+ table,
181
+ issue,
182
+ help,
183
+ codeEdit,
184
+ codeLive,
185
+ codePreview,
186
+ fullscreen,
187
+ };
@@ -12,8 +12,8 @@ export const issue: ICommand = {
12
12
  <svg role="img" width="12" height="12" viewBox="0 0 448 512">
13
13
  <path
14
14
  fill="currentColor"
15
- d="M181.3 32.4c17.4 2.9 29.2 19.4 26.3 36.8L197.8 128h95.1l11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3s29.2 19.4 26.3 36.8L357.8 128H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H347.1L325.8 320H384c17.7 0 32 14.3 32 32s-14.3 32-32 32H315.1l-11.5 69.3c-2.9 17.4-19.4 29.2-36.826.3s-29.2-19.4-26.3-36.8l9.8-58.7H155.1l-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8L90.2 384H32c-17.7 0-32-14.3-32-32s14.3-32 32-32h68.9l21.3-128H64c-17.7 0-32-14.3-32-32s14.3-32 32-32h68.9l11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3zM187.1 192L165.8320h95.1l21.3-128H187.1z"
16
- //Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
15
+ d="M181.3 32.4c17.4 2.9 29.2 19.4 26.3 36.8L197.8 128l95.1 0 11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3s29.2 19.4 26.3 36.8L357.8 128l58.2 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-68.9 0L325.8 320l58.2 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-68.9 0-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8l9.8-58.7-95.1 0-11.5 69.3c-2.9 17.4-19.4 29.2-36.8 26.3s-29.2-19.4-26.3-36.8L90.2 384 32 384c-17.7 0-32-14.3-32-32s14.3-32 32-32l68.9 0 21.3-128L64 192c-17.7 0-32-14.3-32-32s14.3-32 32-32l68.9 0 11.5-69.3c2.9-17.4 19.4-29.2 36.8-26.3zM187.1 192L165.8 320l95.1 0 21.3-128-95.1 0z"
16
+ //Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com
17
17
  />
18
18
  </svg>
19
19
  ),
@@ -1,4 +1,4 @@
1
- import React, { useEffect, Fragment, useContext } from 'react';
1
+ import React, { useEffect, Fragment, useContext, JSX } from 'react';
2
2
  import { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';
3
3
  import shortcuts from './shortcuts';
4
4
  import Textarea, { TextAreaProps } from './Textarea';
@@ -1,4 +1,4 @@
1
- import React, { useEffect, Fragment, useContext } from 'react';
1
+ import React, { useEffect, Fragment, useContext, JSX } from 'react';
2
2
  import { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';
3
3
  import shortcuts from './shortcuts';
4
4
  import Markdown from './Markdown';
@@ -1,4 +1,4 @@
1
- import React, { useContext, useMemo } from 'react';
1
+ import React, { useContext, useMemo, JSX } from 'react';
2
2
  import './Child.less';
3
3
  import Toolbar, { type IToolbarProps } from './';
4
4
  import { EditorContext } from '../../Context';