@uiw/react-md-editor 3.23.6 → 3.24.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/README.md +29 -4
- package/dist/mdeditor.css +2 -0
- package/dist/mdeditor.js +234 -237
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/dist/mdeditor.min.js.LICENSE.txt +1 -1
- package/esm/commands/bold.js +9 -13
- package/esm/commands/code.d.ts +1 -1
- package/esm/commands/code.js +75 -68
- package/esm/commands/comment.js +20 -18
- package/esm/commands/help.d.ts +2 -0
- package/esm/commands/help.js +22 -0
- package/esm/commands/hr.js +33 -2
- package/esm/commands/image.js +39 -16
- package/esm/commands/index.d.ts +7 -2
- package/esm/commands/index.js +5 -2
- package/esm/commands/issue.d.ts +2 -0
- package/esm/commands/issue.js +41 -0
- package/esm/commands/italic.js +9 -13
- package/esm/commands/link.js +40 -14
- package/esm/commands/list.d.ts +3 -10
- package/esm/commands/list.js +39 -41
- package/esm/commands/quote.js +8 -8
- package/esm/commands/strikeThrough.js +9 -13
- package/esm/commands/table.d.ts +2 -0
- package/esm/commands/table.js +57 -0
- package/esm/commands/title.d.ts +7 -1
- package/esm/commands/title.js +21 -0
- package/esm/commands/title1.js +9 -7
- package/esm/commands/title2.js +9 -7
- package/esm/commands/title3.js +9 -7
- package/esm/commands/title4.js +9 -7
- package/esm/commands/title5.js +9 -7
- package/esm/commands/title6.js +9 -7
- package/esm/components/TextArea/handleKeyDown.js +83 -5
- package/esm/utils/InsertTextAtPosition.d.ts +0 -7
- package/esm/utils/InsertTextAtPosition.js +6 -24
- package/esm/utils/markdownUtils.d.ts +23 -1
- package/esm/utils/markdownUtils.js +83 -4
- package/lib/Context.js +2 -3
- package/lib/Editor.js +1 -2
- package/lib/commands/bold.js +10 -15
- package/lib/commands/code.d.ts +1 -1
- package/lib/commands/code.js +75 -70
- package/lib/commands/comment.js +21 -20
- package/lib/commands/divider.js +2 -3
- package/lib/commands/fullscreen.js +2 -3
- package/lib/commands/group.js +2 -3
- package/lib/commands/help.d.ts +2 -0
- package/lib/commands/help.js +29 -0
- package/lib/commands/hr.js +35 -5
- package/lib/commands/image.js +40 -18
- package/lib/commands/index.d.ts +7 -2
- package/lib/commands/index.js +27 -10
- package/lib/commands/issue.d.ts +2 -0
- package/lib/commands/issue.js +48 -0
- package/lib/commands/italic.js +10 -15
- package/lib/commands/link.js +41 -16
- package/lib/commands/list.d.ts +3 -10
- package/lib/commands/list.js +43 -52
- package/lib/commands/preview.js +4 -7
- package/lib/commands/quote.js +9 -10
- package/lib/commands/strikeThrough.js +10 -15
- package/lib/commands/table.d.ts +2 -0
- package/lib/commands/table.js +64 -0
- package/lib/commands/title.d.ts +7 -1
- package/lib/commands/title.js +23 -3
- package/lib/commands/title1.js +11 -10
- package/lib/commands/title2.js +11 -10
- package/lib/commands/title3.js +11 -10
- package/lib/commands/title4.js +11 -10
- package/lib/commands/title5.js +11 -10
- package/lib/commands/title6.js +11 -10
- package/lib/components/DragBar/index.js +1 -2
- package/lib/components/TextArea/handleKeyDown.js +84 -6
- package/lib/index.js +1 -2
- package/lib/utils/InsertTextAtPosition.d.ts +0 -7
- package/lib/utils/InsertTextAtPosition.js +6 -26
- package/lib/utils/markdownUtils.d.ts +23 -1
- package/lib/utils/markdownUtils.js +84 -4
- package/package.json +4 -1
- package/src/commands/bold.tsx +13 -12
- package/src/commands/code.tsx +72 -71
- package/src/commands/comment.tsx +20 -15
- package/src/commands/help.tsx +19 -0
- package/src/commands/hr.tsx +33 -2
- package/src/commands/image.tsx +38 -15
- package/src/commands/index.ts +12 -1
- package/src/commands/issue.tsx +36 -0
- package/src/commands/italic.tsx +13 -12
- package/src/commands/link.tsx +39 -12
- package/src/commands/list.tsx +35 -53
- package/src/commands/quote.tsx +14 -13
- package/src/commands/strikeThrough.tsx +13 -12
- package/src/commands/table.tsx +52 -0
- package/src/commands/title.tsx +18 -1
- package/src/commands/title1.tsx +6 -9
- package/src/commands/title2.tsx +6 -9
- package/src/commands/title3.tsx +6 -9
- package/src/commands/title4.tsx +6 -9
- package/src/commands/title5.tsx +6 -9
- package/src/commands/title6.tsx +6 -9
- package/src/components/TextArea/handleKeyDown.tsx +54 -5
- package/src/utils/InsertTextAtPosition.ts +7 -28
- package/src/utils/markdownUtils.ts +94 -4
package/esm/commands/link.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { selectWord } from '../utils/markdownUtils';
|
|
2
|
+
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var link = {
|
|
5
5
|
name: 'link',
|
|
6
6
|
keyCommand: 'link',
|
|
7
7
|
shortcuts: 'ctrlcmd+l',
|
|
8
|
-
|
|
8
|
+
prefix: '[',
|
|
9
|
+
suffix: '](url)',
|
|
9
10
|
buttonProps: {
|
|
10
11
|
'aria-label': 'Add a link (ctrl + l)',
|
|
11
12
|
title: 'Add a link (ctrl + l)'
|
|
@@ -22,21 +23,46 @@ export var link = {
|
|
|
22
23
|
})
|
|
23
24
|
}),
|
|
24
25
|
execute: (state, api) => {
|
|
25
|
-
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
26
26
|
var newSelectionRange = selectWord({
|
|
27
27
|
text: state.text,
|
|
28
|
-
selection: state.selection
|
|
28
|
+
selection: state.selection,
|
|
29
|
+
prefix: state.command.prefix,
|
|
30
|
+
suffix: state.command.suffix
|
|
29
31
|
});
|
|
30
32
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
if (state1.selectedText.includes('http') || state1.selectedText.includes('www')) {
|
|
34
|
+
newSelectionRange = selectWord({
|
|
35
|
+
text: state.text,
|
|
36
|
+
selection: state.selection,
|
|
37
|
+
prefix: '[](',
|
|
38
|
+
suffix: ')'
|
|
39
|
+
});
|
|
40
|
+
state1 = api.setSelectionRange(newSelectionRange);
|
|
41
|
+
executeCommand({
|
|
42
|
+
api,
|
|
43
|
+
selectedText: state1.selectedText,
|
|
44
|
+
selection: state.selection,
|
|
45
|
+
prefix: '[](',
|
|
46
|
+
suffix: ')'
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
if (state1.selectedText.length === 0) {
|
|
50
|
+
executeCommand({
|
|
51
|
+
api,
|
|
52
|
+
selectedText: state1.selectedText,
|
|
53
|
+
selection: state.selection,
|
|
54
|
+
prefix: '[title',
|
|
55
|
+
suffix: '](url)'
|
|
56
|
+
});
|
|
57
|
+
} else {
|
|
58
|
+
executeCommand({
|
|
59
|
+
api,
|
|
60
|
+
selectedText: state1.selectedText,
|
|
61
|
+
selection: state.selection,
|
|
62
|
+
prefix: state.command.prefix,
|
|
63
|
+
suffix: state.command.suffix
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
41
67
|
}
|
|
42
68
|
};
|
package/esm/commands/list.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
import { ICommand,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Inserts insertionString before each line
|
|
5
|
-
*/
|
|
6
|
-
export declare function insertBeforeEachLine(selectedText: string, insertBefore: string | AlterLineFunction): {
|
|
7
|
-
modifiedText: string;
|
|
8
|
-
insertionLength: number;
|
|
9
|
-
};
|
|
10
|
-
export declare const makeList: (state: TextState, api: TextAreaTextApi, insertBefore: string | AlterLineFunction) => void;
|
|
1
|
+
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
import { AlterLineFunction } from '../utils/markdownUtils';
|
|
3
|
+
export declare const makeList: (state: ExecuteState, api: TextAreaTextApi, insertBefore: string | AlterLineFunction) => void;
|
|
11
4
|
export declare const unorderedListCommand: ICommand;
|
|
12
5
|
export declare const orderedListCommand: ICommand;
|
|
13
6
|
export declare const checkedListCommand: ICommand;
|
package/esm/commands/list.js
CHANGED
|
@@ -1,58 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter } from '../utils/markdownUtils';
|
|
2
|
+
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, insertBeforeEachLine } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
/**
|
|
5
|
-
* Inserts insertionString before each line
|
|
6
|
-
*/
|
|
7
|
-
export function insertBeforeEachLine(selectedText, insertBefore) {
|
|
8
|
-
var lines = selectedText.split(/\n/);
|
|
9
|
-
var insertionLength = 0;
|
|
10
|
-
var modifiedText = lines.map((item, index) => {
|
|
11
|
-
if (typeof insertBefore === 'string') {
|
|
12
|
-
insertionLength += insertBefore.length;
|
|
13
|
-
return insertBefore + item;
|
|
14
|
-
} else if (typeof insertBefore === 'function') {
|
|
15
|
-
var insertionResult = insertBefore(item, index);
|
|
16
|
-
insertionLength += insertionResult.length;
|
|
17
|
-
return insertBefore(item, index) + item;
|
|
18
|
-
}
|
|
19
|
-
throw Error('insertion is expected to be either a string or a function');
|
|
20
|
-
}).join('\n');
|
|
21
|
-
return {
|
|
22
|
-
modifiedText,
|
|
23
|
-
insertionLength
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
4
|
export var makeList = (state, api, insertBefore) => {
|
|
27
|
-
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
28
5
|
var newSelectionRange = selectWord({
|
|
29
6
|
text: state.text,
|
|
30
|
-
selection: state.selection
|
|
7
|
+
selection: state.selection,
|
|
8
|
+
prefix: state.command.prefix
|
|
31
9
|
});
|
|
32
10
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
33
11
|
var breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);
|
|
34
12
|
var breaksBefore = Array(breaksBeforeCount + 1).join('\n');
|
|
35
13
|
var breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);
|
|
36
14
|
var breaksAfter = Array(breaksAfterCount + 1).join('\n');
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
end
|
|
49
|
-
|
|
15
|
+
var {
|
|
16
|
+
modifiedText,
|
|
17
|
+
insertionLength
|
|
18
|
+
} = insertBeforeEachLine(state1.selectedText, insertBefore);
|
|
19
|
+
if (insertionLength < 0) {
|
|
20
|
+
// Remove
|
|
21
|
+
var selectionStart = state1.selection.start;
|
|
22
|
+
var selectionEnd = state1.selection.end;
|
|
23
|
+
if (state1.selection.start > 0 && state.text.slice(state1.selection.start - 1, state1.selection.start) === '\n') {
|
|
24
|
+
selectionStart -= 1;
|
|
25
|
+
}
|
|
26
|
+
if (state1.selection.end < state.text.length - 1 && state.text.slice(state1.selection.end, state1.selection.end + 1) === '\n') {
|
|
27
|
+
selectionEnd += 1;
|
|
28
|
+
}
|
|
29
|
+
api.setSelectionRange({
|
|
30
|
+
start: selectionStart,
|
|
31
|
+
end: selectionEnd
|
|
32
|
+
});
|
|
33
|
+
api.replaceSelection("" + modifiedText);
|
|
34
|
+
api.setSelectionRange({
|
|
35
|
+
start: selectionStart,
|
|
36
|
+
end: selectionStart + modifiedText.length
|
|
37
|
+
});
|
|
38
|
+
} else {
|
|
39
|
+
// Add
|
|
40
|
+
api.replaceSelection("" + breaksBefore + modifiedText + breaksAfter);
|
|
41
|
+
var _selectionStart = state1.selection.start + breaksBeforeCount;
|
|
42
|
+
var _selectionEnd = _selectionStart + modifiedText.length;
|
|
43
|
+
api.setSelectionRange({
|
|
44
|
+
start: _selectionStart,
|
|
45
|
+
end: _selectionEnd
|
|
46
|
+
});
|
|
47
|
+
}
|
|
50
48
|
};
|
|
51
49
|
export var unorderedListCommand = {
|
|
52
50
|
name: 'unordered-list',
|
|
53
51
|
keyCommand: 'list',
|
|
54
52
|
shortcuts: 'ctrl+shift+u',
|
|
55
|
-
|
|
53
|
+
prefix: '- ',
|
|
56
54
|
buttonProps: {
|
|
57
55
|
'aria-label': 'Add unordered list (ctrl + shift + u)',
|
|
58
56
|
title: 'Add unordered list (ctrl + shift + u)'
|
|
@@ -75,7 +73,7 @@ export var orderedListCommand = {
|
|
|
75
73
|
name: 'ordered-list',
|
|
76
74
|
keyCommand: 'list',
|
|
77
75
|
shortcuts: 'ctrl+shift+o',
|
|
78
|
-
|
|
76
|
+
prefix: '1. ',
|
|
79
77
|
buttonProps: {
|
|
80
78
|
'aria-label': 'Add ordered list (ctrl + shift + o)',
|
|
81
79
|
title: 'Add ordered list (ctrl + shift + o)'
|
|
@@ -99,7 +97,7 @@ export var checkedListCommand = {
|
|
|
99
97
|
name: 'checked-list',
|
|
100
98
|
keyCommand: 'list',
|
|
101
99
|
shortcuts: 'ctrl+shift+c',
|
|
102
|
-
|
|
100
|
+
prefix: '- [ ] ',
|
|
103
101
|
buttonProps: {
|
|
104
102
|
'aria-label': 'Add checked list (ctrl + shift + c)',
|
|
105
103
|
title: 'Add checked list (ctrl + shift + c)'
|
package/esm/commands/quote.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, selectWord } from '../utils/markdownUtils';
|
|
2
|
+
import { getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, selectWord, insertBeforeEachLine } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var quote = {
|
|
5
5
|
name: 'quote',
|
|
6
6
|
keyCommand: 'quote',
|
|
7
7
|
shortcuts: 'ctrlcmd+q',
|
|
8
|
+
prefix: '> ',
|
|
8
9
|
buttonProps: {
|
|
9
10
|
'aria-label': 'Insert a quote (ctrl + q)',
|
|
10
11
|
title: 'Insert a quote (ctrl + q)'
|
|
@@ -19,21 +20,20 @@ export var quote = {
|
|
|
19
20
|
})
|
|
20
21
|
}),
|
|
21
22
|
execute: (state, api) => {
|
|
22
|
-
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
23
23
|
var newSelectionRange = selectWord({
|
|
24
24
|
text: state.text,
|
|
25
|
-
selection: state.selection
|
|
25
|
+
selection: state.selection,
|
|
26
|
+
prefix: state.command.prefix
|
|
26
27
|
});
|
|
27
28
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
28
29
|
var breaksBeforeCount = getBreaksNeededForEmptyLineBefore(state1.text, state1.selection.start);
|
|
29
30
|
var breaksBefore = Array(breaksBeforeCount + 1).join('\n');
|
|
30
31
|
var breaksAfterCount = getBreaksNeededForEmptyLineAfter(state1.text, state1.selection.end);
|
|
31
32
|
var breaksAfter = Array(breaksAfterCount + 1).join('\n');
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var selectionEnd = selectionStart + state1.selectedText.length;
|
|
33
|
+
var modifiedText = insertBeforeEachLine(state1.selectedText, state.command.prefix);
|
|
34
|
+
api.replaceSelection("" + breaksBefore + modifiedText.modifiedText + breaksAfter);
|
|
35
|
+
var selectionStart = state1.selection.start + breaksBeforeCount;
|
|
36
|
+
var selectionEnd = selectionStart + modifiedText.modifiedText.length;
|
|
37
37
|
api.setSelectionRange({
|
|
38
38
|
start: selectionStart,
|
|
39
39
|
end: selectionEnd
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { selectWord } from '../utils/markdownUtils';
|
|
2
|
+
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var strikethrough = {
|
|
5
5
|
name: 'strikethrough',
|
|
@@ -9,7 +9,7 @@ export var strikethrough = {
|
|
|
9
9
|
'aria-label': 'Add strikethrough text (ctrl + shift + x)',
|
|
10
10
|
title: 'Add strikethrough text (ctrl + shift + x)'
|
|
11
11
|
},
|
|
12
|
-
|
|
12
|
+
prefix: '~~',
|
|
13
13
|
icon: /*#__PURE__*/_jsx("svg", {
|
|
14
14
|
"data-name": "strikethrough",
|
|
15
15
|
width: "12",
|
|
@@ -22,21 +22,17 @@ export var strikethrough = {
|
|
|
22
22
|
})
|
|
23
23
|
}),
|
|
24
24
|
execute: (state, api) => {
|
|
25
|
-
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
26
25
|
var newSelectionRange = selectWord({
|
|
27
26
|
text: state.text,
|
|
28
|
-
selection: state.selection
|
|
27
|
+
selection: state.selection,
|
|
28
|
+
prefix: state.command.prefix
|
|
29
29
|
});
|
|
30
30
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// Adjust the selection to not contain the **
|
|
37
|
-
api.setSelectionRange({
|
|
38
|
-
start,
|
|
39
|
-
end
|
|
31
|
+
executeCommand({
|
|
32
|
+
api,
|
|
33
|
+
selectedText: state1.selectedText,
|
|
34
|
+
selection: state.selection,
|
|
35
|
+
prefix: state.command.prefix
|
|
40
36
|
});
|
|
41
37
|
}
|
|
42
38
|
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { selectWord, executeCommand } from '../utils/markdownUtils';
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
export var table = {
|
|
5
|
+
name: 'table',
|
|
6
|
+
keyCommand: 'table',
|
|
7
|
+
prefix: '\n| Header | Header |\n|--------|--------|\n| Cell | Cell |\n| Cell | Cell |\n| Cell | Cell |\n\n',
|
|
8
|
+
suffix: '',
|
|
9
|
+
buttonProps: {
|
|
10
|
+
'aria-label': 'Add table',
|
|
11
|
+
title: 'Add table'
|
|
12
|
+
},
|
|
13
|
+
icon: /*#__PURE__*/_jsx("svg", {
|
|
14
|
+
role: "img",
|
|
15
|
+
width: "12",
|
|
16
|
+
height: "12",
|
|
17
|
+
viewBox: "0 0 512 512",
|
|
18
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
19
|
+
fill: "currentColor",
|
|
20
|
+
d: "M64 256V160H224v96H64zm0 64H224v96H64V320zm224 96V320H448v96H288zM448 256H288V160H448v96zM64 32C28.7 32 0 60.7 0 96V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H64z"
|
|
21
|
+
//Font Awesome Free 6.4.2 by @fontawesome - https://fontawesome.com
|
|
22
|
+
})
|
|
23
|
+
}),
|
|
24
|
+
|
|
25
|
+
execute: (state, api) => {
|
|
26
|
+
var newSelectionRange = selectWord({
|
|
27
|
+
text: state.text,
|
|
28
|
+
selection: state.selection,
|
|
29
|
+
prefix: state.command.prefix,
|
|
30
|
+
suffix: state.command.suffix
|
|
31
|
+
});
|
|
32
|
+
var state1 = api.setSelectionRange(newSelectionRange);
|
|
33
|
+
if (state1.selectedText.length >= state.command.prefix.length + state.command.suffix.length && state1.selectedText.startsWith(state.command.prefix)) {
|
|
34
|
+
// Remove
|
|
35
|
+
executeCommand({
|
|
36
|
+
api,
|
|
37
|
+
selectedText: state1.selectedText,
|
|
38
|
+
selection: state.selection,
|
|
39
|
+
prefix: state.command.prefix,
|
|
40
|
+
suffix: state.command.suffix
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
// Add
|
|
44
|
+
state1 = api.setSelectionRange({
|
|
45
|
+
start: state.selection.start,
|
|
46
|
+
end: state.selection.start
|
|
47
|
+
});
|
|
48
|
+
executeCommand({
|
|
49
|
+
api,
|
|
50
|
+
selectedText: state1.selectedText,
|
|
51
|
+
selection: state.selection,
|
|
52
|
+
prefix: state.command.prefix,
|
|
53
|
+
suffix: state.command.suffix
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
package/esm/commands/title.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import { ICommand } from './';
|
|
1
|
+
import { ICommand, ExecuteState, TextAreaTextApi } from './';
|
|
2
|
+
export declare function titleExecute({ state, api, prefix, suffix, }: {
|
|
3
|
+
state: ExecuteState;
|
|
4
|
+
api: TextAreaTextApi;
|
|
5
|
+
prefix: string;
|
|
6
|
+
suffix?: string;
|
|
7
|
+
}): void;
|
|
2
8
|
export declare const title: ICommand;
|
package/esm/commands/title.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { title1 } from './title1';
|
|
4
|
+
import { selectLine, executeCommand } from '../utils/markdownUtils';
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
export function titleExecute(_ref) {
|
|
7
|
+
var {
|
|
8
|
+
state,
|
|
9
|
+
api,
|
|
10
|
+
prefix,
|
|
11
|
+
suffix = prefix
|
|
12
|
+
} = _ref;
|
|
13
|
+
var newSelectionRange = selectLine({
|
|
14
|
+
text: state.text,
|
|
15
|
+
selection: state.selection
|
|
16
|
+
});
|
|
17
|
+
var state1 = api.setSelectionRange(newSelectionRange);
|
|
18
|
+
executeCommand({
|
|
19
|
+
api,
|
|
20
|
+
selectedText: state1.selectedText,
|
|
21
|
+
selection: state.selection,
|
|
22
|
+
prefix,
|
|
23
|
+
suffix
|
|
24
|
+
});
|
|
25
|
+
}
|
|
5
26
|
export var title = _extends({}, title1, {
|
|
6
27
|
icon: /*#__PURE__*/_jsx("svg", {
|
|
7
28
|
width: "12",
|
package/esm/commands/title1.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { titleExecute } from '../commands/title';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title1 = {
|
|
5
5
|
name: 'title1',
|
|
6
6
|
keyCommand: 'title1',
|
|
7
7
|
shortcuts: 'ctrlcmd+1',
|
|
8
|
-
|
|
8
|
+
prefix: '# ',
|
|
9
|
+
suffix: '',
|
|
9
10
|
buttonProps: {
|
|
10
11
|
'aria-label': 'Insert title1 (ctrl + 1)',
|
|
11
12
|
title: 'Insert title1 (ctrl + 1)'
|
|
@@ -18,10 +19,11 @@ export var title1 = {
|
|
|
18
19
|
children: "Title 1"
|
|
19
20
|
}),
|
|
20
21
|
execute: (state, api) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
titleExecute({
|
|
23
|
+
state,
|
|
24
|
+
api,
|
|
25
|
+
prefix: state.command.prefix,
|
|
26
|
+
suffix: state.command.suffix
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
};
|
package/esm/commands/title2.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { titleExecute } from '../commands/title';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title2 = {
|
|
5
5
|
name: 'title2',
|
|
6
6
|
keyCommand: 'title2',
|
|
7
7
|
shortcuts: 'ctrlcmd+2',
|
|
8
|
-
|
|
8
|
+
prefix: '## ',
|
|
9
|
+
suffix: '',
|
|
9
10
|
buttonProps: {
|
|
10
11
|
'aria-label': 'Insert title2 (ctrl + 2)',
|
|
11
12
|
title: 'Insert title2 (ctrl + 2)'
|
|
@@ -18,10 +19,11 @@ export var title2 = {
|
|
|
18
19
|
children: "Title 2"
|
|
19
20
|
}),
|
|
20
21
|
execute: (state, api) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
titleExecute({
|
|
23
|
+
state,
|
|
24
|
+
api,
|
|
25
|
+
prefix: state.command.prefix,
|
|
26
|
+
suffix: state.command.suffix
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
};
|
package/esm/commands/title3.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { titleExecute } from '../commands/title';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title3 = {
|
|
5
5
|
name: 'title3',
|
|
6
6
|
keyCommand: 'title3',
|
|
7
7
|
shortcuts: 'ctrlcmd+3',
|
|
8
|
-
|
|
8
|
+
prefix: '### ',
|
|
9
|
+
suffix: '',
|
|
9
10
|
buttonProps: {
|
|
10
11
|
'aria-label': 'Insert title3 (ctrl + 3)',
|
|
11
12
|
title: 'Insert title3 (ctrl + 3)'
|
|
@@ -18,10 +19,11 @@ export var title3 = {
|
|
|
18
19
|
children: "Title 3"
|
|
19
20
|
}),
|
|
20
21
|
execute: (state, api) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
titleExecute({
|
|
23
|
+
state,
|
|
24
|
+
api,
|
|
25
|
+
prefix: state.command.prefix,
|
|
26
|
+
suffix: state.command.suffix
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
};
|
package/esm/commands/title4.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { titleExecute } from '../commands/title';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title4 = {
|
|
5
5
|
name: 'title4',
|
|
6
6
|
keyCommand: 'title4',
|
|
7
7
|
shortcuts: 'ctrlcmd+4',
|
|
8
|
-
|
|
8
|
+
prefix: '#### ',
|
|
9
|
+
suffix: '',
|
|
9
10
|
buttonProps: {
|
|
10
11
|
'aria-label': 'Insert title4 (ctrl + 4)',
|
|
11
12
|
title: 'Insert title4 (ctrl + 4)'
|
|
@@ -18,10 +19,11 @@ export var title4 = {
|
|
|
18
19
|
children: "Title 4"
|
|
19
20
|
}),
|
|
20
21
|
execute: (state, api) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
titleExecute({
|
|
23
|
+
state,
|
|
24
|
+
api,
|
|
25
|
+
prefix: state.command.prefix,
|
|
26
|
+
suffix: state.command.suffix
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
};
|
package/esm/commands/title5.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { titleExecute } from '../commands/title';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title5 = {
|
|
5
5
|
name: 'title5',
|
|
6
6
|
keyCommand: 'title5',
|
|
7
7
|
shortcuts: 'ctrlcmd+5',
|
|
8
|
-
|
|
8
|
+
prefix: '##### ',
|
|
9
|
+
suffix: '',
|
|
9
10
|
buttonProps: {
|
|
10
11
|
'aria-label': 'Insert title5 (ctrl + 5)',
|
|
11
12
|
title: 'Insert title5 (ctrl + 5)'
|
|
@@ -18,10 +19,11 @@ export var title5 = {
|
|
|
18
19
|
children: "Title 5"
|
|
19
20
|
}),
|
|
20
21
|
execute: (state, api) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
titleExecute({
|
|
23
|
+
state,
|
|
24
|
+
api,
|
|
25
|
+
prefix: state.command.prefix,
|
|
26
|
+
suffix: state.command.suffix
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
};
|
package/esm/commands/title6.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { titleExecute } from '../commands/title';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title6 = {
|
|
5
5
|
name: 'title6',
|
|
6
6
|
keyCommand: 'title6',
|
|
7
7
|
shortcuts: 'ctrlcmd+6',
|
|
8
|
-
|
|
8
|
+
prefix: '###### ',
|
|
9
|
+
suffix: '',
|
|
9
10
|
buttonProps: {
|
|
10
11
|
'aria-label': 'Insert title6 (ctrl + 6)',
|
|
11
12
|
title: 'Insert title6 (ctrl + 6)'
|
|
@@ -18,10 +19,11 @@ export var title6 = {
|
|
|
18
19
|
children: "Title 6"
|
|
19
20
|
}),
|
|
20
21
|
execute: (state, api) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
titleExecute({
|
|
23
|
+
state,
|
|
24
|
+
api,
|
|
25
|
+
prefix: state.command.prefix,
|
|
26
|
+
suffix: state.command.suffix
|
|
27
|
+
});
|
|
26
28
|
}
|
|
27
29
|
};
|