@gravity-ui/markdown-editor 15.4.1 → 15.5.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 +3 -2
- package/build/cjs/bundle/MarkdownEditorView.js +3 -3
- package/build/cjs/bundle/MarkdownEditorView.js.map +1 -1
- package/build/cjs/bundle/MarkupEditorView.d.ts +2 -1
- package/build/cjs/bundle/MarkupEditorView.js +2 -2
- package/build/cjs/bundle/MarkupEditorView.js.map +1 -1
- package/build/cjs/bundle/WysiwygEditorView.d.ts +2 -1
- package/build/cjs/bundle/WysiwygEditorView.js +2 -2
- package/build/cjs/bundle/WysiwygEditorView.js.map +1 -1
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/action-names.js +1 -0
- package/build/cjs/bundle/config/action-names.js.map +1 -1
- package/build/cjs/bundle/config/icons.d.ts +1 -1
- package/build/cjs/bundle/config/icons.js +1 -0
- package/build/cjs/bundle/config/icons.js.map +1 -1
- package/build/cjs/bundle/settings/index.js +3 -3
- package/build/cjs/bundle/settings/index.js.map +1 -1
- package/build/cjs/bundle/types.d.ts +6 -0
- package/build/cjs/bundle/types.js.map +1 -1
- package/build/cjs/bundle/useMarkdownEditor.js +1 -0
- package/build/cjs/bundle/useMarkdownEditor.js.map +1 -1
- package/build/cjs/bundle/wysiwyg-preset.d.ts +1 -0
- package/build/cjs/bundle/wysiwyg-preset.js +1 -0
- package/build/cjs/bundle/wysiwyg-preset.js.map +1 -1
- package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/commands.d.ts +3 -0
- package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/commands.js +10 -0
- package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/commands.js.map +1 -0
- package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.d.ts +16 -0
- package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js +72 -0
- package/build/cjs/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js.map +1 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/index.d.ts +10 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js +71 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js.map +1 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.d.ts +2 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js +41 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js.map +1 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.d.ts +6 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js +24 -0
- package/build/cjs/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js.map +1 -0
- package/build/cjs/extensions/additional/QuoteLink/commands.d.ts +4 -0
- package/build/cjs/extensions/additional/QuoteLink/commands.js +45 -0
- package/build/cjs/extensions/additional/QuoteLink/commands.js.map +1 -0
- package/build/cjs/extensions/additional/QuoteLink/index.css +36 -0
- package/build/cjs/extensions/additional/QuoteLink/index.d.ts +16 -0
- package/build/cjs/extensions/additional/QuoteLink/index.js +42 -0
- package/build/cjs/extensions/additional/QuoteLink/index.js.map +1 -0
- package/build/cjs/extensions/additional/YfmHtmlBlock/utils.js +2 -12
- package/build/cjs/extensions/additional/YfmHtmlBlock/utils.js.map +1 -1
- package/build/cjs/extensions/markdown/Html/schema.js +3 -3
- package/build/cjs/extensions/markdown/Html/schema.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/actions.js +2 -2
- package/build/cjs/extensions/markdown/Lists/actions.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/commands.d.ts +2 -1
- package/build/cjs/extensions/markdown/Lists/commands.js +64 -0
- package/build/cjs/extensions/markdown/Lists/commands.js.map +1 -1
- package/build/cjs/extensions/markdown/Lists/index.js +2 -2
- package/build/cjs/extensions/markdown/Lists/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.d.ts +2 -0
- package/build/cjs/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js +5 -2
- package/build/cjs/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.d.ts +1 -1
- package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js +2 -0
- package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js.map +1 -1
- package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.d.ts +9 -0
- package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js +46 -0
- package/build/cjs/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js.map +1 -0
- package/build/cjs/i18n/menubar/en.json +1 -0
- package/build/cjs/i18n/menubar/index.d.ts +2 -1
- package/build/cjs/i18n/menubar/ru.json +1 -0
- package/build/cjs/icons/index.d.ts +1 -1
- package/build/cjs/icons/index.js +2 -1
- package/build/cjs/icons/index.js.map +1 -1
- package/build/cjs/markup/commands/blocks.d.ts +1 -0
- package/build/cjs/markup/commands/blocks.js +8 -1
- package/build/cjs/markup/commands/blocks.js.map +1 -1
- package/build/cjs/modules/toolbars/items.d.ts +3 -0
- package/build/cjs/modules/toolbars/items.js +22 -3
- package/build/cjs/modules/toolbars/items.js.map +1 -1
- package/build/cjs/utils/getSanitize.d.ts +4 -0
- package/build/cjs/utils/getSanitize.js +16 -0
- package/build/cjs/utils/getSanitize.js.map +1 -0
- package/build/cjs/version.js +1 -1
- package/build/cjs/version.js.map +1 -1
- package/build/cjs/view/hocs/withYfmHtml/index.d.ts +1 -0
- package/build/cjs/view/hocs/withYfmHtml/index.js.map +1 -1
- package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +2 -1
- package/build/cjs/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js.map +1 -1
- package/build/esm/bundle/MarkdownEditorView.d.ts +3 -2
- package/build/esm/bundle/MarkdownEditorView.js +3 -3
- package/build/esm/bundle/MarkdownEditorView.js.map +1 -1
- package/build/esm/bundle/MarkupEditorView.d.ts +2 -1
- package/build/esm/bundle/MarkupEditorView.js +2 -2
- package/build/esm/bundle/MarkupEditorView.js.map +1 -1
- package/build/esm/bundle/WysiwygEditorView.d.ts +2 -1
- package/build/esm/bundle/WysiwygEditorView.js +2 -2
- package/build/esm/bundle/WysiwygEditorView.js.map +1 -1
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/action-names.js +1 -0
- package/build/esm/bundle/config/action-names.js.map +1 -1
- package/build/esm/bundle/config/icons.d.ts +1 -1
- package/build/esm/bundle/config/icons.js +2 -1
- package/build/esm/bundle/config/icons.js.map +1 -1
- package/build/esm/bundle/settings/index.js +3 -3
- package/build/esm/bundle/settings/index.js.map +1 -1
- package/build/esm/bundle/types.d.ts +6 -0
- package/build/esm/bundle/types.js.map +1 -1
- package/build/esm/bundle/useMarkdownEditor.js +1 -0
- package/build/esm/bundle/useMarkdownEditor.js.map +1 -1
- package/build/esm/bundle/wysiwyg-preset.d.ts +1 -0
- package/build/esm/bundle/wysiwyg-preset.js +1 -0
- package/build/esm/bundle/wysiwyg-preset.js.map +1 -1
- package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/commands.d.ts +3 -0
- package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/commands.js +6 -0
- package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/commands.js.map +1 -0
- package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.d.ts +16 -0
- package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js +67 -0
- package/build/esm/extensions/additional/QuoteLink/PlaceholderWidget/descriptor.js.map +1 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/index.d.ts +10 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js +66 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/index.js.map +1 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.d.ts +2 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js +37 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/moveLinkToQuoteAttributes.js.map +1 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.d.ts +6 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js +21 -0
- package/build/esm/extensions/additional/QuoteLink/QuoteLinkSpecs/md/utils.js.map +1 -0
- package/build/esm/extensions/additional/QuoteLink/commands.d.ts +4 -0
- package/build/esm/extensions/additional/QuoteLink/commands.js +41 -0
- package/build/esm/extensions/additional/QuoteLink/commands.js.map +1 -0
- package/build/esm/extensions/additional/QuoteLink/index.css +36 -0
- package/build/esm/extensions/additional/QuoteLink/index.d.ts +16 -0
- package/build/esm/extensions/additional/QuoteLink/index.js +38 -0
- package/build/esm/extensions/additional/QuoteLink/index.js.map +1 -0
- package/build/esm/extensions/additional/YfmHtmlBlock/utils.js +2 -11
- package/build/esm/extensions/additional/YfmHtmlBlock/utils.js.map +1 -1
- package/build/esm/extensions/markdown/Html/schema.js +2 -1
- package/build/esm/extensions/markdown/Html/schema.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/actions.js +4 -4
- package/build/esm/extensions/markdown/Lists/actions.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/commands.d.ts +2 -1
- package/build/esm/extensions/markdown/Lists/commands.js +63 -0
- package/build/esm/extensions/markdown/Lists/commands.js.map +1 -1
- package/build/esm/extensions/markdown/Lists/index.js +4 -4
- package/build/esm/extensions/markdown/Lists/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.d.ts +2 -0
- package/build/esm/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js +5 -2
- package/build/esm/extensions/yfm/YfmConfigs/YfmConfigsSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.d.ts +1 -1
- package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js +2 -0
- package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/index.js.map +1 -1
- package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.d.ts +9 -0
- package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js +42 -0
- package/build/esm/extensions/yfm/YfmHeading/YfmHeadingSpecs/markdown/heading-attrs.js.map +1 -0
- package/build/esm/i18n/menubar/en.json +1 -0
- package/build/esm/i18n/menubar/index.d.ts +2 -1
- package/build/esm/i18n/menubar/ru.json +1 -0
- package/build/esm/icons/index.d.ts +1 -1
- package/build/esm/icons/index.js +1 -1
- package/build/esm/icons/index.js.map +1 -1
- package/build/esm/markup/commands/blocks.d.ts +1 -0
- package/build/esm/markup/commands/blocks.js +6 -0
- package/build/esm/markup/commands/blocks.js.map +1 -1
- package/build/esm/modules/toolbars/items.d.ts +3 -0
- package/build/esm/modules/toolbars/items.js +20 -1
- package/build/esm/modules/toolbars/items.js.map +1 -1
- package/build/esm/utils/getSanitize.d.ts +4 -0
- package/build/esm/utils/getSanitize.js +11 -0
- package/build/esm/utils/getSanitize.js.map +1 -0
- package/build/esm/version.js +1 -1
- package/build/esm/version.js.map +1 -1
- package/build/esm/view/hocs/withYfmHtml/index.d.ts +1 -0
- package/build/esm/view/hocs/withYfmHtml/index.js.map +1 -1
- package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js +2 -1
- package/build/esm/view/hocs/withYfmHtml/useYfmHtmlBlockRuntime.js.map +1 -1
- package/build/styles.css +36 -0
- package/package.json +9 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type QAProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { type ClassNameProps } from "../classname.js";
|
|
2
3
|
import type { ToolbarsPreset } from "../modules/toolbars/types.js";
|
|
3
4
|
import type { Editor } from "./Editor.js";
|
|
@@ -5,7 +6,7 @@ import type { MToolbarData, MToolbarItemData, WToolbarData, WToolbarItemData } f
|
|
|
5
6
|
import "../styles/styles.css";
|
|
6
7
|
import "./MarkdownEditorView.css";
|
|
7
8
|
export declare const cnEditorComponent: import("@bem-react/classname").ClassNameFormatter;
|
|
8
|
-
export type MarkdownEditorViewProps = ClassNameProps & {
|
|
9
|
+
export type MarkdownEditorViewProps = ClassNameProps & QAProps & {
|
|
9
10
|
editor?: Editor;
|
|
10
11
|
autofocus?: boolean;
|
|
11
12
|
toolbarsPreset?: ToolbarsPreset;
|
|
@@ -31,7 +32,7 @@ export type MarkdownEditorViewProps = ClassNameProps & {
|
|
|
31
32
|
enableSubmitInPreview?: boolean;
|
|
32
33
|
hidePreviewAfterSubmit?: boolean;
|
|
33
34
|
};
|
|
34
|
-
export declare const MarkdownEditorView: import("react").ForwardRefExoticComponent<ClassNameProps & {
|
|
35
|
+
export declare const MarkdownEditorView: import("react").ForwardRefExoticComponent<ClassNameProps & QAProps & {
|
|
35
36
|
editor?: Editor;
|
|
36
37
|
autofocus?: boolean;
|
|
37
38
|
toolbarsPreset?: ToolbarsPreset;
|
|
@@ -34,7 +34,7 @@ exports.MarkdownEditorView = (0, react_1.forwardRef)((props, ref) => {
|
|
|
34
34
|
const editor = (props.editor ?? context);
|
|
35
35
|
if (!editor)
|
|
36
36
|
throw new Error('[MarkdownEditorView]: an instance of the editor must be passed through the props or context');
|
|
37
|
-
const { autofocus, className, settingsVisible = true, toolbarsPreset, stickyToolbar, wysiwygToolbarConfig: initialWysiwygToolbarConfig, markupToolbarConfig: initialMarkupToolbarConfig, wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig, markupHiddenActionsConfig: initialMarkupHiddenActionsConfig, enableSubmitInPreview = true, hidePreviewAfterSubmit = false, } = props;
|
|
37
|
+
const { qa, autofocus, className, settingsVisible = true, toolbarsPreset, stickyToolbar, wysiwygToolbarConfig: initialWysiwygToolbarConfig, markupToolbarConfig: initialMarkupToolbarConfig, wysiwygHiddenActionsConfig: initialWysiwygHiddenActionsConfig, markupHiddenActionsConfig: initialMarkupHiddenActionsConfig, enableSubmitInPreview = true, hidePreviewAfterSubmit = false, } = props;
|
|
38
38
|
const { wysiwygToolbarConfig, markupToolbarConfig, wysiwygHiddenActionsConfig, markupHiddenActionsConfig, } = (0, react_1.useMemo)(() => (0, toolbarsConfigs_1.getToolbarsConfigs)({
|
|
39
39
|
toolbarsPreset,
|
|
40
40
|
props: {
|
|
@@ -132,7 +132,7 @@ exports.MarkdownEditorView = (0, react_1.forwardRef)((props, ref) => {
|
|
|
132
132
|
});
|
|
133
133
|
});
|
|
134
134
|
return null;
|
|
135
|
-
}, children: (0, jsx_runtime_1.jsxs)("div", { ref: divRef, className: b({
|
|
135
|
+
}, children: (0, jsx_runtime_1.jsxs)("div", { ref: divRef, "data-qa": qa, className: b({
|
|
136
136
|
settings: settingsVisible,
|
|
137
137
|
split: markupSplitMode && editor.splitMode,
|
|
138
138
|
}, [className]), role: "button", tabIndex: 0, children: [(0, jsx_runtime_1.jsx)("div", { className: b('editor-wrapper'), ref: editorWrapperRef, 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?.({
|
|
@@ -140,7 +140,7 @@ exports.MarkdownEditorView = (0, react_1.forwardRef)((props, ref) => {
|
|
|
140
140
|
mode: 'preview',
|
|
141
141
|
md: editor.mdOptions,
|
|
142
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
|
+
}) }), 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, qa: "g-md-editor-mode", 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, qa: "g-md-editor-mode", 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 })] }))] }) }));
|
|
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,6CAA6C;AAC7C,+DAAmD;AACnD,yCAAoE;AAEpE,+CAAqD;AACrD,oDAAoC;AACpC,yCAAuC;AAEvC,yDAA0D;AAC1D,6CAA+B;AAG/B,wDAAgD;AAChD,4DA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O,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 {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 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 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 className={b(\n {\n settings: settingsVisible,\n split: markupSplitMode && editor.splitMode,\n },\n [className],\n )}\n role=\"button\"\n tabIndex={0}\n >\n <div className={b('editor-wrapper')} ref={editorWrapperRef}>\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;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,EA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I,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 className={b('editor-wrapper')} ref={editorWrapperRef}>\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 qa=\"g-md-editor-mode\"\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 qa=\"g-md-editor-mode\"\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,9 +1,10 @@
|
|
|
1
|
+
import type { QAProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { type ClassNameProps } from "../classname.js";
|
|
2
3
|
import type { EditorInt } from "./Editor.js";
|
|
3
4
|
import type { MToolbarData, MToolbarItemData } from "./toolbar/types.js";
|
|
4
5
|
import type { MarkdownEditorSplitMode } from "./types.js";
|
|
5
6
|
import "./MarkupEditorView.css";
|
|
6
|
-
export type MarkupEditorViewProps = ClassNameProps & {
|
|
7
|
+
export type MarkupEditorViewProps = ClassNameProps & QAProps & {
|
|
7
8
|
editor: EditorInt;
|
|
8
9
|
autofocus?: boolean;
|
|
9
10
|
toolbarConfig: MToolbarData;
|
|
@@ -13,7 +13,7 @@ const context_1 = require("./toolbar/markup/context.js");
|
|
|
13
13
|
require("./MarkupEditorView.css");
|
|
14
14
|
const b = (0, classname_1.cn)('markup-editor');
|
|
15
15
|
exports.MarkupEditorView = (0, react_1.memo)((props) => {
|
|
16
|
-
const { editor, autofocus, settingsVisible, toolbarVisible, toolbarConfig, hiddenActionsConfig, className, toolbarClassName, children, stickyToolbar = true, } = props;
|
|
16
|
+
const { editor, autofocus, settingsVisible, toolbarVisible, toolbarConfig, hiddenActionsConfig, qa, className, toolbarClassName, children, stickyToolbar = true, } = props;
|
|
17
17
|
(0, hooks_1.useRenderTime)((time) => {
|
|
18
18
|
logger_1.globalLogger.metrics({
|
|
19
19
|
component: 'markup-editor',
|
|
@@ -26,7 +26,7 @@ exports.MarkupEditorView = (0, react_1.memo)((props) => {
|
|
|
26
26
|
duration: time,
|
|
27
27
|
});
|
|
28
28
|
});
|
|
29
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: b({ toolbar: toolbarVisible }, [className]), children: [toolbarVisible ? ((0, jsx_runtime_1.jsx)(context_1.MarkupToolbarContextProvider, { value: {
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: b({ toolbar: toolbarVisible }, [className]), "data-mode": editor.currentMode, "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
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 }) })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkupEditorView.js","sourceRoot":"../../../src","sources":["bundle/MarkupEditorView.tsx"],"names":[],"mappings":";;;;AAAA,iCAA2B;
|
|
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,cAA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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\n className={b({toolbar: toolbarVisible}, [className])}\n data-mode={editor.currentMode}\n data-qa={qa}\n >\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,8 +1,9 @@
|
|
|
1
|
+
import type { QAProps } from '@gravity-ui/uikit';
|
|
1
2
|
import { type ClassNameProps } from "../classname.js";
|
|
2
3
|
import type { EditorInt } from "./Editor.js";
|
|
3
4
|
import type { WToolbarData, WToolbarItemData } from "./toolbar/types.js";
|
|
4
5
|
import "./WysiwygEditorView.css";
|
|
5
|
-
export type WysiwygEditorViewProps = ClassNameProps & {
|
|
6
|
+
export type WysiwygEditorViewProps = ClassNameProps & QAProps & {
|
|
6
7
|
editor: EditorInt;
|
|
7
8
|
autofocus?: boolean;
|
|
8
9
|
settingsVisible?: boolean;
|
|
@@ -12,7 +12,7 @@ const WysiwygEditorComponent_1 = require("./WysiwygEditorComponent.js");
|
|
|
12
12
|
require("./WysiwygEditorView.css");
|
|
13
13
|
const b = (0, classname_1.cn)('wysiwyg-editor');
|
|
14
14
|
exports.WysiwygEditorView = (0, react_1.memo)((props) => {
|
|
15
|
-
const { editor, autofocus, settingsVisible, toolbarVisible, toolbarConfig, hiddenActionsConfig, className, toolbarClassName, children, stickyToolbar = true, } = props;
|
|
15
|
+
const { editor, autofocus, settingsVisible, toolbarVisible, toolbarConfig, hiddenActionsConfig, qa, className, toolbarClassName, children, stickyToolbar = true, } = props;
|
|
16
16
|
(0, hooks_1.useRenderTime)((time) => {
|
|
17
17
|
logger_1.globalLogger.metrics({
|
|
18
18
|
component: 'wysiwyg-editor',
|
|
@@ -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]), 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-mode": editor.currentMode, "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 }) })] }));
|
|
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;
|
|
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,iCACI,SAAS,EAAE,CAAC,CAAC,EAAC,OAAO,EAAE,cAAc,EAAC,EAAE,CAAC,SAAS,CAAC,CAAC,eACzC,MAAM,CAAC,WAAW,aACpB,EAAE,aAEV,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\n className={b({toolbar: toolbarVisible}, [className])}\n data-mode={editor.currentMode}\n data-qa={qa}\n >\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,3 +1,3 @@
|
|
|
1
|
-
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "colorify" | "mono" | "block" | "paragraph" | "cut" | "yfm_cut" | "anchor" | "table" | "image" | "checkbox" | "note" | "code_inline" | "code_block" | "undo" | "redo" | "file" | "sinkListItem" | "liftListItem" | "bulletList" | "orderedList" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "emoji" | "yfm_note" | "tabs" | "gpt" | "layout" | "codeBlock" | "math_inline" | "math_block" | "mermaid" | "horizontalRule" | "codeInline" | "filePopup" | "emptyRow" | "horizontalrule" | "imagePopup" | "mathBlock" | "mathInline" | "yfm_block" | "yfm_html_block" | "htmlBlock" | "yfm_layout", string>;
|
|
1
|
+
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "colorify" | "mono" | "quoteLink" | "block" | "paragraph" | "cut" | "yfm_cut" | "anchor" | "table" | "image" | "checkbox" | "note" | "code_inline" | "code_block" | "undo" | "redo" | "file" | "sinkListItem" | "liftListItem" | "bulletList" | "orderedList" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "emoji" | "yfm_note" | "tabs" | "gpt" | "layout" | "codeBlock" | "math_inline" | "math_block" | "mermaid" | "horizontalRule" | "codeInline" | "filePopup" | "emptyRow" | "horizontalrule" | "imagePopup" | "mathBlock" | "mathInline" | "yfm_block" | "yfm_html_block" | "htmlBlock" | "yfm_layout", string>;
|
|
2
2
|
export declare const ActionName: Readonly<typeof namesObj>;
|
|
3
3
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"action-names.js","sourceRoot":"../../../../src","sources":["bundle/config/action-names.ts"],"names":[],"mappings":";;;AAAA,MAAM,KAAK,GAAG;IACV,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,UAAU;IACV,gCAAgC;IAChC,YAAY;IACZ,WAAW;IACX,iCAAiC;IACjC,aAAa;IACb,YAAY;IACZ,UAAU;IACV,OAAO;IACP,MAAM;IACN,WAAW;IACX,KAAK;IACL,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,qCAAqC;IACrC,gBAAgB;IAChB,gBAAgB;IAChB,OAAO;IACP,YAAY;IACZ,QAAQ;IACR,cAAc;IACd,MAAM;IACN,MAAM;IACN,gCAAgC;IAChC,YAAY;IACZ,WAAW;IACX,iCAAiC;IACjC,aAAa;IACb,YAAY;IACZ,SAAS;IACT,MAAM;IACN,aAAa;IACb,WAAW;IACX,OAAO;IACP,MAAM;IACN,cAAc;IACd,QAAQ;IACR,OAAO;IACP,MAAM;IACN,WAAW;IACX,MAAM;IACN,4BAA4B;IAC5B,WAAW;IACX,OAAO;IACP,0BAA0B;IAC1B,SAAS;IACT,KAAK;IACL,gCAAgC;IAChC,gBAAgB;IAChB,WAAW;IACX,6BAA6B;IAC7B,YAAY;IACZ,QAAQ;IACR,2BAA2B;IAC3B,UAAU;IACV,MAAM;CACA,CAAC;AAIX,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CACzB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IACT,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACf,OAAO,GAAG,CAAC;AACf,CAAC,EACD,EAA6C,CAChD,CAAC;AAEW,QAAA,UAAU,GAA8B,QAAQ,CAAC","sourcesContent":["const names = [\n 'anchor',\n 'bold',\n 'bulletList',\n 'checkbox',\n /** @deprecated use codeBlock */\n 'code_block',\n 'codeBlock',\n /** @deprecated use codeInline */\n 'code_inline',\n 'codeInline',\n 'colorify',\n 'emoji',\n 'file',\n 'filePopup',\n 'gpt',\n 'heading1',\n 'heading2',\n 'heading3',\n 'heading4',\n 'heading5',\n 'heading6',\n 'emptyRow',\n /** @deprecated use horizontalRule */\n 'horizontalrule',\n 'horizontalRule',\n 'image',\n 'imagePopup',\n 'italic',\n 'liftListItem',\n 'link',\n 'mark',\n /** @deprecated use mathBlock */\n 'math_block',\n 'mathBlock',\n /** @deprecated use mathInline */\n 'math_inline',\n 'mathInline',\n 'mermaid',\n 'mono',\n 'orderedList',\n 'paragraph',\n 'quote',\n 'redo',\n 'sinkListItem',\n 'strike',\n 'table',\n 'tabs',\n 'underline',\n 'undo',\n /** @deprecated use block */\n 'yfm_block',\n 'block',\n /** @deprecated use cut */\n 'yfm_cut',\n 'cut',\n /** @deprecated use htmlBlock */\n 'yfm_html_block',\n 'htmlBlock',\n /** @deprecated use layout */\n 'yfm_layout',\n 'layout',\n /** @deprecated use note */\n 'yfm_note',\n 'note',\n] as const;\n\ntype ItemsType<L extends readonly string[]> = L extends readonly (infer T)[] ? T : never;\n\nconst namesObj = names.reduce<Record<ItemsType<typeof names>, string>>(\n (obj, val) => {\n obj[val] = val;\n return obj;\n },\n {} as Record<ItemsType<typeof names>, string>,\n);\n\nexport const ActionName: Readonly<typeof namesObj> = namesObj;\n"]}
|
|
1
|
+
{"version":3,"file":"action-names.js","sourceRoot":"../../../../src","sources":["bundle/config/action-names.ts"],"names":[],"mappings":";;;AAAA,MAAM,KAAK,GAAG;IACV,QAAQ;IACR,MAAM;IACN,YAAY;IACZ,UAAU;IACV,gCAAgC;IAChC,YAAY;IACZ,WAAW;IACX,iCAAiC;IACjC,aAAa;IACb,YAAY;IACZ,UAAU;IACV,OAAO;IACP,MAAM;IACN,WAAW;IACX,KAAK;IACL,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,UAAU;IACV,qCAAqC;IACrC,gBAAgB;IAChB,gBAAgB;IAChB,OAAO;IACP,YAAY;IACZ,QAAQ;IACR,cAAc;IACd,MAAM;IACN,MAAM;IACN,gCAAgC;IAChC,YAAY;IACZ,WAAW;IACX,iCAAiC;IACjC,aAAa;IACb,YAAY;IACZ,SAAS;IACT,MAAM;IACN,aAAa;IACb,WAAW;IACX,OAAO;IACP,WAAW;IACX,MAAM;IACN,cAAc;IACd,QAAQ;IACR,OAAO;IACP,MAAM;IACN,WAAW;IACX,MAAM;IACN,4BAA4B;IAC5B,WAAW;IACX,OAAO;IACP,0BAA0B;IAC1B,SAAS;IACT,KAAK;IACL,gCAAgC;IAChC,gBAAgB;IAChB,WAAW;IACX,6BAA6B;IAC7B,YAAY;IACZ,QAAQ;IACR,2BAA2B;IAC3B,UAAU;IACV,MAAM;CACA,CAAC;AAIX,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CACzB,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;IACT,GAAG,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACf,OAAO,GAAG,CAAC;AACf,CAAC,EACD,EAA6C,CAChD,CAAC;AAEW,QAAA,UAAU,GAA8B,QAAQ,CAAC","sourcesContent":["const names = [\n 'anchor',\n 'bold',\n 'bulletList',\n 'checkbox',\n /** @deprecated use codeBlock */\n 'code_block',\n 'codeBlock',\n /** @deprecated use codeInline */\n 'code_inline',\n 'codeInline',\n 'colorify',\n 'emoji',\n 'file',\n 'filePopup',\n 'gpt',\n 'heading1',\n 'heading2',\n 'heading3',\n 'heading4',\n 'heading5',\n 'heading6',\n 'emptyRow',\n /** @deprecated use horizontalRule */\n 'horizontalrule',\n 'horizontalRule',\n 'image',\n 'imagePopup',\n 'italic',\n 'liftListItem',\n 'link',\n 'mark',\n /** @deprecated use mathBlock */\n 'math_block',\n 'mathBlock',\n /** @deprecated use mathInline */\n 'math_inline',\n 'mathInline',\n 'mermaid',\n 'mono',\n 'orderedList',\n 'paragraph',\n 'quote',\n 'quoteLink',\n 'redo',\n 'sinkListItem',\n 'strike',\n 'table',\n 'tabs',\n 'underline',\n 'undo',\n /** @deprecated use block */\n 'yfm_block',\n 'block',\n /** @deprecated use cut */\n 'yfm_cut',\n 'cut',\n /** @deprecated use htmlBlock */\n 'yfm_html_block',\n 'htmlBlock',\n /** @deprecated use layout */\n 'yfm_layout',\n 'layout',\n /** @deprecated use note */\n 'yfm_note',\n 'note',\n] as const;\n\ntype ItemsType<L extends readonly string[]> = L extends readonly (infer T)[] ? T : never;\n\nconst namesObj = names.reduce<Record<ItemsType<typeof names>, string>>(\n (obj, val) => {\n obj[val] = val;\n return obj;\n },\n {} as Record<ItemsType<typeof names>, string>,\n);\n\nexport const ActionName: Readonly<typeof namesObj> = namesObj;\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ToolbarIconData } from "../../toolbar/types.js";
|
|
2
|
-
type Icon = 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'mono' | 'mark' | 'textColor' | 'text' | 'headline' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'bulletList' | 'orderedList' | 'sink' | 'lift' | 'cut' | 'note' | 'code' | 'codeBlock' | 'link' | 'image' | 'table' | 'quote' | 'checklist' | 'horizontalRule' | 'file' | 'functionInline' | 'functionBlock' | 'emoji' | 'tabs' | 'mermaid' | 'html' | 'foldingHeading' | 'gpt';
|
|
2
|
+
type Icon = 'undo' | 'redo' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'mono' | 'mark' | 'textColor' | 'text' | 'headline' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'bulletList' | 'orderedList' | 'sink' | 'lift' | 'cut' | 'note' | 'code' | 'codeBlock' | 'link' | 'image' | 'table' | 'quote' | 'quoteLink' | 'checklist' | 'horizontalRule' | 'file' | 'functionInline' | 'functionBlock' | 'emoji' | 'tabs' | 'mermaid' | 'html' | 'foldingHeading' | 'gpt';
|
|
3
3
|
type Icons = Record<Icon, ToolbarIconData>;
|
|
4
4
|
export declare const icons: Icons;
|
|
5
5
|
export {};
|
|
@@ -34,6 +34,7 @@ exports.icons = {
|
|
|
34
34
|
image: { data: icons_1.ImageIcon },
|
|
35
35
|
table: { data: icons_1.TableIcon },
|
|
36
36
|
quote: { data: icons_1.QuoteIcon },
|
|
37
|
+
quoteLink: { data: icons_1.QuoteLinkIcon },
|
|
37
38
|
checklist: { data: icons_1.CheckListIcon },
|
|
38
39
|
html: { data: icons_1.HtmlBlockIcon },
|
|
39
40
|
horizontalRule: { data: icons_1.HRuleIcon },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"../../../../src","sources":["bundle/config/icons.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"../../../../src","sources":["bundle/config/icons.ts"],"names":[],"mappings":";;;;AAAA,gDAyCqB;AACrB,qEAAsC;AAgDzB,QAAA,KAAK,GAAU;IACxB,IAAI,EAAE,EAAC,IAAI,EAAE,gBAAQ,EAAC;IACtB,IAAI,EAAE,EAAC,IAAI,EAAE,gBAAQ,EAAC;IAEtB,IAAI,EAAE,EAAC,IAAI,EAAE,gBAAQ,EAAC;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AI,EAAE,iBAAS,EAAC;IACxB,KAAK,EAAE,EAAC,IAAI,EAAE,iBAAS,EAAC;IACxB,SAAS,EAAE,EAAC,IAAI,EAAE,qBAAa,EAAC;IAChC,SAAS,EAAE,EAAC,IAAI,EAAE,qBAAa,EAAC;IAEhC,IAAI,EAAE,EAAC,IAAI,EAAE,qBAAa,EAAC;IAC3B,cAAc,EAAE,EAAC,IAAI,EAAE,iBAAS,EAAC;IAEjC,IAAI,EAAE,EAAC,IAAI,EAAE,gBAAQ,EAAC;IAEtB,cAAc,EAAE,EAAC,IAAI,EAAE,0BAAkB,EAAC;IAC1C,aAAa,EAAE,EAAC,IAAI,EAAE,yBAAiB,EAAC;IAExC,KAAK,EAAE,EAAC,IAAI,EAAE,iBAAS,EAAC;IAExB,IAAI,EAAE,EAAC,IAAI,EAAE,gBAAQ,EAAC;IACtB,OAAO,EAAE,EAAC,IAAI,EAAE,mBAAW,EAAC;IAE5B,cAAc,EAAE,EAAC,IAAI,EAAE,0BAAkB,EAAC;IAE1C,GAAG,EAAE,EAAC,IAAI,EAAE,aAAO,EAAC;CACvB,CAAC","sourcesContent":["import {\n BoldIcon,\n CheckListIcon,\n CodeBlockIcon,\n CodeInlineIcon,\n CutIcon,\n EmojiIcon,\n FileIcon,\n FoldingHeadingIcon,\n FunctionBlockIcon,\n FunctionInlineIcon,\n HRuleIcon,\n Heading1Icon,\n Heading2Icon,\n Heading3Icon,\n Heading4Icon,\n Heading5Icon,\n Heading6Icon,\n HeadingIcon,\n HtmlBlockIcon,\n ImageIcon,\n ItalicIcon,\n LiftIcon,\n LinkIcon,\n ListBlIcon,\n ListOlIcon,\n MarkIcon,\n MermaidIcon,\n MonoIcon,\n NoteIcon,\n QuoteIcon,\n QuoteLinkIcon,\n RedoIcon,\n SinkIcon,\n StrikethroughIcon,\n TableIcon,\n TabsIcon,\n TextColorIcon,\n TextIcon,\n UnderlineIcon,\n UndoIcon,\n} from '../../icons';\nimport GPTIcon from '../../icons/GPT';\nimport type {ToolbarIconData} from '../../toolbar/types';\n\ntype Icon =\n | 'undo'\n | 'redo'\n | 'bold'\n | 'italic'\n | 'underline'\n | 'strikethrough'\n | 'mono'\n | 'mark'\n | 'textColor'\n | 'text'\n | 'headline'\n | 'h1'\n | 'h2'\n | 'h3'\n | 'h4'\n | 'h5'\n | 'h6'\n | 'bulletList'\n | 'orderedList'\n | 'sink'\n | 'lift'\n | 'cut'\n | 'note'\n | 'code'\n | 'codeBlock'\n | 'link'\n | 'image'\n | 'table'\n | 'quote'\n | 'quoteLink'\n | 'checklist'\n | 'horizontalRule'\n | 'file'\n | 'functionInline'\n | 'functionBlock'\n | 'emoji'\n | 'tabs'\n | 'mermaid'\n | 'html'\n | 'foldingHeading'\n | 'gpt';\n\ntype Icons = Record<Icon, ToolbarIconData>;\n\nexport const icons: Icons = {\n undo: {data: UndoIcon},\n redo: {data: RedoIcon},\n\n bold: {data: BoldIcon},\n italic: {data: ItalicIcon},\n underline: {data: UnderlineIcon},\n strikethrough: {data: StrikethroughIcon},\n mono: {data: MonoIcon},\n mark: {data: MarkIcon},\n\n textColor: {data: TextColorIcon},\n\n text: {data: TextIcon},\n headline: {data: HeadingIcon},\n h1: {data: Heading1Icon},\n h2: {data: Heading2Icon},\n h3: {data: Heading3Icon},\n h4: {data: Heading4Icon},\n h5: {data: Heading5Icon},\n h6: {data: Heading6Icon},\n\n bulletList: {data: ListBlIcon},\n orderedList: {data: ListOlIcon},\n\n sink: {data: SinkIcon},\n lift: {data: LiftIcon},\n\n cut: {data: CutIcon},\n note: {data: NoteIcon},\n\n code: {data: CodeInlineIcon},\n codeBlock: {data: CodeBlockIcon},\n\n link: {data: LinkIcon},\n image: {data: ImageIcon},\n\n table: {data: TableIcon},\n quote: {data: QuoteIcon},\n quoteLink: {data: QuoteLinkIcon},\n checklist: {data: CheckListIcon},\n\n html: {data: HtmlBlockIcon},\n horizontalRule: {data: HRuleIcon},\n\n file: {data: FileIcon},\n\n functionInline: {data: FunctionInlineIcon},\n functionBlock: {data: FunctionBlockIcon},\n\n emoji: {data: EmojiIcon},\n\n tabs: {data: TabsIcon},\n mermaid: {data: MermaidIcon},\n\n foldingHeading: {data: FoldingHeadingIcon},\n\n gpt: {data: GPTIcon},\n};\n"]}
|
|
@@ -24,14 +24,14 @@ 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, { 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, 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, { 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') }) })] }))] }));
|
|
28
28
|
});
|
|
29
29
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
30
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]), children: [(0, jsx_runtime_1.jsxs)(uikit_1.Menu, { size: "l", className: bContent('mode'), children: [(0, jsx_runtime_1.jsx)(uikit_1.Menu.Item, { active: mode === 'wysiwyg', onClick: () => {
|
|
31
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: bContent(null, [className]), "data-qa": "g-md-settings-content", 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: "md-settings-mode-wysiwyg", active: mode === 'wysiwyg', onClick: () => {
|
|
32
32
|
onModeChange('wysiwyg');
|
|
33
33
|
onClose();
|
|
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, { active: mode === 'markup', onClick: () => {
|
|
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: "md-settings-mode-markup", active: mode === 'markup', onClick: () => {
|
|
35
35
|
onModeChange('markup');
|
|
36
36
|
onClose();
|
|
37
37
|
}, iconStart: (0, jsx_runtime_1.jsx)(uikit_1.Icon, { data: icons_1.LogoMarkdown }), children: [(0, bundle_1.i18n)('settings_markup'), (0, jsx_runtime_1.jsx)(uikit_1.HelpMark, { popoverProps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["bundle/settings/index.tsx"],"names":[],"mappings":";;;;;AAAA,4DAA4D;AAC5D,0DAA0D;AAC1D,iCAAqC;AAErC,6CAA0D;AAC1D,6CAS2B;AAE3B,kDAAwD;AACxD,uDAAuC;AACvC,qFAAsD;AACtD,4CAAkC;AAClC,sDAAwD;AACxD,oDAAkD;AAClD,8CAAsC;AAGtC,4DAA8C;AAE9C,uBAAsB;AAEtB,MAAM,SAAS,GAAmB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAE5D,MAAM,S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0BAA0B,CAAC,GAC/B,IACJ,CACT,EACD,iCAAM,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,YAAG,iBAAO,GAAQ,IACpD,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport {memo, useState} from 'react';\n\nimport {Eye, Gear, LogoMarkdown} from '@gravity-ui/icons';\nimport {\n ActionTooltip,\n Button,\n Checkbox,\n HelpMark,\n Icon,\n Menu,\n Popup,\n type PopupPlacement,\n} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../../classname';\nimport {i18n} from '../../i18n/bundle';\nimport WysiwygModeIcon from '../../icons/WysiwygMode';\nimport {noop} from '../../lodash';\nimport {useBooleanState} from '../../react-utils/hooks';\nimport {ToolbarTooltipDelay} from '../../toolbar';\nimport {VERSION} from '../../version';\nimport type {MarkdownEditorMode, MarkdownEditorSplitMode} from '../types';\n\nimport {MarkdownHints} from './MarkdownHints';\n\nimport './index.scss';\n\nconst placement: PopupPlacement = ['bottom-end', 'top-end'];\n\nconst bSettings = cn('editor-settings');\nconst bContent = cn('settings-content');\n\nexport type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {\n renderPreviewButton?: boolean;\n settingsVisible?: boolean;\n};\n\nexport const EditorSettings = memo<EditorSettingsProps>(function EditorSettings(props) {\n const {className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible} =\n props;\n const [chevronElement, setChevronElement] = useState<HTMLButtonElement | null>(null);\n const [popupShown, , hidePopup, togglePopup] = useBooleanState(false);\n\n return (\n <div className={bSettings(null, [className])}>\n {renderPreviewButton && (\n <>\n <ActionTooltip\n openDelay={ToolbarTooltipDelay.Open}\n closeDelay={ToolbarTooltipDelay.Close}\n title={i18n('preview_hint')}\n hotkey=\"mod+shift+p\"\n >\n <Button\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n className={bSettings('preview-button')}\n onClick={() => onShowPreviewChange?.(!showPreview)}\n selected={showPreview}\n >\n <Icon data={Eye} />\n </Button>\n </ActionTooltip>\n {settingsVisible && <div className={bSettings('separator')} />}\n </>\n )}\n {settingsVisible && (\n <>\n <Button\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n onClick={togglePopup}\n ref={setChevronElement}\n className={bSettings('dropdown-button')}\n >\n <Icon data={Gear} />\n </Button>\n <Popup\n open={popupShown}\n anchorElement={chevronElement}\n placement={placement}\n onOpenChange={hidePopup}\n >\n <SettingsContent\n {...props}\n onClose={hidePopup}\n className={bSettings('content')}\n />\n </Popup>\n </>\n )}\n </div>\n );\n});\n\ntype SettingsContentProps = ClassNameProps & {\n mode: MarkdownEditorMode;\n onClose: () => void;\n onModeChange: (mode: MarkdownEditorMode) => void;\n onShowPreviewChange: (showPreview: boolean) => void;\n showPreview: boolean;\n toolbarVisibility: boolean;\n onToolbarVisibilityChange: (val: boolean) => void;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled?: boolean;\n onSplitModeChange?: (splitModeEnabled: boolean) => void;\n};\n\nconst mdHelpPlacement: PopupPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];\n\nconst SettingsContent: React.FC<SettingsContentProps> = function SettingsContent({\n mode,\n onClose,\n onModeChange,\n toolbarVisibility,\n onToolbarVisibilityChange,\n onSplitModeChange,\n splitMode = false,\n splitModeEnabled,\n className,\n showPreview,\n}) {\n return (\n <div className={bContent(null, [className])}>\n <Menu size=\"l\" className={bContent('mode')}>\n <Menu.Item\n active={mode === 'wysiwyg'}\n onClick={() => {\n onModeChange('wysiwyg');\n onClose();\n }}\n iconStart={<Icon data={WysiwygModeIcon} />}\n >\n {i18n('settings_wysiwyg')}\n </Menu.Item>\n <Menu.Item\n active={mode === 'markup'}\n onClick={() => {\n onModeChange('markup');\n onClose();\n }}\n iconStart={<Icon data={LogoMarkdown} />}\n >\n {i18n('settings_markup')}\n <HelpMark\n popoverProps={{\n placement: mdHelpPlacement,\n modal: false,\n }}\n className={bContent('mode-help')}\n >\n <div\n onClick={(e) => {\n // stop clicks propagation\n // because otherwise click in MarkdownHints handled as click on MenuItem\n e.stopPropagation();\n }}\n >\n <MarkdownHints />\n </div>\n </HelpMark>\n </Menu.Item>\n </Menu>\n <div className={bContent('separator')} />\n {!showPreview && (\n <div className={bContent('toolbar')}>\n <Checkbox\n size=\"m\"\n checked={toolbarVisibility}\n onUpdate={onToolbarVisibilityChange}\n >\n {i18n('settings_menubar')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>{i18n('settings_hint')}</div>\n </div>\n )}\n {splitMode && (\n <div className={bContent('split-mode')}>\n <Checkbox\n size=\"m\"\n disabled={mode !== 'markup'}\n checked={splitModeEnabled}\n onUpdate={onSplitModeChange ?? noop}\n >\n {i18n('settings_split-mode')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>\n {i18n('settings_split-mode-hint')}\n </div>\n </div>\n )}\n <span className={bContent('version')}>{VERSION}</span>\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../../../../src","sources":["bundle/settings/index.tsx"],"names":[],"mappings":";;;;;AAAA,4DAA4D;AAC5D,0DAA0D;AAC1D,iCAAqC;AAErC,6CAA0D;AAC1D,6CAS2B;AAE3B,kDAAwD;AACxD,uDAAuC;AACvC,qFAAsD;AACtD,4CAAkC;AAClC,sDAAwD;AACxD,oDAAkD;AAClD,8CAAsC;AAGtC,4DAA8C;AAE9C,uBAAsB;AAEtB,MAAM,SAAS,GAAmB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAE5D,MAAM,SAAS,GAAG,IAAA,cAAE,EAAC,iBAAiB,CAAC,CAAC;AACxC,MAAM,QAAQ,GAAG,IAAA,cAAE,EAAC,kBAAkB,CAAC,CAAC;AAO3B,QAAA,cAAc,GAAG,IAAA,YAAI,EAAsB,SAAS,cAAc,CAAC,KAAK;IACjF,MAAM,EAAC,SAAS,EAAE,mBAAmB,EAAE,WAAW,E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ourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\nimport {memo, useState} from 'react';\n\nimport {Eye, Gear, LogoMarkdown} from '@gravity-ui/icons';\nimport {\n ActionTooltip,\n Button,\n Checkbox,\n HelpMark,\n Icon,\n Menu,\n Popup,\n type PopupPlacement,\n} from '@gravity-ui/uikit';\n\nimport {type ClassNameProps, cn} from '../../classname';\nimport {i18n} from '../../i18n/bundle';\nimport WysiwygModeIcon from '../../icons/WysiwygMode';\nimport {noop} from '../../lodash';\nimport {useBooleanState} from '../../react-utils/hooks';\nimport {ToolbarTooltipDelay} from '../../toolbar';\nimport {VERSION} from '../../version';\nimport type {MarkdownEditorMode, MarkdownEditorSplitMode} from '../types';\n\nimport {MarkdownHints} from './MarkdownHints';\n\nimport './index.scss';\n\nconst placement: PopupPlacement = ['bottom-end', 'top-end'];\n\nconst bSettings = cn('editor-settings');\nconst bContent = cn('settings-content');\n\nexport type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {\n renderPreviewButton?: boolean;\n settingsVisible?: boolean;\n};\n\nexport const EditorSettings = memo<EditorSettingsProps>(function EditorSettings(props) {\n const {className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible} =\n props;\n const [chevronElement, setChevronElement] = useState<HTMLButtonElement | null>(null);\n const [popupShown, , hidePopup, togglePopup] = useBooleanState(false);\n\n return (\n <div className={bSettings(null, [className])}>\n {renderPreviewButton && (\n <>\n <ActionTooltip\n openDelay={ToolbarTooltipDelay.Open}\n closeDelay={ToolbarTooltipDelay.Close}\n title={i18n('preview_hint')}\n hotkey=\"mod+shift+p\"\n >\n <Button\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n className={bSettings('preview-button')}\n onClick={() => onShowPreviewChange?.(!showPreview)}\n selected={showPreview}\n >\n <Icon data={Eye} />\n </Button>\n </ActionTooltip>\n {settingsVisible && <div className={bSettings('separator')} />}\n </>\n )}\n {settingsVisible && (\n <>\n <Button\n size=\"m\"\n view=\"flat\"\n pin=\"round-round\"\n onClick={togglePopup}\n ref={setChevronElement}\n qa=\"g-md-settings-button\"\n className={bSettings('dropdown-button')}\n >\n <Icon data={Gear} />\n </Button>\n <Popup\n open={popupShown}\n anchorElement={chevronElement}\n placement={placement}\n onOpenChange={hidePopup}\n >\n <SettingsContent\n {...props}\n onClose={hidePopup}\n className={bSettings('content')}\n />\n </Popup>\n </>\n )}\n </div>\n );\n});\n\ntype SettingsContentProps = ClassNameProps & {\n mode: MarkdownEditorMode;\n onClose: () => void;\n onModeChange: (mode: MarkdownEditorMode) => void;\n onShowPreviewChange: (showPreview: boolean) => void;\n showPreview: boolean;\n toolbarVisibility: boolean;\n onToolbarVisibilityChange: (val: boolean) => void;\n splitMode?: MarkdownEditorSplitMode;\n splitModeEnabled?: boolean;\n onSplitModeChange?: (splitModeEnabled: boolean) => void;\n};\n\nconst mdHelpPlacement: PopupPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];\n\nconst SettingsContent: React.FC<SettingsContentProps> = function SettingsContent({\n mode,\n onClose,\n onModeChange,\n toolbarVisibility,\n onToolbarVisibilityChange,\n onSplitModeChange,\n splitMode = false,\n splitModeEnabled,\n className,\n showPreview,\n}) {\n return (\n <div className={bContent(null, [className])} data-qa=\"g-md-settings-content\">\n <Menu size=\"l\" className={bContent('mode')}>\n <Menu.Item\n qa=\"md-settings-mode-wysiwyg\"\n active={mode === 'wysiwyg'}\n onClick={() => {\n onModeChange('wysiwyg');\n onClose();\n }}\n iconStart={<Icon data={WysiwygModeIcon} />}\n >\n {i18n('settings_wysiwyg')}\n </Menu.Item>\n <Menu.Item\n qa=\"md-settings-mode-markup\"\n active={mode === 'markup'}\n onClick={() => {\n onModeChange('markup');\n onClose();\n }}\n iconStart={<Icon data={LogoMarkdown} />}\n >\n {i18n('settings_markup')}\n <HelpMark\n popoverProps={{\n placement: mdHelpPlacement,\n modal: false,\n }}\n className={bContent('mode-help')}\n >\n <div\n onClick={(e) => {\n // stop clicks propagation\n // because otherwise click in MarkdownHints handled as click on MenuItem\n e.stopPropagation();\n }}\n >\n <MarkdownHints />\n </div>\n </HelpMark>\n </Menu.Item>\n </Menu>\n <div className={bContent('separator')} />\n {!showPreview && (\n <div className={bContent('toolbar')}>\n <Checkbox\n size=\"m\"\n checked={toolbarVisibility}\n onUpdate={onToolbarVisibilityChange}\n >\n {i18n('settings_menubar')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>{i18n('settings_hint')}</div>\n </div>\n )}\n {splitMode && (\n <div className={bContent('split-mode')}>\n <Checkbox\n size=\"m\"\n disabled={mode !== 'markup'}\n checked={splitModeEnabled}\n onUpdate={onSplitModeChange ?? noop}\n >\n {i18n('settings_split-mode')}\n </Checkbox>\n <div className={bContent('toolbar-hint')}>\n {i18n('settings_split-mode-hint')}\n </div>\n </div>\n )}\n <span className={bContent('version')}>{VERSION}</span>\n </div>\n );\n};\n"]}
|
|
@@ -159,6 +159,12 @@ export type MarkdownEditorWysiwygConfig = {
|
|
|
159
159
|
extensionOptions?: ExtensionsOptions;
|
|
160
160
|
escapeConfig?: EscapeConfig;
|
|
161
161
|
placeholderOptions?: WysiwygPlaceholderOptions;
|
|
162
|
+
/**
|
|
163
|
+
* Disable the markdown-it-attrs plugin in the markup parser.
|
|
164
|
+
*
|
|
165
|
+
* Note: The use of the markdown-it-attrs plugin will be removed in the next major version.
|
|
166
|
+
*/
|
|
167
|
+
disableMarkdownAttrs?: boolean;
|
|
162
168
|
};
|
|
163
169
|
export type MarkdownEditorOptions = {
|
|
164
170
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["bundle/types.ts"],"names":[],"mappings":";AAAA,mDAAmD","sourcesContent":["// public types, re-exported in src/bundle/index.ts\n\nimport type {ReactNode} from 'react';\n\nimport type {MarkupString} from '../common';\nimport type {EscapeConfig, Extension} from '../core';\nimport type {Logger2} from '../logger';\nimport type {CreateCodemirrorParams, YfmLangOptions} from '../markup';\nimport type {FileUploadHandler} from '../utils';\nimport type {DirectiveSyntaxContext, DirectiveSyntaxOption} from '../utils/directive';\n\nimport type {ChangeEditorModeOptions} from './Editor';\nimport type {ExtensionsOptions as WysiwygPresetExtensionsOptions} from './wysiwyg-preset';\n\nexport type {Editor as MarkdownEditorInstance} from './Editor';\nexport type MarkdownEditorMode = 'wysiwyg' | 'markup';\nexport type MarkdownEditorPreset = 'zero' | 'commonmark' | 'default' | 'yfm' | 'full';\nexport type MarkdownEditorSplitMode = false | 'horizontal' | 'vertical';\n\nexport type RenderPreviewParams = {\n getValue: () => MarkupString;\n mode: 'preview' | 'split';\n md: Readonly<MarkdownEditorMdOptions>;\n directiveSyntax: Pick<DirectiveSyntaxContext, 'option' | 'valueFor' | 'mdPluginValueFor'>;\n};\nexport type RenderPreview = (params: RenderPreviewParams) => ReactNode;\n\nexport type ParseInsertedUrlAsImage = (text: string) => {imageUrl: string; title?: string} | null;\n\nexport type WysiwygPlaceholderOptions = {\n value?: string | (() => string);\n /** Default – empty-doc\n Values:\n - 'empty-doc' – The placeholder will only be shown when the document is completely empty;\n - 'empty-row-top-level' – The placeholder will be displayed in an empty line that is at the top level of the document structure;\n - 'empty-row' – The placeholder will be shown in any empty line within the document, regardless of its nesting level.\n */\n behavior?: 'empty-doc' | 'empty-row-top-level' | 'empty-row';\n};\n\nexport type MarkdownEditorMdOptions = {\n html?: boolean;\n breaks?: boolean;\n linkify?: boolean;\n linkifyTlds?: string | string[];\n};\n\nexport type MarkdownEditorInitialOptions = {\n markup?: MarkupString;\n /** Default – wysiwyg */\n mode?: MarkdownEditorMode;\n /** Default – true */\n toolbarVisible?: boolean;\n /**\n * Default – false\n *\n * Note: has no effect if `MarkdownEditorMarkupConfig.splitMode` is set to false or is not set.\n */\n splitModeEnabled?: boolean;\n};\n\nexport type MarkdownEditorHandlers = {\n /** Pass this handler to allow uploading files from device. */\n uploadFile?: FileUploadHandler;\n};\n\nexport type MarkdownEditorExperimentalOptions = {\n /**\n * If we need to set dimensions for uploaded images\n *\n * @default false\n */\n needToSetDimensionsForUploadedImages?: boolean;\n /**\n * If we need to enable new image size calculations\n *\n * @default false\n */\n enableNewImageSizeCalculation?: boolean;\n /**\n * Called before switching from the markup editor to the wysiwyg editor.\n * You can use it to pre-process the value from the markup editor before it gets into the wysiwyg editor.\n */\n prepareRawMarkup?: (value: MarkupString) => MarkupString;\n beforeEditorModeChange?: (\n options: Pick<ChangeEditorModeOptions, 'mode' | 'reason'>,\n ) => boolean | undefined;\n /**\n * Enables support of directive syntax for diplodoc (YFM) extensions.\n *\n * **Note:** This setting affects parsing of markdown markup and serializing to markdown markup.\n * Be careful with it and use it in consistency with diplodoc/transform and diplodoc-extensions.\n *\n * Before enabling this option, make sure that appropriate versions of diplodoc/transform and diplodoc-extensions are installed.\n *\n * You can pass an object in `key:value` format to provide different behaviour for each extension individually.\n *\n * Values:\n * - 'disabled' – directive syntax is disabled;\n * - 'enabled' – directive syntax is enabled. Syntax of existing blocks is preserved. New blocks will be serialized using old syntax;\n * - 'preserve' – directive syntax is enabled. Syntax of existing blocks is preserved. New blocks will be serialized using directive syntax;\n * - 'overwrite' – existing blocks will be overwritten using directive syntax through serialization;\n * - 'only' – old syntax is disabled, only directive syntax available. Blocks in old syntax will not be parsed.\n *\n * Default value is 'disabled'.\n */\n directiveSyntax?: DirectiveSyntaxOption;\n /**\n * If we need support for empty strings\n *\n * @default false\n */\n preserveEmptyRows?: boolean;\n /**\n * Preserves the original formatting of unmodified blocks,\n * restoring their structure during serialization\n *\n * **Use case:** Maintain consistent markup when switching modes\n *\n * **Note:** Applies to tracked blocks: `yfm_table`\n *\n * @default false\n */\n preserveMarkupFormatting?: boolean;\n};\n\nexport type MarkdownEditorMarkupConfig = {\n /**\n * Pass the rendering function to preview the markdown content.\n *\n * It is also used for split view rendering.\n *\n * If false is passed, preview will be disabled.\n */\n renderPreview?: RenderPreview;\n /**\n * Pass position of split view.\n *\n * Note: for enable split view, you need to pass renderPreview function too.\n *\n * If false is passed, split view will be disabled.\n */\n splitMode?: MarkdownEditorSplitMode;\n /** Additional extensions for codemirror instance. */\n extensions?: CreateCodemirrorParams['extensions'];\n /** Can be used to disable some of the default extensions */\n disabledExtensions?: CreateCodemirrorParams['disabledExtensions'];\n /** Additional keymaps for codemirror instance */\n keymaps?: CreateCodemirrorParams['keymaps'];\n /** Overrides the default placeholder content. */\n placeholder?: CreateCodemirrorParams['placeholder'];\n /** Enable HTML parsing when pasting content. */\n parseHtmlOnPaste?: boolean;\n /**\n * Additional language data for markdown language in codemirror.\n * Can be used to configure additional autocompletions and others.\n * See more https://codemirror.net/docs/ref/#state.EditorState.languageDataAt\n */\n languageData?: YfmLangOptions['languageData'];\n /** Config for @codemirror/autocomplete https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig */\n autocompletion?: CreateCodemirrorParams['autocompletion'];\n /**\n * The function, used to determine if the pasted text is the image url and should be inserted as an image\n */\n parseInsertedUrlAsImage?: ParseInsertedUrlAsImage;\n};\n\n// do not export this type\ntype ExtensionsOptions<T extends object = {}> = Omit<\n WysiwygPresetExtensionsOptions,\n 'reactRenderer'\n> &\n T;\n\nexport type MarkdownEditorWysiwygConfig = {\n /** Additional extensions */\n extensions?: Extension;\n extensionOptions?: ExtensionsOptions;\n escapeConfig?: EscapeConfig;\n placeholderOptions?: WysiwygPlaceholderOptions;\n};\n\nexport type MarkdownEditorOptions = {\n /**\n * A set of plug-in extensions.\n *\n * @default 'full'\n */\n preset?: MarkdownEditorPreset;\n /** Markdown parser options */\n md?: MarkdownEditorMdOptions;\n /** Initial values */\n initial?: MarkdownEditorInitialOptions;\n handlers?: MarkdownEditorHandlers;\n experimental?: MarkdownEditorExperimentalOptions;\n /** Options for markup mode */\n markupConfig?: MarkdownEditorMarkupConfig;\n /** Options for wysiwyg mode */\n wysiwygConfig?: MarkdownEditorWysiwygConfig;\n logger?: Logger2.ILogger;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"../../../src","sources":["bundle/types.ts"],"names":[],"mappings":";AAAA,mDAAmD","sourcesContent":["// public types, re-exported in src/bundle/index.ts\n\nimport type {ReactNode} from 'react';\n\nimport type {MarkupString} from '../common';\nimport type {EscapeConfig, Extension} from '../core';\nimport type {Logger2} from '../logger';\nimport type {CreateCodemirrorParams, YfmLangOptions} from '../markup';\nimport type {FileUploadHandler} from '../utils';\nimport type {DirectiveSyntaxContext, DirectiveSyntaxOption} from '../utils/directive';\n\nimport type {ChangeEditorModeOptions} from './Editor';\nimport type {ExtensionsOptions as WysiwygPresetExtensionsOptions} from './wysiwyg-preset';\n\nexport type {Editor as MarkdownEditorInstance} from './Editor';\nexport type MarkdownEditorMode = 'wysiwyg' | 'markup';\nexport type MarkdownEditorPreset = 'zero' | 'commonmark' | 'default' | 'yfm' | 'full';\nexport type MarkdownEditorSplitMode = false | 'horizontal' | 'vertical';\n\nexport type RenderPreviewParams = {\n getValue: () => MarkupString;\n mode: 'preview' | 'split';\n md: Readonly<MarkdownEditorMdOptions>;\n directiveSyntax: Pick<DirectiveSyntaxContext, 'option' | 'valueFor' | 'mdPluginValueFor'>;\n};\nexport type RenderPreview = (params: RenderPreviewParams) => ReactNode;\n\nexport type ParseInsertedUrlAsImage = (text: string) => {imageUrl: string; title?: string} | null;\n\nexport type WysiwygPlaceholderOptions = {\n value?: string | (() => string);\n /** Default – empty-doc\n Values:\n - 'empty-doc' – The placeholder will only be shown when the document is completely empty;\n - 'empty-row-top-level' – The placeholder will be displayed in an empty line that is at the top level of the document structure;\n - 'empty-row' – The placeholder will be shown in any empty line within the document, regardless of its nesting level.\n */\n behavior?: 'empty-doc' | 'empty-row-top-level' | 'empty-row';\n};\n\nexport type MarkdownEditorMdOptions = {\n html?: boolean;\n breaks?: boolean;\n linkify?: boolean;\n linkifyTlds?: string | string[];\n};\n\nexport type MarkdownEditorInitialOptions = {\n markup?: MarkupString;\n /** Default – wysiwyg */\n mode?: MarkdownEditorMode;\n /** Default – true */\n toolbarVisible?: boolean;\n /**\n * Default – false\n *\n * Note: has no effect if `MarkdownEditorMarkupConfig.splitMode` is set to false or is not set.\n */\n splitModeEnabled?: boolean;\n};\n\nexport type MarkdownEditorHandlers = {\n /** Pass this handler to allow uploading files from device. */\n uploadFile?: FileUploadHandler;\n};\n\nexport type MarkdownEditorExperimentalOptions = {\n /**\n * If we need to set dimensions for uploaded images\n *\n * @default false\n */\n needToSetDimensionsForUploadedImages?: boolean;\n /**\n * If we need to enable new image size calculations\n *\n * @default false\n */\n enableNewImageSizeCalculation?: boolean;\n /**\n * Called before switching from the markup editor to the wysiwyg editor.\n * You can use it to pre-process the value from the markup editor before it gets into the wysiwyg editor.\n */\n prepareRawMarkup?: (value: MarkupString) => MarkupString;\n beforeEditorModeChange?: (\n options: Pick<ChangeEditorModeOptions, 'mode' | 'reason'>,\n ) => boolean | undefined;\n /**\n * Enables support of directive syntax for diplodoc (YFM) extensions.\n *\n * **Note:** This setting affects parsing of markdown markup and serializing to markdown markup.\n * Be careful with it and use it in consistency with diplodoc/transform and diplodoc-extensions.\n *\n * Before enabling this option, make sure that appropriate versions of diplodoc/transform and diplodoc-extensions are installed.\n *\n * You can pass an object in `key:value` format to provide different behaviour for each extension individually.\n *\n * Values:\n * - 'disabled' – directive syntax is disabled;\n * - 'enabled' – directive syntax is enabled. Syntax of existing blocks is preserved. New blocks will be serialized using old syntax;\n * - 'preserve' – directive syntax is enabled. Syntax of existing blocks is preserved. New blocks will be serialized using directive syntax;\n * - 'overwrite' – existing blocks will be overwritten using directive syntax through serialization;\n * - 'only' – old syntax is disabled, only directive syntax available. Blocks in old syntax will not be parsed.\n *\n * Default value is 'disabled'.\n */\n directiveSyntax?: DirectiveSyntaxOption;\n /**\n * If we need support for empty strings\n *\n * @default false\n */\n preserveEmptyRows?: boolean;\n /**\n * Preserves the original formatting of unmodified blocks,\n * restoring their structure during serialization\n *\n * **Use case:** Maintain consistent markup when switching modes\n *\n * **Note:** Applies to tracked blocks: `yfm_table`\n *\n * @default false\n */\n preserveMarkupFormatting?: boolean;\n};\n\nexport type MarkdownEditorMarkupConfig = {\n /**\n * Pass the rendering function to preview the markdown content.\n *\n * It is also used for split view rendering.\n *\n * If false is passed, preview will be disabled.\n */\n renderPreview?: RenderPreview;\n /**\n * Pass position of split view.\n *\n * Note: for enable split view, you need to pass renderPreview function too.\n *\n * If false is passed, split view will be disabled.\n */\n splitMode?: MarkdownEditorSplitMode;\n /** Additional extensions for codemirror instance. */\n extensions?: CreateCodemirrorParams['extensions'];\n /** Can be used to disable some of the default extensions */\n disabledExtensions?: CreateCodemirrorParams['disabledExtensions'];\n /** Additional keymaps for codemirror instance */\n keymaps?: CreateCodemirrorParams['keymaps'];\n /** Overrides the default placeholder content. */\n placeholder?: CreateCodemirrorParams['placeholder'];\n /** Enable HTML parsing when pasting content. */\n parseHtmlOnPaste?: boolean;\n /**\n * Additional language data for markdown language in codemirror.\n * Can be used to configure additional autocompletions and others.\n * See more https://codemirror.net/docs/ref/#state.EditorState.languageDataAt\n */\n languageData?: YfmLangOptions['languageData'];\n /** Config for @codemirror/autocomplete https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig */\n autocompletion?: CreateCodemirrorParams['autocompletion'];\n /**\n * The function, used to determine if the pasted text is the image url and should be inserted as an image\n */\n parseInsertedUrlAsImage?: ParseInsertedUrlAsImage;\n};\n\n// do not export this type\ntype ExtensionsOptions<T extends object = {}> = Omit<\n WysiwygPresetExtensionsOptions,\n 'reactRenderer'\n> &\n T;\n\nexport type MarkdownEditorWysiwygConfig = {\n /** Additional extensions */\n extensions?: Extension;\n extensionOptions?: ExtensionsOptions;\n escapeConfig?: EscapeConfig;\n placeholderOptions?: WysiwygPlaceholderOptions;\n // MAJOR: remove markdown-it-attrs\n /**\n * Disable the markdown-it-attrs plugin in the markup parser.\n *\n * Note: The use of the markdown-it-attrs plugin will be removed in the next major version.\n */\n disableMarkdownAttrs?: boolean;\n};\n\nexport type MarkdownEditorOptions = {\n /**\n * A set of plug-in extensions.\n *\n * @default 'full'\n */\n preset?: MarkdownEditorPreset;\n /** Markdown parser options */\n md?: MarkdownEditorMdOptions;\n /** Initial values */\n initial?: MarkdownEditorInitialOptions;\n handlers?: MarkdownEditorHandlers;\n experimental?: MarkdownEditorExperimentalOptions;\n /** Options for markup mode */\n markupConfig?: MarkdownEditorMarkupConfig;\n /** Options for wysiwyg mode */\n wysiwygConfig?: MarkdownEditorWysiwygConfig;\n logger?: Logger2.ILogger;\n};\n"]}
|
|
@@ -32,6 +32,7 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
32
32
|
editor.emit('submit', null);
|
|
33
33
|
return true;
|
|
34
34
|
},
|
|
35
|
+
disableMdAttrs: wysiwygConfig.disableMarkdownAttrs,
|
|
35
36
|
preserveEmptyRows: experimental.preserveEmptyRows,
|
|
36
37
|
placeholderOptions: wysiwygConfig.placeholderOptions,
|
|
37
38
|
mdBreaks: md.breaks,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarkdownEditor.js","sourceRoot":"../../../src","sources":["bundle/useMarkdownEditor.ts"],"names":[],"mappings":";;AAmBA,
|
|
1
|
+
{"version":3,"file":"useMarkdownEditor.js","sourceRoot":"../../../src","sources":["bundle/useMarkdownEditor.ts"],"names":[],"mappings":";;AAmBA,8CAyFC;AA5GD,iCAA+C;AAG/C,gGAA0F;AAC1F,uDAAiD;AACjD,yCAAgD;AAChD,qDAA0D;AAE1D,wCAAoD;AAOpD,wDAA8C;AAI9C,SAAgB,iBAAiB,CAC7B,KAA6B,EAC7B,OAA6B,EAAE;IAE/B,MAAM,MAAM,GAAG,IAAA,eAAO,EAAY,GAAG,EAAE;QACnC,MAAM,EACF,EAAE,GAAG,EAAE,EACP,OAAO,GAAG,EAAE,EACZ,QAAQ,GAAG,EAAE,EACb,YAAY,GAAG,EAAE,EACjB,YAAY,GAAG,EAAE,EACjB,aAAa,GAAG,EAAE,EAClB,MAAM,GAAG,IAAI,gBAAO,EAAE,GACzB,GAAG,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,CAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;gBACxE,CAAC;YACL,CAAC;QACL,CAAC,CAAC;QAEF,OAAO,IAAI,mBAAU,CAAC;YAClB,GAAG,KAAK;YACR,MAAM;YACN,MAAM;YACN,aAAa;YACb,eAAe;YACf,cAAc;YACd,EAAE;YACF,OAAO;YACP,QAAQ;YACR,YAAY;YACZ,YAAY;YACZ,aAAa,EAAE;gBACX,GAAG,aAAa;gBAChB,UAAU;aACb;SACJ,CAAC,CAAC;IACP,CAAC,EAAE,IAAI,CAAC,CAAC;IAET,IAAA,uBAAe,EAAC,GAAG,EAAE;QACjB,SAAS,eAAe,CAAC,EAAC,UAAU,EAAE,EAAE,EAA+C;YACnF,qBAAY,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAC,CAAC,CAAC;YACvE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAC,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,CAAC,EAAE,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;QAC7C,OAAO,GAAG,EAAE;YACR,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,eAAe,CAAC,CAAC;YAC9C,MAAM,CAAC,OAAO,EAAE,CAAC;QACrB,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IACb,OAAO,MAAM,CAAC;AAClB,CAAC","sourcesContent":["import {useLayoutEffect, useMemo} from 'react';\n\nimport type {Extension} from '../core';\nimport {getPMTransformers} from '../core/markdown/ProseMirrorTransformer/getTransformers';\nimport {ReactRenderStorage} from '../extensions';\nimport {Logger2, globalLogger} from '../logger';\nimport {DirectiveSyntaxContext} from '../utils/directive';\n\nimport {EditorImpl, type EditorInt} from './Editor';\nimport type {\n MarkdownEditorInstance,\n MarkdownEditorMode,\n MarkdownEditorOptions,\n MarkdownEditorPreset,\n} from './types';\nimport {BundlePreset} from './wysiwyg-preset';\n\nexport type UseMarkdownEditorProps = MarkdownEditorOptions;\n\nexport function useMarkdownEditor(\n props: UseMarkdownEditorProps,\n deps: React.DependencyList = [],\n): MarkdownEditorInstance {\n const editor = useMemo<EditorInt>(() => {\n const {\n md = {},\n initial = {},\n handlers = {},\n experimental = {},\n markupConfig = {},\n wysiwygConfig = {},\n logger = new Logger2(),\n } = props;\n\n const preset: MarkdownEditorPreset = props.preset ?? 'full';\n const renderStorage = new ReactRenderStorage();\n\n const pmTransformers = getPMTransformers({\n emptyRowTransformer: experimental.preserveEmptyRows,\n });\n\n const directiveSyntax = new DirectiveSyntaxContext(experimental.directiveSyntax);\n\n const extensions: Extension = (builder) => {\n const extensionOptions = wysiwygConfig.extensionOptions;\n\n builder.use(BundlePreset, {\n ...extensionOptions,\n directiveSyntax,\n preset,\n reactRenderer: renderStorage,\n onCancel: () => {\n editor.emit('cancel', null);\n return true;\n },\n onSubmit: () => {\n editor.emit('submit', null);\n return true;\n },\n disableMdAttrs: wysiwygConfig.disableMarkdownAttrs,\n preserveEmptyRows: experimental.preserveEmptyRows,\n placeholderOptions: wysiwygConfig.placeholderOptions,\n mdBreaks: md.breaks,\n fileUploadHandler: handlers.uploadFile,\n needToSetDimensionsForUploadedImages:\n experimental.needToSetDimensionsForUploadedImages,\n enableNewImageSizeCalculation: experimental.enableNewImageSizeCalculation,\n });\n {\n const extraExtensions = wysiwygConfig.extensions;\n if (extraExtensions) {\n builder.use(extraExtensions, props.wysiwygConfig?.extensionOptions);\n }\n }\n };\n\n return new EditorImpl({\n ...props,\n logger,\n preset,\n renderStorage,\n directiveSyntax,\n pmTransformers,\n md,\n initial,\n handlers,\n experimental,\n markupConfig,\n wysiwygConfig: {\n ...wysiwygConfig,\n extensions,\n },\n });\n }, deps);\n\n useLayoutEffect(() => {\n function onToolbarAction({editorMode, id}: {editorMode: MarkdownEditorMode; id: string}) {\n globalLogger.action({mode: editorMode, source: 'toolbar', action: id});\n editor.logger.action({mode: editorMode, source: 'toolbar', action: id});\n }\n\n editor.on('toolbar-action', onToolbarAction);\n return () => {\n editor.off('toolbar-action', onToolbarAction);\n editor.destroy();\n };\n }, [editor]);\n return editor;\n}\n"]}
|
|
@@ -20,6 +20,7 @@ export type BundlePresetOptions = ExtensionsOptions & EditorModeKeymapOptions &
|
|
|
20
20
|
needToSetDimensionsForUploadedImages?: boolean;
|
|
21
21
|
enableNewImageSizeCalculation?: boolean;
|
|
22
22
|
directiveSyntax: DirectiveSyntaxContext;
|
|
23
|
+
disableMdAttrs?: boolean;
|
|
23
24
|
};
|
|
24
25
|
declare global {
|
|
25
26
|
namespace WysiwygEditor {
|