@gravity-ui/markdown-editor 13.9.0 → 13.11.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 +4 -0
- package/build/cjs/bundle/Editor.js +2 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.d.ts +3 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.js +4 -2
- package/build/cjs/extensions/yfm/YfmHtmlBlock/index.d.ts +3 -0
- package/build/cjs/extensions/yfm/YfmHtmlBlock/index.js +4 -5
- package/build/cjs/markup/codemirror/create.d.ts +5 -1
- package/build/cjs/markup/codemirror/create.js +48 -57
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.d.ts +4 -0
- package/build/esm/bundle/Editor.js +2 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.d.ts +3 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.js +4 -2
- package/build/esm/extensions/yfm/YfmHtmlBlock/index.d.ts +3 -0
- package/build/esm/extensions/yfm/YfmHtmlBlock/index.js +4 -5
- package/build/esm/markup/codemirror/create.d.ts +5 -1
- package/build/esm/markup/codemirror/create.js +48 -57
- package/build/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -47,6 +47,10 @@ export interface Editor extends Receiver<EventMap>, CommonEditor {
|
|
|
47
47
|
export declare type MarkupConfig = {
|
|
48
48
|
/** Additional extensions for codemirror instance. */
|
|
49
49
|
extensions?: CreateCodemirrorParams['extensions'];
|
|
50
|
+
/** Can be used to disable some of the default extensions */
|
|
51
|
+
disabledExtensions?: CreateCodemirrorParams['disabledExtensions'];
|
|
52
|
+
/** Additional keymaps for codemirror instance */
|
|
53
|
+
keymaps?: CreateCodemirrorParams['keymaps'];
|
|
50
54
|
/**
|
|
51
55
|
* Additional language data for markdown language in codemirror.
|
|
52
56
|
* Can be used to configure additional autocompletions and others.
|
|
@@ -157,6 +157,8 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
157
157
|
uploadHandler: this.fileUploadHandler,
|
|
158
158
|
needImgDimms: this.needToSetDimensionsForUploadedImages,
|
|
159
159
|
extensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").extensions,
|
|
160
|
+
disabledExtensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
|
|
161
|
+
keymaps: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
|
|
160
162
|
yfmLangOptions: { languageData: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").languageData },
|
|
161
163
|
receiver: this,
|
|
162
164
|
})), "f");
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
|
|
1
2
|
import type { ExtensionNodeSpec } from '../../../../core';
|
|
2
3
|
export { yfmHtmlBlockNodeName } from './const';
|
|
3
4
|
export declare type YfmHtmlBlockSpecsOptions = {
|
|
4
5
|
nodeView?: ExtensionNodeSpec['view'];
|
|
5
6
|
sanitize?: (dirtyHtml: string) => string;
|
|
7
|
+
styles?: string | StylesObject;
|
|
8
|
+
baseTarget?: BaseTarget;
|
|
6
9
|
};
|
|
7
10
|
export declare const YfmHtmlBlockSpecs: import("../../../../core").ExtensionWithOptions<YfmHtmlBlockSpecsOptions> & {
|
|
8
11
|
readonly NodeName: "yfm_html_block";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.YfmHtmlBlockSpecs = exports.yfmHtmlBlockNodeName = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
6
|
const html_extension_1 = require("@diplodoc/html-extension");
|
|
6
7
|
const const_1 = require("./const");
|
|
7
8
|
var const_2 = require("./const");
|
|
8
9
|
Object.defineProperty(exports, "yfmHtmlBlockNodeName", { enumerable: true, get: function () { return const_2.yfmHtmlBlockNodeName; } });
|
|
9
|
-
const YfmHtmlBlockSpecsExtension = (builder,
|
|
10
|
+
const YfmHtmlBlockSpecsExtension = (builder, _a) => {
|
|
11
|
+
var { nodeView } = _a, options = tslib_1.__rest(_a, ["nodeView"]);
|
|
10
12
|
builder
|
|
11
|
-
.configureMd((md) => md.use((0, html_extension_1.transform)({ bundle: false,
|
|
13
|
+
.configureMd((md) => md.use((0, html_extension_1.transform)(Object.assign({ bundle: false }, options)), {}))
|
|
12
14
|
.addNode(const_1.YfmHtmlBlockConsts.NodeName, () => ({
|
|
13
15
|
fromMd: {
|
|
14
16
|
tokenSpec: {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
|
|
1
2
|
import type { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
|
|
2
3
|
import { Action, ExtensionAuto } from '../../../core';
|
|
3
4
|
import { YfmHtmlBlockAction } from './YfmHtmlBlockSpecs/const';
|
|
4
5
|
export declare type YfmHtmlBlockOptions = {
|
|
5
6
|
useConfig?: () => IHTMLIFrameElementConfig | undefined;
|
|
6
7
|
sanitize?: (dirtyHtml: string) => string;
|
|
8
|
+
styles?: string | StylesObject;
|
|
9
|
+
baseTarget?: BaseTarget;
|
|
7
10
|
};
|
|
8
11
|
export declare const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions>;
|
|
9
12
|
declare global {
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.YfmHtmlBlock = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const YfmHtmlBlockNodeView_1 = require("./YfmHtmlBlockNodeView");
|
|
5
6
|
const YfmHtmlBlockSpecs_1 = require("./YfmHtmlBlockSpecs");
|
|
6
7
|
const const_1 = require("./YfmHtmlBlockSpecs/const");
|
|
7
8
|
const actions_1 = require("./actions");
|
|
8
|
-
const YfmHtmlBlock = (builder,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
sanitize: options.sanitize,
|
|
12
|
-
});
|
|
9
|
+
const YfmHtmlBlock = (builder, _a) => {
|
|
10
|
+
var { useConfig: _ } = _a, options = tslib_1.__rest(_a, ["useConfig"]);
|
|
11
|
+
builder.use(YfmHtmlBlockSpecs_1.YfmHtmlBlockSpecs, Object.assign({ nodeView: YfmHtmlBlockNodeViewFactory(options) }, options));
|
|
13
12
|
builder.addAction(const_1.YfmHtmlBlockAction, () => actions_1.addYfmHtmlBlock);
|
|
14
13
|
};
|
|
15
14
|
exports.YfmHtmlBlock = YfmHtmlBlock;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Extension, StateCommand } from '@codemirror/state';
|
|
2
|
-
import { EditorView, EditorViewConfig } from '@codemirror/view';
|
|
2
|
+
import { EditorView, EditorViewConfig, KeyBinding } from '@codemirror/view';
|
|
3
3
|
import { EventMap } from '../../bundle/Editor';
|
|
4
4
|
import { ReactRenderStorage } from '../../extensions';
|
|
5
5
|
import { Receiver } from '../../utils';
|
|
@@ -18,6 +18,10 @@ export declare type CreateCodemirrorParams = {
|
|
|
18
18
|
uploadHandler?: FileUploadHandler;
|
|
19
19
|
needImgDimms?: boolean;
|
|
20
20
|
extensions?: Extension[];
|
|
21
|
+
disabledExtensions?: {
|
|
22
|
+
history?: boolean;
|
|
23
|
+
};
|
|
24
|
+
keymaps?: readonly KeyBinding[];
|
|
21
25
|
receiver?: Receiver<EventMap>;
|
|
22
26
|
yfmLangOptions?: YfmLangOptions;
|
|
23
27
|
};
|
|
@@ -16,65 +16,56 @@ const react_facet_1 = require("./react-facet");
|
|
|
16
16
|
const plugin_1 = require("./search-plugin/plugin");
|
|
17
17
|
const yfm_1 = require("./yfm");
|
|
18
18
|
function createCodemirror(params) {
|
|
19
|
-
const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, receiver, yfmLangOptions, } = params;
|
|
20
|
-
const extensions = [
|
|
21
|
-
|
|
22
|
-
(0,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return true;
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Submit),
|
|
51
|
-
preventDefault: true,
|
|
52
|
-
run: () => {
|
|
53
|
-
onSubmit();
|
|
54
|
-
return true;
|
|
55
|
-
},
|
|
19
|
+
const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, } = params;
|
|
20
|
+
const extensions = [gravity_1.gravityTheme, (0, view_1.placeholder)(placeholderText)];
|
|
21
|
+
if (!disabledExtensions.history) {
|
|
22
|
+
extensions.push((0, commands_1.history)());
|
|
23
|
+
}
|
|
24
|
+
extensions.push((0, language_1.syntaxHighlighting)(gravity_1.gravityHighlightStyle), view_1.keymap.of([
|
|
25
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Bold), run: withLogger(action_names_1.ActionName.bold, commands_2.toggleBold) },
|
|
26
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Italic), run: withLogger(action_names_1.ActionName.italic, commands_2.toggleItalic) },
|
|
27
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Strike), run: withLogger(action_names_1.ActionName.strike, commands_2.toggleStrikethrough) },
|
|
28
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Underline), run: withLogger(action_names_1.ActionName.underline, commands_2.toggleUnderline) },
|
|
29
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Link), run: withLogger(action_names_1.ActionName.link, commands_2.insertLink) },
|
|
30
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Heading1), run: withLogger(action_names_1.ActionName.heading1, commands_2.toH1) },
|
|
31
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Heading2), run: withLogger(action_names_1.ActionName.heading2, commands_2.toH2) },
|
|
32
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Heading3), run: withLogger(action_names_1.ActionName.heading3, commands_2.toH3) },
|
|
33
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Heading4), run: withLogger(action_names_1.ActionName.heading4, commands_2.toH4) },
|
|
34
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Heading5), run: withLogger(action_names_1.ActionName.heading5, commands_2.toH5) },
|
|
35
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Heading6), run: withLogger(action_names_1.ActionName.heading6, commands_2.toH6) },
|
|
36
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Code), run: withLogger(action_names_1.ActionName.code_inline, commands_2.wrapToInlineCode) },
|
|
37
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.CodeBlock), run: withLogger(action_names_1.ActionName.code_block, commands_2.wrapToCodeBlock) },
|
|
38
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Cut), run: withLogger(action_names_1.ActionName.yfm_cut, commands_2.wrapToYfmCut) },
|
|
39
|
+
{ key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Note), run: withLogger(action_names_1.ActionName.yfm_note, commands_2.wrapToYfmNote) },
|
|
40
|
+
{
|
|
41
|
+
key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Cancel),
|
|
42
|
+
preventDefault: true,
|
|
43
|
+
run: () => {
|
|
44
|
+
onCancel();
|
|
45
|
+
return true;
|
|
56
46
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
react_facet_1.ReactRendererFacet.of(reactRenderer),
|
|
65
|
-
pairing_chars_1.PairingCharactersExtension,
|
|
66
|
-
view_1.EditorView.lineWrapping,
|
|
67
|
-
view_1.EditorView.contentAttributes.of({ spellcheck: 'true' }),
|
|
68
|
-
view_1.EditorView.domEventHandlers({
|
|
69
|
-
scroll(event) {
|
|
70
|
-
onScroll(event);
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: shortcuts_1.formatter.toCM(shortcuts_1.Action.Submit),
|
|
50
|
+
preventDefault: true,
|
|
51
|
+
run: () => {
|
|
52
|
+
onSubmit();
|
|
53
|
+
return true;
|
|
71
54
|
},
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
55
|
+
},
|
|
56
|
+
{ key: 'Tab', preventDefault: true, run: commands_1.insertTab },
|
|
57
|
+
commands_1.indentWithTab,
|
|
58
|
+
...commands_1.defaultKeymap,
|
|
59
|
+
...(disabledExtensions.history ? [] : commands_1.historyKeymap),
|
|
60
|
+
...keymaps,
|
|
61
|
+
]), (0, autocomplete_1.autocompletion)(), (0, yfm_1.yfmLang)(yfmLangOptions), react_facet_1.ReactRendererFacet.of(reactRenderer), pairing_chars_1.PairingCharactersExtension, view_1.EditorView.lineWrapping, view_1.EditorView.contentAttributes.of({ spellcheck: 'true' }), view_1.EditorView.domEventHandlers({
|
|
62
|
+
scroll(event) {
|
|
63
|
+
onScroll(event);
|
|
64
|
+
},
|
|
65
|
+
}), (0, plugin_1.SearchPanelPlugin)({
|
|
66
|
+
anchorSelector: '.g-md-search-anchor',
|
|
67
|
+
receiver,
|
|
68
|
+
}));
|
|
78
69
|
if (params.uploadHandler) {
|
|
79
70
|
extensions.push(files_upload_facet_1.FileUploadHandlerFacet.of({
|
|
80
71
|
fn: params.uploadHandler,
|
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 '13.
|
|
5
|
+
exports.VERSION = typeof '13.11.0' !== 'undefined' ? '13.11.0' : 'unknown';
|
|
@@ -47,6 +47,10 @@ export interface Editor extends Receiver<EventMap>, CommonEditor {
|
|
|
47
47
|
export declare type MarkupConfig = {
|
|
48
48
|
/** Additional extensions for codemirror instance. */
|
|
49
49
|
extensions?: CreateCodemirrorParams['extensions'];
|
|
50
|
+
/** Can be used to disable some of the default extensions */
|
|
51
|
+
disabledExtensions?: CreateCodemirrorParams['disabledExtensions'];
|
|
52
|
+
/** Additional keymaps for codemirror instance */
|
|
53
|
+
keymaps?: CreateCodemirrorParams['keymaps'];
|
|
50
54
|
/**
|
|
51
55
|
* Additional language data for markdown language in codemirror.
|
|
52
56
|
* Can be used to configure additional autocompletions and others.
|
|
@@ -154,6 +154,8 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
154
154
|
uploadHandler: this.fileUploadHandler,
|
|
155
155
|
needImgDimms: this.needToSetDimensionsForUploadedImages,
|
|
156
156
|
extensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").extensions,
|
|
157
|
+
disabledExtensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
|
|
158
|
+
keymaps: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
|
|
157
159
|
yfmLangOptions: { languageData: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").languageData },
|
|
158
160
|
receiver: this,
|
|
159
161
|
})), "f");
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
|
|
1
2
|
import type { ExtensionNodeSpec } from '../../../../core';
|
|
2
3
|
export { yfmHtmlBlockNodeName } from './const';
|
|
3
4
|
export declare type YfmHtmlBlockSpecsOptions = {
|
|
4
5
|
nodeView?: ExtensionNodeSpec['view'];
|
|
5
6
|
sanitize?: (dirtyHtml: string) => string;
|
|
7
|
+
styles?: string | StylesObject;
|
|
8
|
+
baseTarget?: BaseTarget;
|
|
6
9
|
};
|
|
7
10
|
export declare const YfmHtmlBlockSpecs: import("../../../../core").ExtensionWithOptions<YfmHtmlBlockSpecsOptions> & {
|
|
8
11
|
readonly NodeName: "yfm_html_block";
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
3
|
import { transform } from '@diplodoc/html-extension';
|
|
3
4
|
import { YfmHtmlBlockConsts } from './const';
|
|
4
5
|
export { yfmHtmlBlockNodeName } from './const';
|
|
5
|
-
const YfmHtmlBlockSpecsExtension = (builder,
|
|
6
|
+
const YfmHtmlBlockSpecsExtension = (builder, _a) => {
|
|
7
|
+
var { nodeView } = _a, options = __rest(_a, ["nodeView"]);
|
|
6
8
|
builder
|
|
7
|
-
.configureMd((md) => md.use(transform({ bundle: false,
|
|
9
|
+
.configureMd((md) => md.use(transform(Object.assign({ bundle: false }, options)), {}))
|
|
8
10
|
.addNode(YfmHtmlBlockConsts.NodeName, () => ({
|
|
9
11
|
fromMd: {
|
|
10
12
|
tokenSpec: {
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
|
|
1
2
|
import type { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
|
|
2
3
|
import { Action, ExtensionAuto } from '../../../core';
|
|
3
4
|
import { YfmHtmlBlockAction } from './YfmHtmlBlockSpecs/const';
|
|
4
5
|
export declare type YfmHtmlBlockOptions = {
|
|
5
6
|
useConfig?: () => IHTMLIFrameElementConfig | undefined;
|
|
6
7
|
sanitize?: (dirtyHtml: string) => string;
|
|
8
|
+
styles?: string | StylesObject;
|
|
9
|
+
baseTarget?: BaseTarget;
|
|
7
10
|
};
|
|
8
11
|
export declare const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions>;
|
|
9
12
|
declare global {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
1
2
|
import { WYfmHtmlBlockNodeView } from './YfmHtmlBlockNodeView';
|
|
2
3
|
import { YfmHtmlBlockSpecs } from './YfmHtmlBlockSpecs';
|
|
3
4
|
import { YfmHtmlBlockAction } from './YfmHtmlBlockSpecs/const';
|
|
4
5
|
import { addYfmHtmlBlock } from './actions';
|
|
5
|
-
export const YfmHtmlBlock = (builder,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
sanitize: options.sanitize,
|
|
9
|
-
});
|
|
6
|
+
export const YfmHtmlBlock = (builder, _a) => {
|
|
7
|
+
var { useConfig: _ } = _a, options = __rest(_a, ["useConfig"]);
|
|
8
|
+
builder.use(YfmHtmlBlockSpecs, Object.assign({ nodeView: YfmHtmlBlockNodeViewFactory(options) }, options));
|
|
10
9
|
builder.addAction(YfmHtmlBlockAction, () => addYfmHtmlBlock);
|
|
11
10
|
};
|
|
12
11
|
const YfmHtmlBlockNodeViewFactory = (options) => () => (node, view, getPos) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Extension, StateCommand } from '@codemirror/state';
|
|
2
|
-
import { EditorView, EditorViewConfig } from '@codemirror/view';
|
|
2
|
+
import { EditorView, EditorViewConfig, KeyBinding } from '@codemirror/view';
|
|
3
3
|
import { EventMap } from '../../bundle/Editor';
|
|
4
4
|
import { ReactRenderStorage } from '../../extensions';
|
|
5
5
|
import { Receiver } from '../../utils';
|
|
@@ -18,6 +18,10 @@ export declare type CreateCodemirrorParams = {
|
|
|
18
18
|
uploadHandler?: FileUploadHandler;
|
|
19
19
|
needImgDimms?: boolean;
|
|
20
20
|
extensions?: Extension[];
|
|
21
|
+
disabledExtensions?: {
|
|
22
|
+
history?: boolean;
|
|
23
|
+
};
|
|
24
|
+
keymaps?: readonly KeyBinding[];
|
|
21
25
|
receiver?: Receiver<EventMap>;
|
|
22
26
|
yfmLangOptions?: YfmLangOptions;
|
|
23
27
|
};
|
|
@@ -13,65 +13,56 @@ import { ReactRendererFacet } from './react-facet';
|
|
|
13
13
|
import { SearchPanelPlugin } from './search-plugin/plugin';
|
|
14
14
|
import { yfmLang } from './yfm';
|
|
15
15
|
export function createCodemirror(params) {
|
|
16
|
-
const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, receiver, yfmLangOptions, } = params;
|
|
17
|
-
const extensions = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return true;
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
key: f.toCM(A.Submit),
|
|
48
|
-
preventDefault: true,
|
|
49
|
-
run: () => {
|
|
50
|
-
onSubmit();
|
|
51
|
-
return true;
|
|
52
|
-
},
|
|
16
|
+
const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, } = params;
|
|
17
|
+
const extensions = [gravityTheme, placeholder(placeholderText)];
|
|
18
|
+
if (!disabledExtensions.history) {
|
|
19
|
+
extensions.push(history());
|
|
20
|
+
}
|
|
21
|
+
extensions.push(syntaxHighlighting(gravityHighlightStyle), keymap.of([
|
|
22
|
+
{ key: f.toCM(A.Bold), run: withLogger(ActionName.bold, toggleBold) },
|
|
23
|
+
{ key: f.toCM(A.Italic), run: withLogger(ActionName.italic, toggleItalic) },
|
|
24
|
+
{ key: f.toCM(A.Strike), run: withLogger(ActionName.strike, toggleStrikethrough) },
|
|
25
|
+
{ key: f.toCM(A.Underline), run: withLogger(ActionName.underline, toggleUnderline) },
|
|
26
|
+
{ key: f.toCM(A.Link), run: withLogger(ActionName.link, insertLink) },
|
|
27
|
+
{ key: f.toCM(A.Heading1), run: withLogger(ActionName.heading1, toH1) },
|
|
28
|
+
{ key: f.toCM(A.Heading2), run: withLogger(ActionName.heading2, toH2) },
|
|
29
|
+
{ key: f.toCM(A.Heading3), run: withLogger(ActionName.heading3, toH3) },
|
|
30
|
+
{ key: f.toCM(A.Heading4), run: withLogger(ActionName.heading4, toH4) },
|
|
31
|
+
{ key: f.toCM(A.Heading5), run: withLogger(ActionName.heading5, toH5) },
|
|
32
|
+
{ key: f.toCM(A.Heading6), run: withLogger(ActionName.heading6, toH6) },
|
|
33
|
+
{ key: f.toCM(A.Code), run: withLogger(ActionName.code_inline, wrapToInlineCode) },
|
|
34
|
+
{ key: f.toCM(A.CodeBlock), run: withLogger(ActionName.code_block, wrapToCodeBlock) },
|
|
35
|
+
{ key: f.toCM(A.Cut), run: withLogger(ActionName.yfm_cut, wrapToYfmCut) },
|
|
36
|
+
{ key: f.toCM(A.Note), run: withLogger(ActionName.yfm_note, wrapToYfmNote) },
|
|
37
|
+
{
|
|
38
|
+
key: f.toCM(A.Cancel),
|
|
39
|
+
preventDefault: true,
|
|
40
|
+
run: () => {
|
|
41
|
+
onCancel();
|
|
42
|
+
return true;
|
|
53
43
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
ReactRendererFacet.of(reactRenderer),
|
|
62
|
-
PairingCharactersExtension,
|
|
63
|
-
EditorView.lineWrapping,
|
|
64
|
-
EditorView.contentAttributes.of({ spellcheck: 'true' }),
|
|
65
|
-
EditorView.domEventHandlers({
|
|
66
|
-
scroll(event) {
|
|
67
|
-
onScroll(event);
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: f.toCM(A.Submit),
|
|
47
|
+
preventDefault: true,
|
|
48
|
+
run: () => {
|
|
49
|
+
onSubmit();
|
|
50
|
+
return true;
|
|
68
51
|
},
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
52
|
+
},
|
|
53
|
+
{ key: 'Tab', preventDefault: true, run: insertTab },
|
|
54
|
+
indentWithTab,
|
|
55
|
+
...defaultKeymap,
|
|
56
|
+
...(disabledExtensions.history ? [] : historyKeymap),
|
|
57
|
+
...keymaps,
|
|
58
|
+
]), autocompletion(), yfmLang(yfmLangOptions), ReactRendererFacet.of(reactRenderer), PairingCharactersExtension, EditorView.lineWrapping, EditorView.contentAttributes.of({ spellcheck: 'true' }), EditorView.domEventHandlers({
|
|
59
|
+
scroll(event) {
|
|
60
|
+
onScroll(event);
|
|
61
|
+
},
|
|
62
|
+
}), SearchPanelPlugin({
|
|
63
|
+
anchorSelector: '.g-md-search-anchor',
|
|
64
|
+
receiver,
|
|
65
|
+
}));
|
|
75
66
|
if (params.uploadHandler) {
|
|
76
67
|
extensions.push(FileUploadHandlerFacet.of({
|
|
77
68
|
fn: params.uploadHandler,
|
package/build/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** During build process, the current version will be injected here */
|
|
2
|
-
export const VERSION = typeof '13.
|
|
2
|
+
export const VERSION = typeof '13.11.0' !== 'undefined' ? '13.11.0' : 'unknown';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/markdown-editor",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.11.0",
|
|
4
4
|
"description": "Markdown wysiwyg and markup editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -200,7 +200,7 @@
|
|
|
200
200
|
},
|
|
201
201
|
"devDependencies": {
|
|
202
202
|
"@diplodoc/folding-headings-extension": "0.1.0",
|
|
203
|
-
"@diplodoc/html-extension": "1.
|
|
203
|
+
"@diplodoc/html-extension": "1.3.1",
|
|
204
204
|
"@diplodoc/latex-extension": "1.0.3",
|
|
205
205
|
"@diplodoc/mermaid-extension": "1.2.1",
|
|
206
206
|
"@diplodoc/transform": "4.22.0",
|