@uiw/react-md-editor 3.18.1 → 3.18.2
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 +75 -8
- package/dist/mdeditor.css +0 -1
- package/dist/mdeditor.js +124 -224
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/commands/bold.js +3 -2
- package/esm/commands/bold.js.map +3 -2
- package/esm/commands/code.js +6 -4
- package/esm/commands/code.js.map +3 -2
- package/esm/commands/comment.js +5 -0
- package/esm/commands/comment.js.map +5 -2
- package/esm/commands/fullscreen.js +4 -3
- package/esm/commands/fullscreen.js.map +3 -2
- package/esm/commands/hr.js +3 -2
- package/esm/commands/hr.js.map +3 -2
- package/esm/commands/image.js +4 -3
- package/esm/commands/image.js.map +3 -2
- package/esm/commands/italic.js +3 -2
- package/esm/commands/italic.js.map +3 -2
- package/esm/commands/link.js +4 -3
- package/esm/commands/link.js.map +3 -2
- package/esm/commands/list.js +10 -7
- package/esm/commands/list.js.map +3 -2
- package/esm/commands/preview.js +9 -6
- package/esm/commands/preview.js.map +3 -2
- package/esm/commands/quote.js +2 -2
- package/esm/commands/quote.js.map +2 -2
- package/esm/commands/strikeThrough.js +3 -2
- package/esm/commands/strikeThrough.js.map +3 -2
- package/esm/commands/title.js +2 -2
- package/esm/commands/title.js.map +2 -2
- package/esm/commands/title1.js +3 -2
- package/esm/commands/title1.js.map +3 -2
- package/esm/commands/title2.js +3 -2
- package/esm/commands/title2.js.map +3 -2
- package/esm/commands/title3.js +3 -2
- package/esm/commands/title3.js.map +3 -2
- package/esm/commands/title4.js +3 -2
- package/esm/commands/title4.js.map +3 -2
- package/esm/commands/title5.js +3 -2
- package/esm/commands/title5.js.map +3 -2
- package/esm/commands/title6.js +3 -2
- package/esm/commands/title6.js.map +3 -2
- package/lib/commands/bold.js +3 -2
- package/lib/commands/bold.js.map +3 -2
- package/lib/commands/code.js +6 -4
- package/lib/commands/code.js.map +3 -2
- package/lib/commands/comment.js +5 -0
- package/lib/commands/comment.js.map +5 -2
- package/lib/commands/fullscreen.js +4 -3
- package/lib/commands/fullscreen.js.map +3 -2
- package/lib/commands/hr.js +3 -2
- package/lib/commands/hr.js.map +3 -2
- package/lib/commands/image.js +4 -3
- package/lib/commands/image.js.map +3 -2
- package/lib/commands/italic.js +3 -2
- package/lib/commands/italic.js.map +3 -2
- package/lib/commands/link.js +4 -3
- package/lib/commands/link.js.map +3 -2
- package/lib/commands/list.js +10 -7
- package/lib/commands/list.js.map +3 -2
- package/lib/commands/preview.js +9 -6
- package/lib/commands/preview.js.map +3 -2
- package/lib/commands/quote.js +2 -2
- package/lib/commands/quote.js.map +2 -2
- package/lib/commands/strikeThrough.js +3 -2
- package/lib/commands/strikeThrough.js.map +3 -2
- package/lib/commands/title.js +2 -2
- package/lib/commands/title.js.map +2 -2
- package/lib/commands/title1.js +3 -2
- package/lib/commands/title1.js.map +3 -2
- package/lib/commands/title2.js +3 -2
- package/lib/commands/title2.js.map +3 -2
- package/lib/commands/title3.js +3 -2
- package/lib/commands/title3.js.map +3 -2
- package/lib/commands/title4.js +3 -2
- package/lib/commands/title4.js.map +3 -2
- package/lib/commands/title5.js +3 -2
- package/lib/commands/title5.js.map +3 -2
- package/lib/commands/title6.js +3 -2
- package/lib/commands/title6.js.map +3 -2
- package/package.json +1 -1
- package/src/__test__/commands.test.tsx +26 -26
- package/src/commands/bold.tsx +2 -1
- package/src/commands/code.tsx +4 -2
- package/src/commands/comment.tsx +2 -0
- package/src/commands/fullscreen.tsx +3 -2
- package/src/commands/hr.tsx +2 -1
- package/src/commands/image.tsx +3 -2
- package/src/commands/italic.tsx +2 -1
- package/src/commands/link.tsx +3 -2
- package/src/commands/list.tsx +10 -4
- package/src/commands/preview.tsx +6 -3
- package/src/commands/quote.tsx +1 -1
- package/src/commands/strikeThrough.tsx +5 -1
- package/src/commands/title.tsx +2 -2
- package/src/commands/title1.tsx +2 -1
- package/src/commands/title2.tsx +2 -1
- package/src/commands/title3.tsx +2 -1
- package/src/commands/title4.tsx +2 -1
- package/src/commands/title5.tsx +2 -1
- package/src/commands/title6.tsx +2 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"name",
|
|
6
6
|
"keyCommand",
|
|
7
7
|
"shortcuts",
|
|
8
|
+
"value",
|
|
8
9
|
"buttonProps",
|
|
9
10
|
"title",
|
|
10
11
|
"icon",
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"../../src/commands/title5.tsx"
|
|
26
27
|
],
|
|
27
28
|
"sourcesContent": [
|
|
28
|
-
"import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title5: ICommand = {\n name: 'title5',\n keyCommand: 'title5',\n shortcuts: 'ctrlcmd+5',\n buttonProps: { 'aria-label': 'Insert title5', title: 'Insert
|
|
29
|
+
"import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title5: ICommand = {\n name: 'title5',\n keyCommand: 'title5',\n shortcuts: 'ctrlcmd+5',\n value: 'title5',\n buttonProps: { 'aria-label': 'Insert title5 (ctrl + 5)', title: 'Insert title5 (ctrl + 5)' },\n icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 5</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('##### ');\n } else {\n insertAtLineStart('##### ', state.selection.start, api.textArea);\n }\n },\n};\n"
|
|
29
30
|
],
|
|
30
|
-
"mappings": ";;;;;;;;;AAAA;;AACA;;;;AAGO,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QADwB;EAE9BC,UAAU,EAAE,QAFkB;EAG9BC,SAAS,EAAE,WAHmB;EAI9BC,WAAW,EAAE;IAAE,cAAc,
|
|
31
|
+
"mappings": ";;;;;;;;;AAAA;;AACA;;;;AAGO,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QADwB;EAE9BC,UAAU,EAAE,QAFkB;EAG9BC,SAAS,EAAE,WAHmB;EAI9BC,KAAK,EAAE,QAJuB;EAK9BC,WAAW,EAAE;IAAE,cAAc,0BAAhB;IAA4CC,KAAK,EAAE;EAAnD,CALiB;EAM9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EANwB;EAO9BC,OAAO,EAAE,iBAACC,KAAD,EAAmBC,GAAnB,EAA4C;IACnD,IAAID,KAAK,CAACE,SAAN,CAAgBC,KAAhB,KAA0B,CAA1B,IAA+B,MAAMC,IAAN,CAAWJ,KAAK,CAACK,IAAjB,CAAnC,EAA2D;MACzDJ,GAAG,CAACK,gBAAJ,CAAqB,QAArB;IACD,CAFD,MAEO;MACL,IAAAC,uCAAA,EAAkB,QAAlB,EAA4BP,KAAK,CAACE,SAAN,CAAgBC,KAA5C,EAAmDF,GAAG,CAACO,QAAvD;IACD;EACF;AAb6B,CAAzB"
|
|
31
32
|
}
|
package/lib/commands/title6.js
CHANGED
|
@@ -17,9 +17,10 @@ var title6 = {
|
|
|
17
17
|
name: 'title6',
|
|
18
18
|
keyCommand: 'title6',
|
|
19
19
|
shortcuts: 'ctrlcmd+6',
|
|
20
|
+
value: 'title6',
|
|
20
21
|
buttonProps: {
|
|
21
|
-
'aria-label': 'Insert title6',
|
|
22
|
-
title: 'Insert
|
|
22
|
+
'aria-label': 'Insert title6 (ctrl + 6)',
|
|
23
|
+
title: 'Insert title6 (ctrl + 6)'
|
|
23
24
|
},
|
|
24
25
|
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
25
26
|
style: {
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"name",
|
|
6
6
|
"keyCommand",
|
|
7
7
|
"shortcuts",
|
|
8
|
+
"value",
|
|
8
9
|
"buttonProps",
|
|
9
10
|
"title",
|
|
10
11
|
"icon",
|
|
@@ -25,7 +26,7 @@
|
|
|
25
26
|
"../../src/commands/title6.tsx"
|
|
26
27
|
],
|
|
27
28
|
"sourcesContent": [
|
|
28
|
-
"import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title6: ICommand = {\n name: 'title6',\n keyCommand: 'title6',\n shortcuts: 'ctrlcmd+6',\n buttonProps: { 'aria-label': 'Insert title6', title: 'Insert
|
|
29
|
+
"import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title6: ICommand = {\n name: 'title6',\n keyCommand: 'title6',\n shortcuts: 'ctrlcmd+6',\n value: 'title6',\n buttonProps: { 'aria-label': 'Insert title6 (ctrl + 6)', title: 'Insert title6 (ctrl + 6)' },\n icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 6</div>,\n execute: (state: TextState, api: TextAreaTextApi) => {\n if (state.selection.start === 0 || /\\n$/.test(state.text)) {\n api.replaceSelection('###### ');\n } else {\n insertAtLineStart('###### ', state.selection.start, api.textArea);\n }\n },\n};\n"
|
|
29
30
|
],
|
|
30
|
-
"mappings": ";;;;;;;;;AAAA;;AACA;;;;AAGO,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QADwB;EAE9BC,UAAU,EAAE,QAFkB;EAG9BC,SAAS,EAAE,WAHmB;EAI9BC,WAAW,EAAE;IAAE,cAAc,
|
|
31
|
+
"mappings": ";;;;;;;;;AAAA;;AACA;;;;AAGO,IAAMA,MAAgB,GAAG;EAC9BC,IAAI,EAAE,QADwB;EAE9BC,UAAU,EAAE,QAFkB;EAG9BC,SAAS,EAAE,WAHmB;EAI9BC,KAAK,EAAE,QAJuB;EAK9BC,WAAW,EAAE;IAAE,cAAc,0BAAhB;IAA4CC,KAAK,EAAE;EAAnD,CALiB;EAM9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EANwB;EAO9BC,OAAO,EAAE,iBAACC,KAAD,EAAmBC,GAAnB,EAA4C;IACnD,IAAID,KAAK,CAACE,SAAN,CAAgBC,KAAhB,KAA0B,CAA1B,IAA+B,MAAMC,IAAN,CAAWJ,KAAK,CAACK,IAAjB,CAAnC,EAA2D;MACzDJ,GAAG,CAACK,gBAAJ,CAAqB,SAArB;IACD,CAFD,MAEO;MACL,IAAAC,uCAAA,EAAkB,SAAlB,EAA6BP,KAAK,CAACE,SAAN,CAAgBC,KAA7C,EAAoDF,GAAG,CAACO,QAAxD;IACD;EACF;AAb6B,CAAzB"
|
|
31
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uiw/react-md-editor",
|
|
3
|
-
"version": "3.18.
|
|
3
|
+
"version": "3.18.2",
|
|
4
4
|
"description": "A markdown editor with preview, implemented with React.js and TypeScript.",
|
|
5
5
|
"homepage": "https://uiwjs.github.io/react-md-editor/",
|
|
6
6
|
"author": "kenny wang <wowohoo@qq.com>",
|
|
@@ -21,7 +21,7 @@ it('MDEditor commands bold', async () => {
|
|
|
21
21
|
);
|
|
22
22
|
};
|
|
23
23
|
render(<MyComponent />);
|
|
24
|
-
const btn = screen.getByTitle('Add bold text');
|
|
24
|
+
const btn = screen.getByTitle('Add bold text (ctrl + b)');
|
|
25
25
|
btn.focus();
|
|
26
26
|
fireEvent(
|
|
27
27
|
btn,
|
|
@@ -48,7 +48,7 @@ it('MDEditor commands italic', async () => {
|
|
|
48
48
|
);
|
|
49
49
|
};
|
|
50
50
|
render(<MyComponent />);
|
|
51
|
-
const btn = screen.getByTitle('Add italic text');
|
|
51
|
+
const btn = screen.getByTitle('Add italic text (ctrl + i)');
|
|
52
52
|
btn.focus();
|
|
53
53
|
fireEvent(
|
|
54
54
|
btn,
|
|
@@ -66,7 +66,7 @@ it('MDEditor commands code', async () => {
|
|
|
66
66
|
render(<MDEditor value={`He llo \nWold!`} textareaProps={{ title: 'test' }} onChange={handleChange} />);
|
|
67
67
|
const input = screen.getByTitle<HTMLInputElement>('test');
|
|
68
68
|
input.setSelectionRange(0, 5);
|
|
69
|
-
const btn = screen.getByLabelText('Insert code');
|
|
69
|
+
const btn = screen.getByLabelText('Insert code (ctrl + j)');
|
|
70
70
|
fireEvent(
|
|
71
71
|
btn,
|
|
72
72
|
new MouseEvent('click', {
|
|
@@ -82,7 +82,7 @@ it('MDEditor commands selectOptions code', async () => {
|
|
|
82
82
|
render(<MDEditor value={`Hello\nWold!`} textareaProps={{ title: 'test' }} onChange={handleChange} />);
|
|
83
83
|
const input = screen.getByTitle<HTMLInputElement>('test');
|
|
84
84
|
input.setSelectionRange(0, 11);
|
|
85
|
-
const btn = screen.getByLabelText('Insert code');
|
|
85
|
+
const btn = screen.getByLabelText('Insert code (ctrl + j)');
|
|
86
86
|
fireEvent(
|
|
87
87
|
btn,
|
|
88
88
|
new MouseEvent('click', {
|
|
@@ -115,7 +115,7 @@ it('MDEditor commands quote', async () => {
|
|
|
115
115
|
);
|
|
116
116
|
};
|
|
117
117
|
render(<MyComponent />);
|
|
118
|
-
const btn = screen.getByLabelText('Insert a quote');
|
|
118
|
+
const btn = screen.getByLabelText('Insert a quote (ctrl + q)');
|
|
119
119
|
btn.focus();
|
|
120
120
|
fireEvent(
|
|
121
121
|
btn,
|
|
@@ -142,7 +142,7 @@ it('MDEditor commands HR', async () => {
|
|
|
142
142
|
);
|
|
143
143
|
};
|
|
144
144
|
render(<MyComponent />);
|
|
145
|
-
const btn = screen.getByLabelText('Insert HR');
|
|
145
|
+
const btn = screen.getByLabelText('Insert HR (ctrl + h)');
|
|
146
146
|
btn.focus();
|
|
147
147
|
fireEvent(
|
|
148
148
|
btn,
|
|
@@ -169,7 +169,7 @@ it('MDEditor commands strikethrough text', async () => {
|
|
|
169
169
|
);
|
|
170
170
|
};
|
|
171
171
|
render(<MyComponent />);
|
|
172
|
-
const btn = screen.getByLabelText('Add strikethrough text');
|
|
172
|
+
const btn = screen.getByLabelText('Add strikethrough text (ctrl + shift + x)');
|
|
173
173
|
btn.focus();
|
|
174
174
|
fireEvent(
|
|
175
175
|
btn,
|
|
@@ -196,7 +196,7 @@ it('MDEditor commands link', async () => {
|
|
|
196
196
|
);
|
|
197
197
|
};
|
|
198
198
|
render(<MyComponent />);
|
|
199
|
-
const btn = screen.getByLabelText('Add a link');
|
|
199
|
+
const btn = screen.getByLabelText('Add a link (ctrl + l)');
|
|
200
200
|
btn.focus();
|
|
201
201
|
fireEvent(
|
|
202
202
|
btn,
|
|
@@ -223,7 +223,7 @@ it('MDEditor commands image', async () => {
|
|
|
223
223
|
);
|
|
224
224
|
};
|
|
225
225
|
render(<MyComponent />);
|
|
226
|
-
const btn = screen.getByLabelText('Add image');
|
|
226
|
+
const btn = screen.getByLabelText('Add image (ctrl + k)');
|
|
227
227
|
btn.focus();
|
|
228
228
|
fireEvent(
|
|
229
229
|
btn,
|
|
@@ -250,7 +250,7 @@ it("MDEditor commands image === ''", async () => {
|
|
|
250
250
|
);
|
|
251
251
|
};
|
|
252
252
|
render(<MyComponent />);
|
|
253
|
-
const btn = screen.getByLabelText('Add image');
|
|
253
|
+
const btn = screen.getByLabelText('Add image (ctrl + k)');
|
|
254
254
|
btn.focus();
|
|
255
255
|
fireEvent(
|
|
256
256
|
btn,
|
|
@@ -277,7 +277,7 @@ it('MDEditor commands Add unordered list', async () => {
|
|
|
277
277
|
);
|
|
278
278
|
};
|
|
279
279
|
render(<MyComponent />);
|
|
280
|
-
const btn = screen.getByLabelText('Add unordered list');
|
|
280
|
+
const btn = screen.getByLabelText('Add unordered list (ctrl + shift + u)');
|
|
281
281
|
btn.focus();
|
|
282
282
|
fireEvent(
|
|
283
283
|
btn,
|
|
@@ -293,7 +293,7 @@ it('MDEditor commands Add unordered list', async () => {
|
|
|
293
293
|
it('MDEditor commands Add ordered list', async () => {
|
|
294
294
|
const handleChange = jest.fn((value) => value);
|
|
295
295
|
render(<MDEditor value="title" textareaProps={{ title: 'test' }} onChange={handleChange} />);
|
|
296
|
-
const btn = screen.getByLabelText('Add ordered list');
|
|
296
|
+
const btn = screen.getByLabelText('Add ordered list (ctrl + shift + o)');
|
|
297
297
|
fireEvent(
|
|
298
298
|
btn,
|
|
299
299
|
new MouseEvent('click', {
|
|
@@ -318,7 +318,7 @@ it('MDEditor commands Add checked list', async () => {
|
|
|
318
318
|
);
|
|
319
319
|
};
|
|
320
320
|
render(<MyComponent />);
|
|
321
|
-
const btn = screen.getByLabelText('Add checked list');
|
|
321
|
+
const btn = screen.getByLabelText('Add checked list (ctrl + shift + c)');
|
|
322
322
|
|
|
323
323
|
btn.focus();
|
|
324
324
|
fireEvent(
|
|
@@ -335,7 +335,7 @@ it('MDEditor commands Add checked list', async () => {
|
|
|
335
335
|
it('MDEditor commands fullscreen', async () => {
|
|
336
336
|
const handleChange = jest.fn((value) => value);
|
|
337
337
|
await render(<MDEditor value="title" textareaProps={{ title: 'test' }} onChange={handleChange} />);
|
|
338
|
-
const btn = screen.getByLabelText('fullscreen');
|
|
338
|
+
const btn = screen.getByLabelText('Toggle fullscreen (ctrl + 0)');
|
|
339
339
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
340
340
|
expect(document.body.style).toMatchObject({
|
|
341
341
|
overflow: 'hidden',
|
|
@@ -365,7 +365,7 @@ it('MDEditor commands comment `ctrlcmd+/`', async () => {
|
|
|
365
365
|
it('MDEditor commands title1 value === undefined', async () => {
|
|
366
366
|
const handleChange = jest.fn((value) => value);
|
|
367
367
|
render(<MDEditor onChange={handleChange} commands={[commands.title1]} />);
|
|
368
|
-
const btn = screen.getByLabelText('Insert
|
|
368
|
+
const btn = screen.getByLabelText('Insert title1 (ctrl + 1)');
|
|
369
369
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
370
370
|
expect(handleChange).toHaveReturnedWith('# ');
|
|
371
371
|
});
|
|
@@ -380,7 +380,7 @@ it('MDEditor commands title1 value === test', async () => {
|
|
|
380
380
|
commands={[commands.title1]}
|
|
381
381
|
/>,
|
|
382
382
|
);
|
|
383
|
-
const btn = screen.getByLabelText('Insert
|
|
383
|
+
const btn = screen.getByLabelText('Insert title1 (ctrl + 1)');
|
|
384
384
|
const input = screen.getByTitle<HTMLTextAreaElement>('textarea');
|
|
385
385
|
input.setSelectionRange(2, 2);
|
|
386
386
|
|
|
@@ -393,7 +393,7 @@ it('MDEditor commands title2 value === undefined', async () => {
|
|
|
393
393
|
render(<MDEditor onChange={handleChange} textareaProps={{ title: 'test' }} commands={[commands.title2]} />);
|
|
394
394
|
const input = screen.getByTitle<HTMLInputElement>('test');
|
|
395
395
|
input.setSelectionRange(0, 0);
|
|
396
|
-
const btn = screen.getByLabelText('Insert title2');
|
|
396
|
+
const btn = screen.getByLabelText('Insert title2 (ctrl + 2)');
|
|
397
397
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
398
398
|
input.setSelectionRange(0, 0);
|
|
399
399
|
expect(handleChange).toHaveReturnedWith('## ');
|
|
@@ -406,7 +406,7 @@ it('MDEditor commands title2 value === test', async () => {
|
|
|
406
406
|
);
|
|
407
407
|
const input = screen.getByTitle<HTMLInputElement>('test');
|
|
408
408
|
input.setSelectionRange(2, 2);
|
|
409
|
-
const btn = screen.getByLabelText('Insert title2');
|
|
409
|
+
const btn = screen.getByLabelText('Insert title2 (ctrl + 2)');
|
|
410
410
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
411
411
|
expect(handleChange).toHaveReturnedWith('## test');
|
|
412
412
|
});
|
|
@@ -414,7 +414,7 @@ it('MDEditor commands title2 value === test', async () => {
|
|
|
414
414
|
it('MDEditor commands title3 value === undefined', async () => {
|
|
415
415
|
const handleChange = jest.fn((value) => value);
|
|
416
416
|
render(<MDEditor onChange={handleChange} commands={[commands.title3]} />);
|
|
417
|
-
const btn = screen.getByLabelText('Insert title3');
|
|
417
|
+
const btn = screen.getByLabelText('Insert title3 (ctrl + 3)');
|
|
418
418
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
419
419
|
expect(handleChange).toHaveReturnedWith('### ');
|
|
420
420
|
});
|
|
@@ -429,7 +429,7 @@ it('MDEditor commands title3 value === test', async () => {
|
|
|
429
429
|
commands={[commands.title3]}
|
|
430
430
|
/>,
|
|
431
431
|
);
|
|
432
|
-
const btn = screen.getByLabelText('Insert title3');
|
|
432
|
+
const btn = screen.getByLabelText('Insert title3 (ctrl + 3)');
|
|
433
433
|
const input = screen.getByTitle<HTMLInputElement>('textarea');
|
|
434
434
|
input.setSelectionRange(2, 2);
|
|
435
435
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
@@ -439,7 +439,7 @@ it('MDEditor commands title3 value === test', async () => {
|
|
|
439
439
|
it('MDEditor commands title4 value === undefined', async () => {
|
|
440
440
|
const handleChange = jest.fn((value) => value);
|
|
441
441
|
render(<MDEditor onChange={handleChange} commands={[commands.title4]} />);
|
|
442
|
-
const btn = screen.getByLabelText('Insert title4');
|
|
442
|
+
const btn = screen.getByLabelText('Insert title4 (ctrl + 4)');
|
|
443
443
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
444
444
|
expect(handleChange).toHaveReturnedWith('#### ');
|
|
445
445
|
});
|
|
@@ -454,7 +454,7 @@ it('MDEditor commands title4 value === test', async () => {
|
|
|
454
454
|
commands={[commands.title4]}
|
|
455
455
|
/>,
|
|
456
456
|
);
|
|
457
|
-
const btn = screen.getByLabelText('Insert title4');
|
|
457
|
+
const btn = screen.getByLabelText('Insert title4 (ctrl + 4)');
|
|
458
458
|
const input = screen.getByTitle('textarea');
|
|
459
459
|
(input as any).setSelectionRange(2, 2);
|
|
460
460
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
@@ -464,7 +464,7 @@ it('MDEditor commands title4 value === test', async () => {
|
|
|
464
464
|
it('MDEditor commands title5 value === undefined', async () => {
|
|
465
465
|
const handleChange = jest.fn((value) => value);
|
|
466
466
|
render(<MDEditor onChange={handleChange} commands={[commands.title5]} />);
|
|
467
|
-
const btn = screen.getByLabelText('Insert title5');
|
|
467
|
+
const btn = screen.getByLabelText('Insert title5 (ctrl + 5)');
|
|
468
468
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
469
469
|
expect(handleChange).toHaveReturnedWith('##### ');
|
|
470
470
|
});
|
|
@@ -479,7 +479,7 @@ it('MDEditor commands title5 value === test', async () => {
|
|
|
479
479
|
commands={[commands.title5]}
|
|
480
480
|
/>,
|
|
481
481
|
);
|
|
482
|
-
const btn = screen.getByLabelText('Insert title5');
|
|
482
|
+
const btn = screen.getByLabelText('Insert title5 (ctrl + 5)');
|
|
483
483
|
const input = screen.getByTitle<HTMLInputElement>('textarea');
|
|
484
484
|
input.setSelectionRange(2, 2);
|
|
485
485
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
@@ -489,7 +489,7 @@ it('MDEditor commands title5 value === test', async () => {
|
|
|
489
489
|
it('MDEditor commands title6 value === undefined', async () => {
|
|
490
490
|
const handleChange = jest.fn((value) => value);
|
|
491
491
|
render(<MDEditor onChange={handleChange} commands={[commands.title6]} />);
|
|
492
|
-
const btn = screen.getByLabelText('Insert title6');
|
|
492
|
+
const btn = screen.getByLabelText('Insert title6 (ctrl + 6)');
|
|
493
493
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
|
494
494
|
expect(handleChange).toHaveReturnedWith('###### ');
|
|
495
495
|
});
|
|
@@ -504,7 +504,7 @@ it('MDEditor commands title6 value === test', async () => {
|
|
|
504
504
|
commands={[commands.title6]}
|
|
505
505
|
/>,
|
|
506
506
|
);
|
|
507
|
-
const btn = screen.getByLabelText('Insert title6');
|
|
507
|
+
const btn = screen.getByLabelText('Insert title6 (ctrl + 6)');
|
|
508
508
|
const input = screen.getByTitle('textarea');
|
|
509
509
|
(input as any).setSelectionRange(2, 2);
|
|
510
510
|
fireEvent(btn, new MouseEvent('click', { bubbles: true, cancelable: true }));
|
package/src/commands/bold.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const bold: ICommand = {
|
|
|
6
6
|
name: 'bold',
|
|
7
7
|
keyCommand: 'bold',
|
|
8
8
|
shortcuts: 'ctrlcmd+b',
|
|
9
|
-
|
|
9
|
+
value: '**',
|
|
10
|
+
buttonProps: { 'aria-label': 'Add bold text (ctrl + b)', title: 'Add bold text (ctrl + b)' },
|
|
10
11
|
icon: (
|
|
11
12
|
<svg role="img" width="12" height="12" viewBox="0 0 384 512">
|
|
12
13
|
<path
|
package/src/commands/code.tsx
CHANGED
|
@@ -10,7 +10,8 @@ export const code: ICommand = {
|
|
|
10
10
|
name: 'code',
|
|
11
11
|
keyCommand: 'code',
|
|
12
12
|
shortcuts: 'ctrlcmd+j',
|
|
13
|
-
|
|
13
|
+
value: '``',
|
|
14
|
+
buttonProps: { 'aria-label': 'Insert code (ctrl + j)', title: 'Insert code (ctrl + j)' },
|
|
14
15
|
icon: (
|
|
15
16
|
<svg width="12" height="12" role="img" viewBox="0 0 640 512">
|
|
16
17
|
<path
|
|
@@ -60,6 +61,7 @@ export const codeBlock: ICommand = {
|
|
|
60
61
|
name: 'codeBlock',
|
|
61
62
|
keyCommand: 'codeBlock',
|
|
62
63
|
shortcuts: 'ctrlcmd+shift+j',
|
|
64
|
+
value: '```\n```',
|
|
63
65
|
icon: (
|
|
64
66
|
<svg width="12" height="12" role="img" viewBox="0 0 156 156">
|
|
65
67
|
<path
|
|
@@ -68,7 +70,7 @@ export const codeBlock: ICommand = {
|
|
|
68
70
|
/>
|
|
69
71
|
</svg>
|
|
70
72
|
),
|
|
71
|
-
buttonProps: { 'aria-label': 'Insert Code Block', title: 'Insert Code Block' },
|
|
73
|
+
buttonProps: { 'aria-label': 'Insert Code Block (ctrl + shift + j)', title: 'Insert Code Block (ctrl + shift +j)' },
|
|
72
74
|
execute: (tate: TextState, api: TextAreaTextApi) => {
|
|
73
75
|
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
74
76
|
const newSelectionRange = selectWord({ text: tate.text, selection: tate.selection });
|
package/src/commands/comment.tsx
CHANGED
|
@@ -5,6 +5,8 @@ export const comment: ICommand = {
|
|
|
5
5
|
name: 'comment',
|
|
6
6
|
keyCommand: 'comment',
|
|
7
7
|
shortcuts: 'ctrlcmd+/',
|
|
8
|
+
value: '<!-- -->',
|
|
9
|
+
buttonProps: { 'aria-label': 'Insert comment (ctrl + /)', title: 'Insert comment (ctrl + /)' },
|
|
8
10
|
execute: (state: TextState, api: TextAreaTextApi) => {
|
|
9
11
|
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
10
12
|
const newSelectionRange = selectWord({ text: state.text, selection: state.selection });
|
|
@@ -5,8 +5,9 @@ import { ContextStore, ExecuteCommandState } from '../Context';
|
|
|
5
5
|
export const fullscreen: ICommand = {
|
|
6
6
|
name: 'fullscreen',
|
|
7
7
|
keyCommand: 'fullscreen',
|
|
8
|
-
shortcuts: '
|
|
9
|
-
|
|
8
|
+
shortcuts: 'ctrlcmd+0',
|
|
9
|
+
value: 'fullscreen',
|
|
10
|
+
buttonProps: { 'aria-label': 'Toggle fullscreen (ctrl + 0)', title: 'Toggle fullscreen (ctrl+ 0)' },
|
|
10
11
|
icon: (
|
|
11
12
|
<svg width="12" height="12" viewBox="0 0 520 520">
|
|
12
13
|
<path
|
package/src/commands/hr.tsx
CHANGED
|
@@ -5,7 +5,8 @@ export const hr: ICommand = {
|
|
|
5
5
|
name: 'hr',
|
|
6
6
|
keyCommand: 'hr',
|
|
7
7
|
shortcuts: 'ctrlcmd+h',
|
|
8
|
-
|
|
8
|
+
value: '----------',
|
|
9
|
+
buttonProps: { 'aria-label': 'Insert HR (ctrl + h)', title: 'Insert HR (ctrl + h)' },
|
|
9
10
|
icon: (
|
|
10
11
|
<svg width="12" height="12" viewBox="0 0 175 175">
|
|
11
12
|
<path
|
package/src/commands/image.tsx
CHANGED
|
@@ -5,8 +5,9 @@ import { selectWord } from '../utils/markdownUtils';
|
|
|
5
5
|
export const image: ICommand = {
|
|
6
6
|
name: 'image',
|
|
7
7
|
keyCommand: 'image',
|
|
8
|
-
shortcuts: 'ctrlcmd+
|
|
9
|
-
|
|
8
|
+
shortcuts: 'ctrlcmd+k',
|
|
9
|
+
value: '![image]()',
|
|
10
|
+
buttonProps: { 'aria-label': 'Add image (ctrl + k)', title: 'Add image (ctrl + k)' },
|
|
10
11
|
icon: (
|
|
11
12
|
<svg width="12" height="12" viewBox="0 0 20 20">
|
|
12
13
|
<path
|
package/src/commands/italic.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const italic: ICommand = {
|
|
|
6
6
|
name: 'italic',
|
|
7
7
|
keyCommand: 'italic',
|
|
8
8
|
shortcuts: 'ctrlcmd+i',
|
|
9
|
-
|
|
9
|
+
value: '* *',
|
|
10
|
+
buttonProps: { 'aria-label': 'Add italic text (ctrl + i)', title: 'Add italic text (ctrl + i)' },
|
|
10
11
|
icon: (
|
|
11
12
|
<svg data-name="italic" width="12" height="12" role="img" viewBox="0 0 320 512">
|
|
12
13
|
<path
|
package/src/commands/link.tsx
CHANGED
|
@@ -5,8 +5,9 @@ import { selectWord } from '../utils/markdownUtils';
|
|
|
5
5
|
export const link: ICommand = {
|
|
6
6
|
name: 'link',
|
|
7
7
|
keyCommand: 'link',
|
|
8
|
-
shortcuts: 'ctrlcmd+
|
|
9
|
-
|
|
8
|
+
shortcuts: 'ctrlcmd+l',
|
|
9
|
+
value: '[](url)',
|
|
10
|
+
buttonProps: { 'aria-label': 'Add a link (ctrl + l)', title: 'Add a link (ctrl + l)' },
|
|
10
11
|
icon: (
|
|
11
12
|
<svg data-name="italic" width="12" height="12" role="img" viewBox="0 0 520 520">
|
|
12
13
|
<path
|
package/src/commands/list.tsx
CHANGED
|
@@ -66,8 +66,12 @@ export const makeList = (state: TextState, api: TextAreaTextApi, insertBefore: s
|
|
|
66
66
|
export const unorderedListCommand: ICommand = {
|
|
67
67
|
name: 'unordered-list',
|
|
68
68
|
keyCommand: 'list',
|
|
69
|
-
shortcuts: 'ctrl+shift+
|
|
70
|
-
|
|
69
|
+
shortcuts: 'ctrl+shift+u',
|
|
70
|
+
value: '- ',
|
|
71
|
+
buttonProps: {
|
|
72
|
+
'aria-label': 'Add unordered list (ctrl + shift + u)',
|
|
73
|
+
title: 'Add unordered list (ctrl + shift + u)',
|
|
74
|
+
},
|
|
71
75
|
icon: (
|
|
72
76
|
<svg data-name="unordered-list" width="12" height="12" viewBox="0 0 512 512">
|
|
73
77
|
<path
|
|
@@ -85,7 +89,8 @@ export const orderedListCommand: ICommand = {
|
|
|
85
89
|
name: 'ordered-list',
|
|
86
90
|
keyCommand: 'list',
|
|
87
91
|
shortcuts: 'ctrl+shift+o',
|
|
88
|
-
|
|
92
|
+
value: '1. ',
|
|
93
|
+
buttonProps: { 'aria-label': 'Add ordered list (ctrl + shift + o)', title: 'Add ordered list (ctrl + shift + o)' },
|
|
89
94
|
icon: (
|
|
90
95
|
<svg data-name="ordered-list" width="12" height="12" role="img" viewBox="0 0 512 512">
|
|
91
96
|
<path
|
|
@@ -103,7 +108,8 @@ export const checkedListCommand: ICommand = {
|
|
|
103
108
|
name: 'checked-list',
|
|
104
109
|
keyCommand: 'list',
|
|
105
110
|
shortcuts: 'ctrl+shift+c',
|
|
106
|
-
|
|
111
|
+
value: '- [x] ',
|
|
112
|
+
buttonProps: { 'aria-label': 'Add checked list (ctrl + shift + c)', title: 'Add checked list (ctrl + shift + c)' },
|
|
107
113
|
icon: (
|
|
108
114
|
<svg data-name="checked-list" width="12" height="12" role="img" viewBox="0 0 512 512">
|
|
109
115
|
<path
|
package/src/commands/preview.tsx
CHANGED
|
@@ -5,7 +5,8 @@ export const codePreview: ICommand = {
|
|
|
5
5
|
name: 'preview',
|
|
6
6
|
keyCommand: 'preview',
|
|
7
7
|
value: 'preview',
|
|
8
|
-
|
|
8
|
+
shortcuts: 'ctrlcmd+9',
|
|
9
|
+
buttonProps: { 'aria-label': 'Preview code (ctrl + 9)', title: 'Preview code (ctrl + 9)' },
|
|
9
10
|
icon: (
|
|
10
11
|
<svg width="12" height="12" viewBox="0 0 520 520">
|
|
11
12
|
<polygon
|
|
@@ -25,7 +26,8 @@ export const codeEdit: ICommand = {
|
|
|
25
26
|
name: 'edit',
|
|
26
27
|
keyCommand: 'preview',
|
|
27
28
|
value: 'edit',
|
|
28
|
-
|
|
29
|
+
shortcuts: 'ctrlcmd+7',
|
|
30
|
+
buttonProps: { 'aria-label': 'Edit code (ctrl + 7)', title: 'Edit code (ctrl + 7)' },
|
|
29
31
|
icon: (
|
|
30
32
|
<svg width="12" height="12" viewBox="0 0 520 520">
|
|
31
33
|
<polygon fill="currentColor" points="0 71.293 0 122 319 122 319 397 0 397 0 449.707 372 449.413 372 71.293" />
|
|
@@ -42,7 +44,8 @@ export const codeLive: ICommand = {
|
|
|
42
44
|
name: 'live',
|
|
43
45
|
keyCommand: 'preview',
|
|
44
46
|
value: 'live',
|
|
45
|
-
|
|
47
|
+
shortcuts: 'ctrlcmd+8',
|
|
48
|
+
buttonProps: { 'aria-label': 'Live code (ctrl + 8)', title: 'Live code (ctrl + 8)' },
|
|
46
49
|
icon: (
|
|
47
50
|
<svg width="12" height="12" viewBox="0 0 520 520">
|
|
48
51
|
<polygon fill="currentColor" points="0 71.293 0 122 179 122 179 397 0 397 0 449.707 232 449.413 232 71.293" />
|
package/src/commands/quote.tsx
CHANGED
|
@@ -10,7 +10,7 @@ export const quote: ICommand = {
|
|
|
10
10
|
name: 'quote',
|
|
11
11
|
keyCommand: 'quote',
|
|
12
12
|
shortcuts: 'ctrlcmd+q',
|
|
13
|
-
buttonProps: { 'aria-label': 'Insert a quote', title: 'Insert a quote' },
|
|
13
|
+
buttonProps: { 'aria-label': 'Insert a quote (ctrl + q)', title: 'Insert a quote (ctrl + q)' },
|
|
14
14
|
icon: (
|
|
15
15
|
<svg width="12" height="12" viewBox="0 0 520 520">
|
|
16
16
|
<path
|
|
@@ -6,7 +6,11 @@ export const strikethrough: ICommand = {
|
|
|
6
6
|
name: 'strikethrough',
|
|
7
7
|
keyCommand: 'strikethrough',
|
|
8
8
|
shortcuts: 'ctrl+shift+x',
|
|
9
|
-
buttonProps: {
|
|
9
|
+
buttonProps: {
|
|
10
|
+
'aria-label': 'Add strikethrough text (ctrl + shift + x)',
|
|
11
|
+
title: 'Add strikethrough text (ctrl + shift + x)',
|
|
12
|
+
},
|
|
13
|
+
value: '~~',
|
|
10
14
|
icon: (
|
|
11
15
|
<svg data-name="strikethrough" width="12" height="12" role="img" viewBox="0 0 512 512">
|
|
12
16
|
<path
|
package/src/commands/title.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ICommand } from './';
|
|
3
|
-
import {
|
|
3
|
+
import { title1 } from './title1';
|
|
4
4
|
|
|
5
5
|
export const title: ICommand = {
|
|
6
|
-
...
|
|
6
|
+
...title1,
|
|
7
7
|
icon: (
|
|
8
8
|
<svg width="12" height="12" viewBox="0 0 520 520">
|
|
9
9
|
<path
|
package/src/commands/title1.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const title1: ICommand = {
|
|
|
6
6
|
name: 'title1',
|
|
7
7
|
keyCommand: 'title1',
|
|
8
8
|
shortcuts: 'ctrlcmd+1',
|
|
9
|
-
|
|
9
|
+
value: 'title1',
|
|
10
|
+
buttonProps: { 'aria-label': 'Insert title1 (ctrl + 1)', title: 'Insert title1 (ctrl + 1)' },
|
|
10
11
|
icon: <div style={{ fontSize: 18, textAlign: 'left' }}>Title 1</div>,
|
|
11
12
|
execute: (state: TextState, api: TextAreaTextApi) => {
|
|
12
13
|
if (state.selection.start === 0 || /\n$/.test(state.text)) {
|
package/src/commands/title2.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const title2: ICommand = {
|
|
|
6
6
|
name: 'title2',
|
|
7
7
|
keyCommand: 'title2',
|
|
8
8
|
shortcuts: 'ctrlcmd+2',
|
|
9
|
-
|
|
9
|
+
value: 'title2',
|
|
10
|
+
buttonProps: { 'aria-label': 'Insert title2 (ctrl + 2)', title: 'Insert title2 (ctrl + 2)' },
|
|
10
11
|
icon: <div style={{ fontSize: 16, textAlign: 'left' }}>Title 2</div>,
|
|
11
12
|
execute: (state: TextState, api: TextAreaTextApi) => {
|
|
12
13
|
if (state.selection.start === 0 || /\n$/.test(state.text)) {
|
package/src/commands/title3.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const title3: ICommand = {
|
|
|
6
6
|
name: 'title3',
|
|
7
7
|
keyCommand: 'title3',
|
|
8
8
|
shortcuts: 'ctrlcmd+3',
|
|
9
|
-
|
|
9
|
+
value: 'title3',
|
|
10
|
+
buttonProps: { 'aria-label': 'Insert title3 (ctrl + 3)', title: 'Insert title3 (ctrl + 3)' },
|
|
10
11
|
icon: <div style={{ fontSize: 15, textAlign: 'left' }}>Title 3</div>,
|
|
11
12
|
execute: (state: TextState, api: TextAreaTextApi) => {
|
|
12
13
|
if (state.selection.start === 0 || /\n$/.test(state.text)) {
|
package/src/commands/title4.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const title4: ICommand = {
|
|
|
6
6
|
name: 'title4',
|
|
7
7
|
keyCommand: 'title4',
|
|
8
8
|
shortcuts: 'ctrlcmd+4',
|
|
9
|
-
|
|
9
|
+
value: 'title4',
|
|
10
|
+
buttonProps: { 'aria-label': 'Insert title4 (ctrl + 4)', title: 'Insert title4 (ctrl + 4)' },
|
|
10
11
|
icon: <div style={{ fontSize: 14, textAlign: 'left' }}>Title 4</div>,
|
|
11
12
|
execute: (state: TextState, api: TextAreaTextApi) => {
|
|
12
13
|
if (state.selection.start === 0 || /\n$/.test(state.text)) {
|
package/src/commands/title5.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const title5: ICommand = {
|
|
|
6
6
|
name: 'title5',
|
|
7
7
|
keyCommand: 'title5',
|
|
8
8
|
shortcuts: 'ctrlcmd+5',
|
|
9
|
-
|
|
9
|
+
value: 'title5',
|
|
10
|
+
buttonProps: { 'aria-label': 'Insert title5 (ctrl + 5)', title: 'Insert title5 (ctrl + 5)' },
|
|
10
11
|
icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 5</div>,
|
|
11
12
|
execute: (state: TextState, api: TextAreaTextApi) => {
|
|
12
13
|
if (state.selection.start === 0 || /\n$/.test(state.text)) {
|
package/src/commands/title6.tsx
CHANGED
|
@@ -6,7 +6,8 @@ export const title6: ICommand = {
|
|
|
6
6
|
name: 'title6',
|
|
7
7
|
keyCommand: 'title6',
|
|
8
8
|
shortcuts: 'ctrlcmd+6',
|
|
9
|
-
|
|
9
|
+
value: 'title6',
|
|
10
|
+
buttonProps: { 'aria-label': 'Insert title6 (ctrl + 6)', title: 'Insert title6 (ctrl + 6)' },
|
|
10
11
|
icon: <div style={{ fontSize: 12, textAlign: 'left' }}>Title 6</div>,
|
|
11
12
|
execute: (state: TextState, api: TextAreaTextApi) => {
|
|
12
13
|
if (state.selection.start === 0 || /\n$/.test(state.text)) {
|