@gravity-ui/markdown-editor 13.17.0 → 13.18.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/config/action-names.d.ts +1 -1
- package/build/cjs/bundle/config/action-names.js +1 -0
- package/build/cjs/bundle/config/icons.d.ts +1 -1
- package/build/cjs/bundle/config/icons.js +3 -0
- package/build/cjs/bundle/config/wysiwyg.d.ts +1 -0
- package/build/cjs/bundle/config/wysiwyg.js +13 -1
- package/build/cjs/extensions/behavior/Resizable/Resizable.css +38 -0
- package/build/cjs/extensions/behavior/Resizable/Resizable.d.ts +9 -0
- package/build/cjs/extensions/behavior/Resizable/Resizable.js +14 -0
- package/build/cjs/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
- package/build/cjs/extensions/markdown/Table/plugins/TableCellContextPlugin/index.js +19 -9
- package/build/cjs/extensions/yfm/GPT/ErrorScreen/ErrorScreen.css +18 -0
- package/build/cjs/extensions/yfm/GPT/ErrorScreen/ErrorScreen.d.ts +8 -0
- package/build/cjs/extensions/yfm/GPT/ErrorScreen/ErrorScreen.js +21 -0
- package/build/cjs/extensions/yfm/GPT/ErrorScreen/types.d.ts +14 -0
- package/build/cjs/extensions/yfm/GPT/ErrorScreen/types.js +2 -0
- package/build/cjs/extensions/yfm/GPT/GptDialog/GptDialog.css +75 -0
- package/build/cjs/extensions/yfm/GPT/GptDialog/GptDialog.d.ts +28 -0
- package/build/cjs/extensions/yfm/GPT/GptDialog/GptDialog.js +102 -0
- package/build/cjs/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.css +22 -0
- package/build/cjs/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +3 -0
- package/build/cjs/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.js +21 -0
- package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.d.ts +1 -0
- package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.js +5 -0
- package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.css +8 -0
- package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.d.ts +14 -0
- package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.js +28 -0
- package/build/cjs/extensions/yfm/GPT/IconRefuge/index.d.ts +2 -0
- package/build/cjs/extensions/yfm/GPT/IconRefuge/index.js +5 -0
- package/build/cjs/extensions/yfm/GPT/PresetList/PresetList.d.ts +9 -0
- package/build/cjs/extensions/yfm/GPT/PresetList/PresetList.js +29 -0
- package/build/cjs/extensions/yfm/GPT/PresetList/Presetlist.css +6 -0
- package/build/cjs/extensions/yfm/GPT/actions.d.ts +2 -0
- package/build/cjs/extensions/yfm/GPT/actions.js +14 -0
- package/build/cjs/extensions/yfm/GPT/commands.d.ts +2 -0
- package/build/cjs/extensions/yfm/GPT/commands.js +13 -0
- package/build/cjs/extensions/yfm/GPT/constants.d.ts +13 -0
- package/build/cjs/extensions/yfm/GPT/constants.js +15 -0
- package/build/cjs/extensions/yfm/GPT/gptExtension/gptExtension.d.ts +13 -0
- package/build/cjs/extensions/yfm/GPT/gptExtension/gptExtension.js +18 -0
- package/build/cjs/extensions/yfm/GPT/gptExtension/view.css +17 -0
- package/build/cjs/extensions/yfm/GPT/gptExtension/view.d.ts +36 -0
- package/build/cjs/extensions/yfm/GPT/gptExtension/view.js +171 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useGpt.d.ts +27 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useGpt.js +148 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useGptHotKeys.d.ts +2 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useGptHotKeys.js +8 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.d.ts +13 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.js +70 -0
- package/build/cjs/extensions/yfm/GPT/hooks/usePresetList.d.ts +14 -0
- package/build/cjs/extensions/yfm/GPT/hooks/usePresetList.js +36 -0
- package/build/cjs/extensions/yfm/GPT/index.d.ts +2 -0
- package/build/cjs/extensions/yfm/GPT/index.js +5 -0
- package/build/cjs/extensions/yfm/GPT/plugin.d.ts +13 -0
- package/build/cjs/extensions/yfm/GPT/plugin.js +47 -0
- package/build/cjs/extensions/yfm/GPT/toolbar.d.ts +3 -0
- package/build/cjs/extensions/yfm/GPT/toolbar.js +22 -0
- package/build/cjs/extensions/yfm/GPT/utils.d.ts +13 -0
- package/build/cjs/extensions/yfm/GPT/utils.js +31 -0
- package/build/cjs/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImgSettingsButton.css +6 -0
- package/build/cjs/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImgSettingsButton.d.ts +6 -1
- package/build/cjs/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImgSettingsButton.js +21 -37
- package/build/cjs/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/NodeView.d.ts +1 -1
- package/build/cjs/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/NodeView.js +62 -4
- package/build/cjs/extensions/yfm/Mermaid/MermaidNodeView/MermaidView.js +8 -7
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.d.ts +1 -1
- package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js +0 -8
- package/build/cjs/extensions/yfm/index.d.ts +1 -0
- package/build/cjs/extensions/yfm/index.js +1 -0
- package/build/cjs/i18n/gpt/dialog/en.json +16 -0
- package/build/cjs/i18n/gpt/dialog/index.d.ts +19 -0
- package/build/cjs/i18n/gpt/dialog/index.js +8 -0
- package/build/cjs/i18n/gpt/dialog/ru.json +16 -0
- package/build/cjs/i18n/gpt/errors/en.json +5 -0
- package/build/cjs/i18n/gpt/errors/index.d.ts +8 -0
- package/build/cjs/i18n/gpt/errors/index.js +8 -0
- package/build/cjs/i18n/gpt/errors/ru.json +5 -0
- package/build/cjs/i18n/gpt/extension/en.json +6 -0
- package/build/cjs/i18n/gpt/extension/index.d.ts +9 -0
- package/build/cjs/i18n/gpt/extension/index.js +8 -0
- package/build/cjs/i18n/gpt/extension/ru.json +6 -0
- package/build/cjs/i18n/gpt/loading/en.json +3 -0
- package/build/cjs/i18n/gpt/loading/index.d.ts +6 -0
- package/build/cjs/i18n/gpt/loading/index.js +8 -0
- package/build/cjs/i18n/gpt/loading/ru.json +3 -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/i18n/yfm-table/en.json +10 -1
- package/build/cjs/i18n/yfm-table/index.d.ts +10 -1
- package/build/cjs/i18n/yfm-table/ru.json +10 -1
- package/build/cjs/icons/GPT.d.ts +2 -0
- package/build/cjs/icons/GPT.js +22 -0
- package/build/cjs/icons/GPTLoading.d.ts +2 -0
- package/build/cjs/icons/GPTLoading.js +12 -0
- package/build/cjs/icons/index.d.ts +3 -1
- package/build/cjs/icons/index.js +5 -1
- package/build/cjs/react-utils/useAutoFocus.d.ts +1 -1
- package/build/cjs/react-utils/useAutoFocus.js +2 -2
- package/build/cjs/react-utils/useNodeEditing.d.ts +3 -2
- package/build/cjs/react-utils/useNodeEditing.js +1 -1
- package/build/cjs/react-utils/useNodeResizing.d.ts +22 -0
- package/build/cjs/react-utils/useNodeResizing.js +82 -0
- package/build/cjs/table-utils/commands/appendColumn.js +42 -33
- package/build/cjs/table-utils/commands/appendRow.js +40 -22
- package/build/cjs/table-utils/commands/removeColumn.js +18 -20
- package/build/cjs/table-utils/commands/removeRow.js +12 -9
- package/build/cjs/table-utils/table-desc.d.ts +53 -0
- package/build/cjs/table-utils/table-desc.js +149 -0
- package/build/cjs/table-utils/utils.d.ts +1 -1
- package/build/cjs/table-utils/utils.js +19 -12
- package/build/cjs/version.js +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/icons.d.ts +1 -1
- package/build/esm/bundle/config/icons.js +2 -0
- package/build/esm/bundle/config/wysiwyg.d.ts +1 -0
- package/build/esm/bundle/config/wysiwyg.js +12 -0
- package/build/esm/extensions/behavior/Resizable/Resizable.css +38 -0
- package/build/esm/extensions/behavior/Resizable/Resizable.d.ts +10 -0
- package/build/esm/extensions/behavior/Resizable/Resizable.js +10 -0
- package/build/esm/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
- package/build/esm/extensions/markdown/Table/plugins/TableCellContextPlugin/index.js +19 -9
- package/build/esm/extensions/yfm/GPT/ErrorScreen/ErrorScreen.css +18 -0
- package/build/esm/extensions/yfm/GPT/ErrorScreen/ErrorScreen.d.ts +9 -0
- package/build/esm/extensions/yfm/GPT/ErrorScreen/ErrorScreen.js +17 -0
- package/build/esm/extensions/yfm/GPT/ErrorScreen/types.d.ts +14 -0
- package/build/esm/extensions/yfm/GPT/ErrorScreen/types.js +1 -0
- package/build/esm/extensions/yfm/GPT/GptDialog/GptDialog.css +75 -0
- package/build/esm/extensions/yfm/GPT/GptDialog/GptDialog.d.ts +29 -0
- package/build/esm/extensions/yfm/GPT/GptDialog/GptDialog.js +98 -0
- package/build/esm/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.css +22 -0
- package/build/esm/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +4 -0
- package/build/esm/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.js +17 -0
- package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.d.ts +1 -0
- package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.js +2 -0
- package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.css +8 -0
- package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.d.ts +15 -0
- package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.js +25 -0
- package/build/esm/extensions/yfm/GPT/IconRefuge/index.d.ts +2 -0
- package/build/esm/extensions/yfm/GPT/IconRefuge/index.js +1 -0
- package/build/esm/extensions/yfm/GPT/PresetList/PresetList.d.ts +10 -0
- package/build/esm/extensions/yfm/GPT/PresetList/PresetList.js +25 -0
- package/build/esm/extensions/yfm/GPT/PresetList/Presetlist.css +6 -0
- package/build/esm/extensions/yfm/GPT/actions.d.ts +2 -0
- package/build/esm/extensions/yfm/GPT/actions.js +10 -0
- package/build/esm/extensions/yfm/GPT/commands.d.ts +2 -0
- package/build/esm/extensions/yfm/GPT/commands.js +9 -0
- package/build/esm/extensions/yfm/GPT/constants.d.ts +13 -0
- package/build/esm/extensions/yfm/GPT/constants.js +12 -0
- package/build/esm/extensions/yfm/GPT/gptExtension/gptExtension.d.ts +13 -0
- package/build/esm/extensions/yfm/GPT/gptExtension/gptExtension.js +14 -0
- package/build/esm/extensions/yfm/GPT/gptExtension/view.css +17 -0
- package/build/esm/extensions/yfm/GPT/gptExtension/view.d.ts +37 -0
- package/build/esm/extensions/yfm/GPT/gptExtension/view.js +167 -0
- package/build/esm/extensions/yfm/GPT/hooks/useGpt.d.ts +27 -0
- package/build/esm/extensions/yfm/GPT/hooks/useGpt.js +144 -0
- package/build/esm/extensions/yfm/GPT/hooks/useGptHotKeys.d.ts +2 -0
- package/build/esm/extensions/yfm/GPT/hooks/useGptHotKeys.js +4 -0
- package/build/esm/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.d.ts +13 -0
- package/build/esm/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.js +65 -0
- package/build/esm/extensions/yfm/GPT/hooks/usePresetList.d.ts +14 -0
- package/build/esm/extensions/yfm/GPT/hooks/usePresetList.js +32 -0
- package/build/esm/extensions/yfm/GPT/index.d.ts +2 -0
- package/build/esm/extensions/yfm/GPT/index.js +2 -0
- package/build/esm/extensions/yfm/GPT/plugin.d.ts +13 -0
- package/build/esm/extensions/yfm/GPT/plugin.js +43 -0
- package/build/esm/extensions/yfm/GPT/toolbar.d.ts +3 -0
- package/build/esm/extensions/yfm/GPT/toolbar.js +18 -0
- package/build/esm/extensions/yfm/GPT/utils.d.ts +13 -0
- package/build/esm/extensions/yfm/GPT/utils.js +23 -0
- package/build/esm/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImgSettingsButton.css +6 -0
- package/build/esm/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImgSettingsButton.d.ts +7 -1
- package/build/esm/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/ImgSettingsButton.js +23 -38
- package/build/esm/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/NodeView.d.ts +1 -1
- package/build/esm/extensions/yfm/ImgSize/plugins/ImgSizeNodeView/NodeView.js +63 -5
- package/build/esm/extensions/yfm/Mermaid/MermaidNodeView/MermaidView.js +5 -4
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.d.ts +1 -1
- package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js +1 -9
- package/build/esm/extensions/yfm/index.d.ts +1 -0
- package/build/esm/extensions/yfm/index.js +1 -0
- package/build/esm/i18n/gpt/dialog/en.json +16 -0
- package/build/esm/i18n/gpt/dialog/index.d.ts +19 -0
- package/build/esm/i18n/gpt/dialog/index.js +4 -0
- package/build/esm/i18n/gpt/dialog/ru.json +16 -0
- package/build/esm/i18n/gpt/errors/en.json +5 -0
- package/build/esm/i18n/gpt/errors/index.d.ts +8 -0
- package/build/esm/i18n/gpt/errors/index.js +4 -0
- package/build/esm/i18n/gpt/errors/ru.json +5 -0
- package/build/esm/i18n/gpt/extension/en.json +6 -0
- package/build/esm/i18n/gpt/extension/index.d.ts +9 -0
- package/build/esm/i18n/gpt/extension/index.js +4 -0
- package/build/esm/i18n/gpt/extension/ru.json +6 -0
- package/build/esm/i18n/gpt/loading/en.json +3 -0
- package/build/esm/i18n/gpt/loading/index.d.ts +6 -0
- package/build/esm/i18n/gpt/loading/index.js +4 -0
- package/build/esm/i18n/gpt/loading/ru.json +3 -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/i18n/yfm-table/en.json +10 -1
- package/build/esm/i18n/yfm-table/index.d.ts +10 -1
- package/build/esm/i18n/yfm-table/ru.json +10 -1
- package/build/esm/icons/GPT.d.ts +2 -0
- package/build/esm/icons/GPT.js +19 -0
- package/build/esm/icons/GPTLoading.d.ts +2 -0
- package/build/esm/icons/GPTLoading.js +9 -0
- package/build/esm/icons/index.d.ts +3 -1
- package/build/esm/icons/index.js +3 -1
- package/build/esm/react-utils/useAutoFocus.d.ts +1 -1
- package/build/esm/react-utils/useAutoFocus.js +2 -2
- package/build/esm/react-utils/useNodeEditing.d.ts +3 -2
- package/build/esm/react-utils/useNodeEditing.js +1 -1
- package/build/esm/react-utils/useNodeResizing.d.ts +22 -0
- package/build/esm/react-utils/useNodeResizing.js +77 -0
- package/build/esm/table-utils/commands/appendColumn.js +44 -35
- package/build/esm/table-utils/commands/appendRow.js +42 -24
- package/build/esm/table-utils/commands/removeColumn.js +18 -20
- package/build/esm/table-utils/commands/removeRow.js +14 -11
- package/build/esm/table-utils/table-desc.d.ts +53 -0
- package/build/esm/table-utils/table-desc.js +144 -0
- package/build/esm/table-utils/utils.d.ts +1 -1
- package/build/esm/table-utils/utils.js +18 -12
- package/build/esm/version.js +1 -1
- package/build/styles.css +190 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -56,6 +56,8 @@ Read more:
|
|
|
56
56
|
- [How to add Latex extension](docs/how-to-connect-latex-extension.md)
|
|
57
57
|
- [How to add Mermaid extension](docs/how-to-connect-mermaid-extension.md)
|
|
58
58
|
- [How to write extension](docs/how-to-create-extension.md)
|
|
59
|
+
- [How to add gpt extension](docs/how-to-connect-gpt-extensions.md)
|
|
60
|
+
|
|
59
61
|
|
|
60
62
|
### i18n
|
|
61
63
|
|
|
@@ -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" | "undo" | "redo" | "math_inline" | "math_block" | "mermaid" | "liftListItem" | "sinkListItem" | "yfm_block" | "yfm_html_block" | "yfm_layout" | "horizontalrule", string>;
|
|
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" | "math_inline" | "math_block" | "mermaid" | "liftListItem" | "sinkListItem" | "yfm_block" | "yfm_html_block" | "yfm_layout" | "horizontalrule", string>;
|
|
2
2
|
export declare const ActionName: Readonly<typeof namesObj>;
|
|
3
3
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToolbarIconData } from '../../toolbar/types';
|
|
2
|
-
declare 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';
|
|
2
|
+
declare 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';
|
|
3
3
|
declare type Icons = Record<Icon, ToolbarIconData>;
|
|
4
4
|
export declare const icons: Icons;
|
|
5
5
|
export {};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.icons = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const icons_1 = require("../../icons");
|
|
6
|
+
const GPT_1 = tslib_1.__importDefault(require("../../icons/GPT"));
|
|
5
7
|
exports.icons = {
|
|
6
8
|
undo: { data: icons_1.UndoIcon },
|
|
7
9
|
redo: { data: icons_1.RedoIcon },
|
|
@@ -42,4 +44,5 @@ exports.icons = {
|
|
|
42
44
|
tabs: { data: icons_1.TabsIcon },
|
|
43
45
|
mermaid: { data: icons_1.MermaidIcon },
|
|
44
46
|
foldingHeading: { data: icons_1.FoldingHeadingIcon },
|
|
47
|
+
gpt: { data: GPT_1.default },
|
|
45
48
|
};
|
|
@@ -45,6 +45,7 @@ export declare const wMathBlockItemData: WToolbarSingleItemData;
|
|
|
45
45
|
export declare const wMathListConfig: WToolbarListButtonData;
|
|
46
46
|
export declare const wMathListItem: WToolbarListItemData;
|
|
47
47
|
export declare const wYfmHtmlBlockItemData: WToolbarSingleItemData;
|
|
48
|
+
export declare const wGptItemData: WToolbarSingleItemData;
|
|
48
49
|
export declare const wCommandMenuConfig: WToolbarItemData[];
|
|
49
50
|
export declare const wHiddenData: WToolbarItemData[];
|
|
50
51
|
/** prepared wysiwyg toolbar config */
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wSelectionMenuConfigByPreset = exports.wHiddenDataByPreset = exports.wCommandMenuConfigByPreset = exports.wToolbarConfigByPreset = exports.wMermaidItemData = exports.wSelectionMenuConfig = exports.wToggleHeadingFoldingItemData = exports.wToolbarConfig = exports.wHiddenData = exports.wCommandMenuConfig = 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;
|
|
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
|
+
// for typings from Math
|
|
6
|
+
const constants_1 = require("../../extensions/yfm/GPT/constants");
|
|
5
7
|
const hints_1 = require("../../i18n/hints");
|
|
6
8
|
const menubar_1 = require("../../i18n/menubar");
|
|
7
9
|
const shortcuts_1 = require("../../shortcuts");
|
|
@@ -403,6 +405,16 @@ exports.wYfmHtmlBlockItemData = {
|
|
|
403
405
|
isActive: (e) => e.actions.createYfmHtmlBlock.isActive(),
|
|
404
406
|
isEnable: (e) => e.actions.createYfmHtmlBlock.isEnable(),
|
|
405
407
|
};
|
|
408
|
+
exports.wGptItemData = {
|
|
409
|
+
id: action_names_1.ActionName.gpt,
|
|
410
|
+
type: types_1.ToolbarDataType.SingleButton,
|
|
411
|
+
title: menubar_1.i18n.bind(null, 'gpt'),
|
|
412
|
+
hotkey: constants_1.gptHotKeys.openGptKeyTooltip,
|
|
413
|
+
icon: icons_1.icons.gpt,
|
|
414
|
+
exec: (e) => e.actions.addGptWidget.run({}),
|
|
415
|
+
isActive: (e) => e.actions.addGptWidget.isActive(),
|
|
416
|
+
isEnable: (e) => e.actions.addGptWidget.isEnable(),
|
|
417
|
+
};
|
|
406
418
|
exports.wCommandMenuConfig = [
|
|
407
419
|
...exports.wHeadingListConfig.data,
|
|
408
420
|
...exports.wListsListConfig.data,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
body :has(.g-md-resizable_resizing) {
|
|
2
|
+
cursor: col-resize;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.g-md-resizable {
|
|
6
|
+
position: relative;
|
|
7
|
+
}
|
|
8
|
+
.g-md-resizable_resizing .g-md-resizable__resizer-wrapper, .g-md-resizable_hover .g-md-resizable__resizer-wrapper {
|
|
9
|
+
position: absolute;
|
|
10
|
+
z-index: 1;
|
|
11
|
+
top: 0;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
width: 20px;
|
|
16
|
+
height: 100%;
|
|
17
|
+
cursor: col-resize;
|
|
18
|
+
pointer-events: auto;
|
|
19
|
+
}
|
|
20
|
+
.g-md-resizable_resizing .g-md-resizable__resizer-wrapper_left, .g-md-resizable_hover .g-md-resizable__resizer-wrapper_left {
|
|
21
|
+
left: 0;
|
|
22
|
+
}
|
|
23
|
+
.g-md-resizable_resizing .g-md-resizable__resizer-wrapper_right, .g-md-resizable_hover .g-md-resizable__resizer-wrapper_right {
|
|
24
|
+
right: 0;
|
|
25
|
+
}
|
|
26
|
+
.g-md-resizable__resizer {
|
|
27
|
+
opacity: 0;
|
|
28
|
+
}
|
|
29
|
+
.g-md-resizable_resizing .g-md-resizable__resizer, .g-md-resizable_hover .g-md-resizable__resizer {
|
|
30
|
+
box-sizing: content-box;
|
|
31
|
+
width: 4px;
|
|
32
|
+
height: 50px;
|
|
33
|
+
max-height: 50%;
|
|
34
|
+
opacity: 1;
|
|
35
|
+
border-radius: 6px;
|
|
36
|
+
background: rgba(127, 127, 127, 0.8);
|
|
37
|
+
transition: opacity 300ms ease-in 0s;
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ResizableProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
onResizeLeft: (event: React.MouseEvent<HTMLElement>) => void;
|
|
5
|
+
onResizeRight: (event: React.MouseEvent<HTMLElement>) => void;
|
|
6
|
+
hover?: boolean;
|
|
7
|
+
resizing?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const Resizable: React.FC<ResizableProps>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Resizable = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const classname_1 = require("../../../classname");
|
|
7
|
+
const b = (0, classname_1.cn)('resizable');
|
|
8
|
+
const Resizer = ({ onMouseDown, direction }) => (react_1.default.createElement("div", { className: b('resizer-wrapper', { [direction]: true }), role: "button", tabIndex: 0, onMouseDown: onMouseDown },
|
|
9
|
+
react_1.default.createElement("div", { className: b('resizer') })));
|
|
10
|
+
const Resizable = ({ hover, resizing, children, onResizeLeft, onResizeRight, }) => (react_1.default.createElement("div", { className: b({ hover, resizing }) },
|
|
11
|
+
children,
|
|
12
|
+
react_1.default.createElement(Resizer, { onMouseDown: onResizeLeft, direction: "left" }),
|
|
13
|
+
react_1.default.createElement(Resizer, { onMouseDown: onResizeRight, direction: "right" })));
|
|
14
|
+
exports.Resizable = Resizable;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ActionSpec } from '../../../../core';
|
|
2
|
-
export declare const innerActions: Record<"
|
|
2
|
+
export declare const innerActions: Record<"deleteRow" | "deleteColumn" | "setCellLeftAlign" | "setCellCenterAlign" | "setCellRightAlign" | "addRow" | "addColumn", ActionSpec>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.tableCellContextPlugin = void 0;
|
|
4
4
|
const prosemirror_state_1 = require("prosemirror-state");
|
|
5
5
|
const core_1 = require("../../../../../core");
|
|
6
|
+
const yfm_table_1 = require("../../../../../i18n/yfm-table");
|
|
6
7
|
const yfm_1 = require("../../../../yfm");
|
|
7
8
|
const TableSpecs_1 = require("../../TableSpecs");
|
|
8
9
|
const innerActions_1 = require("../../actions/innerActions");
|
|
@@ -17,18 +18,27 @@ const tableCellContextPlugin = () => new prosemirror_state_1.Plugin({
|
|
|
17
18
|
} }))(view);
|
|
18
19
|
return new view_1.TableCellContextView(view, [
|
|
19
20
|
[
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
{
|
|
22
|
+
action: actions.setCellLeftAlign,
|
|
23
|
+
text: (0, yfm_table_1.i18n)('table.menu.cell.align.left'),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
action: actions.setCellCenterAlign,
|
|
27
|
+
text: (0, yfm_table_1.i18n)('table.menu.cell.align.center'),
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
action: actions.setCellRightAlign,
|
|
31
|
+
text: (0, yfm_table_1.i18n)('table.menu.cell.align.right'),
|
|
32
|
+
},
|
|
23
33
|
],
|
|
24
34
|
[
|
|
25
|
-
{ action: actions.addRow, text: 'add
|
|
26
|
-
{ action: actions.deleteRow, text: '
|
|
27
|
-
{ action: actions.addColumn, text: 'add
|
|
28
|
-
{ action: actions.deleteColumn, text: '
|
|
35
|
+
{ action: actions.addRow, text: (0, yfm_table_1.i18n)('table.menu.row.add') },
|
|
36
|
+
{ action: actions.deleteRow, text: (0, yfm_table_1.i18n)('table.menu.row.remove') },
|
|
37
|
+
{ action: actions.addColumn, text: (0, yfm_table_1.i18n)('table.menu.column.add') },
|
|
38
|
+
{ action: actions.deleteColumn, text: (0, yfm_table_1.i18n)('table.menu.column.remove') },
|
|
29
39
|
],
|
|
30
|
-
{ action: actions.convert, text: 'convert
|
|
31
|
-
{ action: actions.deleteTable, text: '
|
|
40
|
+
{ action: actions.convert, text: (0, yfm_table_1.i18n)('table.menu.convert.yfm') },
|
|
41
|
+
{ action: actions.deleteTable, text: (0, yfm_table_1.i18n)('table.menu.table.remove') },
|
|
32
42
|
], [schema.nodes[TableSpecs_1.TableNode.HeaderCell], schema.nodes[TableSpecs_1.TableNode.DataCell]]);
|
|
33
43
|
},
|
|
34
44
|
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.g-md-gpt-dialog-error-screen__content {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
margin-bottom: var(--g-spacing-2);
|
|
5
|
+
}
|
|
6
|
+
.g-md-gpt-dialog-error-screen__icon {
|
|
7
|
+
color: var(--g-color-base-danger-heavy);
|
|
8
|
+
}
|
|
9
|
+
.g-md-gpt-dialog-error-screen__text {
|
|
10
|
+
flex: auto;
|
|
11
|
+
font-size: var(--g-text-body-2-font-size);
|
|
12
|
+
font-weight: 500;
|
|
13
|
+
}
|
|
14
|
+
.g-md-gpt-dialog-error-screen__buttons {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
gap: var(--g-spacing-2);
|
|
18
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
declare type ErrorScreenProps = {
|
|
3
|
+
onRetry: () => void;
|
|
4
|
+
onStartAgain: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const cnGptDialogErrorScreen: import("@bem-react/classname").ClassNameFormatter;
|
|
7
|
+
export declare const ErrorScreen: FC<ErrorScreenProps>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorScreen = exports.cnGptDialogErrorScreen = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const icons_1 = require("@gravity-ui/icons");
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const classname_1 = require("../../../../classname");
|
|
9
|
+
const errors_1 = require("../../../../i18n/gpt/errors");
|
|
10
|
+
const IconRefuge_1 = require("../IconRefuge/IconRefuge");
|
|
11
|
+
exports.cnGptDialogErrorScreen = (0, classname_1.cn)('gpt-dialog-error-screen');
|
|
12
|
+
const ErrorScreen = ({ onRetry, onStartAgain }) => {
|
|
13
|
+
return (react_1.default.createElement("div", { className: (0, exports.cnGptDialogErrorScreen)() },
|
|
14
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialogErrorScreen)('content') },
|
|
15
|
+
react_1.default.createElement(IconRefuge_1.IconRefuge, { containerClassName: (0, exports.cnGptDialogErrorScreen)('icon'), data: icons_1.CircleXmarkFill, refugeSize: 28, size: 16 }),
|
|
16
|
+
react_1.default.createElement("span", { className: (0, exports.cnGptDialogErrorScreen)('text') }, (0, errors_1.i18n)('error-text'))),
|
|
17
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialogErrorScreen)('buttons') },
|
|
18
|
+
react_1.default.createElement(uikit_1.Button, { view: "normal", onClick: onStartAgain }, (0, errors_1.i18n)('start-again-button')),
|
|
19
|
+
react_1.default.createElement(uikit_1.Button, { view: "normal", onClick: onRetry }, (0, errors_1.i18n)('retry-button')))));
|
|
20
|
+
};
|
|
21
|
+
exports.ErrorScreen = ErrorScreen;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare type PromptPreset<PromptData extends unknown = unknown> = {
|
|
2
|
+
display: string;
|
|
3
|
+
key: string;
|
|
4
|
+
data?: PromptData;
|
|
5
|
+
hotKey?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type CommonAnswer = {
|
|
8
|
+
rawText: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type GptRequestData<PromptData extends unknown = unknown> = {
|
|
11
|
+
markup: string;
|
|
12
|
+
customPrompt?: string;
|
|
13
|
+
promptData?: PromptData;
|
|
14
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
.g-md-gpt-dialog__header-top {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
}
|
|
5
|
+
.g-md-gpt-dialog__custom-prompt-input {
|
|
6
|
+
margin-right: var(--g-spacing-2);
|
|
7
|
+
}
|
|
8
|
+
.g-md-gpt-dialog__custom-prompt-input .g-text-input__control {
|
|
9
|
+
font-size: var(--g-text-body-2-font-size);
|
|
10
|
+
}
|
|
11
|
+
.g-md-gpt-dialog__header-bottom {
|
|
12
|
+
margin-top: var(--g-spacing-2);
|
|
13
|
+
}
|
|
14
|
+
.g-md-gpt-dialog__custom-prompt {
|
|
15
|
+
display: flex;
|
|
16
|
+
flex: auto;
|
|
17
|
+
align-items: center;
|
|
18
|
+
}
|
|
19
|
+
.g-md-gpt-dialog__alone-presets-text {
|
|
20
|
+
margin-right: var(--g-spacing-8);
|
|
21
|
+
}
|
|
22
|
+
.g-md-gpt-dialog__alone-presets {
|
|
23
|
+
display: flex;
|
|
24
|
+
flex: auto;
|
|
25
|
+
align-items: center;
|
|
26
|
+
width: 100%;
|
|
27
|
+
font-size: var(--g-text-body-2-font-size);
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
}
|
|
30
|
+
.g-md-gpt-dialog__alone-presets .g-md-gpt-dialog-preset-list {
|
|
31
|
+
flex: auto;
|
|
32
|
+
}
|
|
33
|
+
.g-md-gpt-dialog__answer-title {
|
|
34
|
+
font-size: var(--g-text-body-2-font-size);
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
}
|
|
37
|
+
.g-md-gpt-dialog__gpt-icon {
|
|
38
|
+
margin-right: var(--g-spacing-1);
|
|
39
|
+
}
|
|
40
|
+
.g-md-gpt-dialog__try-again-button {
|
|
41
|
+
margin-right: var(--g-spacing-2);
|
|
42
|
+
}
|
|
43
|
+
.g-md-gpt-dialog__body {
|
|
44
|
+
margin: var(--g-spacing-2) calc(-1 * var(--g-spacing-3));
|
|
45
|
+
padding: var(--g-spacing-4) var(--g-spacing-3);
|
|
46
|
+
border-top: 1px solid var(--g-color-line-generic);
|
|
47
|
+
}
|
|
48
|
+
.g-md-gpt-dialog__answer {
|
|
49
|
+
overflow: auto;
|
|
50
|
+
max-height: 300px;
|
|
51
|
+
}
|
|
52
|
+
.g-md-gpt-dialog__answer-actions {
|
|
53
|
+
display: flex;
|
|
54
|
+
align-items: center;
|
|
55
|
+
}
|
|
56
|
+
.g-md-gpt-dialog__feedback-message {
|
|
57
|
+
margin-left: var(--g-spacing-2);
|
|
58
|
+
}
|
|
59
|
+
.g-md-gpt-dialog__like-button {
|
|
60
|
+
margin-right: var(--g-spacing-2);
|
|
61
|
+
}
|
|
62
|
+
.g-md-gpt-dialog__close-button {
|
|
63
|
+
margin-right: var(--g-spacing-2);
|
|
64
|
+
margin-left: auto;
|
|
65
|
+
}
|
|
66
|
+
.g-md-gpt-dialog__footer {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
margin-top: var(--g-spacing-2);
|
|
70
|
+
}
|
|
71
|
+
.g-md-gpt-dialog__description-alert {
|
|
72
|
+
min-height: 34px;
|
|
73
|
+
margin-top: var(--g-spacing-3);
|
|
74
|
+
padding: var(--g-spacing-1) var(--g-spacing-2);
|
|
75
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { AlertProps } from '@gravity-ui/uikit';
|
|
3
|
+
import type { CommonAnswer, GptRequestData, PromptPreset } from '../ErrorScreen/types';
|
|
4
|
+
export declare type GptDialogProps<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> = {
|
|
5
|
+
markup: string;
|
|
6
|
+
answerRender: (data: AnswerData) => JSX.Element;
|
|
7
|
+
onApplyResult: (markup: string) => void;
|
|
8
|
+
promptPresets?: PromptPreset<PromptData>[];
|
|
9
|
+
disablePromptPresets?: boolean;
|
|
10
|
+
customPromptPlaceholder?: string;
|
|
11
|
+
disabledPromptPlaceholder?: string;
|
|
12
|
+
onCustomPromptApply?: (data: GptRequestData<PromptData>) => Promise<AnswerData | undefined>;
|
|
13
|
+
onPromptPresetClick?: (data: GptRequestData<PromptData>) => Promise<AnswerData | undefined>;
|
|
14
|
+
onTryAgain?: (data: GptRequestData<PromptData>) => Promise<AnswerData | undefined>;
|
|
15
|
+
onLike?: (data: GptRequestData<PromptData>) => Promise<void>;
|
|
16
|
+
onDislike?: (data: GptRequestData<PromptData>) => Promise<void>;
|
|
17
|
+
onClose?: () => void;
|
|
18
|
+
onUpdate?: (value: AnswerData | undefined) => void;
|
|
19
|
+
gptAlertProps?: {
|
|
20
|
+
showedGptAlert: boolean;
|
|
21
|
+
onCloseGptAlert?: () => void;
|
|
22
|
+
message?: string;
|
|
23
|
+
theme?: AlertProps['theme'];
|
|
24
|
+
className?: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export declare const cnGptDialog: import("@bem-react/classname").ClassNameFormatter;
|
|
28
|
+
export declare const GptDialog: FC<GptDialogProps>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GptDialog = exports.cnGptDialog = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
const icons_1 = require("@gravity-ui/icons");
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const classname_1 = require("../../../../classname");
|
|
9
|
+
const dialog_1 = require("../../../../i18n/gpt/dialog");
|
|
10
|
+
const GPT_1 = tslib_1.__importDefault(require("../../../../icons/GPT"));
|
|
11
|
+
const useAutoFocus_1 = require("../../../../react-utils/useAutoFocus");
|
|
12
|
+
const ErrorScreen_1 = require("../ErrorScreen/ErrorScreen");
|
|
13
|
+
const IconRefuge_1 = require("../IconRefuge/IconRefuge");
|
|
14
|
+
const PresetList_1 = require("../PresetList/PresetList");
|
|
15
|
+
const constants_1 = require("../constants");
|
|
16
|
+
const useGpt_1 = require("../hooks/useGpt");
|
|
17
|
+
const useGptHotKeys_1 = require("../hooks/useGptHotKeys");
|
|
18
|
+
const utils_1 = require("../utils");
|
|
19
|
+
const LoadingScreen_1 = require("./LoadingScreen/LoadingScreen");
|
|
20
|
+
exports.cnGptDialog = (0, classname_1.cn)('gpt-dialog');
|
|
21
|
+
const GptDialog = ({ markup, answerRender, promptPresets, disablePromptPresets, customPromptPlaceholder, disabledPromptPlaceholder, onCustomPromptApply, onPromptPresetClick, onTryAgain, onApplyResult, onClose, onLike, onDislike, onUpdate, gptAlertProps, }) => {
|
|
22
|
+
const { answer, customPrompt, loading, mode, feedbackType, feedbackTypeLoading, handleLike, handleDislike, handleCustomPromptUpdate, handleCustomPromptKeyPress, handleCustomPromptApply, handlePresetClick, handleTryAgain, handleFreshStart, handleApplyResult, showAnswer, showError, showAnswerActions, showTryAgainButton, } = (0, useGpt_1.useGpt)({
|
|
23
|
+
markup,
|
|
24
|
+
promptPresets,
|
|
25
|
+
onLike,
|
|
26
|
+
onDislike,
|
|
27
|
+
onCustomPromptApply,
|
|
28
|
+
onPromptPresetClick,
|
|
29
|
+
onTryAgain,
|
|
30
|
+
onApplyResult,
|
|
31
|
+
onUpdate,
|
|
32
|
+
});
|
|
33
|
+
const gptAlert = gptAlertProps;
|
|
34
|
+
const customPromptContainerRef = (0, react_1.useRef)(null);
|
|
35
|
+
const [showedGptAlert, setShowedGptAlert] = (0, react_1.useState)(gptAlert === null || gptAlert === void 0 ? void 0 : gptAlert.showedGptAlert);
|
|
36
|
+
const { alertMessage, alertTheme, alertClassName } = (0, utils_1.getAlertGptInfo)(gptAlert);
|
|
37
|
+
const onCloseAlert = (0, react_1.useCallback)(() => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (gptAlert) {
|
|
40
|
+
gptAlert.showedGptAlert = false;
|
|
41
|
+
}
|
|
42
|
+
(_a = gptAlert === null || gptAlert === void 0 ? void 0 : gptAlert.onCloseGptAlert) === null || _a === void 0 ? void 0 : _a.call(gptAlert);
|
|
43
|
+
setShowedGptAlert(false);
|
|
44
|
+
}, [gptAlert]);
|
|
45
|
+
(0, useAutoFocus_1.useAutoFocus)(customPromptContainerRef, [showAnswer]);
|
|
46
|
+
(0, useGptHotKeys_1.useGptHotKeys)(constants_1.gptHotKeys.tryAgainGpt, handleTryAgain);
|
|
47
|
+
(0, useGptHotKeys_1.useGptHotKeys)(constants_1.gptHotKeys.freshStartGpt, handleFreshStart);
|
|
48
|
+
(0, useGptHotKeys_1.useGptHotKeys)(constants_1.gptHotKeys.applyResultGpt, handleApplyResult);
|
|
49
|
+
const replaceButtonText = (0, utils_1.getDisableReplaceButtonText)(disablePromptPresets);
|
|
50
|
+
const inputPlaceholderText = (0, utils_1.getInputPlaceHolder)(disablePromptPresets, disabledPromptPlaceholder, customPromptPlaceholder);
|
|
51
|
+
const tryAgainButton = (react_1.default.createElement(uikit_1.ActionTooltip, { hotkey: constants_1.gptHotKeys.tryAgainGpt, title: (0, dialog_1.i18n)('try-again') },
|
|
52
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialog)('try-again-button'), view: "normal", size: "m", onClick: handleTryAgain },
|
|
53
|
+
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ArrowRotateLeft, size: 16 }),
|
|
54
|
+
(0, dialog_1.i18n)('try-again'))));
|
|
55
|
+
let content = null;
|
|
56
|
+
if (loading) {
|
|
57
|
+
content = react_1.default.createElement(LoadingScreen_1.LoadingScreen, null);
|
|
58
|
+
}
|
|
59
|
+
else if (showError) {
|
|
60
|
+
content = react_1.default.createElement(ErrorScreen_1.ErrorScreen, { onRetry: handleTryAgain, onStartAgain: handleFreshStart });
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
content = (react_1.default.createElement(react_1.default.Fragment, null,
|
|
64
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('header') },
|
|
65
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('header-top') },
|
|
66
|
+
react_1.default.createElement(IconRefuge_1.IconRefuge, { containerClassName: (0, exports.cnGptDialog)('gpt-icon'), data: GPT_1.default, refugeSize: 28, size: 16 }),
|
|
67
|
+
(mode === 'only-custom' || mode === 'custom-and-presets') &&
|
|
68
|
+
(showAnswer ? (react_1.default.createElement("span", { className: (0, exports.cnGptDialog)('answer-title') }, (0, dialog_1.i18n)('answer-title'))) : (react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('custom-prompt') },
|
|
69
|
+
react_1.default.createElement(uikit_1.TextInput, { controlRef: customPromptContainerRef, view: "clear", size: "m", className: (0, exports.cnGptDialog)('custom-prompt-input'), placeholder: inputPlaceholderText, onKeyPress: handleCustomPromptKeyPress, onUpdate: handleCustomPromptUpdate }),
|
|
70
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialog)('custom-prompt-ask-button'), view: "normal", size: "s", disabled: !customPrompt, onClick: handleCustomPromptApply },
|
|
71
|
+
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ArrowRight, size: 16 }))))),
|
|
72
|
+
mode === 'only-presets' && (react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('alone-presets') },
|
|
73
|
+
react_1.default.createElement("span", { className: (0, exports.cnGptDialog)('alone-presets-text') }, (0, dialog_1.i18n)('only-presets-title'))))),
|
|
74
|
+
(mode === 'custom-and-presets' || mode === 'only-presets') &&
|
|
75
|
+
((showTryAgainButton && (react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('header-bottom') },
|
|
76
|
+
tryAgainButton,
|
|
77
|
+
react_1.default.createElement(uikit_1.ActionTooltip, { title: (0, dialog_1.i18n)('fresh-start-button'), hotkey: constants_1.gptHotKeys.freshStartGpt },
|
|
78
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialog)('back-to-start'), view: "normal", size: "m", onClick: handleFreshStart }, (0, dialog_1.i18n)('fresh-start-button')))))) ||
|
|
79
|
+
(!disablePromptPresets && (react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('header-bottom') },
|
|
80
|
+
react_1.default.createElement(PresetList_1.PresetList, { disablePromptPresets: disablePromptPresets, promptPresets: promptPresets, onPresetClick: handlePresetClick })))) ||
|
|
81
|
+
(disablePromptPresets && showedGptAlert && (react_1.default.createElement(uikit_1.Alert, { theme: alertTheme, message: alertMessage, align: "center", className: (0, exports.cnGptDialog)('description-alert', alertClassName), onClose: onCloseAlert }))))),
|
|
82
|
+
showAnswer && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
83
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('body') },
|
|
84
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('answer') }, answerRender(answer))),
|
|
85
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('footer') },
|
|
86
|
+
showAnswerActions && (react_1.default.createElement("div", { className: (0, exports.cnGptDialog)('answer-actions') },
|
|
87
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialog)('like-button'), view: "normal", size: "m", onClick: handleLike, selected: feedbackType === 'like', loading: feedbackTypeLoading === 'like' },
|
|
88
|
+
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ThumbsUp, size: 16 })),
|
|
89
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialog)('dislike-button'), view: "normal", size: "m", onClick: handleDislike, selected: feedbackType === 'dislike', loading: feedbackTypeLoading === 'dislike' },
|
|
90
|
+
react_1.default.createElement(uikit_1.Icon, { data: icons_1.ThumbsDown, size: 16 })),
|
|
91
|
+
feedbackType && (react_1.default.createElement("span", { className: (0, exports.cnGptDialog)('feedback-message') }, (0, dialog_1.i18n)('feedback-message'))))),
|
|
92
|
+
react_1.default.createElement(uikit_1.ActionTooltip, { title: (0, dialog_1.i18n)('close-button'), hotkey: constants_1.gptHotKeys.closeGpt },
|
|
93
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialog)('close-button'), view: "flat", size: "m", onClick: onClose }, (0, dialog_1.i18n)('close-button'))),
|
|
94
|
+
react_1.default.createElement(uikit_1.ActionTooltip, { title: replaceButtonText, hotkey: constants_1.gptHotKeys.applyResultGpt },
|
|
95
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialog)('apply-button'), view: "action", size: "m", onClick: handleApplyResult }, replaceButtonText)))))));
|
|
96
|
+
}
|
|
97
|
+
return react_1.default.createElement("div", { className: (0, exports.cnGptDialog)() },
|
|
98
|
+
" ",
|
|
99
|
+
content,
|
|
100
|
+
" ");
|
|
101
|
+
};
|
|
102
|
+
exports.GptDialog = GptDialog;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.g-md-gpt-dialog-loading-screen__header {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
margin-bottom: 8px;
|
|
5
|
+
}
|
|
6
|
+
.g-md-gpt-dialog-loading-screen__icon {
|
|
7
|
+
margin-right: 4px;
|
|
8
|
+
}
|
|
9
|
+
.g-md-gpt-dialog-loading-screen__text {
|
|
10
|
+
margin-right: 8px;
|
|
11
|
+
font-size: var(--g-text-body-2-font-size);
|
|
12
|
+
font-weight: 500;
|
|
13
|
+
}
|
|
14
|
+
.g-md-gpt-dialog-loading-screen__skeleton-small-button {
|
|
15
|
+
width: 90px;
|
|
16
|
+
height: 28px;
|
|
17
|
+
margin-right: 8px;
|
|
18
|
+
}
|
|
19
|
+
.g-md-gpt-dialog-loading-screen__skeleton-medium-button {
|
|
20
|
+
width: 120px;
|
|
21
|
+
height: 28px;
|
|
22
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LoadingScreen = exports.cnGptDialogLoadingScreen = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
|
+
const classname_1 = require("@bem-react/classname");
|
|
7
|
+
const uikit_1 = require("@gravity-ui/uikit");
|
|
8
|
+
const loading_1 = require("../../../../../i18n/gpt/loading");
|
|
9
|
+
const GPTLoading_1 = tslib_1.__importDefault(require("../../../../../icons/GPTLoading"));
|
|
10
|
+
const IconRefuge_1 = require("../../IconRefuge/IconRefuge");
|
|
11
|
+
exports.cnGptDialogLoadingScreen = (0, classname_1.cn)('gpt-dialog-loading-screen');
|
|
12
|
+
const LoadingScreen = () => {
|
|
13
|
+
return (react_1.default.createElement("div", { className: (0, exports.cnGptDialogLoadingScreen)() },
|
|
14
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialogLoadingScreen)('header') },
|
|
15
|
+
react_1.default.createElement(IconRefuge_1.IconRefuge, { containerClassName: (0, exports.cnGptDialogLoadingScreen)('icon'), data: GPTLoading_1.default, refugeSize: 28, size: 20 }),
|
|
16
|
+
react_1.default.createElement("span", { className: (0, exports.cnGptDialogLoadingScreen)('text') }, (0, loading_1.i18n)('loading-text'))),
|
|
17
|
+
react_1.default.createElement("div", { className: (0, exports.cnGptDialogLoadingScreen)('skeleton') },
|
|
18
|
+
react_1.default.createElement(uikit_1.Skeleton, { className: (0, exports.cnGptDialogLoadingScreen)('skeleton-small-button') }),
|
|
19
|
+
react_1.default.createElement(uikit_1.Skeleton, { className: (0, exports.cnGptDialogLoadingScreen)('skeleton-medium-button') }))));
|
|
20
|
+
};
|
|
21
|
+
exports.LoadingScreen = LoadingScreen;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const cnIconRefuge: import("@bem-react/classname").ClassNameFormatter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { IconRefugeProps } from './IconRefuge.types';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a div wrapper above the icon, which sets the min-width and min-height
|
|
5
|
+
* equal to its refugeSize prop, puts the original icon in the middle and
|
|
6
|
+
* proxies the rest of the propses to it.
|
|
7
|
+
*
|
|
8
|
+
* The component is made in order to add margins to icons that have
|
|
9
|
+
* margins are indented, but their svg exactly wrap around the edges of the image
|
|
10
|
+
*
|
|
11
|
+
* It seems that all icons will be square, if not, then you can simply add
|
|
12
|
+
* refugeWidth and refugeHeight
|
|
13
|
+
*/
|
|
14
|
+
export declare const IconRefuge: FC<IconRefugeProps>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IconRefuge = 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 IconRefuge_classname_1 = require("./IconRefuge.classname");
|
|
8
|
+
/**
|
|
9
|
+
* Creates a div wrapper above the icon, which sets the min-width and min-height
|
|
10
|
+
* equal to its refugeSize prop, puts the original icon in the middle and
|
|
11
|
+
* proxies the rest of the propses to it.
|
|
12
|
+
*
|
|
13
|
+
* The component is made in order to add margins to icons that have
|
|
14
|
+
* margins are indented, but their svg exactly wrap around the edges of the image
|
|
15
|
+
*
|
|
16
|
+
* It seems that all icons will be square, if not, then you can simply add
|
|
17
|
+
* refugeWidth and refugeHeight
|
|
18
|
+
*/
|
|
19
|
+
const IconRefuge = (_a) => {
|
|
20
|
+
var { refugeSize, containerClassName, containerStyle, widthOnly, inlineIcon, title, 'aria-label': ariaLabel } = _a, props = tslib_1.__rest(_a, ["refugeSize", "containerClassName", "containerStyle", "widthOnly", "inlineIcon", "title", 'aria-label']);
|
|
21
|
+
if (props.size === refugeSize && !title && !ariaLabel && !containerStyle) {
|
|
22
|
+
return react_1.default.createElement(uikit_1.Icon, Object.assign({}, props));
|
|
23
|
+
}
|
|
24
|
+
return (react_1.default.createElement("div", { className: (0, IconRefuge_classname_1.cnIconRefuge)({ inline: inlineIcon }, containerClassName), title: title, "aria-label": ariaLabel, style: Object.assign({ minWidth: refugeSize, minHeight: widthOnly ? undefined : refugeSize }, containerStyle) },
|
|
25
|
+
react_1.default.createElement(uikit_1.Icon, Object.assign({ size: refugeSize }, props))));
|
|
26
|
+
};
|
|
27
|
+
exports.IconRefuge = IconRefuge;
|
|
28
|
+
exports.IconRefuge.displayName = 'Icon';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IconRefuge = void 0;
|
|
4
|
+
var IconRefuge_1 = require("./IconRefuge");
|
|
5
|
+
Object.defineProperty(exports, "IconRefuge", { enumerable: true, get: function () { return IconRefuge_1.IconRefuge; } });
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { GptDialogProps } from '../GptDialog/GptDialog';
|
|
3
|
+
export declare type PresetListProps<PromptData extends unknown = unknown> = {
|
|
4
|
+
disablePromptPresets: GptDialogProps['disablePromptPresets'];
|
|
5
|
+
promptPresets: GptDialogProps['promptPresets'];
|
|
6
|
+
onPresetClick: (data: PromptData) => void;
|
|
7
|
+
};
|
|
8
|
+
export declare const cnGptDialogPresetList: import("@bem-react/classname").ClassNameFormatter;
|
|
9
|
+
export declare const PresetList: FC<PresetListProps>;
|