@ctzhian/tiptap 2.6.1 → 2.7.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.
Files changed (30) hide show
  1. package/dist/Editor/demo.js +1 -1
  2. package/dist/EditorMarkdown/demo.js +1 -1
  3. package/dist/extension/component/TableExtendButton/index.d.ts +1 -3
  4. package/dist/extension/component/TableExtendButton/index.js +16 -7
  5. package/dist/extension/component/TableExtendButton/use-table-extend-row-column.d.ts +1 -3
  6. package/dist/extension/component/TableExtendButton/use-table-extend-row-column.js +5 -10
  7. package/dist/extension/component/TableHandle/TableHandleAddButton.js +19 -11
  8. package/dist/extension/component/TableHandle/TableHandleMenu.js +159 -83
  9. package/dist/extension/component/TableHandle/index.d.ts +2 -7
  10. package/dist/extension/component/TableHandle/index.js +1 -4
  11. package/dist/extension/component/TableHandle/use-table-handle-positioning.d.ts +2 -6
  12. package/dist/extension/component/TableHandle/use-table-handle-positioning.js +28 -55
  13. package/dist/extension/component/TableHandle/use-table-handle-state.d.ts +4 -13
  14. package/dist/extension/component/TableHandle/use-table-handle-state.js +1 -1
  15. package/dist/extension/component/UploadProgress/index.d.ts +1 -1
  16. package/dist/extension/index.js +2 -2
  17. package/dist/extension/node/Table.js +112 -151
  18. package/dist/extension/node/TableHandler/plugin.d.ts +5 -9
  19. package/dist/extension/node/TableHandler/plugin.js +177 -124
  20. package/dist/extension/node/TableOfContents/index.d.ts +4 -7
  21. package/dist/extension/node/TableOfContents/index.js +23 -419
  22. package/dist/util/table-utils.d.ts +28 -61
  23. package/dist/util/table-utils.js +157 -124
  24. package/package.json +32 -32
  25. package/dist/extension/node/TableOfContents/plugin.d.ts +0 -6
  26. package/dist/extension/node/TableOfContents/plugin.js +0 -58
  27. package/dist/extension/node/TableOfContents/types.d.ts +0 -45
  28. package/dist/extension/node/TableOfContents/types.js +0 -1
  29. package/dist/extension/node/TableOfContents/util.d.ts +0 -6
  30. package/dist/extension/node/TableOfContents/util.js +0 -70
@@ -1,11 +1,8 @@
1
1
  import { TocList } from "../../../type";
2
- import { Extension } from '@tiptap/core';
3
- import { TableOfContentsOptions, TableOfContentsStorage } from './types';
4
- export * from './types';
5
- export declare const TableOfContentsExtension: Extension<TableOfContentsOptions, TableOfContentsStorage>;
6
- interface TableOfContentsProps {
2
+ import { TableOfContentsOptions } from '@tiptap/extension-table-of-contents';
3
+ interface Props {
7
4
  onTocUpdate?: (toc: TocList) => void;
8
5
  tableOfContentsOptions?: TableOfContentsOptions;
9
6
  }
10
- export declare const TableOfContents: ({ onTocUpdate, tableOfContentsOptions }: TableOfContentsProps) => Extension<TableOfContentsOptions, TableOfContentsStorage>;
11
- export default TableOfContents;
7
+ export declare const TableOfContentsExtension: ({ onTocUpdate, tableOfContentsOptions }: Props) => import("@tiptap/core").Extension<TableOfContentsOptions, import("@tiptap/extension-table-of-contents").TableOfContentsStorage>;
8
+ export {};
@@ -4,374 +4,31 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- /* eslint-disable @typescript-eslint/no-unused-vars */
8
-
9
- import { Extension } from '@tiptap/core';
10
- import { v4 as uuidv4 } from 'uuid';
11
- import { TableOfContentsPlugin } from "./plugin";
12
- import { getHeadlineLevel, getHierarchicalIndexes, getLinearIndexes } from "./util";
13
- export * from "./types";
14
-
15
- // 全局组合状态管理,避免在 IME 组合期间触发 TOC 更新
16
- var globalCompositionState = false;
17
- var globalCompositionEndTimer = null;
18
- var globalInputTimer = null;
19
- var lastInputTime = 0;
20
-
21
- // 全局监听组合状态和输入事件
22
- if (typeof document !== 'undefined') {
23
- document.addEventListener('compositionstart', function () {
24
- globalCompositionState = true;
25
- }, {
26
- passive: true
27
- });
28
- document.addEventListener('compositionend', function () {
29
- globalCompositionState = false;
30
- // 组合结束后,延迟刷新所有 TOC 实例
31
- if (globalCompositionEndTimer) {
32
- clearTimeout(globalCompositionEndTimer);
33
- }
34
- globalCompositionEndTimer = setTimeout(function () {
35
- // 这里会通过 editor 实例来触发刷新
36
- // 具体实现在 onTransaction 中处理
37
- }, 200);
38
- }, {
39
- passive: true
40
- });
41
-
42
- // 监听所有输入事件,记录最后输入时间
43
- document.addEventListener('input', function () {
44
- lastInputTime = Date.now();
45
- }, {
46
- passive: true
47
- });
48
- document.addEventListener('keydown', function () {
49
- lastInputTime = Date.now();
50
- }, {
51
- passive: true
52
- });
53
- }
54
- var addTocActiveStatesAndGetItems = function addTocActiveStatesAndGetItems(content, options) {
55
- var editor = options.editor;
56
- var headlines = [];
57
- var scrolledOverIds = [];
58
- var activeId = null;
59
- if (editor.isDestroyed) {
60
- return content;
61
- }
62
- editor.state.doc.descendants(function (node, pos) {
63
- var _options$anchorTypes;
64
- var isValidType = (_options$anchorTypes = options.anchorTypes) === null || _options$anchorTypes === void 0 ? void 0 : _options$anchorTypes.includes(node.type.name);
65
- if (!isValidType) {
66
- return;
67
- }
68
- headlines.push({
69
- node: node,
70
- pos: pos
71
- });
72
- });
73
- headlines.forEach(function (headline) {
74
- var domElement = editor.view.domAtPos(headline.pos + 1).node;
75
- var scrolledOver = options.storage.scrollPosition >= domElement.offsetTop;
76
- if (scrolledOver) {
77
- activeId = headline.node.attrs.id;
78
- scrolledOverIds.push(headline.node.attrs.id);
79
- }
80
- });
81
- return content.map(function (heading) {
82
- return _objectSpread(_objectSpread({}, heading), {}, {
83
- isActive: heading.id === activeId,
84
- isScrolledOver: scrolledOverIds.includes(heading.id)
85
- });
86
- });
87
- };
88
- var setTocData = function setTocData(options) {
89
- var editor = options.editor,
90
- onUpdate = options.onUpdate;
91
- if (editor.isDestroyed) {
92
- return;
93
- }
94
- var headlines = [];
95
- var anchors = [];
96
- var anchorEls = [];
97
- editor.state.doc.descendants(function (node, pos) {
98
- var _options$anchorTypes2;
99
- var isValidType = (_options$anchorTypes2 = options.anchorTypes) === null || _options$anchorTypes2 === void 0 ? void 0 : _options$anchorTypes2.includes(node.type.name);
100
- if (!isValidType) {
101
- return;
102
- }
103
- headlines.push({
104
- node: node,
105
- pos: pos
106
- });
107
- });
108
- headlines.forEach(function (headline) {
109
- if (headline.node.textContent.length === 0) {
110
- return;
111
- }
112
- var domElement = editor.view.domAtPos(headline.pos + 1).node;
113
- var scrolledOver = options.storage.scrollPosition >= domElement.offsetTop;
114
- anchorEls.push(domElement);
115
- var originalLevel = headline.node.attrs.level;
116
- var level = options.getLevelFn(headline, anchors);
117
- var itemIndex = options.getIndexFn(headline, anchors, level);
118
- anchors.push({
119
- itemIndex: itemIndex,
120
- id: headline.node.attrs.id || options.getId(headline.node.textContent),
121
- originalLevel: originalLevel,
122
- level: level,
123
- textContent: headline.node.textContent,
124
- pos: headline.pos,
125
- editor: editor,
126
- isActive: false,
127
- isScrolledOver: scrolledOver,
128
- node: headline.node,
129
- dom: domElement
130
- });
131
- });
132
-
133
- // 计算 active 和 scrolledOver 状态
134
- anchors = addTocActiveStatesAndGetItems(anchors, {
135
- editor: options.editor,
136
- anchorTypes: options.anchorTypes,
137
- storage: options.storage
138
- });
139
-
140
- // 更新存储
141
- options.storage.anchors = anchorEls;
142
- options.storage.content = anchors;
143
-
144
- // 调用回调
145
- if (onUpdate) {
146
- var isInitialCreation = options.storage.content.length === 0;
147
- onUpdate(anchors, isInitialCreation);
148
- }
149
- };
150
- export var TableOfContentsExtension = Extension.create({
151
- name: 'tableOfContents',
152
- addStorage: function addStorage() {
153
- return {
154
- content: [],
155
- anchors: [],
156
- scrollHandler: function scrollHandler() {
157
- return null;
158
- },
159
- scrollPosition: 0
160
- };
161
- },
162
- addGlobalAttributes: function addGlobalAttributes() {
163
- return [{
164
- types: this.options.anchorTypes || ['heading'],
165
- attributes: {
166
- id: {
167
- default: null,
168
- renderHTML: function renderHTML(attributes) {
169
- return {
170
- id: attributes.id
171
- };
172
- },
173
- parseHTML: function parseHTML(element) {
174
- return element.id || null;
175
- }
176
- }
177
- }
178
- }];
179
- },
180
- addOptions: function addOptions() {
181
- var defaultScrollParent = typeof window !== 'undefined' ? function () {
182
- return window;
183
- } : undefined;
184
- return {
185
- // eslint-disable-next-line
186
- onUpdate: function onUpdate() {},
187
- // eslint-disable-next-line
188
- getId: function getId(_textContent) {
189
- return uuidv4();
190
- },
191
- scrollParent: defaultScrollParent,
192
- anchorTypes: ['heading']
193
- };
194
- },
195
- addCommands: function addCommands() {
196
- var _this = this;
197
- return {
198
- updateTableOfContents: function updateTableOfContents() {
199
- return function (_ref) {
200
- var dispatch = _ref.dispatch;
201
- if (dispatch) {
202
- var _this$options$onUpdat;
203
- setTocData({
204
- editor: _this.editor,
205
- storage: _this.storage,
206
- onUpdate: (_this$options$onUpdat = _this.options.onUpdate) === null || _this$options$onUpdat === void 0 ? void 0 : _this$options$onUpdat.bind(_this),
207
- getIndexFn: _this.options.getIndex || getLinearIndexes,
208
- getLevelFn: _this.options.getLevel || getHeadlineLevel,
209
- anchorTypes: _this.options.anchorTypes,
210
- getId: _this.options.getId || function (textContent) {
211
- return uuidv4();
212
- }
213
- });
214
- }
215
- return true;
216
- };
217
- }
218
- };
219
- },
220
- onTransaction: function onTransaction(_ref2) {
221
- var _this2 = this;
222
- var transaction = _ref2.transaction;
223
- if (!transaction.docChanged) return;
224
- var now = Date.now();
225
- var timeSinceLastInput = now - lastInputTime;
226
-
227
- // 组合期间完全不处理 TOC 更新,避免打断输入
228
- if (globalCompositionState || this.editor.view.composing) {
229
- return;
230
- }
231
-
232
- // 如果最近有输入(1秒内),延迟处理
233
- if (timeSinceLastInput < 1000) {
234
- if (globalInputTimer) {
235
- clearTimeout(globalInputTimer);
236
- }
237
- globalInputTimer = setTimeout(function () {
238
- // 再次检查组合状态
239
- if (!globalCompositionState && !_this2.editor.view.composing) {
240
- var _this2$options$onUpda;
241
- setTocData({
242
- editor: _this2.editor,
243
- storage: _this2.storage,
244
- onUpdate: (_this2$options$onUpda = _this2.options.onUpdate) === null || _this2$options$onUpda === void 0 ? void 0 : _this2$options$onUpda.bind(_this2),
245
- getIndexFn: _this2.options.getIndex || getLinearIndexes,
246
- getLevelFn: _this2.options.getLevel || getHeadlineLevel,
247
- anchorTypes: _this2.options.anchorTypes,
248
- getId: _this2.options.getId || function (textContent) {
249
- return uuidv4();
250
- }
251
- });
252
- }
253
- }, 1000 - timeSinceLastInput + 200);
254
- return;
255
- }
256
-
257
- // 非组合期间且无最近输入,使用 setTimeout 确保有足够延迟
258
- setTimeout(function () {
259
- // 再次检查,确保组合状态没有变化
260
- if (!globalCompositionState && !_this2.editor.view.composing) {
261
- var _this2$options$onUpda2;
262
- setTocData({
263
- editor: _this2.editor,
264
- storage: _this2.storage,
265
- onUpdate: (_this2$options$onUpda2 = _this2.options.onUpdate) === null || _this2$options$onUpda2 === void 0 ? void 0 : _this2$options$onUpda2.bind(_this2),
266
- getIndexFn: _this2.options.getIndex || getLinearIndexes,
267
- getLevelFn: _this2.options.getLevel || getHeadlineLevel,
268
- anchorTypes: _this2.options.anchorTypes,
269
- getId: _this2.options.getId || function (textContent) {
270
- return uuidv4();
7
+ import { getHierarchicalIndexes, TableOfContents } from '@tiptap/extension-table-of-contents';
8
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
9
+ export var TableOfContentsExtension = function TableOfContentsExtension(_ref) {
10
+ var onTocUpdate = _ref.onTocUpdate,
11
+ tableOfContentsOptions = _ref.tableOfContentsOptions;
12
+ return TableOfContents.extend({
13
+ addProseMirrorPlugins: function addProseMirrorPlugins() {
14
+ var imeCompositionPluginKey = new PluginKey('imeComposition');
15
+ return [new Plugin({
16
+ key: new PluginKey('tableOfContentImeFix'),
17
+ appendTransaction: function appendTransaction(transactions, _oldState, newState) {
18
+ if (transactions.some(function (tr) {
19
+ return tr.getMeta('composition');
20
+ })) {
21
+ return null;
271
22
  }
272
- });
273
- }
274
- }, 100);
275
- },
276
- onCreate: function onCreate() {
277
- var _this3 = this;
278
- var tr = this.editor.state.tr;
279
- var existingIds = [];
280
- if (this.options.scrollParent && typeof this.options.scrollParent !== 'function') {
281
- console.warn("[Tiptap Table of Contents Deprecation Notice]: The 'scrollParent' option must now be provided as a callback function that returns the 'scrollParent' element. The ability to pass this option directly will be deprecated in future releases.");
282
- }
283
-
284
- // 异步处理初始 ID 分配,避免与初始输入竞争
285
- requestAnimationFrame(function () {
286
- _this3.editor.state.doc.descendants(function (node, pos) {
287
- var _this3$options$anchor;
288
- var nodeId = node.attrs.id;
289
- var isValidType = (_this3$options$anchor = _this3.options.anchorTypes) === null || _this3$options$anchor === void 0 ? void 0 : _this3$options$anchor.includes(node.type.name);
290
- if (!isValidType || node.textContent.length === 0) {
291
- return;
292
- }
293
- if (nodeId === null || nodeId === undefined || existingIds.includes(nodeId)) {
294
- var id = '';
295
- if (_this3.options.getId) {
296
- id = _this3.options.getId(node.textContent);
297
- } else {
298
- id = uuidv4();
23
+ var imePluginState = imeCompositionPluginKey.getState(newState);
24
+ if (imePluginState !== null && imePluginState !== void 0 && imePluginState.isComposing) {
25
+ return null;
299
26
  }
300
- tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
301
- id: id
302
- }));
27
+ return null;
303
28
  }
304
- existingIds.push(nodeId);
305
- });
306
- _this3.editor.view.dispatch(tr);
307
-
308
- // 延迟初始化 TOC 数据
309
- setTimeout(function () {
310
- var _this3$options$onUpda;
311
- setTocData({
312
- editor: _this3.editor,
313
- storage: _this3.storage,
314
- onUpdate: (_this3$options$onUpda = _this3.options.onUpdate) === null || _this3$options$onUpda === void 0 ? void 0 : _this3$options$onUpda.bind(_this3),
315
- getIndexFn: _this3.options.getIndex || getLinearIndexes,
316
- getLevelFn: _this3.options.getLevel || getHeadlineLevel,
317
- anchorTypes: _this3.options.anchorTypes,
318
- getId: _this3.options.getId || function (textContent) {
319
- return uuidv4();
320
- }
321
- });
322
- }, 100);
323
- });
324
-
325
- // 防抖的 scroll handler,避免滚动期间频繁触发回调
326
- var scrollTimer = null;
327
- this.storage.scrollHandler = function () {
328
- if (!_this3.options.scrollParent) {
329
- return;
330
- }
331
- var scrollParent = typeof _this3.options.scrollParent === 'function' ? _this3.options.scrollParent() : _this3.options.scrollParent;
332
- var scrollPosition = scrollParent instanceof HTMLElement ? scrollParent.scrollTop : scrollParent.scrollY;
333
- _this3.storage.scrollPosition = scrollPosition || 0;
334
- if (scrollTimer) clearTimeout(scrollTimer);
335
- scrollTimer = setTimeout(function () {
336
- var _this3$options$onUpda2, _this3$options;
337
- var updatedItems = addTocActiveStatesAndGetItems(_this3.storage.content, {
338
- editor: _this3.editor,
339
- anchorTypes: _this3.options.anchorTypes,
340
- storage: _this3.storage
341
- });
342
- _this3.storage.content = updatedItems;
343
- // 调用 onUpdate 回调
344
- (_this3$options$onUpda2 = (_this3$options = _this3.options).onUpdate) === null || _this3$options$onUpda2 === void 0 || _this3$options$onUpda2.call(_this3$options, updatedItems, false);
345
- }, 100);
346
- };
347
-
348
- // 添加滚动监听
349
- if (this.options.scrollParent) {
350
- var scrollParent = typeof this.options.scrollParent === 'function' ? this.options.scrollParent() : this.options.scrollParent;
351
- if (scrollParent) {
352
- scrollParent.addEventListener('scroll', this.storage.scrollHandler);
353
- }
354
- }
355
- },
356
- onDestroy: function onDestroy() {
357
- if (this.options.scrollParent) {
358
- var scrollParent = typeof this.options.scrollParent === 'function' ? this.options.scrollParent() : this.options.scrollParent;
359
- if (scrollParent) {
360
- scrollParent.removeEventListener('scroll', this.storage.scrollHandler);
361
- }
29
+ })];
362
30
  }
363
- },
364
- addProseMirrorPlugins: function addProseMirrorPlugins() {
365
- return [TableOfContentsPlugin({
366
- getId: this.options.getId,
367
- anchorTypes: this.options.anchorTypes
368
- })];
369
- }
370
- });
371
- export var TableOfContents = function TableOfContents(_ref3) {
372
- var onTocUpdate = _ref3.onTocUpdate,
373
- tableOfContentsOptions = _ref3.tableOfContentsOptions;
374
- return TableOfContentsExtension.configure(_objectSpread(_objectSpread({
31
+ }).configure(_objectSpread(_objectSpread({
375
32
  getIndex: getHierarchicalIndexes
376
33
  }, tableOfContentsOptions || {}), {}, {
377
34
  onUpdate: function onUpdate(data, isCreate) {
@@ -390,60 +47,7 @@ export var TableOfContents = function TableOfContents(_ref3) {
390
47
  textContent: content.textContent
391
48
  };
392
49
  }));
393
- }, 0);
50
+ }, 60);
394
51
  }
395
52
  }));
396
- };
397
- export default TableOfContents;
398
-
399
- // import { TocList } from '@ctzhian/tiptap/type'
400
- // import { getHierarchicalIndexes, TableOfContents, TableOfContentsOptions } from '@tiptap/extension-table-of-contents'
401
- // import { Plugin, PluginKey } from '@tiptap/pm/state'
402
-
403
- // interface Props {
404
- // onTocUpdate?: (toc: TocList) => void
405
- // tableOfContentsOptions?: TableOfContentsOptions
406
- // }
407
-
408
- // export const TableOfContentsExtension = ({ onTocUpdate, tableOfContentsOptions }: Props) => TableOfContents.extend({
409
- // addProseMirrorPlugins() {
410
- // const imeCompositionPluginKey = new PluginKey('imeComposition')
411
-
412
- // return [
413
- // new Plugin({
414
- // key: new PluginKey('tableOfContentImeFix'),
415
- // appendTransaction(transactions, _oldState, newState) {
416
- // if (transactions.some(tr => tr.getMeta('composition'))) {
417
- // return null
418
- // }
419
- // const imePluginState = imeCompositionPluginKey.getState(newState) as { isComposing?: boolean } | null
420
- // if (imePluginState?.isComposing) {
421
- // return null
422
- // }
423
- // return null
424
- // },
425
- // }),
426
- // ]
427
- // }
428
- // }).configure({
429
- // getIndex: getHierarchicalIndexes,
430
- // ...(tableOfContentsOptions || {}),
431
- // onUpdate(data, isCreate) {
432
- // // 先调用用户传入的 onUpdate 回调(如果存在)
433
- // tableOfContentsOptions?.onUpdate?.(data, isCreate)
434
-
435
- // // 然后调用我们的 onTocUpdate 回调
436
- // setTimeout(() => {
437
- // onTocUpdate?.(data.map(content => ({
438
- // id: content.id,
439
- // isActive: content.isActive,
440
- // isScrolledOver: content.isScrolledOver,
441
- // itemIndex: content.itemIndex,
442
- // level: content.level,
443
- // originalLevel: content.originalLevel,
444
- // pos: content.pos,
445
- // textContent: content.textContent,
446
- // })))
447
- // }, 60)
448
- // }
449
- // })
53
+ };
@@ -32,6 +32,16 @@ export type StateSelectionOptions = {
32
32
  export type TableInfo = {
33
33
  map: TableMap;
34
34
  } & FindNodeResult;
35
+ export type CellWithRect = {
36
+ pos: number;
37
+ node: Node;
38
+ rect: {
39
+ left: number;
40
+ right: number;
41
+ top: number;
42
+ bottom: number;
43
+ };
44
+ };
35
45
  export declare function isHTMLElement(n: unknown): n is HTMLElement;
36
46
  export type DomCellAroundResult = {
37
47
  type: 'cell';
@@ -43,22 +53,10 @@ export type DomCellAroundResult = {
43
53
  tbodyNode: HTMLTableSectionElement | null;
44
54
  };
45
55
  export declare function safeClosest<T extends Element>(start: Element | null, selector: string): T | null;
46
- /**
47
- * Walk up from an element until we find a TD/TH or the table wrapper.
48
- * Returns the found element plus its tbody (if present).
49
- */
50
56
  export declare function domCellAround(target: Element): DomCellAroundResult | undefined;
51
- /**
52
- * Clamps a value between min and max bounds
53
- */
54
57
  export declare function clamp(value: number, min: number, max: number): number;
55
- /**
56
- * Checks if a cell is merged (has colspan or rowspan > 1)
57
- */
58
58
  export declare function isCellMerged(node: Node | null): boolean;
59
- /**
60
- * Get information about the table at the current selection or a specific position.
61
- */
59
+ export declare function getUniqueCellsWithRect(table: TableInfo): CellWithRect[];
62
60
  export declare function getTable(editor: Editor | null, tablePos?: number): {
63
61
  map: TableMap;
64
62
  node: Node;
@@ -66,40 +64,16 @@ export declare function getTable(editor: Editor | null, tablePos?: number): {
66
64
  start: number;
67
65
  depth: number;
68
66
  } | null;
69
- /**
70
- * Checks if the current text selection is inside a table cell.
71
- */
72
67
  export declare function isSelectionInCell(state: EditorState): boolean;
73
- /**
74
- * Runs a function while preserving the editor's selection.
75
- */
76
68
  export declare function runPreservingCursor(editor: Editor, fn: () => void): boolean;
77
- /**
78
- * Determines whether a table cell is effectively empty.
79
- */
80
69
  export declare function isCellEmpty(cellNode: Node): boolean;
81
- /**
82
- * Counts how many consecutive empty rows exist at the bottom of a given table.
83
- */
84
70
  export declare function countEmptyRowsFromEnd(editor: Editor, tablePos: number): number;
85
- /**
86
- * Counts how many consecutive empty columns exist at the right edge of a given table.
87
- */
88
71
  export declare function countEmptyColumnsFromEnd(editor: Editor, tablePos: number): number;
89
- /**
90
- * Rounds a number with a symmetric "dead-zone" around integer boundaries.
91
- */
92
72
  export declare function marginRound(num: number, margin?: number): number;
93
- /**
94
- * Selects table cells by their (row, col) coordinates.
95
- */
96
73
  export declare function selectCellsByCoords(editor: Editor | null, tablePos: number, coords: {
97
74
  row: number;
98
75
  col: number;
99
76
  }[], options?: BaseSelectionOptions | DispatchSelectionOptions): EditorState | Transaction | void;
100
- /**
101
- * Select the cell at (row, col) using `cellAround` to respect merged cells.
102
- */
103
77
  export declare function selectCellAt({ editor, row, col, tablePos, dispatch, }: {
104
78
  editor: Editor | null;
105
79
  row: number;
@@ -107,13 +81,7 @@ export declare function selectCellAt({ editor, row, col, tablePos, dispatch, }:
107
81
  tablePos?: number;
108
82
  dispatch?: (tr: Transaction) => void;
109
83
  }): boolean;
110
- /**
111
- * Selects a boundary cell of the table based on orientation.
112
- */
113
84
  export declare function selectLastCell(editor: Editor, tableNode: Node, tablePos: number, orientation: Orientation): boolean;
114
- /**
115
- * Get all (row, col) coordinates for a given row or column index.
116
- */
117
85
  export declare function getIndexCoordinates({ editor, index, orientation, tablePos, }: {
118
86
  editor: Editor | null;
119
87
  index: number;
@@ -123,39 +91,38 @@ export declare function getIndexCoordinates({ editor, index, orientation, tableP
123
91
  row: number;
124
92
  col: number;
125
93
  }[] | null;
126
- /**
127
- * Given a DOM cell element, find its (row, col) indices within the table.
128
- */
94
+ export declare function getRowOriginCoords({ editor, rowIndex, tablePos, includeMerged, }: {
95
+ editor: Editor | null;
96
+ rowIndex: number;
97
+ tablePos?: number;
98
+ includeMerged?: boolean;
99
+ }): {
100
+ row: number;
101
+ col: number;
102
+ }[] | null;
103
+ export declare function getRowOriginCells(editor: Editor | null, rowIndex: number, tablePos?: number, options?: {
104
+ includeMerged?: boolean;
105
+ }): {
106
+ cells: CellInfo[];
107
+ mergedCells: CellInfo[];
108
+ };
129
109
  export declare function getCellIndicesFromDOM(cell: HTMLTableCellElement, tableNode: Node | null, editor: Editor): {
130
110
  rowIndex: number;
131
111
  colIndex: number;
132
112
  } | null;
133
- /**
134
- * Given a DOM element inside a table, find the corresponding table node and its position.
135
- */
136
113
  export declare function getTableFromDOM(tableElement: HTMLElement, editor: Editor): {
137
114
  node: Node;
138
115
  pos: number;
139
116
  } | null;
140
- /**
141
- * Checks if a node is a table node
142
- */
143
117
  export declare function isTableNode(node: Node | null | undefined): node is Node;
144
- /**
145
- * Get all cells (and unique merged cells) from a specific row.
146
- */
147
118
  export declare function getRowCells(editor: Editor | null, rowIndex?: number, tablePos?: number): {
148
119
  cells: CellInfo[];
149
120
  mergedCells: CellInfo[];
150
121
  };
151
- /**
152
- * Collect cells (and unique merged cells) from the current table.
153
- */
154
122
  export declare function getColumnCells(editor: Editor | null, columnIndex?: number, tablePos?: number): {
155
123
  cells: CellInfo[];
156
124
  mergedCells: CellInfo[];
157
125
  };
158
- /**
159
- * Compare two DOMRects for equality (within a small tolerance)
160
- */
126
+ export declare function adjustRowspanForRowInsert(editor: Editor, tablePos: number, insertRowIndex: number): boolean;
127
+ export declare function adjustRowspanForRowDelete(editor: Editor, tablePos: number, deleteRowIndex: number): boolean;
161
128
  export declare function rectEq(rect1: DOMRect | null, rect2: DOMRect | null): boolean;