@gravity-ui/markdown-editor 14.9.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/build/cjs/bundle/Editor.d.ts +2 -0
- package/build/cjs/bundle/Editor.js +15 -4
- package/build/cjs/bundle/MarkdownEditorView.js +2 -2
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/action-names.js +1 -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.js → utils/toolbarsConfigs.js} +15 -19
- 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/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/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 +6 -1
- 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/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/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.js +1 -1
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/action-names.js +1 -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.js → utils/toolbarsConfigs.js} +13 -17
- 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/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/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 +7 -2
- 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/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/version.js +1 -1
- package/package.json +1 -1
- package/build/cjs/bundle/toolbar/utils.d.ts +0 -17
- package/build/esm/bundle/toolbar/utils.d.ts +0 -17
|
@@ -45,6 +45,7 @@ const BaseSchemaSpecs = (builder, opts) => {
|
|
|
45
45
|
0,
|
|
46
46
|
];
|
|
47
47
|
},
|
|
48
|
+
selectable: true,
|
|
48
49
|
placeholder: opts.paragraphPlaceholder
|
|
49
50
|
? {
|
|
50
51
|
content: opts.paragraphPlaceholder,
|
|
@@ -53,9 +54,28 @@ const BaseSchemaSpecs = (builder, opts) => {
|
|
|
53
54
|
: undefined,
|
|
54
55
|
},
|
|
55
56
|
fromMd: { tokenSpec: { name: BaseNode.Paragraph, type: 'block' } },
|
|
56
|
-
toMd: (state, node) => {
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
toMd: (state, node, parent) => {
|
|
58
|
+
/*
|
|
59
|
+
An empty line is added only if there is some content in the parent element.
|
|
60
|
+
This is necessary in order to prevent an empty document with empty lines
|
|
61
|
+
*/
|
|
62
|
+
if (opts.preserveEmptyRows && !node.content.size) {
|
|
63
|
+
let isParentEmpty = true;
|
|
64
|
+
for (let index = 0; index < parent.content.childCount; index++) {
|
|
65
|
+
const parentChild = parent.content.child(index);
|
|
66
|
+
if (parentChild.content.size !== 0 ||
|
|
67
|
+
parentChild.type.name !== 'paragraph') {
|
|
68
|
+
isParentEmpty = false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!isParentEmpty) {
|
|
72
|
+
state.write(' \n\n');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
state.renderInline(node);
|
|
77
|
+
state.closeBlock(node);
|
|
78
|
+
}
|
|
59
79
|
},
|
|
60
80
|
}));
|
|
61
81
|
};
|
|
@@ -74,11 +74,7 @@ const getTopLevelNodesFromSelection = (selection, doc) => {
|
|
|
74
74
|
const { from, to } = selection;
|
|
75
75
|
doc.nodesBetween(from, to, (node, pos) => {
|
|
76
76
|
const withinSelection = from <= pos && pos + node.nodeSize <= to;
|
|
77
|
-
if (node &&
|
|
78
|
-
node.type.name !== 'paragraph' &&
|
|
79
|
-
!node.isText &&
|
|
80
|
-
node.type.spec.selectable &&
|
|
81
|
-
withinSelection) {
|
|
77
|
+
if (node && !node.isText && node.type.spec.selectable !== false && withinSelection) {
|
|
82
78
|
nodes.push({ node, pos });
|
|
83
79
|
return false;
|
|
84
80
|
}
|
|
@@ -20,7 +20,7 @@ const setCodeBlockType = ({ serializer }) => (state, dispatch) => {
|
|
|
20
20
|
if (!(0, prosemirror_commands_1.setBlockType)(nodeType)(state))
|
|
21
21
|
return false;
|
|
22
22
|
if (dispatch) {
|
|
23
|
-
const markup = serializer.serialize(state.selection.content().content);
|
|
23
|
+
const markup = serializer.serialize(state.selection.content().content, { escape: false });
|
|
24
24
|
dispatch(state.tr.replaceSelectionWith(nodeType.createAndFill({}, markup ? state.schema.text(markup) : null)));
|
|
25
25
|
}
|
|
26
26
|
return true;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.i18n = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const i18n_1 = require("../i18n");
|
|
6
|
+
const en_json_1 = tslib_1.__importDefault(require("./en.json"));
|
|
7
|
+
const ru_json_1 = tslib_1.__importDefault(require("./ru.json"));
|
|
8
|
+
const KEYSET = 'empty-row';
|
|
9
|
+
exports.i18n = (0, i18n_1.registerKeyset)(KEYSET, { en: en_json_1.default, ru: ru_json_1.default });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const i18n: <G extends "remove" | "info" | "
|
|
1
|
+
export declare const i18n: <G extends "remove" | "info" | "tip" | "warning" | "alert", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
} | undefined) => S extends G ? {
|
|
4
4
|
info: string;
|
package/build/cjs/index.d.ts
CHANGED
package/build/cjs/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
tslib_1.__exportStar(require("./common"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./core"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./toolbar"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./modules/toolbars/types"), exports);
|
|
8
9
|
tslib_1.__exportStar(require("./react-utils"), exports);
|
|
9
10
|
tslib_1.__exportStar(require("./classname"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./logger"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CompletionContext, CompletionResult } from '@codemirror/autocomplete';
|
|
2
|
+
export declare const emptyRowSnippetTemplate = " \n\n";
|
|
3
|
+
export declare const emptyRowSnippet: (editor: {
|
|
4
|
+
state: import("@codemirror/state").EditorState;
|
|
5
|
+
dispatch: (tr: import("@codemirror/state").Transaction) => void;
|
|
6
|
+
}, completion: import("@codemirror/autocomplete").Completion | null, from: number, to: number) => void;
|
|
7
|
+
export declare const emptyRowAutocomplete: {
|
|
8
|
+
autocomplete: (context: CompletionContext) => CompletionResult | null;
|
|
9
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emptyRowAutocomplete = exports.emptyRowSnippet = exports.emptyRowSnippetTemplate = void 0;
|
|
4
|
+
const autocomplete_1 = require("@codemirror/autocomplete");
|
|
5
|
+
const empty_row_1 = require("../../../../src/i18n/empty-row");
|
|
6
|
+
exports.emptyRowSnippetTemplate = ' \n\n';
|
|
7
|
+
exports.emptyRowSnippet = (0, autocomplete_1.snippet)(exports.emptyRowSnippetTemplate);
|
|
8
|
+
exports.emptyRowAutocomplete = {
|
|
9
|
+
autocomplete: (context) => {
|
|
10
|
+
const word = context.matchBefore(/^.*/);
|
|
11
|
+
if (word === null || word === void 0 ? void 0 : word.text.startsWith('&')) {
|
|
12
|
+
return {
|
|
13
|
+
from: word.from,
|
|
14
|
+
options: [
|
|
15
|
+
{
|
|
16
|
+
label: ' ',
|
|
17
|
+
displayLabel: (0, empty_row_1.i18n)('snippet.text'),
|
|
18
|
+
type: 'text',
|
|
19
|
+
apply: exports.emptyRowSnippet,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAutocompleteConfig = void 0;
|
|
4
|
+
const yfm_1 = require("../yfm");
|
|
5
|
+
const emptyRow_1 = require("./emptyRow");
|
|
6
|
+
const getAutocompleteConfig = ({ preserveEmptyRows }) => {
|
|
7
|
+
const autocompleteItems = [];
|
|
8
|
+
if (preserveEmptyRows) {
|
|
9
|
+
autocompleteItems.push(emptyRow_1.emptyRowAutocomplete);
|
|
10
|
+
}
|
|
11
|
+
autocompleteItems.push(yfm_1.mdAutocomplete);
|
|
12
|
+
return autocompleteItems;
|
|
13
|
+
};
|
|
14
|
+
exports.getAutocompleteConfig = getAutocompleteConfig;
|
|
@@ -33,6 +33,7 @@ export declare type CreateCodemirrorParams = {
|
|
|
33
33
|
yfmLangOptions?: YfmLangOptions;
|
|
34
34
|
autocompletion?: Autocompletion;
|
|
35
35
|
directiveSyntax: DirectiveSyntaxContext;
|
|
36
|
+
preserveEmptyRows: boolean;
|
|
36
37
|
};
|
|
37
38
|
export declare function createCodemirror(params: CreateCodemirrorParams): EditorView;
|
|
38
39
|
export declare function withLogger(action: string, command: StateCommand): StateCommand;
|
|
@@ -20,7 +20,7 @@ const plugin_1 = require("./search-plugin/plugin");
|
|
|
20
20
|
const smart_reindent_1 = require("./smart-reindent");
|
|
21
21
|
const yfm_1 = require("./yfm");
|
|
22
22
|
function createCodemirror(params) {
|
|
23
|
-
const { doc, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, extensions: extraExtensions, placeholder: placeholderContent, autocompletion: autocompletionConfig, parseHtmlOnPaste, parseInsertedUrlAsImage, directiveSyntax, } = params;
|
|
23
|
+
const { doc, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, extensions: extraExtensions, placeholder: placeholderContent, autocompletion: autocompletionConfig, parseHtmlOnPaste, parseInsertedUrlAsImage, directiveSyntax, preserveEmptyRows, } = params;
|
|
24
24
|
const extensions = [gravity_1.gravityTheme, (0, view_1.placeholder)(placeholderContent)];
|
|
25
25
|
if (!disabledExtensions.history) {
|
|
26
26
|
extensions.push((0, commands_1.history)());
|
|
@@ -139,6 +139,11 @@ function createCodemirror(params) {
|
|
|
139
139
|
anchorSelector: '.g-md-search-anchor',
|
|
140
140
|
receiver,
|
|
141
141
|
}));
|
|
142
|
+
if (preserveEmptyRows) {
|
|
143
|
+
extensions.push(view_1.keymap.of([
|
|
144
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.EmptyRow), run: withLogger(action_names_1.ActionName.emptyRow, commands_2.insertEmptyRow) },
|
|
145
|
+
]));
|
|
146
|
+
}
|
|
142
147
|
if (params.uploadHandler) {
|
|
143
148
|
extensions.push(files_upload_facet_1.FileUploadHandlerFacet.of({
|
|
144
149
|
fn: params.uploadHandler,
|
|
@@ -8,7 +8,7 @@ export declare const customTags: {
|
|
|
8
8
|
};
|
|
9
9
|
export declare type YfmNoteType = 'info' | 'tip' | 'warning' | 'alert';
|
|
10
10
|
export declare const yfmNoteTypes: readonly YfmNoteType[];
|
|
11
|
-
export declare const yfmNoteSnippetTemplate: (type: YfmNoteType) => "{% note info %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note
|
|
11
|
+
export declare const yfmNoteSnippetTemplate: (type: YfmNoteType) => "{% note info %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note tip %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note warning %}\n\n#{}\n\n{% endnote %}\n\n" | "{% note alert %}\n\n#{}\n\n{% endnote %}\n\n";
|
|
12
12
|
export declare const yfmNoteSnippets: Record<YfmNoteType, ReturnType<typeof snippet>>;
|
|
13
13
|
export declare const yfmCutSnippetTemplate = "{% cut \"#{title}\" %}\n\n#{}\n\n{% endcut %}\n\n";
|
|
14
14
|
export declare const yfmCutSnippet: (editor: {
|
|
@@ -27,4 +27,5 @@ export interface LanguageData {
|
|
|
27
27
|
export interface YfmLangOptions {
|
|
28
28
|
languageData?: LanguageData[];
|
|
29
29
|
}
|
|
30
|
+
export declare const mdAutocomplete: LanguageData;
|
|
30
31
|
export declare function yfmLang({ languageData }?: YfmLangOptions): Extension;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.yfmLang = exports.yfmCutDirectiveSnippet = exports.yfmCutDirectiveSnippetTemplate = exports.yfmCutSnippet = exports.yfmCutSnippetTemplate = exports.yfmNoteSnippets = exports.yfmNoteSnippetTemplate = exports.yfmNoteTypes = exports.customTags = void 0;
|
|
3
|
+
exports.yfmLang = exports.mdAutocomplete = exports.yfmCutDirectiveSnippet = exports.yfmCutDirectiveSnippetTemplate = exports.yfmCutSnippet = exports.yfmCutSnippetTemplate = exports.yfmNoteSnippets = exports.yfmNoteSnippetTemplate = exports.yfmNoteTypes = exports.customTags = void 0;
|
|
4
4
|
const autocomplete_1 = require("@codemirror/autocomplete");
|
|
5
5
|
const lang_markdown_1 = require("@codemirror/lang-markdown");
|
|
6
6
|
const highlight_1 = require("@lezer/highlight");
|
|
@@ -61,7 +61,7 @@ exports.yfmCutSnippetTemplate = '{% cut "#{title}" %}\n\n#{}\n\n{% endcut %}\n\n
|
|
|
61
61
|
exports.yfmCutSnippet = (0, autocomplete_1.snippet)(exports.yfmCutSnippetTemplate);
|
|
62
62
|
exports.yfmCutDirectiveSnippetTemplate = ':::cut [#{title}]\n#{}\n:::\n\n';
|
|
63
63
|
exports.yfmCutDirectiveSnippet = (0, autocomplete_1.snippet)(exports.yfmCutDirectiveSnippetTemplate);
|
|
64
|
-
|
|
64
|
+
exports.mdAutocomplete = {
|
|
65
65
|
autocomplete: (context) => {
|
|
66
66
|
const directiveContext = context.state.facet(directive_facet_1.DirectiveSyntaxFacet);
|
|
67
67
|
// TODO: add more actions and re-enable
|
|
@@ -139,7 +139,7 @@ function yfmLang({ languageData = [] } = {}) {
|
|
|
139
139
|
});
|
|
140
140
|
return [
|
|
141
141
|
mdSupport,
|
|
142
|
-
mdSupport.language.data.of(mdAutocomplete),
|
|
142
|
+
mdSupport.language.data.of(exports.mdAutocomplete),
|
|
143
143
|
languageData.map((item) => mdSupport.language.data.of(item)),
|
|
144
144
|
];
|
|
145
145
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insertEmptyRow = void 0;
|
|
4
|
+
const insertEmptyRow = ({ state, dispatch }) => {
|
|
5
|
+
const emptyRowMarkup = ' ';
|
|
6
|
+
const tr = () => {
|
|
7
|
+
const selrange = state.selection.main;
|
|
8
|
+
const { before, after, selection } = getBlockExtraLineBreaks(state, state.doc.lineAt(selrange.from));
|
|
9
|
+
const insert = state.lineBreak.repeat(before) + emptyRowMarkup + state.lineBreak.repeat(after);
|
|
10
|
+
const from = state.doc.lineAt(selrange.to).to;
|
|
11
|
+
const selAnchor = from + insert.length + selection;
|
|
12
|
+
return { changes: { from, insert }, selection: { anchor: selAnchor } };
|
|
13
|
+
};
|
|
14
|
+
dispatch(state.update(tr()));
|
|
15
|
+
return true;
|
|
16
|
+
};
|
|
17
|
+
exports.insertEmptyRow = insertEmptyRow;
|
|
18
|
+
function getBlockExtraLineBreaks(state, line) {
|
|
19
|
+
let before = 0;
|
|
20
|
+
let after = 0;
|
|
21
|
+
let selection = 2;
|
|
22
|
+
if (line.text) {
|
|
23
|
+
before = 2;
|
|
24
|
+
}
|
|
25
|
+
else if (line.number > 1 && state.doc.line(line.number - 1).text) {
|
|
26
|
+
before = 1;
|
|
27
|
+
}
|
|
28
|
+
if (line.number + 1 <= state.doc.lines && state.doc.line(line.number + 1).text) {
|
|
29
|
+
after = 1;
|
|
30
|
+
selection = 1;
|
|
31
|
+
}
|
|
32
|
+
else if (line.number + 1 <= state.doc.lines &&
|
|
33
|
+
!state.doc.line(line.number + 1).text &&
|
|
34
|
+
line.number + 2 > state.doc.lines) {
|
|
35
|
+
after = 1;
|
|
36
|
+
selection = 1;
|
|
37
|
+
}
|
|
38
|
+
else if (line.number === state.doc.lines) {
|
|
39
|
+
after = 2;
|
|
40
|
+
selection = 0;
|
|
41
|
+
}
|
|
42
|
+
return { before, after, selection };
|
|
43
|
+
}
|
|
@@ -22,6 +22,7 @@ formatter_1.formatter
|
|
|
22
22
|
.set(const_1.Action.Heading4, { pc: [const_1.ModKey.Ctrl, const_1.ModKey.Shift, '4'], mac: [const_1.ModKey.Cmd, const_1.ModKey.Option, '4'] })
|
|
23
23
|
.set(const_1.Action.Heading5, { pc: [const_1.ModKey.Ctrl, const_1.ModKey.Shift, '5'], mac: [const_1.ModKey.Cmd, const_1.ModKey.Option, '5'] })
|
|
24
24
|
.set(const_1.Action.Heading6, { pc: [const_1.ModKey.Ctrl, const_1.ModKey.Shift, '6'], mac: [const_1.ModKey.Cmd, const_1.ModKey.Option, '6'] })
|
|
25
|
+
.set(const_1.Action.EmptyRow, { pc: [const_1.ModKey.Ctrl, const_1.ModKey.Shift, const_1.Key.Enter], mac: [const_1.ModKey.Cmd, const_1.ModKey.Shift, const_1.Key.Enter] })
|
|
25
26
|
.set(const_1.Action.BulletList, [const_1.ModKey.Mod, const_1.ModKey.Shift, 'l'])
|
|
26
27
|
.set(const_1.Action.OrderedList, [const_1.ModKey.Mod, const_1.ModKey.Shift, 'm'])
|
|
27
28
|
.set(const_1.Action.SinkListItem, [const_1.ModKey.Tab])
|
package/build/cjs/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '14.
|
|
5
|
+
exports.VERSION = typeof '14.10.0' !== 'undefined' ? '14.10.0' : 'unknown';
|
|
@@ -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,7 +1,8 @@
|
|
|
1
|
-
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;
|
|
1
|
+
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;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet, __rest } from "tslib";
|
|
3
3
|
import { EditorView as CMEditorView } from '@codemirror/view';
|
|
4
4
|
import { TextSelection } from 'prosemirror-state';
|
|
5
|
+
import { getAutocompleteConfig } from '../../src/markup/codemirror/autocomplete';
|
|
5
6
|
import { WysiwygEditor, } from '../core';
|
|
6
7
|
import { i18n } from '../i18n/bundle';
|
|
7
8
|
import { logger } from '../logger';
|
|
@@ -24,6 +25,8 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
24
25
|
_EditorImpl_markupConfig.set(this, void 0);
|
|
25
26
|
_EditorImpl_escapeConfig.set(this, void 0);
|
|
26
27
|
_EditorImpl_mdOptions.set(this, void 0);
|
|
28
|
+
_EditorImpl_pmTransformers.set(this, []);
|
|
29
|
+
_EditorImpl_preserveEmptyRows.set(this, void 0);
|
|
27
30
|
_EditorImpl_preset.set(this, void 0);
|
|
28
31
|
_EditorImpl_extensions.set(this, void 0);
|
|
29
32
|
_EditorImpl_renderStorage.set(this, void 0);
|
|
@@ -43,6 +46,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
43
46
|
__classPrivateFieldSet(this, _EditorImpl_renderPreview, markupConfig.renderPreview, "f");
|
|
44
47
|
__classPrivateFieldSet(this, _EditorImpl_markup, (_e = initial.markup) !== null && _e !== void 0 ? _e : '', "f");
|
|
45
48
|
__classPrivateFieldSet(this, _EditorImpl_preset, (_f = opts.preset) !== null && _f !== void 0 ? _f : 'full', "f");
|
|
49
|
+
__classPrivateFieldSet(this, _EditorImpl_pmTransformers, opts.pmTransformers, "f");
|
|
46
50
|
__classPrivateFieldSet(this, _EditorImpl_mdOptions, md, "f");
|
|
47
51
|
__classPrivateFieldSet(this, _EditorImpl_extensions, wysiwygConfig.extensions, "f");
|
|
48
52
|
__classPrivateFieldSet(this, _EditorImpl_markupConfig, Object.assign({}, opts.markupConfig), "f");
|
|
@@ -52,6 +56,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
52
56
|
__classPrivateFieldSet(this, _EditorImpl_needToSetDimensionsForUploadedImages, Boolean(experimental.needToSetDimensionsForUploadedImages), "f");
|
|
53
57
|
__classPrivateFieldSet(this, _EditorImpl_directiveSyntax, opts.directiveSyntax, "f");
|
|
54
58
|
__classPrivateFieldSet(this, _EditorImpl_enableNewImageSizeCalculation, Boolean(experimental.enableNewImageSizeCalculation), "f");
|
|
59
|
+
__classPrivateFieldSet(this, _EditorImpl_preserveEmptyRows, experimental.preserveEmptyRows || false, "f");
|
|
55
60
|
__classPrivateFieldSet(this, _EditorImpl_prepareRawMarkup, experimental.prepareRawMarkup, "f");
|
|
56
61
|
__classPrivateFieldSet(this, _EditorImpl_escapeConfig, wysiwygConfig.escapeConfig, "f");
|
|
57
62
|
__classPrivateFieldSet(this, _EditorImpl_beforeEditorModeChange, experimental.beforeEditorModeChange, "f");
|
|
@@ -143,6 +148,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
143
148
|
mdPreset,
|
|
144
149
|
initialContent: __classPrivateFieldGet(this, _EditorImpl_markup, "f"),
|
|
145
150
|
extensions: __classPrivateFieldGet(this, _EditorImpl_extensions, "f"),
|
|
151
|
+
pmTransformers: __classPrivateFieldGet(this, _EditorImpl_pmTransformers, "f"),
|
|
146
152
|
allowHTML: __classPrivateFieldGet(this, _EditorImpl_mdOptions, "f").html,
|
|
147
153
|
linkify: __classPrivateFieldGet(this, _EditorImpl_mdOptions, "f").linkify,
|
|
148
154
|
linkifyTlds: __classPrivateFieldGet(this, _EditorImpl_mdOptions, "f").linkifyTlds,
|
|
@@ -154,7 +160,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
154
160
|
return __classPrivateFieldGet(this, _EditorImpl_wysiwygEditor, "f");
|
|
155
161
|
}
|
|
156
162
|
get markupEditor() {
|
|
157
|
-
var _a;
|
|
163
|
+
var _a, _b;
|
|
158
164
|
if (!__classPrivateFieldGet(this, _EditorImpl_markupEditor, "f")) {
|
|
159
165
|
__classPrivateFieldSet(this, _EditorImpl_markupEditor, new MarkupEditor(createCodemirror({
|
|
160
166
|
doc: __classPrivateFieldGet(this, _EditorImpl_markup, "f"),
|
|
@@ -173,7 +179,12 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
173
179
|
extensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").extensions,
|
|
174
180
|
disabledExtensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
|
|
175
181
|
keymaps: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
|
|
176
|
-
|
|
182
|
+
preserveEmptyRows: __classPrivateFieldGet(this, _EditorImpl_preserveEmptyRows, "f"),
|
|
183
|
+
yfmLangOptions: {
|
|
184
|
+
languageData: getAutocompleteConfig({
|
|
185
|
+
preserveEmptyRows: __classPrivateFieldGet(this, _EditorImpl_preserveEmptyRows, "f"),
|
|
186
|
+
}).concat(((_b = __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f")) === null || _b === void 0 ? void 0 : _b.languageData) || []),
|
|
187
|
+
},
|
|
177
188
|
autocompletion: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").autocompletion,
|
|
178
189
|
directiveSyntax: this.directiveSyntax,
|
|
179
190
|
receiver: this,
|
|
@@ -315,7 +326,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
315
326
|
return (serializedEditorMarkup === null || serializedEditorMarkup === void 0 ? void 0 : serializedEditorMarkup.trim()) !== wysiwygValue.trim();
|
|
316
327
|
}
|
|
317
328
|
}
|
|
318
|
-
_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();
|
|
329
|
+
_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();
|
|
319
330
|
function getTopOffset(elem) {
|
|
320
331
|
const TOOLBAR_HEIGHT = 36; //px
|
|
321
332
|
const TOOLBAR_BOTTOM_OFFSET = 8; // px
|
|
@@ -13,7 +13,7 @@ import { WysiwygEditorView } from './WysiwygEditorView';
|
|
|
13
13
|
import { useMarkdownEditorContext } from './context';
|
|
14
14
|
import { EditorSettings } from './settings';
|
|
15
15
|
import { stickyCn } from './sticky';
|
|
16
|
-
import { getToolbarsConfigs } from './toolbar/utils';
|
|
16
|
+
import { getToolbarsConfigs } from './toolbar/utils/toolbarsConfigs';
|
|
17
17
|
import '../styles/styles.css';
|
|
18
18
|
import './MarkdownEditorView.css'; // eslint-disable-line import/order
|
|
19
19
|
export const cnEditorComponent = cn('editor-component');
|
|
@@ -1,3 +1,3 @@
|
|
|
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" | "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>;
|
|
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 {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ToolbarDataType } from '../../../toolbar/types';
|
|
2
|
+
export const flattenPreset = (config) => {
|
|
3
|
+
return config.flat().reduce((acc, item) => {
|
|
4
|
+
if (item.type === ToolbarDataType.ListButton && Array.isArray(item.data)) {
|
|
5
|
+
return acc.concat(item.data);
|
|
6
|
+
}
|
|
7
|
+
acc.push(item);
|
|
8
|
+
return acc;
|
|
9
|
+
}, []);
|
|
10
|
+
};
|
|
@@ -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 {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ToolbarName } from '
|
|
2
|
-
import { commonmark, defaultPreset, full, yfm, zero } from '
|
|
3
|
-
import { ToolbarDataType } from '
|
|
1
|
+
import { ToolbarName } from '../../../modules/toolbars/constants';
|
|
2
|
+
import { commonmark, defaultPreset, full, yfm, zero } from '../../../modules/toolbars/presets';
|
|
3
|
+
import { ToolbarDataType } from '../../../toolbar';
|
|
4
|
+
import { flattenPreset } from './flattenPreset';
|
|
4
5
|
const defaultPresets = {
|
|
5
6
|
zero,
|
|
6
7
|
commonmark,
|
|
@@ -17,7 +18,7 @@ const transformItem = (type, item, id = 'unknown') => {
|
|
|
17
18
|
const isListButton = item.view.type === ToolbarDataType.ListButton;
|
|
18
19
|
return Object.assign(Object.assign(Object.assign({ type: (_a = item.view.type) !== null && _a !== void 0 ? _a : 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)));
|
|
19
20
|
};
|
|
20
|
-
export const
|
|
21
|
+
export const createToolbarConfig = (editorType, toolbarPreset, toolbarName) => {
|
|
21
22
|
var _a;
|
|
22
23
|
const preset = typeof toolbarPreset === 'string'
|
|
23
24
|
? defaultPresets[toolbarPreset] || defaultPresets.default
|
|
@@ -31,25 +32,20 @@ export const createConfig = (editorType, toolbarPreset, toolbarName) => {
|
|
|
31
32
|
}));
|
|
32
33
|
return toolbarData;
|
|
33
34
|
};
|
|
34
|
-
const flattenPreset = (config) => {
|
|
35
|
-
var _a;
|
|
36
|
-
// TODO: @makhnatkin add logic for flatten
|
|
37
|
-
return ((_a = config[0]) !== null && _a !== void 0 ? _a : []);
|
|
38
|
-
};
|
|
39
35
|
export const getToolbarsConfigs = ({ toolbarsPreset, props, preset }) => {
|
|
40
36
|
var _a, _b, _c, _d;
|
|
41
37
|
const wysiwygToolbarConfig = toolbarsPreset
|
|
42
|
-
?
|
|
43
|
-
: (_a = props.wysiwygToolbarConfig) !== null && _a !== void 0 ? _a :
|
|
38
|
+
? createToolbarConfig('wysiwyg', toolbarsPreset, ToolbarName.wysiwygMain)
|
|
39
|
+
: (_a = props.wysiwygToolbarConfig) !== null && _a !== void 0 ? _a : createToolbarConfig('wysiwyg', preset, ToolbarName.wysiwygMain);
|
|
44
40
|
const markupToolbarConfig = toolbarsPreset
|
|
45
|
-
?
|
|
46
|
-
: (_b = props.markupToolbarConfig) !== null && _b !== void 0 ? _b :
|
|
41
|
+
? createToolbarConfig('markup', toolbarsPreset, ToolbarName.markupMain)
|
|
42
|
+
: (_b = props.markupToolbarConfig) !== null && _b !== void 0 ? _b : createToolbarConfig('markup', preset, ToolbarName.markupMain);
|
|
47
43
|
const wysiwygHiddenActionsConfig = toolbarsPreset
|
|
48
|
-
? flattenPreset(
|
|
49
|
-
: (_c = props.wysiwygHiddenActionsConfig) !== null && _c !== void 0 ? _c : flattenPreset(
|
|
44
|
+
? flattenPreset(createToolbarConfig('wysiwyg', toolbarsPreset, ToolbarName.wysiwygHidden))
|
|
45
|
+
: (_c = props.wysiwygHiddenActionsConfig) !== null && _c !== void 0 ? _c : flattenPreset(createToolbarConfig('wysiwyg', preset, ToolbarName.wysiwygHidden));
|
|
50
46
|
const markupHiddenActionsConfig = toolbarsPreset
|
|
51
|
-
? flattenPreset(
|
|
52
|
-
: (_d = props.markupHiddenActionsConfig) !== null && _d !== void 0 ? _d : flattenPreset(
|
|
47
|
+
? flattenPreset(createToolbarConfig('markup', toolbarsPreset, ToolbarName.markupHidden))
|
|
48
|
+
: (_d = props.markupHiddenActionsConfig) !== null && _d !== void 0 ? _d : flattenPreset(createToolbarConfig('markup', preset, ToolbarName.markupHidden));
|
|
53
49
|
return {
|
|
54
50
|
wysiwygToolbarConfig,
|
|
55
51
|
markupToolbarConfig,
|
|
@@ -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
|
/**
|