@uiw/react-md-editor 3.12.1 → 3.13.0
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.css +26 -16
- package/dist/mdeditor.js +2188 -1638
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/dist/mdeditor.min.js.LICENSE.txt +1 -15
- package/esm/Context.js.map +5 -5
- package/esm/Editor.d.ts +2 -0
- package/esm/Editor.js +10 -3
- package/esm/Editor.js.map +7 -6
- package/esm/commands/bold.js.map +5 -5
- package/esm/commands/code.js +4 -2
- package/esm/commands/code.js.map +7 -6
- package/esm/commands/comment.js.map +5 -5
- package/esm/commands/divider.js.map +5 -5
- package/esm/commands/fullscreen.js.map +5 -5
- package/esm/commands/group.js.map +5 -5
- package/esm/commands/hr.js.map +5 -5
- package/esm/commands/image.js.map +5 -5
- package/esm/commands/index.js.map +5 -5
- package/esm/commands/italic.js.map +5 -5
- package/esm/commands/link.js.map +5 -5
- package/esm/commands/list.js.map +5 -5
- package/esm/commands/preview.js.map +5 -5
- package/esm/commands/quote.js.map +5 -5
- package/esm/commands/strikeThrough.js.map +5 -5
- package/esm/commands/title.js.map +5 -5
- package/esm/commands/title1.js.map +5 -5
- package/esm/commands/title2.js.map +5 -5
- package/esm/commands/title3.js.map +5 -5
- package/esm/commands/title4.js.map +5 -5
- package/esm/commands/title5.js.map +5 -5
- package/esm/commands/title6.js.map +5 -5
- package/esm/components/DragBar/index.js.map +5 -5
- package/esm/components/TextArea/Markdown.js.map +5 -5
- package/esm/components/TextArea/Textarea.js.map +5 -5
- package/esm/components/TextArea/handleKeyDown.js.map +5 -5
- package/esm/components/TextArea/index.css +8 -1
- package/esm/components/TextArea/index.js.map +5 -5
- package/esm/components/TextArea/index.less +8 -1
- package/esm/components/TextArea/shortcuts.js.map +5 -5
- package/esm/components/Toolbar/Child.js.map +5 -5
- package/esm/components/Toolbar/index.css +5 -0
- package/esm/components/Toolbar/index.d.ts +1 -0
- package/esm/components/Toolbar/index.js +3 -1
- package/esm/components/Toolbar/index.js.map +9 -7
- package/esm/components/Toolbar/index.less +5 -0
- package/esm/index.css +3 -0
- package/esm/index.js.map +5 -5
- package/esm/index.less +3 -0
- package/esm/utils/InsertTextAtPosition.js.map +5 -5
- package/esm/utils/markdownUtils.js.map +5 -5
- package/lib/Context.js.map +5 -5
- package/lib/Editor.d.ts +2 -0
- package/lib/Editor.js +11 -3
- package/lib/Editor.js.map +14 -6
- package/lib/commands/bold.js.map +6 -5
- package/lib/commands/code.js +4 -2
- package/lib/commands/code.js.map +10 -6
- package/lib/commands/comment.js.map +6 -5
- package/lib/commands/divider.js.map +5 -5
- package/lib/commands/fullscreen.js.map +5 -5
- package/lib/commands/group.js.map +5 -5
- package/lib/commands/hr.js.map +5 -5
- package/lib/commands/image.js.map +6 -5
- package/lib/commands/index.js.map +6 -5
- package/lib/commands/italic.js.map +6 -5
- package/lib/commands/link.js.map +6 -5
- package/lib/commands/list.js.map +8 -5
- package/lib/commands/preview.js.map +5 -5
- package/lib/commands/quote.js.map +8 -5
- package/lib/commands/strikeThrough.js.map +6 -5
- package/lib/commands/title.js.map +5 -5
- package/lib/commands/title1.js.map +6 -5
- package/lib/commands/title2.js.map +6 -5
- package/lib/commands/title3.js.map +6 -5
- package/lib/commands/title4.js.map +6 -5
- package/lib/commands/title5.js.map +6 -5
- package/lib/commands/title6.js.map +6 -5
- package/lib/components/DragBar/index.js.map +9 -6
- package/lib/components/TextArea/Markdown.js.map +9 -5
- package/lib/components/TextArea/Textarea.js.map +9 -5
- package/lib/components/TextArea/handleKeyDown.js.map +7 -5
- package/lib/components/TextArea/index.js.map +7 -6
- package/lib/components/TextArea/index.less +8 -1
- package/lib/components/TextArea/shortcuts.js.map +5 -5
- package/lib/components/Toolbar/Child.js.map +7 -5
- package/lib/components/Toolbar/index.d.ts +1 -0
- package/lib/components/Toolbar/index.js +3 -1
- package/lib/components/Toolbar/index.js.map +12 -7
- package/lib/components/Toolbar/index.less +5 -0
- package/lib/index.js.map +5 -5
- package/lib/index.less +3 -0
- package/lib/utils/InsertTextAtPosition.js.map +5 -5
- package/lib/utils/markdownUtils.js.map +5 -5
- package/markdown-editor.css +16 -1
- package/package.json +11 -11
- package/src/Editor.tsx +9 -1
- package/src/__test__/editor.test.tsx +1 -1
- package/src/commands/code.tsx +2 -2
- package/src/components/TextArea/index.less +8 -1
- package/src/components/Toolbar/index.less +5 -0
- package/src/components/Toolbar/index.tsx +4 -2
- package/src/index.less +3 -0
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../src/commands/title1.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"title1",
|
|
8
5
|
"name",
|
|
@@ -21,10 +18,14 @@
|
|
|
21
18
|
"test",
|
|
22
19
|
"text",
|
|
23
20
|
"replaceSelection",
|
|
21
|
+
"insertAtLineStart",
|
|
24
22
|
"textArea"
|
|
25
23
|
],
|
|
26
|
-
"
|
|
24
|
+
"sources": [
|
|
25
|
+
"../../src/commands/title1.tsx"
|
|
26
|
+
],
|
|
27
27
|
"sourcesContent": [
|
|
28
28
|
"import React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title1: ICommand = {\n name: 'title1',\n keyCommand: 'title1',\n shortcuts: 'ctrlcmd+1',\n buttonProps: { 'aria-label': 'Insert title 1', title: 'Insert title 1' },\n icon: <div style={{ fontSize: 18, textAlign: 'left' }}>Title 1</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
|
-
]
|
|
29
|
+
],
|
|
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,gBAAhB;IAAkCC,KAAK,EAAE;EAAzC,CAJiB;EAK9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EALwB;EAM9BC,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,IAArB;IACD,CAFD,MAEO;MACL,IAAAC,uCAAA,EAAkB,IAAlB,EAAwBP,KAAK,CAACE,SAAN,CAAgBC,KAAxC,EAA+CF,GAAG,CAACO,QAAnD;IACD;EACF;AAZ6B,CAAzB"
|
|
30
31
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../src/commands/title2.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"title2",
|
|
8
5
|
"name",
|
|
@@ -21,10 +18,14 @@
|
|
|
21
18
|
"test",
|
|
22
19
|
"text",
|
|
23
20
|
"replaceSelection",
|
|
21
|
+
"insertAtLineStart",
|
|
24
22
|
"textArea"
|
|
25
23
|
],
|
|
26
|
-
"
|
|
24
|
+
"sources": [
|
|
25
|
+
"../../src/commands/title2.tsx"
|
|
26
|
+
],
|
|
27
27
|
"sourcesContent": [
|
|
28
28
|
"import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title2: ICommand = {\n name: 'title2',\n keyCommand: 'title2',\n shortcuts: 'ctrlcmd+2',\n buttonProps: { 'aria-label': 'Insert title2', title: 'Insert title 2' },\n icon: <div style={{ fontSize: 16, textAlign: 'left' }}>Title 2</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
|
-
]
|
|
29
|
+
],
|
|
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,eAAhB;IAAiCC,KAAK,EAAE;EAAxC,CAJiB;EAK9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EALwB;EAM9BC,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,KAArB;IACD,CAFD,MAEO;MACL,IAAAC,uCAAA,EAAkB,KAAlB,EAAyBP,KAAK,CAACE,SAAN,CAAgBC,KAAzC,EAAgDF,GAAG,CAACO,QAApD;IACD;EACF;AAZ6B,CAAzB"
|
|
30
31
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../src/commands/title3.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"title3",
|
|
8
5
|
"name",
|
|
@@ -21,10 +18,14 @@
|
|
|
21
18
|
"test",
|
|
22
19
|
"text",
|
|
23
20
|
"replaceSelection",
|
|
21
|
+
"insertAtLineStart",
|
|
24
22
|
"textArea"
|
|
25
23
|
],
|
|
26
|
-
"
|
|
24
|
+
"sources": [
|
|
25
|
+
"../../src/commands/title3.tsx"
|
|
26
|
+
],
|
|
27
27
|
"sourcesContent": [
|
|
28
28
|
"import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title3: ICommand = {\n name: 'title3',\n keyCommand: 'title3',\n shortcuts: 'ctrlcmd+3',\n buttonProps: { 'aria-label': 'Insert title3', title: 'Insert title 3' },\n icon: <div style={{ fontSize: 15, textAlign: 'left' }}>Title 3</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
|
-
]
|
|
29
|
+
],
|
|
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,eAAhB;IAAiCC,KAAK,EAAE;EAAxC,CAJiB;EAK9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EALwB;EAM9BC,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,MAArB;IACD,CAFD,MAEO;MACL,IAAAC,uCAAA,EAAkB,MAAlB,EAA0BP,KAAK,CAACE,SAAN,CAAgBC,KAA1C,EAAiDF,GAAG,CAACO,QAArD;IACD;EACF;AAZ6B,CAAzB"
|
|
30
31
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../src/commands/title4.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"title4",
|
|
8
5
|
"name",
|
|
@@ -21,10 +18,14 @@
|
|
|
21
18
|
"test",
|
|
22
19
|
"text",
|
|
23
20
|
"replaceSelection",
|
|
21
|
+
"insertAtLineStart",
|
|
24
22
|
"textArea"
|
|
25
23
|
],
|
|
26
|
-
"
|
|
24
|
+
"sources": [
|
|
25
|
+
"../../src/commands/title4.tsx"
|
|
26
|
+
],
|
|
27
27
|
"sourcesContent": [
|
|
28
28
|
"import * as React from 'react';\nimport { insertAtLineStart } from '../utils/InsertTextAtPosition';\nimport { ICommand, TextState, TextAreaTextApi } from './';\n\nexport const title4: ICommand = {\n name: 'title4',\n keyCommand: 'title4',\n shortcuts: 'ctrlcmd+4',\n buttonProps: { 'aria-label': 'Insert title4', title: 'Insert title 4' },\n icon: <div style={{ fontSize: 14, textAlign: 'left' }}>Title 4</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
|
-
]
|
|
29
|
+
],
|
|
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,eAAhB;IAAiCC,KAAK,EAAE;EAAxC,CAJiB;EAK9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EALwB;EAM9BC,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,OAArB;IACD,CAFD,MAEO;MACL,IAAAC,uCAAA,EAAkB,OAAlB,EAA2BP,KAAK,CAACE,SAAN,CAAgBC,KAA3C,EAAkDF,GAAG,CAACO,QAAtD;IACD;EACF;AAZ6B,CAAzB"
|
|
30
31
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../src/commands/title5.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"title5",
|
|
8
5
|
"name",
|
|
@@ -21,10 +18,14 @@
|
|
|
21
18
|
"test",
|
|
22
19
|
"text",
|
|
23
20
|
"replaceSelection",
|
|
21
|
+
"insertAtLineStart",
|
|
24
22
|
"textArea"
|
|
25
23
|
],
|
|
26
|
-
"
|
|
24
|
+
"sources": [
|
|
25
|
+
"../../src/commands/title5.tsx"
|
|
26
|
+
],
|
|
27
27
|
"sourcesContent": [
|
|
28
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 title 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
|
-
]
|
|
29
|
+
],
|
|
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,eAAhB;IAAiCC,KAAK,EAAE;EAAxC,CAJiB;EAK9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EALwB;EAM9BC,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;AAZ6B,CAAzB"
|
|
30
31
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../src/commands/title6.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"title6",
|
|
8
5
|
"name",
|
|
@@ -21,10 +18,14 @@
|
|
|
21
18
|
"test",
|
|
22
19
|
"text",
|
|
23
20
|
"replaceSelection",
|
|
21
|
+
"insertAtLineStart",
|
|
24
22
|
"textArea"
|
|
25
23
|
],
|
|
26
|
-
"
|
|
24
|
+
"sources": [
|
|
25
|
+
"../../src/commands/title6.tsx"
|
|
26
|
+
],
|
|
27
27
|
"sourcesContent": [
|
|
28
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 title 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
|
-
]
|
|
29
|
+
],
|
|
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,eAAhB;IAAiCC,KAAK,EAAE;EAAxC,CAJiB;EAK9BC,IAAI,eAAE;IAAK,KAAK,EAAE;MAAEC,QAAQ,EAAE,EAAZ;MAAgBC,SAAS,EAAE;IAA3B,CAAZ;IAAA;EAAA,EALwB;EAM9BC,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;AAZ6B,CAAzB"
|
|
30
31
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../../src/components/DragBar/index.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"DragBar",
|
|
8
5
|
"props",
|
|
9
6
|
"prefixCls",
|
|
10
7
|
"onChange",
|
|
11
8
|
"dragRef",
|
|
9
|
+
"useRef",
|
|
12
10
|
"handleMouseMove",
|
|
13
11
|
"event",
|
|
14
12
|
"current",
|
|
@@ -21,13 +19,18 @@
|
|
|
21
19
|
"handleMouseUp",
|
|
22
20
|
"undefined",
|
|
23
21
|
"handleMouseDown",
|
|
22
|
+
"useEffect",
|
|
24
23
|
"document",
|
|
25
24
|
"addEventListener",
|
|
26
25
|
"removeEventListener",
|
|
27
|
-
"svg"
|
|
26
|
+
"svg",
|
|
27
|
+
"useMemo"
|
|
28
|
+
],
|
|
29
|
+
"sources": [
|
|
30
|
+
"../../../src/components/DragBar/index.tsx"
|
|
28
31
|
],
|
|
29
|
-
"mappings": ";;;;;;;;;AAAA;;;;AAWA,IAAMA,OAAgC,GAAG,SAAnCA,OAAmC,CAACC,KAAD,EAAW;AAClD,aAAgCA,KAAK,IAAI,EAAzC;AAAA,MAAQC,SAAR,QAAQA,SAAR;AAAA,MAAmBC,QAAnB,QAAmBA,QAAnB;;AACA,MAAMC,OAAO,GAAG,oBAAhB;;AACA,WAASC,eAAT,CAAyBC,KAAzB,EAA4C;AAC1C,QAAIF,OAAO,CAACG,OAAZ,EAAqB;AACnB,UAAMC,SAAS,GAAGJ,OAAO,CAACG,OAAR,CAAgBE,MAAhB,GAAyBH,KAAK,CAACI,OAA/B,GAAyCN,OAAO,CAACG,OAAR,CAAgBI,KAA3E;;AACA,UAAIH,SAAS,IAAIP,KAAK,CAACW,SAAnB,IAAgCJ,SAAS,IAAIP,KAAK,CAACY,SAAvD,EAAkE;AAChEV,QAAAA,QAAQ,IAAIA,QAAQ,CAACC,OAAO,CAACG,OAAR,CAAgBE,MAAhB,IAA0BH,KAAK,CAACI,OAAN,GAAgBN,OAAO,CAACG,OAAR,CAAgBI,KAA1D,CAAD,CAApB;AACD;AACF;AACF;;AACD,WAASG,aAAT,GAAyB;AACvBV,IAAAA,OAAO,CAACG,OAAR,GAAkBQ,SAAlB;AACD;;AACD,WAASC,eAAT,CAAyBV,KAAzB,EAA8E;AAC5EF,IAAAA,OAAO,CAACG,OAAR,GAAkB;AAChBE,MAAAA,MAAM,EAAER,KAAK,CAACQ,MADE;AAEhBE,MAAAA,KAAK,EAAEL,KAAK,CAACI;AAFG,KAAlB;AAID;;AAED,wBAAU,YAAM;AACd,QAAIO,QAAJ,EAAc;AACZA,MAAAA,QAAQ,CAACC,gBAAT,CAA0B,WAA1B,EAAuCb,eAAvC;AACAY,MAAAA,QAAQ,CAACC,gBAAT,CAA0B,SAA1B,EAAqCJ,aAArC;AACD;;AACD,WAAO,YAAM;AACX,UAAIG,QAAJ,EAAc;AACZA,QAAAA,QAAQ,CAACE,mBAAT,CAA6B,WAA7B,EAA0Cd,eAA1C;AACAY,QAAAA,QAAQ,CAACE,mBAAT,CAA6B,SAA7B,EAAwCL,aAAxC;AACD;AACF,KALD,CALc,CAWd;AACD,GAZD,EAYG,EAZH;AAaA,MAAMM,GAAG,GAAG,oBACV;AAAA,wBACE;AAAK,MAAA,OAAO,EAAC,aAAb;AAA2B,MAAA,MAAM,EAAC,MAAlC;AAAA,6BACE;AACE,QAAA,IAAI,EAAC,cADP;AAEE,QAAA,CAAC,EAAC;AAFJ;AADF,MADF;AAAA,GADU,EASV,EATU,CAAZ;AAWA,sBACE;AAAK,IAAA,SAAS,YAAKlB,SAAL,SAAd;AAAoC,IAAA,WAAW,EAAEc,eAAjD;AAAA,cACGI;AADH,IADF;AAKD,CAlDD;;eAoDepB,O",
|
|
30
32
|
"sourcesContent": [
|
|
31
33
|
"import React, { useEffect, useMemo, useRef } from 'react';\nimport { IProps } from '../../Editor';\nimport './index.less';\n\nexport interface IDragBarProps extends IProps {\n height: number;\n maxHeight: number;\n minHeight: number;\n onChange: (value: number) => void;\n}\n\nconst DragBar: React.FC<IDragBarProps> = (props) => {\n const { prefixCls, onChange } = props || {};\n const dragRef = useRef<{ height: number; dragY: number }>();\n function handleMouseMove(event: MouseEvent) {\n if (dragRef.current) {\n const newHeight = dragRef.current.height + event.clientY - dragRef.current.dragY;\n if (newHeight >= props.minHeight && newHeight <= props.maxHeight) {\n onChange && onChange(dragRef.current.height + (event.clientY - dragRef.current.dragY));\n }\n }\n }\n function handleMouseUp() {\n dragRef.current = undefined;\n }\n function handleMouseDown(event: React.MouseEvent<HTMLDivElement, MouseEvent>) {\n dragRef.current = {\n height: props.height,\n dragY: event.clientY,\n };\n }\n\n useEffect(() => {\n if (document) {\n document.addEventListener('mousemove', handleMouseMove);\n document.addEventListener('mouseup', handleMouseUp);\n }\n return () => {\n if (document) {\n document.removeEventListener('mousemove', handleMouseMove);\n document.removeEventListener('mouseup', handleMouseUp);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n const svg = useMemo(\n () => (\n <svg viewBox=\"0 0 512 512\" height=\"100%\">\n <path\n fill=\"currentColor\"\n d=\"M304 256c0 26.5-21.5 48-48 48s-48-21.5-48-48 21.5-48 48-48 48 21.5 48 48zm120-48c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48zm-336 0c-26.5 0-48 21.5-48 48s21.5 48 48 48 48-21.5 48-48-21.5-48-48-48z\"\n />\n </svg>\n ),\n [],\n );\n return (\n <div className={`${prefixCls}-bar`} onMouseDown={handleMouseDown}>\n {svg}\n </div>\n );\n};\n\nexport default DragBar;\n"
|
|
32
|
-
]
|
|
34
|
+
],
|
|
35
|
+
"mappings": ";;;;;;;;;AAAA;;;;AAWA,IAAMA,OAAgC,GAAG,SAAnCA,OAAmC,CAACC,KAAD,EAAW;EAClD,WAAgCA,KAAK,IAAI,EAAzC;EAAA,IAAQC,SAAR,QAAQA,SAAR;EAAA,IAAmBC,QAAnB,QAAmBA,QAAnB;;EACA,IAAMC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ACE;QACE,IAAI,EAAC,cADP;QAEE,CAAC,EAAC;MAFJ;IADF,EADF;EAAA,CADU,EASV,EATU,CAAZ;EAWA,oBACE;IAAK,SAAS,YAAKrB,SAAL,SAAd;IAAoC,WAAW,EAAEe,eAAjD;IAAA,UACGK;EADH,EADF;AAKD,CAlDD;;eAoDetB,O"
|
|
33
36
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../../src/components/TextArea/Markdown.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"Markdown",
|
|
8
5
|
"props",
|
|
9
6
|
"prefixCls",
|
|
7
|
+
"useContext",
|
|
10
8
|
"EditorContext",
|
|
11
9
|
"markdown",
|
|
12
10
|
"dispatch",
|
|
13
11
|
"preRef",
|
|
14
12
|
"React",
|
|
15
13
|
"createRef",
|
|
14
|
+
"useEffect",
|
|
16
15
|
"current",
|
|
17
16
|
"textareaPre",
|
|
18
17
|
"html2Escape",
|
|
@@ -20,6 +19,8 @@
|
|
|
20
19
|
"replace",
|
|
21
20
|
"str",
|
|
22
21
|
"c",
|
|
22
|
+
"useMemo",
|
|
23
|
+
"rehype",
|
|
23
24
|
"data",
|
|
24
25
|
"fragment",
|
|
25
26
|
"use",
|
|
@@ -32,8 +33,11 @@
|
|
|
32
33
|
"__html",
|
|
33
34
|
"value"
|
|
34
35
|
],
|
|
35
|
-
"
|
|
36
|
+
"sources": [
|
|
37
|
+
"../../../src/components/TextArea/Markdown.tsx"
|
|
38
|
+
],
|
|
36
39
|
"sourcesContent": [
|
|
37
40
|
"import React, { useContext, useEffect, useMemo } from 'react';\nimport { rehype } from 'rehype';\nimport rehypePrism from 'rehype-prism-plus';\nimport { IProps } from '../../Editor';\nimport { EditorContext } from '../../Context';\n\nexport interface MarkdownProps extends IProps, React.HTMLAttributes<HTMLPreElement> {}\n\nexport default function Markdown(props: MarkdownProps) {\n const { prefixCls } = props;\n const { markdown = '', dispatch } = useContext(EditorContext);\n const preRef = React.createRef<HTMLPreElement>();\n useEffect(() => {\n if (preRef.current && dispatch) {\n dispatch({ textareaPre: preRef.current });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n function html2Escape(sHtml: string) {\n return sHtml\n .replace(/```(tsx?|jsx?|html|xml)(.*)\\s+([\\s\\S]*?)(\\s.+)?```/g, (str: string) => {\n return str.replace(\n /[<&\"]/g,\n (c: string) => (({ '<': '<', '>': '>', '&': '&', '\"': '"' } as Record<string, string>)[c]),\n );\n })\n .replace(\n /[<&\"]/g,\n (c: string) => (({ '<': '<', '>': '>', '&': '&', '\"': '"' } as Record<string, string>)[c]),\n );\n }\n\n return useMemo(() => {\n if (!markdown) {\n return <pre children={markdown || ''} ref={preRef} className={`${prefixCls}-text-pre wmde-markdown-color`} />;\n }\n const str = rehype()\n .data('settings', { fragment: true })\n .use(rehypePrism, { ignoreMissing: true })\n .processSync(\n `<pre class=\"language-markdown ${prefixCls}-text-pre wmde-markdown-color\"><code class=\"language-markdown\">${html2Escape(\n markdown,\n )}\\n</code></pre>`,\n );\n return React.createElement('div', {\n className: 'wmde-markdown-color',\n dangerouslySetInnerHTML: { __html: str.value as string },\n });\n }, [markdown, preRef, prefixCls]);\n}\n"
|
|
38
|
-
]
|
|
41
|
+
],
|
|
42
|
+
"mappings": ";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;;;AAIe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;EACrD,IAAQC,SAAR,GAAsBD,KAAtB,CAAQC,SAAR;;EACA,kBAAoC,IAAAC,iBAAA,EAAWC,sBAAX,CAApC;EAAA,uCAAQC,QAAR;EAAA,IAAQA,QAAR,qCAAmB,EAAnB;EAAA,IAAuBC,QAAvB,eAAuBA,QAAvB;;EACA,IAAMC,MAAM,gBAAGC,cAAA,CAAMC,SAAN,EAAf;;EACA,IAAAC,gBAAA,EAAU,YAAM;IACd,IAAIH,MAAM,CAACI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AP;EAID,CAhBM,EAgBJ,CAACzB,QAAD,EAAWE,MAAX,EAAmBL,SAAnB,CAhBI,CAAP;AAiBD"
|
|
39
43
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../../src/components/TextArea/Textarea.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"Textarea",
|
|
8
5
|
"props",
|
|
9
6
|
"prefixCls",
|
|
10
7
|
"onChange",
|
|
11
8
|
"other",
|
|
9
|
+
"useContext",
|
|
12
10
|
"EditorContext",
|
|
13
11
|
"markdown",
|
|
14
12
|
"commands",
|
|
@@ -24,20 +22,26 @@
|
|
|
24
22
|
"useRef",
|
|
25
23
|
"executeRef",
|
|
26
24
|
"statesRef",
|
|
25
|
+
"useEffect",
|
|
27
26
|
"current",
|
|
28
27
|
"commandOrchestrator",
|
|
29
28
|
"TextAreaCommandOrchestrator",
|
|
30
29
|
"textarea",
|
|
31
30
|
"onKeyDown",
|
|
32
31
|
"e",
|
|
32
|
+
"handleKeyDown",
|
|
33
|
+
"shortcuts",
|
|
33
34
|
"addEventListener",
|
|
34
35
|
"removeEventListener",
|
|
35
36
|
"className",
|
|
36
37
|
"target",
|
|
37
38
|
"value"
|
|
38
39
|
],
|
|
39
|
-
"
|
|
40
|
+
"sources": [
|
|
41
|
+
"../../../src/components/TextArea/Textarea.tsx"
|
|
42
|
+
],
|
|
40
43
|
"sourcesContent": [
|
|
41
44
|
"import React, { useContext, useEffect } from 'react';\nimport { IProps } from '../../Editor';\nimport { EditorContext, ExecuteCommandState } from '../../Context';\nimport { TextAreaCommandOrchestrator } from '../../commands';\nimport handleKeyDown from './handleKeyDown';\nimport shortcuts from './shortcuts';\nimport './index.less';\n\nexport interface TextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value'>, IProps {}\n\nexport default function Textarea(props: TextAreaProps) {\n const { prefixCls, onChange, ...other } = props;\n const {\n markdown,\n commands,\n fullscreen,\n preview,\n highlightEnable,\n extraCommands,\n tabSize,\n defaultTabEnable,\n dispatch,\n } = useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const statesRef = React.useRef<ExecuteCommandState>({ fullscreen, preview });\n\n useEffect(() => {\n statesRef.current = { fullscreen, preview, highlightEnable };\n }, [fullscreen, preview, highlightEnable]);\n\n useEffect(() => {\n if (textRef.current && dispatch) {\n const commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);\n executeRef.current = commandOrchestrator;\n dispatch({ textarea: textRef.current, commandOrchestrator });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const onKeyDown = (e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) => {\n handleKeyDown(e, tabSize, defaultTabEnable);\n shortcuts(e, [...(commands || []), ...(extraCommands || [])], executeRef.current, dispatch, statesRef.current);\n };\n useEffect(() => {\n if (textRef.current) {\n textRef.current.addEventListener('keydown', onKeyDown);\n }\n return () => {\n if (textRef.current) {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n textRef.current.removeEventListener('keydown', onKeyDown);\n }\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n return (\n <textarea\n autoComplete=\"off\"\n autoCorrect=\"off\"\n autoCapitalize=\"off\"\n spellCheck={false}\n {...other}\n ref={textRef}\n className={`${prefixCls}-text-input ${other.className ? other.className : ''}`}\n value={markdown}\n onChange={(e) => {\n dispatch && dispatch({ markdown: e.target.value });\n onChange && onChange(e);\n }}\n />\n );\n}\n"
|
|
42
|
-
]
|
|
45
|
+
],
|
|
46
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;;;;;AAKe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;EACrD,IAAQC,SAAR,GAA0CD,KAA1C,CAAQC,SAAR;EAAA,IA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x"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"stopPropagation",
|
|
8
5
|
"e",
|
|
@@ -43,6 +40,7 @@
|
|
|
43
40
|
"indexOf",
|
|
44
41
|
"end",
|
|
45
42
|
"modifiedTextObj",
|
|
43
|
+
"insertBeforeEachLine",
|
|
46
44
|
"shiftKey",
|
|
47
45
|
"text",
|
|
48
46
|
"map",
|
|
@@ -51,13 +49,17 @@
|
|
|
51
49
|
"replaceSelection",
|
|
52
50
|
"startTabSize",
|
|
53
51
|
"endTabSize",
|
|
52
|
+
"insertTextAtPosition",
|
|
54
53
|
"test",
|
|
55
54
|
"startStr",
|
|
56
55
|
"startsWith",
|
|
57
56
|
"parseInt"
|
|
58
57
|
],
|
|
59
|
-
"
|
|
58
|
+
"sources": [
|
|
59
|
+
"../../../src/components/TextArea/handleKeyDown.tsx"
|
|
60
|
+
],
|
|
60
61
|
"sourcesContent": [
|
|
61
62
|
"import { insertTextAtPosition } from '../../utils/InsertTextAtPosition';\nimport { TextAreaTextApi } from '../../commands';\nimport { insertBeforeEachLine } from '../../commands/list';\n\n/**\n * - `13` - `Enter`\n * - `9` - `Tab`\n */\nfunction stopPropagation(e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>) {\n e.stopPropagation();\n e.preventDefault();\n}\n\nexport default function handleKeyDown(\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n tabSize: number = 2,\n defaultTabEnable: boolean = false,\n) {\n const target = e.target as HTMLTextAreaElement;\n const starVal = target.value.substr(0, target.selectionStart);\n const valArr = starVal.split('\\n');\n const currentLineStr = valArr[valArr.length - 1];\n const textArea = new TextAreaTextApi(target);\n\n /**\n * `9` - `Tab`\n */\n if (!defaultTabEnable && e.code && e.code.toLowerCase() === 'tab') {\n stopPropagation(e);\n const space = new Array(tabSize + 1).join(' ');\n if (target.selectionStart !== target.selectionEnd) {\n const _star = target.value.substring(0, target.selectionStart).split('\\n');\n const _end = target.value.substring(0, target.selectionEnd).split('\\n');\n const modifiedTextLine: string[] = [];\n _end.forEach((item, idx) => {\n if (item !== _star[idx]) {\n modifiedTextLine.push(item);\n }\n });\n const modifiedText = modifiedTextLine.join('\\n');\n const oldSelectText = target.value.substring(target.selectionStart, target.selectionEnd);\n const newStarNum = target.value.substring(0, target.selectionStart).length;\n\n textArea.setSelectionRange({\n start: target.value.indexOf(modifiedText),\n end: target.selectionEnd,\n });\n\n const modifiedTextObj = insertBeforeEachLine(modifiedText, e.shiftKey ? '' : space);\n\n let text = modifiedTextObj.modifiedText;\n if (e.shiftKey) {\n text = text\n .split('\\n')\n .map((item) => item.replace(new RegExp(`^${space}`), ''))\n .join('\\n');\n }\n textArea.replaceSelection(text);\n\n let startTabSize = e.shiftKey ? -tabSize : tabSize;\n let endTabSize = e.shiftKey ? -modifiedTextLine.length * tabSize : modifiedTextLine.length * tabSize;\n\n textArea.setSelectionRange({\n start: newStarNum + startTabSize,\n end: newStarNum + oldSelectText.length + endTabSize,\n });\n } else {\n return insertTextAtPosition(target, space);\n }\n } else if (\n e.code &&\n e.code.toLowerCase() === 'enter' &&\n (/^(-|\\*)\\s/.test(currentLineStr) || /^\\d+.\\s/.test(currentLineStr))\n ) {\n /**\n * `13` - `Enter`\n */\n stopPropagation(e);\n let startStr = '\\n- ';\n\n if (currentLineStr.startsWith('*')) {\n startStr = '\\n* ';\n }\n\n if (currentLineStr.startsWith('- [ ]')) {\n startStr = '\\n- [ ] ';\n } else if (currentLineStr.startsWith('- [X]')) {\n startStr = '\\n- [X] ';\n }\n\n if (/^\\d+.\\s/.test(currentLineStr)) {\n startStr = `\\n${parseInt(currentLineStr) + 1}. `;\n }\n return insertTextAtPosition(target, startStr);\n }\n}\n"
|
|
62
|
-
]
|
|
63
|
+
],
|
|
64
|
+
"mappings": ";;;;;;;AAAA;;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA,SAASA,eAAT,CAAyBC,CAAzB,EAAsF;EACpFA,CAAC,CAACD,eAAF;EACAC,CAA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,7 @@
|
|
|
11
8
|
"onScroll",
|
|
12
9
|
"renderTextarea",
|
|
13
10
|
"otherProps",
|
|
11
|
+
"useContext",
|
|
14
12
|
"EditorContext",
|
|
15
13
|
"markdown",
|
|
16
14
|
"scrollTop",
|
|
@@ -24,6 +22,7 @@
|
|
|
24
22
|
"executeRef",
|
|
25
23
|
"warp",
|
|
26
24
|
"createRef",
|
|
25
|
+
"useEffect",
|
|
27
26
|
"state",
|
|
28
27
|
"current",
|
|
29
28
|
"textareaWarp",
|
|
@@ -43,11 +42,13 @@
|
|
|
43
42
|
"overflow",
|
|
44
43
|
"onChange",
|
|
45
44
|
"shortcuts",
|
|
46
|
-
"useContext",
|
|
47
45
|
"ref"
|
|
48
46
|
],
|
|
49
|
-
"
|
|
47
|
+
"sources": [
|
|
48
|
+
"../../../src/components/TextArea/index.tsx"
|
|
49
|
+
],
|
|
50
50
|
"sourcesContent": [
|
|
51
51
|
"import React, { useEffect, Fragment, useContext } from 'react';\nimport { EditorContext, ContextStore, ExecuteCommandState } from '../../Context';\nimport shortcuts from './shortcuts';\nimport Markdown from './Markdown';\nimport Textarea, { TextAreaProps } from './Textarea';\nimport { IProps } from '../../Editor';\nimport { TextAreaCommandOrchestrator, ICommand } from '../../commands';\nimport './index.less';\n\ntype RenderTextareaHandle = {\n dispatch: ContextStore['dispatch'];\n onChange?: TextAreaProps['onChange'];\n useContext?: {\n commands: ContextStore['commands'];\n extraCommands: ContextStore['extraCommands'];\n commandOrchestrator?: TextAreaCommandOrchestrator;\n };\n shortcuts?: (\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n ) => void;\n};\n\nexport interface ITextAreaProps\n extends Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'value' | 'onScroll'>,\n IProps {\n value?: string;\n onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;\n renderTextarea?: (\n props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>,\n opts: RenderTextareaHandle,\n ) => JSX.Element;\n}\n\nexport type TextAreaRef = {\n text?: HTMLTextAreaElement;\n warp?: HTMLDivElement;\n};\n\nexport default function TextArea(props: ITextAreaProps) {\n const { prefixCls, className, onScroll, renderTextarea, ...otherProps } = props || {};\n const { markdown, scrollTop, commands, highlightEnable, extraCommands, dispatch } = useContext(EditorContext);\n const textRef = React.useRef<HTMLTextAreaElement>(null);\n const executeRef = React.useRef<TextAreaCommandOrchestrator>();\n const warp = React.createRef<HTMLDivElement>();\n useEffect(() => {\n const state: ContextStore = {};\n if (warp.current) {\n state.textareaWarp = warp.current || undefined;\n warp.current.scrollTop = scrollTop || 0;\n }\n if (dispatch) {\n dispatch({ ...state });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (textRef.current && dispatch) {\n const commandOrchestrator = new TextAreaCommandOrchestrator(textRef.current);\n executeRef.current = commandOrchestrator;\n dispatch({ textarea: textRef.current, commandOrchestrator });\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // @ts-ignore\n const textStyle: React.CSSProperties = highlightEnable ? {} : { '-webkit-text-fill-color': 'inherit' };\n\n return (\n <div ref={warp} className={`${prefixCls}-aree ${className || ''}`} onScroll={onScroll}>\n <div className={`${prefixCls}-text`}>\n {renderTextarea ? (\n React.cloneElement(\n renderTextarea(\n {\n ...otherProps,\n value: markdown,\n autoComplete: 'off',\n autoCorrect: 'off',\n spellCheck: 'false',\n autoCapitalize: 'off',\n className: `${prefixCls}-text-input`,\n style: {\n WebkitTextFillColor: 'inherit',\n overflow: 'auto',\n },\n },\n {\n dispatch,\n onChange: otherProps.onChange,\n shortcuts,\n useContext: { commands, extraCommands, commandOrchestrator: executeRef.current },\n },\n ),\n {\n ref: textRef,\n },\n )\n ) : (\n <Fragment>\n {highlightEnable && <Markdown prefixCls={prefixCls} />}\n <Textarea prefixCls={prefixCls} {...otherProps} style={textStyle} />\n </Fragment>\n )}\n </div>\n </div>\n );\n}\n"
|
|
52
|
-
]
|
|
52
|
+
],
|
|
53
|
+
"mappings": ";;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAoCe,SAASA,QAAT,CAAkBC,KAAlB,EAAyC;EACtD,WAA0EA,KAAK,IAAI,EAAnF;EAAA,IAAQC,SAAR,QAAQA,SAAR;EAAA,IAAmBC,SAAnB,QAAmBA,SAAnB;EAAA,IAA8BC,QAA9B,QAA8BA,QAA9B;EAAA,IAAwCC,cAAxC,QAAwCA,cAAxC;EAAA,IAA2DC,UAA3D;;EACA,kBAAoF,IAAAC,iBAAA,EAAWC,sBAAX,CAApF;EAAA,IAAQC,QAAR,eAAQA,QAAR;EAAA,IAAkBC,SAAlB,eAAkBA,SAAlB;EAAA,IAA6BC,QAA7B,eAA6BA,QAA7B;EAAA,IAAuCC,eAAvC,eAAuCA,eAAvC;EAAA,IAAwDC,aAAxD,eAAwDA,aAAxD;EAAA,IAAuEC,QAAvE,eAAuEA,QAAvE;;EACA,IAAMC,OAAO,GAAGC,cAAA,CAAMC,MAAN,CAAkC,IAAlC,CAAhB;;EACA,IAAMC,UAAU,GAAGF,cAAA,CAAMC,MAAN,EAAnB;;EACA,IAAME,IAAI,gBAAGH,cAAA,CAAMI,SAAN,EAAb;;EACA,IAAAC,gBAAA,EAAU,YAAM;IACd,IAAMC,KAAmB,GAAG,EAA5B;;IACA,IAAIH,IAAI,CAACI,OAAT,EAAkB;MAChBD,KAAK,CAACE,YAAN,GAAqBL,IAAI,CAACI,OAAL,IAAgBE,SAArC;MACAN,IAAI,CAACI,OAAL,CAAab,SAAb,GAAyBA,SAAS,IAAI,CAAtC;IACD;;IACD,IAAII,QAAJ,EAAc;MACZA,QAAQ,iCAAMQ,KAAN,EAAR;IACD,CARa,CASd;;EACD,CAVD,EAUG,EAVH;EAYA,IA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AAD;QAAA,WACGH,eAAe,iBAAI,qBAAC,iBAAD;UAAU,SAAS,EAAEV;QAArB,EADtB,eAEE,qBAAC,iBAAD;UAAU,SAAS,EAAEA;QAArB,GAAoCI,UAApC;UAAgD,KAAK,EAAEuB;QAAvD,GAFF;MAAA;IA7BJ;EADF,EADF;AAuCD"
|
|
53
54
|
}
|
|
@@ -48,8 +48,15 @@
|
|
|
48
48
|
}
|
|
49
49
|
&-pre {
|
|
50
50
|
position: relative;
|
|
51
|
-
margin: 0px;
|
|
51
|
+
margin: 0px !important;
|
|
52
52
|
pointer-events: none;
|
|
53
|
+
background-color: transparent !important;
|
|
54
|
+
> code {
|
|
55
|
+
padding: 0 !important;
|
|
56
|
+
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif !important;
|
|
57
|
+
font-size: 14px !important;
|
|
58
|
+
line-height: 18px !important;
|
|
59
|
+
}
|
|
53
60
|
}
|
|
54
61
|
&-input {
|
|
55
62
|
position: absolute;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../../src/components/TextArea/shortcuts.ts"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"getCommands",
|
|
8
5
|
"data",
|
|
@@ -45,8 +42,11 @@
|
|
|
45
42
|
"preventDefault",
|
|
46
43
|
"executeCommand"
|
|
47
44
|
],
|
|
48
|
-
"
|
|
45
|
+
"sources": [
|
|
46
|
+
"../../../src/components/TextArea/shortcuts.ts"
|
|
47
|
+
],
|
|
49
48
|
"sourcesContent": [
|
|
50
49
|
"import { ICommand, TextAreaCommandOrchestrator } from '../../commands';\nimport { ContextStore, ExecuteCommandState } from '../../Context';\n\nfunction getCommands(data: ICommand[] = [], resulte: Record<string, ICommand> = {}): Record<string, ICommand> {\n data.forEach((item) => {\n if (item.children && Array.isArray(item.children)) {\n resulte = { ...resulte, ...getCommands(item.children || []) };\n } else if (item.keyCommand && item.shortcuts && item.execute) {\n resulte[item.shortcuts.toLocaleLowerCase()] = item;\n }\n });\n return resulte;\n}\n\nexport default function shortcutsHandle(\n e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>,\n commands: ICommand[] = [],\n commandOrchestrator?: TextAreaCommandOrchestrator,\n dispatch?: React.Dispatch<ContextStore>,\n state?: ExecuteCommandState,\n) {\n const data = getCommands(commands || []);\n const shortcuts: (string | number)[] = [];\n if (e.altKey) {\n shortcuts.push('alt');\n }\n if (e.shiftKey) {\n shortcuts.push('shift');\n }\n if (e.metaKey) {\n shortcuts.push('cmd');\n }\n if (e.ctrlKey) {\n shortcuts.push('ctrl');\n }\n if (shortcuts.length > 0 && !/(control|alt|meta|shift)/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push(e.key.toLocaleLowerCase());\n }\n if (/escape/.test(e.key.toLocaleLowerCase())) {\n shortcuts.push('escape');\n }\n if (shortcuts.length < 1) {\n return;\n }\n\n let equal = !!data[shortcuts.join('+')];\n let command = equal ? data[shortcuts.join('+')] : undefined;\n\n Object.keys(data).forEach((item) => {\n const isequal = item.split('+').every((v) => {\n if (/ctrlcmd/.test(v)) {\n return shortcuts.includes('ctrl') || shortcuts.includes('cmd');\n }\n return shortcuts.includes(v);\n });\n if (isequal) {\n command = data[item];\n }\n });\n if (command && commandOrchestrator) {\n e.stopPropagation();\n e.preventDefault();\n commandOrchestrator.executeCommand(command, dispatch, state);\n return;\n }\n}\n"
|
|
51
|
-
]
|
|
50
|
+
],
|
|
51
|
+
"mappings": ";;;;;;;;;;;AAGA,SAASA,WAAT,GAA8G;EAAA,IAAzFC,IAAyF,uEAAtE,EAAsE;EAAA,IAAlEC,OAAkE,uEAA9B,EAA8B;EAC5GD,IAAI,CAACE,OAAL,CAAa,UAACC,IAAD,EAAU;IACrB,IAAIA,IAAI,CAACC,QAAL,IAAiBC,KAAK,CAACC,OAAN,CAAcH,IAAI,CAACC,QAAnB,CAArB,EAAmD;MACjDH,OAAO,+DAAQA,OAAR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ACD;;EAED,IAAIG,KAAK,GAAG,CAAC,CAACzB,IAAI,CAACQ,SAAS,CAACkB,IAAV,CAAe,GAAf,CAAD,CAAlB;EACA,IAAIC,OAAO,GAAGF,KAAK,GAAGzB,IAAI,CAACQ,SAAS,CAACkB,IAAV,CAAe,GAAf,CAAD,CAAP,GAA+BE,SAAlD;EAEAC,MAAM,CAACC,IAAP,CAAY9B,IAAZ,EAAkBE,OAAlB,CAA0B,UAACC,IAAD,EAAU;IAClC,IAAM4B,OAAO,GAAG5B,IAAI,CAAC6B,KAAL,CAAW,GAAX,EAAgBC,KAAhB,CAAsB,UAACC,CAAD,EAAO;MAC3C,IAAI,UAAUX,IAAV,CAAeW,CAAf,CAAJ,EAAuB;QACrB,OAAO1B,SAAS,CAAC2B,QAAV,CAAmB,MAAnB,KAA8B3B,SAAS,CAAC2B,QAAV,CAAmB,KAAnB,CAArC;MACD;;MACD,OAAO3B,SAAS,CAAC2B,QAAV,CAAmBD,CAAnB,CAAP;IACD,CALe,CAAhB;;IAMA,IAAIH,OAAJ,EAAa;MACXJ,OAAO,GAAG3B,IAAI,CAACG,IAAD,CAAd;IACD;EACF,CAVD;;EAWA,IAAIwB,OAAO,IAAIb,mBAAf,EAAoC;IAClCF,CAAC,CAACwB,eAAF;IACAxB,CAAC,CAACyB,cAAF;IACAvB,mBAAmB,CAACwB,cAApB,CAAmCX,OAAnC,EAA4CZ,QAA5C,EAAsDC,KAAtD;IACA;EACD;AACF"
|
|
52
52
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"../../../src/components/Toolbar/Child.tsx"
|
|
5
|
-
],
|
|
6
3
|
"names": [
|
|
7
4
|
"Child",
|
|
8
5
|
"props",
|
|
@@ -10,15 +7,20 @@
|
|
|
10
7
|
"groupName",
|
|
11
8
|
"commands",
|
|
12
9
|
"children",
|
|
10
|
+
"useContext",
|
|
13
11
|
"EditorContext",
|
|
14
12
|
"barPopup",
|
|
13
|
+
"useMemo",
|
|
15
14
|
"e",
|
|
16
15
|
"stopPropagation",
|
|
17
16
|
"Array",
|
|
18
17
|
"isArray"
|
|
19
18
|
],
|
|
20
|
-
"
|
|
19
|
+
"sources": [
|
|
20
|
+
"../../../src/components/Toolbar/Child.tsx"
|
|
21
|
+
],
|
|
21
22
|
"sourcesContent": [
|
|
22
23
|
"import React, { useContext, useMemo } from 'react';\nimport './Child.less';\nimport Toolbar, { IToolbarProps } from './';\nimport { EditorContext } from '../../Context';\n\nexport type ChildProps = IToolbarProps & {\n children?: JSX.Element;\n groupName?: string;\n};\n\nexport default function Child(props: ChildProps) {\n const { prefixCls, groupName, commands, children } = props || {};\n const { barPopup = {} } = useContext(EditorContext);\n return useMemo(\n () => (\n <div\n className={`${prefixCls}-toolbar-child ${groupName && barPopup[groupName] ? 'active' : ''}`}\n onClick={(e) => e.stopPropagation()}\n >\n {Array.isArray(commands) ? <Toolbar commands={commands} {...props} height=\"\" isChild /> : children}\n </div>\n ),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [commands, barPopup, groupName, prefixCls],\n );\n}\n"
|
|
23
|
-
]
|
|
24
|
+
],
|
|
25
|
+
"mappings": ";;;;;;;;;;;;;AAAA;;AAEA;;AACA;;;;AAOe,SAASA,KAAT,CAAeC,KAAf,EAAkC;EAC/C,WAAqDA,KAAK,IAAI,EAA9D;EAAA,IAAQC,SAAR,QAAQA,SAAR;EAAA,IAAmBC,SAAnB,QAAmBA,SAAnB;EAAA,IAA8BC,QAA9B,QAA8BA,QAA9B;EAAA,IAAwCC,QAAxC,QAAwCA,QAAxC;;EACA,kBAA0B,IAAAC,iBAAA,EAAWC,sBAAX,CAA1B;EAAA,uCAAQC,QAAR;EAAA,IAAQA,QAAR,qCAAmB,EAAnB;;EACA,OAAO,IAAAC,cAAA,EACL;IAAA,oBACE;MACE,SAAS,YAAKP,SAAL,4BAAgCC,SAAS,IAAIK,QAAQ,CAACL,SAAD,CAArB,GAAmC,QAAnC,GAA8C,EAA9E,CADX;MAEE,OAAO,EAAE,iBAACO,CAAD;QAAA,OAAOA,CAAC,CAACC,eAAF,EAAP;MAAA,CAFX;MAAA,UAIGC,KAAK,CAACC,OAAN,CAAcT,QAAd,iBAA0B,qBAAC,SAAD;QAAS,QAAQ,EAAEA;MAAnB,GAAiCH,KAAjC;QAAwC,MAAM,EAAC,EAA/C;QAAkD,OAAO;MAAzD,GAA1B,GAAyFI;IAJ5F,EADF;EAAA,CADK,EASL;EACA,CAACD,QAAD,EAAWI,QAAX,EAAqBL,SAArB,EAAgCD,SAAhC,CAVK,CAAP;AAYD"
|
|
24
26
|
}
|
|
@@ -5,6 +5,7 @@ import './index.less';
|
|
|
5
5
|
export interface IToolbarProps extends IProps {
|
|
6
6
|
overflow?: boolean;
|
|
7
7
|
height?: React.CSSProperties['height'];
|
|
8
|
+
toolbarBottom?: boolean;
|
|
8
9
|
onCommand?: (command: ICommand<string>, groupName?: string) => void;
|
|
9
10
|
commands?: ICommand<string>[];
|
|
10
11
|
isChild?: boolean;
|
|
@@ -139,14 +139,16 @@ function Toolbar() {
|
|
|
139
139
|
var prefixCls = props.prefixCls,
|
|
140
140
|
_props$height = props.height,
|
|
141
141
|
height = _props$height === void 0 ? 29 : _props$height,
|
|
142
|
+
toolbarBottom = props.toolbarBottom,
|
|
142
143
|
isChild = props.isChild;
|
|
143
144
|
|
|
144
145
|
var _useContext2 = (0, _react.useContext)(_Context.EditorContext),
|
|
145
146
|
commands = _useContext2.commands,
|
|
146
147
|
extraCommands = _useContext2.extraCommands;
|
|
147
148
|
|
|
149
|
+
var bottomClassName = toolbarBottom ? 'bottom' : '';
|
|
148
150
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
149
|
-
className: "".concat(prefixCls, "-toolbar"),
|
|
151
|
+
className: "".concat(prefixCls, "-toolbar ").concat(bottomClassName),
|
|
150
152
|
style: {
|
|
151
153
|
height: height
|
|
152
154
|
},
|