@gravity-ui/markdown-editor 13.17.1 → 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/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 +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/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/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/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 +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/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/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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removeColumn = void 0;
|
|
4
|
-
const
|
|
4
|
+
const table_desc_1 = require("../table-desc");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const removeColumn = (state, dispatch, _, attrs = {}) => {
|
|
7
7
|
const { tablePos, columnNumber } = attrs;
|
|
@@ -12,30 +12,28 @@ const removeColumn = (state, dispatch, _, attrs = {}) => {
|
|
|
12
12
|
if (tablePos < 0 || columnNumber < 0)
|
|
13
13
|
return false;
|
|
14
14
|
const tableNode = state.doc.nodeAt(tablePos);
|
|
15
|
-
if (!tableNode || tableNode.nodeSize <= 2 || !(0,
|
|
15
|
+
if (!tableNode || tableNode.nodeSize <= 2 || !(0, utils_1.isTableNode)(tableNode))
|
|
16
16
|
return false;
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
17
|
+
const tableDesc = table_desc_1.TableDesc.create(tableNode);
|
|
18
|
+
if (!tableDesc)
|
|
19
19
|
return false;
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
if (!tableDesc ||
|
|
21
|
+
// there is one column left
|
|
22
|
+
tableDesc.cols < 2 ||
|
|
23
|
+
tableDesc.cols <= columnNumber ||
|
|
24
|
+
!tableDesc.isSafeColumn(columnNumber))
|
|
22
25
|
return false;
|
|
23
26
|
if (dispatch) {
|
|
24
27
|
const { tr } = state;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const to = from + cellNode.nodeSize;
|
|
35
|
-
tr.delete(tr.mapping.map(from), tr.mapping.map(to));
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
28
|
+
const pos = tableDesc.getRelativePosForColumn(columnNumber);
|
|
29
|
+
for (const item of pos) {
|
|
30
|
+
if (item.type === 'real') {
|
|
31
|
+
let { from, to } = item;
|
|
32
|
+
from += tablePos;
|
|
33
|
+
to += tablePos;
|
|
34
|
+
tr.delete(tr.mapping.map(from), tr.mapping.map(to));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
39
37
|
dispatch(tr);
|
|
40
38
|
}
|
|
41
39
|
return true;
|
|
@@ -5,7 +5,7 @@ const prosemirror_model_1 = require("prosemirror-model");
|
|
|
5
5
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
6
6
|
const __1 = require("..");
|
|
7
7
|
const core_1 = require("../../core");
|
|
8
|
-
const
|
|
8
|
+
const table_desc_1 = require("../table-desc");
|
|
9
9
|
const removeRow = (state, dispatch, _, attrs = {}) => {
|
|
10
10
|
var _a;
|
|
11
11
|
const { tablePos, rowNumber } = attrs;
|
|
@@ -14,17 +14,20 @@ const removeRow = (state, dispatch, _, attrs = {}) => {
|
|
|
14
14
|
const tableNode = (_a = (0, prosemirror_utils_1.findParentNodeClosestToPos)(state.doc.resolve(tablePos + 1), __1.isTableNode)) === null || _a === void 0 ? void 0 : _a.node;
|
|
15
15
|
if (!tableNode)
|
|
16
16
|
return false;
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
const parentRow = parentRows[rowNumber];
|
|
20
|
-
if (!parentRows.length || !parentBody) {
|
|
17
|
+
const tableDesc = table_desc_1.TableDesc.create(tableNode);
|
|
18
|
+
if (!tableDesc || rowNumber >= tableDesc.rows)
|
|
21
19
|
return false;
|
|
22
|
-
|
|
23
|
-
if ((0, utils_1.findChildTableRows)(parentBody.node).length < 2) {
|
|
24
|
-
// there is one row left
|
|
20
|
+
if (!tableDesc.isSafeRow(rowNumber))
|
|
25
21
|
return false;
|
|
22
|
+
if (dispatch) {
|
|
23
|
+
let { from, to } = tableDesc.getRelativePosForRow(rowNumber);
|
|
24
|
+
from += tablePos;
|
|
25
|
+
to += tablePos;
|
|
26
|
+
dispatch((0, core_1.trackTransactionMetrics)(state.tr.replaceWith(from, to, prosemirror_model_1.Fragment.empty), 'removeRow', {
|
|
27
|
+
rows: tableDesc.rows,
|
|
28
|
+
cols: tableDesc.cols,
|
|
29
|
+
}));
|
|
26
30
|
}
|
|
27
|
-
dispatch === null || dispatch === void 0 ? void 0 : dispatch((0, core_1.trackTransactionMetrics)(state.tr.replaceWith(tablePos + parentRow.pos, tablePos + parentRow.pos + parentRow.node.nodeSize + 1, prosemirror_model_1.Fragment.empty), 'removeRow', { rows: parentRows.length, cols: parentRow.node.childCount }));
|
|
28
31
|
return true;
|
|
29
32
|
};
|
|
30
33
|
exports.removeRow = removeRow;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Node } from 'prosemirror-model';
|
|
2
|
+
declare type TableCellRealDesc = {
|
|
3
|
+
type: 'real';
|
|
4
|
+
offset: number;
|
|
5
|
+
node: Node;
|
|
6
|
+
colspan?: number;
|
|
7
|
+
rowspan?: number;
|
|
8
|
+
};
|
|
9
|
+
declare type TableCellVirtualDesc = {
|
|
10
|
+
type: 'virtual';
|
|
11
|
+
/** Index of real cell, that prodeced this virtual cell */
|
|
12
|
+
colspan?: [number, number];
|
|
13
|
+
/** Index of real cell, that prodeced this virtual cell */
|
|
14
|
+
rowspan?: [number, number];
|
|
15
|
+
};
|
|
16
|
+
declare type Pos = {
|
|
17
|
+
from: number;
|
|
18
|
+
to: number;
|
|
19
|
+
};
|
|
20
|
+
export declare type CellPos = ({
|
|
21
|
+
type: 'real';
|
|
22
|
+
} & Pos) | {
|
|
23
|
+
type: 'virtual';
|
|
24
|
+
closestPos: number;
|
|
25
|
+
};
|
|
26
|
+
declare type TableCellDesc = TableCellRealDesc | TableCellVirtualDesc;
|
|
27
|
+
declare type TableRowDesc = {
|
|
28
|
+
node: Node;
|
|
29
|
+
cells: TableCellDesc[];
|
|
30
|
+
offset: number;
|
|
31
|
+
colspan?: boolean;
|
|
32
|
+
rowspan?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare class TableDesc {
|
|
35
|
+
readonly rows: number;
|
|
36
|
+
readonly cols: number;
|
|
37
|
+
readonly rowsDesc: readonly TableRowDesc[];
|
|
38
|
+
readonly baseOffset: number;
|
|
39
|
+
private static __cache;
|
|
40
|
+
static create(table: Node): TableDesc | null;
|
|
41
|
+
private constructor();
|
|
42
|
+
rowHasVirtualCells(rowIndex: number): boolean;
|
|
43
|
+
columnHasVirtualCells(columnIndex: number): boolean;
|
|
44
|
+
isSafeColumn(columnIndex: number): boolean;
|
|
45
|
+
isSafeRow(rowIndex: number): boolean;
|
|
46
|
+
getOffsetForRow(rowIndex: number): number;
|
|
47
|
+
getRelativePosForRow(rowIndex: number): Pos;
|
|
48
|
+
getRelativePosForCell(rowIndex: number, columnIndex: number): CellPos;
|
|
49
|
+
getRelativePosForColumn(columnIndex: number): CellPos[];
|
|
50
|
+
getCellNodeType(): import("prosemirror-model").NodeType;
|
|
51
|
+
getRowNodeType(): import("prosemirror-model").NodeType;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TableDesc = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const is_number_1 = tslib_1.__importDefault(require("is-number"));
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
class TableDesc {
|
|
8
|
+
constructor(
|
|
9
|
+
/* eslint-disable @typescript-eslint/parameter-properties */
|
|
10
|
+
rows, cols, rowsDesc, baseOffset) {
|
|
11
|
+
this.rows = rows;
|
|
12
|
+
this.cols = cols;
|
|
13
|
+
this.rowsDesc = rowsDesc;
|
|
14
|
+
this.baseOffset = baseOffset;
|
|
15
|
+
}
|
|
16
|
+
static create(table) {
|
|
17
|
+
if (this.__cache.has(table))
|
|
18
|
+
return this.__cache.get(table);
|
|
19
|
+
if (!(0, utils_1.isTableNode)(table))
|
|
20
|
+
return null;
|
|
21
|
+
const tbody = table.lastChild;
|
|
22
|
+
if (!tbody || !(0, utils_1.isTableBodyNode)(tbody))
|
|
23
|
+
return null;
|
|
24
|
+
// table –> tbody -> ...
|
|
25
|
+
const baseOffset = 2;
|
|
26
|
+
const rows = [];
|
|
27
|
+
tbody.forEach((trow, offset) => {
|
|
28
|
+
rows.push({ node: trow, offset, cells: [] });
|
|
29
|
+
});
|
|
30
|
+
tbody.forEach((trow, _1, trowIndex) => {
|
|
31
|
+
trow.forEach((tcell, offset, tcellRealIndex) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const rowDesc = rows[trowIndex];
|
|
34
|
+
let tcellIndex = tcellRealIndex;
|
|
35
|
+
while (rowDesc.cells[tcellIndex]) {
|
|
36
|
+
tcellIndex++;
|
|
37
|
+
}
|
|
38
|
+
const cellDesc = (rowDesc.cells[tcellIndex] = {
|
|
39
|
+
type: 'real',
|
|
40
|
+
node: tcell,
|
|
41
|
+
offset,
|
|
42
|
+
});
|
|
43
|
+
const map = [trowIndex, tcellIndex];
|
|
44
|
+
if ((0, is_number_1.default)(tcell.attrs['colspan'])) {
|
|
45
|
+
rowDesc.colspan = true;
|
|
46
|
+
const colspan = (cellDesc.colspan = parseInt(tcell.attrs['colspan'], 10));
|
|
47
|
+
for (let i = 1; i < colspan; i++) {
|
|
48
|
+
rowDesc.cells[tcellIndex + i] = {
|
|
49
|
+
type: 'virtual',
|
|
50
|
+
colspan: map,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if ((0, is_number_1.default)(tcell.attrs['rowspan'])) {
|
|
55
|
+
rowDesc.rowspan = true;
|
|
56
|
+
const rowspan = (cellDesc.rowspan = parseInt(tcell.attrs['rowspan'], 10));
|
|
57
|
+
for (let i = 1; i < rowspan; i++) {
|
|
58
|
+
const colspan = (_a = cellDesc.colspan) !== null && _a !== void 0 ? _a : 1;
|
|
59
|
+
for (let j = 0; j < colspan; j++)
|
|
60
|
+
rows[trowIndex + i].cells[tcellIndex + j] = {
|
|
61
|
+
type: 'virtual',
|
|
62
|
+
rowspan: map,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
const desc = new this(rows.length, rows[0].cells.length, rows, baseOffset);
|
|
69
|
+
this.__cache.set(table, desc);
|
|
70
|
+
return desc;
|
|
71
|
+
}
|
|
72
|
+
rowHasVirtualCells(rowIndex) {
|
|
73
|
+
var _a;
|
|
74
|
+
return (_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.some((cell) => cell.type === 'virtual');
|
|
75
|
+
}
|
|
76
|
+
columnHasVirtualCells(columnIndex) {
|
|
77
|
+
return this.rowsDesc.some((row) => { var _a; return ((_a = row.cells[columnIndex]) === null || _a === void 0 ? void 0 : _a.type) === 'virtual'; });
|
|
78
|
+
}
|
|
79
|
+
isSafeColumn(columnIndex) {
|
|
80
|
+
return this.rowsDesc.every((row) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const cell = row.cells[columnIndex];
|
|
83
|
+
if (cell.type === 'real' && (!cell.colspan || cell.colspan === 1))
|
|
84
|
+
return true;
|
|
85
|
+
if (cell.type === 'virtual' && ((_a = cell.rowspan) === null || _a === void 0 ? void 0 : _a[1]) === columnIndex)
|
|
86
|
+
return true;
|
|
87
|
+
return false;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
isSafeRow(rowIndex) {
|
|
91
|
+
var _a;
|
|
92
|
+
return (_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.every((cell) => {
|
|
93
|
+
var _a;
|
|
94
|
+
if (cell.type === 'real' && (!cell.rowspan || cell.rowspan === 1))
|
|
95
|
+
return true;
|
|
96
|
+
if (cell.type === 'virtual' && ((_a = cell.colspan) === null || _a === void 0 ? void 0 : _a[0]) === rowIndex)
|
|
97
|
+
return true;
|
|
98
|
+
return false;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
getOffsetForRow(rowIndex) {
|
|
102
|
+
var _a;
|
|
103
|
+
return this.baseOffset + ((_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.offset);
|
|
104
|
+
}
|
|
105
|
+
getRelativePosForRow(rowIndex) {
|
|
106
|
+
const from = this.getOffsetForRow(rowIndex);
|
|
107
|
+
const to = from + this.rowsDesc[rowIndex].node.nodeSize;
|
|
108
|
+
return { from, to };
|
|
109
|
+
}
|
|
110
|
+
getRelativePosForCell(rowIndex, columnIndex) {
|
|
111
|
+
var _a;
|
|
112
|
+
const cell = (_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells[columnIndex];
|
|
113
|
+
const rowOffset = this.getOffsetForRow(rowIndex);
|
|
114
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.type) === 'real') {
|
|
115
|
+
// 1 – open boundary for row node
|
|
116
|
+
const from = rowOffset + 1 + cell.offset;
|
|
117
|
+
const to = from + cell.node.nodeSize;
|
|
118
|
+
return { type: 'real', from, to };
|
|
119
|
+
}
|
|
120
|
+
if ((cell === null || cell === void 0 ? void 0 : cell.type) === 'virtual') {
|
|
121
|
+
let index = columnIndex;
|
|
122
|
+
while (--index >= 0) {
|
|
123
|
+
const cell = this.rowsDesc[rowIndex].cells[index];
|
|
124
|
+
if (cell.type === 'real') {
|
|
125
|
+
const closest = rowOffset + 1 + cell.offset + cell.node.nodeSize;
|
|
126
|
+
return { type: 'virtual', closestPos: closest };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return { type: 'virtual', closestPos: rowOffset + 1 };
|
|
130
|
+
}
|
|
131
|
+
throw new Error(`Impossible to calculate offset for cell with position [${rowIndex},${columnIndex}]`);
|
|
132
|
+
}
|
|
133
|
+
getRelativePosForColumn(columnIndex) {
|
|
134
|
+
const ranges = [];
|
|
135
|
+
for (let i = 0; i < this.rows; i++) {
|
|
136
|
+
ranges.push(this.getRelativePosForCell(i, columnIndex));
|
|
137
|
+
}
|
|
138
|
+
return ranges;
|
|
139
|
+
}
|
|
140
|
+
getCellNodeType() {
|
|
141
|
+
const isRealCell = (cell) => cell.type === 'real';
|
|
142
|
+
return this.rowsDesc[0].cells.find(isRealCell).node.type;
|
|
143
|
+
}
|
|
144
|
+
getRowNodeType() {
|
|
145
|
+
return this.rowsDesc[0].node.type;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.TableDesc = TableDesc;
|
|
149
|
+
TableDesc.__cache = new WeakMap();
|
|
@@ -25,7 +25,7 @@ export declare const findChildTableBody: (node: PmNode) => {
|
|
|
25
25
|
node: PmNode;
|
|
26
26
|
pos: number;
|
|
27
27
|
}[];
|
|
28
|
-
export declare const getTableDimensions: (node: PmNode
|
|
28
|
+
export declare const getTableDimensions: (node: PmNode) => {
|
|
29
29
|
rows: number;
|
|
30
30
|
cols: number;
|
|
31
31
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.atEndOfCell = exports.getTableDimensions = exports.findChildTableBody = exports.findChildTableCells = exports.findChildTableRows = exports.findParentTableCellFromPos = exports.findParentTableRowFromPos = exports.findParentTableBodyFromPos = exports.findParentTableFromPos = exports.findParentTableCell = exports.findParentTableRow = exports.findParentTableBody = exports.findParentTable = exports.isTableCellNode = exports.isTableRowNode = exports.isTableBodyNode = exports.isTableNode = void 0;
|
|
4
|
-
const
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const is_number_1 = tslib_1.__importDefault(require("is-number"));
|
|
5
6
|
const prosemirror_utils_1 = require("prosemirror-utils");
|
|
6
7
|
const selection_1 = require("../utils/selection");
|
|
7
8
|
const const_1 = require("./const");
|
|
@@ -32,17 +33,23 @@ exports.findChildTableCells = findChildTableCells;
|
|
|
32
33
|
const findChildTableBody = (node) => (0, prosemirror_utils_1.findChildren)(node, exports.isTableBodyNode);
|
|
33
34
|
exports.findChildTableBody = findChildTableBody;
|
|
34
35
|
const getTableDimensions = (node) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
rows
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
let rows = 0, cols = 0;
|
|
37
|
+
const tbody = node.firstChild;
|
|
38
|
+
tbody === null || tbody === void 0 ? void 0 : tbody.forEach((trow, _1, trowIndex) => {
|
|
39
|
+
rows++;
|
|
40
|
+
if (trowIndex === 0) {
|
|
41
|
+
trow.forEach((tcell, _2) => {
|
|
42
|
+
const cellAttrs = tcell.attrs;
|
|
43
|
+
if ((0, is_number_1.default)(cellAttrs['colspan'])) {
|
|
44
|
+
cols += parseInt(cellAttrs['colspan'], 10);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
cols++;
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return { rows, cols };
|
|
46
53
|
};
|
|
47
54
|
exports.getTableDimensions = getTableDimensions;
|
|
48
55
|
function atEndOfCell(view, dir) {
|
package/build/cjs/version.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
/** During build process, the current version will be injected here */
|
|
5
|
-
exports.VERSION = typeof '13.
|
|
5
|
+
exports.VERSION = typeof '13.18.0' !== 'undefined' ? '13.18.0' : 'unknown';
|
|
@@ -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,4 +1,5 @@
|
|
|
1
1
|
import { BoldIcon, CheckListIcon, CodeBlockIcon, CodeInlineIcon, CutIcon, EmojiIcon, FileIcon, FoldingHeadingIcon, FunctionBlockIcon, FunctionInlineIcon, HRuleIcon, Heading1Icon, Heading2Icon, Heading3Icon, Heading4Icon, Heading5Icon, Heading6Icon, HeadingIcon, HtmlBlockIcon, ImageIcon, ItalicIcon, LiftIcon, LinkIcon, ListBlIcon, ListOlIcon, MarkIcon, MermaidIcon, MonoIcon, NoteIcon, QuoteIcon, RedoIcon, SinkIcon, StrikethroughIcon, TableIcon, TabsIcon, TextColorIcon, TextIcon, UnderlineIcon, UndoIcon, } from '../../icons';
|
|
2
|
+
import GPTIcon from '../../icons/GPT';
|
|
2
3
|
export const icons = {
|
|
3
4
|
undo: { data: UndoIcon },
|
|
4
5
|
redo: { data: RedoIcon },
|
|
@@ -39,4 +40,5 @@ export const icons = {
|
|
|
39
40
|
tabs: { data: TabsIcon },
|
|
40
41
|
mermaid: { data: MermaidIcon },
|
|
41
42
|
foldingHeading: { data: FoldingHeadingIcon },
|
|
43
|
+
gpt: { data: GPTIcon },
|
|
42
44
|
};
|
|
@@ -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,4 +1,6 @@
|
|
|
1
1
|
import { headingType, pType } from '../../extensions';
|
|
2
|
+
// for typings from Math
|
|
3
|
+
import { gptHotKeys } from '../../extensions/yfm/GPT/constants';
|
|
2
4
|
import { i18n as i18nHint } from '../../i18n/hints';
|
|
3
5
|
import { i18n } from '../../i18n/menubar';
|
|
4
6
|
import { Action as A, formatter as f } from '../../shortcuts';
|
|
@@ -400,6 +402,16 @@ export const wYfmHtmlBlockItemData = {
|
|
|
400
402
|
isActive: (e) => e.actions.createYfmHtmlBlock.isActive(),
|
|
401
403
|
isEnable: (e) => e.actions.createYfmHtmlBlock.isEnable(),
|
|
402
404
|
};
|
|
405
|
+
export const wGptItemData = {
|
|
406
|
+
id: ActionName.gpt,
|
|
407
|
+
type: ToolbarDataType.SingleButton,
|
|
408
|
+
title: i18n.bind(null, 'gpt'),
|
|
409
|
+
hotkey: gptHotKeys.openGptKeyTooltip,
|
|
410
|
+
icon: icons.gpt,
|
|
411
|
+
exec: (e) => e.actions.addGptWidget.run({}),
|
|
412
|
+
isActive: (e) => e.actions.addGptWidget.isActive(),
|
|
413
|
+
isEnable: (e) => e.actions.addGptWidget.isEnable(),
|
|
414
|
+
};
|
|
403
415
|
export const wCommandMenuConfig = [
|
|
404
416
|
...wHeadingListConfig.data,
|
|
405
417
|
...wListsListConfig.data,
|
|
@@ -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,9 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import './ErrorScreen.css';
|
|
3
|
+
declare type ErrorScreenProps = {
|
|
4
|
+
onRetry: () => void;
|
|
5
|
+
onStartAgain: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const cnGptDialogErrorScreen: import("@bem-react/classname").ClassNameFormatter;
|
|
8
|
+
export declare const ErrorScreen: FC<ErrorScreenProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CircleXmarkFill } from '@gravity-ui/icons';
|
|
3
|
+
import { Button } from '@gravity-ui/uikit';
|
|
4
|
+
import { cn } from '../../../../classname';
|
|
5
|
+
import { i18n } from '../../../../i18n/gpt/errors';
|
|
6
|
+
import { IconRefuge } from '../IconRefuge/IconRefuge';
|
|
7
|
+
import './ErrorScreen.css';
|
|
8
|
+
export const cnGptDialogErrorScreen = cn('gpt-dialog-error-screen');
|
|
9
|
+
export const ErrorScreen = ({ onRetry, onStartAgain }) => {
|
|
10
|
+
return (React.createElement("div", { className: cnGptDialogErrorScreen() },
|
|
11
|
+
React.createElement("div", { className: cnGptDialogErrorScreen('content') },
|
|
12
|
+
React.createElement(IconRefuge, { containerClassName: cnGptDialogErrorScreen('icon'), data: CircleXmarkFill, refugeSize: 28, size: 16 }),
|
|
13
|
+
React.createElement("span", { className: cnGptDialogErrorScreen('text') }, i18n('error-text'))),
|
|
14
|
+
React.createElement("div", { className: cnGptDialogErrorScreen('buttons') },
|
|
15
|
+
React.createElement(Button, { view: "normal", onClick: onStartAgain }, i18n('start-again-button')),
|
|
16
|
+
React.createElement(Button, { view: "normal", onClick: onRetry }, i18n('retry-button')))));
|
|
17
|
+
};
|
|
@@ -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 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,29 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import { AlertProps } from '@gravity-ui/uikit';
|
|
3
|
+
import type { CommonAnswer, GptRequestData, PromptPreset } from '../ErrorScreen/types';
|
|
4
|
+
import './GptDialog.css';
|
|
5
|
+
export declare type GptDialogProps<AnswerData extends CommonAnswer = CommonAnswer, PromptData extends unknown = unknown> = {
|
|
6
|
+
markup: string;
|
|
7
|
+
answerRender: (data: AnswerData) => JSX.Element;
|
|
8
|
+
onApplyResult: (markup: string) => void;
|
|
9
|
+
promptPresets?: PromptPreset<PromptData>[];
|
|
10
|
+
disablePromptPresets?: boolean;
|
|
11
|
+
customPromptPlaceholder?: string;
|
|
12
|
+
disabledPromptPlaceholder?: string;
|
|
13
|
+
onCustomPromptApply?: (data: GptRequestData<PromptData>) => Promise<AnswerData | undefined>;
|
|
14
|
+
onPromptPresetClick?: (data: GptRequestData<PromptData>) => Promise<AnswerData | undefined>;
|
|
15
|
+
onTryAgain?: (data: GptRequestData<PromptData>) => Promise<AnswerData | undefined>;
|
|
16
|
+
onLike?: (data: GptRequestData<PromptData>) => Promise<void>;
|
|
17
|
+
onDislike?: (data: GptRequestData<PromptData>) => Promise<void>;
|
|
18
|
+
onClose?: () => void;
|
|
19
|
+
onUpdate?: (value: AnswerData | undefined) => void;
|
|
20
|
+
gptAlertProps?: {
|
|
21
|
+
showedGptAlert: boolean;
|
|
22
|
+
onCloseGptAlert?: () => void;
|
|
23
|
+
message?: string;
|
|
24
|
+
theme?: AlertProps['theme'];
|
|
25
|
+
className?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const cnGptDialog: import("@bem-react/classname").ClassNameFormatter;
|
|
29
|
+
export declare const GptDialog: FC<GptDialogProps>;
|