@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,14 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
2
|
function getCommands(data, resulte) {
|
|
4
3
|
if (data === void 0) {
|
|
5
4
|
data = [];
|
|
6
5
|
}
|
|
7
|
-
|
|
8
6
|
if (resulte === void 0) {
|
|
9
7
|
resulte = {};
|
|
10
8
|
}
|
|
11
|
-
|
|
12
9
|
data.forEach(item => {
|
|
13
10
|
if (item.children && Array.isArray(item.children)) {
|
|
14
11
|
resulte = _extends({}, resulte, getCommands(item.children || []));
|
|
@@ -18,43 +15,33 @@ function getCommands(data, resulte) {
|
|
|
18
15
|
});
|
|
19
16
|
return resulte;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
export default function shortcutsHandle(e, commands, commandOrchestrator, dispatch, state) {
|
|
23
19
|
if (commands === void 0) {
|
|
24
20
|
commands = [];
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
var data = getCommands(commands || []);
|
|
28
23
|
var shortcuts = [];
|
|
29
|
-
|
|
30
24
|
if (e.altKey) {
|
|
31
25
|
shortcuts.push('alt');
|
|
32
26
|
}
|
|
33
|
-
|
|
34
27
|
if (e.shiftKey) {
|
|
35
28
|
shortcuts.push('shift');
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
if (e.metaKey) {
|
|
39
31
|
shortcuts.push('cmd');
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
if (e.ctrlKey) {
|
|
43
34
|
shortcuts.push('ctrl');
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
if (shortcuts.length > 0 && !/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())) {
|
|
47
37
|
shortcuts.push(e.key.toLocaleLowerCase());
|
|
48
38
|
}
|
|
49
|
-
|
|
50
39
|
if (/escape/.test(e.key.toLocaleLowerCase())) {
|
|
51
40
|
shortcuts.push('escape');
|
|
52
41
|
}
|
|
53
|
-
|
|
54
42
|
if (shortcuts.length < 1) {
|
|
55
43
|
return;
|
|
56
44
|
}
|
|
57
|
-
|
|
58
45
|
var equal = !!data[shortcuts.join('+')];
|
|
59
46
|
var command = equal ? data[shortcuts.join('+')] : undefined;
|
|
60
47
|
Object.keys(data).forEach(item => {
|
|
@@ -62,19 +49,16 @@ export default function shortcutsHandle(e, commands, commandOrchestrator, dispat
|
|
|
62
49
|
if (/ctrlcmd/.test(v)) {
|
|
63
50
|
return shortcuts.includes('ctrl') || shortcuts.includes('cmd');
|
|
64
51
|
}
|
|
65
|
-
|
|
66
52
|
return shortcuts.includes(v);
|
|
67
53
|
});
|
|
68
|
-
|
|
69
54
|
if (isequal) {
|
|
70
55
|
command = data[item];
|
|
71
56
|
}
|
|
72
57
|
});
|
|
73
|
-
|
|
74
58
|
if (command && commandOrchestrator) {
|
|
75
59
|
e.stopPropagation();
|
|
76
60
|
e.preventDefault();
|
|
77
|
-
commandOrchestrator.executeCommand(command, dispatch, state);
|
|
61
|
+
commandOrchestrator.executeCommand(command, dispatch, state, shortcuts);
|
|
78
62
|
return;
|
|
79
63
|
}
|
|
80
64
|
}
|
|
@@ -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
|
],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BxB,CAAC,CAACyB,cAAc,EAAE;IAClBvB,mBAAmB,CAACwB,cAAc,CAACX,OAAO,EAAEZ,QAAQ,EAAEC,KAAK,EAAER,SAAS,CAAC;IACvE;EACF;AACF"
|
|
52
52
|
}
|
|
@@ -22,7 +22,8 @@ export default function Child(props) {
|
|
|
22
22
|
}, props, {
|
|
23
23
|
isChild: true
|
|
24
24
|
})) : children
|
|
25
|
-
}),
|
|
25
|
+
}),
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
27
|
[commands, barPopup, groupName, prefixCls]);
|
|
27
28
|
}
|
|
28
29
|
//# sourceMappingURL=Child.js.map
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"sourcesContent": [
|
|
25
25
|
"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"
|
|
26
26
|
],
|
|
27
|
-
"mappings": ";AAAA,OAAOA,
|
|
27
|
+
"mappings": ";AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAClD;AACA,OAAOC,OAAO,MAAyB,IAAI;AAC3C,SAASC,aAAa,QAAQ,eAAe;AAAC;AAO9C,eAAe,SAASC,KAAK,CAACC,KAAiB,EAAE;EAC/C,IAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC,QAAQ;IAAEC;EAAS,CAAC,GAAGJ,KAAK,IAAI,CAAC,CAAC;EAChE,IAAM;IAAEK,QAAQ,GAAG,CAAC;EAAE,CAAC,GAAGV,UAAU,CAACG,aAAa,CAAC;EACnD,OAAOF,OAAO,CACZ,mBACE;IACE,SAAS,EAAKK,SAAS,wBAAkBC,SAAS,IAAIG,QAAQ,CAACH,SAAS,CAAC,GAAG,QAAQ,GAAG,EAAE,CAAG;IAC5F,OAAO,EAAGI,CAAC,IAAKA,CAAC,CAACC,eAAe,EAAG;IAAA,UAEnCC,KAAK,CAACC,OAAO,CAACN,QAAQ,CAAC,gBAAG,KAAC,OAAO;MAAC,QAAQ,EAAEA;IAAS,GAAKH,KAAK;MAAE,OAAO;IAAA,GAAG,GAAGI;EAAQ,EAE3F;EACD;EACA,CAACD,QAAQ,EAAEE,QAAQ,EAAEH,SAAS,EAAED,SAAS,CAAC,CAC3C;AACH"
|
|
28
28
|
}
|
|
@@ -19,21 +19,17 @@ export function ToolbarItems(props) {
|
|
|
19
19
|
dispatch
|
|
20
20
|
} = useContext(EditorContext);
|
|
21
21
|
var originalOverflow = useRef('');
|
|
22
|
-
|
|
23
22
|
function handleClick(command, name) {
|
|
24
23
|
if (!dispatch) return;
|
|
25
24
|
var state = {
|
|
26
25
|
barPopup: _extends({}, barPopup)
|
|
27
26
|
};
|
|
28
|
-
|
|
29
27
|
if (command.keyCommand === 'preview') {
|
|
30
28
|
state.preview = command.value;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
30
|
if (command.keyCommand === 'fullscreen') {
|
|
34
31
|
state.fullscreen = !fullscreen;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
if (props.commands && command.keyCommand === 'group') {
|
|
38
34
|
props.commands.forEach(item => {
|
|
39
35
|
if (name === item.groupName) {
|
|
@@ -47,14 +43,11 @@ export function ToolbarItems(props) {
|
|
|
47
43
|
state.barPopup[keyName] = false;
|
|
48
44
|
});
|
|
49
45
|
}
|
|
50
|
-
|
|
51
46
|
if (Object.keys(state).length) {
|
|
52
47
|
dispatch(_extends({}, state));
|
|
53
48
|
}
|
|
54
|
-
|
|
55
49
|
commandOrchestrator && commandOrchestrator.executeCommand(command);
|
|
56
50
|
}
|
|
57
|
-
|
|
58
51
|
useEffect(() => {
|
|
59
52
|
if (document && overflow) {
|
|
60
53
|
if (fullscreen) {
|
|
@@ -64,9 +57,8 @@ export function ToolbarItems(props) {
|
|
|
64
57
|
// get the original overflow only the first time
|
|
65
58
|
if (!originalOverflow.current) {
|
|
66
59
|
originalOverflow.current = window.getComputedStyle(document.body, null).overflow;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
}
|
|
61
|
+
// reset to the original overflow
|
|
70
62
|
document.body.style.overflow = originalOverflow.current;
|
|
71
63
|
}
|
|
72
64
|
}
|
|
@@ -78,7 +70,6 @@ export function ToolbarItems(props) {
|
|
|
78
70
|
className: prefixCls + "-toolbar-divider"
|
|
79
71
|
}), idx);
|
|
80
72
|
}
|
|
81
|
-
|
|
82
73
|
if (!item.keyCommand) return /*#__PURE__*/_jsx(Fragment, {}, idx);
|
|
83
74
|
var activeBtn = fullscreen && item.keyCommand === 'fullscreen' || item.keyCommand === 'preview' && preview === item.value;
|
|
84
75
|
var childNode = item.children && typeof item.children === 'function' ? item.children({
|
|
@@ -119,7 +110,6 @@ export default function Toolbar(props) {
|
|
|
119
110
|
if (props === void 0) {
|
|
120
111
|
props = {};
|
|
121
112
|
}
|
|
122
|
-
|
|
123
113
|
var {
|
|
124
114
|
prefixCls,
|
|
125
115
|
toolbarBottom,
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"sourcesContent": [
|
|
81
81
|
"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"
|
|
82
82
|
],
|
|
83
|
-
"mappings": ";AAAA,OAAOA,
|
|
83
|
+
"mappings": ";AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAEtE,SAASC,aAAa,QAAmC,eAAe;AAExE,OAAOC,KAAK,MAAM,SAAS;AAC3B;AAAsB;AAAA;AAUtB,OAAO,SAASC,YAAY,CAACC,KAAoB,EAAE;EACjD,IAAM;IAAEC,SAAS;IAAEC;EAAS,CAAC,GAAGF,KAAK;EACrC,IAAM;IAAEG,UAAU;IAAEC,OAAO;IAAEC,Q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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"
|
|
13
13
|
],
|
|
14
|
-
"mappings": "AAAA,OAAOA,
|
|
14
|
+
"mappings": "AAAA,OAAOA,QAAQ,MAAM,UAAU;AAC/B,OAAO,KAAKC,QAAQ,MAAM,YAAY;AACtC,OAAO,KAAKC,YAAY,MAAM,uBAAuB;AAErD,cAAc,YAAY;AAC1B,cAAc,uBAAuB;AACrC,cAAc,UAAU;AACxB,cAAc,WAAW;AAEzB,SAASA,YAAY,EAAED,QAAQ;AAE/B,eAAeD,QAAQ"
|
|
15
15
|
}
|
|
@@ -3,90 +3,84 @@
|
|
|
3
3
|
* Copyright (c) 2018 Dmitriy Kubyshkin
|
|
4
4
|
* Copied from https://github.com/grassator/insert-text-at-cursor
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
var browserSupportsTextareaTextNodes;
|
|
8
|
+
|
|
7
9
|
/**
|
|
8
10
|
* @param {HTMLElement} input
|
|
9
11
|
* @return {boolean}
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
13
|
function canManipulateViaTextNodes(input) {
|
|
13
14
|
if (input.nodeName !== 'TEXTAREA') {
|
|
14
15
|
return false;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
17
|
if (typeof browserSupportsTextareaTextNodes === 'undefined') {
|
|
18
18
|
var textarea = document.createElement('textarea');
|
|
19
19
|
textarea.value = '1';
|
|
20
20
|
browserSupportsTextareaTextNodes = !!textarea.firstChild;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
22
|
return browserSupportsTextareaTextNodes;
|
|
24
23
|
}
|
|
24
|
+
|
|
25
25
|
/**
|
|
26
26
|
* @param {string} val
|
|
27
27
|
* @param {number} cursorIdx
|
|
28
28
|
* @param {HTMLTextAreaElement|HTMLInputElement} input
|
|
29
29
|
* @return {void}
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
31
|
export var insertAtLineStart = (val, cursorIdx, input) => {
|
|
34
32
|
var content = input.value;
|
|
35
33
|
var startIdx = 0;
|
|
36
|
-
|
|
37
34
|
while (cursorIdx--) {
|
|
38
35
|
var char = content[cursorIdx];
|
|
39
|
-
|
|
40
36
|
if (char === '\n') {
|
|
41
37
|
startIdx = cursorIdx + 1;
|
|
42
38
|
break;
|
|
43
39
|
}
|
|
44
40
|
}
|
|
45
|
-
|
|
46
41
|
input.focus();
|
|
47
42
|
input.setRangeText(val, startIdx, startIdx);
|
|
48
43
|
input.dispatchEvent(new Event('input', {
|
|
49
44
|
bubbles: true
|
|
50
45
|
}));
|
|
51
46
|
};
|
|
47
|
+
|
|
52
48
|
/**
|
|
53
49
|
* @param {HTMLTextAreaElement|HTMLInputElement} input
|
|
54
50
|
* @param {string} text
|
|
55
51
|
* @returns {void}
|
|
56
52
|
*/
|
|
57
|
-
|
|
58
53
|
export function insertTextAtPosition(input, text) {
|
|
59
54
|
// Most of the used APIs only work with the field selected
|
|
60
|
-
input.focus();
|
|
55
|
+
input.focus();
|
|
61
56
|
|
|
57
|
+
// IE 8-10
|
|
62
58
|
if (document.selection) {
|
|
63
59
|
var ieRange = document.selection.createRange();
|
|
64
|
-
ieRange.text = text;
|
|
60
|
+
ieRange.text = text;
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
/* to the end */
|
|
68
|
-
);
|
|
62
|
+
// Move cursor after the inserted text
|
|
63
|
+
ieRange.collapse(false /* to the end */);
|
|
69
64
|
ieRange.select();
|
|
70
65
|
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
66
|
+
}
|
|
73
67
|
|
|
68
|
+
// Webkit + Edge
|
|
74
69
|
var isSuccess = document.execCommand && document.execCommand('insertText', false, text);
|
|
75
|
-
|
|
76
70
|
if (!isSuccess) {
|
|
77
71
|
var start = input.selectionStart;
|
|
78
|
-
var end = input.selectionEnd;
|
|
79
|
-
|
|
72
|
+
var end = input.selectionEnd;
|
|
73
|
+
// Firefox (non-standard method)
|
|
80
74
|
if (typeof input.setRangeText === 'function') {
|
|
81
75
|
input.setRangeText(text);
|
|
82
76
|
} else {
|
|
83
77
|
// To make a change we just need a Range, not a Selection
|
|
84
78
|
var range = document.createRange();
|
|
85
79
|
var textNode = document.createTextNode(text);
|
|
86
|
-
|
|
87
80
|
if (canManipulateViaTextNodes(input)) {
|
|
88
|
-
var node = input.firstChild;
|
|
81
|
+
var node = input.firstChild;
|
|
89
82
|
|
|
83
|
+
// If textarea is empty, just insert the text
|
|
90
84
|
if (!node) {
|
|
91
85
|
input.appendChild(textNode);
|
|
92
86
|
} else {
|
|
@@ -94,35 +88,34 @@ export function insertTextAtPosition(input, text) {
|
|
|
94
88
|
var offset = 0;
|
|
95
89
|
var startNode = null;
|
|
96
90
|
var endNode = null;
|
|
97
|
-
|
|
98
91
|
while (node && (startNode === null || endNode === null)) {
|
|
99
|
-
var nodeLength = node.nodeValue.length;
|
|
92
|
+
var nodeLength = node.nodeValue.length;
|
|
100
93
|
|
|
94
|
+
// if start of the selection falls into current node
|
|
101
95
|
if (start >= offset && start <= offset + nodeLength) {
|
|
102
96
|
range.setStart(startNode = node, start - offset);
|
|
103
|
-
}
|
|
104
|
-
|
|
97
|
+
}
|
|
105
98
|
|
|
99
|
+
// if end of the selection falls into current node
|
|
106
100
|
if (end >= offset && end <= offset + nodeLength) {
|
|
107
101
|
range.setEnd(endNode = node, end - offset);
|
|
108
102
|
}
|
|
109
|
-
|
|
110
103
|
offset += nodeLength;
|
|
111
104
|
node = node.nextSibling;
|
|
112
|
-
}
|
|
113
|
-
|
|
105
|
+
}
|
|
114
106
|
|
|
107
|
+
// If there is some text selected, remove it as we should replace it
|
|
115
108
|
if (start !== end) {
|
|
116
109
|
range.deleteContents();
|
|
117
110
|
}
|
|
118
111
|
}
|
|
119
|
-
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// If the node is a textarea and the range doesn't span outside the element
|
|
120
115
|
//
|
|
121
116
|
// Get the commonAncestorContainer of the selected range and test its type
|
|
122
117
|
// If the node is of type `#text` it means that we're still working with text nodes within our textarea element
|
|
123
118
|
// otherwise, if it's of type `#document` for example it means our selection spans outside the textarea.
|
|
124
|
-
|
|
125
|
-
|
|
126
119
|
if (canManipulateViaTextNodes(input) && range.commonAncestorContainer.nodeName === '#text') {
|
|
127
120
|
// Finally insert a new node. The browser will automatically split start and end nodes into two if necessary
|
|
128
121
|
range.insertNode(textNode);
|
|
@@ -131,11 +124,12 @@ export function insertTextAtPosition(input, text) {
|
|
|
131
124
|
var value = input.value;
|
|
132
125
|
input.value = value.slice(0, start) + text + value.slice(end);
|
|
133
126
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
127
|
+
}
|
|
136
128
|
|
|
137
|
-
|
|
129
|
+
// Correct the cursor position to be at the end of the insertion
|
|
130
|
+
input.setSelectionRange(start + text.length, start + text.length);
|
|
138
131
|
|
|
132
|
+
// Notify any possible listeners of the change
|
|
139
133
|
var e = document.createEvent('UIEvent');
|
|
140
134
|
e.initEvent('input', true, false);
|
|
141
135
|
input.dispatchEvent(e);
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"sourcesContent": [
|
|
64
64
|
"/**\n * The MIT License\n * Copyright (c) 2018 Dmitriy Kubyshkin\n * Copied from https://github.com/grassator/insert-text-at-cursor\n */\n\nlet browserSupportsTextareaTextNodes: any;\n\n/**\n * @param {HTMLElement} input\n * @return {boolean}\n */\nfunction canManipulateViaTextNodes(input: HTMLTextAreaElement | HTMLInputElement): boolean {\n if (input.nodeName !== 'TEXTAREA') {\n return false;\n }\n if (typeof browserSupportsTextareaTextNodes === 'undefined') {\n const textarea: HTMLTextAreaElement = document.createElement('textarea');\n textarea.value = '1';\n browserSupportsTextareaTextNodes = !!textarea.firstChild;\n }\n return browserSupportsTextareaTextNodes;\n}\n\n/**\n * @param {string} val\n * @param {number} cursorIdx\n * @param {HTMLTextAreaElement|HTMLInputElement} input\n * @return {void}\n */\nexport const insertAtLineStart = (\n val: string,\n cursorIdx: number,\n input: HTMLTextAreaElement | HTMLInputElement,\n): void => {\n const content = input.value;\n let startIdx = 0;\n\n while (cursorIdx--) {\n let char = content[cursorIdx];\n if (char === '\\n') {\n startIdx = cursorIdx + 1;\n break;\n }\n }\n\n input.focus();\n input.setRangeText(val, startIdx, startIdx);\n input.dispatchEvent(new Event('input', { bubbles: true }));\n};\n\n/**\n * @param {HTMLTextAreaElement|HTMLInputElement} input\n * @param {string} text\n * @returns {void}\n */\nexport function insertTextAtPosition(input: HTMLTextAreaElement | HTMLInputElement, text: string): void {\n // Most of the used APIs only work with the field selected\n input.focus();\n\n // IE 8-10\n if ((document as any).selection) {\n const ieRange = (document as any).selection.createRange();\n ieRange.text = text;\n\n // Move cursor after the inserted text\n ieRange.collapse(false /* to the end */);\n ieRange.select();\n\n return;\n }\n\n // Webkit + Edge\n const isSuccess = document.execCommand && document.execCommand('insertText', false, text);\n if (!isSuccess) {\n const start = input.selectionStart!;\n const end = input.selectionEnd!;\n // Firefox (non-standard method)\n if (typeof input.setRangeText === 'function') {\n input.setRangeText(text);\n } else {\n // To make a change we just need a Range, not a Selection\n const range = document.createRange();\n const textNode = document.createTextNode(text);\n\n if (canManipulateViaTextNodes(input)) {\n let node = input.firstChild;\n\n // If textarea is empty, just insert the text\n if (!node) {\n input.appendChild(textNode);\n } else {\n // Otherwise we need to find a nodes for start and end\n let offset = 0;\n let startNode = null;\n let endNode = null;\n\n while (node && (startNode === null || endNode === null)) {\n const nodeLength = node.nodeValue!.length;\n\n // if start of the selection falls into current node\n if (start >= offset && start <= offset + nodeLength) {\n range.setStart((startNode = node), start - offset);\n }\n\n // if end of the selection falls into current node\n if (end >= offset && end <= offset + nodeLength) {\n range.setEnd((endNode = node), end - offset);\n }\n\n offset += nodeLength;\n node = node.nextSibling;\n }\n\n // If there is some text selected, remove it as we should replace it\n if (start !== end) {\n range.deleteContents();\n }\n }\n }\n\n // If the node is a textarea and the range doesn't span outside the element\n //\n // Get the commonAncestorContainer of the selected range and test its type\n // If the node is of type `#text` it means that we're still working with text nodes within our textarea element\n // otherwise, if it's of type `#document` for example it means our selection spans outside the textarea.\n if (canManipulateViaTextNodes(input) && range.commonAncestorContainer.nodeName === '#text') {\n // Finally insert a new node. The browser will automatically split start and end nodes into two if necessary\n range.insertNode(textNode);\n } else {\n // If the node is not a textarea or the range spans outside a textarea the only way is to replace the whole value\n const value = input.value;\n input.value = value.slice(0, start) + text + value.slice(end);\n }\n }\n\n // Correct the cursor position to be at the end of the insertion\n input.setSelectionRange(start + text.length, start + text.length);\n\n // Notify any possible listeners of the change\n const e = document.createEvent('UIEvent');\n e.initEvent('input', true, false);\n input.dispatchEvent(e);\n }\n}\n"
|
|
65
65
|
],
|
|
66
|
-
"mappings": "AAAA;AACA;AACA;AACA;AACA
|
|
66
|
+
"mappings": "AAAA;AACA;AACA;AACA;AACA;;AAEA,IAAIA,gCAAqC;;AAEzC;AACA;AACA;AACA;AACA,SAASC,yBAAyB,CAACC,KAA6C,EAAW;EACzF,IAAIA,KAAK,CAACC,QAAQ,KAAK,UAAU,EAAE;IACjC,OAAO,KAAK;EACd;EACA,IAAI,OAAOH,gCAAgC,KAAK,WAAW,EAAE;IAC3D,IAAMI,QAA6B,GAAGC,QAAQ,CAACC,aAAa,CAAC,UAAU,CAAC;IACxEF,QAAQ,CAACG,KAAK,GAAG,GAAG;IACpBP,gCAAgC,GAAG,CAAC,CAACI,QAAQ,CAACI,UAAU;EAC1D;EACA,OAAOR,gCAAgC;AACzC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMS,iBAAiB,GAAG,CAC/BC,GAAW,EACXC,SAAiB,EACjBT,KAA6C,KACpC;EACT,IAAMU,OAAO,GAAGV,KAAK,CAACK,KAAK;EAC3B,IAAIM,QAAQ,GAAG,CAAC;EAEhB,OAAOF,SAAS,EAAE,EAAE;IAClB,IAAIG,IAAI,GAAGF,OAAO,CAACD,SAAS,C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C,CAAC,EAAErB,KAAK,CAAC,GAAGR,IAAI,GAAGd,KAAK,CAAC2C,KAAK,CAACnB,GAAG,CAAC;MAC/D;IACF;;IAEA;IACA7B,KAAK,CAACiD,iBAAiB,CAACtB,KAAK,GAAGR,IAAI,CAACsB,MAAM,EAAEd,KAAK,GAAGR,IAAI,CAACsB,MAAM,CAAC;;IAEjE;IACA,IAAMS,CAAC,GAAG/C,QAAQ,CAACgD,WAAW,CAAC,SAAS,CAAC;IACzCD,CAAC,CAACE,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC;IACjCpD,KAAK,CAACe,aAAa,CAACmC,CAAC,CAAC;EACxB;AACF"
|
|
67
67
|
}
|
|
@@ -3,113 +3,104 @@ export function selectWord(_ref) {
|
|
|
3
3
|
text,
|
|
4
4
|
selection
|
|
5
5
|
} = _ref;
|
|
6
|
-
|
|
7
6
|
if (text && text.length && selection.start === selection.end) {
|
|
8
7
|
// the user is pointing to a word
|
|
9
8
|
return getSurroundingWord(text, selection.start);
|
|
10
9
|
}
|
|
11
|
-
|
|
12
10
|
return selection;
|
|
13
11
|
}
|
|
12
|
+
|
|
14
13
|
/**
|
|
15
14
|
* Gets the number of line-breaks that would have to be inserted before the given 'startPosition'
|
|
16
15
|
* to make sure there's an empty line between 'startPosition' and the previous text
|
|
17
16
|
*/
|
|
18
|
-
|
|
19
17
|
export function getBreaksNeededForEmptyLineBefore(text, startPosition) {
|
|
20
18
|
if (text === void 0) {
|
|
21
19
|
text = '';
|
|
22
20
|
}
|
|
21
|
+
if (startPosition === 0) return 0;
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
// rules:
|
|
25
24
|
// - If we're in the first line, no breaks are needed
|
|
26
25
|
// - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we
|
|
27
26
|
// may need to insert 0, 1 or 2 breaks
|
|
28
27
|
|
|
29
28
|
var neededBreaks = 2;
|
|
30
29
|
var isInFirstLine = true;
|
|
31
|
-
|
|
32
30
|
for (var i = startPosition - 1; i >= 0 && neededBreaks >= 0; i--) {
|
|
33
31
|
switch (text.charCodeAt(i)) {
|
|
34
32
|
case 32:
|
|
35
33
|
// blank space
|
|
36
34
|
continue;
|
|
37
|
-
|
|
38
35
|
case 10:
|
|
39
36
|
// line break
|
|
40
37
|
neededBreaks--;
|
|
41
38
|
isInFirstLine = false;
|
|
42
39
|
break;
|
|
43
|
-
|
|
44
40
|
default:
|
|
45
41
|
return neededBreaks;
|
|
46
42
|
}
|
|
47
43
|
}
|
|
48
|
-
|
|
49
44
|
return isInFirstLine ? 0 : neededBreaks;
|
|
50
45
|
}
|
|
46
|
+
|
|
51
47
|
/**
|
|
52
48
|
* Gets the number of line-breaks that would have to be inserted after the given 'startPosition'
|
|
53
49
|
* to make sure there's an empty line between 'startPosition' and the next text
|
|
54
50
|
*/
|
|
55
|
-
|
|
56
51
|
export function getBreaksNeededForEmptyLineAfter(text, startPosition) {
|
|
57
52
|
if (text === void 0) {
|
|
58
53
|
text = '';
|
|
59
54
|
}
|
|
55
|
+
if (startPosition === text.length - 1) return 0;
|
|
60
56
|
|
|
61
|
-
|
|
57
|
+
// rules:
|
|
62
58
|
// - If we're in the first line, no breaks are needed
|
|
63
59
|
// - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we
|
|
64
60
|
// may need to insert 0, 1 or 2 breaks
|
|
65
61
|
|
|
66
62
|
var neededBreaks = 2;
|
|
67
63
|
var isInLastLine = true;
|
|
68
|
-
|
|
69
64
|
for (var i = startPosition; i < text.length && neededBreaks >= 0; i++) {
|
|
70
65
|
switch (text.charCodeAt(i)) {
|
|
71
66
|
case 32:
|
|
72
67
|
continue;
|
|
73
|
-
|
|
74
68
|
case 10:
|
|
75
69
|
{
|
|
76
70
|
neededBreaks--;
|
|
77
71
|
isInLastLine = false;
|
|
78
72
|
break;
|
|
79
73
|
}
|
|
80
|
-
|
|
81
74
|
default:
|
|
82
75
|
return neededBreaks;
|
|
83
76
|
}
|
|
84
77
|
}
|
|
85
|
-
|
|
86
78
|
return isInLastLine ? 0 : neededBreaks;
|
|
87
79
|
}
|
|
88
80
|
export function getSurroundingWord(text, position) {
|
|
89
81
|
if (!text) throw Error("Argument 'text' should be truthy");
|
|
82
|
+
var isWordDelimiter = c => c === ' ' || c.charCodeAt(0) === 10;
|
|
90
83
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var
|
|
95
|
-
|
|
96
|
-
var end = text.length; // iterate to the left
|
|
84
|
+
// leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration
|
|
85
|
+
var start = 0;
|
|
86
|
+
// rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation
|
|
87
|
+
var end = text.length;
|
|
97
88
|
|
|
89
|
+
// iterate to the left
|
|
98
90
|
for (var i = position; i - 1 > -1; i--) {
|
|
99
91
|
if (isWordDelimiter(text[i - 1])) {
|
|
100
92
|
start = i;
|
|
101
93
|
break;
|
|
102
94
|
}
|
|
103
|
-
}
|
|
104
|
-
|
|
95
|
+
}
|
|
105
96
|
|
|
97
|
+
// iterate to the right
|
|
106
98
|
for (var _i = position; _i < text.length; _i++) {
|
|
107
99
|
if (isWordDelimiter(text[_i])) {
|
|
108
100
|
end = _i;
|
|
109
101
|
break;
|
|
110
102
|
}
|
|
111
103
|
}
|
|
112
|
-
|
|
113
104
|
return {
|
|
114
105
|
start,
|
|
115
106
|
end
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"sourcesContent": [
|
|
28
28
|
"import { TextRange } from '../commands';\n\nexport interface TextSection {\n text: string;\n selection: TextRange;\n}\n\nexport function selectWord({ text, selection }: TextSection): TextRange {\n if (text && text.length && selection.start === selection.end) {\n // the user is pointing to a word\n return getSurroundingWord(text, selection.start);\n }\n return selection;\n}\n\n/**\n * Gets the number of line-breaks that would have to be inserted before the given 'startPosition'\n * to make sure there's an empty line between 'startPosition' and the previous text\n */\nexport function getBreaksNeededForEmptyLineBefore(text = '', startPosition: number): number {\n if (startPosition === 0) return 0;\n\n // rules:\n // - If we're in the first line, no breaks are needed\n // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we\n // may need to insert 0, 1 or 2 breaks\n\n let neededBreaks = 2;\n let isInFirstLine = true;\n for (let i = startPosition - 1; i >= 0 && neededBreaks >= 0; i--) {\n switch (text.charCodeAt(i)) {\n case 32: // blank space\n continue;\n case 10: // line break\n neededBreaks--;\n isInFirstLine = false;\n break;\n default:\n return neededBreaks;\n }\n }\n return isInFirstLine ? 0 : neededBreaks;\n}\n\n/**\n * Gets the number of line-breaks that would have to be inserted after the given 'startPosition'\n * to make sure there's an empty line between 'startPosition' and the next text\n */\nexport function getBreaksNeededForEmptyLineAfter(text = '', startPosition: number): number {\n if (startPosition === text.length - 1) return 0;\n\n // rules:\n // - If we're in the first line, no breaks are needed\n // - Otherwise there must be 2 breaks before the previous character. Depending on how many breaks exist already, we\n // may need to insert 0, 1 or 2 breaks\n\n let neededBreaks = 2;\n let isInLastLine = true;\n for (let i = startPosition; i < text.length && neededBreaks >= 0; i++) {\n switch (text.charCodeAt(i)) {\n case 32:\n continue;\n case 10: {\n neededBreaks--;\n isInLastLine = false;\n break;\n }\n default:\n return neededBreaks;\n }\n }\n return isInLastLine ? 0 : neededBreaks;\n}\n\nexport function getSurroundingWord(text: string, position: number): TextRange {\n if (!text) throw Error(\"Argument 'text' should be truthy\");\n\n const isWordDelimiter = (c: string) => c === ' ' || c.charCodeAt(0) === 10;\n\n // leftIndex is initialized to 0 because if selection is 0, it won't even enter the iteration\n let start = 0;\n // rightIndex is initialized to text.length because if selection is equal to text.length it won't even enter the interation\n let end = text.length;\n\n // iterate to the left\n for (let i = position; i - 1 > -1; i--) {\n if (isWordDelimiter(text[i - 1])) {\n start = i;\n break;\n }\n }\n\n // iterate to the right\n for (let i = position; i < text.length; i++) {\n if (isWordDelimiter(text[i])) {\n end = i;\n break;\n }\n }\n\n return { start, end };\n}\n"
|
|
29
29
|
],
|
|
30
|
-
"mappings": "AA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