@uiw/react-md-editor 3.20.4 → 3.20.6
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 +5 -2
- package/dist/mdeditor.css +13 -0
- package/dist/mdeditor.js +9004 -934
- package/dist/mdeditor.min.css +1 -1
- package/dist/mdeditor.min.js +1 -1
- package/esm/Context.d.ts +3 -3
- package/esm/Context.js +1 -2
- package/esm/Editor.d.ts +1 -1
- package/esm/Editor.js +9 -2
- package/esm/commands/bold.js +8 -7
- package/esm/commands/code.js +2 -3
- package/esm/commands/comment.js +2 -2
- package/esm/commands/divider.js +1 -2
- package/esm/commands/fullscreen.js +2 -3
- package/esm/commands/group.d.ts +1 -1
- package/esm/commands/group.js +1 -2
- package/esm/commands/hr.js +3 -4
- package/esm/commands/image.js +12 -8
- package/esm/commands/index.d.ts +5 -2
- package/esm/commands/index.js +5 -3
- package/esm/commands/italic.js +11 -9
- package/esm/commands/link.js +9 -7
- package/esm/commands/list.d.ts +1 -1
- package/esm/commands/list.js +2 -3
- package/esm/commands/preview.js +2 -3
- package/esm/commands/quote.js +2 -3
- package/esm/commands/strikeThrough.js +11 -9
- package/esm/commands/title.js +1 -2
- package/esm/commands/title1.js +1 -2
- package/esm/commands/title2.js +2 -3
- package/esm/commands/title3.js +2 -3
- package/esm/commands/title4.js +2 -3
- package/esm/commands/title5.js +2 -3
- package/esm/commands/title6.js +2 -3
- package/esm/components/DragBar/index.js +1 -2
- package/esm/components/TextArea/Markdown.js +1 -2
- package/esm/components/TextArea/Textarea.js +1 -2
- package/esm/components/TextArea/handleKeyDown.d.ts +1 -0
- package/esm/components/TextArea/handleKeyDown.js +1 -2
- package/esm/components/TextArea/index.d.ts +2 -2
- package/esm/components/TextArea/index.js +1 -2
- package/esm/components/TextArea/shortcuts.d.ts +1 -0
- package/esm/components/TextArea/shortcuts.js +1 -2
- package/esm/components/Toolbar/Child.d.ts +2 -1
- package/esm/components/Toolbar/Child.js +1 -2
- package/esm/components/Toolbar/index.d.ts +1 -0
- package/esm/components/Toolbar/index.js +1 -2
- package/esm/index.js +1 -2
- package/esm/react-app-env.d.ts +1 -0
- package/esm/utils/InsertTextAtPosition.js +1 -2
- package/esm/utils/markdownUtils.js +1 -2
- package/lib/Context.d.ts +3 -3
- package/lib/Context.js +1 -2
- package/lib/Editor.d.ts +1 -1
- package/lib/Editor.js +13 -2
- package/lib/commands/bold.js +8 -7
- package/lib/commands/code.js +3 -4
- package/lib/commands/comment.js +3 -2
- package/lib/commands/divider.js +1 -2
- package/lib/commands/fullscreen.js +3 -4
- package/lib/commands/group.d.ts +1 -1
- package/lib/commands/group.js +1 -2
- package/lib/commands/hr.js +4 -5
- package/lib/commands/image.js +13 -9
- package/lib/commands/index.d.ts +5 -2
- package/lib/commands/index.js +5 -3
- package/lib/commands/italic.js +12 -10
- package/lib/commands/link.js +10 -8
- package/lib/commands/list.d.ts +1 -1
- package/lib/commands/list.js +3 -4
- package/lib/commands/preview.js +3 -4
- package/lib/commands/quote.js +3 -4
- package/lib/commands/strikeThrough.js +12 -10
- package/lib/commands/title.js +1 -2
- package/lib/commands/title1.js +1 -2
- package/lib/commands/title2.js +3 -4
- package/lib/commands/title3.js +3 -4
- package/lib/commands/title4.js +3 -4
- package/lib/commands/title5.js +3 -4
- package/lib/commands/title6.js +3 -4
- package/lib/components/DragBar/index.js +1 -2
- package/lib/components/TextArea/Markdown.js +1 -2
- package/lib/components/TextArea/Textarea.js +1 -2
- package/lib/components/TextArea/handleKeyDown.d.ts +1 -0
- package/lib/components/TextArea/handleKeyDown.js +1 -2
- package/lib/components/TextArea/index.d.ts +2 -2
- package/lib/components/TextArea/index.js +1 -2
- package/lib/components/TextArea/shortcuts.d.ts +1 -0
- package/lib/components/TextArea/shortcuts.js +1 -2
- package/lib/components/Toolbar/Child.d.ts +2 -1
- package/lib/components/Toolbar/Child.js +1 -2
- package/lib/components/Toolbar/index.d.ts +1 -0
- package/lib/components/Toolbar/index.js +1 -2
- package/lib/index.js +1 -2
- package/lib/react-app-env.d.ts +1 -0
- package/lib/utils/InsertTextAtPosition.js +1 -2
- package/lib/utils/markdownUtils.js +1 -2
- package/package.json +1 -1
- package/src/Editor.tsx +4 -0
- package/src/__test__/commands.test.tsx +4 -4
- package/src/commands/bold.tsx +9 -8
- package/src/commands/code.tsx +1 -1
- package/src/commands/comment.tsx +1 -0
- package/src/commands/divider.tsx +1 -0
- package/src/commands/fullscreen.tsx +1 -1
- package/src/commands/hr.tsx +4 -4
- package/src/commands/image.tsx +13 -10
- package/src/commands/index.ts +5 -2
- package/src/commands/italic.tsx +12 -11
- package/src/commands/link.tsx +9 -9
- package/src/commands/list.tsx +1 -1
- package/src/commands/preview.tsx +1 -1
- package/src/commands/quote.tsx +1 -1
- package/src/commands/strikeThrough.tsx +12 -11
- package/src/commands/title2.tsx +1 -1
- package/src/commands/title3.tsx +1 -1
- package/src/commands/title4.tsx +1 -1
- package/src/commands/title5.tsx +1 -1
- package/src/commands/title6.tsx +1 -1
- package/esm/Context.js.map +0 -19
- package/esm/Editor.js.map +0 -116
- package/esm/commands/bold.js.map +0 -36
- package/esm/commands/code.js.map +0 -47
- package/esm/commands/comment.js.map +0 -35
- package/esm/commands/divider.js.map +0 -14
- package/esm/commands/fullscreen.js.map +0 -28
- package/esm/commands/group.js.map +0 -26
- package/esm/commands/hr.js.map +0 -26
- package/esm/commands/image.js.map +0 -36
- package/esm/commands/index.js.map +0 -69
- package/esm/commands/italic.js.map +0 -36
- package/esm/commands/link.js.map +0 -36
- package/esm/commands/list.js.map +0 -61
- package/esm/commands/preview.js.map +0 -31
- package/esm/commands/quote.js.map +0 -44
- package/esm/commands/strikeThrough.js.map +0 -36
- package/esm/commands/title.js.map +0 -16
- package/esm/commands/title1.js.map +0 -33
- package/esm/commands/title2.js.map +0 -33
- package/esm/commands/title3.js.map +0 -33
- package/esm/commands/title4.js.map +0 -33
- package/esm/commands/title5.js.map +0 -33
- package/esm/commands/title6.js.map +0 -33
- package/esm/components/DragBar/index.js.map +0 -41
- package/esm/components/TextArea/Markdown.js.map +0 -47
- package/esm/components/TextArea/Textarea.js.map +0 -47
- package/esm/components/TextArea/handleKeyDown.js.map +0 -66
- package/esm/components/TextArea/index.js.map +0 -57
- package/esm/components/TextArea/shortcuts.js.map +0 -52
- package/esm/components/Toolbar/Child.js.map +0 -28
- package/esm/components/Toolbar/index.js.map +0 -84
- package/esm/index.js.map +0 -15
- package/esm/utils/InsertTextAtPosition.js.map +0 -67
- package/esm/utils/markdownUtils.js.map +0 -31
- package/lib/Context.js.map +0 -19
- package/lib/Editor.js.map +0 -112
- package/lib/commands/bold.js.map +0 -35
- package/lib/commands/code.js.map +0 -46
- package/lib/commands/comment.js.map +0 -35
- package/lib/commands/divider.js.map +0 -14
- package/lib/commands/fullscreen.js.map +0 -27
- package/lib/commands/group.js.map +0 -25
- package/lib/commands/hr.js.map +0 -25
- package/lib/commands/image.js.map +0 -35
- package/lib/commands/index.js.map +0 -64
- package/lib/commands/italic.js.map +0 -35
- package/lib/commands/link.js.map +0 -35
- package/lib/commands/list.js.map +0 -60
- package/lib/commands/preview.js.map +0 -30
- package/lib/commands/quote.js.map +0 -43
- package/lib/commands/strikeThrough.js.map +0 -35
- package/lib/commands/title.js.map +0 -15
- package/lib/commands/title1.js.map +0 -32
- package/lib/commands/title2.js.map +0 -32
- package/lib/commands/title3.js.map +0 -32
- package/lib/commands/title4.js.map +0 -32
- package/lib/commands/title5.js.map +0 -32
- package/lib/commands/title6.js.map +0 -32
- package/lib/components/DragBar/index.js.map +0 -40
- package/lib/components/TextArea/Markdown.js.map +0 -47
- package/lib/components/TextArea/Textarea.js.map +0 -47
- package/lib/components/TextArea/handleKeyDown.js.map +0 -66
- package/lib/components/TextArea/index.js.map +0 -54
- package/lib/components/TextArea/shortcuts.js.map +0 -52
- package/lib/components/Toolbar/Child.js.map +0 -26
- package/lib/components/Toolbar/index.js.map +0 -82
- package/lib/index.js.map +0 -13
- package/lib/utils/InsertTextAtPosition.js.map +0 -67
- package/lib/utils/markdownUtils.js.map +0 -31
package/esm/Context.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ICommand, TextAreaCommandOrchestrator } from './commands';
|
|
3
3
|
import { MDEditorProps } from './Editor';
|
|
4
|
-
export
|
|
4
|
+
export type PreviewType = 'live' | 'edit' | 'preview';
|
|
5
5
|
export interface ContextStore {
|
|
6
6
|
components?: MDEditorProps['components'];
|
|
7
7
|
commands?: ICommand<string>[];
|
|
@@ -24,7 +24,7 @@ export interface ContextStore {
|
|
|
24
24
|
tabSize?: number;
|
|
25
25
|
defaultTabEnable?: boolean;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type ExecuteCommandState = Pick<ContextStore, 'fullscreen' | 'preview' | 'highlightEnable'>;
|
|
28
28
|
export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
29
29
|
components?: {
|
|
30
30
|
textarea?: ((props: React.HTMLAttributes<HTMLDivElement> | React.TextareaHTMLAttributes<HTMLTextAreaElement>, opts: {
|
|
@@ -35,7 +35,7 @@ export declare function reducer(state: ContextStore, action: ContextStore): {
|
|
|
35
35
|
extraCommands: ICommand<string>[] | undefined;
|
|
36
36
|
commandOrchestrator?: TextAreaCommandOrchestrator | undefined;
|
|
37
37
|
} | undefined;
|
|
38
|
-
shortcuts?: ((e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand
|
|
38
|
+
shortcuts?: ((e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator | undefined, dispatch?: React.Dispatch<ContextStore> | undefined, state?: ExecuteCommandState | undefined) => void) | undefined;
|
|
39
39
|
}) => JSX.Element) | undefined;
|
|
40
40
|
toolbar?: ((command: ICommand<string>, disabled: boolean, executeCommand: (command: ICommand<string>, name?: string | undefined) => void, index: number) => void | React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined) | undefined;
|
|
41
41
|
preview?: ((source: string, state: ContextStore, dispath: React.Dispatch<ContextStore>) => JSX.Element) | undefined;
|
package/esm/Context.js
CHANGED
package/esm/Editor.d.ts
CHANGED
|
@@ -141,7 +141,7 @@ export interface MDEditorProps extends Omit<React.HTMLAttributes<HTMLDivElement>
|
|
|
141
141
|
}
|
|
142
142
|
export interface RefMDEditor extends ContextStore {
|
|
143
143
|
}
|
|
144
|
-
|
|
144
|
+
type Editor = React.FC<PropsWithRef<MDEditorProps>> & {
|
|
145
145
|
Markdown: typeof MarkdownPreview;
|
|
146
146
|
};
|
|
147
147
|
declare const mdEditor: Editor;
|
package/esm/Editor.js
CHANGED
|
@@ -120,6 +120,14 @@ var InternalMDEditor = (props, ref) => {
|
|
|
120
120
|
height: height
|
|
121
121
|
}), [height]);
|
|
122
122
|
useMemo(() => height !== state.height && onHeightChange && onHeightChange(state.height, height, state), [height, onHeightChange, state]);
|
|
123
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
124
|
+
useMemo(() => commands !== state.commands && dispatch({
|
|
125
|
+
commands: cmds
|
|
126
|
+
}), [props.commands]);
|
|
127
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
128
|
+
useMemo(() => extraCommands !== state.extraCommands && dispatch({
|
|
129
|
+
extraCommands: extraCmds
|
|
130
|
+
}), [props.extraCommands]);
|
|
123
131
|
var textareaDomRef = useRef();
|
|
124
132
|
var active = useRef('preview');
|
|
125
133
|
var initScroll = useRef(false);
|
|
@@ -235,5 +243,4 @@ var InternalMDEditor = (props, ref) => {
|
|
|
235
243
|
};
|
|
236
244
|
var mdEditor = /*#__PURE__*/React.forwardRef(InternalMDEditor);
|
|
237
245
|
mdEditor.Markdown = MarkdownPreview;
|
|
238
|
-
export default mdEditor;
|
|
239
|
-
//# sourceMappingURL=Editor.js.map
|
|
246
|
+
export default mdEditor;
|
package/esm/commands/bold.js
CHANGED
|
@@ -5,7 +5,7 @@ export var bold = {
|
|
|
5
5
|
name: 'bold',
|
|
6
6
|
keyCommand: 'bold',
|
|
7
7
|
shortcuts: 'ctrlcmd+b',
|
|
8
|
-
value: '**',
|
|
8
|
+
value: '**{{text}}**',
|
|
9
9
|
buttonProps: {
|
|
10
10
|
'aria-label': 'Add bold text (ctrl + b)',
|
|
11
11
|
title: 'Add bold text (ctrl + b)'
|
|
@@ -21,7 +21,6 @@ export var bold = {
|
|
|
21
21
|
})
|
|
22
22
|
}),
|
|
23
23
|
execute: (state, api) => {
|
|
24
|
-
var _state1$selectedText;
|
|
25
24
|
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
26
25
|
var newSelectionRange = selectWord({
|
|
27
26
|
text: state.text,
|
|
@@ -29,12 +28,14 @@ export var bold = {
|
|
|
29
28
|
});
|
|
30
29
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
31
30
|
// Replaces the current selection with the bold mark up
|
|
32
|
-
var
|
|
31
|
+
var val = state.command.value || '';
|
|
32
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
33
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
34
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
33
35
|
// Adjust the selection to not contain the **
|
|
34
36
|
api.setSelectionRange({
|
|
35
|
-
start
|
|
36
|
-
end
|
|
37
|
+
start,
|
|
38
|
+
end
|
|
37
39
|
});
|
|
38
40
|
}
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=bold.js.map
|
|
41
|
+
};
|
package/esm/commands/code.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var code = {
|
|
@@ -91,5 +91,4 @@ export var codeBlock = {
|
|
|
91
91
|
end: selectionEnd
|
|
92
92
|
});
|
|
93
93
|
}
|
|
94
|
-
};
|
|
95
|
-
//# sourceMappingURL=code.js.map
|
|
94
|
+
};
|
package/esm/commands/comment.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
2
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
4
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -49,5 +50,4 @@ export var comment = {
|
|
|
49
50
|
})]
|
|
50
51
|
})
|
|
51
52
|
})
|
|
52
|
-
};
|
|
53
|
-
//# sourceMappingURL=comment.js.map
|
|
53
|
+
};
|
package/esm/commands/divider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
export var fullscreen = {
|
|
4
4
|
name: 'fullscreen',
|
|
@@ -26,5 +26,4 @@ export var fullscreen = {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=fullscreen.js.map
|
|
29
|
+
};
|
package/esm/commands/group.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICommand, ICommandChildCommands, ICommandChildHandle } from './';
|
|
2
|
-
export
|
|
2
|
+
export type GroupOptions = Omit<ICommand<string>, 'children'> & {
|
|
3
3
|
children?: ICommandChildHandle['children'];
|
|
4
4
|
};
|
|
5
5
|
export declare const group: (arr: ICommandChildCommands['children'], options?: GroupOptions) => ICommand<string>;
|
package/esm/commands/group.js
CHANGED
package/esm/commands/hr.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
export var hr = {
|
|
4
4
|
name: 'hr',
|
|
@@ -20,7 +20,6 @@ export var hr = {
|
|
|
20
20
|
})
|
|
21
21
|
}),
|
|
22
22
|
execute: (state, api) => {
|
|
23
|
-
api.replaceSelection(state.selectedText + "\n\n
|
|
23
|
+
api.replaceSelection(state.selectedText + "\n\n" + (state.command.value || '') + "-\n\n");
|
|
24
24
|
}
|
|
25
|
-
};
|
|
26
|
-
//# sourceMappingURL=hr.js.map
|
|
25
|
+
};
|
package/esm/commands/image.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var image = {
|
|
5
5
|
name: 'image',
|
|
6
6
|
keyCommand: 'image',
|
|
7
7
|
shortcuts: 'ctrlcmd+k',
|
|
8
|
-
value: '![image]()',
|
|
8
|
+
value: '',
|
|
9
9
|
buttonProps: {
|
|
10
10
|
'aria-label': 'Add image (ctrl + k)',
|
|
11
11
|
title: 'Add image (ctrl + k)'
|
|
@@ -28,12 +28,16 @@ export var image = {
|
|
|
28
28
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
29
29
|
// Replaces the current selection with the image
|
|
30
30
|
var imageTemplate = state1.selectedText || 'https://example.com/your-image.png';
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
var val = state.command.value || '';
|
|
32
|
+
api.replaceSelection(val.replace(/({{text}})/gi, imageTemplate));
|
|
33
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
34
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
35
|
+
if (!state1.selectedText) {
|
|
36
|
+
end = end + imageTemplate.length;
|
|
37
|
+
}
|
|
33
38
|
api.setSelectionRange({
|
|
34
|
-
start
|
|
35
|
-
end
|
|
39
|
+
start,
|
|
40
|
+
end
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=image.js.map
|
|
43
|
+
};
|
package/esm/commands/index.d.ts
CHANGED
|
@@ -47,9 +47,12 @@ export interface ICommandBase<T> {
|
|
|
47
47
|
liProps?: React.LiHTMLAttributes<HTMLLIElement>;
|
|
48
48
|
buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement> | null;
|
|
49
49
|
render?: (command: ICommand<T>, disabled: boolean, executeCommand: (command: ICommand<T>, name?: string) => void, index: number) => void | undefined | null | React.ReactElement;
|
|
50
|
-
execute?: (state:
|
|
50
|
+
execute?: (state: ExecuteState, api: TextAreaTextApi, dispatch?: React.Dispatch<ContextStore>, executeCommandState?: ExecuteCommandState, shortcuts?: string[]) => void;
|
|
51
51
|
}
|
|
52
|
-
export
|
|
52
|
+
export type ExecuteState = TextState & {
|
|
53
|
+
command: ICommand;
|
|
54
|
+
};
|
|
55
|
+
export type ICommand<T = string> = ICommandChildCommands<T> | ICommandChildHandle<T>;
|
|
53
56
|
export interface TextRange {
|
|
54
57
|
start: number;
|
|
55
58
|
end: number;
|
package/esm/commands/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import { insertTextAtPosition } from '../utils/InsertTextAtPosition';
|
|
2
3
|
import { bold } from './bold';
|
|
3
4
|
import { code, codeBlock } from './code';
|
|
@@ -79,10 +80,11 @@ class TextAreaCommandOrchestrator {
|
|
|
79
80
|
return getStateFromTextArea(this.textArea);
|
|
80
81
|
}
|
|
81
82
|
executeCommand(command, dispatch, state, shortcuts) {
|
|
82
|
-
command.execute && command.execute(
|
|
83
|
+
command.execute && command.execute(_extends({
|
|
84
|
+
command
|
|
85
|
+
}, getStateFromTextArea(this.textArea)), this.textApi, dispatch, state, shortcuts);
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
export { title, title1, title2, title3, title4, title5, title6, bold, codeBlock, comment, italic, strikethrough, hr, group, divider, link, quote, code, image, unorderedListCommand, orderedListCommand, checkedListCommand, codeEdit, codeLive, codePreview, fullscreen,
|
|
86
89
|
// Tool method.
|
|
87
|
-
getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi };
|
|
88
|
-
//# sourceMappingURL=index.js.map
|
|
90
|
+
getCommands, getExtraCommands, getStateFromTextArea, TextAreaCommandOrchestrator, TextAreaTextApi };
|
package/esm/commands/italic.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var italic = {
|
|
5
5
|
name: 'italic',
|
|
6
6
|
keyCommand: 'italic',
|
|
7
7
|
shortcuts: 'ctrlcmd+i',
|
|
8
|
-
value: '*
|
|
8
|
+
value: '*{{text}}*',
|
|
9
9
|
buttonProps: {
|
|
10
10
|
'aria-label': 'Add italic text (ctrl + i)',
|
|
11
11
|
title: 'Add italic text (ctrl + i)'
|
|
@@ -28,13 +28,15 @@ export var italic = {
|
|
|
28
28
|
selection: state.selection
|
|
29
29
|
});
|
|
30
30
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
31
|
-
// Replaces the current selection with the
|
|
32
|
-
var
|
|
33
|
-
|
|
31
|
+
// Replaces the current selection with the bold mark up
|
|
32
|
+
var val = state.command.value || '';
|
|
33
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
34
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
35
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
36
|
+
// Adjust the selection to not contain the **
|
|
34
37
|
api.setSelectionRange({
|
|
35
|
-
start
|
|
36
|
-
end
|
|
38
|
+
start,
|
|
39
|
+
end
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=italic.js.map
|
|
42
|
+
};
|
package/esm/commands/link.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } 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
|
-
value: '[](
|
|
8
|
+
value: '[{{text}}](URL Here)',
|
|
9
9
|
buttonProps: {
|
|
10
10
|
'aria-label': 'Add a link (ctrl + l)',
|
|
11
11
|
title: 'Add a link (ctrl + l)'
|
|
@@ -28,13 +28,15 @@ export var link = {
|
|
|
28
28
|
selection: state.selection
|
|
29
29
|
});
|
|
30
30
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
31
|
+
var val = state.command.value || '';
|
|
31
32
|
// Replaces the current selection with the bold mark up
|
|
32
|
-
|
|
33
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
34
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
35
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
33
36
|
// Adjust the selection to not contain the **
|
|
34
37
|
api.setSelectionRange({
|
|
35
|
-
start
|
|
36
|
-
end
|
|
38
|
+
start,
|
|
39
|
+
end
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=link.js.map
|
|
42
|
+
};
|
package/esm/commands/list.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ICommand, TextState, TextAreaTextApi } from './';
|
|
2
|
-
export
|
|
2
|
+
export type AlterLineFunction = (line: string, index: number) => string;
|
|
3
3
|
/**
|
|
4
4
|
* Inserts insertionString before each line
|
|
5
5
|
*/
|
package/esm/commands/list.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord, getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
/**
|
|
@@ -118,5 +118,4 @@ export var checkedListCommand = {
|
|
|
118
118
|
execute: (state, api) => {
|
|
119
119
|
makeList(state, api, (item, index) => "- [ ] ");
|
|
120
120
|
}
|
|
121
|
-
};
|
|
122
|
-
//# sourceMappingURL=list.js.map
|
|
121
|
+
};
|
package/esm/commands/preview.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
export var codePreview = {
|
|
@@ -90,5 +90,4 @@ export var codeLive = {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
};
|
|
94
|
-
//# sourceMappingURL=preview.js.map
|
|
93
|
+
};
|
package/esm/commands/quote.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { getBreaksNeededForEmptyLineBefore, getBreaksNeededForEmptyLineAfter, selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var quote = {
|
|
@@ -39,5 +39,4 @@ export var quote = {
|
|
|
39
39
|
end: selectionEnd
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL=quote.js.map
|
|
42
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { selectWord } from '../utils/markdownUtils';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var 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
|
-
value: '~~',
|
|
12
|
+
value: '~~{{text}}~~',
|
|
13
13
|
icon: /*#__PURE__*/_jsx("svg", {
|
|
14
14
|
"data-name": "strikethrough",
|
|
15
15
|
width: "12",
|
|
@@ -28,13 +28,15 @@ export var strikethrough = {
|
|
|
28
28
|
selection: state.selection
|
|
29
29
|
});
|
|
30
30
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
31
|
-
// Replaces the current selection with the
|
|
32
|
-
var
|
|
33
|
-
|
|
31
|
+
// Replaces the current selection with the bold mark up
|
|
32
|
+
var val = state.command.value || '';
|
|
33
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
34
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
35
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
36
|
+
// Adjust the selection to not contain the **
|
|
34
37
|
api.setSelectionRange({
|
|
35
|
-
start
|
|
36
|
-
end
|
|
38
|
+
start,
|
|
39
|
+
end
|
|
37
40
|
});
|
|
38
41
|
}
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=strikeThrough.js.map
|
|
42
|
+
};
|
package/esm/commands/title.js
CHANGED
|
@@ -12,5 +12,4 @@ export var title = _extends({}, title1, {
|
|
|
12
12
|
d: "M15.7083333,468 C7.03242448,468 0,462.030833 0,454.666667 L0,421.333333 C0,413.969167 7.03242448,408 15.7083333,408 L361.291667,408 C369.967576,408 377,413.969167 377,421.333333 L377,454.666667 C377,462.030833 369.967576,468 361.291667,468 L15.7083333,468 Z M21.6666667,366 C9.69989583,366 0,359.831861 0,352.222222 L0,317.777778 C0,310.168139 9.69989583,304 21.6666667,304 L498.333333,304 C510.300104,304 520,310.168139 520,317.777778 L520,352.222222 C520,359.831861 510.300104,366 498.333333,366 L21.6666667,366 Z M136.835938,64 L136.835937,126 L107.25,126 L107.25,251 L40.75,251 L40.75,126 L-5.68434189e-14,126 L-5.68434189e-14,64 L136.835938,64 Z M212,64 L212,251 L161.648438,251 L161.648438,64 L212,64 Z M378,64 L378,126 L343.25,126 L343.25,251 L281.75,251 L281.75,126 L238,126 L238,64 L378,64 Z M449.047619,189.550781 L520,189.550781 L520,251 L405,251 L405,64 L449.047619,64 L449.047619,189.550781 Z"
|
|
13
13
|
})
|
|
14
14
|
})
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=title.js.map
|
|
15
|
+
});
|
package/esm/commands/title1.js
CHANGED
package/esm/commands/title2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title2 = {
|
|
@@ -24,5 +24,4 @@ export var title2 = {
|
|
|
24
24
|
insertAtLineStart('## ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title2.js.map
|
|
27
|
+
};
|
package/esm/commands/title3.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title3 = {
|
|
@@ -24,5 +24,4 @@ export var title3 = {
|
|
|
24
24
|
insertAtLineStart('### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title3.js.map
|
|
27
|
+
};
|
package/esm/commands/title4.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title4 = {
|
|
@@ -24,5 +24,4 @@ export var title4 = {
|
|
|
24
24
|
insertAtLineStart('#### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title4.js.map
|
|
27
|
+
};
|
package/esm/commands/title5.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title5 = {
|
|
@@ -24,5 +24,4 @@ export var title5 = {
|
|
|
24
24
|
insertAtLineStart('##### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title5.js.map
|
|
27
|
+
};
|
package/esm/commands/title6.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { insertAtLineStart } from '../utils/InsertTextAtPosition';
|
|
3
3
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
export var title6 = {
|
|
@@ -24,5 +24,4 @@ export var title6 = {
|
|
|
24
24
|
insertAtLineStart('###### ', state.selection.start, api.textArea);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=title6.js.map
|
|
27
|
+
};
|
|
@@ -4,7 +4,7 @@ import { TextAreaProps } from './Textarea';
|
|
|
4
4
|
import { IProps } from '../../Editor';
|
|
5
5
|
import { TextAreaCommandOrchestrator, ICommand } from '../../commands';
|
|
6
6
|
import './index.less';
|
|
7
|
-
|
|
7
|
+
type RenderTextareaHandle = {
|
|
8
8
|
dispatch: ContextStore['dispatch'];
|
|
9
9
|
onChange?: TextAreaProps['onChange'];
|
|
10
10
|
useContext?: {
|
|
@@ -19,7 +19,7 @@ export interface ITextAreaProps extends Omit<React.TextareaHTMLAttributes<HTMLTe
|
|
|
19
19
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
20
20
|
renderTextarea?: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement> | React.HTMLAttributes<HTMLDivElement>, opts: RenderTextareaHandle) => JSX.Element;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
22
|
+
export type TextAreaRef = {
|
|
23
23
|
text?: HTMLTextAreaElement;
|
|
24
24
|
warp?: HTMLDivElement;
|
|
25
25
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { ICommand, TextAreaCommandOrchestrator } from '../../commands';
|
|
2
3
|
import { ContextStore, ExecuteCommandState } from '../../Context';
|
|
3
4
|
export default function shortcutsHandle(e: KeyboardEvent | React.KeyboardEvent<HTMLTextAreaElement>, commands?: ICommand[], commandOrchestrator?: TextAreaCommandOrchestrator, dispatch?: React.Dispatch<ContextStore>, state?: ExecuteCommandState): void;
|
package/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="react-scripts" />
|