@gravity-ui/markdown-editor 14.8.0 → 14.10.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/README.md +16 -14
- package/build/cjs/bundle/Editor.d.ts +2 -0
- package/build/cjs/bundle/Editor.js +15 -4
- package/build/cjs/bundle/MarkdownEditorView.d.ts +27 -0
- package/build/cjs/bundle/MarkdownEditorView.js +19 -2
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/action-names.js +51 -27
- package/build/cjs/bundle/config/index.d.ts +3 -0
- package/build/cjs/bundle/config/index.js +3 -0
- package/build/cjs/bundle/config/markup.js +3 -0
- package/build/cjs/bundle/config/wysiwyg.d.ts +3 -0
- package/build/cjs/bundle/toolbar/utils/flattenPreset.d.ts +2 -0
- package/build/cjs/bundle/toolbar/utils/flattenPreset.js +14 -0
- package/build/cjs/bundle/toolbar/utils/toolbarsConfigs.d.ts +17 -0
- package/build/cjs/bundle/toolbar/utils/toolbarsConfigs.js +60 -0
- package/build/cjs/bundle/types.d.ts +6 -0
- package/build/cjs/bundle/useMarkdownEditor.js +8 -2
- package/build/cjs/bundle/wysiwyg-preset.d.ts +1 -0
- package/build/cjs/bundle/wysiwyg-preset.js +1 -1
- package/build/cjs/core/Editor.d.ts +3 -1
- package/build/cjs/core/Editor.js +2 -1
- package/build/cjs/core/ExtensionsManager.d.ts +2 -0
- package/build/cjs/core/ExtensionsManager.js +8 -4
- package/build/cjs/core/ParserTokensRegistry.d.ts +2 -1
- package/build/cjs/core/ParserTokensRegistry.js +2 -2
- package/build/cjs/core/markdown/MarkdownParser.d.ts +3 -1
- package/build/cjs/core/markdown/MarkdownParser.js +5 -2
- package/build/cjs/core/markdown/MarkdownSerializer.js +1 -1
- package/build/cjs/core/markdown/ProseMirrorTransformer/emptyRowTransformer.d.ts +2 -0
- package/build/cjs/core/markdown/ProseMirrorTransformer/emptyRowTransformer.js +15 -0
- package/build/cjs/core/markdown/ProseMirrorTransformer/getTransformers.d.ts +7 -0
- package/build/cjs/core/markdown/ProseMirrorTransformer/getTransformers.js +13 -0
- package/build/cjs/core/markdown/ProseMirrorTransformer/index.d.ts +15 -0
- package/build/cjs/core/markdown/ProseMirrorTransformer/index.js +25 -0
- package/build/cjs/extensions/additional/Math/MathSpecs/index.js +1 -0
- package/build/cjs/extensions/base/BaseSchema/BaseSchemaSpecs/index.d.ts +1 -0
- package/build/cjs/extensions/base/BaseSchema/BaseSchemaSpecs/index.js +23 -3
- package/build/cjs/extensions/behavior/Selection/selection.js +1 -5
- package/build/cjs/extensions/markdown/Blockquote/BlockquoteSpecs/index.js +1 -0
- package/build/cjs/extensions/markdown/CodeBlock/commands.js +1 -1
- package/build/cjs/extensions/markdown/HorizontalRule/HorizontalRuleSpecs/index.js +1 -0
- package/build/cjs/extensions/markdown/Link/paste-plugin.js +21 -5
- package/build/cjs/extensions/yfm/YfmTabs/YfmTabsSpecs/schema.js +1 -0
- package/build/cjs/i18n/empty-row/en.json +3 -0
- package/build/cjs/i18n/empty-row/index.d.ts +5 -0
- package/build/cjs/i18n/empty-row/index.js +9 -0
- package/build/cjs/i18n/empty-row/ru.json +3 -0
- package/build/cjs/i18n/menubar/en.json +1 -0
- package/build/cjs/i18n/menubar/index.d.ts +2 -1
- package/build/cjs/i18n/menubar/ru.json +1 -0
- package/build/cjs/i18n/yfm-note/index.d.ts +1 -1
- package/build/cjs/index.d.ts +1 -0
- package/build/cjs/index.js +1 -0
- package/build/cjs/markup/codemirror/autocomplete/emptyRow.d.ts +9 -0
- package/build/cjs/markup/codemirror/autocomplete/emptyRow.js +26 -0
- package/build/cjs/markup/codemirror/autocomplete/index.d.ts +5 -0
- package/build/cjs/markup/codemirror/autocomplete/index.js +14 -0
- package/build/cjs/markup/codemirror/create.d.ts +1 -0
- package/build/cjs/markup/codemirror/create.js +30 -12
- package/build/cjs/markup/codemirror/smart-reindent/index.d.ts +4 -0
- package/build/cjs/markup/codemirror/smart-reindent/index.js +42 -0
- package/build/cjs/markup/codemirror/smart-reindent/utils.d.ts +15 -0
- package/build/cjs/markup/codemirror/smart-reindent/utils.js +59 -0
- package/build/cjs/markup/codemirror/yfm.d.ts +2 -1
- package/build/cjs/markup/codemirror/yfm.js +3 -3
- package/build/cjs/markup/commands/emptyRow.d.ts +2 -0
- package/build/cjs/markup/commands/emptyRow.js +43 -0
- package/build/cjs/markup/commands/index.d.ts +1 -0
- package/build/cjs/markup/commands/index.js +1 -0
- package/build/cjs/modules/toolbars/constants.d.ts +13 -0
- package/build/cjs/modules/toolbars/constants.js +18 -0
- package/build/cjs/modules/toolbars/items.d.ts +127 -0
- package/build/cjs/modules/toolbars/items.js +736 -0
- package/build/cjs/modules/toolbars/presets.d.ts +6 -0
- package/build/cjs/modules/toolbars/presets.js +465 -0
- package/build/cjs/modules/toolbars/types.d.ts +62 -0
- package/build/cjs/modules/toolbars/types.js +2 -0
- package/build/cjs/shortcuts/const.d.ts +1 -0
- package/build/cjs/shortcuts/const.js +1 -0
- package/build/cjs/shortcuts/default.js +1 -0
- package/build/cjs/toolbar/types.d.ts +8 -0
- package/build/cjs/toolbar/types.js +2 -0
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.d.ts +2 -0
- package/build/esm/bundle/Editor.js +15 -4
- package/build/esm/bundle/MarkdownEditorView.d.ts +27 -0
- package/build/esm/bundle/MarkdownEditorView.js +19 -2
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/action-names.js +51 -27
- package/build/esm/bundle/config/index.d.ts +3 -0
- package/build/esm/bundle/config/index.js +3 -0
- package/build/esm/bundle/config/markup.js +3 -0
- package/build/esm/bundle/config/wysiwyg.d.ts +3 -0
- package/build/esm/bundle/toolbar/utils/flattenPreset.d.ts +2 -0
- package/build/esm/bundle/toolbar/utils/flattenPreset.js +10 -0
- package/build/esm/bundle/toolbar/utils/toolbarsConfigs.d.ts +17 -0
- package/build/esm/bundle/toolbar/utils/toolbarsConfigs.js +55 -0
- package/build/esm/bundle/types.d.ts +6 -0
- package/build/esm/bundle/useMarkdownEditor.js +8 -2
- package/build/esm/bundle/wysiwyg-preset.d.ts +1 -0
- package/build/esm/bundle/wysiwyg-preset.js +1 -1
- package/build/esm/core/Editor.d.ts +3 -1
- package/build/esm/core/Editor.js +2 -1
- package/build/esm/core/ExtensionsManager.d.ts +2 -0
- package/build/esm/core/ExtensionsManager.js +8 -4
- package/build/esm/core/ParserTokensRegistry.d.ts +2 -1
- package/build/esm/core/ParserTokensRegistry.js +2 -2
- package/build/esm/core/markdown/MarkdownParser.d.ts +3 -1
- package/build/esm/core/markdown/MarkdownParser.js +5 -2
- package/build/esm/core/markdown/MarkdownSerializer.js +1 -1
- package/build/esm/core/markdown/ProseMirrorTransformer/emptyRowTransformer.d.ts +2 -0
- package/build/esm/core/markdown/ProseMirrorTransformer/emptyRowTransformer.js +11 -0
- package/build/esm/core/markdown/ProseMirrorTransformer/getTransformers.d.ts +7 -0
- package/build/esm/core/markdown/ProseMirrorTransformer/getTransformers.js +9 -0
- package/build/esm/core/markdown/ProseMirrorTransformer/index.d.ts +15 -0
- package/build/esm/core/markdown/ProseMirrorTransformer/index.js +21 -0
- package/build/esm/extensions/additional/Math/MathSpecs/index.js +1 -0
- package/build/esm/extensions/base/BaseSchema/BaseSchemaSpecs/index.d.ts +1 -0
- package/build/esm/extensions/base/BaseSchema/BaseSchemaSpecs/index.js +23 -3
- package/build/esm/extensions/behavior/Selection/selection.js +1 -5
- package/build/esm/extensions/markdown/Blockquote/BlockquoteSpecs/index.js +1 -0
- package/build/esm/extensions/markdown/CodeBlock/commands.js +1 -1
- package/build/esm/extensions/markdown/HorizontalRule/HorizontalRuleSpecs/index.js +1 -0
- package/build/esm/extensions/markdown/Link/paste-plugin.js +21 -5
- package/build/esm/extensions/yfm/YfmTabs/YfmTabsSpecs/schema.js +1 -0
- package/build/esm/i18n/empty-row/en.json +3 -0
- package/build/esm/i18n/empty-row/index.d.ts +5 -0
- package/build/esm/i18n/empty-row/index.js +5 -0
- package/build/esm/i18n/empty-row/ru.json +3 -0
- package/build/esm/i18n/menubar/en.json +1 -0
- package/build/esm/i18n/menubar/index.d.ts +2 -1
- package/build/esm/i18n/menubar/ru.json +1 -0
- package/build/esm/i18n/yfm-note/index.d.ts +1 -1
- package/build/esm/index.d.ts +1 -0
- package/build/esm/index.js +1 -0
- package/build/esm/markup/codemirror/autocomplete/emptyRow.d.ts +9 -0
- package/build/esm/markup/codemirror/autocomplete/emptyRow.js +23 -0
- package/build/esm/markup/codemirror/autocomplete/index.d.ts +5 -0
- package/build/esm/markup/codemirror/autocomplete/index.js +10 -0
- package/build/esm/markup/codemirror/create.d.ts +1 -0
- package/build/esm/markup/codemirror/create.js +31 -13
- package/build/esm/markup/codemirror/smart-reindent/index.d.ts +4 -0
- package/build/esm/markup/codemirror/smart-reindent/index.js +38 -0
- package/build/esm/markup/codemirror/smart-reindent/utils.d.ts +15 -0
- package/build/esm/markup/codemirror/smart-reindent/utils.js +55 -0
- package/build/esm/markup/codemirror/yfm.d.ts +2 -1
- package/build/esm/markup/codemirror/yfm.js +1 -1
- package/build/esm/markup/commands/emptyRow.d.ts +2 -0
- package/build/esm/markup/commands/emptyRow.js +39 -0
- package/build/esm/markup/commands/index.d.ts +1 -0
- package/build/esm/markup/commands/index.js +1 -0
- package/build/esm/modules/toolbars/constants.d.ts +13 -0
- package/build/esm/modules/toolbars/constants.js +15 -0
- package/build/esm/modules/toolbars/items.d.ts +127 -0
- package/build/esm/modules/toolbars/items.js +730 -0
- package/build/esm/modules/toolbars/presets.d.ts +6 -0
- package/build/esm/modules/toolbars/presets.js +462 -0
- package/build/esm/modules/toolbars/types.d.ts +62 -0
- package/build/esm/modules/toolbars/types.js +1 -0
- package/build/esm/shortcuts/const.d.ts +1 -0
- package/build/esm/shortcuts/const.js +1 -0
- package/build/esm/shortcuts/default.js +1 -0
- package/build/esm/toolbar/types.d.ts +8 -0
- package/build/esm/toolbar/types.js +2 -0
- package/build/esm/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -52,15 +52,21 @@ function Editor({onSubmit}) {
|
|
|
52
52
|
}
|
|
53
53
|
```
|
|
54
54
|
Read more:
|
|
55
|
-
- [How to connect the editor in the Create React App](https://
|
|
56
|
-
- [How to add preview for markup mode](https://
|
|
57
|
-
- [How to add HTML extension](https://
|
|
58
|
-
- [How to add Latex extension](https://
|
|
59
|
-
- [How to add Mermaid extension](https://
|
|
60
|
-
- [How to write extension](https://
|
|
61
|
-
- [How to add GPT extension](https://
|
|
62
|
-
- [How to add text binding extension in markdown](https://
|
|
55
|
+
- [How to connect the editor in the Create React App](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-install-create-react-app--docs)
|
|
56
|
+
- [How to add preview for markup mode](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-develop-preview--docs)
|
|
57
|
+
- [How to add HTML extension](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-connect-html-block--docs)
|
|
58
|
+
- [How to add Latex extension](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-connect-latex-extension--docs)
|
|
59
|
+
- [How to add Mermaid extension](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-connect-mermaid-extension--docs)
|
|
60
|
+
- [How to write extension](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-develop-extension-creation--docs)
|
|
61
|
+
- [How to add GPT extension](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-connect-gpt--docs)
|
|
62
|
+
- [How to add text binding extension in markdown](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-develop-extension-with-popup--docs)
|
|
63
|
+
|
|
64
|
+
### Development
|
|
65
|
+
To start the dev storybook
|
|
63
66
|
|
|
67
|
+
```shell
|
|
68
|
+
npm start
|
|
69
|
+
```
|
|
64
70
|
|
|
65
71
|
|
|
66
72
|
### i18n
|
|
@@ -77,10 +83,6 @@ configure({
|
|
|
77
83
|
|
|
78
84
|
Don't forget to call `configure()` from [UIKit](https://github.com/gravity-ui/uikit?tab=readme-ov-file#i18n) and other UI libraries.
|
|
79
85
|
|
|
80
|
-
|
|
86
|
+
### Contributing
|
|
81
87
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
```shell
|
|
85
|
-
npm start
|
|
86
|
-
```
|
|
88
|
+
- [Contributor Guidelines](https://preview.gravity-ui.com/md-editor/?path=/docs/docs-contributing--docs)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TransformFn } from 'src/core/markdown/ProseMirrorTransformer';
|
|
1
2
|
import type { CommonEditor } from '../common';
|
|
2
3
|
import { ReactRenderStorage } from '../extensions';
|
|
3
4
|
import { type Receiver } from '../utils';
|
|
@@ -43,5 +44,6 @@ export declare type EditorOptions = Pick<MarkdownEditorOptions, 'md' | 'initial'
|
|
|
43
44
|
renderStorage: ReactRenderStorage;
|
|
44
45
|
preset: EditorPreset;
|
|
45
46
|
directiveSyntax: DirectiveSyntaxContext;
|
|
47
|
+
pmTransformers: TransformFn[];
|
|
46
48
|
};
|
|
47
49
|
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_mdOptions, _EditorImpl_preset, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_parseInsertedUrlAsImage, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_enableNewImageSizeCalculation, _EditorImpl_directiveSyntax, _EditorImpl_prepareRawMarkup, _EditorImpl_beforeEditorModeChange;
|
|
2
|
+
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_mdOptions, _EditorImpl_pmTransformers, _EditorImpl_preserveEmptyRows, _EditorImpl_preset, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_parseInsertedUrlAsImage, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_enableNewImageSizeCalculation, _EditorImpl_directiveSyntax, _EditorImpl_prepareRawMarkup, _EditorImpl_beforeEditorModeChange;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.EditorImpl = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const view_1 = require("@codemirror/view");
|
|
7
7
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
8
|
+
const autocomplete_1 = require("../../src/markup/codemirror/autocomplete");
|
|
8
9
|
const core_1 = require("../core");
|
|
9
10
|
const bundle_1 = require("../i18n/bundle");
|
|
10
11
|
const logger_1 = require("../logger");
|
|
@@ -27,6 +28,8 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
27
28
|
_EditorImpl_markupConfig.set(this, void 0);
|
|
28
29
|
_EditorImpl_escapeConfig.set(this, void 0);
|
|
29
30
|
_EditorImpl_mdOptions.set(this, void 0);
|
|
31
|
+
_EditorImpl_pmTransformers.set(this, []);
|
|
32
|
+
_EditorImpl_preserveEmptyRows.set(this, void 0);
|
|
30
33
|
_EditorImpl_preset.set(this, void 0);
|
|
31
34
|
_EditorImpl_extensions.set(this, void 0);
|
|
32
35
|
_EditorImpl_renderStorage.set(this, void 0);
|
|
@@ -46,6 +49,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
46
49
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_renderPreview, markupConfig.renderPreview, "f");
|
|
47
50
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_markup, (_e = initial.markup) !== null && _e !== void 0 ? _e : '', "f");
|
|
48
51
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_preset, (_f = opts.preset) !== null && _f !== void 0 ? _f : 'full', "f");
|
|
52
|
+
tslib_1.__classPrivateFieldSet(this, _EditorImpl_pmTransformers, opts.pmTransformers, "f");
|
|
49
53
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_mdOptions, md, "f");
|
|
50
54
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_extensions, wysiwygConfig.extensions, "f");
|
|
51
55
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_markupConfig, Object.assign({}, opts.markupConfig), "f");
|
|
@@ -55,6 +59,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
55
59
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_needToSetDimensionsForUploadedImages, Boolean(experimental.needToSetDimensionsForUploadedImages), "f");
|
|
56
60
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_directiveSyntax, opts.directiveSyntax, "f");
|
|
57
61
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_enableNewImageSizeCalculation, Boolean(experimental.enableNewImageSizeCalculation), "f");
|
|
62
|
+
tslib_1.__classPrivateFieldSet(this, _EditorImpl_preserveEmptyRows, experimental.preserveEmptyRows || false, "f");
|
|
58
63
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_prepareRawMarkup, experimental.prepareRawMarkup, "f");
|
|
59
64
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_escapeConfig, wysiwygConfig.escapeConfig, "f");
|
|
60
65
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_beforeEditorModeChange, experimental.beforeEditorModeChange, "f");
|
|
@@ -146,6 +151,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
146
151
|
mdPreset,
|
|
147
152
|
initialContent: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markup, "f"),
|
|
148
153
|
extensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_extensions, "f"),
|
|
154
|
+
pmTransformers: tslib_1.__classPrivateFieldGet(this, _EditorImpl_pmTransformers, "f"),
|
|
149
155
|
allowHTML: tslib_1.__classPrivateFieldGet(this, _EditorImpl_mdOptions, "f").html,
|
|
150
156
|
linkify: tslib_1.__classPrivateFieldGet(this, _EditorImpl_mdOptions, "f").linkify,
|
|
151
157
|
linkifyTlds: tslib_1.__classPrivateFieldGet(this, _EditorImpl_mdOptions, "f").linkifyTlds,
|
|
@@ -157,7 +163,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
157
163
|
return tslib_1.__classPrivateFieldGet(this, _EditorImpl_wysiwygEditor, "f");
|
|
158
164
|
}
|
|
159
165
|
get markupEditor() {
|
|
160
|
-
var _a;
|
|
166
|
+
var _a, _b;
|
|
161
167
|
if (!tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupEditor, "f")) {
|
|
162
168
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_markupEditor, new editor_1.Editor((0, markup_1.createCodemirror)({
|
|
163
169
|
doc: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markup, "f"),
|
|
@@ -176,7 +182,12 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
176
182
|
extensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").extensions,
|
|
177
183
|
disabledExtensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
|
|
178
184
|
keymaps: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
|
|
179
|
-
|
|
185
|
+
preserveEmptyRows: tslib_1.__classPrivateFieldGet(this, _EditorImpl_preserveEmptyRows, "f"),
|
|
186
|
+
yfmLangOptions: {
|
|
187
|
+
languageData: (0, autocomplete_1.getAutocompleteConfig)({
|
|
188
|
+
preserveEmptyRows: tslib_1.__classPrivateFieldGet(this, _EditorImpl_preserveEmptyRows, "f"),
|
|
189
|
+
}).concat(((_b = tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f")) === null || _b === void 0 ? void 0 : _b.languageData) || []),
|
|
190
|
+
},
|
|
180
191
|
autocompletion: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").autocompletion,
|
|
181
192
|
directiveSyntax: this.directiveSyntax,
|
|
182
193
|
receiver: this,
|
|
@@ -319,7 +330,7 @@ class EditorImpl extends utils_1.SafeEventEmitter {
|
|
|
319
330
|
}
|
|
320
331
|
}
|
|
321
332
|
exports.EditorImpl = EditorImpl;
|
|
322
|
-
_EditorImpl_markup = new WeakMap(), _EditorImpl_editorMode = new WeakMap(), _EditorImpl_toolbarVisible = new WeakMap(), _EditorImpl_splitModeEnabled = new WeakMap(), _EditorImpl_splitMode = new WeakMap(), _EditorImpl_renderPreview = new WeakMap(), _EditorImpl_wysiwygEditor = new WeakMap(), _EditorImpl_markupEditor = new WeakMap(), _EditorImpl_markupConfig = new WeakMap(), _EditorImpl_escapeConfig = new WeakMap(), _EditorImpl_mdOptions = new WeakMap(), _EditorImpl_preset = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_parseInsertedUrlAsImage = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_enableNewImageSizeCalculation = new WeakMap(), _EditorImpl_directiveSyntax = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
333
|
+
_EditorImpl_markup = new WeakMap(), _EditorImpl_editorMode = new WeakMap(), _EditorImpl_toolbarVisible = new WeakMap(), _EditorImpl_splitModeEnabled = new WeakMap(), _EditorImpl_splitMode = new WeakMap(), _EditorImpl_renderPreview = new WeakMap(), _EditorImpl_wysiwygEditor = new WeakMap(), _EditorImpl_markupEditor = new WeakMap(), _EditorImpl_markupConfig = new WeakMap(), _EditorImpl_escapeConfig = new WeakMap(), _EditorImpl_mdOptions = new WeakMap(), _EditorImpl_pmTransformers = new WeakMap(), _EditorImpl_preserveEmptyRows = new WeakMap(), _EditorImpl_preset = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_parseInsertedUrlAsImage = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_enableNewImageSizeCalculation = new WeakMap(), _EditorImpl_directiveSyntax = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
323
334
|
function getTopOffset(elem) {
|
|
324
335
|
const TOOLBAR_HEIGHT = 36; //px
|
|
325
336
|
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
@@ -1,15 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ToasterPublicMethods } from '@gravity-ui/uikit';
|
|
3
3
|
import { ClassNameProps } from '../classname';
|
|
4
|
+
import type { ToolbarsPreset } from '../modules/toolbars/types';
|
|
4
5
|
import type { Editor } from './Editor';
|
|
5
6
|
import { MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData } from './config';
|
|
6
7
|
export declare const cnEditorComponent: import("@bem-react/classname").ClassNameFormatter;
|
|
7
8
|
export declare type MarkdownEditorViewProps = ClassNameProps & {
|
|
8
9
|
editor?: Editor;
|
|
9
10
|
autofocus?: boolean;
|
|
11
|
+
toolbarsPreset?: ToolbarsPreset;
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated use `toolbarsPreset` instead
|
|
14
|
+
*/
|
|
10
15
|
markupToolbarConfig?: MToolbarData;
|
|
16
|
+
/**
|
|
17
|
+
* @deprecated use `toolbarsPreset` instead
|
|
18
|
+
*/
|
|
11
19
|
wysiwygToolbarConfig?: WToolbarData;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated use `toolbarsPreset` instead
|
|
22
|
+
*/
|
|
12
23
|
markupHiddenActionsConfig?: MToolbarItemData[];
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated use `toolbarsPreset` instead
|
|
26
|
+
*/
|
|
13
27
|
wysiwygHiddenActionsConfig?: WToolbarItemData[];
|
|
14
28
|
/** @default true */
|
|
15
29
|
settingsVisible?: boolean;
|
|
@@ -21,9 +35,22 @@ export declare type MarkdownEditorViewProps = ClassNameProps & {
|
|
|
21
35
|
export declare const MarkdownEditorView: React.ForwardRefExoticComponent<ClassNameProps & {
|
|
22
36
|
editor?: Editor | undefined;
|
|
23
37
|
autofocus?: boolean | undefined;
|
|
38
|
+
toolbarsPreset?: ToolbarsPreset | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated use `toolbarsPreset` instead
|
|
41
|
+
*/
|
|
24
42
|
markupToolbarConfig?: MToolbarData | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated use `toolbarsPreset` instead
|
|
45
|
+
*/
|
|
25
46
|
wysiwygToolbarConfig?: WToolbarData | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* @deprecated use `toolbarsPreset` instead
|
|
49
|
+
*/
|
|
26
50
|
markupHiddenActionsConfig?: MToolbarItemData[] | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated use `toolbarsPreset` instead
|
|
53
|
+
*/
|
|
27
54
|
wysiwygHiddenActionsConfig?: WToolbarItemData[] | undefined;
|
|
28
55
|
/** @default true */
|
|
29
56
|
settingsVisible?: boolean | undefined;
|
|
@@ -14,10 +14,10 @@ const HorizontalDrag_1 = require("./HorizontalDrag");
|
|
|
14
14
|
const MarkupEditorView_1 = require("./MarkupEditorView");
|
|
15
15
|
const SplitModeView_1 = require("./SplitModeView");
|
|
16
16
|
const WysiwygEditorView_1 = require("./WysiwygEditorView");
|
|
17
|
-
const config_1 = require("./config");
|
|
18
17
|
const context_1 = require("./context");
|
|
19
18
|
const settings_1 = require("./settings");
|
|
20
19
|
const sticky_1 = require("./sticky");
|
|
20
|
+
const toolbarsConfigs_1 = require("./toolbar/utils/toolbarsConfigs");
|
|
21
21
|
// eslint-disable-line import/order
|
|
22
22
|
exports.cnEditorComponent = (0, classname_1.cn)('editor-component');
|
|
23
23
|
const b = exports.cnEditorComponent;
|
|
@@ -33,7 +33,24 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
33
33
|
const editor = ((_a = props.editor) !== null && _a !== void 0 ? _a : context);
|
|
34
34
|
if (!editor)
|
|
35
35
|
throw new Error('[MarkdownEditorView]: an instance of the editor must be passed through the props or context');
|
|
36
|
-
const { autofocus, className, settingsVisible = true,
|
|
36
|
+
const { autofocus, className, settingsVisible = true, toolbarsPreset, toaster, stickyToolbar, wysiwygToolbarConfig: initialWysiwygToolbarConfig, markupToolbarConfig: initialMarkupToolbarConfig, wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig, markupHiddenActionsConfig: initialMarkupHiddenActionsConfig, enableSubmitInPreview = true, hidePreviewAfterSubmit = false, } = props;
|
|
37
|
+
const { wysiwygToolbarConfig, markupToolbarConfig, wysiwygHiddenActionsConfig, markupHiddenActionsConfig, } = (0, react_1.useMemo)(() => (0, toolbarsConfigs_1.getToolbarsConfigs)({
|
|
38
|
+
toolbarsPreset,
|
|
39
|
+
props: {
|
|
40
|
+
wysiwygToolbarConfig: initialWysiwygToolbarConfig,
|
|
41
|
+
markupToolbarConfig: initialMarkupToolbarConfig,
|
|
42
|
+
wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig,
|
|
43
|
+
markupHiddenActionsConfig: initialMarkupHiddenActionsConfig,
|
|
44
|
+
},
|
|
45
|
+
preset: editor.preset,
|
|
46
|
+
}), [
|
|
47
|
+
toolbarsPreset,
|
|
48
|
+
initialWysiwygToolbarConfig,
|
|
49
|
+
initialMarkupToolbarConfig,
|
|
50
|
+
initialWysiwygHiddenActionsConfig,
|
|
51
|
+
initialMarkupHiddenActionsConfig,
|
|
52
|
+
editor.preset,
|
|
53
|
+
]);
|
|
37
54
|
const rerender = (0, react_use_1.useUpdate)();
|
|
38
55
|
react_1.default.useLayoutEffect(() => {
|
|
39
56
|
editor.on('rerender', rerender);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const namesObj: Record<"bold" | "mono" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "paragraph" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "file" | "checkbox" | "emoji" | "
|
|
1
|
+
declare const namesObj: Record<"bold" | "colorify" | "mono" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "block" | "paragraph" | "cut" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "note" | "file" | "codeBlock" | "checkbox" | "emoji" | "bulletList" | "codeInline" | "filePopup" | "gpt" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "emptyRow" | "horizontalrule" | "horizontalRule" | "imagePopup" | "liftListItem" | "math_block" | "mathBlock" | "math_inline" | "mathInline" | "mermaid" | "orderedList" | "redo" | "sinkListItem" | "tabs" | "undo" | "yfm_block" | "yfm_cut" | "yfm_html_block" | "htmlBlock" | "yfm_layout" | "layout" | "yfm_note", string>;
|
|
2
2
|
export declare const ActionName: Readonly<typeof namesObj>;
|
|
3
3
|
export {};
|
|
@@ -2,46 +2,70 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActionName = void 0;
|
|
4
4
|
const names = [
|
|
5
|
-
'
|
|
6
|
-
'redo',
|
|
5
|
+
'anchor',
|
|
7
6
|
'bold',
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
|
|
7
|
+
'bulletList',
|
|
8
|
+
'checkbox',
|
|
9
|
+
/** @deprecated use codeBlock */
|
|
10
|
+
'code_block',
|
|
11
|
+
'codeBlock',
|
|
12
|
+
/** @deprecated use codeInline */
|
|
13
|
+
'code_inline',
|
|
14
|
+
'codeInline',
|
|
15
|
+
'colorify',
|
|
16
|
+
'emoji',
|
|
17
|
+
'file',
|
|
18
|
+
'filePopup',
|
|
19
|
+
'gpt',
|
|
14
20
|
'heading1',
|
|
15
21
|
'heading2',
|
|
16
22
|
'heading3',
|
|
17
23
|
'heading4',
|
|
18
24
|
'heading5',
|
|
19
25
|
'heading6',
|
|
20
|
-
'
|
|
21
|
-
|
|
26
|
+
'emptyRow',
|
|
27
|
+
/** @deprecated use horizontalRule */
|
|
28
|
+
'horizontalrule',
|
|
29
|
+
'horizontalRule',
|
|
30
|
+
'image',
|
|
31
|
+
'imagePopup',
|
|
32
|
+
'italic',
|
|
22
33
|
'liftListItem',
|
|
23
|
-
'sinkListItem',
|
|
24
|
-
'checkbox',
|
|
25
34
|
'link',
|
|
35
|
+
'mark',
|
|
36
|
+
/** @deprecated use mathBlock */
|
|
37
|
+
'math_block',
|
|
38
|
+
'mathBlock',
|
|
39
|
+
/** @deprecated use mathInline */
|
|
40
|
+
'math_inline',
|
|
41
|
+
'mathInline',
|
|
42
|
+
'mermaid',
|
|
43
|
+
'mono',
|
|
44
|
+
'orderedList',
|
|
45
|
+
'paragraph',
|
|
26
46
|
'quote',
|
|
27
|
-
'
|
|
28
|
-
'
|
|
47
|
+
'redo',
|
|
48
|
+
'sinkListItem',
|
|
49
|
+
'strike',
|
|
50
|
+
'table',
|
|
51
|
+
'tabs',
|
|
52
|
+
'underline',
|
|
53
|
+
'undo',
|
|
54
|
+
/** @deprecated use block */
|
|
29
55
|
'yfm_block',
|
|
56
|
+
'block',
|
|
57
|
+
/** @deprecated use cut */
|
|
58
|
+
'yfm_cut',
|
|
59
|
+
'cut',
|
|
60
|
+
/** @deprecated use htmlBlock */
|
|
30
61
|
'yfm_html_block',
|
|
62
|
+
'htmlBlock',
|
|
63
|
+
/** @deprecated use layout */
|
|
31
64
|
'yfm_layout',
|
|
32
|
-
'
|
|
33
|
-
|
|
34
|
-
'
|
|
35
|
-
'
|
|
36
|
-
'horizontalrule',
|
|
37
|
-
'emoji',
|
|
38
|
-
'file',
|
|
39
|
-
'anchor',
|
|
40
|
-
'math_inline',
|
|
41
|
-
'math_block',
|
|
42
|
-
'tabs',
|
|
43
|
-
'mermaid',
|
|
44
|
-
'gpt',
|
|
65
|
+
'layout',
|
|
66
|
+
/** @deprecated use note */
|
|
67
|
+
'yfm_note',
|
|
68
|
+
'note',
|
|
45
69
|
];
|
|
46
70
|
const namesObj = names.reduce((obj, val) => {
|
|
47
71
|
obj[val] = val;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated This file is deprecated. Use ToolbarsPreset instead.
|
|
6
|
+
*/
|
|
4
7
|
tslib_1.__exportStar(require("./wysiwyg"), exports);
|
|
5
8
|
tslib_1.__exportStar(require("./markup"), exports);
|
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.mListMoveListConfig = exports.mListsListConfig = exports.mHeadingListConfig = exports.mLiftListItemData = exports.mSinkListItemData = exports.mOrderedListItemData = exports.mBulletListItemData = exports.mHeading6ItemData = exports.mHeading5ItemData = exports.mHeading4ItemData = exports.mHeading3ItemData = exports.mHeading2ItemData = exports.mHeading1ItemData = exports.mMathListItem = exports.mEmojiItemData = exports.mHruleItemData = exports.mCodeBlockItemData = exports.mCodeblockItemData = exports.mMermaidItemData = exports.mMermaidButton = exports.mYfmHtmlBlockItemData = exports.mYfmHtmlBlockButton = exports.mMathBlockItemData = exports.mMathInlineItemData = exports.mTabsItemData = exports.mFileItemData = exports.mFilePopupData = exports.mImageItemData = exports.mImagePopupData = exports.mCodeItemData = exports.mTableItemData = exports.mTableButton = exports.mNoteItemData = exports.mNoteButton = exports.mCutItemData = exports.mCutButton = exports.mQuoteItemData = exports.mQuoteButton = exports.mLinkItemData = exports.mLinkButton = exports.mCheckboxItemData = exports.mCheckboxButton = exports.mMarkedItemData = exports.mMonospaceItemData = exports.mStrikethroughItemData = exports.mUnderlineItemData = exports.mItalicItemData = exports.mBoldItemData = exports.mRedoItemData = exports.mUndoItemData = void 0;
|
|
4
4
|
exports.mHiddenDataByPreset = exports.mToolbarConfigByPreset = exports.mToolbarConfig = exports.mBiusGroupConfig = exports.mHistoryGroupConfig = exports.mHiddenData = exports.mMathListConfig = exports.mCodeListConfig = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated This file is deprecated. Use ToolbarsPreset instead.
|
|
8
|
+
*/
|
|
6
9
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
7
10
|
const menubar_1 = require("../../i18n/menubar");
|
|
8
11
|
const commands_1 = require("../../markup/commands");
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated This file is deprecated. Use ToolbarsPreset instead.
|
|
3
|
+
*/
|
|
1
4
|
import { ActionStorage } from 'src/core';
|
|
2
5
|
import type { SelectionContextConfig, SelectionContextItemData } from '../../extensions/behavior/SelectionContext';
|
|
3
6
|
import { ToolbarGroupItemData, ToolbarItemData, ToolbarListButtonItemData, ToolbarListItemData, ToolbarSingleItemData } from '../../toolbar';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenPreset = void 0;
|
|
4
|
+
const types_1 = require("../../../toolbar/types");
|
|
5
|
+
const flattenPreset = (config) => {
|
|
6
|
+
return config.flat().reduce((acc, item) => {
|
|
7
|
+
if (item.type === types_1.ToolbarDataType.ListButton && Array.isArray(item.data)) {
|
|
8
|
+
return acc.concat(item.data);
|
|
9
|
+
}
|
|
10
|
+
acc.push(item);
|
|
11
|
+
return acc;
|
|
12
|
+
}, []);
|
|
13
|
+
};
|
|
14
|
+
exports.flattenPreset = flattenPreset;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ToolbarsPreset } from '../../../modules/toolbars/types';
|
|
2
|
+
import type { MToolbarData, WToolbarData } from '../../../toolbar';
|
|
3
|
+
import type { MarkdownEditorViewProps } from '../../MarkdownEditorView';
|
|
4
|
+
import { MarkdownEditorPreset } from '../../types';
|
|
5
|
+
export declare const createToolbarConfig: <T extends MToolbarData | WToolbarData>(editorType: 'wysiwyg' | 'markup', toolbarPreset: ToolbarsPreset | MarkdownEditorPreset, toolbarName: string) => T;
|
|
6
|
+
interface GetToolbarsConfigsArgs {
|
|
7
|
+
toolbarsPreset?: ToolbarsPreset;
|
|
8
|
+
props: Pick<MarkdownEditorViewProps, 'markupToolbarConfig' | 'wysiwygToolbarConfig' | 'wysiwygHiddenActionsConfig' | 'markupHiddenActionsConfig'>;
|
|
9
|
+
preset: MarkdownEditorPreset;
|
|
10
|
+
}
|
|
11
|
+
export declare const getToolbarsConfigs: ({ toolbarsPreset, props, preset }: GetToolbarsConfigsArgs) => {
|
|
12
|
+
wysiwygToolbarConfig: WToolbarData;
|
|
13
|
+
markupToolbarConfig: MToolbarData;
|
|
14
|
+
wysiwygHiddenActionsConfig: import("../../config/wysiwyg").WToolbarItemData[];
|
|
15
|
+
markupHiddenActionsConfig: import("../../config/markup").MToolbarItemData[];
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getToolbarsConfigs = exports.createToolbarConfig = void 0;
|
|
4
|
+
const constants_1 = require("../../../modules/toolbars/constants");
|
|
5
|
+
const presets_1 = require("../../../modules/toolbars/presets");
|
|
6
|
+
const toolbar_1 = require("../../../toolbar");
|
|
7
|
+
const flattenPreset_1 = require("./flattenPreset");
|
|
8
|
+
const defaultPresets = {
|
|
9
|
+
zero: presets_1.zero,
|
|
10
|
+
commonmark: presets_1.commonmark,
|
|
11
|
+
default: presets_1.defaultPreset,
|
|
12
|
+
yfm: presets_1.yfm,
|
|
13
|
+
full: presets_1.full,
|
|
14
|
+
};
|
|
15
|
+
const transformItem = (type, item, id = 'unknown') => {
|
|
16
|
+
var _a;
|
|
17
|
+
if (!item) {
|
|
18
|
+
console.warn(`Toolbar item "${id}" not found, it might not have been added to the items dictionary.`);
|
|
19
|
+
return {};
|
|
20
|
+
}
|
|
21
|
+
const isListButton = item.view.type === toolbar_1.ToolbarDataType.ListButton;
|
|
22
|
+
return Object.assign(Object.assign(Object.assign({ type: (_a = item.view.type) !== null && _a !== void 0 ? _a : toolbar_1.ToolbarDataType.SingleButton, id, title: item.view.title, hint: item.view.hint, icon: item.view.icon, hotkey: item.view.hotkey }, (isListButton && { withArrow: item.view.withArrow })), (type === 'wysiwyg' && item.wysiwyg && Object.assign({}, item.wysiwyg))), (type === 'markup' && item.markup && Object.assign({}, item.markup)));
|
|
23
|
+
};
|
|
24
|
+
const createToolbarConfig = (editorType, toolbarPreset, toolbarName) => {
|
|
25
|
+
var _a;
|
|
26
|
+
const preset = typeof toolbarPreset === 'string'
|
|
27
|
+
? defaultPresets[toolbarPreset] || defaultPresets.default
|
|
28
|
+
: toolbarPreset;
|
|
29
|
+
const orders = (_a = preset.orders[toolbarName]) !== null && _a !== void 0 ? _a : [[]];
|
|
30
|
+
const { items } = preset;
|
|
31
|
+
const toolbarData = orders.map((group) => group.map((action) => {
|
|
32
|
+
return typeof action === 'string'
|
|
33
|
+
? transformItem(editorType, items[action], action)
|
|
34
|
+
: Object.assign(Object.assign({}, transformItem(editorType, items[action.id], action.id)), { data: action.items.map((id) => transformItem(editorType, items[id], id)) });
|
|
35
|
+
}));
|
|
36
|
+
return toolbarData;
|
|
37
|
+
};
|
|
38
|
+
exports.createToolbarConfig = createToolbarConfig;
|
|
39
|
+
const getToolbarsConfigs = ({ toolbarsPreset, props, preset }) => {
|
|
40
|
+
var _a, _b, _c, _d;
|
|
41
|
+
const wysiwygToolbarConfig = toolbarsPreset
|
|
42
|
+
? (0, exports.createToolbarConfig)('wysiwyg', toolbarsPreset, constants_1.ToolbarName.wysiwygMain)
|
|
43
|
+
: (_a = props.wysiwygToolbarConfig) !== null && _a !== void 0 ? _a : (0, exports.createToolbarConfig)('wysiwyg', preset, constants_1.ToolbarName.wysiwygMain);
|
|
44
|
+
const markupToolbarConfig = toolbarsPreset
|
|
45
|
+
? (0, exports.createToolbarConfig)('markup', toolbarsPreset, constants_1.ToolbarName.markupMain)
|
|
46
|
+
: (_b = props.markupToolbarConfig) !== null && _b !== void 0 ? _b : (0, exports.createToolbarConfig)('markup', preset, constants_1.ToolbarName.markupMain);
|
|
47
|
+
const wysiwygHiddenActionsConfig = toolbarsPreset
|
|
48
|
+
? (0, flattenPreset_1.flattenPreset)((0, exports.createToolbarConfig)('wysiwyg', toolbarsPreset, constants_1.ToolbarName.wysiwygHidden))
|
|
49
|
+
: (_c = props.wysiwygHiddenActionsConfig) !== null && _c !== void 0 ? _c : (0, flattenPreset_1.flattenPreset)((0, exports.createToolbarConfig)('wysiwyg', preset, constants_1.ToolbarName.wysiwygHidden));
|
|
50
|
+
const markupHiddenActionsConfig = toolbarsPreset
|
|
51
|
+
? (0, flattenPreset_1.flattenPreset)((0, exports.createToolbarConfig)('markup', toolbarsPreset, constants_1.ToolbarName.markupHidden))
|
|
52
|
+
: (_d = props.markupHiddenActionsConfig) !== null && _d !== void 0 ? _d : (0, flattenPreset_1.flattenPreset)((0, exports.createToolbarConfig)('markup', preset, constants_1.ToolbarName.markupHidden));
|
|
53
|
+
return {
|
|
54
|
+
wysiwygToolbarConfig,
|
|
55
|
+
markupToolbarConfig,
|
|
56
|
+
wysiwygHiddenActionsConfig,
|
|
57
|
+
markupHiddenActionsConfig,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
exports.getToolbarsConfigs = getToolbarsConfigs;
|
|
@@ -93,6 +93,12 @@ export declare type MarkdownEditorExperimentalOptions = {
|
|
|
93
93
|
* Default value is 'disabled'.
|
|
94
94
|
*/
|
|
95
95
|
directiveSyntax?: DirectiveSyntaxOption;
|
|
96
|
+
/**
|
|
97
|
+
* If we need support for empty strings
|
|
98
|
+
*
|
|
99
|
+
* @default false
|
|
100
|
+
*/
|
|
101
|
+
preserveEmptyRows?: boolean;
|
|
96
102
|
};
|
|
97
103
|
export declare type MarkdownEditorMarkupConfig = {
|
|
98
104
|
/**
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useMarkdownEditor = void 0;
|
|
4
4
|
const react_1 = require("react");
|
|
5
|
+
const getTransformers_1 = require("../core/markdown/ProseMirrorTransformer/getTransformers");
|
|
5
6
|
const extensions_1 = require("../extensions");
|
|
6
7
|
const logger_1 = require("../logger");
|
|
7
8
|
const directive_1 = require("../utils/directive");
|
|
@@ -13,11 +14,15 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
13
14
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
14
15
|
const { md = {}, initial = {}, handlers = {}, experimental = {}, markupConfig = {}, wysiwygConfig = {}, } = props;
|
|
15
16
|
const breaks = (_a = md.breaks) !== null && _a !== void 0 ? _a : props.breaks;
|
|
17
|
+
const preserveEmptyRows = experimental.preserveEmptyRows;
|
|
16
18
|
const preset = (_b = props.preset) !== null && _b !== void 0 ? _b : 'full';
|
|
17
19
|
const renderStorage = new extensions_1.ReactRenderStorage();
|
|
18
20
|
const uploadFile = (_c = handlers.uploadFile) !== null && _c !== void 0 ? _c : props.fileUploadHandler;
|
|
19
21
|
const needToSetDimensionsForUploadedImages = (_d = experimental.needToSetDimensionsForUploadedImages) !== null && _d !== void 0 ? _d : props.needToSetDimensionsForUploadedImages;
|
|
20
22
|
const enableNewImageSizeCalculation = experimental.enableNewImageSizeCalculation;
|
|
23
|
+
const pmTransformers = (0, getTransformers_1.getPMTransformers)({
|
|
24
|
+
emptyRowTransformer: preserveEmptyRows,
|
|
25
|
+
});
|
|
21
26
|
const directiveSyntax = new directive_1.DirectiveSyntaxContext(experimental.directiveSyntax);
|
|
22
27
|
const extensions = (builder) => {
|
|
23
28
|
var _a;
|
|
@@ -29,7 +34,7 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
29
34
|
}, onSubmit: () => {
|
|
30
35
|
editor.emit('submit', null);
|
|
31
36
|
return true;
|
|
32
|
-
}, placeholderOptions: wysiwygConfig.placeholderOptions, mdBreaks: breaks, fileUploadHandler: uploadFile, needToSetDimensionsForUploadedImages,
|
|
37
|
+
}, preserveEmptyRows: preserveEmptyRows, placeholderOptions: wysiwygConfig.placeholderOptions, mdBreaks: breaks, fileUploadHandler: uploadFile, needToSetDimensionsForUploadedImages,
|
|
33
38
|
enableNewImageSizeCalculation }));
|
|
34
39
|
{
|
|
35
40
|
const extraExtensions = wysiwygConfig.extensions || props.extraExtensions;
|
|
@@ -40,7 +45,8 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
40
45
|
};
|
|
41
46
|
return new Editor_1.EditorImpl(Object.assign(Object.assign({}, props), { preset,
|
|
42
47
|
renderStorage,
|
|
43
|
-
directiveSyntax,
|
|
48
|
+
directiveSyntax,
|
|
49
|
+
pmTransformers, md: Object.assign(Object.assign({}, md), { breaks, html: (_e = md.html) !== null && _e !== void 0 ? _e : props.allowHTML, linkify: (_f = md.linkify) !== null && _f !== void 0 ? _f : props.linkify, linkifyTlds: (_g = md.linkifyTlds) !== null && _g !== void 0 ? _g : props.linkifyTlds }), initial: Object.assign(Object.assign({}, initial), { markup: (_h = initial.markup) !== null && _h !== void 0 ? _h : props.initialMarkup, mode: (_j = initial.mode) !== null && _j !== void 0 ? _j : props.initialEditorMode, toolbarVisible: (_k = initial.toolbarVisible) !== null && _k !== void 0 ? _k : props.initialToolbarVisible, splitModeEnabled: (_l = initial.splitModeEnabled) !== null && _l !== void 0 ? _l : props.initialSplitModeEnabled }), handlers: Object.assign(Object.assign({}, handlers), { uploadFile }), experimental: Object.assign(Object.assign({}, experimental), { needToSetDimensionsForUploadedImages,
|
|
44
50
|
enableNewImageSizeCalculation, prepareRawMarkup: (_m = experimental.prepareRawMarkup) !== null && _m !== void 0 ? _m : props.prepareRawMarkup, beforeEditorModeChange: (_o = experimental.beforeEditorModeChange) !== null && _o !== void 0 ? _o : props.experimental_beforeEditorModeChange }), markupConfig: Object.assign(Object.assign({}, markupConfig), { splitMode: (_p = markupConfig.splitMode) !== null && _p !== void 0 ? _p : props.splitMode, renderPreview: (_q = markupConfig.renderPreview) !== null && _q !== void 0 ? _q : props.renderPreview, extensions: (_r = markupConfig.extensions) !== null && _r !== void 0 ? _r : props.extraMarkupExtensions }), wysiwygConfig: Object.assign(Object.assign({}, wysiwygConfig), { extensions, escapeConfig: (_s = wysiwygConfig.escapeConfig) !== null && _s !== void 0 ? _s : props.escapeConfig }) }));
|
|
45
51
|
}, deps);
|
|
46
52
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -9,6 +9,7 @@ export declare type ExtensionsOptions = BehaviorPresetOptions & FullPresetOption
|
|
|
9
9
|
export declare type BundlePresetOptions = ExtensionsOptions & EditorModeKeymapOptions & {
|
|
10
10
|
preset: MarkdownEditorPreset;
|
|
11
11
|
mdBreaks?: boolean;
|
|
12
|
+
preserveEmptyRows?: boolean;
|
|
12
13
|
fileUploadHandler?: FileUploadHandler;
|
|
13
14
|
placeholderOptions?: WysiwygPlaceholderOptions;
|
|
14
15
|
/**
|
|
@@ -34,7 +34,7 @@ const BundlePreset = (builder, opts) => {
|
|
|
34
34
|
return typeof value === 'function'
|
|
35
35
|
? value()
|
|
36
36
|
: value !== null && value !== void 0 ? value : (0, placeholder_1.i18n)('doc_empty');
|
|
37
|
-
} }, opts.baseSchema) });
|
|
37
|
+
}, preserveEmptyRows: opts.preserveEmptyRows }, opts.baseSchema) });
|
|
38
38
|
const commonMarkOptions = Object.assign(Object.assign({}, zeroOptions), { selectionContext: Object.assign({ config: wysiwyg_1.wSelectionMenuConfigByPreset.commonmark }, opts.selectionContext), commandMenu: Object.assign({ actions: wysiwyg_1.wCommandMenuConfigByPreset.commonmark }, opts.commandMenu), breaks: Object.assign({ preferredBreak: (opts.mdBreaks ? 'soft' : 'hard') }, opts.breaks), bold: Object.assign({ boldKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.Bold) }, opts.bold), italic: Object.assign({ italicKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.Italic) }, opts.italic), code: Object.assign({ codeKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.Code) }, opts.code), codeBlock: Object.assign({ codeBlockKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.CodeBlock) }, opts.codeBlock), blockquote: Object.assign({ qouteKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.Quote) }, opts.blockquote), link: Object.assign({ linkKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.Link) }, opts.link), lists: Object.assign({ ulKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.BulletList), olKey: shortcuts_1.formatter.toPM(shortcuts_1.Action.OrderedList), ulInputRules: { plus: false } }, opts.lists), image: {
|
|
39
39
|
parseInsertedUrlAsImage: (_a = opts.imgSize) === null || _a === void 0 ? void 0 : _a.parseInsertedUrlAsImage,
|
|
40
40
|
} });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PresetName } from 'markdown-it';
|
|
2
2
|
import type { CommonEditor, MarkupString } from '../common';
|
|
3
|
+
import { TransformFn } from './markdown/ProseMirrorTransformer';
|
|
3
4
|
import type { ActionStorage } from './types/actions';
|
|
4
5
|
import type { Extension } from './types/extension';
|
|
5
6
|
import type { Parser } from './types/parser';
|
|
@@ -18,6 +19,7 @@ export declare type WysiwygEditorOptions = {
|
|
|
18
19
|
mdPreset?: PresetName;
|
|
19
20
|
allowHTML?: boolean;
|
|
20
21
|
linkify?: boolean;
|
|
22
|
+
pmTransformers?: TransformFn[];
|
|
21
23
|
linkifyTlds?: string | string[];
|
|
22
24
|
escapeConfig?: EscapeConfig;
|
|
23
25
|
/** Call on any state change (move cursor, change selection, etc...) */
|
|
@@ -31,7 +33,7 @@ export declare class WysiwygEditor implements CommonEditor, ActionStorage {
|
|
|
31
33
|
get serializer(): Serializer;
|
|
32
34
|
get parser(): Parser;
|
|
33
35
|
get actions(): WysiwygEditor.Actions;
|
|
34
|
-
constructor({ domElem, initialContent, extensions, allowHTML, mdPreset, linkify, linkifyTlds, escapeConfig, onChange, onDocChange, }: WysiwygEditorOptions);
|
|
36
|
+
constructor({ domElem, initialContent, extensions, allowHTML, mdPreset, linkify, pmTransformers, linkifyTlds, escapeConfig, onChange, onDocChange, }: WysiwygEditorOptions);
|
|
35
37
|
action<T extends keyof WysiwygEditor.Actions>(actionName: T): WysiwygEditor.Actions[T];
|
|
36
38
|
focus(): void;
|
|
37
39
|
hasFocus(): boolean;
|
package/build/cjs/core/Editor.js
CHANGED
|
@@ -10,7 +10,7 @@ const ExtensionsManager_1 = require("./ExtensionsManager");
|
|
|
10
10
|
const actions_1 = require("./utils/actions");
|
|
11
11
|
const metrics_1 = require("./utils/metrics");
|
|
12
12
|
class WysiwygEditor {
|
|
13
|
-
constructor({ domElem, initialContent = '', extensions = () => { }, allowHTML, mdPreset, linkify, linkifyTlds, escapeConfig, onChange, onDocChange, }) {
|
|
13
|
+
constructor({ domElem, initialContent = '', extensions = () => { }, allowHTML, mdPreset, linkify, pmTransformers, linkifyTlds, escapeConfig, onChange, onDocChange, }) {
|
|
14
14
|
_WysiwygEditor_view.set(this, void 0);
|
|
15
15
|
_WysiwygEditor_serializer.set(this, void 0);
|
|
16
16
|
_WysiwygEditor_parser.set(this, void 0);
|
|
@@ -21,6 +21,7 @@ class WysiwygEditor {
|
|
|
21
21
|
// "breaks" option only affects the renderer, but not the parser
|
|
22
22
|
mdOpts: { html: allowHTML, linkify, breaks: true, preset: mdPreset },
|
|
23
23
|
linkifyTlds,
|
|
24
|
+
pmTransformers,
|
|
24
25
|
});
|
|
25
26
|
const state = prosemirror_state_1.EditorState.create({
|
|
26
27
|
schema,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import MarkdownIt, { PresetName } from 'markdown-it';
|
|
2
2
|
import type { Plugin } from 'prosemirror-state';
|
|
3
3
|
import { ActionsManager } from './ActionsManager';
|
|
4
|
+
import { TransformFn } from './markdown/ProseMirrorTransformer';
|
|
4
5
|
import type { ActionSpec } from './types/actions';
|
|
5
6
|
import type { Extension, ExtensionDeps } from './types/extension';
|
|
6
7
|
import type { MarkViewConstructor, NodeViewConstructor } from './types/node-views';
|
|
@@ -13,6 +14,7 @@ declare type ExtensionsManagerOptions = {
|
|
|
13
14
|
preset?: PresetName;
|
|
14
15
|
};
|
|
15
16
|
linkifyTlds?: string | string[];
|
|
17
|
+
pmTransformers?: TransformFn[];
|
|
16
18
|
};
|
|
17
19
|
export declare class ExtensionsManager {
|
|
18
20
|
#private;
|