@uiw/react-md-editor 3.18.3 → 3.19.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.
- package/dist/mdeditor.js +1564 -1583
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.js.map +1 -1
- package/esm/Editor.js +43 -67
- package/esm/Editor.js.map +1 -1
- package/esm/commands/bold.js +4 -4
- package/esm/commands/bold.js.map +1 -1
- package/esm/commands/code.js +8 -10
- package/esm/commands/code.js.map +2 -2
- package/esm/commands/comment.js +27 -16
- package/esm/commands/comment.js.map +2 -2
- package/esm/commands/divider.js.map +1 -1
- package/esm/commands/fullscreen.js +3 -4
- package/esm/commands/fullscreen.js.map +2 -2
- package/esm/commands/group.js +2 -4
- package/esm/commands/group.js.map +1 -1
- package/esm/commands/hr.js.map +1 -1
- package/esm/commands/image.js +6 -6
- package/esm/commands/image.js.map +2 -2
- package/esm/commands/index.d.ts +2 -2
- package/esm/commands/index.js +12 -23
- package/esm/commands/index.js.map +3 -2
- package/esm/commands/italic.js +4 -4
- package/esm/commands/italic.js.map +1 -1
- package/esm/commands/link.js +4 -4
- package/esm/commands/link.js.map +1 -1
- package/esm/commands/list.js +4 -4
- package/esm/commands/list.js.map +1 -1
- package/esm/commands/preview.js +21 -3
- package/esm/commands/preview.js.map +7 -2
- package/esm/commands/quote.js +2 -1
- package/esm/commands/quote.js.map +1 -1
- package/esm/commands/strikeThrough.js +4 -4
- package/esm/commands/strikeThrough.js.map +1 -1
- package/esm/commands/title.js.map +1 -1
- package/esm/commands/title1.js.map +1 -1
- package/esm/commands/title2.js.map +1 -1
- package/esm/commands/title3.js.map +1 -1
- package/esm/commands/title4.js.map +1 -1
- package/esm/commands/title5.js.map +1 -1
- package/esm/commands/title6.js.map +1 -1
- package/esm/components/DragBar/index.js +2 -9
- package/esm/components/DragBar/index.js.map +1 -1
- package/esm/components/TextArea/Markdown.js +2 -7
- package/esm/components/TextArea/Markdown.js.map +1 -1
- package/esm/components/TextArea/Textarea.js +8 -11
- package/esm/components/TextArea/Textarea.js.map +1 -1
- package/esm/components/TextArea/handleKeyDown.js +2 -16
- package/esm/components/TextArea/handleKeyDown.js.map +1 -1
- package/esm/components/TextArea/index.js +11 -15
- package/esm/components/TextArea/index.js.map +1 -1
- package/esm/components/TextArea/shortcuts.js +1 -17
- package/esm/components/TextArea/shortcuts.js.map +2 -2
- package/esm/components/Toolbar/Child.js +2 -1
- package/esm/components/Toolbar/Child.js.map +1 -1
- package/esm/components/Toolbar/index.js +2 -12
- package/esm/components/Toolbar/index.js.map +1 -1
- package/esm/index.js.map +1 -1
- package/esm/utils/InsertTextAtPosition.js +28 -34
- package/esm/utils/InsertTextAtPosition.js.map +1 -1
- package/esm/utils/markdownUtils.js +14 -23
- package/esm/utils/markdownUtils.js.map +1 -1
- package/lib/Context.js +0 -6
- package/lib/Context.js.map +1 -1
- package/lib/Editor.js +74 -114
- package/lib/Editor.js.map +1 -1
- package/lib/commands/bold.js +4 -9
- package/lib/commands/bold.js.map +1 -1
- package/lib/commands/code.js +8 -15
- package/lib/commands/code.js.map +2 -2
- package/lib/commands/comment.js +27 -19
- package/lib/commands/comment.js.map +2 -2
- package/lib/commands/divider.js.map +1 -1
- package/lib/commands/fullscreen.js +3 -8
- package/lib/commands/fullscreen.js.map +2 -2
- package/lib/commands/group.js +2 -10
- package/lib/commands/group.js.map +1 -1
- package/lib/commands/hr.js +0 -4
- package/lib/commands/hr.js.map +1 -1
- package/lib/commands/image.js +6 -11
- package/lib/commands/image.js.map +2 -2
- package/lib/commands/index.d.ts +2 -2
- package/lib/commands/index.js +10 -47
- package/lib/commands/index.js.map +4 -3
- package/lib/commands/italic.js +4 -9
- package/lib/commands/italic.js.map +1 -1
- package/lib/commands/link.js +4 -9
- package/lib/commands/link.js.map +1 -1
- package/lib/commands/list.js +4 -10
- package/lib/commands/list.js.map +1 -1
- package/lib/commands/preview.js +21 -7
- package/lib/commands/preview.js.map +7 -2
- package/lib/commands/quote.js +2 -6
- package/lib/commands/quote.js.map +1 -1
- package/lib/commands/strikeThrough.js +4 -9
- package/lib/commands/strikeThrough.js.map +1 -1
- package/lib/commands/title.js +0 -6
- package/lib/commands/title.js.map +1 -1
- package/lib/commands/title1.js +0 -5
- package/lib/commands/title1.js.map +1 -1
- package/lib/commands/title2.js +0 -5
- package/lib/commands/title2.js.map +1 -1
- package/lib/commands/title3.js +0 -5
- package/lib/commands/title3.js.map +1 -1
- package/lib/commands/title4.js +0 -5
- package/lib/commands/title4.js.map +1 -1
- package/lib/commands/title5.js +0 -5
- package/lib/commands/title5.js.map +1 -1
- package/lib/commands/title6.js +0 -5
- package/lib/commands/title6.js.map +1 -1
- package/lib/components/DragBar/index.js +4 -15
- package/lib/components/DragBar/index.js.map +1 -1
- package/lib/components/TextArea/Markdown.js +6 -22
- package/lib/components/TextArea/Markdown.js.map +1 -1
- package/lib/components/TextArea/Textarea.js +15 -36
- package/lib/components/TextArea/Textarea.js.map +1 -1
- package/lib/components/TextArea/handleKeyDown.js +1 -18
- package/lib/components/TextArea/handleKeyDown.js.map +1 -1
- package/lib/components/TextArea/index.js +15 -37
- package/lib/components/TextArea/index.js.map +1 -1
- package/lib/components/TextArea/shortcuts.js +1 -17
- package/lib/components/TextArea/shortcuts.js.map +2 -2
- package/lib/components/Toolbar/Child.js +8 -18
- package/lib/components/Toolbar/Child.js.map +1 -1
- package/lib/components/Toolbar/index.js +14 -36
- package/lib/components/Toolbar/index.js.map +1 -1
- package/lib/index.js +0 -9
- package/lib/index.js.map +1 -1
- package/lib/utils/InsertTextAtPosition.js +28 -37
- package/lib/utils/InsertTextAtPosition.js.map +1 -1
- package/lib/utils/markdownUtils.js +17 -28
- package/lib/utils/markdownUtils.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/code.tsx +2 -2
- package/src/commands/comment.tsx +19 -4
- package/src/commands/fullscreen.tsx +3 -2
- package/src/commands/image.tsx +1 -1
- package/src/commands/index.ts +8 -7
- package/src/commands/preview.tsx +35 -4
- package/src/components/TextArea/shortcuts.ts +2 -2
|
@@ -1,80 +1,59 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
-
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = TextArea;
|
|
11
|
-
|
|
12
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
-
|
|
14
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _Context = require("../../Context");
|
|
19
|
-
|
|
20
13
|
var _shortcuts = _interopRequireDefault(require("./shortcuts"));
|
|
21
|
-
|
|
22
14
|
var _Markdown = _interopRequireDefault(require("./Markdown"));
|
|
23
|
-
|
|
24
15
|
var _Textarea = _interopRequireDefault(require("./Textarea"));
|
|
25
|
-
|
|
26
16
|
var _commands = require("../../commands");
|
|
27
|
-
|
|
28
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
29
|
-
|
|
30
18
|
var _excluded = ["prefixCls", "className", "onScroll", "renderTextarea"];
|
|
31
|
-
|
|
32
19
|
function TextArea(props) {
|
|
33
20
|
var _ref = props || {},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
21
|
+
prefixCls = _ref.prefixCls,
|
|
22
|
+
className = _ref.className,
|
|
23
|
+
onScroll = _ref.onScroll,
|
|
24
|
+
renderTextarea = _ref.renderTextarea,
|
|
25
|
+
otherProps = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
40
26
|
var _useContext = (0, _react.useContext)(_Context.EditorContext),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
27
|
+
markdown = _useContext.markdown,
|
|
28
|
+
scrollTop = _useContext.scrollTop,
|
|
29
|
+
commands = _useContext.commands,
|
|
30
|
+
highlightEnable = _useContext.highlightEnable,
|
|
31
|
+
extraCommands = _useContext.extraCommands,
|
|
32
|
+
dispatch = _useContext.dispatch;
|
|
48
33
|
var textRef = _react["default"].useRef(null);
|
|
49
|
-
|
|
50
34
|
var executeRef = _react["default"].useRef();
|
|
51
|
-
|
|
52
35
|
var warp = /*#__PURE__*/_react["default"].createRef();
|
|
53
|
-
|
|
54
36
|
(0, _react.useEffect)(function () {
|
|
55
37
|
var state = {};
|
|
56
|
-
|
|
57
38
|
if (warp.current) {
|
|
58
39
|
state.textareaWarp = warp.current || undefined;
|
|
59
40
|
warp.current.scrollTop = scrollTop || 0;
|
|
60
41
|
}
|
|
61
|
-
|
|
62
42
|
if (dispatch) {
|
|
63
43
|
dispatch((0, _objectSpread2["default"])({}, state));
|
|
64
|
-
}
|
|
65
|
-
|
|
44
|
+
}
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
66
46
|
}, []);
|
|
67
47
|
(0, _react.useEffect)(function () {
|
|
68
48
|
if (textRef.current && dispatch) {
|
|
69
49
|
var _commandOrchestrator = new _commands.TextAreaCommandOrchestrator(textRef.current);
|
|
70
|
-
|
|
71
50
|
executeRef.current = _commandOrchestrator;
|
|
72
51
|
dispatch({
|
|
73
52
|
textarea: textRef.current,
|
|
74
53
|
commandOrchestrator: _commandOrchestrator
|
|
75
54
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
55
|
+
}
|
|
56
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78
57
|
}, []);
|
|
79
58
|
var textStyle = highlightEnable ? {} : {
|
|
80
59
|
WebkitTextFillColor: 'initial',
|
|
@@ -120,6 +99,5 @@ function TextArea(props) {
|
|
|
120
99
|
})
|
|
121
100
|
});
|
|
122
101
|
}
|
|
123
|
-
|
|
124
102
|
module.exports = exports.default;
|
|
125
103
|
//# sourceMappingURL=index.js.map
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"sourcesContent": [
|
|
51
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 const textStyle: React.CSSProperties = highlightEnable ? {} : { WebkitTextFillColor: 'initial', overflow: 'auto' };\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"
|
|
52
52
|
],
|
|
53
|
-
"mappings": "
|
|
53
|
+
"mappings": ";;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AAEA;AAAuE;AAAA;AAoCxD,SAASA,QAAQ,CAACC,KAAqB,EAAE;EACtD,WAA0EA,KAAK,IAAI,CAAC,CAAC;IAA7EC,SAAS,QAATA,SAAS;IAAEC,SAAS,QAATA,SAAS;IAAEC,QAAQ,QAARA,QAAQ;IAAEC,cAAc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E;IAAK,GAAG,EAAEZ,IAAK;IAAC,SAAS,YAAKjB,SAAS,mBAASC,SAAS,IAAI,EAAE,CAAG;IAAC,QAAQ,EAAEC,QAAS;IAAA,uBACpF;MAAK,SAAS,YAAKF,SAAS,UAAQ;MAAA,UACjCG,cAAc,gBACbW,iBAAK,CAACgB,YAAY,CAChB3B,cAAc,mEAEPC,UAAU;QACb2B,KAAK,EAAExB,QAAQ;QACfyB,YAAY,EAAE,KAAK;QACnBC,WAAW,EAAE,KAAK;QAClBC,UAAU,EAAE,OAAO;QACnBC,cAAc,EAAE,KAAK;QACrBlC,SAAS,YAAKD,SAAS,gBAAa;QACpCoC,KAAK,EAAE;UACLR,mBAAmB,EAAE,SAAS;UAC9BC,QAAQ,EAAE;QACZ;MAAC,IAEH;QACEjB,QAAQ,EAARA,QAAQ;QACRyB,QAAQ,EAAEjC,UAAU,CAACiC,QAAQ;QAC7BC,SAAS,EAATA,qBAAS;QACTjC,UAAU,EAAE;UAAEI,QAAQ,EAARA,QAAQ;UAAEE,aAAa,EAAbA,aAAa;UAAEa,mBAAmB,EAAER,UAAU,CAACK;QAAQ;MACjF,CAAC,CACF,EACD;QACEkB,GAAG,EAAE1B;MACP,CAAC,CACF,gBAED,sBAAC,eAAQ;QAAA,WACNH,eAAe,iBAAI,qBAAC,oBAAQ;UAAC,SAAS,EAAEV;QAAU,EAAG,eACtD,qBAAC,oBAAQ;UAAC,SAAS,EAAEA;QAAU,GAAKI,UAAU;UAAE,KAAK,EAAEuB;QAAU,GAAG;MAAA;IAEvE;EACG,EACF;AAEV;AAAC"
|
|
54
54
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports["default"] = shortcutsHandle;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
function getCommands() {
|
|
13
10
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
14
11
|
var resulte = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -21,7 +18,6 @@ function getCommands() {
|
|
|
21
18
|
});
|
|
22
19
|
return resulte;
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
function shortcutsHandle(e) {
|
|
26
22
|
var commands = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
27
23
|
var commandOrchestrator = arguments.length > 2 ? arguments[2] : undefined;
|
|
@@ -29,35 +25,27 @@ function shortcutsHandle(e) {
|
|
|
29
25
|
var state = arguments.length > 4 ? arguments[4] : undefined;
|
|
30
26
|
var data = getCommands(commands || []);
|
|
31
27
|
var shortcuts = [];
|
|
32
|
-
|
|
33
28
|
if (e.altKey) {
|
|
34
29
|
shortcuts.push('alt');
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
if (e.shiftKey) {
|
|
38
32
|
shortcuts.push('shift');
|
|
39
33
|
}
|
|
40
|
-
|
|
41
34
|
if (e.metaKey) {
|
|
42
35
|
shortcuts.push('cmd');
|
|
43
36
|
}
|
|
44
|
-
|
|
45
37
|
if (e.ctrlKey) {
|
|
46
38
|
shortcuts.push('ctrl');
|
|
47
39
|
}
|
|
48
|
-
|
|
49
40
|
if (shortcuts.length > 0 && !/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())) {
|
|
50
41
|
shortcuts.push(e.key.toLocaleLowerCase());
|
|
51
42
|
}
|
|
52
|
-
|
|
53
43
|
if (/escape/.test(e.key.toLocaleLowerCase())) {
|
|
54
44
|
shortcuts.push('escape');
|
|
55
45
|
}
|
|
56
|
-
|
|
57
46
|
if (shortcuts.length < 1) {
|
|
58
47
|
return;
|
|
59
48
|
}
|
|
60
|
-
|
|
61
49
|
var equal = !!data[shortcuts.join('+')];
|
|
62
50
|
var command = equal ? data[shortcuts.join('+')] : undefined;
|
|
63
51
|
Object.keys(data).forEach(function (item) {
|
|
@@ -65,22 +53,18 @@ function shortcutsHandle(e) {
|
|
|
65
53
|
if (/ctrlcmd/.test(v)) {
|
|
66
54
|
return shortcuts.includes('ctrl') || shortcuts.includes('cmd');
|
|
67
55
|
}
|
|
68
|
-
|
|
69
56
|
return shortcuts.includes(v);
|
|
70
57
|
});
|
|
71
|
-
|
|
72
58
|
if (isequal) {
|
|
73
59
|
command = data[item];
|
|
74
60
|
}
|
|
75
61
|
});
|
|
76
|
-
|
|
77
62
|
if (command && commandOrchestrator) {
|
|
78
63
|
e.stopPropagation();
|
|
79
64
|
e.preventDefault();
|
|
80
|
-
commandOrchestrator.executeCommand(command, dispatch, state);
|
|
65
|
+
commandOrchestrator.executeCommand(command, dispatch, state, shortcuts);
|
|
81
66
|
return;
|
|
82
67
|
}
|
|
83
68
|
}
|
|
84
|
-
|
|
85
69
|
module.exports = exports.default;
|
|
86
70
|
//# sourceMappingURL=shortcuts.js.map
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"../../../src/components/TextArea/shortcuts.ts"
|
|
47
47
|
],
|
|
48
48
|
"sourcesContent": [
|
|
49
|
-
"import { ICommand, TextAreaCommandOrchestrator } from '../../commands';\nimport { ContextStore, ExecuteCommandState } from '../../Context';\n\nfunction getCommands(data: ICommand[] = [], resulte: Record<string, ICommand> = {}): Record<string, ICommand> {\n data.forEach((item) => {\n if (item.children && Array.isArray(item.children)) {\n resulte = { ...resulte, ...getCommands(item.children || []) };\n } else if (item.keyCommand && item.shortcuts && item.execute) {\n resulte[item.shortcuts.toLocaleLowerCase()] = item;\n }\n });\n return resulte;\n}\n\nexport default function shortcutsHandle(\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[] = [],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n) {\n const data = getCommands(commands || []);\n const shortcuts:
|
|
49
|
+
"import { ICommand, TextAreaCommandOrchestrator } from '../../commands';\nimport { ContextStore, ExecuteCommandState } from '../../Context';\n\nfunction getCommands(data: ICommand[] = [], resulte: Record<string, ICommand> = {}): Record<string, ICommand> {\n data.forEach((item) => {\n if (item.children && Array.isArray(item.children)) {\n resulte = { ...resulte, ...getCommands(item.children || []) };\n } else if (item.keyCommand && item.shortcuts && item.execute) {\n resulte[item.shortcuts.toLocaleLowerCase()] = item;\n }\n });\n return resulte;\n}\n\nexport default function shortcutsHandle(\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[] = [],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n) {\n const data = getCommands(commands || []);\n const shortcuts: string[] = [];\n if (e.altKey) {\n shortcuts.push('alt');\n }\n if (e.shiftKey) {\n shortcuts.push('shift');\n }\n if (e.metaKey) {\n shortcuts.push('cmd');\n }\n if (e.ctrlKey) {\n shortcuts.push('ctrl');\n }\n if (shortcuts.length > 0 && !/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push(e.key.toLocaleLowerCase());\n }\n if (/escape/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push('escape');\n }\n if (shortcuts.length < 1) {\n return;\n }\n\n let equal = !!data[shortcuts.join('+')];\n let command = equal ? data[shortcuts.join('+')] : undefined;\n\n Object.keys(data).forEach((item) => {\n const isequal = item.split('+').every((v) => {\n if (/ctrlcmd/.test(v)) {\n return shortcuts.includes('ctrl') || shortcuts.includes('cmd');\n }\n return shortcuts.includes(v);\n });\n if (isequal) {\n command = data[item];\n }\n });\n if (command && commandOrchestrator) {\n e.stopPropagation();\n e.preventDefault();\n commandOrchestrator.executeCommand(command, dispatch, state, shortcuts);\n return;\n }\n}\n"
|
|
50
50
|
],
|
|
51
|
-
"mappings": "
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AAEC,KAAK,EAAER,SAAS,CAAC;IACvE;EACF;AACF;AAAC"
|
|
52
52
|
}
|
|
@@ -1,35 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports["default"] = Child;
|
|
11
|
-
|
|
12
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
-
|
|
14
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
-
|
|
16
11
|
var _ = _interopRequireDefault(require("./"));
|
|
17
|
-
|
|
18
12
|
var _Context = require("../../Context");
|
|
19
|
-
|
|
20
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
-
|
|
22
14
|
function Child(props) {
|
|
23
15
|
var _ref = props || {},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
prefixCls = _ref.prefixCls,
|
|
17
|
+
groupName = _ref.groupName,
|
|
18
|
+
commands = _ref.commands,
|
|
19
|
+
children = _ref.children;
|
|
29
20
|
var _useContext = (0, _react.useContext)(_Context.EditorContext),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
_useContext$barPopup = _useContext.barPopup,
|
|
22
|
+
barPopup = _useContext$barPopup === void 0 ? {} : _useContext$barPopup;
|
|
33
23
|
return (0, _react.useMemo)(function () {
|
|
34
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
35
25
|
className: "".concat(prefixCls, "-toolbar-child ").concat(groupName && barPopup[groupName] ? 'active' : ''),
|
|
@@ -42,9 +32,9 @@ function Child(props) {
|
|
|
42
32
|
isChild: true
|
|
43
33
|
})) : children
|
|
44
34
|
});
|
|
45
|
-
},
|
|
35
|
+
},
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
37
|
[commands, barPopup, groupName, prefixCls]);
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
module.exports = exports.default;
|
|
50
40
|
//# sourceMappingURL=Child.js.map
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"sourcesContent": [
|
|
23
23
|
"import React, { useContext, useMemo } from 'react';\nimport './Child.less';\nimport Toolbar, { IToolbarProps } from './';\nimport { EditorContext } from '../../Context';\n\nexport type ChildProps = IToolbarProps & {\n children?: JSX.Element;\n groupName?: string;\n};\n\nexport default function Child(props: ChildProps) {\n const { prefixCls, groupName, commands, children } = props || {};\n const { barPopup = {} } = useContext(EditorContext);\n return useMemo(\n () => (\n <div\n className={`${prefixCls}-toolbar-child ${groupName && barPopup[groupName] ? 'active' : ''}`}\n onClick={(e) => e.stopPropagation()}\n >\n {Array.isArray(commands) ? <Toolbar commands={commands} {...props} isChild /> : children}\n </div>\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [commands, barPopup, groupName, prefixCls],\n );\n}\n"
|
|
24
24
|
],
|
|
25
|
-
"mappings": "
|
|
25
|
+
"mappings": ";;;;;;;;;AAAA;AAEA;AACA;AAA8C;AAO/B,SAASA,KAAK,CAACC,KAAiB,EAAE;EAC/C,WAAqDA,KAAK,IAAI,CAAC,CAAC;IAAxDC,SAAS,QAATA,SAAS;IAAEC,SAAS,QAATA,SAAS;IAAEC,QAAQ,QAARA,QAAQ;IAAEC,QAAQ,QAARA,QAAQ;EAChD,kBAA0B,IAAAC,iBAAU,EAACC,sBAAa,CAAC;IAAA,mCAA3CC,QAAQ;IAARA,QAAQ,qCAAG,CAAC,CAAC;EACrB,OAAO,IAAAC,cAAO,EACZ;IAAA,oBACE;MACE,SAAS,YAAKP,SAAS,4BAAkBC,SAAS,IAAIK,QAAQ,CAACL,SAAS,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAG;MAC5F,OAAO,EAAE,iBAACO,CAAC;QAAA,OAAKA,CAAC,CAACC,eAAe,EAAE;MAAA,CAAC;MAAA,UAEnCC,KAAK,CAACC,OAAO,CAACT,QAAQ,CAAC,gBAAG,qBAAC,YAAO;QAAC,QAAQ,EAAEA;MAAS,GAAKH,KAAK;QAAE,OAAO;MAAA,GAAG,GAAGI;IAAQ,EACpF;EAAA,CACP;EACD;EACA,CAACD,QAAQ,EAAEI,QAAQ,EAAEL,SAAS,EAAED,SAAS,CAAC,CAC3C;AACH;AAAC"
|
|
26
26
|
}
|
|
@@ -1,54 +1,40 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.ToolbarItems = ToolbarItems;
|
|
11
9
|
exports["default"] = Toolbar;
|
|
12
|
-
|
|
13
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
14
|
-
|
|
15
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
16
|
-
|
|
17
12
|
var _Context = require("../../Context");
|
|
18
|
-
|
|
19
13
|
var _Child = _interopRequireDefault(require("./Child"));
|
|
20
|
-
|
|
21
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
|
-
|
|
23
15
|
function ToolbarItems(props) {
|
|
24
16
|
var prefixCls = props.prefixCls,
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
overflow = props.overflow;
|
|
27
18
|
var _useContext = (0, _react.useContext)(_Context.EditorContext),
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
fullscreen = _useContext.fullscreen,
|
|
20
|
+
preview = _useContext.preview,
|
|
21
|
+
_useContext$barPopup = _useContext.barPopup,
|
|
22
|
+
barPopup = _useContext$barPopup === void 0 ? {} : _useContext$barPopup,
|
|
23
|
+
components = _useContext.components,
|
|
24
|
+
commandOrchestrator = _useContext.commandOrchestrator,
|
|
25
|
+
dispatch = _useContext.dispatch;
|
|
36
26
|
var originalOverflow = (0, _react.useRef)('');
|
|
37
|
-
|
|
38
27
|
function handleClick(command, name) {
|
|
39
28
|
if (!dispatch) return;
|
|
40
29
|
var state = {
|
|
41
30
|
barPopup: (0, _objectSpread2["default"])({}, barPopup)
|
|
42
31
|
};
|
|
43
|
-
|
|
44
32
|
if (command.keyCommand === 'preview') {
|
|
45
33
|
state.preview = command.value;
|
|
46
34
|
}
|
|
47
|
-
|
|
48
35
|
if (command.keyCommand === 'fullscreen') {
|
|
49
36
|
state.fullscreen = !fullscreen;
|
|
50
37
|
}
|
|
51
|
-
|
|
52
38
|
if (props.commands && command.keyCommand === 'group') {
|
|
53
39
|
props.commands.forEach(function (item) {
|
|
54
40
|
if (name === item.groupName) {
|
|
@@ -62,14 +48,11 @@ function ToolbarItems(props) {
|
|
|
62
48
|
state.barPopup[keyName] = false;
|
|
63
49
|
});
|
|
64
50
|
}
|
|
65
|
-
|
|
66
51
|
if (Object.keys(state).length) {
|
|
67
52
|
dispatch((0, _objectSpread2["default"])({}, state));
|
|
68
53
|
}
|
|
69
|
-
|
|
70
54
|
commandOrchestrator && commandOrchestrator.executeCommand(command);
|
|
71
55
|
}
|
|
72
|
-
|
|
73
56
|
(0, _react.useEffect)(function () {
|
|
74
57
|
if (document && overflow) {
|
|
75
58
|
if (fullscreen) {
|
|
@@ -79,9 +62,8 @@ function ToolbarItems(props) {
|
|
|
79
62
|
// get the original overflow only the first time
|
|
80
63
|
if (!originalOverflow.current) {
|
|
81
64
|
originalOverflow.current = window.getComputedStyle(document.body, null).overflow;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
65
|
+
}
|
|
66
|
+
// reset to the original overflow
|
|
85
67
|
document.body.style.overflow = originalOverflow.current;
|
|
86
68
|
}
|
|
87
69
|
}
|
|
@@ -93,7 +75,6 @@ function ToolbarItems(props) {
|
|
|
93
75
|
className: "".concat(prefixCls, "-toolbar-divider")
|
|
94
76
|
}), idx);
|
|
95
77
|
}
|
|
96
|
-
|
|
97
78
|
if (!item.keyCommand) return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {}, idx);
|
|
98
79
|
var activeBtn = fullscreen && item.keyCommand === 'fullscreen' || item.keyCommand === 'preview' && preview === item.value;
|
|
99
80
|
var childNode = item.children && typeof item.children === 'function' ? item.children({
|
|
@@ -136,17 +117,14 @@ function ToolbarItems(props) {
|
|
|
136
117
|
})
|
|
137
118
|
});
|
|
138
119
|
}
|
|
139
|
-
|
|
140
120
|
function Toolbar() {
|
|
141
121
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
142
122
|
var prefixCls = props.prefixCls,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
123
|
+
toolbarBottom = props.toolbarBottom,
|
|
124
|
+
isChild = props.isChild;
|
|
146
125
|
var _useContext2 = (0, _react.useContext)(_Context.EditorContext),
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
126
|
+
commands = _useContext2.commands,
|
|
127
|
+
extraCommands = _useContext2.extraCommands;
|
|
150
128
|
var bottomClassName = toolbarBottom ? 'bottom' : '';
|
|
151
129
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
152
130
|
className: "".concat(prefixCls, "-toolbar ").concat(bottomClassName),
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"sourcesContent": [
|
|
79
79
|
"import React, { Fragment, useContext, useEffect, useRef } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, PreviewType, ContextStore } from '../../Context';\nimport { ICommand } from '../../commands';\nimport Child from './Child';\nimport './index.less';\n\nexport interface IToolbarProps extends IProps {\n overflow?: boolean;\n toolbarBottom?: boolean;\n onCommand?: (command: ICommand<string>, groupName?: string) => void;\n commands?: ICommand<string>[];\n isChild?: boolean;\n}\n\nexport function ToolbarItems(props: IToolbarProps) {\n const { prefixCls, overflow } = props;\n const { fullscreen, preview, barPopup = {}, components, commandOrchestrator, dispatch } = useContext(EditorContext);\n const originalOverflow = useRef('');\n\n function handleClick(command: ICommand<string>, name?: string) {\n if (!dispatch) return;\n const state: ContextStore = { barPopup: { ...barPopup } };\n if (command.keyCommand === 'preview') {\n state.preview = command.value as PreviewType;\n }\n if (command.keyCommand === 'fullscreen') {\n state.fullscreen = !fullscreen;\n }\n if (props.commands && command.keyCommand === 'group') {\n props.commands.forEach((item) => {\n if (name === item.groupName) {\n state.barPopup![name!] = true;\n } else if (item.keyCommand) {\n state.barPopup![item.groupName!] = false;\n }\n });\n } else if (name || command.parent) {\n Object.keys(state.barPopup || {}).forEach((keyName) => {\n state.barPopup![keyName] = false;\n });\n }\n\n if (Object.keys(state).length) {\n dispatch({ ...state });\n }\n commandOrchestrator && commandOrchestrator.executeCommand(command);\n }\n\n useEffect(() => {\n if (document && overflow) {\n if (fullscreen) {\n // prevent scroll on fullscreen\n document.body.style.overflow = 'hidden';\n } else {\n // get the original overflow only the first time\n if (!originalOverflow.current) {\n originalOverflow.current = window.getComputedStyle(document.body, null).overflow;\n }\n // reset to the original overflow\n document.body.style.overflow = originalOverflow.current;\n }\n }\n }, [fullscreen, originalOverflow, overflow]);\n\n return (\n <ul>\n {(props.commands || []).map((item, idx) => {\n if (item.keyCommand === 'divider') {\n return <li key={idx} {...item.liProps} className={`${prefixCls}-toolbar-divider`} />;\n }\n if (!item.keyCommand) return <Fragment key={idx} />;\n const activeBtn =\n (fullscreen && item.keyCommand === 'fullscreen') || (item.keyCommand === 'preview' && preview === item.value);\n const childNode =\n item.children && typeof item.children === 'function'\n ? item.children({\n getState: () => commandOrchestrator!.getState(),\n textApi: commandOrchestrator ? commandOrchestrator!.textApi : undefined,\n close: () => handleClick({}, item.groupName),\n execute: () => handleClick({ execute: item.execute }),\n })\n : undefined;\n const disabled = barPopup && preview && preview === 'preview' && !/(preview|fullscreen)/.test(item.keyCommand);\n const render = components?.toolbar || item.render;\n const com = (\n render && typeof render === 'function' ? render(item, !!disabled, handleClick, idx) : null\n ) as React.ReactElement;\n return (\n <li key={idx} {...item.liProps} className={activeBtn ? `active` : ''}>\n {com && React.isValidElement(com) && com}\n {!com && !item.buttonProps && item.icon}\n {!com &&\n item.buttonProps &&\n React.createElement(\n 'button',\n {\n type: 'button',\n key: idx,\n disabled,\n 'data-name': item.name,\n ...item.buttonProps,\n onClick: (evn: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {\n evn.stopPropagation();\n handleClick(item, item.groupName);\n },\n },\n item.icon,\n )}\n {item.children && (\n <Child\n overflow={overflow}\n groupName={item.groupName}\n prefixCls={prefixCls}\n children={childNode}\n commands={Array.isArray(item.children) ? item.children : undefined}\n />\n )}\n </li>\n );\n })}\n </ul>\n );\n}\n\nexport default function Toolbar(props: IToolbarProps = {}) {\n const { prefixCls, toolbarBottom, isChild } = props;\n const { commands, extraCommands } = useContext(EditorContext);\n const bottomClassName = toolbarBottom ? 'bottom' : '';\n return (\n <div className={`${prefixCls}-toolbar ${bottomClassName}`}>\n <ToolbarItems {...props} commands={props.commands || commands || []} />\n {!isChild && <ToolbarItems {...props} commands={extraCommands || []} />}\n </div>\n );\n}\n"
|
|
80
80
|
],
|
|
81
|
-
"mappings": "
|
|
81
|
+
"mappings": ";;;;;;;;;;AAAA;AAEA;AAEA;AAA4B;AAWrB,SAASA,YAAY,CAACC,KAAoB,EAAE;EACjD,IAAQC,SAAS,GAAeD,KAAK,CAA7BC,SAAS;IAAEC,QAAQ,GAAKF,KAAK,CAAlBE,QAAQ;EAC3B,kBAA0F,IAAAC,iBAAU,EAACC,sBAAa,CAAC;IAA3GC,UAAU,e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ACtE,CAAC+C,OAAO,iBAAI,qBAAC,YAAY,oEAAKlE,KAAK;MAAE,QAAQ,EAAEmE,aAAa,IAAI;IAAG,GAAG;EAAA,EACnE;AAEV"
|
|
82
82
|
}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -10,9 +9,7 @@ var _exportNames = {
|
|
|
10
9
|
MarkdownUtil: true
|
|
11
10
|
};
|
|
12
11
|
exports["default"] = exports.commands = exports.MarkdownUtil = void 0;
|
|
13
|
-
|
|
14
12
|
var _Editor = _interopRequireWildcard(require("./Editor"));
|
|
15
|
-
|
|
16
13
|
Object.keys(_Editor).forEach(function (key) {
|
|
17
14
|
if (key === "default" || key === "__esModule") return;
|
|
18
15
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
@@ -24,9 +21,7 @@ Object.keys(_Editor).forEach(function (key) {
|
|
|
24
21
|
}
|
|
25
22
|
});
|
|
26
23
|
});
|
|
27
|
-
|
|
28
24
|
var commands = _interopRequireWildcard(require("./commands"));
|
|
29
|
-
|
|
30
25
|
exports.commands = commands;
|
|
31
26
|
Object.keys(commands).forEach(function (key) {
|
|
32
27
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -39,9 +34,7 @@ Object.keys(commands).forEach(function (key) {
|
|
|
39
34
|
}
|
|
40
35
|
});
|
|
41
36
|
});
|
|
42
|
-
|
|
43
37
|
var MarkdownUtil = _interopRequireWildcard(require("./utils/markdownUtils"));
|
|
44
|
-
|
|
45
38
|
exports.MarkdownUtil = MarkdownUtil;
|
|
46
39
|
Object.keys(MarkdownUtil).forEach(function (key) {
|
|
47
40
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -54,9 +47,7 @@ Object.keys(MarkdownUtil).forEach(function (key) {
|
|
|
54
47
|
}
|
|
55
48
|
});
|
|
56
49
|
});
|
|
57
|
-
|
|
58
50
|
var _Context = require("./Context");
|
|
59
|
-
|
|
60
51
|
Object.keys(_Context).forEach(function (key) {
|
|
61
52
|
if (key === "default" || key === "__esModule") return;
|
|
62
53
|
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
package/lib/index.js.map
CHANGED
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
"sourcesContent": [
|
|
10
10
|
"import MDEditor from './Editor';\nimport * as commands from './commands';\nimport * as MarkdownUtil from './utils/markdownUtils';\n\nexport * from './commands';\nexport * from './utils/markdownUtils';\nexport * from './Editor';\nexport * from './Context';\n\nexport { MarkdownUtil, commands };\n\nexport default MDEditor;\n"
|
|
11
11
|
],
|
|
12
|
-
"mappings": "
|
|
12
|
+
"mappings": ";;;;;;;;;;;AAAA;AAMA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AALA;AAAuC;AAGvC;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAFA;AAAsD;AAGtD;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAEA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAA0B,eAIXA,kBAAQ;AAAA"
|
|
13
13
|
}
|