@gravity-ui/markdown-editor 13.13.0 → 13.15.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 +8 -0
- package/build/cjs/bundle/Editor.js +9 -2
- package/build/cjs/bundle/settings/index.d.ts +2 -1
- package/build/cjs/bundle/settings/index.js +10 -4
- package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js +14 -6
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +9 -5
- package/build/cjs/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.d.ts +3 -6
- package/build/cjs/extensions/yfm/YfmHtmlBlock/index.d.ts +3 -6
- package/build/cjs/markup/codemirror/create.d.ts +3 -0
- package/build/cjs/markup/codemirror/create.js +2 -2
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.d.ts +8 -0
- package/build/esm/bundle/Editor.js +9 -2
- package/build/esm/bundle/settings/index.d.ts +2 -1
- package/build/esm/bundle/settings/index.js +10 -4
- package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js +14 -6
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +9 -5
- package/build/esm/extensions/yfm/YfmHtmlBlock/YfmHtmlBlockSpecs/index.d.ts +3 -6
- package/build/esm/extensions/yfm/YfmHtmlBlock/index.d.ts +3 -6
- package/build/esm/markup/codemirror/create.d.ts +3 -0
- package/build/esm/markup/codemirror/create.js +2 -2
- package/build/esm/version.js +1 -1
- package/package.json +2 -2
|
@@ -45,6 +45,11 @@ export interface Editor extends Receiver<EventMap>, CommonEditor {
|
|
|
45
45
|
}): void;
|
|
46
46
|
}
|
|
47
47
|
declare type SetEditorModeOptions = Pick<ChangeEditorModeOptions, 'emit'>;
|
|
48
|
+
declare type ChangeEditorModeOptions = {
|
|
49
|
+
mode: EditorMode;
|
|
50
|
+
reason: 'error-boundary' | 'settings' | 'manually';
|
|
51
|
+
emit?: boolean;
|
|
52
|
+
};
|
|
48
53
|
export declare type MarkupConfig = {
|
|
49
54
|
/** Additional extensions for codemirror instance. */
|
|
50
55
|
extensions?: CreateCodemirrorParams['extensions'];
|
|
@@ -58,6 +63,8 @@ export declare type MarkupConfig = {
|
|
|
58
63
|
* See more https://codemirror.net/docs/ref/#state.EditorState.languageDataAt
|
|
59
64
|
*/
|
|
60
65
|
languageData?: YfmLangOptions['languageData'];
|
|
66
|
+
/** Config for @codemirror/autocomplete https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig */
|
|
67
|
+
autocompletion?: CreateCodemirrorParams['autocompletion'];
|
|
61
68
|
};
|
|
62
69
|
export declare type EscapeConfig = {
|
|
63
70
|
commonEscape?: RegExp;
|
|
@@ -86,6 +93,7 @@ export declare type EditorOptions = Pick<WysiwygEditorOptions, 'allowHTML' | 'li
|
|
|
86
93
|
* You can use it to pre-process the value from the markup editor before it gets into the wysiwyg editor.
|
|
87
94
|
*/
|
|
88
95
|
prepareRawMarkup?: (value: MarkupString) => MarkupString;
|
|
96
|
+
experimental_beforeEditorModeChange?: (options: Pick<ChangeEditorModeOptions, 'mode' | 'reason'>) => boolean | undefined;
|
|
89
97
|
splitMode?: SplitMode;
|
|
90
98
|
renderPreview?: RenderPreview;
|
|
91
99
|
preset: EditorPreset;
|
|
@@ -1,5 +1,5 @@
|
|
|
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_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup;
|
|
2
|
+
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _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");
|
|
@@ -35,6 +35,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
35
35
|
_EditorImpl_fileUploadHandler.set(this, void 0);
|
|
36
36
|
_EditorImpl_needToSetDimensionsForUploadedImages.set(this, void 0);
|
|
37
37
|
_EditorImpl_prepareRawMarkup.set(this, void 0);
|
|
38
|
+
_EditorImpl_beforeEditorModeChange.set(this, void 0);
|
|
38
39
|
this.getValue = () => this.currentEditor.getValue();
|
|
39
40
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_editorMode, (_a = opts.initialEditorMode) !== null && _a !== void 0 ? _a : 'wysiwyg', "f");
|
|
40
41
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_toolbarVisible, Boolean(opts.initialToolbarVisible), "f");
|
|
@@ -54,6 +55,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
54
55
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_needToSetDimensionsForUploadedImages, Boolean(opts.needToSetDimensionsForUploadedImages), "f");
|
|
55
56
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_prepareRawMarkup, opts.prepareRawMarkup, "f");
|
|
56
57
|
tslib_1.__classPrivateFieldSet(this, _EditorImpl_escapeConfig, opts.escapeConfig, "f");
|
|
58
|
+
tslib_1.__classPrivateFieldSet(this, _EditorImpl_beforeEditorModeChange, opts.experimental_beforeEditorModeChange, "f");
|
|
57
59
|
}
|
|
58
60
|
get _wysiwygView() {
|
|
59
61
|
var _a;
|
|
@@ -163,6 +165,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
163
165
|
disabledExtensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
|
|
164
166
|
keymaps: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
|
|
165
167
|
yfmLangOptions: { languageData: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").languageData },
|
|
168
|
+
autocompletion: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").autocompletion,
|
|
166
169
|
receiver: this,
|
|
167
170
|
})), "f");
|
|
168
171
|
}
|
|
@@ -202,9 +205,13 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
202
205
|
this.changeEditorMode({ mode, reason: 'manually', emit: opts === null || opts === void 0 ? void 0 : opts.emit });
|
|
203
206
|
}
|
|
204
207
|
changeEditorMode(_a) {
|
|
208
|
+
var _b;
|
|
205
209
|
var { emit = true } = _a, opts = tslib_1.__rest(_a, ["emit"]);
|
|
206
210
|
if (tslib_1.__classPrivateFieldGet(this, _EditorImpl_editorMode, "f") === opts.mode)
|
|
207
211
|
return;
|
|
212
|
+
if (((_b = tslib_1.__classPrivateFieldGet(this, _EditorImpl_beforeEditorModeChange, "f")) === null || _b === void 0 ? void 0 : _b.call(this, { mode: opts.mode, reason: opts.reason })) === false) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
208
215
|
this.currentMode = opts.mode;
|
|
209
216
|
this.emit('rerender', null);
|
|
210
217
|
if (emit) {
|
|
@@ -284,4 +291,4 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
284
291
|
}
|
|
285
292
|
}
|
|
286
293
|
exports.EditorImpl = EditorImpl;
|
|
287
|
-
_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_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap();
|
|
294
|
+
_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_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ClassNameProps } from '../../classname';
|
|
3
3
|
import type { EditorMode, SplitMode } from '../Editor';
|
|
4
|
-
export declare type EditorSettingsProps = SettingsContentProps & {
|
|
4
|
+
export declare type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {
|
|
5
5
|
renderPreviewButton?: boolean;
|
|
6
6
|
};
|
|
7
7
|
export declare const EditorSettings: React.NamedExoticComponent<EditorSettingsProps>;
|
|
8
8
|
declare type SettingsContentProps = ClassNameProps & {
|
|
9
9
|
mode: EditorMode;
|
|
10
|
+
onClose: () => void;
|
|
10
11
|
onModeChange: (mode: EditorMode) => void;
|
|
11
12
|
onShowPreviewChange: (showPreview: boolean) => void;
|
|
12
13
|
showPreview: boolean;
|
|
@@ -32,14 +32,20 @@ exports.EditorSettings = react_1.default.memo(function EditorSettings(props) {
|
|
|
32
32
|
react_1.default.createElement(uikit_1.Button, { size: "m", view: "flat", ref: chevronRef, pin: "round-round", onClick: togglePopup, className: bSettings('dropdown-button') },
|
|
33
33
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Gear })),
|
|
34
34
|
react_1.default.createElement(uikit_1.Popup, { open: popupShown, anchorRef: chevronRef, placement: placement, onClose: hidePopup },
|
|
35
|
-
react_1.default.createElement(SettingsContent, Object.assign({}, props, { className: bSettings('content') })))));
|
|
35
|
+
react_1.default.createElement(SettingsContent, Object.assign({}, props, { onClose: hidePopup, className: bSettings('content') })))));
|
|
36
36
|
});
|
|
37
37
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
38
|
-
const SettingsContent = function SettingsContent({ mode, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
38
|
+
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
39
39
|
return (react_1.default.createElement("div", { className: bContent(null, [className]) },
|
|
40
40
|
react_1.default.createElement(uikit_1.Menu, { size: "l", className: bContent('mode') },
|
|
41
|
-
react_1.default.createElement(uikit_1.Menu.Item, { active: mode === 'wysiwyg', onClick: () =>
|
|
42
|
-
|
|
41
|
+
react_1.default.createElement(uikit_1.Menu.Item, { active: mode === 'wysiwyg', onClick: () => {
|
|
42
|
+
onModeChange('wysiwyg');
|
|
43
|
+
onClose();
|
|
44
|
+
}, icon: react_1.default.createElement(uikit_1.Icon, { data: WysiwygMode_1.default }) }, (0, bundle_1.i18n)('settings_wysiwyg')),
|
|
45
|
+
react_1.default.createElement(uikit_1.Menu.Item, { active: mode === 'markup', onClick: () => {
|
|
46
|
+
onModeChange('markup');
|
|
47
|
+
onClose();
|
|
48
|
+
}, icon: react_1.default.createElement(uikit_1.Icon, { data: icons_1.LogoMarkdown }) },
|
|
43
49
|
(0, bundle_1.i18n)('settings_markup'),
|
|
44
50
|
react_1.default.createElement(components_1.HelpPopover, { content: react_1.default.createElement("div", { onClick: (e) => {
|
|
45
51
|
// stop clicks propagation
|
|
@@ -23,12 +23,20 @@ const YfmHeadingSpecs = (builder, opts) => {
|
|
|
23
23
|
defining: true,
|
|
24
24
|
selectable: true,
|
|
25
25
|
parseDOM: [
|
|
26
|
-
{ tag: 'h1', getAttrs: (0, utils_1.getNodeAttrs)(1) },
|
|
27
|
-
{ tag: 'h2', getAttrs: (0, utils_1.getNodeAttrs)(2) },
|
|
28
|
-
{ tag: 'h3', getAttrs: (0, utils_1.getNodeAttrs)(3) },
|
|
29
|
-
{ tag: 'h4', getAttrs: (0, utils_1.getNodeAttrs)(4) },
|
|
30
|
-
{ tag: 'h5', getAttrs: (0, utils_1.getNodeAttrs)(5) },
|
|
31
|
-
{ tag: 'h6', getAttrs: (0, utils_1.getNodeAttrs)(6) },
|
|
26
|
+
{ tag: 'h1', getAttrs: (0, utils_1.getNodeAttrs)(1), priority: 100, consuming: true },
|
|
27
|
+
{ tag: 'h2', getAttrs: (0, utils_1.getNodeAttrs)(2), priority: 100, consuming: true },
|
|
28
|
+
{ tag: 'h3', getAttrs: (0, utils_1.getNodeAttrs)(3), priority: 100, consuming: true },
|
|
29
|
+
{ tag: 'h4', getAttrs: (0, utils_1.getNodeAttrs)(4), priority: 100, consuming: true },
|
|
30
|
+
{ tag: 'h5', getAttrs: (0, utils_1.getNodeAttrs)(5), priority: 100, consuming: true },
|
|
31
|
+
{ tag: 'h6', getAttrs: (0, utils_1.getNodeAttrs)(6), priority: 100, consuming: true },
|
|
32
|
+
{
|
|
33
|
+
// ignore anchor link inside headings
|
|
34
|
+
tag: 'a.yfm-anchor',
|
|
35
|
+
context: `${const_1.headingNodeName}/`,
|
|
36
|
+
skip: true,
|
|
37
|
+
ignore: true,
|
|
38
|
+
priority: 1000,
|
|
39
|
+
},
|
|
32
40
|
],
|
|
33
41
|
toDOM(node) {
|
|
34
42
|
const id = node.attrs[const_1.YfmHeadingAttr.Id];
|
|
@@ -138,7 +138,8 @@ const CodeEditMode = ({ initialText, onSave, onCancel }) => {
|
|
|
138
138
|
react_1.default.createElement(uikit_1.Button, { onClick: () => onSave(text), view: 'action' },
|
|
139
139
|
react_1.default.createElement("span", { className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }) }, (0, common_1.i18n)('save'))))))));
|
|
140
140
|
};
|
|
141
|
-
const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useConfig, sanitize, styles, baseTarget = '
|
|
141
|
+
const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useConfig, sanitize, styles, baseTarget = '_parent', head: headContent = '' }, }) => {
|
|
142
|
+
var _a;
|
|
142
143
|
const [editing, setEditing, unsetEditing, toggleEditing] = (0, hooks_1.useBooleanState)(Boolean(node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.newCreated]));
|
|
143
144
|
const config = useConfig === null || useConfig === void 0 ? void 0 : useConfig();
|
|
144
145
|
const [menuOpen, , , toggleMenuOpen] = (0, hooks_1.useBooleanState)(false);
|
|
@@ -152,17 +153,20 @@ const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useConfig,
|
|
|
152
153
|
unsetEditing();
|
|
153
154
|
} }));
|
|
154
155
|
}
|
|
155
|
-
let
|
|
156
|
+
let additional = baseTarget ? `<base target="${baseTarget}">` : '';
|
|
156
157
|
if (styles) {
|
|
157
158
|
const stylesContent = typeof styles === 'string'
|
|
158
159
|
? `<link rel="stylesheet" href="${styles}" />`
|
|
159
160
|
: `<style>${(0, html_extension_1.getStyles)(styles)}</style>`;
|
|
160
|
-
|
|
161
|
+
additional += stylesContent;
|
|
161
162
|
}
|
|
162
|
-
const
|
|
163
|
+
const head = `<head>${headContent || additional}</head>`;
|
|
164
|
+
const body = `<body>${(_a = node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.srcdoc]) !== null && _a !== void 0 ? _a : ''}</body>`;
|
|
165
|
+
const html = `<!DOCTYPE html><html>${head}${body}</html>`;
|
|
166
|
+
const resultHtml = sanitize ? sanitize(html) : html;
|
|
163
167
|
return (react_1.default.createElement("div", { className: b(), onDoubleClick: setEditing },
|
|
164
168
|
react_1.default.createElement(uikit_1.Label, { className: b('label'), icon: react_1.default.createElement(uikit_1.Icon, { size: 16, data: icons_1.Eye }) }, (0, common_1.i18n)('preview')),
|
|
165
|
-
react_1.default.createElement(YfmHtmlBlockPreview, { html:
|
|
169
|
+
react_1.default.createElement(YfmHtmlBlockPreview, { html: resultHtml, "on\u0421lick": handleClick, config: config }),
|
|
166
170
|
react_1.default.createElement("div", { className: b('menu') },
|
|
167
171
|
react_1.default.createElement(uikit_1.Button, { onClick: toggleMenuOpen, ref: buttonRef, size: 's', className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }) },
|
|
168
172
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Ellipsis, className: (0, exports.cnHelper)({ 'prosemirror-stop-event': true }) })),
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
|
|
2
2
|
import type { ExtensionNodeSpec } from '../../../../core';
|
|
3
3
|
export { yfmHtmlBlockNodeName } from './const';
|
|
4
|
-
export
|
|
4
|
+
export interface YfmHtmlBlockSpecsOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
|
|
5
5
|
nodeView?: ExtensionNodeSpec['view'];
|
|
6
|
-
|
|
7
|
-
styles?: string | StylesObject;
|
|
8
|
-
baseTarget?: BaseTarget;
|
|
9
|
-
};
|
|
6
|
+
}
|
|
10
7
|
export declare const YfmHtmlBlockSpecs: import("../../../../core").ExtensionWithOptions<YfmHtmlBlockSpecsOptions> & {
|
|
11
8
|
readonly NodeName: "yfm_html_block";
|
|
12
9
|
readonly NodeAttrs: typeof import("./const").YfmHtmlBlockAttrs;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
|
|
2
2
|
import type { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
|
|
3
3
|
import { Action, ExtensionAuto } from '../../../core';
|
|
4
4
|
import { YfmHtmlBlockAction } from './YfmHtmlBlockSpecs/const';
|
|
5
|
-
export
|
|
5
|
+
export interface YfmHtmlBlockOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
|
|
6
6
|
useConfig?: () => IHTMLIFrameElementConfig | undefined;
|
|
7
|
-
|
|
8
|
-
styles?: string | StylesObject;
|
|
9
|
-
baseTarget?: BaseTarget;
|
|
10
|
-
};
|
|
7
|
+
}
|
|
11
8
|
export declare const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions>;
|
|
12
9
|
declare global {
|
|
13
10
|
namespace WysiwygEditor {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autocompletion } from '@codemirror/autocomplete';
|
|
1
2
|
import type { Extension, StateCommand } from '@codemirror/state';
|
|
2
3
|
import { EditorView, EditorViewConfig, KeyBinding } from '@codemirror/view';
|
|
3
4
|
import { EventMap } from '../../bundle/Editor';
|
|
@@ -6,6 +7,7 @@ import { Receiver } from '../../utils';
|
|
|
6
7
|
import { FileUploadHandler } from './files-upload-facet';
|
|
7
8
|
import { type YfmLangOptions } from './yfm';
|
|
8
9
|
export type { YfmLangOptions };
|
|
10
|
+
declare type Autocompletion = Parameters<typeof autocompletion>[0];
|
|
9
11
|
export declare type CreateCodemirrorParams = {
|
|
10
12
|
doc: EditorViewConfig['doc'];
|
|
11
13
|
placeholderText: string;
|
|
@@ -24,6 +26,7 @@ export declare type CreateCodemirrorParams = {
|
|
|
24
26
|
keymaps?: readonly KeyBinding[];
|
|
25
27
|
receiver?: Receiver<EventMap>;
|
|
26
28
|
yfmLangOptions?: YfmLangOptions;
|
|
29
|
+
autocompletion?: Autocompletion;
|
|
27
30
|
};
|
|
28
31
|
export declare function createCodemirror(params: CreateCodemirrorParams): EditorView;
|
|
29
32
|
export declare function withLogger(action: string, command: StateCommand): StateCommand;
|
|
@@ -16,7 +16,7 @@ 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, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, } = params;
|
|
19
|
+
const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, autocompletion: autocompletionConfig, } = params;
|
|
20
20
|
const extensions = [gravity_1.gravityTheme, (0, view_1.placeholder)(placeholderText)];
|
|
21
21
|
if (!disabledExtensions.history) {
|
|
22
22
|
extensions.push((0, commands_1.history)());
|
|
@@ -58,7 +58,7 @@ function createCodemirror(params) {
|
|
|
58
58
|
...commands_1.defaultKeymap,
|
|
59
59
|
...(disabledExtensions.history ? [] : commands_1.historyKeymap),
|
|
60
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({
|
|
61
|
+
]), (0, autocomplete_1.autocompletion)(autocompletionConfig), (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
62
|
scroll(event) {
|
|
63
63
|
onScroll(event);
|
|
64
64
|
},
|
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.15.0' !== 'undefined' ? '13.15.0' : 'unknown';
|
|
@@ -45,6 +45,11 @@ export interface Editor extends Receiver<EventMap>, CommonEditor {
|
|
|
45
45
|
}): void;
|
|
46
46
|
}
|
|
47
47
|
declare type SetEditorModeOptions = Pick<ChangeEditorModeOptions, 'emit'>;
|
|
48
|
+
declare type ChangeEditorModeOptions = {
|
|
49
|
+
mode: EditorMode;
|
|
50
|
+
reason: 'error-boundary' | 'settings' | 'manually';
|
|
51
|
+
emit?: boolean;
|
|
52
|
+
};
|
|
48
53
|
export declare type MarkupConfig = {
|
|
49
54
|
/** Additional extensions for codemirror instance. */
|
|
50
55
|
extensions?: CreateCodemirrorParams['extensions'];
|
|
@@ -58,6 +63,8 @@ export declare type MarkupConfig = {
|
|
|
58
63
|
* See more https://codemirror.net/docs/ref/#state.EditorState.languageDataAt
|
|
59
64
|
*/
|
|
60
65
|
languageData?: YfmLangOptions['languageData'];
|
|
66
|
+
/** Config for @codemirror/autocomplete https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig */
|
|
67
|
+
autocompletion?: CreateCodemirrorParams['autocompletion'];
|
|
61
68
|
};
|
|
62
69
|
export declare type EscapeConfig = {
|
|
63
70
|
commonEscape?: RegExp;
|
|
@@ -86,6 +93,7 @@ export declare type EditorOptions = Pick<WysiwygEditorOptions, 'allowHTML' | 'li
|
|
|
86
93
|
* You can use it to pre-process the value from the markup editor before it gets into the wysiwyg editor.
|
|
87
94
|
*/
|
|
88
95
|
prepareRawMarkup?: (value: MarkupString) => MarkupString;
|
|
96
|
+
experimental_beforeEditorModeChange?: (options: Pick<ChangeEditorModeOptions, 'mode' | 'reason'>) => boolean | undefined;
|
|
89
97
|
splitMode?: SplitMode;
|
|
90
98
|
renderPreview?: RenderPreview;
|
|
91
99
|
preset: EditorPreset;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup;
|
|
1
|
+
var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_escapeConfig, _EditorImpl_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup, _EditorImpl_beforeEditorModeChange;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet, __rest } from "tslib";
|
|
3
3
|
import { TextSelection } from 'prosemirror-state';
|
|
4
4
|
import { WysiwygEditor } from '../core';
|
|
@@ -32,6 +32,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
32
32
|
_EditorImpl_fileUploadHandler.set(this, void 0);
|
|
33
33
|
_EditorImpl_needToSetDimensionsForUploadedImages.set(this, void 0);
|
|
34
34
|
_EditorImpl_prepareRawMarkup.set(this, void 0);
|
|
35
|
+
_EditorImpl_beforeEditorModeChange.set(this, void 0);
|
|
35
36
|
this.getValue = () => this.currentEditor.getValue();
|
|
36
37
|
__classPrivateFieldSet(this, _EditorImpl_editorMode, (_a = opts.initialEditorMode) !== null && _a !== void 0 ? _a : 'wysiwyg', "f");
|
|
37
38
|
__classPrivateFieldSet(this, _EditorImpl_toolbarVisible, Boolean(opts.initialToolbarVisible), "f");
|
|
@@ -51,6 +52,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
51
52
|
__classPrivateFieldSet(this, _EditorImpl_needToSetDimensionsForUploadedImages, Boolean(opts.needToSetDimensionsForUploadedImages), "f");
|
|
52
53
|
__classPrivateFieldSet(this, _EditorImpl_prepareRawMarkup, opts.prepareRawMarkup, "f");
|
|
53
54
|
__classPrivateFieldSet(this, _EditorImpl_escapeConfig, opts.escapeConfig, "f");
|
|
55
|
+
__classPrivateFieldSet(this, _EditorImpl_beforeEditorModeChange, opts.experimental_beforeEditorModeChange, "f");
|
|
54
56
|
}
|
|
55
57
|
get _wysiwygView() {
|
|
56
58
|
var _a;
|
|
@@ -160,6 +162,7 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
160
162
|
disabledExtensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
|
|
161
163
|
keymaps: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
|
|
162
164
|
yfmLangOptions: { languageData: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").languageData },
|
|
165
|
+
autocompletion: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").autocompletion,
|
|
163
166
|
receiver: this,
|
|
164
167
|
})), "f");
|
|
165
168
|
}
|
|
@@ -199,9 +202,13 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
199
202
|
this.changeEditorMode({ mode, reason: 'manually', emit: opts === null || opts === void 0 ? void 0 : opts.emit });
|
|
200
203
|
}
|
|
201
204
|
changeEditorMode(_a) {
|
|
205
|
+
var _b;
|
|
202
206
|
var { emit = true } = _a, opts = __rest(_a, ["emit"]);
|
|
203
207
|
if (__classPrivateFieldGet(this, _EditorImpl_editorMode, "f") === opts.mode)
|
|
204
208
|
return;
|
|
209
|
+
if (((_b = __classPrivateFieldGet(this, _EditorImpl_beforeEditorModeChange, "f")) === null || _b === void 0 ? void 0 : _b.call(this, { mode: opts.mode, reason: opts.reason })) === false) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
205
212
|
this.currentMode = opts.mode;
|
|
206
213
|
this.emit('rerender', null);
|
|
207
214
|
if (emit) {
|
|
@@ -280,4 +287,4 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
280
287
|
return (serializedEditorMarkup === null || serializedEditorMarkup === void 0 ? void 0 : serializedEditorMarkup.trim()) !== wysiwygValue.trim();
|
|
281
288
|
}
|
|
282
289
|
}
|
|
283
|
-
_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_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap();
|
|
290
|
+
_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_preset = new WeakMap(), _EditorImpl_allowHTML = new WeakMap(), _EditorImpl_linkify = new WeakMap(), _EditorImpl_linkifyTlds = new WeakMap(), _EditorImpl_extensions = new WeakMap(), _EditorImpl_renderStorage = new WeakMap(), _EditorImpl_fileUploadHandler = new WeakMap(), _EditorImpl_needToSetDimensionsForUploadedImages = new WeakMap(), _EditorImpl_prepareRawMarkup = new WeakMap(), _EditorImpl_beforeEditorModeChange = new WeakMap();
|
|
@@ -2,12 +2,13 @@ import React from 'react';
|
|
|
2
2
|
import { ClassNameProps } from '../../classname';
|
|
3
3
|
import type { EditorMode, SplitMode } from '../Editor';
|
|
4
4
|
import './index.css';
|
|
5
|
-
export declare type EditorSettingsProps = SettingsContentProps & {
|
|
5
|
+
export declare type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {
|
|
6
6
|
renderPreviewButton?: boolean;
|
|
7
7
|
};
|
|
8
8
|
export declare const EditorSettings: React.NamedExoticComponent<EditorSettingsProps>;
|
|
9
9
|
declare type SettingsContentProps = ClassNameProps & {
|
|
10
10
|
mode: EditorMode;
|
|
11
|
+
onClose: () => void;
|
|
11
12
|
onModeChange: (mode: EditorMode) => void;
|
|
12
13
|
onShowPreviewChange: (showPreview: boolean) => void;
|
|
13
14
|
showPreview: boolean;
|
|
@@ -29,14 +29,20 @@ export const EditorSettings = React.memo(function EditorSettings(props) {
|
|
|
29
29
|
React.createElement(Button, { size: "m", view: "flat", ref: chevronRef, pin: "round-round", onClick: togglePopup, className: bSettings('dropdown-button') },
|
|
30
30
|
React.createElement(Icon, { data: Gear })),
|
|
31
31
|
React.createElement(Popup, { open: popupShown, anchorRef: chevronRef, placement: placement, onClose: hidePopup },
|
|
32
|
-
React.createElement(SettingsContent, Object.assign({}, props, { className: bSettings('content') })))));
|
|
32
|
+
React.createElement(SettingsContent, Object.assign({}, props, { onClose: hidePopup, className: bSettings('content') })))));
|
|
33
33
|
});
|
|
34
34
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
35
|
-
const SettingsContent = function SettingsContent({ mode, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
35
|
+
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
36
36
|
return (React.createElement("div", { className: bContent(null, [className]) },
|
|
37
37
|
React.createElement(Menu, { size: "l", className: bContent('mode') },
|
|
38
|
-
React.createElement(Menu.Item, { active: mode === 'wysiwyg', onClick: () =>
|
|
39
|
-
|
|
38
|
+
React.createElement(Menu.Item, { active: mode === 'wysiwyg', onClick: () => {
|
|
39
|
+
onModeChange('wysiwyg');
|
|
40
|
+
onClose();
|
|
41
|
+
}, icon: React.createElement(Icon, { data: WysiwygModeIcon }) }, i18n('settings_wysiwyg')),
|
|
42
|
+
React.createElement(Menu.Item, { active: mode === 'markup', onClick: () => {
|
|
43
|
+
onModeChange('markup');
|
|
44
|
+
onClose();
|
|
45
|
+
}, icon: React.createElement(Icon, { data: LogoMarkdown }) },
|
|
40
46
|
i18n('settings_markup'),
|
|
41
47
|
React.createElement(HelpPopover, { content: React.createElement("div", { onClick: (e) => {
|
|
42
48
|
// stop clicks propagation
|
|
@@ -19,12 +19,20 @@ export const YfmHeadingSpecs = (builder, opts) => {
|
|
|
19
19
|
defining: true,
|
|
20
20
|
selectable: true,
|
|
21
21
|
parseDOM: [
|
|
22
|
-
{ tag: 'h1', getAttrs: getNodeAttrs(1) },
|
|
23
|
-
{ tag: 'h2', getAttrs: getNodeAttrs(2) },
|
|
24
|
-
{ tag: 'h3', getAttrs: getNodeAttrs(3) },
|
|
25
|
-
{ tag: 'h4', getAttrs: getNodeAttrs(4) },
|
|
26
|
-
{ tag: 'h5', getAttrs: getNodeAttrs(5) },
|
|
27
|
-
{ tag: 'h6', getAttrs: getNodeAttrs(6) },
|
|
22
|
+
{ tag: 'h1', getAttrs: getNodeAttrs(1), priority: 100, consuming: true },
|
|
23
|
+
{ tag: 'h2', getAttrs: getNodeAttrs(2), priority: 100, consuming: true },
|
|
24
|
+
{ tag: 'h3', getAttrs: getNodeAttrs(3), priority: 100, consuming: true },
|
|
25
|
+
{ tag: 'h4', getAttrs: getNodeAttrs(4), priority: 100, consuming: true },
|
|
26
|
+
{ tag: 'h5', getAttrs: getNodeAttrs(5), priority: 100, consuming: true },
|
|
27
|
+
{ tag: 'h6', getAttrs: getNodeAttrs(6), priority: 100, consuming: true },
|
|
28
|
+
{
|
|
29
|
+
// ignore anchor link inside headings
|
|
30
|
+
tag: 'a.yfm-anchor',
|
|
31
|
+
context: `${headingNodeName}/`,
|
|
32
|
+
skip: true,
|
|
33
|
+
ignore: true,
|
|
34
|
+
priority: 1000,
|
|
35
|
+
},
|
|
28
36
|
],
|
|
29
37
|
toDOM(node) {
|
|
30
38
|
const id = node.attrs[YfmHeadingAttr.Id];
|
|
@@ -134,7 +134,8 @@ const CodeEditMode = ({ initialText, onSave, onCancel }) => {
|
|
|
134
134
|
React.createElement(Button, { onClick: () => onSave(text), view: 'action' },
|
|
135
135
|
React.createElement("span", { className: cnHelper({ 'prosemirror-stop-event': true }) }, i18n('save'))))))));
|
|
136
136
|
};
|
|
137
|
-
export const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useConfig, sanitize, styles, baseTarget = '
|
|
137
|
+
export const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useConfig, sanitize, styles, baseTarget = '_parent', head: headContent = '' }, }) => {
|
|
138
|
+
var _a;
|
|
138
139
|
const [editing, setEditing, unsetEditing, toggleEditing] = useBooleanState(Boolean(node.attrs[YfmHtmlBlockConsts.NodeAttrs.newCreated]));
|
|
139
140
|
const config = useConfig === null || useConfig === void 0 ? void 0 : useConfig();
|
|
140
141
|
const [menuOpen, , , toggleMenuOpen] = useBooleanState(false);
|
|
@@ -148,17 +149,20 @@ export const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useC
|
|
|
148
149
|
unsetEditing();
|
|
149
150
|
} }));
|
|
150
151
|
}
|
|
151
|
-
let
|
|
152
|
+
let additional = baseTarget ? `<base target="${baseTarget}">` : '';
|
|
152
153
|
if (styles) {
|
|
153
154
|
const stylesContent = typeof styles === 'string'
|
|
154
155
|
? `<link rel="stylesheet" href="${styles}" />`
|
|
155
156
|
: `<style>${getStyles(styles)}</style>`;
|
|
156
|
-
|
|
157
|
+
additional += stylesContent;
|
|
157
158
|
}
|
|
158
|
-
const
|
|
159
|
+
const head = `<head>${headContent || additional}</head>`;
|
|
160
|
+
const body = `<body>${(_a = node.attrs[YfmHtmlBlockConsts.NodeAttrs.srcdoc]) !== null && _a !== void 0 ? _a : ''}</body>`;
|
|
161
|
+
const html = `<!DOCTYPE html><html>${head}${body}</html>`;
|
|
162
|
+
const resultHtml = sanitize ? sanitize(html) : html;
|
|
159
163
|
return (React.createElement("div", { className: b(), onDoubleClick: setEditing },
|
|
160
164
|
React.createElement(Label, { className: b('label'), icon: React.createElement(Icon, { size: 16, data: Eye }) }, i18n('preview')),
|
|
161
|
-
React.createElement(YfmHtmlBlockPreview, { html:
|
|
165
|
+
React.createElement(YfmHtmlBlockPreview, { html: resultHtml, "on\u0421lick": handleClick, config: config }),
|
|
162
166
|
React.createElement("div", { className: b('menu') },
|
|
163
167
|
React.createElement(Button, { onClick: toggleMenuOpen, ref: buttonRef, size: 's', className: cnHelper({ 'prosemirror-stop-event': true }) },
|
|
164
168
|
React.createElement(Icon, { data: DotsIcon, className: cnHelper({ 'prosemirror-stop-event': true }) })),
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
|
|
2
2
|
import type { ExtensionNodeSpec } from '../../../../core';
|
|
3
3
|
export { yfmHtmlBlockNodeName } from './const';
|
|
4
|
-
export
|
|
4
|
+
export interface YfmHtmlBlockSpecsOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
|
|
5
5
|
nodeView?: ExtensionNodeSpec['view'];
|
|
6
|
-
|
|
7
|
-
styles?: string | StylesObject;
|
|
8
|
-
baseTarget?: BaseTarget;
|
|
9
|
-
};
|
|
6
|
+
}
|
|
10
7
|
export declare const YfmHtmlBlockSpecs: import("../../../../core").ExtensionWithOptions<YfmHtmlBlockSpecsOptions> & {
|
|
11
8
|
readonly NodeName: "yfm_html_block";
|
|
12
9
|
readonly NodeAttrs: typeof import("./const").YfmHtmlBlockAttrs;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
|
|
2
2
|
import type { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
|
|
3
3
|
import { Action, ExtensionAuto } from '../../../core';
|
|
4
4
|
import { YfmHtmlBlockAction } from './YfmHtmlBlockSpecs/const';
|
|
5
|
-
export
|
|
5
|
+
export interface YfmHtmlBlockOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
|
|
6
6
|
useConfig?: () => IHTMLIFrameElementConfig | undefined;
|
|
7
|
-
|
|
8
|
-
styles?: string | StylesObject;
|
|
9
|
-
baseTarget?: BaseTarget;
|
|
10
|
-
};
|
|
7
|
+
}
|
|
11
8
|
export declare const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions>;
|
|
12
9
|
declare global {
|
|
13
10
|
namespace WysiwygEditor {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autocompletion } from '@codemirror/autocomplete';
|
|
1
2
|
import type { Extension, StateCommand } from '@codemirror/state';
|
|
2
3
|
import { EditorView, EditorViewConfig, KeyBinding } from '@codemirror/view';
|
|
3
4
|
import { EventMap } from '../../bundle/Editor';
|
|
@@ -6,6 +7,7 @@ import { Receiver } from '../../utils';
|
|
|
6
7
|
import { FileUploadHandler } from './files-upload-facet';
|
|
7
8
|
import { type YfmLangOptions } from './yfm';
|
|
8
9
|
export type { YfmLangOptions };
|
|
10
|
+
declare type Autocompletion = Parameters<typeof autocompletion>[0];
|
|
9
11
|
export declare type CreateCodemirrorParams = {
|
|
10
12
|
doc: EditorViewConfig['doc'];
|
|
11
13
|
placeholderText: string;
|
|
@@ -24,6 +26,7 @@ export declare type CreateCodemirrorParams = {
|
|
|
24
26
|
keymaps?: readonly KeyBinding[];
|
|
25
27
|
receiver?: Receiver<EventMap>;
|
|
26
28
|
yfmLangOptions?: YfmLangOptions;
|
|
29
|
+
autocompletion?: Autocompletion;
|
|
27
30
|
};
|
|
28
31
|
export declare function createCodemirror(params: CreateCodemirrorParams): EditorView;
|
|
29
32
|
export declare function withLogger(action: string, command: StateCommand): StateCommand;
|
|
@@ -13,7 +13,7 @@ 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, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, } = params;
|
|
16
|
+
const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, autocompletion: autocompletionConfig, } = params;
|
|
17
17
|
const extensions = [gravityTheme, placeholder(placeholderText)];
|
|
18
18
|
if (!disabledExtensions.history) {
|
|
19
19
|
extensions.push(history());
|
|
@@ -55,7 +55,7 @@ export function createCodemirror(params) {
|
|
|
55
55
|
...defaultKeymap,
|
|
56
56
|
...(disabledExtensions.history ? [] : historyKeymap),
|
|
57
57
|
...keymaps,
|
|
58
|
-
]), autocompletion(), yfmLang(yfmLangOptions), ReactRendererFacet.of(reactRenderer), PairingCharactersExtension, EditorView.lineWrapping, EditorView.contentAttributes.of({ spellcheck: 'true' }), EditorView.domEventHandlers({
|
|
58
|
+
]), autocompletion(autocompletionConfig), yfmLang(yfmLangOptions), ReactRendererFacet.of(reactRenderer), PairingCharactersExtension, EditorView.lineWrapping, EditorView.contentAttributes.of({ spellcheck: 'true' }), EditorView.domEventHandlers({
|
|
59
59
|
scroll(event) {
|
|
60
60
|
onScroll(event);
|
|
61
61
|
},
|
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.15.0' !== 'undefined' ? '13.15.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.15.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.5.0",
|
|
204
204
|
"@diplodoc/latex-extension": "1.0.3",
|
|
205
205
|
"@diplodoc/mermaid-extension": "1.2.1",
|
|
206
206
|
"@diplodoc/transform": "4.22.0",
|