@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.
Files changed (197) hide show
  1. package/README.md +4 -0
  2. package/build/cjs/bundle/config/action-names.d.ts +1 -1
  3. package/build/cjs/bundle/config/action-names.js +1 -0
  4. package/build/cjs/bundle/config/icons.d.ts +1 -1
  5. package/build/cjs/bundle/config/icons.js +3 -0
  6. package/build/cjs/bundle/config/wysiwyg.d.ts +1 -0
  7. package/build/cjs/bundle/config/wysiwyg.js +13 -1
  8. package/build/cjs/extensions/behavior/Clipboard/clipboard.js +4 -1
  9. package/build/cjs/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
  10. package/build/cjs/extensions/yfm/GPT/ErrorScreen/ErrorScreen.css +18 -0
  11. package/build/cjs/extensions/yfm/GPT/ErrorScreen/ErrorScreen.d.ts +8 -0
  12. package/build/cjs/extensions/yfm/GPT/ErrorScreen/ErrorScreen.js +21 -0
  13. package/build/cjs/extensions/yfm/GPT/ErrorScreen/types.d.ts +14 -0
  14. package/build/cjs/extensions/yfm/GPT/ErrorScreen/types.js +2 -0
  15. package/build/cjs/extensions/yfm/GPT/GptDialog/GptDialog.css +75 -0
  16. package/build/cjs/extensions/yfm/GPT/GptDialog/GptDialog.d.ts +28 -0
  17. package/build/cjs/extensions/yfm/GPT/GptDialog/GptDialog.js +102 -0
  18. package/build/cjs/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.css +22 -0
  19. package/build/cjs/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +3 -0
  20. package/build/cjs/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.js +21 -0
  21. package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.d.ts +1 -0
  22. package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.js +5 -0
  23. package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.css +8 -0
  24. package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.d.ts +14 -0
  25. package/build/cjs/extensions/yfm/GPT/IconRefuge/IconRefuge.js +28 -0
  26. package/build/cjs/extensions/yfm/GPT/IconRefuge/index.d.ts +2 -0
  27. package/build/cjs/extensions/yfm/GPT/IconRefuge/index.js +5 -0
  28. package/build/cjs/extensions/yfm/GPT/PresetList/PresetList.d.ts +9 -0
  29. package/build/cjs/extensions/yfm/GPT/PresetList/PresetList.js +29 -0
  30. package/build/cjs/extensions/yfm/GPT/PresetList/Presetlist.css +6 -0
  31. package/build/cjs/extensions/yfm/GPT/actions.d.ts +2 -0
  32. package/build/cjs/extensions/yfm/GPT/actions.js +14 -0
  33. package/build/cjs/extensions/yfm/GPT/commands.d.ts +2 -0
  34. package/build/cjs/extensions/yfm/GPT/commands.js +13 -0
  35. package/build/cjs/extensions/yfm/GPT/constants.d.ts +13 -0
  36. package/build/cjs/extensions/yfm/GPT/constants.js +15 -0
  37. package/build/cjs/extensions/yfm/GPT/gptExtension/gptExtension.d.ts +13 -0
  38. package/build/cjs/extensions/yfm/GPT/gptExtension/gptExtension.js +18 -0
  39. package/build/cjs/extensions/yfm/GPT/gptExtension/view.css +17 -0
  40. package/build/cjs/extensions/yfm/GPT/gptExtension/view.d.ts +36 -0
  41. package/build/cjs/extensions/yfm/GPT/gptExtension/view.js +167 -0
  42. package/build/cjs/extensions/yfm/GPT/hooks/useGpt.d.ts +27 -0
  43. package/build/cjs/extensions/yfm/GPT/hooks/useGpt.js +155 -0
  44. package/build/cjs/extensions/yfm/GPT/hooks/useGptHotKeys.d.ts +2 -0
  45. package/build/cjs/extensions/yfm/GPT/hooks/useGptHotKeys.js +8 -0
  46. package/build/cjs/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.d.ts +13 -0
  47. package/build/cjs/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.js +70 -0
  48. package/build/cjs/extensions/yfm/GPT/hooks/usePresetList.d.ts +14 -0
  49. package/build/cjs/extensions/yfm/GPT/hooks/usePresetList.js +36 -0
  50. package/build/cjs/extensions/yfm/GPT/index.d.ts +2 -0
  51. package/build/cjs/extensions/yfm/GPT/index.js +5 -0
  52. package/build/cjs/extensions/yfm/GPT/plugin.d.ts +13 -0
  53. package/build/cjs/extensions/yfm/GPT/plugin.js +47 -0
  54. package/build/cjs/extensions/yfm/GPT/toolbar.d.ts +3 -0
  55. package/build/cjs/extensions/yfm/GPT/toolbar.js +22 -0
  56. package/build/cjs/extensions/yfm/GPT/utils.d.ts +13 -0
  57. package/build/cjs/extensions/yfm/GPT/utils.js +31 -0
  58. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.d.ts +1 -1
  59. package/build/cjs/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js +0 -8
  60. package/build/cjs/extensions/yfm/index.d.ts +1 -0
  61. package/build/cjs/extensions/yfm/index.js +1 -0
  62. package/build/cjs/i18n/gpt/dialog/en.json +16 -0
  63. package/build/cjs/i18n/gpt/dialog/index.d.ts +19 -0
  64. package/build/cjs/i18n/gpt/dialog/index.js +8 -0
  65. package/build/cjs/i18n/gpt/dialog/ru.json +16 -0
  66. package/build/cjs/i18n/gpt/errors/en.json +5 -0
  67. package/build/cjs/i18n/gpt/errors/index.d.ts +8 -0
  68. package/build/cjs/i18n/gpt/errors/index.js +8 -0
  69. package/build/cjs/i18n/gpt/errors/ru.json +5 -0
  70. package/build/cjs/i18n/gpt/extension/en.json +6 -0
  71. package/build/cjs/i18n/gpt/extension/index.d.ts +9 -0
  72. package/build/cjs/i18n/gpt/extension/index.js +8 -0
  73. package/build/cjs/i18n/gpt/extension/ru.json +6 -0
  74. package/build/cjs/i18n/gpt/loading/en.json +3 -0
  75. package/build/cjs/i18n/gpt/loading/index.d.ts +6 -0
  76. package/build/cjs/i18n/gpt/loading/index.js +8 -0
  77. package/build/cjs/i18n/gpt/loading/ru.json +3 -0
  78. package/build/cjs/i18n/menubar/en.json +1 -0
  79. package/build/cjs/i18n/menubar/index.d.ts +2 -1
  80. package/build/cjs/i18n/menubar/ru.json +1 -0
  81. package/build/cjs/icons/GPT.d.ts +2 -0
  82. package/build/cjs/icons/GPT.js +22 -0
  83. package/build/cjs/icons/GPTLoading.d.ts +2 -0
  84. package/build/cjs/icons/GPTLoading.js +12 -0
  85. package/build/cjs/icons/index.d.ts +3 -1
  86. package/build/cjs/icons/index.js +5 -1
  87. package/build/cjs/react-utils/useAutoFocus.d.ts +1 -1
  88. package/build/cjs/react-utils/useAutoFocus.js +2 -2
  89. package/build/cjs/react-utils/useNodeResizing.js +7 -2
  90. package/build/cjs/table-utils/commands/appendColumn.js +42 -33
  91. package/build/cjs/table-utils/commands/appendRow.js +40 -22
  92. package/build/cjs/table-utils/commands/removeColumn.js +18 -20
  93. package/build/cjs/table-utils/commands/removeRow.js +12 -9
  94. package/build/cjs/table-utils/table-desc.d.ts +53 -0
  95. package/build/cjs/table-utils/table-desc.js +149 -0
  96. package/build/cjs/table-utils/utils.d.ts +1 -1
  97. package/build/cjs/table-utils/utils.js +19 -12
  98. package/build/cjs/version.js +1 -1
  99. package/build/esm/bundle/config/action-names.d.ts +1 -1
  100. package/build/esm/bundle/config/action-names.js +1 -0
  101. package/build/esm/bundle/config/icons.d.ts +1 -1
  102. package/build/esm/bundle/config/icons.js +2 -0
  103. package/build/esm/bundle/config/wysiwyg.d.ts +1 -0
  104. package/build/esm/bundle/config/wysiwyg.js +12 -0
  105. package/build/esm/extensions/behavior/Clipboard/clipboard.js +4 -1
  106. package/build/esm/extensions/markdown/Table/actions/innerActions.d.ts +1 -1
  107. package/build/esm/extensions/yfm/GPT/ErrorScreen/ErrorScreen.css +18 -0
  108. package/build/esm/extensions/yfm/GPT/ErrorScreen/ErrorScreen.d.ts +9 -0
  109. package/build/esm/extensions/yfm/GPT/ErrorScreen/ErrorScreen.js +17 -0
  110. package/build/esm/extensions/yfm/GPT/ErrorScreen/types.d.ts +14 -0
  111. package/build/esm/extensions/yfm/GPT/ErrorScreen/types.js +1 -0
  112. package/build/esm/extensions/yfm/GPT/GptDialog/GptDialog.css +75 -0
  113. package/build/esm/extensions/yfm/GPT/GptDialog/GptDialog.d.ts +29 -0
  114. package/build/esm/extensions/yfm/GPT/GptDialog/GptDialog.js +98 -0
  115. package/build/esm/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.css +22 -0
  116. package/build/esm/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.d.ts +4 -0
  117. package/build/esm/extensions/yfm/GPT/GptDialog/LoadingScreen/LoadingScreen.js +17 -0
  118. package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.d.ts +1 -0
  119. package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.classname.js +2 -0
  120. package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.css +8 -0
  121. package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.d.ts +15 -0
  122. package/build/esm/extensions/yfm/GPT/IconRefuge/IconRefuge.js +25 -0
  123. package/build/esm/extensions/yfm/GPT/IconRefuge/index.d.ts +2 -0
  124. package/build/esm/extensions/yfm/GPT/IconRefuge/index.js +1 -0
  125. package/build/esm/extensions/yfm/GPT/PresetList/PresetList.d.ts +10 -0
  126. package/build/esm/extensions/yfm/GPT/PresetList/PresetList.js +25 -0
  127. package/build/esm/extensions/yfm/GPT/PresetList/Presetlist.css +6 -0
  128. package/build/esm/extensions/yfm/GPT/actions.d.ts +2 -0
  129. package/build/esm/extensions/yfm/GPT/actions.js +10 -0
  130. package/build/esm/extensions/yfm/GPT/commands.d.ts +2 -0
  131. package/build/esm/extensions/yfm/GPT/commands.js +9 -0
  132. package/build/esm/extensions/yfm/GPT/constants.d.ts +13 -0
  133. package/build/esm/extensions/yfm/GPT/constants.js +12 -0
  134. package/build/esm/extensions/yfm/GPT/gptExtension/gptExtension.d.ts +13 -0
  135. package/build/esm/extensions/yfm/GPT/gptExtension/gptExtension.js +14 -0
  136. package/build/esm/extensions/yfm/GPT/gptExtension/view.css +17 -0
  137. package/build/esm/extensions/yfm/GPT/gptExtension/view.d.ts +37 -0
  138. package/build/esm/extensions/yfm/GPT/gptExtension/view.js +163 -0
  139. package/build/esm/extensions/yfm/GPT/hooks/useGpt.d.ts +27 -0
  140. package/build/esm/extensions/yfm/GPT/hooks/useGpt.js +151 -0
  141. package/build/esm/extensions/yfm/GPT/hooks/useGptHotKeys.d.ts +2 -0
  142. package/build/esm/extensions/yfm/GPT/hooks/useGptHotKeys.js +4 -0
  143. package/build/esm/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.d.ts +13 -0
  144. package/build/esm/extensions/yfm/GPT/hooks/useOverflowingHorizontalItems.js +65 -0
  145. package/build/esm/extensions/yfm/GPT/hooks/usePresetList.d.ts +14 -0
  146. package/build/esm/extensions/yfm/GPT/hooks/usePresetList.js +32 -0
  147. package/build/esm/extensions/yfm/GPT/index.d.ts +2 -0
  148. package/build/esm/extensions/yfm/GPT/index.js +2 -0
  149. package/build/esm/extensions/yfm/GPT/plugin.d.ts +13 -0
  150. package/build/esm/extensions/yfm/GPT/plugin.js +43 -0
  151. package/build/esm/extensions/yfm/GPT/toolbar.d.ts +3 -0
  152. package/build/esm/extensions/yfm/GPT/toolbar.js +18 -0
  153. package/build/esm/extensions/yfm/GPT/utils.d.ts +13 -0
  154. package/build/esm/extensions/yfm/GPT/utils.js +23 -0
  155. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.d.ts +1 -1
  156. package/build/esm/extensions/yfm/YfmTable/plugins/YfmTableControls/actions.js +1 -9
  157. package/build/esm/extensions/yfm/index.d.ts +1 -0
  158. package/build/esm/extensions/yfm/index.js +1 -0
  159. package/build/esm/i18n/gpt/dialog/en.json +16 -0
  160. package/build/esm/i18n/gpt/dialog/index.d.ts +19 -0
  161. package/build/esm/i18n/gpt/dialog/index.js +4 -0
  162. package/build/esm/i18n/gpt/dialog/ru.json +16 -0
  163. package/build/esm/i18n/gpt/errors/en.json +5 -0
  164. package/build/esm/i18n/gpt/errors/index.d.ts +8 -0
  165. package/build/esm/i18n/gpt/errors/index.js +4 -0
  166. package/build/esm/i18n/gpt/errors/ru.json +5 -0
  167. package/build/esm/i18n/gpt/extension/en.json +6 -0
  168. package/build/esm/i18n/gpt/extension/index.d.ts +9 -0
  169. package/build/esm/i18n/gpt/extension/index.js +4 -0
  170. package/build/esm/i18n/gpt/extension/ru.json +6 -0
  171. package/build/esm/i18n/gpt/loading/en.json +3 -0
  172. package/build/esm/i18n/gpt/loading/index.d.ts +6 -0
  173. package/build/esm/i18n/gpt/loading/index.js +4 -0
  174. package/build/esm/i18n/gpt/loading/ru.json +3 -0
  175. package/build/esm/i18n/menubar/en.json +1 -0
  176. package/build/esm/i18n/menubar/index.d.ts +2 -1
  177. package/build/esm/i18n/menubar/ru.json +1 -0
  178. package/build/esm/icons/GPT.d.ts +2 -0
  179. package/build/esm/icons/GPT.js +19 -0
  180. package/build/esm/icons/GPTLoading.d.ts +2 -0
  181. package/build/esm/icons/GPTLoading.js +9 -0
  182. package/build/esm/icons/index.d.ts +3 -1
  183. package/build/esm/icons/index.js +3 -1
  184. package/build/esm/react-utils/useAutoFocus.d.ts +1 -1
  185. package/build/esm/react-utils/useAutoFocus.js +2 -2
  186. package/build/esm/react-utils/useNodeResizing.js +7 -2
  187. package/build/esm/table-utils/commands/appendColumn.js +44 -35
  188. package/build/esm/table-utils/commands/appendRow.js +42 -24
  189. package/build/esm/table-utils/commands/removeColumn.js +18 -20
  190. package/build/esm/table-utils/commands/removeRow.js +14 -11
  191. package/build/esm/table-utils/table-desc.d.ts +53 -0
  192. package/build/esm/table-utils/table-desc.js +144 -0
  193. package/build/esm/table-utils/utils.d.ts +1 -1
  194. package/build/esm/table-utils/utils.js +18 -12
  195. package/build/esm/version.js +1 -1
  196. package/build/styles.css +146 -0
  197. package/package.json +2 -1
@@ -0,0 +1,144 @@
1
+ import isNumber from 'is-number';
2
+ import { isTableBodyNode, isTableNode } from './utils';
3
+ export class TableDesc {
4
+ constructor(
5
+ /* eslint-disable @typescript-eslint/parameter-properties */
6
+ rows, cols, rowsDesc, baseOffset) {
7
+ this.rows = rows;
8
+ this.cols = cols;
9
+ this.rowsDesc = rowsDesc;
10
+ this.baseOffset = baseOffset;
11
+ }
12
+ static create(table) {
13
+ if (this.__cache.has(table))
14
+ return this.__cache.get(table);
15
+ if (!isTableNode(table))
16
+ return null;
17
+ const tbody = table.lastChild;
18
+ if (!tbody || !isTableBodyNode(tbody))
19
+ return null;
20
+ // table –> tbody -> ...
21
+ const baseOffset = 2;
22
+ const rows = [];
23
+ tbody.forEach((trow, offset) => {
24
+ rows.push({ node: trow, offset, cells: [] });
25
+ });
26
+ tbody.forEach((trow, _1, trowIndex) => {
27
+ trow.forEach((tcell, offset, tcellRealIndex) => {
28
+ var _a;
29
+ const rowDesc = rows[trowIndex];
30
+ let tcellIndex = tcellRealIndex;
31
+ while (rowDesc.cells[tcellIndex]) {
32
+ tcellIndex++;
33
+ }
34
+ const cellDesc = (rowDesc.cells[tcellIndex] = {
35
+ type: 'real',
36
+ node: tcell,
37
+ offset,
38
+ });
39
+ const map = [trowIndex, tcellIndex];
40
+ if (isNumber(tcell.attrs['colspan'])) {
41
+ rowDesc.colspan = true;
42
+ const colspan = (cellDesc.colspan = parseInt(tcell.attrs['colspan'], 10));
43
+ for (let i = 1; i < colspan; i++) {
44
+ rowDesc.cells[tcellIndex + i] = {
45
+ type: 'virtual',
46
+ colspan: map,
47
+ };
48
+ }
49
+ }
50
+ if (isNumber(tcell.attrs['rowspan'])) {
51
+ rowDesc.rowspan = true;
52
+ const rowspan = (cellDesc.rowspan = parseInt(tcell.attrs['rowspan'], 10));
53
+ for (let i = 1; i < rowspan; i++) {
54
+ const colspan = (_a = cellDesc.colspan) !== null && _a !== void 0 ? _a : 1;
55
+ for (let j = 0; j < colspan; j++)
56
+ rows[trowIndex + i].cells[tcellIndex + j] = {
57
+ type: 'virtual',
58
+ rowspan: map,
59
+ };
60
+ }
61
+ }
62
+ });
63
+ });
64
+ const desc = new this(rows.length, rows[0].cells.length, rows, baseOffset);
65
+ this.__cache.set(table, desc);
66
+ return desc;
67
+ }
68
+ rowHasVirtualCells(rowIndex) {
69
+ var _a;
70
+ return (_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.some((cell) => cell.type === 'virtual');
71
+ }
72
+ columnHasVirtualCells(columnIndex) {
73
+ return this.rowsDesc.some((row) => { var _a; return ((_a = row.cells[columnIndex]) === null || _a === void 0 ? void 0 : _a.type) === 'virtual'; });
74
+ }
75
+ isSafeColumn(columnIndex) {
76
+ return this.rowsDesc.every((row) => {
77
+ var _a;
78
+ const cell = row.cells[columnIndex];
79
+ if (cell.type === 'real' && (!cell.colspan || cell.colspan === 1))
80
+ return true;
81
+ if (cell.type === 'virtual' && ((_a = cell.rowspan) === null || _a === void 0 ? void 0 : _a[1]) === columnIndex)
82
+ return true;
83
+ return false;
84
+ });
85
+ }
86
+ isSafeRow(rowIndex) {
87
+ var _a;
88
+ return (_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells.every((cell) => {
89
+ var _a;
90
+ if (cell.type === 'real' && (!cell.rowspan || cell.rowspan === 1))
91
+ return true;
92
+ if (cell.type === 'virtual' && ((_a = cell.colspan) === null || _a === void 0 ? void 0 : _a[0]) === rowIndex)
93
+ return true;
94
+ return false;
95
+ });
96
+ }
97
+ getOffsetForRow(rowIndex) {
98
+ var _a;
99
+ return this.baseOffset + ((_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.offset);
100
+ }
101
+ getRelativePosForRow(rowIndex) {
102
+ const from = this.getOffsetForRow(rowIndex);
103
+ const to = from + this.rowsDesc[rowIndex].node.nodeSize;
104
+ return { from, to };
105
+ }
106
+ getRelativePosForCell(rowIndex, columnIndex) {
107
+ var _a;
108
+ const cell = (_a = this.rowsDesc[rowIndex]) === null || _a === void 0 ? void 0 : _a.cells[columnIndex];
109
+ const rowOffset = this.getOffsetForRow(rowIndex);
110
+ if ((cell === null || cell === void 0 ? void 0 : cell.type) === 'real') {
111
+ // 1 – open boundary for row node
112
+ const from = rowOffset + 1 + cell.offset;
113
+ const to = from + cell.node.nodeSize;
114
+ return { type: 'real', from, to };
115
+ }
116
+ if ((cell === null || cell === void 0 ? void 0 : cell.type) === 'virtual') {
117
+ let index = columnIndex;
118
+ while (--index >= 0) {
119
+ const cell = this.rowsDesc[rowIndex].cells[index];
120
+ if (cell.type === 'real') {
121
+ const closest = rowOffset + 1 + cell.offset + cell.node.nodeSize;
122
+ return { type: 'virtual', closestPos: closest };
123
+ }
124
+ }
125
+ return { type: 'virtual', closestPos: rowOffset + 1 };
126
+ }
127
+ throw new Error(`Impossible to calculate offset for cell with position [${rowIndex},${columnIndex}]`);
128
+ }
129
+ getRelativePosForColumn(columnIndex) {
130
+ const ranges = [];
131
+ for (let i = 0; i < this.rows; i++) {
132
+ ranges.push(this.getRelativePosForCell(i, columnIndex));
133
+ }
134
+ return ranges;
135
+ }
136
+ getCellNodeType() {
137
+ const isRealCell = (cell) => cell.type === 'real';
138
+ return this.rowsDesc[0].cells.find(isRealCell).node.type;
139
+ }
140
+ getRowNodeType() {
141
+ return this.rowsDesc[0].node.type;
142
+ }
143
+ }
144
+ 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 | Node) => {
28
+ export declare const getTableDimensions: (node: PmNode) => {
29
29
  rows: number;
30
30
  cols: number;
31
31
  };
@@ -1,4 +1,4 @@
1
- import { Node as PmNode } from 'prosemirror-model';
1
+ import isNumber from 'is-number';
2
2
  import { findChildren, findParentNode, findParentNodeClosestToPos, } from 'prosemirror-utils';
3
3
  import { isTextSelection } from '../utils/selection';
4
4
  import { TableRole } from './const';
@@ -18,17 +18,23 @@ export const findChildTableRows = (node) => findChildren(node, isTableRowNode);
18
18
  export const findChildTableCells = (node) => findChildren(node, isTableCellNode);
19
19
  export const findChildTableBody = (node) => findChildren(node, isTableBodyNode);
20
20
  export const getTableDimensions = (node) => {
21
- var _a, _b, _c, _d, _e, _f;
22
- let rows, cols;
23
- if (node instanceof PmNode) {
24
- rows = (_a = node.firstChild) === null || _a === void 0 ? void 0 : _a.childCount;
25
- cols = (_c = (_b = node.firstChild) === null || _b === void 0 ? void 0 : _b.firstChild) === null || _c === void 0 ? void 0 : _c.childCount;
26
- }
27
- else {
28
- rows = (_d = node.firstChild) === null || _d === void 0 ? void 0 : _d.childNodes.length;
29
- cols = (_f = (_e = node.firstChild) === null || _e === void 0 ? void 0 : _e.firstChild) === null || _f === void 0 ? void 0 : _f.childNodes.length;
30
- }
31
- return { rows: rows || 1, cols: cols || 1 };
21
+ let rows = 0, cols = 0;
22
+ const tbody = node.firstChild;
23
+ tbody === null || tbody === void 0 ? void 0 : tbody.forEach((trow, _1, trowIndex) => {
24
+ rows++;
25
+ if (trowIndex === 0) {
26
+ trow.forEach((tcell, _2) => {
27
+ const cellAttrs = tcell.attrs;
28
+ if (isNumber(cellAttrs['colspan'])) {
29
+ cols += parseInt(cellAttrs['colspan'], 10);
30
+ }
31
+ else {
32
+ cols++;
33
+ }
34
+ });
35
+ }
36
+ });
37
+ return { rows, cols };
32
38
  };
33
39
  export function atEndOfCell(view, dir) {
34
40
  if (!isTextSelection(view.state.selection))
@@ -1,2 +1,2 @@
1
1
  /** During build process, the current version will be injected here */
2
- export const VERSION = typeof '13.17.1' !== 'undefined' ? '13.17.1' : 'unknown';
2
+ export const VERSION = typeof '13.18.1' !== 'undefined' ? '13.18.1' : 'unknown';
package/build/styles.css CHANGED
@@ -1242,6 +1242,130 @@ body :has(.g-md-resizable_resizing) {
1242
1242
  line-height: var(--g-text-body-1-line-height);
1243
1243
  font-weight: var(--g-text-body-font-weight);
1244
1244
  }
1245
+ .g-md-gpt-dialog-error-screen__content {
1246
+ display: flex;
1247
+ align-items: center;
1248
+ margin-bottom: var(--g-spacing-2);
1249
+ }
1250
+ .g-md-gpt-dialog-error-screen__icon {
1251
+ color: var(--g-color-base-danger-heavy);
1252
+ }
1253
+ .g-md-gpt-dialog-error-screen__text {
1254
+ flex: auto;
1255
+ font-size: var(--g-text-body-2-font-size);
1256
+ font-weight: 500;
1257
+ }
1258
+ .g-md-gpt-dialog-error-screen__buttons {
1259
+ display: flex;
1260
+ align-items: center;
1261
+ gap: var(--g-spacing-2);
1262
+ }
1263
+ .g-md-gpt-dialog__header-top {
1264
+ display: flex;
1265
+ align-items: center;
1266
+ }
1267
+ .g-md-gpt-dialog__custom-prompt-input {
1268
+ margin-right: var(--g-spacing-2);
1269
+ }
1270
+ .g-md-gpt-dialog__custom-prompt-input .g-text-input__control {
1271
+ font-size: var(--g-text-body-2-font-size);
1272
+ }
1273
+ .g-md-gpt-dialog__header-bottom {
1274
+ margin-top: var(--g-spacing-2);
1275
+ }
1276
+ .g-md-gpt-dialog__custom-prompt {
1277
+ display: flex;
1278
+ flex: auto;
1279
+ align-items: center;
1280
+ }
1281
+ .g-md-gpt-dialog__alone-presets-text {
1282
+ margin-right: var(--g-spacing-8);
1283
+ }
1284
+ .g-md-gpt-dialog__alone-presets {
1285
+ display: flex;
1286
+ flex: auto;
1287
+ align-items: center;
1288
+ width: 100%;
1289
+ font-size: var(--g-text-body-2-font-size);
1290
+ font-weight: 500;
1291
+ }
1292
+ .g-md-gpt-dialog__alone-presets .g-md-gpt-dialog-preset-list {
1293
+ flex: auto;
1294
+ }
1295
+ .g-md-gpt-dialog__answer-title {
1296
+ font-size: var(--g-text-body-2-font-size);
1297
+ font-weight: 500;
1298
+ }
1299
+ .g-md-gpt-dialog__gpt-icon {
1300
+ margin-right: var(--g-spacing-1);
1301
+ }
1302
+ .g-md-gpt-dialog__try-again-button {
1303
+ margin-right: var(--g-spacing-2);
1304
+ }
1305
+ .g-md-gpt-dialog__body {
1306
+ margin: var(--g-spacing-2) calc(-1 * var(--g-spacing-3));
1307
+ padding: var(--g-spacing-4) var(--g-spacing-3);
1308
+ border-top: 1px solid var(--g-color-line-generic);
1309
+ }
1310
+ .g-md-gpt-dialog__answer {
1311
+ overflow: auto;
1312
+ max-height: 300px;
1313
+ }
1314
+ .g-md-gpt-dialog__answer-actions {
1315
+ display: flex;
1316
+ align-items: center;
1317
+ }
1318
+ .g-md-gpt-dialog__feedback-message {
1319
+ margin-left: var(--g-spacing-2);
1320
+ }
1321
+ .g-md-gpt-dialog__like-button {
1322
+ margin-right: var(--g-spacing-2);
1323
+ }
1324
+ .g-md-gpt-dialog__close-button {
1325
+ margin-right: var(--g-spacing-2);
1326
+ margin-left: auto;
1327
+ }
1328
+ .g-md-gpt-dialog__footer {
1329
+ display: flex;
1330
+ align-items: center;
1331
+ margin-top: var(--g-spacing-2);
1332
+ }
1333
+ .g-md-gpt-dialog__description-alert {
1334
+ min-height: 34px;
1335
+ margin-top: var(--g-spacing-3);
1336
+ padding: var(--g-spacing-1) var(--g-spacing-2);
1337
+ }
1338
+ .icon-refuge {
1339
+ display: inline-flex;
1340
+ justify-content: center;
1341
+ align-items: center;
1342
+ }
1343
+ .icon-refuge_inline {
1344
+ display: inline-flex;
1345
+ }
1346
+ .g-md-gpt-dialog-preset-list__preset + .g-md-gpt-dialog-preset-list__preset {
1347
+ margin-left: var(--g-spacing-2);
1348
+ }
1349
+ .g-md-gpt-dialog-preset-list__more-button-wrapper {
1350
+ margin-left: var(--g-spacing-2);
1351
+ }
1352
+ .g-md-gpt-widget-deco {
1353
+ background-color: var(--g-color-base-info-light-hover);
1354
+ }
1355
+
1356
+ .g-md-gpt-popup {
1357
+ --layer-navigation-bar: 900;
1358
+ pointer-events: initial;
1359
+ }
1360
+ .g-md-gpt-popup[class] {
1361
+ border-radius: var(--g-spacing-2);
1362
+ }
1363
+ .g-md-gpt-popup__content {
1364
+ width: 720px;
1365
+ padding: var(--g-spacing-3);
1366
+ pointer-events: all;
1367
+ box-shadow: -8px 2px 16px -4px var(--g-color-private-purple-150), 8px 2px 16px -4px var(--g-color-private-blue-150);
1368
+ }
1245
1369
  .g-md-image-skeleton {
1246
1370
  vertical-align: middle;
1247
1371
  }
@@ -1425,6 +1549,28 @@ body :has(.g-md-resizable_resizing) {
1425
1549
  .table-cell-floating-icon {
1426
1550
  transform: rotate(90deg);
1427
1551
  }
1552
+ .g-md-gpt-dialog-loading-screen__header {
1553
+ display: flex;
1554
+ align-items: center;
1555
+ margin-bottom: 8px;
1556
+ }
1557
+ .g-md-gpt-dialog-loading-screen__icon {
1558
+ margin-right: 4px;
1559
+ }
1560
+ .g-md-gpt-dialog-loading-screen__text {
1561
+ margin-right: 8px;
1562
+ font-size: var(--g-text-body-2-font-size);
1563
+ font-weight: 500;
1564
+ }
1565
+ .g-md-gpt-dialog-loading-screen__skeleton-small-button {
1566
+ width: 90px;
1567
+ height: 28px;
1568
+ margin-right: 8px;
1569
+ }
1570
+ .g-md-gpt-dialog-loading-screen__skeleton-medium-button {
1571
+ width: 120px;
1572
+ height: 28px;
1573
+ }
1428
1574
  .g-md-img-size-node-view__wrapper {
1429
1575
  position: relative;
1430
1576
  display: inline-block;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/markdown-editor",
3
- "version": "13.17.1",
3
+ "version": "13.18.1",
4
4
  "description": "Markdown wysiwyg and markup editor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -195,6 +195,7 @@
195
195
  "prosemirror-utils": "1.2.0",
196
196
  "prosemirror-view": "1.33.6",
197
197
  "react-error-boundary": "^3.1.4",
198
+ "react-hotkeys-hook": "4.5.0",
198
199
  "react-use": "^17.3.2",
199
200
  "tslib": "^2.3.1"
200
201
  },