@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/lib/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/lib/Context.js
CHANGED
package/lib/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/lib/Editor.js
CHANGED
|
@@ -166,6 +166,18 @@ var InternalMDEditor = function InternalMDEditor(props, ref) {
|
|
|
166
166
|
(0, _react.useMemo)(function () {
|
|
167
167
|
return height !== state.height && onHeightChange && onHeightChange(state.height, height, state);
|
|
168
168
|
}, [height, onHeightChange, state]);
|
|
169
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
|
+
(0, _react.useMemo)(function () {
|
|
171
|
+
return commands !== state.commands && dispatch({
|
|
172
|
+
commands: cmds
|
|
173
|
+
});
|
|
174
|
+
}, [props.commands]);
|
|
175
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
176
|
+
(0, _react.useMemo)(function () {
|
|
177
|
+
return extraCommands !== state.extraCommands && dispatch({
|
|
178
|
+
extraCommands: extraCmds
|
|
179
|
+
});
|
|
180
|
+
}, [props.extraCommands]);
|
|
169
181
|
var textareaDomRef = (0, _react.useRef)();
|
|
170
182
|
var active = (0, _react.useRef)('preview');
|
|
171
183
|
var initScroll = (0, _react.useRef)(false);
|
|
@@ -293,5 +305,4 @@ var mdEditor = /*#__PURE__*/_react["default"].forwardRef(InternalMDEditor);
|
|
|
293
305
|
mdEditor.Markdown = _reactMarkdownPreview["default"];
|
|
294
306
|
var _default = mdEditor;
|
|
295
307
|
exports["default"] = _default;
|
|
296
|
-
module.exports = exports.default;
|
|
297
|
-
//# sourceMappingURL=Editor.js.map
|
|
308
|
+
module.exports = exports.default;
|
package/lib/commands/bold.js
CHANGED
|
@@ -12,7 +12,7 @@ var bold = {
|
|
|
12
12
|
name: 'bold',
|
|
13
13
|
keyCommand: 'bold',
|
|
14
14
|
shortcuts: 'ctrlcmd+b',
|
|
15
|
-
value: '**',
|
|
15
|
+
value: '**{{text}}**',
|
|
16
16
|
buttonProps: {
|
|
17
17
|
'aria-label': 'Add bold text (ctrl + b)',
|
|
18
18
|
title: 'Add bold text (ctrl + b)'
|
|
@@ -28,7 +28,6 @@ var bold = {
|
|
|
28
28
|
})
|
|
29
29
|
}),
|
|
30
30
|
execute: function execute(state, api) {
|
|
31
|
-
var _state1$selectedText;
|
|
32
31
|
// Adjust the selection to encompass the whole word if the caret is inside one
|
|
33
32
|
var newSelectionRange = (0, _markdownUtils.selectWord)({
|
|
34
33
|
text: state.text,
|
|
@@ -36,13 +35,15 @@ var bold = {
|
|
|
36
35
|
});
|
|
37
36
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
38
37
|
// Replaces the current selection with the bold mark up
|
|
39
|
-
var
|
|
38
|
+
var val = state.command.value || '';
|
|
39
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
40
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
41
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
40
42
|
// Adjust the selection to not contain the **
|
|
41
43
|
api.setSelectionRange({
|
|
42
|
-
start:
|
|
43
|
-
end:
|
|
44
|
+
start: start,
|
|
45
|
+
end: end
|
|
44
46
|
});
|
|
45
47
|
}
|
|
46
48
|
};
|
|
47
|
-
exports.bold = bold;
|
|
48
|
-
//# sourceMappingURL=bold.js.map
|
|
49
|
+
exports.bold = bold;
|
package/lib/commands/code.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.codeBlock = exports.code = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var code = {
|
|
@@ -100,5 +100,4 @@ var codeBlock = {
|
|
|
100
100
|
});
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
-
exports.codeBlock = codeBlock;
|
|
104
|
-
//# sourceMappingURL=code.js.map
|
|
103
|
+
exports.codeBlock = codeBlock;
|
package/lib/commands/comment.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.comment = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
8
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
11
|
var comment = {
|
|
@@ -55,5 +57,4 @@ var comment = {
|
|
|
55
57
|
})
|
|
56
58
|
})
|
|
57
59
|
};
|
|
58
|
-
exports.comment = comment;
|
|
59
|
-
//# sourceMappingURL=comment.js.map
|
|
60
|
+
exports.comment = comment;
|
package/lib/commands/divider.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.fullscreen = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
var fullscreen = {
|
|
11
11
|
name: 'fullscreen',
|
|
@@ -34,5 +34,4 @@ var fullscreen = {
|
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
exports.fullscreen = fullscreen;
|
|
38
|
-
//# sourceMappingURL=fullscreen.js.map
|
|
37
|
+
exports.fullscreen = fullscreen;
|
package/lib/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/lib/commands/group.js
CHANGED
package/lib/commands/hr.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.hr = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
var hr = {
|
|
11
11
|
name: 'hr',
|
|
@@ -27,8 +27,7 @@ var hr = {
|
|
|
27
27
|
})
|
|
28
28
|
}),
|
|
29
29
|
execute: function execute(state, api) {
|
|
30
|
-
api.replaceSelection("".concat(state.selectedText, "\n\n
|
|
30
|
+
api.replaceSelection("".concat(state.selectedText, "\n\n").concat(state.command.value || '', "-\n\n"));
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
exports.hr = hr;
|
|
34
|
-
//# sourceMappingURL=hr.js.map
|
|
33
|
+
exports.hr = hr;
|
package/lib/commands/image.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.image = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var image = {
|
|
12
12
|
name: 'image',
|
|
13
13
|
keyCommand: 'image',
|
|
14
14
|
shortcuts: 'ctrlcmd+k',
|
|
15
|
-
value: '![image]()',
|
|
15
|
+
value: '',
|
|
16
16
|
buttonProps: {
|
|
17
17
|
'aria-label': 'Add image (ctrl + k)',
|
|
18
18
|
title: 'Add image (ctrl + k)'
|
|
@@ -35,13 +35,17 @@ var image = {
|
|
|
35
35
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
36
36
|
// Replaces the current selection with the image
|
|
37
37
|
var imageTemplate = state1.selectedText || 'https://example.com/your-image.png';
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
var val = state.command.value || '';
|
|
39
|
+
api.replaceSelection(val.replace(/({{text}})/gi, imageTemplate));
|
|
40
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
41
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
42
|
+
if (!state1.selectedText) {
|
|
43
|
+
end = end + imageTemplate.length;
|
|
44
|
+
}
|
|
40
45
|
api.setSelectionRange({
|
|
41
|
-
start:
|
|
42
|
-
end:
|
|
46
|
+
start: start,
|
|
47
|
+
end: end
|
|
43
48
|
});
|
|
44
49
|
}
|
|
45
50
|
};
|
|
46
|
-
exports.image = image;
|
|
47
|
-
//# sourceMappingURL=image.js.map
|
|
51
|
+
exports.image = image;
|
package/lib/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/lib/commands/index.js
CHANGED
|
@@ -163,6 +163,7 @@ Object.defineProperty(exports, "unorderedListCommand", {
|
|
|
163
163
|
return _list.unorderedListCommand;
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
166
167
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
167
168
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
168
169
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -266,10 +267,11 @@ var TextAreaCommandOrchestrator = /*#__PURE__*/function () {
|
|
|
266
267
|
}, {
|
|
267
268
|
key: "executeCommand",
|
|
268
269
|
value: function executeCommand(command, dispatch, state, shortcuts) {
|
|
269
|
-
command.execute && command.execute(
|
|
270
|
+
command.execute && command.execute((0, _objectSpread2["default"])({
|
|
271
|
+
command: command
|
|
272
|
+
}, getStateFromTextArea(this.textArea)), this.textApi, dispatch, state, shortcuts);
|
|
270
273
|
}
|
|
271
274
|
}]);
|
|
272
275
|
return TextAreaCommandOrchestrator;
|
|
273
276
|
}();
|
|
274
|
-
exports.TextAreaCommandOrchestrator = TextAreaCommandOrchestrator;
|
|
275
|
-
//# sourceMappingURL=index.js.map
|
|
277
|
+
exports.TextAreaCommandOrchestrator = TextAreaCommandOrchestrator;
|
package/lib/commands/italic.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.italic = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var italic = {
|
|
12
12
|
name: 'italic',
|
|
13
13
|
keyCommand: 'italic',
|
|
14
14
|
shortcuts: 'ctrlcmd+i',
|
|
15
|
-
value: '*
|
|
15
|
+
value: '*{{text}}*',
|
|
16
16
|
buttonProps: {
|
|
17
17
|
'aria-label': 'Add italic text (ctrl + i)',
|
|
18
18
|
title: 'Add italic text (ctrl + i)'
|
|
@@ -35,14 +35,16 @@ var italic = {
|
|
|
35
35
|
selection: state.selection
|
|
36
36
|
});
|
|
37
37
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
38
|
-
// Replaces the current selection with the
|
|
39
|
-
var
|
|
40
|
-
|
|
38
|
+
// Replaces the current selection with the bold mark up
|
|
39
|
+
var val = state.command.value || '';
|
|
40
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
41
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
42
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
43
|
+
// Adjust the selection to not contain the **
|
|
41
44
|
api.setSelectionRange({
|
|
42
|
-
start:
|
|
43
|
-
end:
|
|
45
|
+
start: start,
|
|
46
|
+
end: end
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
|
-
exports.italic = italic;
|
|
48
|
-
//# sourceMappingURL=italic.js.map
|
|
50
|
+
exports.italic = italic;
|
package/lib/commands/link.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.link = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var link = {
|
|
12
12
|
name: 'link',
|
|
13
13
|
keyCommand: 'link',
|
|
14
14
|
shortcuts: 'ctrlcmd+l',
|
|
15
|
-
value: '[](
|
|
15
|
+
value: '[{{text}}](URL Here)',
|
|
16
16
|
buttonProps: {
|
|
17
17
|
'aria-label': 'Add a link (ctrl + l)',
|
|
18
18
|
title: 'Add a link (ctrl + l)'
|
|
@@ -35,14 +35,16 @@ var link = {
|
|
|
35
35
|
selection: state.selection
|
|
36
36
|
});
|
|
37
37
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
38
|
+
var val = state.command.value || '';
|
|
38
39
|
// Replaces the current selection with the bold mark up
|
|
39
|
-
|
|
40
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
41
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
42
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
40
43
|
// Adjust the selection to not contain the **
|
|
41
44
|
api.setSelectionRange({
|
|
42
|
-
start:
|
|
43
|
-
end:
|
|
45
|
+
start: start,
|
|
46
|
+
end: end
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
|
-
exports.link = link;
|
|
48
|
-
//# sourceMappingURL=link.js.map
|
|
50
|
+
exports.link = link;
|
package/lib/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/lib/commands/list.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.checkedListCommand = void 0;
|
|
8
8
|
exports.insertBeforeEachLine = insertBeforeEachLine;
|
|
9
9
|
exports.unorderedListCommand = exports.orderedListCommand = exports.makeList = void 0;
|
|
10
|
-
var
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
/**
|
|
@@ -135,5 +135,4 @@ var checkedListCommand = {
|
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
|
-
exports.checkedListCommand = checkedListCommand;
|
|
139
|
-
//# sourceMappingURL=list.js.map
|
|
138
|
+
exports.checkedListCommand = checkedListCommand;
|
package/lib/commands/preview.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.codePreview = exports.codeLive = exports.codeEdit = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
10
|
var codePreview = {
|
|
11
11
|
name: 'preview',
|
|
@@ -99,5 +99,4 @@ var codeLive = {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
exports.codeLive = codeLive;
|
|
103
|
-
//# sourceMappingURL=preview.js.map
|
|
102
|
+
exports.codeLive = codeLive;
|
package/lib/commands/quote.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.quote = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var quote = {
|
|
@@ -47,5 +47,4 @@ var quote = {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
exports.quote = quote;
|
|
51
|
-
//# sourceMappingURL=quote.js.map
|
|
50
|
+
exports.quote = quote;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.strikethrough = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _markdownUtils = require("../utils/markdownUtils");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var strikethrough = {
|
|
@@ -16,7 +16,7 @@ var strikethrough = {
|
|
|
16
16
|
'aria-label': 'Add strikethrough text (ctrl + shift + x)',
|
|
17
17
|
title: 'Add strikethrough text (ctrl + shift + x)'
|
|
18
18
|
},
|
|
19
|
-
value: '~~',
|
|
19
|
+
value: '~~{{text}}~~',
|
|
20
20
|
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
|
|
21
21
|
"data-name": "strikethrough",
|
|
22
22
|
width: "12",
|
|
@@ -35,14 +35,16 @@ var strikethrough = {
|
|
|
35
35
|
selection: state.selection
|
|
36
36
|
});
|
|
37
37
|
var state1 = api.setSelectionRange(newSelectionRange);
|
|
38
|
-
// Replaces the current selection with the
|
|
39
|
-
var
|
|
40
|
-
|
|
38
|
+
// Replaces the current selection with the bold mark up
|
|
39
|
+
var val = state.command.value || '';
|
|
40
|
+
api.replaceSelection(val.replace(/({{text}})/gi, state1.selectedText));
|
|
41
|
+
var start = state1.selection.start + val.indexOf('{{text}}');
|
|
42
|
+
var end = state1.selection.start + val.indexOf('{{text}}') + (state1.selection.end - state1.selection.start);
|
|
43
|
+
// Adjust the selection to not contain the **
|
|
41
44
|
api.setSelectionRange({
|
|
42
|
-
start:
|
|
43
|
-
end:
|
|
45
|
+
start: start,
|
|
46
|
+
end: end
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
49
|
};
|
|
47
|
-
exports.strikethrough = strikethrough;
|
|
48
|
-
//# sourceMappingURL=strikeThrough.js.map
|
|
50
|
+
exports.strikethrough = strikethrough;
|
package/lib/commands/title.js
CHANGED
package/lib/commands/title1.js
CHANGED
package/lib/commands/title2.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.title2 = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var title2 = {
|
|
@@ -32,5 +32,4 @@ var title2 = {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
exports.title2 = title2;
|
|
36
|
-
//# sourceMappingURL=title2.js.map
|
|
35
|
+
exports.title2 = title2;
|
package/lib/commands/title3.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.title3 = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var title3 = {
|
|
@@ -32,5 +32,4 @@ var title3 = {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
exports.title3 = title3;
|
|
36
|
-
//# sourceMappingURL=title3.js.map
|
|
35
|
+
exports.title3 = title3;
|
package/lib/commands/title4.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.title4 = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var title4 = {
|
|
@@ -32,5 +32,4 @@ var title4 = {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
exports.title4 = title4;
|
|
36
|
-
//# sourceMappingURL=title4.js.map
|
|
35
|
+
exports.title4 = title4;
|
package/lib/commands/title5.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.title5 = void 0;
|
|
8
|
-
var
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _InsertTextAtPosition = require("../utils/InsertTextAtPosition");
|
|
10
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
11
|
var title5 = {
|
|
@@ -32,5 +32,4 @@ var title5 = {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
exports.title5 = title5;
|
|
36
|
-
//# sourceMappingURL=title5.js.map
|
|
35
|
+
exports.title5 = title5;
|