@gravity-ui/markdown-editor 13.24.0 → 13.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/build/cjs/bundle/MarkdownEditorView.js +18 -14
- package/build/cjs/bundle/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/wysiwyg.js +1 -2
- package/build/cjs/bundle/settings/index.d.ts +1 -0
- package/build/cjs/bundle/settings/index.js +7 -6
- package/build/cjs/extensions/additional/GPT/MarkupGpt/commands.d.ts +4 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/commands.js +18 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/effects.d.ts +2 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/effects.js +6 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/index.d.ts +4 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/index.js +24 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/plugin.d.ts +22 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/plugin.js +121 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/popup.d.ts +11 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/popup.js +14 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/toolbar.d.ts +2 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/toolbar.js +18 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/index.d.ts +1 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/index.js +1 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/plugin.js +6 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/utils.d.ts +2 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/utils.js +12 -1
- package/build/cjs/extensions/additional/index.d.ts +1 -0
- package/build/cjs/extensions/additional/index.js +4 -0
- package/build/cjs/extensions/behavior/SelectionContext/index.js +2 -1
- package/build/cjs/extensions/index.d.ts +1 -0
- package/build/cjs/extensions/index.js +1 -0
- package/build/cjs/extensions/yfm/index.d.ts +1 -1
- package/build/cjs/extensions/yfm/index.js +1 -1
- package/build/cjs/i18n/gpt/dialog/en.json +1 -1
- package/build/cjs/i18n/gpt/dialog/ru.json +1 -1
- package/build/cjs/i18n/menubar/index.d.ts +1 -1
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/MarkdownEditorView.js +18 -14
- package/build/esm/bundle/config/action-names.d.ts +1 -1
- package/build/esm/bundle/config/wysiwyg.js +1 -2
- package/build/esm/bundle/settings/index.d.ts +1 -0
- package/build/esm/bundle/settings/index.js +7 -6
- package/build/esm/extensions/additional/GPT/MarkupGpt/commands.d.ts +4 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/commands.js +12 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/effects.d.ts +2 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/effects.js +3 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/index.d.ts +4 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/index.js +17 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/plugin.d.ts +22 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/plugin.js +117 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/popup.d.ts +11 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/popup.js +9 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/toolbar.d.ts +2 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/toolbar.js +15 -0
- package/build/esm/extensions/{yfm → additional}/GPT/index.d.ts +1 -0
- package/build/esm/extensions/{yfm → additional}/GPT/index.js +1 -0
- package/build/esm/extensions/{yfm → additional}/GPT/plugin.js +6 -0
- package/build/esm/extensions/{yfm → additional}/GPT/utils.d.ts +2 -0
- package/build/esm/extensions/{yfm → additional}/GPT/utils.js +10 -0
- package/build/esm/extensions/additional/index.d.ts +1 -0
- package/build/esm/extensions/additional/index.js +1 -0
- package/build/esm/extensions/behavior/SelectionContext/index.js +3 -2
- package/build/esm/extensions/index.d.ts +1 -0
- package/build/esm/extensions/index.js +1 -0
- package/build/esm/extensions/yfm/index.d.ts +1 -1
- package/build/esm/extensions/yfm/index.js +1 -1
- package/build/esm/i18n/gpt/dialog/en.json +1 -1
- package/build/esm/i18n/gpt/dialog/ru.json +1 -1
- package/build/esm/i18n/menubar/index.d.ts +1 -1
- package/build/esm/version.js +1 -1
- package/build/styles.css +128 -128
- package/package.json +1 -1
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/types.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/ErrorScreen/types.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/index.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/IconRefuge/index.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/PresetList/PresetList.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/PresetList/PresetList.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/PresetList/Presetlist.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/actions.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/actions.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/commands.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/commands.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/constants.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/constants.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGpt.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGpt.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/usePresetList.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/hooks/usePresetList.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/plugin.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/toolbar.d.ts +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/toolbar.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/ErrorScreen.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/types.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/ErrorScreen/types.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/GptDialog.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/GptDialog/LoadingScreen/LoadingScreen.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.classname.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/IconRefuge.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/index.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/IconRefuge/index.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/PresetList/PresetList.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/PresetList/PresetList.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/PresetList/Presetlist.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/actions.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/actions.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/commands.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/commands.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/constants.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/constants.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/gptExtension.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGpt.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGpt.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGptHotKeys.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/useOverflowingHorizontalItems.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/usePresetList.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/hooks/usePresetList.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/plugin.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/toolbar.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/toolbar.js +0 -0
|
@@ -57,7 +57,10 @@ export const MarkdownEditorView = React.forwardRef((props, ref) => {
|
|
|
57
57
|
const editorMode = editor.currentMode;
|
|
58
58
|
const markupSplitMode = editor.splitModeEnabled && editor.splitMode && editorMode === 'markup';
|
|
59
59
|
const canRenderPreview = Boolean(editor.renderPreview && editorMode === 'markup' && !editor.splitModeEnabled);
|
|
60
|
-
useKey((e) => canRenderPreview && isPreviewKeyDown(e), () =>
|
|
60
|
+
useKey((e) => canRenderPreview && isPreviewKeyDown(e), (e) => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
onShowPreviewChange(!showPreview);
|
|
63
|
+
}, { event: 'keydown' }, [showPreview, editorMode, onShowPreviewChange, canRenderPreview]);
|
|
61
64
|
const editorWrapperRef = useRef(null);
|
|
62
65
|
const splitModeViewWrapperRef = useRef(null);
|
|
63
66
|
useEffect(() => {
|
|
@@ -74,18 +77,19 @@ export const MarkdownEditorView = React.forwardRef((props, ref) => {
|
|
|
74
77
|
onShowPreviewChange(false);
|
|
75
78
|
}
|
|
76
79
|
}, { event: 'keydown' }, [hidePreviewAfterSubmit, enableSubmitInPreview, showPreview, showPreview]);
|
|
77
|
-
const settings = useMemo(() => (React.createElement(Settings, { mode: editorMode, onModeChange: onModeChange, toolbarVisibility: editor.toolbarVisible && !showPreview, onToolbarVisibilityChange: onToolbarVisibilityChange, onSplitModeChange: onSplitModeChange, splitModeEnabled: editor.splitModeEnabled, splitMode: editor.splitMode, stickyToolbar: stickyToolbar, onShowPreviewChange: onShowPreviewChange, showPreview: showPreview, renderPreviewButton: canRenderPreview })), [
|
|
78
|
-
canRenderPreview,
|
|
79
|
-
stickyToolbar,
|
|
80
|
-
editor.splitMode,
|
|
81
|
-
editor.splitModeEnabled,
|
|
82
|
-
editor.toolbarVisible,
|
|
80
|
+
const settings = useMemo(() => (React.createElement(Settings, { mode: editorMode, settingsVisible: settingsVisible, onModeChange: onModeChange, toolbarVisibility: editor.toolbarVisible && !showPreview, onToolbarVisibilityChange: onToolbarVisibilityChange, onSplitModeChange: onSplitModeChange, splitModeEnabled: editor.splitModeEnabled, splitMode: editor.splitMode, stickyToolbar: stickyToolbar, onShowPreviewChange: onShowPreviewChange, showPreview: showPreview, renderPreviewButton: canRenderPreview })), [
|
|
83
81
|
editorMode,
|
|
82
|
+
settingsVisible,
|
|
83
|
+
editor.toolbarVisible,
|
|
84
|
+
editor.splitModeEnabled,
|
|
85
|
+
editor.splitMode,
|
|
84
86
|
onModeChange,
|
|
85
|
-
onShowPreviewChange,
|
|
86
|
-
onSplitModeChange,
|
|
87
|
-
onToolbarVisibilityChange,
|
|
88
87
|
showPreview,
|
|
88
|
+
onToolbarVisibilityChange,
|
|
89
|
+
onSplitModeChange,
|
|
90
|
+
stickyToolbar,
|
|
91
|
+
onShowPreviewChange,
|
|
92
|
+
canRenderPreview,
|
|
89
93
|
]);
|
|
90
94
|
return (React.createElement(ErrorBoundary, { onError: (e) => {
|
|
91
95
|
logger.error(e);
|
|
@@ -118,8 +122,8 @@ export const MarkdownEditorView = React.forwardRef((props, ref) => {
|
|
|
118
122
|
})),
|
|
119
123
|
settings)) : (React.createElement(React.Fragment, null,
|
|
120
124
|
editorMode === 'wysiwyg' && (React.createElement(WysiwygEditorView, { editor: editor, autofocus: autofocus, settingsVisible: settingsVisible, toolbarConfig: wysiwygToolbarConfig, toolbarVisible: editor.toolbarVisible, hiddenActionsConfig: wysiwygHiddenActionsConfig, className: b('editor', { mode: editorMode }), toolbarClassName: b('toolbar'), stickyToolbar: stickyToolbar }, editor.toolbarVisible && settingsVisible && settings)),
|
|
121
|
-
editorMode === 'markup' && (React.createElement(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 }, editor.toolbarVisible &&
|
|
122
|
-
!editor.toolbarVisible &&
|
|
125
|
+
editorMode === 'markup' && (React.createElement(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 }, editor.toolbarVisible && settings)),
|
|
126
|
+
!editor.toolbarVisible && settings))),
|
|
123
127
|
markupSplitMode && (React.createElement(React.Fragment, null,
|
|
124
128
|
editor.splitMode === 'horizontal' ? (React.createElement(HorizontalDrag, { editor: editor, isMounted: isMounted, leftElRef: editorWrapperRef, rightElRef: splitModeViewWrapperRef, wrapperRef: divRef })) : (React.createElement("div", { className: b('resizer') })),
|
|
125
129
|
React.createElement(SplitModeView, { editor: editor, ref: splitModeViewWrapperRef })))))));
|
|
@@ -129,13 +133,13 @@ const MarkupSearchAnchor = ({ mode }) => (React.createElement(React.Fragment, nu
|
|
|
129
133
|
function Settings(props) {
|
|
130
134
|
const wrapperRef = useRef(null);
|
|
131
135
|
const isSticky = useSticky(wrapperRef) && props.toolbarVisibility && props.stickyToolbar;
|
|
132
|
-
return (React.createElement("div", { className: b('settings-wrapper') },
|
|
136
|
+
return (React.createElement(React.Fragment, null, (props.renderPreviewButton || props.settingsVisible) && (React.createElement("div", { className: b('settings-wrapper') },
|
|
133
137
|
React.createElement("div", { ref: wrapperRef, className: stickyCn.settings({
|
|
134
138
|
withToolbar: props.toolbarVisibility,
|
|
135
139
|
stickyActive: isSticky,
|
|
136
140
|
}) },
|
|
137
141
|
React.createElement(EditorSettings, Object.assign({}, props)),
|
|
138
|
-
React.createElement(MarkupSearchAnchor, Object.assign({}, props)))));
|
|
142
|
+
React.createElement(MarkupSearchAnchor, Object.assign({}, props)))))));
|
|
139
143
|
}
|
|
140
144
|
function isPreviewKeyDown(e) {
|
|
141
145
|
const modKey = isMac() ? e.metaKey : e.ctrlKey;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "mono" | "paragraph" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "file" | "checkbox" | "bulletList" | "orderedList" | "emoji" | "tabs" | "yfm_cut" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "yfm_note" | "gpt" | "undo" | "redo" | "
|
|
1
|
+
declare const namesObj: Record<"bold" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "mono" | "paragraph" | "anchor" | "table" | "image" | "code_inline" | "code_block" | "file" | "checkbox" | "bulletList" | "orderedList" | "emoji" | "tabs" | "yfm_cut" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "yfm_note" | "gpt" | "undo" | "redo" | "liftListItem" | "sinkListItem" | "yfm_block" | "yfm_html_block" | "yfm_layout" | "horizontalrule" | "math_inline" | "math_block" | "mermaid", string>;
|
|
2
2
|
export declare const ActionName: Readonly<typeof namesObj>;
|
|
3
3
|
export {};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { headingType, pType } from '../../extensions';
|
|
2
|
-
|
|
3
|
-
import { gptHotKeys } from '../../extensions/yfm/GPT/constants';
|
|
2
|
+
import { gptHotKeys } from '../../extensions/additional/GPT/constants';
|
|
4
3
|
import { i18n as i18nHint } from '../../i18n/hints';
|
|
5
4
|
import { i18n } from '../../i18n/menubar';
|
|
6
5
|
import { Action as A, formatter as f } from '../../shortcuts';
|
|
@@ -4,6 +4,7 @@ import type { EditorMode, SplitMode } from '../Editor';
|
|
|
4
4
|
import './index.css';
|
|
5
5
|
export declare type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {
|
|
6
6
|
renderPreviewButton?: boolean;
|
|
7
|
+
settingsVisible?: boolean;
|
|
7
8
|
};
|
|
8
9
|
export declare const EditorSettings: React.NamedExoticComponent<EditorSettingsProps>;
|
|
9
10
|
declare type SettingsContentProps = ClassNameProps & {
|
|
@@ -17,7 +17,7 @@ const placement = ['bottom-end', 'top-end'];
|
|
|
17
17
|
const bSettings = cn('editor-settings');
|
|
18
18
|
const bContent = cn('settings-content');
|
|
19
19
|
export const EditorSettings = React.memo(function EditorSettings(props) {
|
|
20
|
-
const { className, onShowPreviewChange, showPreview, renderPreviewButton } = props;
|
|
20
|
+
const { className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible } = props;
|
|
21
21
|
const chevronRef = React.useRef(null);
|
|
22
22
|
const [popupShown, , hidePopup, togglePopup] = useBooleanState(false);
|
|
23
23
|
return (React.createElement("div", { className: bSettings(null, [className]) },
|
|
@@ -25,11 +25,12 @@ export const EditorSettings = React.memo(function EditorSettings(props) {
|
|
|
25
25
|
React.createElement(ActionTooltip, { openDelay: ToolbarTooltipDelay.Open, closeDelay: ToolbarTooltipDelay.Close, title: i18n('preview_hint'), hotkey: "mod+shift+p" },
|
|
26
26
|
React.createElement(Button, { size: "m", view: "flat", pin: "round-round", className: bSettings('preview-button'), onClick: () => onShowPreviewChange === null || onShowPreviewChange === void 0 ? void 0 : onShowPreviewChange(!showPreview), selected: showPreview },
|
|
27
27
|
React.createElement(Icon, { data: Eye }))),
|
|
28
|
-
React.createElement("div", { className: bSettings('separator') }))),
|
|
29
|
-
React.createElement(
|
|
30
|
-
React.createElement(
|
|
31
|
-
|
|
32
|
-
React.createElement(
|
|
28
|
+
settingsVisible && React.createElement("div", { className: bSettings('separator') }))),
|
|
29
|
+
settingsVisible && (React.createElement(React.Fragment, null,
|
|
30
|
+
React.createElement(Button, { size: "m", view: "flat", ref: chevronRef, pin: "round-round", onClick: togglePopup, className: bSettings('dropdown-button') },
|
|
31
|
+
React.createElement(Icon, { data: Gear })),
|
|
32
|
+
React.createElement(Popup, { open: popupShown, anchorRef: chevronRef, placement: placement, onClose: hidePopup },
|
|
33
|
+
React.createElement(SettingsContent, Object.assign({}, props, { onClose: hidePopup, className: bSettings('content') })))))));
|
|
33
34
|
});
|
|
34
35
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
35
36
|
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { HideMarkupGptEffect, ShowMarkupGptEffect } from './effects';
|
|
2
|
+
export const showMarkupGpt = (view) => {
|
|
3
|
+
view.dispatch({ effects: [ShowMarkupGptEffect.of(null)] });
|
|
4
|
+
};
|
|
5
|
+
export const hideMarkupGpt = (view) => {
|
|
6
|
+
view.dispatch({ effects: [HideMarkupGptEffect.of(null)] });
|
|
7
|
+
};
|
|
8
|
+
export const runMarkupGpt = (view) => {
|
|
9
|
+
if (view)
|
|
10
|
+
showMarkupGpt(view);
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { keymap } from '@codemirror/view';
|
|
2
|
+
import { gptHotKeys } from '../constants';
|
|
3
|
+
import { runMarkupGpt } from './commands';
|
|
4
|
+
import { mGptPlugin } from './plugin';
|
|
5
|
+
export { mGptToolbarItem } from './toolbar';
|
|
6
|
+
export { showMarkupGpt, hideMarkupGpt } from './commands';
|
|
7
|
+
export function mGptExtension(props) {
|
|
8
|
+
return [
|
|
9
|
+
mGptPlugin(props).extension,
|
|
10
|
+
keymap.of([
|
|
11
|
+
{
|
|
12
|
+
key: gptHotKeys.openGptKey,
|
|
13
|
+
run: runMarkupGpt,
|
|
14
|
+
},
|
|
15
|
+
]),
|
|
16
|
+
];
|
|
17
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GptWidgetOptions } from '../../..';
|
|
2
|
+
import { type DecorationSet, type EditorView, ViewPlugin, type ViewUpdate } from '../../../../cm/view';
|
|
3
|
+
export declare function mGptPlugin(gptProps: GptWidgetOptions): ViewPlugin<{
|
|
4
|
+
readonly _view: EditorView;
|
|
5
|
+
readonly _renderItem: import("../../..").RendererItem;
|
|
6
|
+
_anchor: Element | null;
|
|
7
|
+
decos: DecorationSet;
|
|
8
|
+
disablePromptPresets: boolean;
|
|
9
|
+
markup: string | null;
|
|
10
|
+
selectedPosition: {
|
|
11
|
+
from: number;
|
|
12
|
+
to: number;
|
|
13
|
+
};
|
|
14
|
+
update(update: ViewUpdate): void;
|
|
15
|
+
docViewUpdate(): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
renderPopup(): JSX.Element | null;
|
|
18
|
+
_getDecorationText(update: ViewUpdate, from: number, to: number): string;
|
|
19
|
+
_clearSelectedText(): void;
|
|
20
|
+
_setSelectedText(str: string): void;
|
|
21
|
+
_onApplyResult(changedMarkup: string): void;
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { WidgetType } from '@codemirror/view';
|
|
2
|
+
import { Decoration, ViewPlugin, } from '../../../../cm/view';
|
|
3
|
+
import { ReactRendererFacet } from '../../../../markup';
|
|
4
|
+
import { WIDGET_DECO_CLASS_NAME } from '../constants';
|
|
5
|
+
import { isEmptyGptPrompts } from '../utils';
|
|
6
|
+
import { hideMarkupGpt } from './commands';
|
|
7
|
+
import { HideMarkupGptEffect, ShowMarkupGptEffect } from './effects';
|
|
8
|
+
import { renderPopup } from './popup';
|
|
9
|
+
class SpanWidget extends WidgetType {
|
|
10
|
+
constructor(className, textContent) {
|
|
11
|
+
super();
|
|
12
|
+
this.className = '';
|
|
13
|
+
this.textContent = '';
|
|
14
|
+
this.className = className;
|
|
15
|
+
this.textContent = textContent;
|
|
16
|
+
}
|
|
17
|
+
toDOM() {
|
|
18
|
+
const spanElem = document.createElement('span');
|
|
19
|
+
spanElem.className = this.className;
|
|
20
|
+
spanElem.textContent = this.textContent;
|
|
21
|
+
return spanElem;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function mGptPlugin(gptProps) {
|
|
25
|
+
return ViewPlugin.fromClass(class {
|
|
26
|
+
constructor(view) {
|
|
27
|
+
this._anchor = null;
|
|
28
|
+
this.decos = Decoration.none;
|
|
29
|
+
this.disablePromptPresets = true;
|
|
30
|
+
this.markup = null;
|
|
31
|
+
this.selectedPosition = {
|
|
32
|
+
from: 0,
|
|
33
|
+
to: 0,
|
|
34
|
+
};
|
|
35
|
+
this._view = view;
|
|
36
|
+
this._renderItem = view.state
|
|
37
|
+
.facet(ReactRendererFacet)
|
|
38
|
+
.createItem('gpt-in-markup-mode', () => this.renderPopup());
|
|
39
|
+
}
|
|
40
|
+
update(update) {
|
|
41
|
+
if (update.docChanged || update.selectionSet) {
|
|
42
|
+
this.decos = Decoration.none;
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.decos = this.decos.map(update.changes);
|
|
46
|
+
const { from, to } = update.state.selection.main;
|
|
47
|
+
this.selectedPosition.from = from;
|
|
48
|
+
this.selectedPosition.to = to;
|
|
49
|
+
for (const tr of update.transactions) {
|
|
50
|
+
for (const eff of tr.effects) {
|
|
51
|
+
if (eff.is(ShowMarkupGptEffect)) {
|
|
52
|
+
this._setSelectedText(this._getDecorationText(update, from, to));
|
|
53
|
+
if (from === to) {
|
|
54
|
+
this.disablePromptPresets = true;
|
|
55
|
+
if (isEmptyGptPrompts(gptProps, true))
|
|
56
|
+
return;
|
|
57
|
+
const decorationWidget = Decoration.widget({
|
|
58
|
+
widget: new SpanWidget(WIDGET_DECO_CLASS_NAME, ' '),
|
|
59
|
+
});
|
|
60
|
+
this.decos = Decoration.set([decorationWidget.range(from)]);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.disablePromptPresets = false;
|
|
64
|
+
if (isEmptyGptPrompts(gptProps, false))
|
|
65
|
+
return;
|
|
66
|
+
this.decos = Decoration.set([
|
|
67
|
+
{
|
|
68
|
+
from,
|
|
69
|
+
to,
|
|
70
|
+
value: Decoration.mark({ class: WIDGET_DECO_CLASS_NAME }),
|
|
71
|
+
},
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
if (eff.is(HideMarkupGptEffect)) {
|
|
75
|
+
this.decos = Decoration.none;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
docViewUpdate() {
|
|
81
|
+
this._anchor = this._view.dom
|
|
82
|
+
.getElementsByClassName(WIDGET_DECO_CLASS_NAME)
|
|
83
|
+
.item(0);
|
|
84
|
+
this._renderItem.rerender();
|
|
85
|
+
}
|
|
86
|
+
destroy() {
|
|
87
|
+
this._clearSelectedText();
|
|
88
|
+
this._renderItem.remove();
|
|
89
|
+
}
|
|
90
|
+
renderPopup() {
|
|
91
|
+
if (!this._anchor || this.markup === null) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
return renderPopup(this._anchor, Object.assign(Object.assign({}, gptProps), { disablePromptPresets: this.disablePromptPresets, onClose: () => hideMarkupGpt(this._view), markup: this.markup, onApplyResult: (changedMarkup) => this._onApplyResult(changedMarkup) }));
|
|
95
|
+
}
|
|
96
|
+
_getDecorationText(update, from, to) {
|
|
97
|
+
return update.state.doc.sliceString(from, to);
|
|
98
|
+
}
|
|
99
|
+
_clearSelectedText() {
|
|
100
|
+
this.markup = null;
|
|
101
|
+
}
|
|
102
|
+
_setSelectedText(str) {
|
|
103
|
+
this.markup = str;
|
|
104
|
+
}
|
|
105
|
+
_onApplyResult(changedMarkup) {
|
|
106
|
+
const { from, to } = this.selectedPosition;
|
|
107
|
+
const changes = [{ from: from, to: to, insert: changedMarkup }];
|
|
108
|
+
const transaction = this._view.state.update({
|
|
109
|
+
changes: changes,
|
|
110
|
+
effects: [HideMarkupGptEffect.of(null)],
|
|
111
|
+
});
|
|
112
|
+
this._view.dispatch(transaction);
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
decorations: (value) => value.decos,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PopupProps } from '@gravity-ui/uikit';
|
|
3
|
+
import { GptDialogProps } from '../GptDialog/GptDialog';
|
|
4
|
+
declare type Props = {
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
markup: string;
|
|
7
|
+
onConfirmOk?: () => void;
|
|
8
|
+
onConfirmCancel?: () => void;
|
|
9
|
+
} & GptDialogProps & Pick<PopupProps, 'anchorRef' | 'container'>;
|
|
10
|
+
export declare function renderPopup(anchor: HTMLElement, props: Props): JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Popup } from '@gravity-ui/uikit';
|
|
3
|
+
import { GptDialog } from '../GptDialog/GptDialog';
|
|
4
|
+
import { cnGptPopup } from '../gptExtension/view';
|
|
5
|
+
export function renderPopup(anchor, props) {
|
|
6
|
+
const handleUpdate = (result) => { var _a; return (_a = props.onUpdate) === null || _a === void 0 ? void 0 : _a.call(props, result); };
|
|
7
|
+
return (React.createElement(Popup, { className: cnGptPopup(), contentClassName: cnGptPopup('content'), open: true, anchorRef: { current: anchor }, onOutsideClick: props.onClose, focusTrap: true, strategy: "absolute", onEscapeKeyDown: props.onClose },
|
|
8
|
+
React.createElement(GptDialog, { markup: props.markup, answerRender: props.answerRender, promptPresets: props.promptPresets, disablePromptPresets: props.disablePromptPresets, customPromptPlaceholder: props.customPromptPlaceholder, disabledPromptPlaceholder: props.disabledPromptPlaceholder, onApplyResult: props.onApplyResult, onCustomPromptApply: props.onCustomPromptApply, onPromptPresetClick: props.onPromptPresetClick, onTryAgain: props.onTryAgain, onLike: props.onLike, onDislike: props.onDislike, onClose: props.onClose, onUpdate: handleUpdate, gptAlertProps: props.gptAlertProps })));
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { i18n } from '../../../../i18n/gpt/extension';
|
|
2
|
+
import { GPTIcon } from '../../../../icons';
|
|
3
|
+
import { ToolbarDataType } from '../../../../toolbar';
|
|
4
|
+
import { gptHotKeys } from '../constants';
|
|
5
|
+
import { showMarkupGpt } from './commands';
|
|
6
|
+
export const mGptToolbarItem = {
|
|
7
|
+
id: 'gpt',
|
|
8
|
+
type: ToolbarDataType.SingleButton,
|
|
9
|
+
hotkey: gptHotKeys.openGptKeyTooltip,
|
|
10
|
+
title: () => `${i18n('help-with-text')}`,
|
|
11
|
+
icon: { data: GPTIcon },
|
|
12
|
+
exec: (e) => showMarkupGpt(e.cm),
|
|
13
|
+
isActive: () => false,
|
|
14
|
+
isEnable: () => true,
|
|
15
|
+
};
|
|
@@ -2,6 +2,7 @@ import { Plugin, PluginKey } from 'prosemirror-state';
|
|
|
2
2
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
3
3
|
import { WIDGET_DECO_CLASS_NAME, WIDGET_DECO_SPEC_FLAG } from './constants';
|
|
4
4
|
import { GptWidgetDecoView } from './gptExtension/view';
|
|
5
|
+
import { isEmptyGptPrompts } from './utils';
|
|
5
6
|
const key = new PluginKey('gpt-widget');
|
|
6
7
|
export { key as pluginKey };
|
|
7
8
|
export const gptWidgetPlugin = (params) => {
|
|
@@ -12,18 +13,23 @@ export const gptWidgetPlugin = (params) => {
|
|
|
12
13
|
apply: (tr, decos) => {
|
|
13
14
|
const meta = tr.getMeta(key);
|
|
14
15
|
const paramsGpt = params;
|
|
16
|
+
paramsGpt.disablePromptPresets = false;
|
|
15
17
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'show') {
|
|
16
18
|
if (meta.to === meta.from) {
|
|
17
19
|
const spanElem = document.createElement('span');
|
|
18
20
|
spanElem.className = WIDGET_DECO_CLASS_NAME;
|
|
19
21
|
spanElem.textContent = ' ';
|
|
20
22
|
paramsGpt.disablePromptPresets = true;
|
|
23
|
+
if (isEmptyGptPrompts(paramsGpt, true))
|
|
24
|
+
return DecorationSet.empty;
|
|
21
25
|
return DecorationSet.create(tr.doc, [
|
|
22
26
|
Decoration.widget(meta.from, spanElem, {
|
|
23
27
|
[WIDGET_DECO_SPEC_FLAG]: true,
|
|
24
28
|
}),
|
|
25
29
|
]);
|
|
26
30
|
}
|
|
31
|
+
if (isEmptyGptPrompts(paramsGpt, false))
|
|
32
|
+
return DecorationSet.empty;
|
|
27
33
|
return DecorationSet.create(tr.doc, [
|
|
28
34
|
Decoration.inline(meta.from, meta.to, { nodeName: 'span', class: WIDGET_DECO_CLASS_NAME }, { [WIDGET_DECO_SPEC_FLAG]: true }),
|
|
29
35
|
]);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { GptDialogProps } from './GptDialog/GptDialog';
|
|
3
|
+
import { GptWidgetOptions } from './gptExtension/gptExtension';
|
|
3
4
|
declare type CombinedKeyboardEvent = KeyboardEvent | React.KeyboardEvent;
|
|
4
5
|
export declare function getAlertGptInfo(gptAlert: GptDialogProps['gptAlertProps']): {
|
|
5
6
|
alertMessage: string;
|
|
@@ -10,4 +11,5 @@ export declare function getDisableReplaceButtonText(disablePromptPresets?: boole
|
|
|
10
11
|
export declare function getInputPlaceHolder(disablePromptPresets?: boolean, disabledPromptPlaceholder?: string, customPromptPlaceholder?: string): string | undefined;
|
|
11
12
|
export declare const isEnter: (event: CombinedKeyboardEvent) => boolean;
|
|
12
13
|
export declare function focusWithoutScroll(element?: HTMLElement | null): void;
|
|
14
|
+
export declare function isEmptyGptPrompts(gptWidgetOptions: GptWidgetOptions, disablePromptPresets: boolean): boolean;
|
|
13
15
|
export {};
|
|
@@ -21,3 +21,13 @@ export function focusWithoutScroll(element) {
|
|
|
21
21
|
});
|
|
22
22
|
window.scrollTo(x, y);
|
|
23
23
|
}
|
|
24
|
+
export function isEmptyGptPrompts(gptWidgetOptions, disablePromptPresets) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (disablePromptPresets && !gptWidgetOptions.onCustomPromptApply)
|
|
27
|
+
return true;
|
|
28
|
+
if (!disablePromptPresets &&
|
|
29
|
+
!((_a = gptWidgetOptions.promptPresets) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
30
|
+
!gptWidgetOptions.onCustomPromptApply)
|
|
31
|
+
return true;
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GPT';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GPT';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { keydownHandler } from 'prosemirror-keymap';
|
|
2
|
-
import { Plugin, TextSelection } from 'prosemirror-state';
|
|
2
|
+
import { AllSelection, Plugin, TextSelection, } from 'prosemirror-state';
|
|
3
3
|
import { isCodeBlock } from '../../../utils/nodes';
|
|
4
4
|
import { TooltipView } from './tooltip';
|
|
5
5
|
export const SelectionContext = (builder, { config }) => {
|
|
@@ -74,7 +74,8 @@ class SelectionTooltip {
|
|
|
74
74
|
return;
|
|
75
75
|
const { selection } = state;
|
|
76
76
|
// Hide the tooltip if the selection is empty
|
|
77
|
-
if (selection.empty ||
|
|
77
|
+
if (selection.empty ||
|
|
78
|
+
!(selection instanceof TextSelection || selection instanceof AllSelection)) {
|
|
78
79
|
this.tooltip.hide(view);
|
|
79
80
|
return;
|
|
80
81
|
}
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"replace": "Заменить выделенный текст",
|
|
13
13
|
"replace-disabled": "Вставить текст",
|
|
14
14
|
"try-again": "Иначе",
|
|
15
|
-
"alert-gpt-presets-info": "Выделите текст, чтобы увидеть пресеты
|
|
15
|
+
"alert-gpt-presets-info": "Выделите текст, чтобы увидеть пресеты GPT"
|
|
16
16
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const i18n: <G extends "bold" | "code" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "colorify" | "mono" | "text" | "html" | "cut" | "table" | "image" | "code_inline" | "list" | "heading" | "note" | "file" | "codeblock" | "checkbox" | "emoji" | "tabs" | "math" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "gpt" | "undo" | "redo" | "math_inline" | "math_block" | "colorify__color_blue" | "colorify__color_default" | "colorify__color_gray" | "colorify__color_green" | "colorify__color_orange" | "colorify__color_red" | "colorify__color_violet" | "colorify__color_yellow" | "colorify__group_text" | "folding-heading" | "folding-heading_hint" | "hrule" | "list__action_lift" | "list__action_sink" | "list_action_disabled" | "
|
|
1
|
+
export declare const i18n: <G extends "bold" | "code" | "link" | "italic" | "strike" | "underline" | "mark" | "quote" | "colorify" | "mono" | "text" | "html" | "cut" | "table" | "image" | "code_inline" | "list" | "heading" | "note" | "file" | "codeblock" | "checkbox" | "emoji" | "tabs" | "math" | "heading1" | "heading2" | "heading3" | "heading4" | "heading5" | "heading6" | "gpt" | "undo" | "redo" | "math_inline" | "math_block" | "mermaid" | "colorify__color_blue" | "colorify__color_default" | "colorify__color_gray" | "colorify__color_green" | "colorify__color_orange" | "colorify__color_red" | "colorify__color_violet" | "colorify__color_yellow" | "colorify__group_text" | "folding-heading" | "folding-heading_hint" | "hrule" | "list__action_lift" | "list__action_sink" | "list_action_disabled" | "more_action" | "olist" | "ulist", S extends string>(key: G | (string extends S ? S : never), params?: {
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
} | undefined) => S extends G ? {
|
|
4
4
|
bold: string;
|
package/build/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** During build process, the current version will be injected here */
|
|
2
|
-
export const VERSION = typeof '13.
|
|
2
|
+
export const VERSION = typeof '13.25.0' !== 'undefined' ? '13.25.0' : 'unknown';
|