@gravity-ui/markdown-editor 13.17.1 → 13.18.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 +4 -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/Clipboard/clipboard.js +4 -1
- package/build/cjs/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
- 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 +167 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useGpt.d.ts +27 -0
- package/build/cjs/extensions/yfm/GPT/hooks/useGpt.js +155 -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/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/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/useNodeResizing.js +7 -2
- 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/Clipboard/clipboard.js +4 -1
- package/build/esm/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
- 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 +163 -0
- package/build/esm/extensions/yfm/GPT/hooks/useGpt.d.ts +27 -0
- package/build/esm/extensions/yfm/GPT/hooks/useGpt.js +151 -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/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/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/useNodeResizing.js +7 -2
- 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 +146 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
1
3
|
# @gravity-ui/markdown-editor · [](https://www.npmjs.com/package/@gravity-ui/markdown-editor) [](https://github.com/gravity-ui/markdown-editor/actions/workflows/ci.yml?query=branch:main) [](https://github.com/gravity-ui/markdown-editor/actions/workflows/release.yml?query=branch:main) [](https://preview.gravity-ui.com/md-editor/)
|
|
2
4
|
|
|
3
5
|
## Markdown wysiwyg and markup editor
|
|
@@ -56,6 +58,8 @@ Read more:
|
|
|
56
58
|
- [How to add Latex extension](docs/how-to-connect-latex-extension.md)
|
|
57
59
|
- [How to add Mermaid extension](docs/how-to-connect-mermaid-extension.md)
|
|
58
60
|
- [How to write extension](docs/how-to-create-extension.md)
|
|
61
|
+
- [How to add GPT extension](docs/how-to-connect-gpt-extensions.md)
|
|
62
|
+
|
|
59
63
|
|
|
60
64
|
### i18n
|
|
61
65
|
|
|
@@ -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,
|
|
@@ -92,7 +92,10 @@ const clipboard = ({ textParser, mdParser, serializer, pasteFileHandler, }) => {
|
|
|
92
92
|
const codeType = (0, code_1.isInsideCode)(view.state);
|
|
93
93
|
if (codeType) {
|
|
94
94
|
const schema = view.state.schema;
|
|
95
|
-
|
|
95
|
+
const insideCodeData = e.clipboardData.getData(utils_1.DataTransferType.Text);
|
|
96
|
+
view.dispatch((0, core_1.trackTransactionMetrics)(view.state.tr.replaceSelectionWith(schema.text(codeType === 'inline'
|
|
97
|
+
? insideCodeData.trim()
|
|
98
|
+
: insideCodeData)), 'paste', { clipboardDataFormat: utils_1.DataTransferType.Text, code: codeType }));
|
|
96
99
|
isPasteHandled = true;
|
|
97
100
|
}
|
|
98
101
|
else {
|
|
@@ -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>;
|
|
@@ -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 uikit_1 = require("@gravity-ui/uikit");
|
|
7
|
+
const classname_1 = require("../../../../../classname");
|
|
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>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PresetList = exports.cnGptDialogPresetList = 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 classname_1 = require("../../../../classname");
|
|
8
|
+
const dialog_1 = require("../../../../i18n/gpt/dialog");
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
|
+
const useGptHotKeys_1 = require("../hooks/useGptHotKeys");
|
|
11
|
+
const usePresetList_1 = require("../hooks/usePresetList");
|
|
12
|
+
exports.cnGptDialogPresetList = (0, classname_1.cn)('gpt-dialog-preset-list');
|
|
13
|
+
const PresetItem = ({ preset, onPresetClick, disablePromptPresets, hotKey }) => {
|
|
14
|
+
(0, useGptHotKeys_1.useGptHotKeys)(hotKey, () => {
|
|
15
|
+
onPresetClick(preset.data);
|
|
16
|
+
}, { enableOnFormTags: true, enableOnContentEditable: true });
|
|
17
|
+
return (react_1.default.createElement(uikit_1.ActionTooltip, { title: preset.display, hotkey: hotKey },
|
|
18
|
+
react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialogPresetList)('preset'), view: "normal", size: "m", disabled: disablePromptPresets, onClick: () => onPresetClick(preset.data) }, preset.display)));
|
|
19
|
+
};
|
|
20
|
+
const PresetList = ({ disablePromptPresets, promptPresets, onPresetClick, }) => {
|
|
21
|
+
const { presetsContainerRef, visiblePresets, hiddenPresets, showMoreButton, measured } = (0, usePresetList_1.usePresetList)({
|
|
22
|
+
promptPresets,
|
|
23
|
+
onPresetClick,
|
|
24
|
+
});
|
|
25
|
+
return (react_1.default.createElement("div", { className: (0, exports.cnGptDialogPresetList)({ measured }), ref: presetsContainerRef },
|
|
26
|
+
visiblePresets.map((preset, index) => (react_1.default.createElement(PresetItem, { preset: preset, key: preset.display, hotKey: preset.hotKey || constants_1.gptHotKeys.presetsKey(String(index + 1)), disablePromptPresets: disablePromptPresets, onPresetClick: onPresetClick }))),
|
|
27
|
+
showMoreButton && (react_1.default.createElement(uikit_1.DropdownMenu, { switcherWrapperClassName: (0, exports.cnGptDialogPresetList)('more-button-wrapper'), switcher: react_1.default.createElement(uikit_1.Button, { className: (0, exports.cnGptDialogPresetList)('more-button'), view: "normal", size: "m" }, (0, dialog_1.i18n)('more')), items: hiddenPresets }))));
|
|
28
|
+
};
|
|
29
|
+
exports.PresetList = PresetList;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showGptWidget = void 0;
|
|
4
|
+
const commands_1 = require("./commands");
|
|
5
|
+
const showGptWidget = (_deps) => ({
|
|
6
|
+
isActive() {
|
|
7
|
+
return false;
|
|
8
|
+
},
|
|
9
|
+
isEnable() {
|
|
10
|
+
return true;
|
|
11
|
+
},
|
|
12
|
+
run: commands_1.runGpt,
|
|
13
|
+
});
|
|
14
|
+
exports.showGptWidget = showGptWidget;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runGpt = void 0;
|
|
4
|
+
const prosemirror_state_1 = require("prosemirror-state");
|
|
5
|
+
const plugin_1 = require("./plugin");
|
|
6
|
+
const runGpt = (state, dispatch) => {
|
|
7
|
+
const { selection: sel } = state;
|
|
8
|
+
const meta = { action: 'show', from: sel.from, to: sel.to };
|
|
9
|
+
const tr = state.tr.setMeta(plugin_1.pluginKey, meta);
|
|
10
|
+
dispatch === null || dispatch === void 0 ? void 0 : dispatch(tr.setSelection(prosemirror_state_1.TextSelection.create(tr.doc, sel.to)));
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
exports.runGpt = runGpt;
|