@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
package/lib/commands/code.js.map
CHANGED
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"../../src/commands/code.tsx"
|
|
41
41
|
],
|
|
42
42
|
"sourcesContent": [
|
|
43
|
-
"import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport {\n selectWord,\n getBreaksNeededForEmptyLineBefore,\n getBreaksNeededForEmptyLineAfter,\n} from '../utils/markdownUtils';\n\nexport const code: ICommand = {\n name: 'code',\n keyCommand: 'code',\n shortcuts: 'ctrlcmd+j',\n value: '``',\n buttonProps: { 'aria-label': 'Insert code (ctrl + j)', title: 'Insert code (ctrl + j)' },\n icon: (\n <svg width=\"
|
|
43
|
+
"import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport {\n selectWord,\n getBreaksNeededForEmptyLineBefore,\n getBreaksNeededForEmptyLineAfter,\n} from '../utils/markdownUtils';\n\nexport const code: ICommand = {\n name: 'code',\n keyCommand: 'code',\n shortcuts: 'ctrlcmd+j',\n value: '``',\n buttonProps: { 'aria-label': 'Insert code (ctrl + j)', title: 'Insert code (ctrl + j)' },\n icon: (\n <svg width=\"14\" height=\"14\" role=\"img\" viewBox=\"0 0 640 512\">\n <path\n fill=\"currentColor\"\n d=\"M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z\"\n />\n </svg>\n ),\n execute: (tate: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // when there's no breaking line\n if (state1.selectedText.indexOf('\\n') === -1) {\n api.replaceSelection(`\\`${state1.selectedText}\\``);\n // Adjust the selection to not contain the **\n\n const selectionStart = state1.selection.start + 1;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n return;\n }\n\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n api.replaceSelection(`${breaksBefore}\\`\\`\\`\\n${state1.selectedText}\\n\\`\\`\\`${breaksAfter}`);\n\n const selectionStart = state1.selection.start + breaksBeforeCount + 4;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n },\n};\n\nexport const codeBlock: ICommand = {\n name: 'codeBlock',\n keyCommand: 'codeBlock',\n shortcuts: 'ctrlcmd+shift+j',\n value: '```\\n```',\n icon: (\n <svg width=\"13\" height=\"13\" role=\"img\" viewBox=\"0 0 156 156\">\n <path\n fill=\"currentColor\"\n d=\"M110.85 120.575 43.7 120.483333 43.7083334 110.091667 110.85 110.191667 110.841667 120.583333 110.85 120.575ZM85.1333334 87.1916666 43.625 86.7083332 43.7083334 76.3166666 85.2083334 76.7916666 85.1333334 87.1916666 85.1333334 87.1916666ZM110.841667 53.4166666 43.7 53.3166666 43.7083334 42.925 110.85 43.025 110.841667 53.4166666ZM36 138C27.2916666 138 20.75 136.216667 16.4 132.666667 12.1333334 129.2 10 124.308333 10 118L10 95.3333332C10 91.0666666 9.25 88.1333332 7.7333334 86.5333332 6.3166668 84.8416666 3.7333334 84 0 84L0 72C3.7333334 72 6.3083334 71.2 7.7333334 69.6 9.2416668 67.9083334 10 64.9333334 10 60.6666666L10 38C10 31.775 12.1333334 26.8833334 16.4 23.3333332 20.7583334 19.7749998 27.2916666 18 36 18L40.6666668 18 40.6666668 30 36 30C34.0212222 29.9719277 32.1263151 30.7979128 30.8 32.2666666 29.3605875 33.8216362 28.5938182 35.8823287 28.6666668 38L28.6666668 60.6666666C28.6666668 67.5083332 26.6666668 72.4 22.6666668 75.3333332 20.9317416 76.7274684 18.8640675 77.6464347 16.6666668 78 18.8916668 78.35 20.8916668 79.2416666 22.6666668 80.6666666 26.6666668 83.95 28.6666668 88.8416666 28.6666668 95.3333332L28.6666668 118C28.6666668 120.308333 29.3750002 122.216667 30.8 123.733333 32.2166666 125.241667 33.9583334 126 36 126L40.6666668 126 40.6666668 138 36 138 36 138ZM114.116667 126 118.783333 126C120.833333 126 122.566667 125.241667 123.983333 123.733333 125.422746 122.178364 126.189515 120.117671 126.116667 118L126.116667 95.3333332C126.116667 88.8333332 128.116667 83.9499998 132.116667 80.6666666 133.9 79.2416666 135.9 78.35 138.116667 78 135.919156 77.6468047 133.851391 76.7277979 132.116667 75.3333332 128.116667 72.3999998 126.116667 67.5 126.116667 60.6666666L126.116667 38C126.189515 35.8823287 125.422746 33.8216361 123.983333 32.2666666 122.657018 30.7979128 120.762111 29.9719277 118.783333 30L114.116667 30 114.116667 18 118.783333 18C127.5 18 133.983333 19.775 138.25 23.3333332 142.608333 26.8833332 144.783333 31.7749998 144.783333 38L144.783333 60.6666666C144.783333 64.9333332 145.5 67.9083332 146.916667 69.6 148.433333 71.2 151.05 72 154.783333 72L154.783333 84C151.05 84 148.433333 84.8333334 146.916667 86.5333332 145.5 88.1333332 144.783333 91.0666666 144.783333 95.3333332L144.783333 118C144.783333 124.308333 142.616667 129.2 138.25 132.666667 133.983333 136.216667 127.5 138 118.783333 138L114.116667 138 114.116667 126 114.116667 126Z\"\n />\n </svg>\n ),\n buttonProps: { 'aria-label': 'Insert Code Block (ctrl + shift + j)', title: 'Insert Code Block (ctrl + shift +j)' },\n execute: (tate: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n\n const breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);\n const breaksBefore = Array(breaksBeforeCount + 1).join('\\n');\n\n const breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);\n const breaksAfter = Array(breaksAfterCount + 1).join('\\n');\n\n api.replaceSelection(`${breaksBefore}\\`\\`\\`\\n${state1.selectedText}\\n\\`\\`\\`${breaksAfter}`);\n\n const selectionStart = state1.selection.start + breaksBeforeCount + 4;\n const selectionEnd = selectionStart + state1.selectedText.length;\n\n api.setSelectionRange({\n start: selectionStart,\n end: selectionEnd,\n });\n },\n};\n"
|
|
44
44
|
],
|
|
45
|
-
"mappings": "
|
|
45
|
+
"mappings": "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"
|
|
46
46
|
}
|
package/lib/commands/comment.js
CHANGED
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.comment = void 0;
|
|
7
|
-
|
|
8
7
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
9
|
-
|
|
10
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
|
|
12
9
|
var comment = {
|
|
13
10
|
name: 'comment',
|
|
14
11
|
keyCommand: 'comment',
|
|
@@ -24,27 +21,38 @@ var comment = {
|
|
|
24
21
|
text: state.text,
|
|
25
22
|
selection: state.selection
|
|
26
23
|
});
|
|
27
|
-
var state1 = api.setSelectionRange(newSelectionRange);
|
|
28
|
-
|
|
29
|
-
var state2 = api.replaceSelection("<!-- ".concat(state1.selectedText, " -->"));
|
|
30
|
-
|
|
24
|
+
var state1 = api.setSelectionRange(newSelectionRange);
|
|
25
|
+
// Replaces the current selection with the bold mark up
|
|
26
|
+
var state2 = api.replaceSelection("<!-- ".concat(state1.selectedText, " -->"));
|
|
27
|
+
// Adjust the selection to not contain the **
|
|
31
28
|
api.setSelectionRange({
|
|
32
29
|
start: state2.selection.end - 4 - state1.selectedText.length,
|
|
33
30
|
end: state2.selection.end - 4
|
|
34
31
|
});
|
|
35
32
|
},
|
|
36
|
-
icon: /*#__PURE__*/(0, _jsxRuntime.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
34
|
+
height: "1em",
|
|
35
|
+
width: "1em",
|
|
36
|
+
viewBox: "0 0 25 25",
|
|
37
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("g", {
|
|
38
|
+
fill: "none",
|
|
39
|
+
fillRule: "evenodd",
|
|
40
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("polygon", {
|
|
41
|
+
points: ".769 .727 24.981 .727 24.981 24.727 .769 24.727"
|
|
42
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
43
|
+
stroke: "currentColor",
|
|
44
|
+
strokeLinecap: "round",
|
|
45
|
+
strokeLinejoin: "round",
|
|
46
|
+
strokeWidth: "3",
|
|
47
|
+
d: "M12.625,23.8787879 L8.125,19.6969697 L5.125,19.6969697 C2.63971863,19.6969697 0.625,17.8247059 0.625,15.5151515 L0.625,7.15151515 C0.625,4.84196074 2.63971863,2.96969697 5.125,2.96969697 L20.125,2.96969697 C22.6102814,2.96969697 24.625,4.84196074 24.625,7.15151515 L24.625,15.5151515 C24.625,17.8247059 22.6102814,19.6969697 20.125,19.6969697 L17.125,19.6969697 L12.625,23.8787879"
|
|
48
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
49
|
+
stroke: "currentColor",
|
|
50
|
+
strokeLinecap: "round",
|
|
51
|
+
strokeLinejoin: "round",
|
|
52
|
+
strokeWidth: "3",
|
|
53
|
+
d: "M10.625,8.54545455 L7.25,11.3333333 L10.625,14.1212121 M15.6875,8.54545455 L19.0625,11.3333333 L15.6875,14.1212121"
|
|
54
|
+
})]
|
|
55
|
+
})
|
|
48
56
|
})
|
|
49
57
|
};
|
|
50
58
|
exports.comment = comment;
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"../../src/commands/comment.tsx"
|
|
30
30
|
],
|
|
31
31
|
"sourcesContent": [
|
|
32
|
-
"import { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const comment: ICommand = {\n name: 'comment',\n keyCommand: 'comment',\n shortcuts: 'ctrlcmd+/',\n value: '<!-- -->',\n buttonProps: { 'aria-label': 'Insert comment (ctrl + /)', title: 'Insert comment (ctrl + /)' },\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // Replaces the current selection with the bold mark up\n const state2 = api.replaceSelection(`<!-- ${state1.selectedText} -->`);\n // Adjust the selection to not contain the **\n api.setSelectionRange({\n start: state2.selection.end - 4 - state1.selectedText.length,\n end: state2.selection.end - 4,\n });\n },\n icon: (\n <svg
|
|
32
|
+
"import { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const comment: ICommand = {\n name: 'comment',\n keyCommand: 'comment',\n shortcuts: 'ctrlcmd+/',\n value: '<!-- -->',\n buttonProps: { 'aria-label': 'Insert comment (ctrl + /)', title: 'Insert comment (ctrl + /)' },\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Adjust the selection to encompass the whole word if the caret is inside one\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // Replaces the current selection with the bold mark up\n const state2 = api.replaceSelection(`<!-- ${state1.selectedText} -->`);\n // Adjust the selection to not contain the **\n api.setSelectionRange({\n start: state2.selection.end - 4 - state1.selectedText.length,\n end: state2.selection.end - 4,\n });\n },\n icon: (\n <svg height=\"1em\" width=\"1em\" viewBox=\"0 0 25 25\">\n <g fill=\"none\" fillRule=\"evenodd\">\n <polygon points=\".769 .727 24.981 .727 24.981 24.727 .769 24.727\" />\n <path\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"3\"\n d=\"M12.625,23.8787879 L8.125,19.6969697 L5.125,19.6969697 C2.63971863,19.6969697 0.625,17.8247059 0.625,15.5151515 L0.625,7.15151515 C0.625,4.84196074 2.63971863,2.96969697 5.125,2.96969697 L20.125,2.96969697 C22.6102814,2.96969697 24.625,4.84196074 24.625,7.15151515 L24.625,15.5151515 C24.625,17.8247059 22.6102814,19.6969697 20.125,19.6969697 L17.125,19.6969697 L12.625,23.8787879\"\n />\n <path\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth=\"3\"\n d=\"M10.625,8.54545455 L7.25,11.3333333 L10.625,14.1212121 M15.6875,8.54545455 L19.0625,11.3333333 L15.6875,14.1212121\"\n />\n </g>\n </svg>\n ),\n};\n"
|
|
33
33
|
],
|
|
34
|
-
"mappings": "
|
|
34
|
+
"mappings": ";;;;;;AACA;AAAoD;AAE7C,IAAMA,OAAiB,GAAG;EAC/BC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE,SAAS;EACrBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,UAAU;EACjBC,WAAW,EAAE;IAAE,YAAY,EAAE,2BAA2B;IAAEC,KAAK,EAAE;EAA4B,CAAC;EAC9FC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD;IACA,IAAMC,iBAAiB,GAAG,IAAAC,yBAAU,EAAC;MAAEC,IAAI,EAAEJ,KAAK,CAACI,IAAI;MAAEC,SAAS,EAAEL,KAAK,CAACK;IAAU,CAAC,CAAC;IACtF,IAAMC,MAAM,GAAGL,GAAG,CAACM,iBAAiB,CAACL,iBAAiB,CAAC;IACvD;IACA,IAAMM,MAAM,GAAGP,GAAG,CAACQ,gBAAgB,gBAASH,MAAM,CAACI,YAAY,UAAO;IACtE;IACAT,GAAG,CAACM,iBAAiB,CAAC;MACpBI,KAAK,EAAEH,MAAM,CAACH,SAAS,CAACO,GAAG,GAAG,CAAC,GAAGN,MAAM,CAACI,YAAY,CAACG,MAAM;MAC5DD,GAAG,EAAEJ,MAAM,CAACH,SAAS,CAACO,GAAG,GAAG;IAC9B,CAAC,CAAC;EACJ,CAAC;EACDE,IAAI,eACF;IAAK,MAAM,EAAC,KAAK;IAAC,KAAK,EAAC,KAAK;IAAC,OAAO,EAAC,WAAW;IAAA,uBAC/C;MAAG,IAAI,EAAC,MAAM;MAAC,QAAQ,EAAC,SAAS;MAAA,wBAC/B;QAAS,MAAM,EAAC;MAAiD,EAAG,eACpE;QACE,MAAM,EAAC,cAAc;QACrB,aAAa,EAAC,OAAO;QACrB,cAAc,EAAC,OAAO;QACtB,WAAW,EAAC,GAAG;QACf,CAAC,EAAC;MAA8X,EAChY,eACF;QACE,MAAM,EAAC,cAAc;QACrB,aAAa,EAAC,OAAO;QACrB,cAAc,EAAC,OAAO;QACtB,WAAW,EAAC,GAAG;QACf,CAAC,EAAC;MAAoH,EACtH;IAAA;EACA;AAGV,CAAC;AAAC"
|
|
35
35
|
}
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
"sourcesContent": [
|
|
11
11
|
"import { ICommand } from './';\n\nexport const divider: ICommand = {\n keyCommand: 'divider',\n};\n"
|
|
12
12
|
],
|
|
13
|
-
"mappings": ";;;;;;AAEO,IAAMA,OAAiB,GAAG;EAC/BC,UAAU,EAAE;
|
|
13
|
+
"mappings": ";;;;;;AAEO,IAAMA,OAAiB,GAAG;EAC/BC,UAAU,EAAE;AACd,CAAC;AAAC"
|
|
14
14
|
}
|
|
@@ -1,16 +1,12 @@
|
|
|
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
|
});
|
|
8
7
|
exports.fullscreen = void 0;
|
|
9
|
-
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
|
|
14
10
|
var fullscreen = {
|
|
15
11
|
name: 'fullscreen',
|
|
16
12
|
keyCommand: 'fullscreen',
|
|
@@ -29,12 +25,11 @@ var fullscreen = {
|
|
|
29
25
|
d: "M118 171.133334L118 342.200271C118 353.766938 126.675 365.333605 141.133333 365.333605L382.634614 365.333605C394.201281 365.333605 405.767948 356.658605 405.767948 342.200271L405.767948 171.133334C405.767948 159.566667 397.092948 148 382.634614 148L141.133333 148C126.674999 148 117.999999 156.675 118 171.133334zM465.353591 413.444444L370 413.444444 370 471.222222 474.0221 471.222222C500.027624 471.222222 520.254143 451 520.254143 425L520.254143 321 462.464089 321 462.464089 413.444444 465.353591 413.444444zM471.0221 43L367 43 367 100.777778 462.353591 100.777778 462.353591 196.111111 520.143647 196.111111 520.143647 89.2222219C517.254144 63.2222219 497.027624 43 471.0221 43zM57.7900547 100.777778L153.143646 100.777778 153.143646 43 46.2320439 43C20.2265191 43 0 63.2222219 0 89.2222219L0 193.222222 57.7900547 193.222222 57.7900547 100.777778zM57.7900547 321L0 321 0 425C0 451 20.2265191 471.222222 46.2320439 471.222223L150.254143 471.222223 150.254143 413.444445 57.7900547 413.444445 57.7900547 321z"
|
|
30
26
|
})
|
|
31
27
|
}),
|
|
32
|
-
execute: function execute(state, api, dispatch, executeCommandState) {
|
|
28
|
+
execute: function execute(state, api, dispatch, executeCommandState, shortcuts) {
|
|
33
29
|
api.textArea.focus();
|
|
34
|
-
|
|
35
|
-
if (dispatch && executeCommandState && executeCommandState.fullscreen) {
|
|
30
|
+
if (shortcuts && dispatch && executeCommandState) {
|
|
36
31
|
dispatch({
|
|
37
|
-
fullscreen:
|
|
32
|
+
fullscreen: !executeCommandState.fullscreen
|
|
38
33
|
});
|
|
39
34
|
}
|
|
40
35
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"../../src/commands/fullscreen.tsx"
|
|
22
22
|
],
|
|
23
23
|
"sourcesContent": [
|
|
24
|
-
"import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { ContextStore, ExecuteCommandState } from '../Context';\n\nexport const fullscreen: ICommand = {\n name: 'fullscreen',\n keyCommand: 'fullscreen',\n shortcuts: 'ctrlcmd+0',\n value: 'fullscreen',\n buttonProps: { 'aria-label': 'Toggle fullscreen (ctrl + 0)', title: 'Toggle fullscreen (ctrl+ 0)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n d=\"M118 171.133334L118 342.200271C118 353.766938 126.675 365.333605 141.133333 365.333605L382.634614 365.333605C394.201281 365.333605 405.767948 356.658605 405.767948 342.200271L405.767948 171.133334C405.767948 159.566667 397.092948 148 382.634614 148L141.133333 148C126.674999 148 117.999999 156.675 118 171.133334zM465.353591 413.444444L370 413.444444 370 471.222222 474.0221 471.222222C500.027624 471.222222 520.254143 451 520.254143 425L520.254143 321 462.464089 321 462.464089 413.444444 465.353591 413.444444zM471.0221 43L367 43 367 100.777778 462.353591 100.777778 462.353591 196.111111 520.143647 196.111111 520.143647 89.2222219C517.254144 63.2222219 497.027624 43 471.0221 43zM57.7900547 100.777778L153.143646 100.777778 153.143646 43 46.2320439 43C20.2265191 43 0 63.2222219 0 89.2222219L0 193.222222 57.7900547 193.222222 57.7900547 100.777778zM57.7900547 321L0 321 0 425C0 451 20.2265191 471.222222 46.2320439 471.222223L150.254143 471.222223 150.254143 413.444445 57.7900547 413.444445 57.7900547 321z\"\n />\n </svg>\n ),\n execute: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n ) => {\n api.textArea.focus();\n if (
|
|
24
|
+
"import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { ContextStore, ExecuteCommandState } from '../Context';\n\nexport const fullscreen: ICommand = {\n name: 'fullscreen',\n keyCommand: 'fullscreen',\n shortcuts: 'ctrlcmd+0',\n value: 'fullscreen',\n buttonProps: { 'aria-label': 'Toggle fullscreen (ctrl + 0)', title: 'Toggle fullscreen (ctrl+ 0)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n d=\"M118 171.133334L118 342.200271C118 353.766938 126.675 365.333605 141.133333 365.333605L382.634614 365.333605C394.201281 365.333605 405.767948 356.658605 405.767948 342.200271L405.767948 171.133334C405.767948 159.566667 397.092948 148 382.634614 148L141.133333 148C126.674999 148 117.999999 156.675 118 171.133334zM465.353591 413.444444L370 413.444444 370 471.222222 474.0221 471.222222C500.027624 471.222222 520.254143 451 520.254143 425L520.254143 321 462.464089 321 462.464089 413.444444 465.353591 413.444444zM471.0221 43L367 43 367 100.777778 462.353591 100.777778 462.353591 196.111111 520.143647 196.111111 520.143647 89.2222219C517.254144 63.2222219 497.027624 43 471.0221 43zM57.7900547 100.777778L153.143646 100.777778 153.143646 43 46.2320439 43C20.2265191 43 0 63.2222219 0 89.2222219L0 193.222222 57.7900547 193.222222 57.7900547 100.777778zM57.7900547 321L0 321 0 425C0 451 20.2265191 471.222222 46.2320439 471.222223L150.254143 471.222223 150.254143 413.444445 57.7900547 413.444445 57.7900547 321z\"\n />\n </svg>\n ),\n execute: (\n state: TextState,\n api: TextAreaTextApi,\n dispatch?: React.Dispatch<ContextStore>,\n executeCommandState?: ExecuteCommandState,\n shortcuts?: string[],\n ) => {\n api.textArea.focus();\n if (shortcuts && dispatch && executeCommandState) {\n dispatch({ fullscreen: !executeCommandState.fullscreen });\n }\n },\n};\n"
|
|
25
25
|
],
|
|
26
|
-
"mappings": "
|
|
26
|
+
"mappings": ";;;;;;;AAAA;AAA+B;AAIxB,IAAMA,UAAoB,GAAG;EAClCC,IAAI,EAAE,YAAY;EAClBC,UAAU,EAAE,YAAY;EACxBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,YAAY;EACnBC,WAAW,EAAE;IAAE,YAAY,EAAE,8BAA8B;IAAEC,KAAK,EAAE;EAA8B,CAAC;EACnGC,IAAI,eACF;IAAK,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,OAAO,EAAC,aAAa;IAAA,uBAC/C;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC;IAAs/B;EACx/B,EAEL;EACDC,OAAO,EAAE,iBACPC,KAAgB,EAChBC,GAAoB,EACpBC,QAAuC,EACvCC,mBAAyC,EACzCT,SAAoB,EACjB;IACHO,GAAG,CAACG,QAAQ,CAACC,KAAK,EAAE;IACpB,IAAIX,SAAS,IAAIQ,QAAQ,IAAIC,mBAAmB,EAAE;MAChDD,QAAQ,CAAC;QAAEX,UAAU,EAAE,CAACY,mBAAmB,CAACZ;MAAW,CAAC,CAAC;IAC3D;EACF;AACF,CAAC;AAAC"
|
|
27
27
|
}
|
package/lib/commands/group.js
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
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.group = void 0;
|
|
9
|
-
|
|
8
|
+
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
|
|
10
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
10
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
13
|
-
|
|
14
11
|
var _react = _interopRequireDefault(require("react"));
|
|
15
|
-
|
|
16
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
-
|
|
18
13
|
var group = function group(arr, options) {
|
|
19
14
|
var data = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
20
15
|
children: arr,
|
|
@@ -31,17 +26,14 @@ var group = function group(arr, options) {
|
|
|
31
26
|
}, options), {}, {
|
|
32
27
|
keyCommand: 'group'
|
|
33
28
|
});
|
|
34
|
-
|
|
35
29
|
if (Array.isArray(data.children)) {
|
|
36
30
|
data.children = data.children.map(function (_ref) {
|
|
37
|
-
var item = (0, _extends2["default"])({}, _ref);
|
|
31
|
+
var item = (0, _extends2["default"])({}, ((0, _objectDestructuringEmpty2["default"])(_ref), _ref));
|
|
38
32
|
item.parent = data;
|
|
39
33
|
return (0, _objectSpread2["default"])({}, item);
|
|
40
34
|
});
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
return data;
|
|
44
37
|
};
|
|
45
|
-
|
|
46
38
|
exports.group = group;
|
|
47
39
|
//# sourceMappingURL=group.js.map
|
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"sourcesContent": [
|
|
22
22
|
"import React from 'react';\nimport { ICommand, ICommandChildCommands, ICommandChildHandle } from './';\n\nexport type GroupOptions = Omit<ICommand<string>, 'children'> & {\n children?: ICommandChildHandle['children'];\n};\n\nexport const group = (arr: ICommandChildCommands['children'], options?: GroupOptions): ICommand<string> => {\n let data = {\n children: arr as any,\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 520 520\">\n <path\n fill=\"currentColor\"\n d=\"M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z\"\n />\n </svg>\n ),\n execute: () => {},\n ...options,\n keyCommand: 'group',\n };\n if (Array.isArray(data.children)) {\n data.children = data.children.map(({ ...item }: ICommand) => {\n item.parent = data;\n return { ...item };\n });\n }\n return data;\n};\n"
|
|
23
23
|
],
|
|
24
|
-
"mappings": "
|
|
24
|
+
"mappings": ";;;;;;;;;;AAAA;AAA0B;AAOnB,IAAMA,KAAK,GAAG,SAARA,KAAK,CAAIC,GAAsC,EAAEC,OAAsB,EAAuB;EACzG,IAAIC,IAAI;IACNC,QAAQ,EAAEH,GAAU;IACpBI,IAAI,eACF;MAAK,KAAK,EAAC,IAAI;MAAC,MAAM,EAAC,IAAI;MAAC,OAAO,EAAC,aAAa;MAAA,uBAC/C;QACE,IAAI,EAAC,cAAc;QACnB,CAAC,EAAC;MAA24B;IAC74B,EAEL;IACDC,OAAO,EAAE,mBAAM,CAAC;EAAC,GACdJ,OAAO;IACVK,UAAU,EAAE;EAAO,EACpB;EACD,IAAIC,KAAK,CAACC,OAAO,CAACN,IAAI,CAACC,QAAQ,CAAC,EAAE;IAChCD,IAAI,CAACC,QAAQ,GAAGD,IAAI,CAACC,QAAQ,CAACM,GAAG,CAAC,gBAA2B;MAAA,IAArBC,IAAI;MAC1CA,IAAI,CAACC,MAAM,GAAGT,IAAI;MAClB,0CAAYQ,IAAI;IAClB,CAAC,CAAC;EACJ;EACA,OAAOR,IAAI;AACb,CAAC;AAAC"
|
|
25
25
|
}
|
package/lib/commands/hr.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
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
|
});
|
|
8
7
|
exports.hr = void 0;
|
|
9
|
-
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
|
|
14
10
|
var hr = {
|
|
15
11
|
name: 'hr',
|
|
16
12
|
keyCommand: 'hr',
|
package/lib/commands/hr.js.map
CHANGED
|
@@ -21,5 +21,5 @@
|
|
|
21
21
|
"sourcesContent": [
|
|
22
22
|
"import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const hr: ICommand = {\n name: 'hr',\n keyCommand: 'hr',\n shortcuts: 'ctrlcmd+h',\n value: '----------',\n buttonProps: { 'aria-label': 'Insert HR (ctrl + h)', title: 'Insert HR (ctrl + h)' },\n icon: (\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 175 175\">\n <path\n fill=\"currentColor\"\n d=\"M0,129 L175,129 L175,154 L0,154 L0,129 Z M3,9 L28.2158203,9 L28.2158203,47.9824219 L55.7695313,47.9824219 L55.7695313,9 L81.0966797,9 L81.0966797,107.185547 L55.7695313,107.185547 L55.7695313,68.0214844 L28.2158203,68.0214844 L28.2158203,107.185547 L3,107.185547 L3,9 Z M93.1855469,100.603516 L93.1855469,19 L135.211914,19 C143.004922,19 148.960917,19.6679621 153.080078,21.0039063 C157.199239,22.3398504 160.520495,24.8168764 163.043945,28.4350586 C165.567395,32.0532407 166.829102,36.459935 166.829102,41.6552734 C166.829102,46.1826398 165.864267,50.0883625 163.93457,53.3725586 C162.004873,56.6567547 159.351579,59.3193257 155.974609,61.3603516 C153.822255,62.6591862 150.872089,63.7353473 147.124023,64.5888672 C150.129898,65.5908253 152.319329,66.5927684 153.692383,67.5947266 C154.620122,68.2626987 155.965323,69.6913953 157.728027,71.8808594 C159.490731,74.0703234 160.668942,75.7587831 161.262695,76.9462891 L173,100.603516 L144.953125,100.603516 L131.482422,75.6660156 C129.775382,72.4374839 128.253913,70.3408251 126.917969,69.3759766 C125.0996,68.1142515 123.040051,67.4833984 120.739258,67.4833984 L118.512695,67.4833984 L118.512695,100.603516 L93.1855469,100.603516 Z M118.512695,52.0644531 L129.144531,52.0644531 C130.294928,52.0644531 132.521468,51.6933631 135.824219,50.9511719 C137.494149,50.6171858 138.857905,49.7636787 139.915527,48.390625 C140.97315,47.0175713 141.501953,45.4404386 141.501953,43.6591797 C141.501953,41.0244009 140.667001,39.0019602 138.99707,37.5917969 C137.32714,36.1816336 134.191429,35.4765625 129.589844,35.4765625 L117.512695,35.4765625 L118.512695,52.0644531 Z\"\n transform=\"translate(0 9)\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n api.replaceSelection(`${state.selectedText}\\n\\n----------\\n\\n`);\n },\n};\n"
|
|
23
23
|
],
|
|
24
|
-
"mappings": "
|
|
24
|
+
"mappings": ";;;;;;;AAAA;AAA+B;AAGxB,IAAMA,EAAY,GAAG;EAC1BC,IAAI,EAAE,IAAI;EACVC,UAAU,EAAE,IAAI;EAChBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,YAAY;EACnBC,WAAW,EAAE;IAAE,YAAY,EAAE,sBAAsB;IAAEC,KAAK,EAAE;EAAuB,CAAC;EACpFC,IAAI,eACF;IAAK,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,OAAO,EAAC,aAAa;IAAA,uBAC/C;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC,ukDAAukD;MACzkD,SAAS,EAAC;IAAgB;EAC1B,EAEL;EACDC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnDA,GAAG,CAACC,gBAAgB,WAAIF,KAAK,CAACG,YAAY,wBAAqB;EACjE;AACF,CAAC;AAAC"
|
|
25
25
|
}
|
package/lib/commands/image.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
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
|
});
|
|
8
7
|
exports.image = void 0;
|
|
9
|
-
|
|
10
8
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
13
|
-
|
|
14
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
|
|
16
11
|
var image = {
|
|
17
12
|
name: 'image',
|
|
18
13
|
keyCommand: 'image',
|
|
@@ -23,8 +18,8 @@ var image = {
|
|
|
23
18
|
title: 'Add image (ctrl + k)'
|
|
24
19
|
},
|
|
25
20
|
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
26
|
-
width: "
|
|
27
|
-
height: "
|
|
21
|
+
width: "13",
|
|
22
|
+
height: "13",
|
|
28
23
|
viewBox: "0 0 20 20",
|
|
29
24
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
|
|
30
25
|
fill: "currentColor",
|
|
@@ -37,11 +32,11 @@ var image = {
|
|
|
37
32
|
text: state.text,
|
|
38
33
|
selection: state.selection
|
|
39
34
|
});
|
|
40
|
-
var state1 = api.setSelectionRange(newSelectionRange);
|
|
41
|
-
|
|
35
|
+
var state1 = api.setSelectionRange(newSelectionRange);
|
|
36
|
+
// Replaces the current selection with the image
|
|
42
37
|
var imageTemplate = state1.selectedText || 'https://example.com/your-image.png';
|
|
43
|
-
api.replaceSelection(""));
|
|
44
|
-
|
|
38
|
+
api.replaceSelection(""));
|
|
39
|
+
// Adjust the selection to not contain the **
|
|
45
40
|
api.setSelectionRange({
|
|
46
41
|
start: 4 + state1.selection.start,
|
|
47
42
|
end: 4 + state1.selection.start + imageTemplate.length
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"../../src/commands/image.tsx"
|
|
30
30
|
],
|
|
31
31
|
"sourcesContent": [
|
|
32
|
-
"import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const image: ICommand = {\n name: 'image',\n keyCommand: 'image',\n shortcuts: 'ctrlcmd+k',\n value: '![image]()',\n buttonProps: { 'aria-label': 'Add image (ctrl + k)', title: 'Add image (ctrl + k)' },\n icon: (\n <svg width=\"
|
|
32
|
+
"import * as React from 'react';\nimport { ICommand, TextState, TextAreaTextApi } from './';\nimport { selectWord } from '../utils/markdownUtils';\n\nexport const image: ICommand = {\n name: 'image',\n keyCommand: 'image',\n shortcuts: 'ctrlcmd+k',\n value: '![image]()',\n buttonProps: { 'aria-label': 'Add image (ctrl + k)', title: 'Add image (ctrl + k)' },\n icon: (\n <svg width=\"13\" height=\"13\" viewBox=\"0 0 20 20\">\n <path\n fill=\"currentColor\"\n d=\"M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 13l-6-5-2 2-4-5-4 8V4h16v11z\"\n />\n </svg>\n ),\n execute: (state: TextState, api: TextAreaTextApi) => {\n // Select everything\n const newSelectionRange = selectWord({ text: state.text, selection: state.selection });\n const state1 = api.setSelectionRange(newSelectionRange);\n // Replaces the current selection with the image\n const imageTemplate = state1.selectedText || 'https://example.com/your-image.png';\n api.replaceSelection(``);\n // Adjust the selection to not contain the **\n api.setSelectionRange({\n start: 4 + state1.selection.start,\n end: 4 + state1.selection.start + imageTemplate.length,\n });\n },\n};\n"
|
|
33
33
|
],
|
|
34
|
-
"mappings": "
|
|
34
|
+
"mappings": ";;;;;;;AAAA;AAEA;AAAoD;AAE7C,IAAMA,KAAe,GAAG;EAC7BC,IAAI,EAAE,OAAO;EACbC,UAAU,EAAE,OAAO;EACnBC,SAAS,EAAE,WAAW;EACtBC,KAAK,EAAE,YAAY;EACnBC,WAAW,EAAE;IAAE,YAAY,EAAE,sBAAsB;IAAEC,KAAK,EAAE;EAAuB,CAAC;EACpFC,IAAI,eACF;IAAK,KAAK,EAAC,IAAI;IAAC,MAAM,EAAC,IAAI;IAAC,OAAO,EAAC,WAAW;IAAA,uBAC7C;MACE,IAAI,EAAC,cAAc;MACnB,CAAC,EAAC;IAAkK;EACpK,EAEL;EACDC,OAAO,EAAE,iBAACC,KAAgB,EAAEC,GAAoB,EAAK;IACnD;IACA,IAAMC,iBAAiB,GAAG,IAAAC,yBAAU,EAAC;MAAEC,IAAI,EAAEJ,KAAK,CAACI,IAAI;MAAEC,SAAS,EAAEL,KAAK,CAACK;IAAU,CAAC,CAAC;IACtF,IAAMC,MAAM,GAAGL,GAAG,CAACM,iBAAiB,CAACL,iBAAiB,CAAC;IACvD;IACA,IAAMM,aAAa,GAAGF,MAAM,CAACG,YAAY,IAAI,oCAAoC;IACjFR,GAAG,CAACS,gBAAgB,eAAQF,aAAa,OAAI;IAC7C;IACAP,GAAG,CAACM,iBAAiB,CAAC;MACpBI,KAAK,EAAE,CAAC,GAAGL,MAAM,CAACD,SAAS,CAACM,KAAK;MACjCC,GAAG,EAAE,CAAC,GAAGN,MAAM,CAACD,SAAS,CAACM,KAAK,GAAGH,aAAa,CAACK;IAClD,CAAC,CAAC;EACJ;AACF,CAAC;AAAC"
|
|
35
35
|
}
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export interface ICommandBase<T> {
|
|
|
46
46
|
liProps?: React.LiHTMLAttributes<HTMLLIElement>;
|
|
47
47
|
buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement> | null;
|
|
48
48
|
render?: (command: ICommand<T>, disabled: boolean, executeCommand: (command: ICommand<T>, name?: string) => void, index: number) => void | undefined | null | React.ReactElement;
|
|
49
|
-
execute?: (state: TextState, api: TextAreaTextApi, dispatch?: React.Dispatch<ContextStore>, executeCommandState?: ExecuteCommandState) => void;
|
|
49
|
+
execute?: (state: TextState, api: TextAreaTextApi, dispatch?: React.Dispatch<ContextStore>, executeCommandState?: ExecuteCommandState, shortcuts?: string[]) => void;
|
|
50
50
|
}
|
|
51
51
|
export declare type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;
|
|
52
52
|
export interface TextRange {
|
|
@@ -81,6 +81,6 @@ declare class TextAreaCommandOrchestrator implements CommandOrchestrator {
|
|
|
81
81
|
textApi: TextAreaTextApi;
|
|
82
82
|
constructor(textArea: HTMLTextAreaElement);
|
|
83
83
|
getState(): false | TextState;
|
|
84
|
-
executeCommand(command: ICommand<string>, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState): void;
|
|
84
|
+
executeCommand(command: ICommand<string>, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState, shortcuts?: string[]): void;
|
|
85
85
|
}
|
|
86
86
|
export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, codeEdit, codeLive, codePreview, fullscreen, getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi, };
|
package/lib/commands/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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
|
});
|
|
@@ -158,76 +157,46 @@ Object.defineProperty(exports, "unorderedListCommand", {
|
|
|
158
157
|
return _list.unorderedListCommand;
|
|
159
158
|
}
|
|
160
159
|
});
|
|
161
|
-
|
|
162
160
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
163
|
-
|
|
164
161
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
165
|
-
|
|
166
162
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
167
|
-
|
|
168
163
|
var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
|
|
169
|
-
|
|
170
164
|
var _bold = require("./bold");
|
|
171
|
-
|
|
172
165
|
var _code = require("./code");
|
|
173
|
-
|
|
174
166
|
var _comment = require("./comment");
|
|
175
|
-
|
|
176
167
|
var _divider = require("./divider");
|
|
177
|
-
|
|
178
168
|
var _fullscreen = require("./fullscreen");
|
|
179
|
-
|
|
180
169
|
var _group = require("./group");
|
|
181
|
-
|
|
182
170
|
var _hr = require("./hr");
|
|
183
|
-
|
|
184
171
|
var _image = require("./image");
|
|
185
|
-
|
|
186
172
|
var _italic = require("./italic");
|
|
187
|
-
|
|
188
173
|
var _link = require("./link");
|
|
189
|
-
|
|
190
174
|
var _list = require("./list");
|
|
191
|
-
|
|
192
175
|
var _preview = require("./preview");
|
|
193
|
-
|
|
194
176
|
var _quote = require("./quote");
|
|
195
|
-
|
|
196
177
|
var _strikeThrough = require("./strikeThrough");
|
|
197
|
-
|
|
198
178
|
var _title = require("./title");
|
|
199
|
-
|
|
200
179
|
var _title2 = require("./title1");
|
|
201
|
-
|
|
202
180
|
var _title3 = require("./title2");
|
|
203
|
-
|
|
204
181
|
var _title4 = require("./title3");
|
|
205
|
-
|
|
206
182
|
var _title5 = require("./title4");
|
|
207
|
-
|
|
208
183
|
var _title6 = require("./title5");
|
|
209
|
-
|
|
210
184
|
var _title7 = require("./title6");
|
|
211
|
-
|
|
212
185
|
var getCommands = function getCommands() {
|
|
213
|
-
return [
|
|
214
|
-
name:
|
|
215
|
-
groupName:
|
|
186
|
+
return [_bold.bold, _italic.italic, _strikeThrough.strikethrough, _hr.hr, (0, _group.group)([_title2.title1, _title3.title2, _title4.title3, _title5.title4, _title6.title5, _title7.title6], {
|
|
187
|
+
name: 'title',
|
|
188
|
+
groupName: 'title',
|
|
216
189
|
buttonProps: {
|
|
217
|
-
|
|
218
|
-
title:
|
|
190
|
+
'aria-label': 'Insert title',
|
|
191
|
+
title: 'Insert title'
|
|
219
192
|
}
|
|
220
|
-
}), _divider.divider, _link.link, _quote.quote, _code.code, _code.codeBlock, _image.image, _divider.divider, _list.unorderedListCommand, _list.orderedListCommand, _list.checkedListCommand];
|
|
193
|
+
}), _divider.divider, _link.link, _quote.quote, _code.code, _code.codeBlock, _comment.comment, _image.image, _divider.divider, _list.unorderedListCommand, _list.orderedListCommand, _list.checkedListCommand];
|
|
221
194
|
};
|
|
222
|
-
|
|
223
195
|
exports.getCommands = getCommands;
|
|
224
|
-
|
|
225
196
|
var getExtraCommands = function getExtraCommands() {
|
|
226
197
|
return [_preview.codeEdit, _preview.codeLive, _preview.codePreview, _divider.divider, _fullscreen.fullscreen];
|
|
227
198
|
};
|
|
228
|
-
|
|
229
199
|
exports.getExtraCommands = getExtraCommands;
|
|
230
|
-
|
|
231
200
|
function getStateFromTextArea(textArea) {
|
|
232
201
|
return {
|
|
233
202
|
selection: {
|
|
@@ -238,31 +207,29 @@ function getStateFromTextArea(textArea) {
|
|
|
238
207
|
selectedText: textArea.value.slice(textArea.selectionStart, textArea.selectionEnd)
|
|
239
208
|
};
|
|
240
209
|
}
|
|
241
|
-
|
|
242
210
|
var TextAreaTextApi = /*#__PURE__*/function () {
|
|
243
211
|
function TextAreaTextApi(textArea) {
|
|
244
212
|
(0, _classCallCheck2["default"])(this, TextAreaTextApi);
|
|
245
213
|
(0, _defineProperty2["default"])(this, "textArea", void 0);
|
|
246
214
|
this.textArea = textArea;
|
|
247
215
|
}
|
|
216
|
+
|
|
248
217
|
/**
|
|
249
218
|
* Replaces the current selection with the new text. This will make the new selectedText to be empty, the
|
|
250
219
|
* selection start and selection end will be the same and will both point to the end
|
|
251
220
|
* @param text Text that should replace the current selection
|
|
252
221
|
*/
|
|
253
|
-
|
|
254
|
-
|
|
255
222
|
(0, _createClass2["default"])(TextAreaTextApi, [{
|
|
256
223
|
key: "replaceSelection",
|
|
257
224
|
value: function replaceSelection(text) {
|
|
258
225
|
(0, _InsertTextAtPosition.insertTextAtPosition)(this.textArea, text);
|
|
259
226
|
return getStateFromTextArea(this.textArea);
|
|
260
227
|
}
|
|
228
|
+
|
|
261
229
|
/**
|
|
262
230
|
* Selects the specified text range
|
|
263
231
|
* @param selection
|
|
264
232
|
*/
|
|
265
|
-
|
|
266
233
|
}, {
|
|
267
234
|
key: "setSelectionRange",
|
|
268
235
|
value: function setSelectionRange(selection) {
|
|
@@ -274,9 +241,7 @@ var TextAreaTextApi = /*#__PURE__*/function () {
|
|
|
274
241
|
}]);
|
|
275
242
|
return TextAreaTextApi;
|
|
276
243
|
}();
|
|
277
|
-
|
|
278
244
|
exports.TextAreaTextApi = TextAreaTextApi;
|
|
279
|
-
|
|
280
245
|
var TextAreaCommandOrchestrator = /*#__PURE__*/function () {
|
|
281
246
|
function TextAreaCommandOrchestrator(textArea) {
|
|
282
247
|
(0, _classCallCheck2["default"])(this, TextAreaCommandOrchestrator);
|
|
@@ -285,7 +250,6 @@ var TextAreaCommandOrchestrator = /*#__PURE__*/function () {
|
|
|
285
250
|
this.textArea = textArea;
|
|
286
251
|
this.textApi = new TextAreaTextApi(textArea);
|
|
287
252
|
}
|
|
288
|
-
|
|
289
253
|
(0, _createClass2["default"])(TextAreaCommandOrchestrator, [{
|
|
290
254
|
key: "getState",
|
|
291
255
|
value: function getState() {
|
|
@@ -294,12 +258,11 @@ var TextAreaCommandOrchestrator = /*#__PURE__*/function () {
|
|
|
294
258
|
}
|
|
295
259
|
}, {
|
|
296
260
|
key: "executeCommand",
|
|
297
|
-
value: function executeCommand(command, dispatch, state) {
|
|
298
|
-
command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state);
|
|
261
|
+
value: function executeCommand(command, dispatch, state, shortcuts) {
|
|
262
|
+
command.execute && command.execute(getStateFromTextArea(this.textArea), this.textApi, dispatch, state, shortcuts);
|
|
299
263
|
}
|
|
300
264
|
}]);
|
|
301
265
|
return TextAreaCommandOrchestrator;
|
|
302
266
|
}();
|
|
303
|
-
|
|
304
267
|
exports.TextAreaCommandOrchestrator = TextAreaCommandOrchestrator;
|
|
305
268
|
//# sourceMappingURL=index.js.map
|