@gravity-ui/markdown-editor 15.7.0 → 15.8.1
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/MarkdownEditorView.d.ts +7 -28
- package/build/cjs/bundle/MarkdownEditorView.js +49 -49
- package/build/cjs/bundle/MarkdownEditorView.js.map +1 -1
- package/build/cjs/bundle/MarkupEditorComponent.d.ts +2 -1
- package/build/cjs/bundle/MarkupEditorComponent.js +2 -2
- package/build/cjs/bundle/MarkupEditorComponent.js.map +1 -1
- package/build/cjs/bundle/MarkupEditorView.js +1 -1
- package/build/cjs/bundle/MarkupEditorView.js.map +1 -1
- package/build/cjs/bundle/ToolbarView.d.ts +3 -2
- package/build/cjs/bundle/ToolbarView.js +2 -2
- package/build/cjs/bundle/ToolbarView.js.map +1 -1
- package/build/cjs/bundle/WysiwygEditorComponent.d.ts +2 -1
- package/build/cjs/bundle/WysiwygEditorComponent.js +2 -2
- package/build/cjs/bundle/WysiwygEditorComponent.js.map +1 -1
- package/build/cjs/bundle/WysiwygEditorView.js +1 -1
- package/build/cjs/bundle/WysiwygEditorView.js.map +1 -1
- package/build/cjs/bundle/settings/index.d.ts +2 -1
- package/build/cjs/bundle/settings/index.js +3 -3
- package/build/cjs/bundle/settings/index.js.map +1 -1
- package/build/cjs/bundle/toolbar/custom/ToolbarImagePopup.d.ts +1 -1
- package/build/cjs/bundle/toolbar/custom/ToolbarImagePopup.js +2 -2
- package/build/cjs/bundle/toolbar/custom/ToolbarImagePopup.js.map +1 -1
- package/build/cjs/bundle/toolbar/markup/MToolbarImagePopup.js +8 -1
- package/build/cjs/bundle/toolbar/markup/MToolbarImagePopup.js.map +1 -1
- package/build/cjs/extensions/additional/QuoteLink/index.css +1 -2
- package/build/cjs/extensions/behavior/CommandMenu/component.js +1 -1
- package/build/cjs/extensions/behavior/CommandMenu/component.js.map +1 -1
- package/build/cjs/extensions/markdown/Link/PlaceholderWidget/widget.js +1 -1
- package/build/cjs/extensions/markdown/Link/PlaceholderWidget/widget.js.map +1 -1
- package/build/cjs/forms/ImageForm.d.ts +1 -0
- package/build/cjs/forms/ImageForm.js +2 -2
- package/build/cjs/forms/ImageForm.js.map +1 -1
- package/build/cjs/markup/codemirror/create.js +16 -11
- package/build/cjs/markup/codemirror/create.js.map +1 -1
- package/build/cjs/modules/toolbars/items.js +2 -1
- package/build/cjs/modules/toolbars/items.js.map +1 -1
- package/build/cjs/toolbar/FlexToolbar.js +1 -1
- package/build/cjs/toolbar/FlexToolbar.js.map +1 -1
- package/build/cjs/toolbar/ToolbarButton.d.ts +1 -1
- package/build/cjs/toolbar/ToolbarButton.js +10 -8
- package/build/cjs/toolbar/ToolbarButton.js.map +1 -1
- package/build/cjs/toolbar/ToolbarListButton.d.ts +1 -1
- package/build/cjs/toolbar/ToolbarListButton.js +2 -2
- package/build/cjs/toolbar/ToolbarListButton.js.map +1 -1
- package/build/cjs/toolbar/types.d.ts +3 -3
- package/build/cjs/toolbar/types.js.map +1 -1
- package/build/cjs/version.js +1 -1
- package/build/cjs/version.js.map +1 -1
- package/build/cjs/view/components/YfmHtml/YfmStaticView.d.ts +3 -4
- package/build/cjs/view/components/YfmHtml/YfmStaticView.js.map +1 -1
- package/build/esm/bundle/MarkdownEditorView.d.ts +7 -28
- package/build/esm/bundle/MarkdownEditorView.js +49 -49
- package/build/esm/bundle/MarkdownEditorView.js.map +1 -1
- package/build/esm/bundle/MarkupEditorComponent.d.ts +2 -1
- package/build/esm/bundle/MarkupEditorComponent.js +2 -2
- package/build/esm/bundle/MarkupEditorComponent.js.map +1 -1
- package/build/esm/bundle/MarkupEditorView.js +1 -1
- package/build/esm/bundle/MarkupEditorView.js.map +1 -1
- package/build/esm/bundle/ToolbarView.d.ts +3 -2
- package/build/esm/bundle/ToolbarView.js +2 -2
- package/build/esm/bundle/ToolbarView.js.map +1 -1
- package/build/esm/bundle/WysiwygEditorComponent.d.ts +2 -1
- package/build/esm/bundle/WysiwygEditorComponent.js +2 -2
- package/build/esm/bundle/WysiwygEditorComponent.js.map +1 -1
- package/build/esm/bundle/WysiwygEditorView.js +1 -1
- package/build/esm/bundle/WysiwygEditorView.js.map +1 -1
- package/build/esm/bundle/settings/index.d.ts +2 -1
- package/build/esm/bundle/settings/index.js +3 -3
- package/build/esm/bundle/settings/index.js.map +1 -1
- package/build/esm/bundle/toolbar/custom/ToolbarImagePopup.d.ts +1 -1
- package/build/esm/bundle/toolbar/custom/ToolbarImagePopup.js +2 -2
- package/build/esm/bundle/toolbar/custom/ToolbarImagePopup.js.map +1 -1
- package/build/esm/bundle/toolbar/markup/MToolbarImagePopup.js +8 -1
- package/build/esm/bundle/toolbar/markup/MToolbarImagePopup.js.map +1 -1
- package/build/esm/extensions/additional/QuoteLink/index.css +1 -2
- package/build/esm/extensions/behavior/CommandMenu/component.js +1 -1
- package/build/esm/extensions/behavior/CommandMenu/component.js.map +1 -1
- package/build/esm/extensions/markdown/Link/PlaceholderWidget/widget.js +1 -1
- package/build/esm/extensions/markdown/Link/PlaceholderWidget/widget.js.map +1 -1
- package/build/esm/forms/ImageForm.d.ts +1 -0
- package/build/esm/forms/ImageForm.js +2 -2
- package/build/esm/forms/ImageForm.js.map +1 -1
- package/build/esm/markup/codemirror/create.js +16 -11
- package/build/esm/markup/codemirror/create.js.map +1 -1
- package/build/esm/modules/toolbars/items.js +2 -1
- package/build/esm/modules/toolbars/items.js.map +1 -1
- package/build/esm/toolbar/FlexToolbar.js +1 -1
- package/build/esm/toolbar/FlexToolbar.js.map +1 -1
- package/build/esm/toolbar/ToolbarButton.d.ts +1 -1
- package/build/esm/toolbar/ToolbarButton.js +10 -8
- package/build/esm/toolbar/ToolbarButton.js.map +1 -1
- package/build/esm/toolbar/ToolbarListButton.d.ts +1 -1
- package/build/esm/toolbar/ToolbarListButton.js +2 -2
- package/build/esm/toolbar/ToolbarListButton.js.map +1 -1
- package/build/esm/toolbar/types.d.ts +3 -3
- package/build/esm/toolbar/types.js.map +1 -1
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esm/view/components/YfmHtml/YfmStaticView.d.ts +3 -4
- package/build/esm/view/components/YfmHtml/YfmStaticView.js.map +1 -1
- package/build/styles.css +1 -2
- package/package.json +2 -2
|
@@ -6,10 +6,7 @@ import type { MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData } f
|
|
|
6
6
|
import "../styles/styles.css";
|
|
7
7
|
import "./MarkdownEditorView.css";
|
|
8
8
|
export declare const cnEditorComponent: import("@bem-react/classname").ClassNameFormatter;
|
|
9
|
-
|
|
10
|
-
editor?: Editor;
|
|
11
|
-
autofocus?: boolean;
|
|
12
|
-
toolbarsPreset?: ToolbarsPreset;
|
|
9
|
+
type ToolbarConfigs = {
|
|
13
10
|
/**
|
|
14
11
|
* @deprecated use `toolbarsPreset` instead
|
|
15
12
|
*/
|
|
@@ -26,35 +23,17 @@ export type MarkdownEditorViewProps = ClassNameProps & QAProps & {
|
|
|
26
23
|
* @deprecated use `toolbarsPreset` instead
|
|
27
24
|
*/
|
|
28
25
|
wysiwygHiddenActionsConfig?: WToolbarItemData[];
|
|
29
|
-
/** @default true */
|
|
30
|
-
settingsVisible?: boolean;
|
|
31
|
-
stickyToolbar: boolean;
|
|
32
|
-
enableSubmitInPreview?: boolean;
|
|
33
|
-
hidePreviewAfterSubmit?: boolean;
|
|
34
26
|
};
|
|
35
|
-
|
|
27
|
+
type ViewProps = {
|
|
36
28
|
editor?: Editor;
|
|
37
29
|
autofocus?: boolean;
|
|
38
|
-
toolbarsPreset?: ToolbarsPreset;
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated use `toolbarsPreset` instead
|
|
41
|
-
*/
|
|
42
|
-
markupToolbarConfig?: MToolbarData;
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated use `toolbarsPreset` instead
|
|
45
|
-
*/
|
|
46
|
-
wysiwygToolbarConfig?: WToolbarData;
|
|
47
|
-
/**
|
|
48
|
-
* @deprecated use `toolbarsPreset` instead
|
|
49
|
-
*/
|
|
50
|
-
markupHiddenActionsConfig?: MToolbarItemData[];
|
|
51
|
-
/**
|
|
52
|
-
* @deprecated use `toolbarsPreset` instead
|
|
53
|
-
*/
|
|
54
|
-
wysiwygHiddenActionsConfig?: WToolbarItemData[];
|
|
55
30
|
/** @default true */
|
|
56
31
|
settingsVisible?: boolean;
|
|
32
|
+
toolbarsPreset?: ToolbarsPreset;
|
|
57
33
|
stickyToolbar: boolean;
|
|
58
34
|
enableSubmitInPreview?: boolean;
|
|
59
35
|
hidePreviewAfterSubmit?: boolean;
|
|
60
|
-
}
|
|
36
|
+
};
|
|
37
|
+
export type MarkdownEditorViewProps = ClassNameProps & ToolbarConfigs & ViewProps & QAProps & {};
|
|
38
|
+
export declare const MarkdownEditorView: import("react").ForwardRefExoticComponent<ClassNameProps & ToolbarConfigs & ViewProps & QAProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
39
|
+
export {};
|
|
@@ -23,18 +23,7 @@ require("../styles/styles.css");
|
|
|
23
23
|
require("./MarkdownEditorView.css"); // eslint-disable-line import/order
|
|
24
24
|
exports.cnEditorComponent = (0, classname_1.cn)('editor-component');
|
|
25
25
|
const b = exports.cnEditorComponent;
|
|
26
|
-
|
|
27
|
-
const divRef = (0, react_use_1.useEnsuredForwardedRef)(ref);
|
|
28
|
-
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
29
|
-
(0, react_1.useEffect)(() => {
|
|
30
|
-
setIsMounted(true);
|
|
31
|
-
}, []);
|
|
32
|
-
const [showPreview, , unsetShowPreview, toggleShowPreview] = (0, react_utils_1.useBooleanState)(false);
|
|
33
|
-
const context = (0, context_1.useMarkdownEditorContext)();
|
|
34
|
-
const editor = (props.editor ?? context);
|
|
35
|
-
if (!editor)
|
|
36
|
-
throw new Error('[MarkdownEditorView]: an instance of the editor must be passed through the props or context');
|
|
37
|
-
const { qa, autofocus, className, settingsVisible = true, toolbarsPreset, stickyToolbar, wysiwygToolbarConfig: initialWysiwygToolbarConfig, markupToolbarConfig: initialMarkupToolbarConfig, wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig, markupHiddenActionsConfig: initialMarkupHiddenActionsConfig, enableSubmitInPreview = true, hidePreviewAfterSubmit = false, } = props;
|
|
26
|
+
const EditorWrapper = (0, react_1.forwardRef)(({ autofocus, editor, editorMode, enableSubmitInPreview, hidePreviewAfterSubmit, isFocused, markupHiddenActionsConfig: initialMarkupHiddenActionsConfig, markupToolbarConfig: initialMarkupToolbarConfig, qa, settingsVisible, showPreview, stickyToolbar, toggleShowPreview, toolbarsPreset, unsetShowPreview, wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig, wysiwygToolbarConfig: initialWysiwygToolbarConfig, }, ref) => {
|
|
38
27
|
const { wysiwygToolbarConfig, markupToolbarConfig, wysiwygHiddenActionsConfig, markupHiddenActionsConfig, } = (0, react_1.useMemo)(() => (0, toolbarsConfigs_1.getToolbarsConfigs)({
|
|
39
28
|
toolbarsPreset,
|
|
40
29
|
props: {
|
|
@@ -52,13 +41,6 @@ exports.MarkdownEditorView = (0, react_1.forwardRef)((props, ref) => {
|
|
|
52
41
|
initialMarkupHiddenActionsConfig,
|
|
53
42
|
editor.preset,
|
|
54
43
|
]);
|
|
55
|
-
const rerender = (0, react_use_1.useUpdate)();
|
|
56
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
57
|
-
editor.on('rerender', rerender);
|
|
58
|
-
return () => {
|
|
59
|
-
editor.off('rerender', rerender);
|
|
60
|
-
};
|
|
61
|
-
}, [editor, rerender]);
|
|
62
44
|
const onModeChange = (0, react_1.useCallback)((type) => {
|
|
63
45
|
editor.changeEditorMode({ mode: type, reason: 'settings' });
|
|
64
46
|
unsetShowPreview();
|
|
@@ -75,44 +57,67 @@ exports.MarkdownEditorView = (0, react_1.forwardRef)((props, ref) => {
|
|
|
75
57
|
if (showPreviewValue !== showPreview)
|
|
76
58
|
toggleShowPreview();
|
|
77
59
|
}, [editor, showPreview, toggleShowPreview]);
|
|
78
|
-
const editorMode = editor.currentMode;
|
|
79
|
-
const markupSplitMode = editor.splitModeEnabled && editor.splitMode && editorMode === 'markup';
|
|
80
60
|
const canRenderPreview = Boolean(editor.renderPreview && editorMode === 'markup' && !editor.splitModeEnabled);
|
|
81
61
|
(0, react_use_1.useKey)((e) => canRenderPreview && isPreviewKeyDown(e), (e) => {
|
|
82
62
|
e.preventDefault();
|
|
83
63
|
onShowPreviewChange(!showPreview);
|
|
84
64
|
}, { event: 'keydown' }, [showPreview, editorMode, onShowPreviewChange, canRenderPreview]);
|
|
85
|
-
|
|
86
|
-
const splitModeViewWrapperRef = (0, react_1.useRef)(null);
|
|
87
|
-
(0, react_1.useEffect)(() => {
|
|
88
|
-
if (showPreview) {
|
|
89
|
-
divRef.current.focus();
|
|
90
|
-
}
|
|
91
|
-
}, [divRef, showPreview]);
|
|
92
|
-
(0, react_use_1.useKey)((e) => enableSubmitInPreview &&
|
|
93
|
-
showPreview &&
|
|
94
|
-
isWrapperFocused(divRef) &&
|
|
95
|
-
isSubmitKeyDown(e), () => {
|
|
65
|
+
(0, react_use_1.useKey)((e) => Boolean(enableSubmitInPreview && showPreview && isFocused && isSubmitKeyDown(e)), () => {
|
|
96
66
|
editor.emit('submit', null);
|
|
97
67
|
if (hidePreviewAfterSubmit) {
|
|
98
68
|
onShowPreviewChange(false);
|
|
99
69
|
}
|
|
100
70
|
}, { event: 'keydown' }, [hidePreviewAfterSubmit, enableSubmitInPreview, showPreview, showPreview]);
|
|
101
|
-
const
|
|
102
|
-
editorMode,
|
|
103
|
-
settingsVisible,
|
|
104
|
-
editor.toolbarVisible,
|
|
105
|
-
editor.splitModeEnabled,
|
|
106
|
-
editor.splitMode,
|
|
71
|
+
const settingsProps = {
|
|
72
|
+
mode: editorMode,
|
|
107
73
|
onModeChange,
|
|
108
|
-
|
|
109
|
-
onToolbarVisibilityChange,
|
|
74
|
+
onShowPreviewChange,
|
|
110
75
|
onSplitModeChange,
|
|
76
|
+
onToolbarVisibilityChange,
|
|
77
|
+
renderPreviewButton: canRenderPreview,
|
|
78
|
+
showPreview,
|
|
79
|
+
splitMode: editor.splitMode,
|
|
80
|
+
splitModeEnabled: editor.splitModeEnabled,
|
|
111
81
|
stickyToolbar,
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
82
|
+
toolbarVisibility: editor.toolbarVisible && !showPreview,
|
|
83
|
+
};
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: b('editor-wrapper'), ref: ref, "data-qa": qa, "data-mode": editor.currentMode, children: showPreview ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: b('preview-wrapper'), children: editor.renderPreview?.({
|
|
85
|
+
getValue: editor.getValue,
|
|
86
|
+
mode: 'preview',
|
|
87
|
+
md: editor.mdOptions,
|
|
88
|
+
directiveSyntax: editor.directiveSyntax,
|
|
89
|
+
}) }), (0, jsx_runtime_1.jsx)(Settings, { ...settingsProps, settingsVisible: settingsVisible })] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [editorMode === 'wysiwyg' && ((0, jsx_runtime_1.jsx)(WysiwygEditorView_1.WysiwygEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: wysiwygToolbarConfig, toolbarVisible: editor.toolbarVisible, hiddenActionsConfig: wysiwygHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar, children: (0, jsx_runtime_1.jsx)(Settings, { ...settingsProps, settingsVisible: settingsVisible && editor.toolbarVisible }) })), editorMode === 'markup' && ((0, jsx_runtime_1.jsx)(MarkupEditorView_1.MarkupEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: markupToolbarConfig, toolbarVisible: editor.toolbarVisible, splitMode: editor.splitMode, splitModeEnabled: editor.splitModeEnabled, hiddenActionsConfig: markupHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar, children: (0, jsx_runtime_1.jsx)(Settings, { ...settingsProps, settingsVisible: settingsVisible && editor.toolbarVisible }) })), (0, jsx_runtime_1.jsx)(Settings, { ...settingsProps, settingsVisible: !editor.toolbarVisible && settingsVisible, renderPreviewButton: !editor.toolbarVisible && editorMode === 'markup' })] })) }));
|
|
90
|
+
});
|
|
91
|
+
EditorWrapper.displayName = 'EditorWrapper';
|
|
92
|
+
exports.MarkdownEditorView = (0, react_1.forwardRef)((props, ref) => {
|
|
93
|
+
const divRef = (0, react_use_1.useEnsuredForwardedRef)(ref);
|
|
94
|
+
const editorWrapperRef = (0, react_1.useRef)(null);
|
|
95
|
+
const [showPreview, , unsetShowPreview, toggleShowPreview] = (0, react_utils_1.useBooleanState)(false);
|
|
96
|
+
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
97
|
+
(0, react_1.useEffect)(() => {
|
|
98
|
+
setIsMounted(true);
|
|
99
|
+
}, []);
|
|
100
|
+
const context = (0, context_1.useMarkdownEditorContext)();
|
|
101
|
+
const editor = (props.editor ?? context);
|
|
102
|
+
if (!editor)
|
|
103
|
+
throw new Error('[MarkdownEditorView]: an instance of the editor must be passed through the props or context');
|
|
104
|
+
const { autofocus, className, enableSubmitInPreview = true, hidePreviewAfterSubmit = false, markupHiddenActionsConfig, markupToolbarConfig, qa, settingsVisible = true, stickyToolbar, toolbarsPreset, wysiwygHiddenActionsConfig, wysiwygToolbarConfig, } = props;
|
|
105
|
+
const rerender = (0, react_use_1.useUpdate)();
|
|
106
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
107
|
+
editor.on('rerender', rerender);
|
|
108
|
+
return () => {
|
|
109
|
+
editor.off('rerender', rerender);
|
|
110
|
+
};
|
|
111
|
+
}, [editor, rerender]);
|
|
112
|
+
const editorMode = editor.currentMode;
|
|
113
|
+
const markupSplitMode = editor.splitModeEnabled && editor.splitMode && editorMode === 'markup';
|
|
114
|
+
const splitModeViewWrapperRef = (0, react_1.useRef)(null);
|
|
115
115
|
const toaster = (0, uikit_1.useToaster)();
|
|
116
|
+
(0, react_1.useEffect)(() => {
|
|
117
|
+
if (showPreview) {
|
|
118
|
+
divRef.current.focus();
|
|
119
|
+
}
|
|
120
|
+
}, [divRef, showPreview]);
|
|
116
121
|
return ((0, jsx_runtime_1.jsx)(react_error_boundary_1.ErrorBoundary, { onError: (e) => {
|
|
117
122
|
logger_1.globalLogger.error(e);
|
|
118
123
|
editor.logger.error(e);
|
|
@@ -135,12 +140,7 @@ exports.MarkdownEditorView = (0, react_1.forwardRef)((props, ref) => {
|
|
|
135
140
|
}, children: (0, jsx_runtime_1.jsxs)("div", { ref: divRef, "data-qa": qa, className: b({
|
|
136
141
|
settings: settingsVisible,
|
|
137
142
|
split: markupSplitMode && editor.splitMode,
|
|
138
|
-
}, [className]), role: "button", tabIndex: 0, children: [(0, jsx_runtime_1.jsx)(
|
|
139
|
-
getValue: editor.getValue,
|
|
140
|
-
mode: 'preview',
|
|
141
|
-
md: editor.mdOptions,
|
|
142
|
-
directiveSyntax: editor.directiveSyntax,
|
|
143
|
-
}) }), settings] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [editorMode === 'wysiwyg' && ((0, jsx_runtime_1.jsx)(WysiwygEditorView_1.WysiwygEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: wysiwygToolbarConfig, toolbarVisible: editor.toolbarVisible, hiddenActionsConfig: wysiwygHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar, children: editor.toolbarVisible && settingsVisible && settings })), editorMode === 'markup' && ((0, jsx_runtime_1.jsx)(MarkupEditorView_1.MarkupEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: markupToolbarConfig, toolbarVisible: editor.toolbarVisible, splitMode: editor.splitMode, splitModeEnabled: editor.splitModeEnabled, hiddenActionsConfig: markupHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar, children: editor.toolbarVisible && settings })), !editor.toolbarVisible && settings] })) }), markupSplitMode && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [editor.splitMode === 'horizontal' ? ((0, jsx_runtime_1.jsx)(HorizontalDrag_1.HorizontalDrag, { editor: editor, isMounted: isMounted, leftElRef: editorWrapperRef, rightElRef: splitModeViewWrapperRef, wrapperRef: divRef })) : ((0, jsx_runtime_1.jsx)("div", { className: b('resizer') })), (0, jsx_runtime_1.jsx)(SplitModeView_1.SplitModeView, { editor: editor, ref: splitModeViewWrapperRef })] }))] }) }));
|
|
143
|
+
}, [className]), role: "button", tabIndex: 0, children: [(0, jsx_runtime_1.jsx)(EditorWrapper, { autofocus: autofocus, editor: editor, editorMode: editorMode, enableSubmitInPreview: enableSubmitInPreview, hidePreviewAfterSubmit: hidePreviewAfterSubmit, isFocused: isWrapperFocused(divRef), markupHiddenActionsConfig: markupHiddenActionsConfig, markupToolbarConfig: markupToolbarConfig, qa: "g-md-editor-mode", ref: editorWrapperRef, settingsVisible: settingsVisible, showPreview: showPreview, stickyToolbar: stickyToolbar, toggleShowPreview: toggleShowPreview, toolbarsPreset: toolbarsPreset, unsetShowPreview: unsetShowPreview, wysiwygHiddenActionsConfig: wysiwygHiddenActionsConfig, wysiwygToolbarConfig: wysiwygToolbarConfig }), markupSplitMode && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [editor.splitMode === 'horizontal' ? ((0, jsx_runtime_1.jsx)(HorizontalDrag_1.HorizontalDrag, { editor: editor, isMounted: isMounted, leftElRef: editorWrapperRef, rightElRef: splitModeViewWrapperRef, wrapperRef: divRef })) : ((0, jsx_runtime_1.jsx)("div", { className: b('resizer') })), (0, jsx_runtime_1.jsx)(SplitModeView_1.SplitModeView, { editor: editor, ref: splitModeViewWrapperRef })] }))] }) }));
|
|
144
144
|
});
|
|
145
145
|
exports.MarkdownEditorView.displayName = 'MarkdownEditorView';
|
|
146
146
|
const MarkupSearchAnchor = ({ mode }) => ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: mode === 'markup' && (0, jsx_runtime_1.jsx)("div", { className: "g-md-search-anchor" }) }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditorView.js","sourceRoot":"../../../src","sources":["bundle/MarkdownEditorView.tsx"],"names":[],"mappings":";;;;AAAA,iCAQe;AAEf,6CAA2D;AAC3D,+DAAmD;AACnD,yCAAoE;AAEpE,+CAAqD;AACrD,oDAAoC;AACpC,yCAAuC;AAEvC,yDAA0D;AAC1D,6CAA+B;AAG/B,wDAAgD;AAChD,4DAAoD;AACpD,sDAA8C;AAC9C,8DAAsD;AACtD,0CAAmD;AACnD,kDAAoE;AACpE,8CAAkC;AAElC,wEAAmE;AAGnE,gCAA+B;AAC/B,oCAAmC,CAAC,mCAAmC;AAE1D,QAAA,iBAAiB,GAAG,IAAA,cAAE,EAAC,kBAAkB,CAAC,CAAC;AACxD,MAAM,CAAC,GAAG,yBAAiB,CAAC;AA8Bf,QAAA,kBAAkB,GAAG,IAAA,kBAAU,EACxC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;IACX,MAAM,MAAM,GAAG,IAAA,kCAAsB,EAAC,GAA6C,CAAC,CAAC;IAErF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAClD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,CAAC,WAAW,EAAE,AAAD,EAAG,gBAAgB,EAAE,iBAAiB,CAAC,GAAG,IAAA,6BAAe,EAAC,KAAK,CAAC,CAAC;IAEpF,MAAM,OAAO,GAAG,IAAA,kCAAwB,GAAE,CAAC;IAC3C,MAAM,MAAM,GAAG,C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O,CACH,2DACK,CAAC,KAAK,CAAC,mBAAmB,IAAI,KAAK,CAAC,eAAe,CAAC,IAAI,CACrD,gCAAK,SAAS,EAAE,CAAC,CAAC,kBAAkB,CAAC,YACjC,iCACI,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,iBAAQ,CAAC,QAAQ,CAAC;oBACzB,WAAW,EAAE,KAAK,CAAC,iBAAiB;oBACpC,YAAY,EAAE,QAAQ;iBACzB,CAAC,aAEF,uBAAC,yBAAc,OAAK,KAAK,GAAI,EAC7B,uBAAC,kBAAkB,OAAK,KAAK,GAAI,IAC/B,GACJ,CACT,GACF,CACN,CAAC;AACN,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAgB;IACtC,MAAM,MAAM,GAAG,IAAA,aAAK,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,OAAO,MAAM,IAAI,CAAC,CAAC,QAAQ,IAAI,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;AACrD,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAuC;IAC7D,OAAO,QAAQ,CAAC,aAAa,KAAK,MAAM,CAAC,OAAO,CAAC;AACrD,CAAC;AAED,SAAS,eAAe,CAAC,CAAgB;IACrC,MAAM,MAAM,GAAG,IAAA,aAAK,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,OAAO,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC;AACxC,CAAC","sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {type QAProps, useToaster} from '@gravity-ui/uikit';\nimport {ErrorBoundary} from 'react-error-boundary';\nimport {useEnsuredForwardedRef, useKey, useUpdate} from 'react-use';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {i18n} from '../i18n/bundle';\nimport {globalLogger} from '../logger';\nimport type {ToolbarsPreset} from '../modules/toolbars/types';\nimport {useBooleanState, useSticky} from '../react-utils';\nimport {isMac} from '../utils';\n\nimport type {Editor, EditorInt} from './Editor';\nimport {HorizontalDrag} from './HorizontalDrag';\nimport {MarkupEditorView} from './MarkupEditorView';\nimport {SplitModeView} from './SplitModeView';\nimport {WysiwygEditorView} from './WysiwygEditorView';\nimport {useMarkdownEditorContext} from './context';\nimport {EditorSettings, type EditorSettingsProps} from './settings';\nimport {stickyCn} from './sticky';\nimport type {MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData} from './toolbar/types';\nimport {getToolbarsConfigs} from './toolbar/utils/toolbarsConfigs';\nimport type {MarkdownEditorMode} from './types';\n\nimport '../styles/styles.scss';\nimport './MarkdownEditorView.scss'; // eslint-disable-line import/order\n\nexport const cnEditorComponent = cn('editor-component');\nconst b = cnEditorComponent;\n\nexport type MarkdownEditorViewProps = ClassNameProps &\n QAProps & {\n editor?: Editor;\n autofocus?: boolean;\n toolbarsPreset?: ToolbarsPreset;\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n markupToolbarConfig?: MToolbarData;\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n wysiwygToolbarConfig?: WToolbarData;\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n markupHiddenActionsConfig?: MToolbarItemData[];\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n wysiwygHiddenActionsConfig?: WToolbarItemData[];\n /** @default true */\n settingsVisible?: boolean;\n stickyToolbar: boolean;\n enableSubmitInPreview?: boolean;\n hidePreviewAfterSubmit?: boolean;\n };\n\nexport const MarkdownEditorView = forwardRef<HTMLDivElement, MarkdownEditorViewProps>(\n (props, ref) => {\n const divRef = useEnsuredForwardedRef(ref as React.MutableRefObject<HTMLDivElement>);\n\n const [isMounted, setIsMounted] = useState(false);\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n const [showPreview, , unsetShowPreview, toggleShowPreview] = useBooleanState(false);\n\n const context = useMarkdownEditorContext();\n const editor = (props.editor ?? context) as EditorInt;\n if (!editor)\n throw new Error(\n '[MarkdownEditorView]: an instance of the editor must be passed through the props or context',\n );\n\n const {\n qa,\n autofocus,\n className,\n settingsVisible = true,\n toolbarsPreset,\n stickyToolbar,\n wysiwygToolbarConfig: initialWysiwygToolbarConfig,\n markupToolbarConfig: initialMarkupToolbarConfig,\n wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig,\n markupHiddenActionsConfig: initialMarkupHiddenActionsConfig,\n enableSubmitInPreview = true,\n hidePreviewAfterSubmit = false,\n } = props;\n\n const {\n wysiwygToolbarConfig,\n markupToolbarConfig,\n wysiwygHiddenActionsConfig,\n markupHiddenActionsConfig,\n } = useMemo(\n () =>\n getToolbarsConfigs({\n toolbarsPreset,\n props: {\n wysiwygToolbarConfig: initialWysiwygToolbarConfig,\n markupToolbarConfig: initialMarkupToolbarConfig,\n wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig,\n markupHiddenActionsConfig: initialMarkupHiddenActionsConfig,\n },\n preset: editor.preset,\n }),\n [\n toolbarsPreset,\n initialWysiwygToolbarConfig,\n initialMarkupToolbarConfig,\n initialWysiwygHiddenActionsConfig,\n initialMarkupHiddenActionsConfig,\n editor.preset,\n ],\n );\n\n const rerender = useUpdate();\n useLayoutEffect(() => {\n editor.on('rerender', rerender);\n return () => {\n editor.off('rerender', rerender);\n };\n }, [editor, rerender]);\n\n const onModeChange = useCallback(\n (type: MarkdownEditorMode) => {\n editor.changeEditorMode({mode: type, reason: 'settings'});\n unsetShowPreview();\n },\n [editor, unsetShowPreview],\n );\n const onToolbarVisibilityChange = useCallback(\n (visible: boolean) => {\n editor.changeToolbarVisibility({visible});\n },\n [editor],\n );\n const onSplitModeChange = useCallback(\n (splitModeEnabled: boolean) => {\n unsetShowPreview();\n editor.changeSplitModeEnabled({splitModeEnabled});\n },\n [editor, unsetShowPreview],\n );\n\n const onShowPreviewChange = useCallback(\n (showPreviewValue: boolean) => {\n editor.changeSplitModeEnabled({splitModeEnabled: false});\n if (showPreviewValue !== showPreview) toggleShowPreview();\n },\n [editor, showPreview, toggleShowPreview],\n );\n\n const editorMode = editor.currentMode;\n const markupSplitMode =\n editor.splitModeEnabled && editor.splitMode && editorMode === 'markup';\n const canRenderPreview = Boolean(\n editor.renderPreview && editorMode === 'markup' && !editor.splitModeEnabled,\n );\n\n useKey(\n (e) => canRenderPreview && isPreviewKeyDown(e),\n (e) => {\n e.preventDefault();\n onShowPreviewChange(!showPreview);\n },\n {event: 'keydown'},\n [showPreview, editorMode, onShowPreviewChange, canRenderPreview],\n );\n\n const editorWrapperRef = useRef(null);\n const splitModeViewWrapperRef = useRef(null);\n\n useEffect(() => {\n if (showPreview) {\n divRef.current.focus();\n }\n }, [divRef, showPreview]);\n\n useKey(\n (e) =>\n enableSubmitInPreview &&\n showPreview &&\n isWrapperFocused(divRef) &&\n isSubmitKeyDown(e),\n () => {\n editor.emit('submit', null);\n\n if (hidePreviewAfterSubmit) {\n onShowPreviewChange(false);\n }\n },\n {event: 'keydown'},\n [hidePreviewAfterSubmit, enableSubmitInPreview, showPreview, showPreview],\n );\n\n const settings = useMemo(\n () => (\n <Settings\n mode={editorMode}\n settingsVisible={settingsVisible}\n onModeChange={onModeChange}\n toolbarVisibility={editor.toolbarVisible && !showPreview}\n onToolbarVisibilityChange={onToolbarVisibilityChange}\n onSplitModeChange={onSplitModeChange}\n splitModeEnabled={editor.splitModeEnabled}\n splitMode={editor.splitMode}\n stickyToolbar={stickyToolbar}\n onShowPreviewChange={onShowPreviewChange}\n showPreview={showPreview}\n renderPreviewButton={canRenderPreview}\n />\n ),\n [\n editorMode,\n settingsVisible,\n editor.toolbarVisible,\n editor.splitModeEnabled,\n editor.splitMode,\n onModeChange,\n showPreview,\n onToolbarVisibilityChange,\n onSplitModeChange,\n stickyToolbar,\n onShowPreviewChange,\n canRenderPreview,\n ],\n );\n\n const toaster = useToaster();\n\n return (\n <ErrorBoundary\n onError={(e) => {\n globalLogger.error(e);\n editor.logger.error(e);\n }}\n fallbackRender={({error, resetErrorBoundary}) => {\n toaster.add({\n theme: 'danger',\n name: 'g-md-editor-error',\n title: i18n('error-title'),\n content: error.message,\n });\n setTimeout(() => {\n resetErrorBoundary();\n editor.changeEditorMode({\n mode: 'markup',\n reason: 'error-boundary',\n emit: false,\n });\n });\n return null;\n }}\n >\n <div\n ref={divRef}\n data-qa={qa}\n className={b(\n {\n settings: settingsVisible,\n split: markupSplitMode && editor.splitMode,\n },\n [className],\n )}\n role=\"button\"\n tabIndex={0}\n >\n <div\n className={b('editor-wrapper')}\n ref={editorWrapperRef}\n data-qa=\"g-md-editor-mode\"\n data-mode={editor.currentMode}\n >\n {showPreview ? (\n <>\n <div className={b('preview-wrapper')}>\n {editor.renderPreview?.({\n getValue: editor.getValue,\n mode: 'preview',\n md: editor.mdOptions,\n directiveSyntax: editor.directiveSyntax,\n })}\n </div>\n {settings}\n </>\n ) : (\n <>\n {editorMode === 'wysiwyg' && (\n <WysiwygEditorView\n editor={editor}\n autofocus={autofocus}\n settingsVisible={settingsVisible}\n toolbarConfig={wysiwygToolbarConfig}\n toolbarVisible={editor.toolbarVisible}\n hiddenActionsConfig={wysiwygHiddenActionsConfig}\n className={b('editor', {mode: editorMode})}\n toolbarClassName={b('toolbar')}\n stickyToolbar={stickyToolbar}\n >\n {editor.toolbarVisible && settingsVisible && settings}\n </WysiwygEditorView>\n )}\n {editorMode === 'markup' && (\n <MarkupEditorView\n editor={editor}\n autofocus={autofocus}\n settingsVisible={settingsVisible}\n toolbarConfig={markupToolbarConfig}\n toolbarVisible={editor.toolbarVisible}\n splitMode={editor.splitMode}\n splitModeEnabled={editor.splitModeEnabled}\n hiddenActionsConfig={markupHiddenActionsConfig}\n className={b('editor', {mode: editorMode})}\n toolbarClassName={b('toolbar')}\n stickyToolbar={stickyToolbar}\n >\n {editor.toolbarVisible && settings}\n </MarkupEditorView>\n )}\n {!editor.toolbarVisible && settings}\n </>\n )}\n </div>\n\n {markupSplitMode && (\n <>\n {editor.splitMode === 'horizontal' ? (\n <HorizontalDrag\n editor={editor}\n isMounted={isMounted}\n leftElRef={editorWrapperRef}\n rightElRef={splitModeViewWrapperRef}\n wrapperRef={divRef}\n />\n ) : (\n <div className={b('resizer')} />\n )}\n <SplitModeView editor={editor} ref={splitModeViewWrapperRef} />\n </>\n )}\n </div>\n </ErrorBoundary>\n );\n },\n);\nMarkdownEditorView.displayName = 'MarkdownEditorView';\n\ninterface MarkupSearchAnchorProps extends Pick<EditorSettingsProps, 'mode'> {}\n\nconst MarkupSearchAnchor: React.FC<MarkupSearchAnchorProps> = ({mode}) => (\n <>{mode === 'markup' && <div className=\"g-md-search-anchor\"></div>}</>\n);\n\nfunction Settings(props: EditorSettingsProps & {stickyToolbar: boolean}) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const isSticky = useSticky(wrapperRef) && props.toolbarVisibility && props.stickyToolbar;\n\n return (\n <>\n {(props.renderPreviewButton || props.settingsVisible) && (\n <div className={b('settings-wrapper')}>\n <div\n ref={wrapperRef}\n className={stickyCn.settings({\n withToolbar: props.toolbarVisibility,\n stickyActive: isSticky,\n })}\n >\n <EditorSettings {...props} />\n <MarkupSearchAnchor {...props} />\n </div>\n </div>\n )}\n </>\n );\n}\n\nfunction isPreviewKeyDown(e: KeyboardEvent) {\n const modKey = isMac() ? e.metaKey : e.ctrlKey;\n return modKey && e.shiftKey && e.code === 'KeyP';\n}\n\nfunction isWrapperFocused(divRef: React.RefObject<HTMLDivElement>) {\n return document.activeElement === divRef.current;\n}\n\nfunction isSubmitKeyDown(e: KeyboardEvent) {\n const modKey = isMac() ? e.metaKey : e.ctrlKey;\n return modKey && e.code === 'Enter';\n}\n"]}
|
|
1
|
+
{"version":3,"file":"MarkdownEditorView.js","sourceRoot":"../../../src","sources":["bundle/MarkdownEditorView.tsx"],"names":[],"mappings":";;;;AAAA,iCAQe;AAEf,6CAA2D;AAC3D,+DAAmD;AACnD,yCAAoE;AA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GAAG,IAAA,aAAK,GAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/C,OAAO,MAAM,IAAI,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC;AACxC,CAAC","sourcesContent":["import {\n forwardRef,\n useCallback,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from 'react';\n\nimport {type QAProps, useToaster} from '@gravity-ui/uikit';\nimport {ErrorBoundary} from 'react-error-boundary';\nimport {useEnsuredForwardedRef, useKey, useUpdate} from 'react-use';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {i18n} from '../i18n/bundle';\nimport {globalLogger} from '../logger';\nimport type {ToolbarsPreset} from '../modules/toolbars/types';\nimport {useBooleanState, useSticky} from '../react-utils';\nimport {isMac} from '../utils';\n\nimport type {Editor, EditorInt} from './Editor';\nimport {HorizontalDrag} from './HorizontalDrag';\nimport {MarkupEditorView} from './MarkupEditorView';\nimport {SplitModeView} from './SplitModeView';\nimport {WysiwygEditorView} from './WysiwygEditorView';\nimport {useMarkdownEditorContext} from './context';\nimport {EditorSettings, type EditorSettingsProps} from './settings';\nimport {stickyCn} from './sticky';\nimport type {MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData} from './toolbar/types';\nimport {getToolbarsConfigs} from './toolbar/utils/toolbarsConfigs';\nimport type {MarkdownEditorMode} from './types';\n\nimport '../styles/styles.scss';\nimport './MarkdownEditorView.scss'; // eslint-disable-line import/order\n\nexport const cnEditorComponent = cn('editor-component');\nconst b = cnEditorComponent;\n\ninterface EditorWrapperProps extends QAProps, ToolbarConfigs, Omit<ViewProps, 'editor'> {\n editor: EditorInt;\n editorMode: MarkdownEditorMode;\n isFocused: boolean;\n showPreview: boolean;\n toggleShowPreview: () => void;\n unsetShowPreview: () => void;\n}\nconst EditorWrapper = forwardRef<HTMLDivElement, EditorWrapperProps>(\n (\n {\n autofocus,\n editor,\n editorMode,\n enableSubmitInPreview,\n hidePreviewAfterSubmit,\n isFocused,\n markupHiddenActionsConfig: initialMarkupHiddenActionsConfig,\n markupToolbarConfig: initialMarkupToolbarConfig,\n qa,\n settingsVisible,\n showPreview,\n stickyToolbar,\n toggleShowPreview,\n toolbarsPreset,\n unsetShowPreview,\n wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig,\n wysiwygToolbarConfig: initialWysiwygToolbarConfig,\n },\n ref,\n ) => {\n const {\n wysiwygToolbarConfig,\n markupToolbarConfig,\n wysiwygHiddenActionsConfig,\n markupHiddenActionsConfig,\n } = useMemo(\n () =>\n getToolbarsConfigs({\n toolbarsPreset,\n props: {\n wysiwygToolbarConfig: initialWysiwygToolbarConfig,\n markupToolbarConfig: initialMarkupToolbarConfig,\n wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig,\n markupHiddenActionsConfig: initialMarkupHiddenActionsConfig,\n },\n preset: editor.preset,\n }),\n [\n toolbarsPreset,\n initialWysiwygToolbarConfig,\n initialMarkupToolbarConfig,\n initialWysiwygHiddenActionsConfig,\n initialMarkupHiddenActionsConfig,\n editor.preset,\n ],\n );\n const onModeChange = useCallback(\n (type: MarkdownEditorMode) => {\n editor.changeEditorMode({mode: type, reason: 'settings'});\n unsetShowPreview();\n },\n [editor, unsetShowPreview],\n );\n const onToolbarVisibilityChange = useCallback(\n (visible: boolean) => {\n editor.changeToolbarVisibility({visible});\n },\n [editor],\n );\n const onSplitModeChange = useCallback(\n (splitModeEnabled: boolean) => {\n unsetShowPreview();\n editor.changeSplitModeEnabled({splitModeEnabled});\n },\n [editor, unsetShowPreview],\n );\n const onShowPreviewChange = useCallback(\n (showPreviewValue: boolean) => {\n editor.changeSplitModeEnabled({splitModeEnabled: false});\n if (showPreviewValue !== showPreview) toggleShowPreview();\n },\n [editor, showPreview, toggleShowPreview],\n );\n const canRenderPreview = Boolean(\n editor.renderPreview && editorMode === 'markup' && !editor.splitModeEnabled,\n );\n\n useKey(\n (e) => canRenderPreview && isPreviewKeyDown(e),\n (e) => {\n e.preventDefault();\n onShowPreviewChange(!showPreview);\n },\n {event: 'keydown'},\n [showPreview, editorMode, onShowPreviewChange, canRenderPreview],\n );\n\n useKey(\n (e) => Boolean(enableSubmitInPreview && showPreview && isFocused && isSubmitKeyDown(e)),\n () => {\n editor.emit('submit', null);\n\n if (hidePreviewAfterSubmit) {\n onShowPreviewChange(false);\n }\n },\n {event: 'keydown'},\n [hidePreviewAfterSubmit, enableSubmitInPreview, showPreview, showPreview],\n );\n\n const settingsProps = {\n mode: editorMode,\n onModeChange,\n onShowPreviewChange,\n onSplitModeChange,\n onToolbarVisibilityChange,\n renderPreviewButton: canRenderPreview,\n showPreview,\n splitMode: editor.splitMode,\n splitModeEnabled: editor.splitModeEnabled,\n stickyToolbar,\n toolbarVisibility: editor.toolbarVisible && !showPreview,\n };\n\n return (\n <div\n className={b('editor-wrapper')}\n ref={ref}\n data-qa={qa}\n data-mode={editor.currentMode}\n >\n {showPreview ? (\n <>\n <div className={b('preview-wrapper')}>\n {editor.renderPreview?.({\n getValue: editor.getValue,\n mode: 'preview',\n md: editor.mdOptions,\n directiveSyntax: editor.directiveSyntax,\n })}\n </div>\n <Settings {...settingsProps} settingsVisible={settingsVisible} />\n </>\n ) : (\n <>\n {editorMode === 'wysiwyg' && (\n <WysiwygEditorView\n editor={editor}\n autofocus={autofocus}\n settingsVisible={settingsVisible}\n toolbarConfig={wysiwygToolbarConfig}\n toolbarVisible={editor.toolbarVisible}\n hiddenActionsConfig={wysiwygHiddenActionsConfig}\n className={b('editor', {mode: editorMode})}\n toolbarClassName={b('toolbar')}\n stickyToolbar={stickyToolbar}\n >\n <Settings\n {...settingsProps}\n settingsVisible={settingsVisible && editor.toolbarVisible}\n />\n </WysiwygEditorView>\n )}\n {editorMode === 'markup' && (\n <MarkupEditorView\n editor={editor}\n autofocus={autofocus}\n settingsVisible={settingsVisible}\n toolbarConfig={markupToolbarConfig}\n toolbarVisible={editor.toolbarVisible}\n splitMode={editor.splitMode}\n splitModeEnabled={editor.splitModeEnabled}\n hiddenActionsConfig={markupHiddenActionsConfig}\n className={b('editor', {mode: editorMode})}\n toolbarClassName={b('toolbar')}\n stickyToolbar={stickyToolbar}\n >\n <Settings\n {...settingsProps}\n settingsVisible={settingsVisible && editor.toolbarVisible}\n />\n </MarkupEditorView>\n )}\n <Settings\n {...settingsProps}\n settingsVisible={!editor.toolbarVisible && settingsVisible}\n renderPreviewButton={!editor.toolbarVisible && editorMode === 'markup'}\n />\n </>\n )}\n </div>\n );\n },\n);\n\nEditorWrapper.displayName = 'EditorWrapper';\n\ntype ToolbarConfigs = {\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n markupToolbarConfig?: MToolbarData;\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n wysiwygToolbarConfig?: WToolbarData;\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n markupHiddenActionsConfig?: MToolbarItemData[];\n /**\n * @deprecated use `toolbarsPreset` instead\n */\n wysiwygHiddenActionsConfig?: WToolbarItemData[];\n};\n\ntype ViewProps = {\n editor?: Editor;\n autofocus?: boolean;\n /** @default true */\n settingsVisible?: boolean;\n toolbarsPreset?: ToolbarsPreset;\n stickyToolbar: boolean;\n enableSubmitInPreview?: boolean;\n hidePreviewAfterSubmit?: boolean;\n};\n\nexport type MarkdownEditorViewProps = ClassNameProps & ToolbarConfigs & ViewProps & QAProps & {};\n\nexport const MarkdownEditorView = forwardRef<HTMLDivElement, MarkdownEditorViewProps>(\n (props, ref) => {\n const divRef = useEnsuredForwardedRef(ref as React.MutableRefObject<HTMLDivElement>);\n const editorWrapperRef = useRef(null);\n const [showPreview, , unsetShowPreview, toggleShowPreview] = useBooleanState(false);\n\n const [isMounted, setIsMounted] = useState(false);\n useEffect(() => {\n setIsMounted(true);\n }, []);\n\n const context = useMarkdownEditorContext();\n const editor = (props.editor ?? context) as EditorInt;\n if (!editor)\n throw new Error(\n '[MarkdownEditorView]: an instance of the editor must be passed through the props or context',\n );\n\n const {\n autofocus,\n className,\n enableSubmitInPreview = true,\n hidePreviewAfterSubmit = false,\n markupHiddenActionsConfig,\n markupToolbarConfig,\n qa,\n settingsVisible = true,\n stickyToolbar,\n toolbarsPreset,\n wysiwygHiddenActionsConfig,\n wysiwygToolbarConfig,\n } = props;\n\n const rerender = useUpdate();\n useLayoutEffect(() => {\n editor.on('rerender', rerender);\n return () => {\n editor.off('rerender', rerender);\n };\n }, [editor, rerender]);\n\n const editorMode = editor.currentMode;\n const markupSplitMode =\n editor.splitModeEnabled && editor.splitMode && editorMode === 'markup';\n\n const splitModeViewWrapperRef = useRef(null);\n\n const toaster = useToaster();\n\n useEffect(() => {\n if (showPreview) {\n divRef.current.focus();\n }\n }, [divRef, showPreview]);\n\n return (\n <ErrorBoundary\n onError={(e) => {\n globalLogger.error(e);\n editor.logger.error(e);\n }}\n fallbackRender={({error, resetErrorBoundary}) => {\n toaster.add({\n theme: 'danger',\n name: 'g-md-editor-error',\n title: i18n('error-title'),\n content: error.message,\n });\n setTimeout(() => {\n resetErrorBoundary();\n editor.changeEditorMode({\n mode: 'markup',\n reason: 'error-boundary',\n emit: false,\n });\n });\n return null;\n }}\n >\n <div\n ref={divRef}\n data-qa={qa}\n className={b(\n {\n settings: settingsVisible,\n split: markupSplitMode && editor.splitMode,\n },\n [className],\n )}\n role=\"button\"\n tabIndex={0}\n >\n <EditorWrapper\n autofocus={autofocus}\n editor={editor}\n editorMode={editorMode}\n enableSubmitInPreview={enableSubmitInPreview}\n hidePreviewAfterSubmit={hidePreviewAfterSubmit}\n isFocused={isWrapperFocused(divRef)}\n markupHiddenActionsConfig={markupHiddenActionsConfig}\n markupToolbarConfig={markupToolbarConfig}\n qa=\"g-md-editor-mode\"\n ref={editorWrapperRef}\n settingsVisible={settingsVisible}\n showPreview={showPreview}\n stickyToolbar={stickyToolbar}\n toggleShowPreview={toggleShowPreview}\n toolbarsPreset={toolbarsPreset}\n unsetShowPreview={unsetShowPreview}\n wysiwygHiddenActionsConfig={wysiwygHiddenActionsConfig}\n wysiwygToolbarConfig={wysiwygToolbarConfig}\n />\n\n {markupSplitMode && (\n <>\n {editor.splitMode === 'horizontal' ? (\n <HorizontalDrag\n editor={editor}\n isMounted={isMounted}\n leftElRef={editorWrapperRef}\n rightElRef={splitModeViewWrapperRef}\n wrapperRef={divRef}\n />\n ) : (\n <div className={b('resizer')} />\n )}\n <SplitModeView editor={editor} ref={splitModeViewWrapperRef} />\n </>\n )}\n </div>\n </ErrorBoundary>\n );\n },\n);\nMarkdownEditorView.displayName = 'MarkdownEditorView';\n\ninterface MarkupSearchAnchorProps extends Pick<EditorSettingsProps, 'mode'> {}\n\nconst MarkupSearchAnchor: React.FC<MarkupSearchAnchorProps> = ({mode}) => (\n <>{mode === 'markup' && <div className=\"g-md-search-anchor\"></div>}</>\n);\n\nfunction Settings(props: EditorSettingsProps & {stickyToolbar: boolean}) {\n const wrapperRef = useRef<HTMLDivElement>(null);\n const isSticky = useSticky(wrapperRef) && props.toolbarVisibility && props.stickyToolbar;\n\n return (\n <>\n {(props.renderPreviewButton || props.settingsVisible) && (\n <div className={b('settings-wrapper')}>\n <div\n ref={wrapperRef}\n className={stickyCn.settings({\n withToolbar: props.toolbarVisibility,\n stickyActive: isSticky,\n })}\n >\n <EditorSettings {...props} />\n <MarkupSearchAnchor {...props} />\n </div>\n </div>\n )}\n </>\n );\n}\n\nfunction isPreviewKeyDown(e: KeyboardEvent) {\n const modKey = isMac() ? e.metaKey : e.ctrlKey;\n return modKey && e.shiftKey && e.code === 'KeyP';\n}\n\nfunction isWrapperFocused(divRef: React.RefObject<HTMLDivElement>) {\n return document.activeElement === divRef.current;\n}\n\nfunction isSubmitKeyDown(e: KeyboardEvent) {\n const modKey = isMac() ? e.metaKey : e.ctrlKey;\n return modKey && e.code === 'Enter';\n}\n"]}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MarkupEditorComponent = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const MarkupEditorComponent = function MarkupEditorComponent({ editor, autofocus, className, children }) {
|
|
6
|
+
const MarkupEditorComponent = function MarkupEditorComponent({ editor, autofocus, className, children, qa }) {
|
|
7
7
|
const ref = (0, react_1.useRef)(null);
|
|
8
8
|
// insert editor to dom
|
|
9
9
|
(0, react_1.useLayoutEffect)(() => {
|
|
@@ -24,7 +24,7 @@ const MarkupEditorComponent = function MarkupEditorComponent({ editor, autofocus
|
|
|
24
24
|
}, [editor.markupEditor]);
|
|
25
25
|
return (
|
|
26
26
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
27
|
-
(0, jsx_runtime_1.jsx)("div", { ref: ref, className: className, onClick: (event) => {
|
|
27
|
+
(0, jsx_runtime_1.jsx)("div", { "data-qa": qa, ref: ref, className: className, onClick: (event) => {
|
|
28
28
|
const target = event.target;
|
|
29
29
|
if (target instanceof Element && target.classList.contains('cm-editor')) {
|
|
30
30
|
editor.markupEditor.focus();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkupEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorComponent.tsx"],"names":[],"mappings":";;;;AAAA,iCAAyD;
|
|
1
|
+
{"version":3,"file":"MarkupEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorComponent.tsx"],"names":[],"mappings":";;;;AAAA,iCAAyD;AAalD,MAAM,qBAAqB,GAC9B,SAAS,qBAAqB,CAAC,EAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE,EAAC;IACvE,MAAM,GAAG,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAEzC,uBAAuB;IACvB,IAAA,uBAAe,EAAC,GAAG,EAAE;QACjB,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,GAAG,CAAC;QAC3C,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YACd,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,GAAG,EAAE;YACR,OAAO,CAAC,MAAM,EAAE,CAAC;QACrB,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAE1B,wCAAwC;IACxC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,MAAM,CAAC,YAAY,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC;QACxC,IAAI,SAAS,EAAE,CAAC;YACZ,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAChC,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAE1B,OAAO;IACH,0GAA0G;IAC1G,2CACa,EAAE,EACX,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACf,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YAE5B,IAAI,MAAM,YAAY,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACtE,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAChC,CAAC;QACL,CAAC,YAEA,QAAQ,GACP,CACT,CAAC;AACN,CAAC,CAAC;AAxCO,QAAA,qBAAqB,yBAwC5B","sourcesContent":["import {useEffect, useLayoutEffect, useRef} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport type {EditorInt} from './Editor';\n\nexport type MarkupEditorComponentProps = QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n className?: string;\n children?: React.ReactNode;\n};\n\nexport const MarkupEditorComponent: React.FC<MarkupEditorComponentProps> =\n function MarkupEditorComponent({editor, autofocus, className, children, qa}) {\n const ref = useRef<HTMLDivElement>(null);\n\n // insert editor to dom\n useLayoutEffect(() => {\n const domElem = editor.markupEditor.cm.dom;\n if (ref.current) {\n ref.current.appendChild(domElem);\n }\n return () => {\n domElem.remove();\n };\n }, [editor.markupEditor]);\n\n // update editor after connecting to dom\n useEffect(() => {\n editor.markupEditor.cm.requestMeasure();\n if (autofocus) {\n editor.markupEditor.focus();\n }\n }, [editor.markupEditor]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions\n <div\n data-qa={qa}\n ref={ref}\n className={className}\n onClick={(event) => {\n const target = event.target;\n\n if (target instanceof Element && target.classList.contains('cm-editor')) {\n editor.markupEditor.focus();\n }\n }}\n >\n {children}\n </div>\n );\n };\n"]}
|
|
@@ -29,7 +29,7 @@ exports.MarkupEditorView = (0, react_1.memo)((props) => {
|
|
|
29
29
|
return ((0, jsx_runtime_1.jsxs)("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? ((0, jsx_runtime_1.jsx)(context_1.MarkupToolbarContextProvider, { value: {
|
|
30
30
|
uploadHandler: editor.fileUploadHandler,
|
|
31
31
|
needToSetDimensionsForUploadedImages: editor.needToSetDimensionsForUploadedImages,
|
|
32
|
-
}, children: (0, jsx_runtime_1.jsx)(ToolbarView_1.ToolbarView, { editor: editor, editorMode: "markup", toolbarEditor: editor, hiddenActionsConfig: hiddenActionsConfig, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children }) })) : null, (0, jsx_runtime_1.jsx)(MarkupEditorComponent_1.MarkupEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor', { 'toolbar-visible': toolbarVisible }), children: (0, jsx_runtime_1.jsx)(extensions_1.ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
32
|
+
}, children: (0, jsx_runtime_1.jsx)(ToolbarView_1.ToolbarView, { qa: "g-md-toolbar", editor: editor, editorMode: "markup", toolbarEditor: editor, hiddenActionsConfig: hiddenActionsConfig, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children }) })) : null, (0, jsx_runtime_1.jsx)(MarkupEditorComponent_1.MarkupEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor', { 'toolbar-visible': toolbarVisible }), children: (0, jsx_runtime_1.jsx)(extensions_1.ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
33
33
|
});
|
|
34
34
|
exports.MarkupEditorView.displayName = 'MarkdownMarkupEditorView';
|
|
35
35
|
//# sourceMappingURL=MarkupEditorView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkupEditorView.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorView.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2B;AAI3B,+CAAqD;AACrD,uDAAqD;AACrD,yCAAuC;AACvC,mDAAmD;AAGnD,sEAA8D;AAC9D,kDAA0C;AAC1C,yDAAsE;AAItE,kCAAiC;AAEjC,MAAM,CAAC,GAAG,IAAA,cAAE,EAAC,eAAe,CAAC,CAAC;AAiBjB,QAAA,gBAAgB,GAAG,IAAA,YAAI,EAAwB,CAAC,KAAK,EAAE,EAAE;IAClE,MAAM,EACF,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,EAAE,EACF,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,aAAa,GAAG,IAAI,GACvB,GAAG,KAAK,CAAC;IACV,IAAA,qBAAa,EAAC,CAAC,IAAI,EAAE,EAAE;QACnB,qBAAY,CAAC,OAAO,CAAC;YACjB,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAClB,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,EAAE,CAAC,SAAS,CAAC,CAAC,aAAW,EAAE,aACjE,cAAc,CAAC,CAAC,CAAC,CACd,uBAAC,sCAA4B,IACzB,KAAK,EAAE;oBACH,aAAa,EAAE,MAAM,CAAC,iBAAiB;oBACvC,oCAAoC,EAChC,MAAM,CAAC,oCAAoC;iBAClD,YAED,uBAAC,yBAAW,IACR,MAAM,EAAE,MAAM,EACd,UAAU,EAAC,QAAQ,EACnB,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAClC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAE1C,QAAQ,GACC,GACa,CAClC,CAAC,CAAC,CAAC,IAAI,EACR,uBAAC,6CAAqB,IAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC,iBAAiB,EAAE,cAAc,EAAC,CAAC,YAE3D,uBAAC,mCAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACrC,IACtB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,wBAAgB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {MarkupEditorComponent} from './MarkupEditorComponent';\nimport {ToolbarView} from './ToolbarView';\nimport {MarkupToolbarContextProvider} from './toolbar/markup/context';\nimport type {MToolbarData, MToolbarItemData} from './toolbar/types';\nimport type {MarkdownEditorSplitMode} from './types';\n\nimport './MarkupEditorView.scss';\n\nconst b = cn('markup-editor');\n\nexport type MarkupEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n toolbarConfig: MToolbarData;\n settingsVisible?: boolean;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled: boolean;\n hiddenActionsConfig?: MToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const MarkupEditorView = memo<MarkupEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n });\n\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <MarkupToolbarContextProvider\n value={{\n uploadHandler: editor.fileUploadHandler,\n needToSetDimensionsForUploadedImages:\n editor.needToSetDimensionsForUploadedImages,\n }}\n >\n <ToolbarView\n editor={editor}\n editorMode=\"markup\"\n toolbarEditor={editor}\n hiddenActionsConfig={hiddenActionsConfig}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n </MarkupToolbarContextProvider>\n ) : null}\n <MarkupEditorComponent\n autofocus={autofocus}\n editor={editor}\n className={b('editor', {'toolbar-visible': toolbarVisible})}\n >\n <ReactRendererComponent storage={editor.renderStorage} />\n </MarkupEditorComponent>\n </div>\n );\n});\nMarkupEditorView.displayName = 'MarkdownMarkupEditorView';\n"]}
|
|
1
|
+
{"version":3,"file":"MarkupEditorView.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorView.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2B;AAI3B,+CAAqD;AACrD,uDAAqD;AACrD,yCAAuC;AACvC,mDAAmD;AAGnD,sEAA8D;AAC9D,kDAA0C;AAC1C,yDAAsE;AAItE,kCAAiC;AAEjC,MAAM,CAAC,GAAG,IAAA,cAAE,EAAC,eAAe,CAAC,CAAC;AAiBjB,QAAA,gBAAgB,GAAG,IAAA,YAAI,EAAwB,CAAC,KAAK,EAAE,EAAE;IAClE,MAAM,EACF,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,EAAE,EACF,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,aAAa,GAAG,IAAI,GACvB,GAAG,KAAK,CAAC;IACV,IAAA,qBAAa,EAAC,CAAC,IAAI,EAAE,EAAE;QACnB,qBAAY,CAAC,OAAO,CAAC;YACjB,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAClB,SAAS,EAAE,eAAe;YAC1B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,EAAE,CAAC,SAAS,CAAC,CAAC,aAAW,EAAE,aACjE,cAAc,CAAC,CAAC,CAAC,CACd,uBAAC,sCAA4B,IACzB,KAAK,EAAE;oBACH,aAAa,EAAE,MAAM,CAAC,iBAAiB;oBACvC,oCAAoC,EAChC,MAAM,CAAC,oCAAoC;iBAClD,YAED,uBAAC,yBAAW,IACR,EAAE,EAAC,cAAc,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAC,QAAQ,EACnB,aAAa,EAAE,MAAM,EACrB,mBAAmB,EAAE,mBAAmB,EACxC,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAClC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAE1C,QAAQ,GACC,GACa,CAClC,CAAC,CAAC,CAAC,IAAI,EACR,uBAAC,6CAAqB,IAClB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAC,iBAAiB,EAAE,cAAc,EAAC,CAAC,YAE3D,uBAAC,mCAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACrC,IACtB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,wBAAgB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {MarkupEditorComponent} from './MarkupEditorComponent';\nimport {ToolbarView} from './ToolbarView';\nimport {MarkupToolbarContextProvider} from './toolbar/markup/context';\nimport type {MToolbarData, MToolbarItemData} from './toolbar/types';\nimport type {MarkdownEditorSplitMode} from './types';\n\nimport './MarkupEditorView.scss';\n\nconst b = cn('markup-editor');\n\nexport type MarkupEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n toolbarConfig: MToolbarData;\n settingsVisible?: boolean;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled: boolean;\n hiddenActionsConfig?: MToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const MarkupEditorView = memo<MarkupEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'markup-editor',\n event: 'render',\n duration: time,\n });\n });\n\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <MarkupToolbarContextProvider\n value={{\n uploadHandler: editor.fileUploadHandler,\n needToSetDimensionsForUploadedImages:\n editor.needToSetDimensionsForUploadedImages,\n }}\n >\n <ToolbarView\n qa=\"g-md-toolbar\"\n editor={editor}\n editorMode=\"markup\"\n toolbarEditor={editor}\n hiddenActionsConfig={hiddenActionsConfig}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n </MarkupToolbarContextProvider>\n ) : null}\n <MarkupEditorComponent\n autofocus={autofocus}\n editor={editor}\n className={b('editor', {'toolbar-visible': toolbarVisible})}\n >\n <ReactRendererComponent storage={editor.renderStorage} />\n </MarkupEditorComponent>\n </div>\n );\n});\nMarkupEditorView.displayName = 'MarkdownMarkupEditorView';\n"]}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { QAProps } from '@gravity-ui/uikit';
|
|
1
2
|
import type { ClassNameProps } from "../classname.js";
|
|
2
3
|
import { type ToolbarData, type ToolbarItemData } from "../toolbar/index.js";
|
|
3
4
|
import type { EditorInt } from "./Editor.js";
|
|
4
5
|
import type { MarkdownEditorMode } from "./types.js";
|
|
5
|
-
export type ToolbarViewProps<T> = ClassNameProps & {
|
|
6
|
+
export type ToolbarViewProps<T> = ClassNameProps & QAProps & {
|
|
6
7
|
editor: EditorInt;
|
|
7
8
|
editorMode: MarkdownEditorMode;
|
|
8
9
|
toolbarEditor: T;
|
|
@@ -13,4 +14,4 @@ export type ToolbarViewProps<T> = ClassNameProps & {
|
|
|
13
14
|
children?: React.ReactNode;
|
|
14
15
|
stickyToolbar: boolean;
|
|
15
16
|
};
|
|
16
|
-
export declare function ToolbarView<T>({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, }: ToolbarViewProps<T>): JSX.Element;
|
|
17
|
+
export declare function ToolbarView<T>({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, qa, }: ToolbarViewProps<T>): JSX.Element;
|
|
@@ -8,7 +8,7 @@ const menubar_1 = require("../i18n/menubar/index.js");
|
|
|
8
8
|
const useSticky_1 = require("../react-utils/useSticky.js");
|
|
9
9
|
const toolbar_1 = require("../toolbar/index.js");
|
|
10
10
|
const sticky_1 = require("./sticky/index.js");
|
|
11
|
-
function ToolbarView({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, }) {
|
|
11
|
+
function ToolbarView({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarConfig, hiddenActionsConfig, settingsVisible, className, children, stickyToolbar, qa, }) {
|
|
12
12
|
const rerender = (0, react_use_1.useUpdate)();
|
|
13
13
|
(0, react_1.useLayoutEffect)(() => {
|
|
14
14
|
editor.on('rerender-toolbar', rerender);
|
|
@@ -18,7 +18,7 @@ function ToolbarView({ editor, editorMode, toolbarEditor, toolbarFocus, toolbarC
|
|
|
18
18
|
}, [editor, rerender]);
|
|
19
19
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
20
20
|
const isStickyActive = (0, useSticky_1.useSticky)(wrapperRef) && stickyToolbar;
|
|
21
|
-
return ((0, jsx_runtime_1.jsxs)("div", { ref: wrapperRef, className: sticky_1.stickyCn.toolbar({
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)("div", { "data-qa": qa, ref: wrapperRef, className: sticky_1.stickyCn.toolbar({
|
|
22
22
|
withSettings: settingsVisible,
|
|
23
23
|
stickyActive: isStickyActive,
|
|
24
24
|
isSticky: stickyToolbar,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToolbarView.js","sourceRoot":"../../../src","sources":["bundle/ToolbarView.tsx"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"ToolbarView.js","sourceRoot":"../../../src","sources":["bundle/ToolbarView.tsx"],"names":[],"mappings":";;AA2BA,kCAgDC;;AA3ED,iCAA8C;AAG9C,yCAAoC;AAGpC,sDAAqC;AACrC,2DAAmD;AACnD,iDAA+E;AAG/E,8CAAkC;AAgBlC,SAAgB,WAAW,CAAI,EAC3B,MAAM,EACN,UAAU,EACV,aAAa,EACb,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,eAAe,EACf,SAAS,EACT,QAAQ,EACR,aAAa,EACb,EAAE,GACgB;IAClB,MAAM,QAAQ,GAAG,IAAA,qBAAS,GAAE,CAAC;IAC7B,IAAA,uBAAe,EAAC,GAAG,EAAE;QACjB,MAAM,CAAC,EAAE,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QACxC,OAAO,GAAG,EAAE;YACR,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;QAC7C,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEvB,MAAM,UAAU,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IAChD,MAAM,cAAc,GAAG,IAAA,qBAAS,EAAC,UAAU,CAAC,IAAI,aAAa,CAAC;IAE9D,OAAO,CACH,4CACa,EAAE,EACX,GAAG,EAAE,UAAU,EACf,SAAS,EAAE,iBAAQ,CAAC,OAAO,CACvB;YACI,YAAY,EAAE,eAAe;YAC7B,YAAY,EAAE,cAAc;YAC5B,QAAQ,EAAE,aAAa;SAC1B,EACD,CAAC,SAAS,CAAC,CACd,aAED,uBAAC,qBAAW,IACR,IAAI,EAAE,aAAa,EACnB,aAAa,EAAE,mBAAmB,EAClC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,IAAA,cAAI,EAAC,aAAa,CAAC,EAC9B,OAAO,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAC,EAAE,EAAE,KAAK,EAAE,UAAU,EAAC,CAAC,GAChF,EACD,QAAQ,IACP,CACT,CAAC;AACN,CAAC","sourcesContent":["import {useLayoutEffect, useRef} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\nimport {useUpdate} from 'react-use';\n\nimport type {ClassNameProps} from '../classname';\nimport {i18n} from '../i18n/menubar';\nimport {useSticky} from '../react-utils/useSticky';\nimport {FlexToolbar, type ToolbarData, type ToolbarItemData} from '../toolbar';\n\nimport type {EditorInt} from './Editor';\nimport {stickyCn} from './sticky';\nimport type {MarkdownEditorMode} from './types';\n\nexport type ToolbarViewProps<T> = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n editorMode: MarkdownEditorMode;\n toolbarEditor: T;\n toolbarFocus: () => void;\n toolbarConfig: ToolbarData<T>;\n settingsVisible?: boolean;\n hiddenActionsConfig?: ToolbarItemData<T>[];\n children?: React.ReactNode;\n stickyToolbar: boolean;\n };\n\nexport function ToolbarView<T>({\n editor,\n editorMode,\n toolbarEditor,\n toolbarFocus,\n toolbarConfig,\n hiddenActionsConfig,\n settingsVisible,\n className,\n children,\n stickyToolbar,\n qa,\n}: ToolbarViewProps<T>) {\n const rerender = useUpdate();\n useLayoutEffect(() => {\n editor.on('rerender-toolbar', rerender);\n return () => {\n editor.off('rerender-toolbar', rerender);\n };\n }, [editor, rerender]);\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n const isStickyActive = useSticky(wrapperRef) && stickyToolbar;\n\n return (\n <div\n data-qa={qa}\n ref={wrapperRef}\n className={stickyCn.toolbar(\n {\n withSettings: settingsVisible,\n stickyActive: isStickyActive,\n isSticky: stickyToolbar,\n },\n [className],\n )}\n >\n <FlexToolbar\n data={toolbarConfig}\n hiddenActions={hiddenActionsConfig}\n editor={toolbarEditor}\n focus={toolbarFocus}\n dotsTitle={i18n('more_action')}\n onClick={(id, attrs) => editor.emit('toolbar-action', {id, attrs, editorMode})}\n />\n {children}\n </div>\n );\n}\n"]}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WysiwygEditorComponent = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const WysiwygEditorComponent = function WysiwygEditorComponent({ className, autofocus, editor, children }) {
|
|
6
|
+
const WysiwygEditorComponent = function WysiwygEditorComponent({ className, autofocus, editor, children, qa }) {
|
|
7
7
|
const ref = (0, react_1.useRef)(null);
|
|
8
8
|
(0, react_1.useEffect)(() => {
|
|
9
9
|
const { current } = ref;
|
|
@@ -14,7 +14,7 @@ const WysiwygEditorComponent = function WysiwygEditorComponent({ className, auto
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
}, [editor]);
|
|
17
|
-
return ((0, jsx_runtime_1.jsx)("div", { ref: ref, className: className, children: children }));
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)("div", { "data-qa": qa, ref: ref, className: className, children: children }));
|
|
18
18
|
};
|
|
19
19
|
exports.WysiwygEditorComponent = WysiwygEditorComponent;
|
|
20
20
|
//# sourceMappingURL=WysiwygEditorComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WysiwygEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorComponent.tsx"],"names":[],"mappings":";;;;AAAA,iCAAwC;
|
|
1
|
+
{"version":3,"file":"WysiwygEditorComponent.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorComponent.tsx"],"names":[],"mappings":";;;;AAAA,iCAAwC;AAajC,MAAM,sBAAsB,GAC/B,SAAS,sBAAsB,CAAC,EAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAC;IACxE,MAAM,GAAG,GAAG,IAAA,cAAM,EAAiB,IAAI,CAAC,CAAC;IACzC,IAAA,iBAAS,EAAC,GAAG,EAAE;QACX,MAAM,EAAC,OAAO,EAAC,GAAG,GAAG,CAAC;QACtB,IAAI,OAAO,EAAE,CAAC;YACV,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;YAC9C,IAAI,SAAS,EAAE,CAAC;gBACZ,MAAM,CAAC,KAAK,EAAE,CAAC;YACnB,CAAC;QACL,CAAC;IACL,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,OAAO,CACH,2CAAc,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,YAC3C,QAAQ,GACP,CACT,CAAC;AACN,CAAC,CAAC;AAlBO,QAAA,sBAAsB,0BAkB7B","sourcesContent":["import {useEffect, useRef} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport type {EditorInt} from './Editor';\n\nexport type WysiwygEditorComponentProps = QAProps & {\n className?: string;\n autofocus?: boolean;\n editor: EditorInt;\n children?: React.ReactNode;\n};\n\nexport const WysiwygEditorComponent: React.FC<WysiwygEditorComponentProps> =\n function WysiwygEditorComponent({className, autofocus, editor, children, qa}) {\n const ref = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const {current} = ref;\n if (current) {\n current.appendChild(editor.wysiwygEditor.dom);\n if (autofocus) {\n editor.focus();\n }\n }\n }, [editor]);\n\n return (\n <div data-qa={qa} ref={ref} className={className}>\n {children}\n </div>\n );\n };\n"]}
|
|
@@ -25,7 +25,7 @@ exports.WysiwygEditorView = (0, react_1.memo)((props) => {
|
|
|
25
25
|
duration: time,
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? ((0, jsx_runtime_1.jsx)(ToolbarView_1.ToolbarView, { editor: editor, editorMode: "wysiwyg", toolbarEditor: editor, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), hiddenActionsConfig: hiddenActionsConfig, settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children })) : null, (0, jsx_runtime_1.jsx)(WysiwygEditorComponent_1.WysiwygEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor'), children: (0, jsx_runtime_1.jsx)(extensions_1.ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
28
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-qa": qa, children: [toolbarVisible ? ((0, jsx_runtime_1.jsx)(ToolbarView_1.ToolbarView, { qa: "g-md-toolbar", editor: editor, editorMode: "wysiwyg", toolbarEditor: editor, stickyToolbar: stickyToolbar, toolbarConfig: toolbarConfig, toolbarFocus: () => editor.focus(), hiddenActionsConfig: hiddenActionsConfig, settingsVisible: settingsVisible, className: b('toolbar', [toolbarClassName]), children: children })) : null, (0, jsx_runtime_1.jsx)(WysiwygEditorComponent_1.WysiwygEditorComponent, { autofocus: autofocus, editor: editor, className: b('editor'), children: (0, jsx_runtime_1.jsx)(extensions_1.ReactRendererComponent, { storage: editor.renderStorage }) })] }));
|
|
29
29
|
});
|
|
30
30
|
exports.WysiwygEditorView.displayName = 'MarkdownWysiwgEditorView';
|
|
31
31
|
//# sourceMappingURL=WysiwygEditorView.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WysiwygEditorView.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorView.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2B;AAI3B,+CAAqD;AACrD,uDAAqD;AACrD,yCAAuC;AACvC,mDAAmD;AAGnD,kDAA0C;AAC1C,wEAAgE;AAGhE,mCAAkC;AAElC,MAAM,CAAC,GAAG,IAAA,cAAE,EAAC,gBAAgB,CAAC,CAAC;AAelB,QAAA,iBAAiB,GAAG,IAAA,YAAI,EAAyB,CAAC,KAAK,EAAE,EAAE;IACpE,MAAM,EACF,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,EAAE,EACF,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,aAAa,GAAG,IAAI,GACvB,GAAG,KAAK,CAAC;IACV,IAAA,qBAAa,EAAC,CAAC,IAAI,EAAE,EAAE;QACnB,qBAAY,CAAC,OAAO,CAAC;YACjB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAClB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,EAAE,CAAC,SAAS,CAAC,CAAC,aAAW,EAAE,aACjE,cAAc,CAAC,CAAC,CAAC,CACd,uBAAC,yBAAW,IACR,MAAM,EAAE,MAAM,EACd,UAAU,EAAC,SAAS,EACpB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAE1C,QAAQ,GACC,CACjB,CAAC,CAAC,CAAC,IAAI,EACR,uBAAC,+CAAsB,IAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,YAChF,uBAAC,mCAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACpC,IACvB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,yBAAiB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {ToolbarView} from './ToolbarView';\nimport {WysiwygEditorComponent} from './WysiwygEditorComponent';\nimport type {WToolbarData, WToolbarItemData} from './toolbar/types';\n\nimport './WysiwygEditorView.scss';\n\nconst b = cn('wysiwyg-editor');\n\nexport type WysiwygEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n settingsVisible?: boolean;\n toolbarConfig: WToolbarData;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n hiddenActionsConfig?: WToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const WysiwygEditorView = memo<WysiwygEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n });\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <ToolbarView\n editor={editor}\n editorMode=\"wysiwyg\"\n toolbarEditor={editor}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n hiddenActionsConfig={hiddenActionsConfig}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n ) : null}\n <WysiwygEditorComponent autofocus={autofocus} editor={editor} className={b('editor')}>\n <ReactRendererComponent storage={editor.renderStorage} />\n </WysiwygEditorComponent>\n </div>\n );\n});\nWysiwygEditorView.displayName = 'MarkdownWysiwgEditorView';\n"]}
|
|
1
|
+
{"version":3,"file":"WysiwygEditorView.js","sourceRoot":"../../../src","sources":["bundle/WysiwygEditorView.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2B;AAI3B,+CAAqD;AACrD,uDAAqD;AACrD,yCAAuC;AACvC,mDAAmD;AAGnD,kDAA0C;AAC1C,wEAAgE;AAGhE,mCAAkC;AAElC,MAAM,CAAC,GAAG,IAAA,cAAE,EAAC,gBAAgB,CAAC,CAAC;AAelB,QAAA,iBAAiB,GAAG,IAAA,YAAI,EAAyB,CAAC,KAAK,EAAE,EAAE;IACpE,MAAM,EACF,MAAM,EACN,SAAS,EACT,eAAe,EACf,cAAc,EACd,aAAa,EACb,mBAAmB,EACnB,EAAE,EACF,SAAS,EACT,gBAAgB,EAChB,QAAQ,EACR,aAAa,GAAG,IAAI,GACvB,GAAG,KAAK,CAAC;IACV,IAAA,qBAAa,EAAC,CAAC,IAAI,EAAE,EAAE;QACnB,qBAAY,CAAC,OAAO,CAAC;YACjB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;QACH,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YAClB,SAAS,EAAE,gBAAgB;YAC3B,KAAK,EAAE,QAAQ;YACf,QAAQ,EAAE,IAAI;SACjB,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IACH,OAAO,CACH,iCAAK,SAAS,EAAE,CAAC,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,EAAE,CAAC,SAAS,CAAC,CAAC,aAAW,EAAE,aACjE,cAAc,CAAC,CAAC,CAAC,CACd,uBAAC,yBAAW,IACR,EAAE,EAAC,cAAc,EACjB,MAAM,EAAE,MAAM,EACd,UAAU,EAAC,SAAS,EACpB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,aAAa,EAC5B,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,EAClC,mBAAmB,EAAE,mBAAmB,EACxC,eAAe,EAAE,eAAe,EAChC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,gBAAgB,CAAC,CAAC,YAE1C,QAAQ,GACC,CACjB,CAAC,CAAC,CAAC,IAAI,EACR,uBAAC,+CAAsB,IAAC,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,YAChF,uBAAC,mCAAsB,IAAC,OAAO,EAAE,MAAM,CAAC,aAAa,GAAI,GACpC,IACvB,CACT,CAAC;AACN,CAAC,CAAC,CAAC;AACH,yBAAiB,CAAC,WAAW,GAAG,0BAA0B,CAAC","sourcesContent":["import {memo} from 'react';\n\nimport type {QAProps} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../classname';\nimport {ReactRendererComponent} from '../extensions';\nimport {globalLogger} from '../logger';\nimport {useRenderTime} from '../react-utils/hooks';\n\nimport type {EditorInt} from './Editor';\nimport {ToolbarView} from './ToolbarView';\nimport {WysiwygEditorComponent} from './WysiwygEditorComponent';\nimport type {WToolbarData, WToolbarItemData} from './toolbar/types';\n\nimport './WysiwygEditorView.scss';\n\nconst b = cn('wysiwyg-editor');\n\nexport type WysiwygEditorViewProps = ClassNameProps &\n QAProps & {\n editor: EditorInt;\n autofocus?: boolean;\n settingsVisible?: boolean;\n toolbarConfig: WToolbarData;\n toolbarVisible?: boolean;\n stickyToolbar?: boolean;\n toolbarClassName?: string;\n hiddenActionsConfig?: WToolbarItemData[];\n children?: React.ReactNode;\n };\n\nexport const WysiwygEditorView = memo<WysiwygEditorViewProps>((props) => {\n const {\n editor,\n autofocus,\n settingsVisible,\n toolbarVisible,\n toolbarConfig,\n hiddenActionsConfig,\n qa,\n className,\n toolbarClassName,\n children,\n stickyToolbar = true,\n } = props;\n useRenderTime((time) => {\n globalLogger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n editor.logger.metrics({\n component: 'wysiwyg-editor',\n event: 'render',\n duration: time,\n });\n });\n return (\n <div className={b({toolbar: toolbarVisible}, [className])} data-qa={qa}>\n {toolbarVisible ? (\n <ToolbarView\n qa=\"g-md-toolbar\"\n editor={editor}\n editorMode=\"wysiwyg\"\n toolbarEditor={editor}\n stickyToolbar={stickyToolbar}\n toolbarConfig={toolbarConfig}\n toolbarFocus={() => editor.focus()}\n hiddenActionsConfig={hiddenActionsConfig}\n settingsVisible={settingsVisible}\n className={b('toolbar', [toolbarClassName])}\n >\n {children}\n </ToolbarView>\n ) : null}\n <WysiwygEditorComponent autofocus={autofocus} editor={editor} className={b('editor')}>\n <ReactRendererComponent storage={editor.renderStorage} />\n </WysiwygEditorComponent>\n </div>\n );\n});\nWysiwygEditorView.displayName = 'MarkdownWysiwgEditorView';\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type QAProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { type ClassNameProps } from "../../classname.js";
|
|
2
3
|
import type { MarkdownEditorMode, MarkdownEditorSplitMode } from "../types.js";
|
|
3
4
|
import "./index.css";
|
|
@@ -6,7 +7,7 @@ export type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {
|
|
|
6
7
|
settingsVisible?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const EditorSettings: import("react").NamedExoticComponent<EditorSettingsProps>;
|
|
9
|
-
type SettingsContentProps = ClassNameProps & {
|
|
10
|
+
type SettingsContentProps = ClassNameProps & QAProps & {
|
|
10
11
|
mode: MarkdownEditorMode;
|
|
11
12
|
onClose: () => void;
|
|
12
13
|
onModeChange: (mode: MarkdownEditorMode) => void;
|
|
@@ -24,11 +24,11 @@ exports.EditorSettings = (0, react_1.memo)(function EditorSettings(props) {
|
|
|
24
24
|
const { className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible } = props;
|
|
25
25
|
const [chevronElement, setChevronElement] = (0, react_1.useState)(null);
|
|
26
26
|
const [popupShown, , hidePopup, togglePopup] = (0, hooks_1.useBooleanState)(false);
|
|
27
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: bSettings(null, [className]), children: [renderPreviewButton && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(uikit_1.ActionTooltip, { openDelay: toolbar_1.ToolbarTooltipDelay.Open, closeDelay: toolbar_1.ToolbarTooltipDelay.Close, title: (0, bundle_1.i18n)('preview_hint'), hotkey: "mod+shift+p", children: (0, jsx_runtime_1.jsx)(uikit_1.Button, { qa: "g-md-markup-preview-button", size: "m", view: "flat", pin: "round-round", className: bSettings('preview-button'), onClick: () => onShowPreviewChange?.(!showPreview), selected: showPreview, children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Eye }) }) }), settingsVisible && (0, jsx_runtime_1.jsx)("div", { className: bSettings('separator') })] })), settingsVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(uikit_1.Button, { size: "m", view: "flat", pin: "round-round", onClick: togglePopup, ref: setChevronElement, qa: "g-md-settings-button", className: bSettings('dropdown-button'), children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Gear }) }), (0, jsx_runtime_1.jsx)(uikit_1.Popup, { open: popupShown, anchorElement: chevronElement, placement: placement, onOpenChange: hidePopup, children: (0, jsx_runtime_1.jsx)(SettingsContent, { ...props, onClose: hidePopup, className: bSettings('content') }) })] }))] }));
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: bSettings(null, [className]), children: [renderPreviewButton && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(uikit_1.ActionTooltip, { openDelay: toolbar_1.ToolbarTooltipDelay.Open, closeDelay: toolbar_1.ToolbarTooltipDelay.Close, title: (0, bundle_1.i18n)('preview_hint'), hotkey: "mod+shift+p", children: (0, jsx_runtime_1.jsx)(uikit_1.Button, { qa: "g-md-markup-preview-button", size: "m", view: "flat", pin: "round-round", className: bSettings('preview-button'), onClick: () => onShowPreviewChange?.(!showPreview), selected: showPreview, children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Eye }) }) }), settingsVisible && (0, jsx_runtime_1.jsx)("div", { className: bSettings('separator') })] })), settingsVisible && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(uikit_1.Button, { size: "m", view: "flat", pin: "round-round", onClick: togglePopup, ref: setChevronElement, qa: "g-md-settings-button", className: bSettings('dropdown-button'), children: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.Gear }) }), (0, jsx_runtime_1.jsx)(uikit_1.Popup, { open: popupShown, anchorElement: chevronElement, placement: placement, onOpenChange: hidePopup, children: (0, jsx_runtime_1.jsx)(SettingsContent, { ...props, qa: "g-md-settings-content", onClose: hidePopup, className: bSettings('content') }) })] }))] }));
|
|
28
28
|
});
|
|
29
29
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
30
|
-
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
31
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: bContent(null, [className]), "data-qa":
|
|
30
|
+
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, qa, }) {
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: bContent(null, [className]), "data-qa": qa, children: [(0, jsx_runtime_1.jsxs)(uikit_1.Menu, { size: "l", className: bContent('mode'), children: [(0, jsx_runtime_1.jsx)(uikit_1.Menu.Item, { qa: "g-md-settings-mode-wysiwyg", active: mode === 'wysiwyg', onClick: () => {
|
|
32
32
|
onModeChange('wysiwyg');
|
|
33
33
|
onClose();
|
|
34
34
|
}, iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: WysiwygMode_1.default }), children: (0, bundle_1.i18n)('settings_wysiwyg') }), (0, jsx_runtime_1.jsxs)(uikit_1.Menu.Item, { qa: "g-md-settings-mode-markup", active: mode === 'markup', onClick: () => {
|