@gravity-ui/markdown-editor 13.24.0 → 13.25.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/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/{yfm → additional}/GPT/GptDialog/GptDialog.d.ts +2 -2
- 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 +5 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/index.js +24 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/plugin.d.ts +23 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/plugin.js +121 -0
- package/build/cjs/extensions/additional/GPT/MarkupGpt/popup.d.ts +12 -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/additional/GPT/PresetList/PresetList.d.ts +9 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/PresetList/PresetList.js +1 -1
- package/build/{esm/extensions/yfm → cjs/extensions/additional}/GPT/gptExtension/gptExtension.d.ts +2 -2
- package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.d.ts +2 -2
- package/build/cjs/extensions/{yfm → additional}/GPT/hooks/useGpt.d.ts +1 -1
- package/build/cjs/extensions/additional/GPT/hooks/usePresetList.d.ts +15 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/hooks/usePresetList.js +1 -1
- 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/{esm/extensions/yfm → cjs/extensions/additional}/GPT/plugin.d.ts +2 -1
- package/build/cjs/extensions/{yfm → additional}/GPT/plugin.js +6 -0
- package/build/cjs/extensions/{yfm → additional}/GPT/utils.d.ts +3 -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/YfmCut/YfmCutSpecs/schema.js +3 -3
- package/build/cjs/extensions/yfm/YfmCut/actions/toYfmCut.js +1 -1
- package/build/cjs/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.css +10 -0
- package/build/cjs/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js +1 -1
- package/build/cjs/extensions/yfm/YfmCut/plugins/auto-open.js +1 -3
- 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/{yfm → additional}/GPT/GptDialog/GptDialog.d.ts +2 -2
- 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 +5 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/index.js +17 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/plugin.d.ts +23 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/plugin.js +117 -0
- package/build/esm/extensions/additional/GPT/MarkupGpt/popup.d.ts +12 -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/additional/GPT/PresetList/PresetList.d.ts +10 -0
- package/build/esm/extensions/{yfm → additional}/GPT/PresetList/PresetList.js +1 -1
- package/build/{cjs/extensions/yfm → esm/extensions/additional}/GPT/gptExtension/gptExtension.d.ts +2 -2
- package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.d.ts +2 -2
- package/build/esm/extensions/{yfm → additional}/GPT/hooks/useGpt.d.ts +1 -1
- package/build/esm/extensions/additional/GPT/hooks/usePresetList.d.ts +15 -0
- package/build/esm/extensions/{yfm → additional}/GPT/hooks/usePresetList.js +1 -1
- 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/{cjs/extensions/yfm → esm/extensions/additional}/GPT/plugin.d.ts +2 -1
- package/build/esm/extensions/{yfm → additional}/GPT/plugin.js +6 -0
- package/build/esm/extensions/{yfm → additional}/GPT/utils.d.ts +3 -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/YfmCut/YfmCutSpecs/schema.js +3 -3
- package/build/esm/extensions/yfm/YfmCut/actions/toYfmCut.js +1 -1
- package/build/esm/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.css +10 -0
- package/build/esm/extensions/yfm/YfmCut/nodeviews/yfm-cut-title.js +1 -1
- package/build/esm/extensions/yfm/YfmCut/plugins/auto-open.js +1 -3
- 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 +138 -128
- package/package.json +1 -1
- package/build/cjs/extensions/yfm/GPT/PresetList/PresetList.d.ts +0 -9
- package/build/cjs/extensions/yfm/GPT/hooks/usePresetList.d.ts +0 -14
- package/build/esm/extensions/yfm/GPT/PresetList/PresetList.d.ts +0 -10
- package/build/esm/extensions/yfm/GPT/hooks/usePresetList.d.ts +0 -14
- /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.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.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.js +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.css +0 -0
- /package/build/cjs/extensions/{yfm → additional}/GPT/gptExtension/view.js +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/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.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.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.js +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.css +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/gptExtension/view.js +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/toolbar.d.ts +0 -0
- /package/build/esm/extensions/{yfm → additional}/GPT/toolbar.js +0 -0
package/README.md
CHANGED
|
@@ -59,6 +59,8 @@ Read more:
|
|
|
59
59
|
- [How to add Mermaid extension](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-connect-mermaid-extension.md)
|
|
60
60
|
- [How to write extension](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-create-extension.md)
|
|
61
61
|
- [How to add GPT extension](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-connect-gpt-extensions.md)
|
|
62
|
+
- [How to add text binding extension in markdown](https://github.com/gravity-ui/markdown-editor/blob/main/docs/how-to-add-text-binding-extension-in-markdown.md)
|
|
63
|
+
|
|
62
64
|
|
|
63
65
|
|
|
64
66
|
### i18n
|
|
@@ -60,7 +60,10 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
60
60
|
const editorMode = editor.currentMode;
|
|
61
61
|
const markupSplitMode = editor.splitModeEnabled && editor.splitMode && editorMode === 'markup';
|
|
62
62
|
const canRenderPreview = Boolean(editor.renderPreview && editorMode === 'markup' && !editor.splitModeEnabled);
|
|
63
|
-
(0, react_use_1.useKey)((e) => canRenderPreview && isPreviewKeyDown(e), () =>
|
|
63
|
+
(0, react_use_1.useKey)((e) => canRenderPreview && isPreviewKeyDown(e), (e) => {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
onShowPreviewChange(!showPreview);
|
|
66
|
+
}, { event: 'keydown' }, [showPreview, editorMode, onShowPreviewChange, canRenderPreview]);
|
|
64
67
|
const editorWrapperRef = (0, react_1.useRef)(null);
|
|
65
68
|
const splitModeViewWrapperRef = (0, react_1.useRef)(null);
|
|
66
69
|
(0, react_1.useEffect)(() => {
|
|
@@ -77,18 +80,19 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
77
80
|
onShowPreviewChange(false);
|
|
78
81
|
}
|
|
79
82
|
}, { event: 'keydown' }, [hidePreviewAfterSubmit, enableSubmitInPreview, showPreview, showPreview]);
|
|
80
|
-
const settings = (0, react_1.useMemo)(() => (react_1.default.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 })), [
|
|
81
|
-
canRenderPreview,
|
|
82
|
-
stickyToolbar,
|
|
83
|
-
editor.splitMode,
|
|
84
|
-
editor.splitModeEnabled,
|
|
85
|
-
editor.toolbarVisible,
|
|
83
|
+
const settings = (0, react_1.useMemo)(() => (react_1.default.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 })), [
|
|
86
84
|
editorMode,
|
|
85
|
+
settingsVisible,
|
|
86
|
+
editor.toolbarVisible,
|
|
87
|
+
editor.splitModeEnabled,
|
|
88
|
+
editor.splitMode,
|
|
87
89
|
onModeChange,
|
|
88
|
-
onShowPreviewChange,
|
|
89
|
-
onSplitModeChange,
|
|
90
|
-
onToolbarVisibilityChange,
|
|
91
90
|
showPreview,
|
|
91
|
+
onToolbarVisibilityChange,
|
|
92
|
+
onSplitModeChange,
|
|
93
|
+
stickyToolbar,
|
|
94
|
+
onShowPreviewChange,
|
|
95
|
+
canRenderPreview,
|
|
92
96
|
]);
|
|
93
97
|
return (react_1.default.createElement(react_error_boundary_1.ErrorBoundary, { onError: (e) => {
|
|
94
98
|
logger_1.logger.error(e);
|
|
@@ -121,8 +125,8 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
|
|
|
121
125
|
})),
|
|
122
126
|
settings)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
123
127
|
editorMode === 'wysiwyg' && (react_1.default.createElement(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 }, editor.toolbarVisible && settingsVisible && settings)),
|
|
124
|
-
editorMode === 'markup' && (react_1.default.createElement(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 }, editor.toolbarVisible &&
|
|
125
|
-
!editor.toolbarVisible &&
|
|
128
|
+
editorMode === 'markup' && (react_1.default.createElement(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 }, editor.toolbarVisible && settings)),
|
|
129
|
+
!editor.toolbarVisible && settings))),
|
|
126
130
|
markupSplitMode && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
127
131
|
editor.splitMode === 'horizontal' ? (react_1.default.createElement(HorizontalDrag_1.HorizontalDrag, { editor: editor, isMounted: isMounted, leftElRef: editorWrapperRef, rightElRef: splitModeViewWrapperRef, wrapperRef: divRef })) : (react_1.default.createElement("div", { className: b('resizer') })),
|
|
128
132
|
react_1.default.createElement(SplitModeView_1.SplitModeView, { editor: editor, ref: splitModeViewWrapperRef })))))));
|
|
@@ -132,13 +136,13 @@ const MarkupSearchAnchor = ({ mode }) => (react_1.default.createElement(react_1.
|
|
|
132
136
|
function Settings(props) {
|
|
133
137
|
const wrapperRef = (0, react_1.useRef)(null);
|
|
134
138
|
const isSticky = (0, react_utils_1.useSticky)(wrapperRef) && props.toolbarVisibility && props.stickyToolbar;
|
|
135
|
-
return (react_1.default.createElement("div", { className: b('settings-wrapper') },
|
|
139
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, (props.renderPreviewButton || props.settingsVisible) && (react_1.default.createElement("div", { className: b('settings-wrapper') },
|
|
136
140
|
react_1.default.createElement("div", { ref: wrapperRef, className: sticky_1.stickyCn.settings({
|
|
137
141
|
withToolbar: props.toolbarVisibility,
|
|
138
142
|
stickyActive: isSticky,
|
|
139
143
|
}) },
|
|
140
144
|
react_1.default.createElement(settings_1.EditorSettings, Object.assign({}, props)),
|
|
141
|
-
react_1.default.createElement(MarkupSearchAnchor, Object.assign({}, props)))));
|
|
145
|
+
react_1.default.createElement(MarkupSearchAnchor, Object.assign({}, props)))))));
|
|
142
146
|
}
|
|
143
147
|
function isPreviewKeyDown(e) {
|
|
144
148
|
const modKey = (0, utils_1.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 {};
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.wSelectionMenuConfigByPreset = exports.wHiddenDataByPreset = exports.wCommandMenuConfigByPreset = exports.wToolbarConfigByPreset = exports.wMermaidItemData = exports.wSelectionMenuConfig = exports.wToggleHeadingFoldingItemData = exports.wToolbarConfig = exports.wHiddenData = exports.wCommandMenuConfig = exports.wGptItemData = exports.wYfmHtmlBlockItemData = exports.wMathListItem = exports.wMathListConfig = exports.wMathBlockItemData = exports.wTabsItemData = exports.wMathInlineItemData = exports.wFileItemData = exports.wEmojiItemData = exports.wHruleItemData = exports.wImageItemData = exports.wCodeListConfig = exports.wCodeBlockItemData = exports.wCodeItemData = exports.wTableItemData = exports.wNoteItemData = exports.wListMoveListConfig = exports.wCutItemData = exports.wQuoteItemData = exports.wLinkItemData = exports.wCheckboxItemData = exports.wListsListConfig = exports.wHeadingListConfig = exports.wTextItemData = exports.wBiusGroupConfig = exports.wMarkedItemData = exports.wMonospaceItemData = exports.wStrikethroughItemData = exports.wUnderlineItemData = exports.wItalicItemData = exports.wBoldItemData = exports.wHistoryGroupConfig = void 0;
|
|
4
4
|
const extensions_1 = require("../../extensions");
|
|
5
|
-
|
|
6
|
-
const constants_1 = require("../../extensions/yfm/GPT/constants");
|
|
5
|
+
const constants_1 = require("../../extensions/additional/GPT/constants");
|
|
7
6
|
const hints_1 = require("../../i18n/hints");
|
|
8
7
|
const menubar_1 = require("../../i18n/menubar");
|
|
9
8
|
const shortcuts_1 = require("../../shortcuts");
|
|
@@ -3,6 +3,7 @@ import { ClassNameProps } from '../../classname';
|
|
|
3
3
|
import type { EditorMode, SplitMode } from '../Editor';
|
|
4
4
|
export declare type EditorSettingsProps = Omit<SettingsContentProps, 'onClose'> & {
|
|
5
5
|
renderPreviewButton?: boolean;
|
|
6
|
+
settingsVisible?: boolean;
|
|
6
7
|
};
|
|
7
8
|
export declare const EditorSettings: React.NamedExoticComponent<EditorSettingsProps>;
|
|
8
9
|
declare type SettingsContentProps = ClassNameProps & {
|
|
@@ -20,7 +20,7 @@ const placement = ['bottom-end', 'top-end'];
|
|
|
20
20
|
const bSettings = (0, classname_1.cn)('editor-settings');
|
|
21
21
|
const bContent = (0, classname_1.cn)('settings-content');
|
|
22
22
|
exports.EditorSettings = react_1.default.memo(function EditorSettings(props) {
|
|
23
|
-
const { className, onShowPreviewChange, showPreview, renderPreviewButton } = props;
|
|
23
|
+
const { className, onShowPreviewChange, showPreview, renderPreviewButton, settingsVisible } = props;
|
|
24
24
|
const chevronRef = react_1.default.useRef(null);
|
|
25
25
|
const [popupShown, , hidePopup, togglePopup] = (0, hooks_1.useBooleanState)(false);
|
|
26
26
|
return (react_1.default.createElement("div", { className: bSettings(null, [className]) },
|
|
@@ -28,11 +28,12 @@ exports.EditorSettings = react_1.default.memo(function EditorSettings(props) {
|
|
|
28
28
|
react_1.default.createElement(uikit_1.ActionTooltip, { openDelay: toolbar_1.ToolbarTooltipDelay.Open, closeDelay: toolbar_1.ToolbarTooltipDelay.Close, title: (0, bundle_1.i18n)('preview_hint'), hotkey: "mod+shift+p" },
|
|
29
29
|
react_1.default.createElement(uikit_1.Button, { size: "m", view: "flat", pin: "round-round", className: bSettings('preview-button'), onClick: () => onShowPreviewChange === null || onShowPreviewChange === void 0 ? void 0 : onShowPreviewChange(!showPreview), selected: showPreview },
|
|
30
30
|
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Eye }))),
|
|
31
|
-
react_1.default.createElement("div", { className: bSettings('separator') }))),
|
|
32
|
-
react_1.default.createElement(
|
|
33
|
-
react_1.default.createElement(uikit_1.
|
|
34
|
-
|
|
35
|
-
react_1.default.createElement(
|
|
31
|
+
settingsVisible && react_1.default.createElement("div", { className: bSettings('separator') }))),
|
|
32
|
+
settingsVisible && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
33
|
+
react_1.default.createElement(uikit_1.Button, { size: "m", view: "flat", ref: chevronRef, pin: "round-round", onClick: togglePopup, className: bSettings('dropdown-button') },
|
|
34
|
+
react_1.default.createElement(uikit_1.Icon, { data: icons_1.Gear })),
|
|
35
|
+
react_1.default.createElement(uikit_1.Popup, { open: popupShown, anchorRef: chevronRef, placement: placement, onClose: hidePopup },
|
|
36
|
+
react_1.default.createElement(SettingsContent, Object.assign({}, props, { onClose: hidePopup, className: bSettings('content') })))))));
|
|
36
37
|
});
|
|
37
38
|
const mdHelpPlacement = ['bottom', 'bottom-end', 'right-start', 'right', 'left'];
|
|
38
39
|
const SettingsContent = function SettingsContent({ mode, onClose, onModeChange, toolbarVisibility, onToolbarVisibilityChange, onSplitModeChange, splitMode = false, splitModeEnabled, className, showPreview, }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { AlertProps } from '@gravity-ui/uikit';
|
|
3
3
|
import type { CommonAnswer, GptRequestData, PromptPreset } from '../ErrorScreen/types';
|
|
4
4
|
export declare type GptDialogProps<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> = {
|
|
@@ -25,4 +25,4 @@ export declare type GptDialogProps<AnswerData extends CommonAnswer = CommonAnswe
|
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
export declare const cnGptDialog: import("@bem-react/classname").ClassNameFormatter;
|
|
28
|
-
export declare const GptDialog:
|
|
28
|
+
export declare const GptDialog: <AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>({ markup, answerRender, promptPresets, disablePromptPresets, customPromptPlaceholder, disabledPromptPlaceholder, onCustomPromptApply, onPromptPresetClick, onTryAgain, onApplyResult, onClose, onLike, onDislike, onUpdate, gptAlertProps, }: GptDialogProps<AnswerData, PromptData>) => JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runMarkupGpt = exports.hideMarkupGpt = exports.showMarkupGpt = void 0;
|
|
4
|
+
const effects_1 = require("./effects");
|
|
5
|
+
const showMarkupGpt = (view) => {
|
|
6
|
+
view.dispatch({ effects: [effects_1.ShowMarkupGptEffect.of(null)] });
|
|
7
|
+
};
|
|
8
|
+
exports.showMarkupGpt = showMarkupGpt;
|
|
9
|
+
const hideMarkupGpt = (view) => {
|
|
10
|
+
view.dispatch({ effects: [effects_1.HideMarkupGptEffect.of(null)] });
|
|
11
|
+
};
|
|
12
|
+
exports.hideMarkupGpt = hideMarkupGpt;
|
|
13
|
+
const runMarkupGpt = (view) => {
|
|
14
|
+
if (view)
|
|
15
|
+
(0, exports.showMarkupGpt)(view);
|
|
16
|
+
return true;
|
|
17
|
+
};
|
|
18
|
+
exports.runMarkupGpt = runMarkupGpt;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HideMarkupGptEffect = exports.ShowMarkupGptEffect = void 0;
|
|
4
|
+
const state_1 = require("../../../../cm/state");
|
|
5
|
+
exports.ShowMarkupGptEffect = state_1.StateEffect.define();
|
|
6
|
+
exports.HideMarkupGptEffect = state_1.StateEffect.define();
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GptWidgetOptions } from '../../..';
|
|
2
|
+
import { CommonAnswer } from '../ErrorScreen/types';
|
|
3
|
+
export { mGptToolbarItem } from './toolbar';
|
|
4
|
+
export { showMarkupGpt, hideMarkupGpt } from './commands';
|
|
5
|
+
export declare function mGptExtension<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>(props: GptWidgetOptions<AnswerData, PromptData>): import("@codemirror/state").Extension[];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mGptExtension = exports.hideMarkupGpt = exports.showMarkupGpt = exports.mGptToolbarItem = void 0;
|
|
4
|
+
const view_1 = require("@codemirror/view");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const commands_1 = require("./commands");
|
|
7
|
+
const plugin_1 = require("./plugin");
|
|
8
|
+
var toolbar_1 = require("./toolbar");
|
|
9
|
+
Object.defineProperty(exports, "mGptToolbarItem", { enumerable: true, get: function () { return toolbar_1.mGptToolbarItem; } });
|
|
10
|
+
var commands_2 = require("./commands");
|
|
11
|
+
Object.defineProperty(exports, "showMarkupGpt", { enumerable: true, get: function () { return commands_2.showMarkupGpt; } });
|
|
12
|
+
Object.defineProperty(exports, "hideMarkupGpt", { enumerable: true, get: function () { return commands_2.hideMarkupGpt; } });
|
|
13
|
+
function mGptExtension(props) {
|
|
14
|
+
return [
|
|
15
|
+
(0, plugin_1.mGptPlugin)(props).extension,
|
|
16
|
+
view_1.keymap.of([
|
|
17
|
+
{
|
|
18
|
+
key: constants_1.gptHotKeys.openGptKey,
|
|
19
|
+
run: commands_1.runMarkupGpt,
|
|
20
|
+
},
|
|
21
|
+
]),
|
|
22
|
+
];
|
|
23
|
+
}
|
|
24
|
+
exports.mGptExtension = mGptExtension;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { GptWidgetOptions } from '../../..';
|
|
2
|
+
import { type DecorationSet, type EditorView, ViewPlugin, type ViewUpdate } from '../../../../cm/view';
|
|
3
|
+
import { CommonAnswer } from '../ErrorScreen/types';
|
|
4
|
+
export declare function mGptPlugin<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>(gptProps: GptWidgetOptions<AnswerData, PromptData>): ViewPlugin<{
|
|
5
|
+
readonly _view: EditorView;
|
|
6
|
+
readonly _renderItem: import("../../..").RendererItem;
|
|
7
|
+
_anchor: Element | null;
|
|
8
|
+
decos: DecorationSet;
|
|
9
|
+
disablePromptPresets: boolean;
|
|
10
|
+
markup: string | null;
|
|
11
|
+
selectedPosition: {
|
|
12
|
+
from: number;
|
|
13
|
+
to: number;
|
|
14
|
+
};
|
|
15
|
+
update(update: ViewUpdate): void;
|
|
16
|
+
docViewUpdate(): void;
|
|
17
|
+
destroy(): void;
|
|
18
|
+
renderPopup(): JSX.Element | null;
|
|
19
|
+
_getDecorationText(update: ViewUpdate, from: number, to: number): string;
|
|
20
|
+
_clearSelectedText(): void;
|
|
21
|
+
_setSelectedText(str: string): void;
|
|
22
|
+
_onApplyResult(changedMarkup: string): void;
|
|
23
|
+
}>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mGptPlugin = void 0;
|
|
4
|
+
const view_1 = require("@codemirror/view");
|
|
5
|
+
const view_2 = require("../../../../cm/view");
|
|
6
|
+
const markup_1 = require("../../../../markup");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const utils_1 = require("../utils");
|
|
9
|
+
const commands_1 = require("./commands");
|
|
10
|
+
const effects_1 = require("./effects");
|
|
11
|
+
const popup_1 = require("./popup");
|
|
12
|
+
class SpanWidget extends view_1.WidgetType {
|
|
13
|
+
constructor(className, textContent) {
|
|
14
|
+
super();
|
|
15
|
+
this.className = '';
|
|
16
|
+
this.textContent = '';
|
|
17
|
+
this.className = className;
|
|
18
|
+
this.textContent = textContent;
|
|
19
|
+
}
|
|
20
|
+
toDOM() {
|
|
21
|
+
const spanElem = document.createElement('span');
|
|
22
|
+
spanElem.className = this.className;
|
|
23
|
+
spanElem.textContent = this.textContent;
|
|
24
|
+
return spanElem;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function mGptPlugin(gptProps) {
|
|
28
|
+
return view_2.ViewPlugin.fromClass(class {
|
|
29
|
+
constructor(view) {
|
|
30
|
+
this._anchor = null;
|
|
31
|
+
this.decos = view_2.Decoration.none;
|
|
32
|
+
this.disablePromptPresets = true;
|
|
33
|
+
this.markup = null;
|
|
34
|
+
this.selectedPosition = {
|
|
35
|
+
from: 0,
|
|
36
|
+
to: 0,
|
|
37
|
+
};
|
|
38
|
+
this._view = view;
|
|
39
|
+
this._renderItem = view.state
|
|
40
|
+
.facet(markup_1.ReactRendererFacet)
|
|
41
|
+
.createItem('gpt-in-markup-mode', () => this.renderPopup());
|
|
42
|
+
}
|
|
43
|
+
update(update) {
|
|
44
|
+
if (update.docChanged || update.selectionSet) {
|
|
45
|
+
this.decos = view_2.Decoration.none;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.decos = this.decos.map(update.changes);
|
|
49
|
+
const { from, to } = update.state.selection.main;
|
|
50
|
+
this.selectedPosition.from = from;
|
|
51
|
+
this.selectedPosition.to = to;
|
|
52
|
+
for (const tr of update.transactions) {
|
|
53
|
+
for (const eff of tr.effects) {
|
|
54
|
+
if (eff.is(effects_1.ShowMarkupGptEffect)) {
|
|
55
|
+
this._setSelectedText(this._getDecorationText(update, from, to));
|
|
56
|
+
if (from === to) {
|
|
57
|
+
this.disablePromptPresets = true;
|
|
58
|
+
if ((0, utils_1.isEmptyGptPrompts)(gptProps, true))
|
|
59
|
+
return;
|
|
60
|
+
const decorationWidget = view_2.Decoration.widget({
|
|
61
|
+
widget: new SpanWidget(constants_1.WIDGET_DECO_CLASS_NAME, ' '),
|
|
62
|
+
});
|
|
63
|
+
this.decos = view_2.Decoration.set([decorationWidget.range(from)]);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
this.disablePromptPresets = false;
|
|
67
|
+
if ((0, utils_1.isEmptyGptPrompts)(gptProps, false))
|
|
68
|
+
return;
|
|
69
|
+
this.decos = view_2.Decoration.set([
|
|
70
|
+
{
|
|
71
|
+
from,
|
|
72
|
+
to,
|
|
73
|
+
value: view_2.Decoration.mark({ class: constants_1.WIDGET_DECO_CLASS_NAME }),
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
if (eff.is(effects_1.HideMarkupGptEffect)) {
|
|
78
|
+
this.decos = view_2.Decoration.none;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
docViewUpdate() {
|
|
84
|
+
this._anchor = this._view.dom
|
|
85
|
+
.getElementsByClassName(constants_1.WIDGET_DECO_CLASS_NAME)
|
|
86
|
+
.item(0);
|
|
87
|
+
this._renderItem.rerender();
|
|
88
|
+
}
|
|
89
|
+
destroy() {
|
|
90
|
+
this._clearSelectedText();
|
|
91
|
+
this._renderItem.remove();
|
|
92
|
+
}
|
|
93
|
+
renderPopup() {
|
|
94
|
+
if (!this._anchor || this.markup === null) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
return (0, popup_1.renderPopup)(this._anchor, Object.assign(Object.assign({}, gptProps), { disablePromptPresets: this.disablePromptPresets, onClose: () => (0, commands_1.hideMarkupGpt)(this._view), markup: this.markup, onApplyResult: (changedMarkup) => this._onApplyResult(changedMarkup) }));
|
|
98
|
+
}
|
|
99
|
+
_getDecorationText(update, from, to) {
|
|
100
|
+
return update.state.doc.sliceString(from, to);
|
|
101
|
+
}
|
|
102
|
+
_clearSelectedText() {
|
|
103
|
+
this.markup = null;
|
|
104
|
+
}
|
|
105
|
+
_setSelectedText(str) {
|
|
106
|
+
this.markup = str;
|
|
107
|
+
}
|
|
108
|
+
_onApplyResult(changedMarkup) {
|
|
109
|
+
const { from, to } = this.selectedPosition;
|
|
110
|
+
const changes = [{ from: from, to: to, insert: changedMarkup }];
|
|
111
|
+
const transaction = this._view.state.update({
|
|
112
|
+
changes: changes,
|
|
113
|
+
effects: [effects_1.HideMarkupGptEffect.of(null)],
|
|
114
|
+
});
|
|
115
|
+
this._view.dispatch(transaction);
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
decorations: (value) => value.decos,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
exports.mGptPlugin = mGptPlugin;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { PopupProps } from '@gravity-ui/uikit';
|
|
3
|
+
import { CommonAnswer } from '../ErrorScreen/types';
|
|
4
|
+
import { GptDialogProps } from '../GptDialog/GptDialog';
|
|
5
|
+
declare type Props<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> = {
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
markup: string;
|
|
8
|
+
onConfirmOk?: () => void;
|
|
9
|
+
onConfirmCancel?: () => void;
|
|
10
|
+
} & GptDialogProps<AnswerData, PromptData> & Pick<PopupProps, 'anchorRef' | 'container'>;
|
|
11
|
+
export declare function renderPopup<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>(anchor: HTMLElement, props: Props<AnswerData, PromptData>): JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderPopup = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
7
|
+
const GptDialog_1 = require("../GptDialog/GptDialog");
|
|
8
|
+
const view_1 = require("../gptExtension/view");
|
|
9
|
+
function renderPopup(anchor, props) {
|
|
10
|
+
const handleUpdate = (result) => { var _a; return (_a = props.onUpdate) === null || _a === void 0 ? void 0 : _a.call(props, result); };
|
|
11
|
+
return (react_1.default.createElement(uikit_1.Popup, { className: (0, view_1.cnGptPopup)(), contentClassName: (0, view_1.cnGptPopup)('content'), open: true, anchorRef: { current: anchor }, onOutsideClick: props.onClose, focusTrap: true, strategy: "absolute", onEscapeKeyDown: props.onClose },
|
|
12
|
+
react_1.default.createElement(GptDialog_1.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 })));
|
|
13
|
+
}
|
|
14
|
+
exports.renderPopup = renderPopup;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mGptToolbarItem = void 0;
|
|
4
|
+
const extension_1 = require("../../../../i18n/gpt/extension");
|
|
5
|
+
const icons_1 = require("../../../../icons");
|
|
6
|
+
const toolbar_1 = require("../../../../toolbar");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const commands_1 = require("./commands");
|
|
9
|
+
exports.mGptToolbarItem = {
|
|
10
|
+
id: 'gpt',
|
|
11
|
+
type: toolbar_1.ToolbarDataType.SingleButton,
|
|
12
|
+
hotkey: constants_1.gptHotKeys.openGptKeyTooltip,
|
|
13
|
+
title: () => `${(0, extension_1.i18n)('help-with-text')}`,
|
|
14
|
+
icon: { data: icons_1.GPTIcon },
|
|
15
|
+
exec: (e) => (0, commands_1.showMarkupGpt)(e.cm),
|
|
16
|
+
isActive: () => false,
|
|
17
|
+
isEnable: () => true,
|
|
18
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CommonAnswer } from '../ErrorScreen/types';
|
|
2
|
+
import type { GptDialogProps } from '../GptDialog/GptDialog';
|
|
3
|
+
export declare type PresetListProps<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> = {
|
|
4
|
+
disablePromptPresets: GptDialogProps<AnswerData, PromptData>['disablePromptPresets'];
|
|
5
|
+
promptPresets: GptDialogProps<AnswerData, PromptData>['promptPresets'];
|
|
6
|
+
onPresetClick: (data?: PromptData) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const cnGptDialogPresetList: import("@bem-react/classname").ClassNameFormatter;
|
|
9
|
+
export declare const PresetList: <AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>({ disablePromptPresets, promptPresets, onPresetClick, }: PresetListProps<AnswerData, PromptData>) => JSX.Element;
|
|
@@ -10,7 +10,7 @@ const constants_1 = require("../constants");
|
|
|
10
10
|
const useGptHotKeys_1 = require("../hooks/useGptHotKeys");
|
|
11
11
|
const usePresetList_1 = require("../hooks/usePresetList");
|
|
12
12
|
exports.cnGptDialogPresetList = (0, classname_1.cn)('gpt-dialog-preset-list');
|
|
13
|
-
const PresetItem = ({ preset, onPresetClick, disablePromptPresets, hotKey }) => {
|
|
13
|
+
const PresetItem = ({ preset, onPresetClick, disablePromptPresets, hotKey, }) => {
|
|
14
14
|
(0, useGptHotKeys_1.useGptHotKeys)(hotKey, () => {
|
|
15
15
|
onPresetClick(preset.data);
|
|
16
16
|
}, { enableOnFormTags: true, enableOnContentEditable: true });
|
package/build/{esm/extensions/yfm → cjs/extensions/additional}/GPT/gptExtension/gptExtension.d.ts
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Action,
|
|
1
|
+
import { Action, ExtensionBuilder } from '../../../../core';
|
|
2
2
|
import type { CommonAnswer } from '../ErrorScreen/types';
|
|
3
3
|
import type { GptWidgetDecoViewParams } from './view';
|
|
4
4
|
export declare const gptActionName = "addGptWidget";
|
|
5
5
|
export declare type GptWidgetOptions<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> = Pick<GptWidgetDecoViewParams<AnswerData, PromptData>, 'gptPopupContainer' | 'answerRender' | 'onApplyResult' | 'promptPresets' | 'customPromptPlaceholder' | 'disabledPromptPlaceholder' | 'onCustomPromptApply' | 'onPromptPresetClick' | 'onTryAgain' | 'onLike' | 'onDislike' | 'onClose' | 'onUpdate' | 'gptAlertProps'>;
|
|
6
|
-
export declare const gptExtension:
|
|
6
|
+
export declare const gptExtension: <AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>(builder: ExtensionBuilder, options: GptWidgetOptions<AnswerData, PromptData>) => void;
|
|
7
7
|
declare global {
|
|
8
8
|
namespace WysiwygEditor {
|
|
9
9
|
interface Actions {
|
|
@@ -12,7 +12,7 @@ export declare type GptWidgetDecoViewParams<AnswerData extends CommonAnswer = Co
|
|
|
12
12
|
onApplyResult?: GptDialogProps['onApplyResult'];
|
|
13
13
|
gptPopupContainer?: PopupProps['container'];
|
|
14
14
|
};
|
|
15
|
-
export declare class GptWidgetDecoView implements Required<PluginView> {
|
|
15
|
+
export declare class GptWidgetDecoView<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> implements Required<PluginView> {
|
|
16
16
|
private readonly _view;
|
|
17
17
|
private readonly _renderer;
|
|
18
18
|
private _decoElem;
|
|
@@ -20,7 +20,7 @@ export declare class GptWidgetDecoView implements Required<PluginView> {
|
|
|
20
20
|
private _serializer;
|
|
21
21
|
private _parser;
|
|
22
22
|
private _confirmOpen;
|
|
23
|
-
constructor(view: EditorView, params: GptWidgetDecoViewParams);
|
|
23
|
+
constructor(view: EditorView, params: GptWidgetDecoViewParams<AnswerData, PromptData>);
|
|
24
24
|
update(view: EditorView, prevState: EditorState): void;
|
|
25
25
|
destroy(): void;
|
|
26
26
|
private _resetState;
|
|
@@ -15,7 +15,7 @@ export declare const useGpt: <AnswerData extends CommonAnswer = CommonAnswer, Pr
|
|
|
15
15
|
handleCustomPromptUpdate: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
16
16
|
handleCustomPromptKeyPress: import("react").KeyboardEventHandler<HTMLInputElement>;
|
|
17
17
|
handleCustomPromptApply: () => Promise<void>;
|
|
18
|
-
handlePresetClick: (data
|
|
18
|
+
handlePresetClick: (data?: PromptData | undefined) => void;
|
|
19
19
|
handleTryAgain: () => Promise<void>;
|
|
20
20
|
handleFreshStart: () => void;
|
|
21
21
|
handleApplyResult: () => void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DropdownMenuItem } from '@gravity-ui/uikit';
|
|
2
|
+
import { CommonAnswer } from '../ErrorScreen/types';
|
|
3
|
+
import type { GptDialogProps } from '../GptDialog/GptDialog';
|
|
4
|
+
import type { PresetListProps } from '../PresetList/PresetList';
|
|
5
|
+
declare type UsePresetListProps<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> = Pick<GptDialogProps<AnswerData, PromptData>, 'promptPresets'> & {
|
|
6
|
+
onPresetClick: PresetListProps<AnswerData, PromptData>['onPresetClick'];
|
|
7
|
+
};
|
|
8
|
+
export declare const usePresetList: <AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>({ promptPresets, onPresetClick, }: UsePresetListProps<AnswerData, PromptData>) => {
|
|
9
|
+
measured: boolean;
|
|
10
|
+
showMoreButton: boolean;
|
|
11
|
+
presetsContainerRef: import("react").RefObject<HTMLDivElement>;
|
|
12
|
+
visiblePresets: import("../ErrorScreen/types").PromptPreset<PromptData>[];
|
|
13
|
+
hiddenPresets: DropdownMenuItem<unknown>[];
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -4,7 +4,7 @@ exports.usePresetList = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const PresetList_1 = require("../PresetList/PresetList");
|
|
6
6
|
const useOverflowingHorizontalItems_1 = require("./useOverflowingHorizontalItems");
|
|
7
|
-
const usePresetList = ({ promptPresets, onPresetClick }) => {
|
|
7
|
+
const usePresetList = ({ promptPresets, onPresetClick, }) => {
|
|
8
8
|
const presetsContainerRef = (0, react_1.useRef)(null);
|
|
9
9
|
const { visibleItems, hiddenItems, measured } = (0, useOverflowingHorizontalItems_1.useOverflowingHorizontalItems)({
|
|
10
10
|
containerRef: presetsContainerRef,
|
|
@@ -3,3 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./toolbar"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./gptExtension/gptExtension"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./MarkupGpt"), exports);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
2
2
|
import { DecorationSet } from 'prosemirror-view';
|
|
3
|
+
import { CommonAnswer } from './ErrorScreen/types';
|
|
3
4
|
import type { GptWidgetDecoViewParams } from './gptExtension/view';
|
|
4
5
|
export declare type GptWidgetMeta = {
|
|
5
6
|
action: 'show';
|
|
@@ -10,4 +11,4 @@ export declare type GptWidgetMeta = {
|
|
|
10
11
|
};
|
|
11
12
|
declare const key: PluginKey<DecorationSet>;
|
|
12
13
|
export { key as pluginKey };
|
|
13
|
-
export declare const gptWidgetPlugin: (params: GptWidgetDecoViewParams) => Plugin;
|
|
14
|
+
export declare const gptWidgetPlugin: <AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>(params: GptWidgetDecoViewParams<AnswerData, PromptData>) => Plugin;
|
|
@@ -5,6 +5,7 @@ const prosemirror_state_1 = require("prosemirror-state");
|
|
|
5
5
|
const prosemirror_view_1 = require("prosemirror-view");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const view_1 = require("./gptExtension/view");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
8
9
|
const key = new prosemirror_state_1.PluginKey('gpt-widget');
|
|
9
10
|
exports.pluginKey = key;
|
|
10
11
|
const gptWidgetPlugin = (params) => {
|
|
@@ -15,18 +16,23 @@ const gptWidgetPlugin = (params) => {
|
|
|
15
16
|
apply: (tr, decos) => {
|
|
16
17
|
const meta = tr.getMeta(key);
|
|
17
18
|
const paramsGpt = params;
|
|
19
|
+
paramsGpt.disablePromptPresets = false;
|
|
18
20
|
if ((meta === null || meta === void 0 ? void 0 : meta.action) === 'show') {
|
|
19
21
|
if (meta.to === meta.from) {
|
|
20
22
|
const spanElem = document.createElement('span');
|
|
21
23
|
spanElem.className = constants_1.WIDGET_DECO_CLASS_NAME;
|
|
22
24
|
spanElem.textContent = ' ';
|
|
23
25
|
paramsGpt.disablePromptPresets = true;
|
|
26
|
+
if ((0, utils_1.isEmptyGptPrompts)(paramsGpt, true))
|
|
27
|
+
return prosemirror_view_1.DecorationSet.empty;
|
|
24
28
|
return prosemirror_view_1.DecorationSet.create(tr.doc, [
|
|
25
29
|
prosemirror_view_1.Decoration.widget(meta.from, spanElem, {
|
|
26
30
|
[constants_1.WIDGET_DECO_SPEC_FLAG]: true,
|
|
27
31
|
}),
|
|
28
32
|
]);
|
|
29
33
|
}
|
|
34
|
+
if ((0, utils_1.isEmptyGptPrompts)(paramsGpt, false))
|
|
35
|
+
return prosemirror_view_1.DecorationSet.empty;
|
|
30
36
|
return prosemirror_view_1.DecorationSet.create(tr.doc, [
|
|
31
37
|
prosemirror_view_1.Decoration.inline(meta.from, meta.to, { nodeName: 'span', class: constants_1.WIDGET_DECO_CLASS_NAME }, { [constants_1.WIDGET_DECO_SPEC_FLAG]: true }),
|
|
32
38
|
]);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
+
import { CommonAnswer } from './ErrorScreen/types';
|
|
2
3
|
import { GptDialogProps } from './GptDialog/GptDialog';
|
|
4
|
+
import { GptWidgetOptions } from './gptExtension/gptExtension';
|
|
3
5
|
declare type CombinedKeyboardEvent = KeyboardEvent | React.KeyboardEvent;
|
|
4
6
|
export declare function getAlertGptInfo(gptAlert: GptDialogProps['gptAlertProps']): {
|
|
5
7
|
alertMessage: string;
|
|
@@ -10,4 +12,5 @@ export declare function getDisableReplaceButtonText(disablePromptPresets?: boole
|
|
|
10
12
|
export declare function getInputPlaceHolder(disablePromptPresets?: boolean, disabledPromptPlaceholder?: string, customPromptPlaceholder?: string): string | undefined;
|
|
11
13
|
export declare const isEnter: (event: CombinedKeyboardEvent) => boolean;
|
|
12
14
|
export declare function focusWithoutScroll(element?: HTMLElement | null): void;
|
|
15
|
+
export declare function isEmptyGptPrompts<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown>(gptWidgetOptions: GptWidgetOptions<AnswerData, PromptData>, disablePromptPresets: boolean): boolean;
|
|
13
16
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.focusWithoutScroll = exports.isEnter = exports.getInputPlaceHolder = exports.getDisableReplaceButtonText = exports.getAlertGptInfo = void 0;
|
|
3
|
+
exports.isEmptyGptPrompts = exports.focusWithoutScroll = exports.isEnter = exports.getInputPlaceHolder = exports.getDisableReplaceButtonText = exports.getAlertGptInfo = void 0;
|
|
4
4
|
const dialog_1 = require("../../../i18n/gpt/dialog");
|
|
5
5
|
function getAlertGptInfo(gptAlert) {
|
|
6
6
|
return {
|
|
@@ -29,3 +29,14 @@ function focusWithoutScroll(element) {
|
|
|
29
29
|
window.scrollTo(x, y);
|
|
30
30
|
}
|
|
31
31
|
exports.focusWithoutScroll = focusWithoutScroll;
|
|
32
|
+
function isEmptyGptPrompts(gptWidgetOptions, disablePromptPresets) {
|
|
33
|
+
var _a;
|
|
34
|
+
if (disablePromptPresets && !gptWidgetOptions.onCustomPromptApply)
|
|
35
|
+
return true;
|
|
36
|
+
if (!disablePromptPresets &&
|
|
37
|
+
!((_a = gptWidgetOptions.promptPresets) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
38
|
+
!gptWidgetOptions.onCustomPromptApply)
|
|
39
|
+
return true;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
exports.isEmptyGptPrompts = isEmptyGptPrompts;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './GPT';
|