@gravity-ui/markdown-editor 13.13.0 → 13.14.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 +6 -0
- package/build/cjs/bundle/Editor.js +8 -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/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +9 -5
- package/build/cjs/extensions/yfm/YfmHtmlBlock/index.d.ts +1 -0
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/Editor.d.ts +6 -0
- package/build/esm/bundle/Editor.js +8 -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/YfmHtmlBlock/YfmHtmlBlockNodeView/YfmHtmlBlockView.js +9 -5
- package/build/esm/extensions/yfm/YfmHtmlBlock/index.d.ts +1 -0
- 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'];
|
|
@@ -86,6 +91,7 @@ export declare type EditorOptions = Pick<WysiwygEditorOptions, 'allowHTML' | 'li
|
|
|
86
91
|
* You can use it to pre-process the value from the markup editor before it gets into the wysiwyg editor.
|
|
87
92
|
*/
|
|
88
93
|
prepareRawMarkup?: (value: MarkupString) => MarkupString;
|
|
94
|
+
experimental_beforeEditorModeChange?: (options: Pick<ChangeEditorModeOptions, 'mode' | 'reason'>) => boolean | undefined;
|
|
89
95
|
splitMode?: SplitMode;
|
|
90
96
|
renderPreview?: RenderPreview;
|
|
91
97
|
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;
|
|
@@ -202,9 +204,13 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
202
204
|
this.changeEditorMode({ mode, reason: 'manually', emit: opts === null || opts === void 0 ? void 0 : opts.emit });
|
|
203
205
|
}
|
|
204
206
|
changeEditorMode(_a) {
|
|
207
|
+
var _b;
|
|
205
208
|
var { emit = true } = _a, opts = tslib_1.__rest(_a, ["emit"]);
|
|
206
209
|
if (tslib_1.__classPrivateFieldGet(this, _EditorImpl_editorMode, "f") === opts.mode)
|
|
207
210
|
return;
|
|
211
|
+
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) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
208
214
|
this.currentMode = opts.mode;
|
|
209
215
|
this.emit('rerender', null);
|
|
210
216
|
if (emit) {
|
|
@@ -284,4 +290,4 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
|
|
|
284
290
|
}
|
|
285
291
|
}
|
|
286
292
|
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();
|
|
293
|
+
_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
|
|
@@ -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 }) })),
|
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.14.0' !== 'undefined' ? '13.14.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'];
|
|
@@ -86,6 +91,7 @@ export declare type EditorOptions = Pick<WysiwygEditorOptions, 'allowHTML' | 'li
|
|
|
86
91
|
* You can use it to pre-process the value from the markup editor before it gets into the wysiwyg editor.
|
|
87
92
|
*/
|
|
88
93
|
prepareRawMarkup?: (value: MarkupString) => MarkupString;
|
|
94
|
+
experimental_beforeEditorModeChange?: (options: Pick<ChangeEditorModeOptions, 'mode' | 'reason'>) => boolean | undefined;
|
|
89
95
|
splitMode?: SplitMode;
|
|
90
96
|
renderPreview?: RenderPreview;
|
|
91
97
|
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;
|
|
@@ -199,9 +201,13 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
199
201
|
this.changeEditorMode({ mode, reason: 'manually', emit: opts === null || opts === void 0 ? void 0 : opts.emit });
|
|
200
202
|
}
|
|
201
203
|
changeEditorMode(_a) {
|
|
204
|
+
var _b;
|
|
202
205
|
var { emit = true } = _a, opts = __rest(_a, ["emit"]);
|
|
203
206
|
if (__classPrivateFieldGet(this, _EditorImpl_editorMode, "f") === opts.mode)
|
|
204
207
|
return;
|
|
208
|
+
if (((_b = __classPrivateFieldGet(this, _EditorImpl_beforeEditorModeChange, "f")) === null || _b === void 0 ? void 0 : _b.call(this, { mode: opts.mode, reason: opts.reason })) === false) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
205
211
|
this.currentMode = opts.mode;
|
|
206
212
|
this.emit('rerender', null);
|
|
207
213
|
if (emit) {
|
|
@@ -280,4 +286,4 @@ export class EditorImpl extends SafeEventEmitter {
|
|
|
280
286
|
return (serializedEditorMarkup === null || serializedEditorMarkup === void 0 ? void 0 : serializedEditorMarkup.trim()) !== wysiwygValue.trim();
|
|
281
287
|
}
|
|
282
288
|
}
|
|
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();
|
|
289
|
+
_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
|
|
@@ -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 }) })),
|
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.14.0' !== 'undefined' ? '13.14.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.14.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",
|