@milkdown/preset-gfm 7.4.0 → 7.5.8

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 (54) hide show
  1. package/lib/__internal__/with-meta.d.ts.map +1 -1
  2. package/lib/composed/commands.d.ts +9 -5
  3. package/lib/composed/commands.d.ts.map +1 -1
  4. package/lib/composed/inputrules.d.ts.map +1 -1
  5. package/lib/composed/schema.d.ts.map +1 -1
  6. package/lib/index.d.ts.map +1 -1
  7. package/lib/index.es.js +816 -669
  8. package/lib/index.es.js.map +1 -1
  9. package/lib/mark/strike-through.d.ts.map +1 -1
  10. package/lib/node/footnote/definition.d.ts.map +1 -1
  11. package/lib/node/footnote/reference.d.ts.map +1 -1
  12. package/lib/node/table/command.d.ts +33 -0
  13. package/lib/node/table/command.d.ts.map +1 -0
  14. package/lib/node/table/index.d.ts +3 -30
  15. package/lib/node/table/index.d.ts.map +1 -1
  16. package/lib/node/table/input.d.ts +3 -0
  17. package/lib/node/table/input.d.ts.map +1 -0
  18. package/lib/node/table/schema.d.ts +6 -0
  19. package/lib/node/table/schema.d.ts.map +1 -0
  20. package/lib/node/table/utils.d.ts +21 -7
  21. package/lib/node/table/utils.d.ts.map +1 -1
  22. package/lib/node/task-list-item.d.ts.map +1 -1
  23. package/lib/plugin/auto-insert-span-plugin.d.ts +2 -0
  24. package/lib/plugin/auto-insert-span-plugin.d.ts.map +1 -0
  25. package/lib/plugin/index.d.ts +2 -1
  26. package/lib/plugin/index.d.ts.map +1 -1
  27. package/lib/plugin/keep-table-align-plugin.d.ts +2 -0
  28. package/lib/plugin/keep-table-align-plugin.d.ts.map +1 -0
  29. package/lib/plugin/remark-gfm-plugin.d.ts.map +1 -1
  30. package/lib/plugin/table-editing-plugin.d.ts.map +1 -1
  31. package/package.json +12 -17
  32. package/src/__internal__/with-meta.ts +4 -1
  33. package/src/composed/commands.ts +18 -2
  34. package/src/composed/inputrules.ts +1 -3
  35. package/src/composed/plugins.ts +4 -4
  36. package/src/composed/schema.ts +11 -1
  37. package/src/index.ts +16 -2
  38. package/src/mark/strike-through.ts +21 -9
  39. package/src/node/footnote/definition.ts +56 -54
  40. package/src/node/footnote/reference.ts +47 -45
  41. package/src/node/table/command.ts +304 -0
  42. package/src/node/table/index.ts +3 -450
  43. package/src/node/table/input.ts +90 -0
  44. package/src/node/table/schema.ts +215 -0
  45. package/src/node/table/utils.ts +163 -96
  46. package/src/node/task-list-item.ts +100 -88
  47. package/src/plugin/auto-insert-span-plugin.ts +12 -0
  48. package/src/plugin/index.ts +2 -1
  49. package/src/plugin/keep-table-align-plugin.ts +53 -0
  50. package/src/plugin/remark-gfm-plugin.ts +2 -1
  51. package/src/plugin/table-editing-plugin.ts +3 -1
  52. package/lib/plugin/auto-insert-zero-space-plugin.d.ts +0 -2
  53. package/lib/plugin/auto-insert-zero-space-plugin.d.ts.map +0 -1
  54. package/src/plugin/auto-insert-zero-space-plugin.ts +0 -55
@@ -1,12 +1,18 @@
1
1
  import type { ContentNodeWithPos } from '@milkdown/prose'
2
- import { cloneTr, findParentNode } from '@milkdown/prose'
3
- import type { Node } from '@milkdown/prose/model'
2
+ import { cloneTr, findParentNodeClosestToPos } from '@milkdown/prose'
3
+ import type { Node, ResolvedPos } from '@milkdown/prose/model'
4
4
  import type { Selection, Transaction } from '@milkdown/prose/state'
5
5
  import type { TableRect } from '@milkdown/prose/tables'
6
6
  import { CellSelection, TableMap } from '@milkdown/prose/tables'
7
7
 
8
8
  import type { Ctx } from '@milkdown/ctx'
9
- import { tableCellSchema, tableHeaderSchema, tableRowSchema, tableSchema } from '.'
9
+ import {
10
+ tableCellSchema,
11
+ tableHeaderRowSchema,
12
+ tableHeaderSchema,
13
+ tableRowSchema,
14
+ tableSchema,
15
+ } from './schema'
10
16
 
11
17
  /// @internal
12
18
  export interface CellPos {
@@ -27,31 +33,42 @@ export function createTable(ctx: Ctx, rowsCount = 3, colsCount = 3): Node {
27
33
 
28
34
  const rows = Array(rowsCount)
29
35
  .fill(0)
30
- .map((_, i) => tableRowSchema.type(ctx).create(null, i === 0 ? headerCells : cells))
36
+ .map((_, i) =>
37
+ i === 0
38
+ ? tableHeaderRowSchema.type(ctx).create(null, headerCells)
39
+ : tableRowSchema.type(ctx).create(null, cells)
40
+ )
31
41
 
32
42
  return tableSchema.type(ctx).create(null, rows)
33
43
  }
34
44
 
35
- /// Find the table node with position information for current selection.
36
- export function findTable(selection: Selection) {
37
- return findParentNode(node => node.type.spec.tableRole === 'table')(selection)
45
+ /// Find the table node with position information for target pos.
46
+ export function findTable($pos: ResolvedPos) {
47
+ return findParentNodeClosestToPos(
48
+ (node) => node.type.spec.tableRole === 'table'
49
+ )($pos)
38
50
  }
39
51
 
40
52
  /// Get cells in a column of a table.
41
- export function getCellsInCol(columnIndex: number, selection: Selection): CellPos[] | undefined {
42
- const table = findTable(selection)
43
- if (!table)
44
- return undefined
53
+ export function getCellsInCol(
54
+ columnIndex: number,
55
+ selection: Selection
56
+ ): CellPos[] | undefined {
57
+ const table = findTable(selection.$from)
58
+ if (!table) return undefined
45
59
  const map = TableMap.get(table.node)
46
- if (columnIndex < 0 || columnIndex >= map.width)
47
- return undefined
60
+ if (columnIndex < 0 || columnIndex >= map.width) return undefined
48
61
 
49
62
  return map
50
- .cellsInRect({ left: columnIndex, right: columnIndex + 1, top: 0, bottom: map.height })
63
+ .cellsInRect({
64
+ left: columnIndex,
65
+ right: columnIndex + 1,
66
+ top: 0,
67
+ bottom: map.height,
68
+ })
51
69
  .map((pos) => {
52
70
  const node = table.node.nodeAt(pos)
53
- if (!node)
54
- return undefined
71
+ if (!node) return undefined
55
72
  const start = pos + table.start
56
73
  return {
57
74
  pos: start,
@@ -63,20 +80,25 @@ export function getCellsInCol(columnIndex: number, selection: Selection): CellPo
63
80
  }
64
81
 
65
82
  /// Get cells in a row of a table.
66
- export function getCellsInRow(rowIndex: number, selection: Selection): CellPos[] | undefined {
67
- const table = findTable(selection)
68
- if (!table)
69
- return undefined
83
+ export function getCellsInRow(
84
+ rowIndex: number,
85
+ selection: Selection
86
+ ): CellPos[] | undefined {
87
+ const table = findTable(selection.$from)
88
+ if (!table) return undefined
70
89
  const map = TableMap.get(table.node)
71
- if (rowIndex < 0 || rowIndex >= map.height)
72
- return undefined
90
+ if (rowIndex < 0 || rowIndex >= map.height) return undefined
73
91
 
74
92
  return map
75
- .cellsInRect({ left: 0, right: map.width, top: rowIndex, bottom: rowIndex + 1 })
93
+ .cellsInRect({
94
+ left: 0,
95
+ right: map.width,
96
+ top: rowIndex,
97
+ bottom: rowIndex + 1,
98
+ })
76
99
  .map((pos) => {
77
100
  const node = table.node.nodeAt(pos)
78
- if (!node)
79
- return undefined
101
+ if (!node) return undefined
80
102
  const start = pos + table.start
81
103
  return {
82
104
  pos: start,
@@ -89,9 +111,8 @@ export function getCellsInRow(rowIndex: number, selection: Selection): CellPos[]
89
111
 
90
112
  /// Get all cells in a table.
91
113
  export function getAllCellsInTable(selection: Selection) {
92
- const table = findTable(selection)
93
- if (!table)
94
- return
114
+ const table = findTable(selection.$from)
115
+ if (!table) return
95
116
 
96
117
  const map = TableMap.get(table.node)
97
118
  const cells = map.cellsInRect({
@@ -122,7 +143,12 @@ export function selectTable(tr: Transaction) {
122
143
  }
123
144
 
124
145
  /// @internal
125
- export function addRowWithAlignment(ctx: Ctx, tr: Transaction, { map, tableStart, table }: TableRect, row: number) {
146
+ export function addRowWithAlignment(
147
+ ctx: Ctx,
148
+ tr: Transaction,
149
+ { map, tableStart, table }: TableRect,
150
+ row: number
151
+ ) {
126
152
  const rowPos = Array(row)
127
153
  .fill(0)
128
154
  .reduce((acc, _, i) => {
@@ -133,7 +159,9 @@ export function addRowWithAlignment(ctx: Ctx, tr: Transaction, { map, tableStart
133
159
  .fill(0)
134
160
  .map((_, col) => {
135
161
  const headerCol = table.nodeAt(map.map[col] as number)
136
- return tableCellSchema.type(ctx).createAndFill({ alignment: headerCol?.attrs.alignment }) as Node
162
+ return tableCellSchema
163
+ .type(ctx)
164
+ .createAndFill({ alignment: headerCol?.attrs.alignment }) as Node
137
165
  })
138
166
 
139
167
  tr.insert(rowPos, tableRowSchema.type(ctx).create(null, cells))
@@ -142,8 +170,19 @@ export function addRowWithAlignment(ctx: Ctx, tr: Transaction, { map, tableStart
142
170
 
143
171
  /// @internal
144
172
  export function selectLine(type: 'row' | 'col') {
145
- return (index: number) => (tr: Transaction) => {
146
- const table = findTable(tr.selection)
173
+ return (index: number, pos?: number) => (tr: Transaction) => {
174
+ pos = pos ?? tr.selection.from
175
+ const $pos = tr.doc.resolve(pos)
176
+ const $node = findParentNodeClosestToPos(
177
+ (node) => node.type.name === 'table'
178
+ )($pos)
179
+ const table = $node
180
+ ? {
181
+ node: $node.node,
182
+ from: $node.start,
183
+ }
184
+ : undefined
185
+
147
186
  const isRowSelection = type === 'row'
148
187
  if (table) {
149
188
  const map = TableMap.get(table.node)
@@ -153,15 +192,25 @@ export function selectLine(type: 'row' | 'col') {
153
192
  const lastCell = map.positionAt(
154
193
  isRowSelection ? index : map.height - 1,
155
194
  isRowSelection ? map.width - 1 : index,
156
- table.node,
195
+ table.node
157
196
  )
158
- const $lastCell = tr.doc.resolve(table.start + lastCell)
197
+ const $lastCell = tr.doc.resolve(table.from + lastCell)
159
198
 
160
- const createCellSelection = isRowSelection ? CellSelection.rowSelection : CellSelection.colSelection
199
+ const createCellSelection = isRowSelection
200
+ ? CellSelection.rowSelection
201
+ : CellSelection.colSelection
161
202
 
162
- const firstCell = map.positionAt(isRowSelection ? index : 0, isRowSelection ? 0 : index, table.node)
163
- const $firstCell = tr.doc.resolve(table.start + firstCell)
164
- return cloneTr(tr.setSelection(createCellSelection($lastCell, $firstCell) as unknown as Selection))
203
+ const firstCell = map.positionAt(
204
+ isRowSelection ? index : 0,
205
+ isRowSelection ? 0 : index,
206
+ table.node
207
+ )
208
+ const $firstCell = tr.doc.resolve(table.from + firstCell)
209
+ return cloneTr(
210
+ tr.setSelection(
211
+ createCellSelection($lastCell, $firstCell) as unknown as Selection
212
+ )
213
+ )
165
214
  }
166
215
  }
167
216
  return tr
@@ -178,11 +227,14 @@ export const selectCol = selectLine('col')
178
227
 
179
228
  function transpose<T>(array: T[][]) {
180
229
  return array[0]!.map((_, i) => {
181
- return array.map(column => column[i])
230
+ return array.map((column) => column[i])
182
231
  }) as T[][]
183
232
  }
184
233
 
185
- function convertArrayOfRowsToTableNode(tableNode: Node, arrayOfNodes: (Node | null)[][]) {
234
+ function convertArrayOfRowsToTableNode(
235
+ tableNode: Node,
236
+ arrayOfNodes: (Node | null)[][]
237
+ ) {
186
238
  const rowsPM = []
187
239
  const map = TableMap.get(tableNode)
188
240
  for (let rowIndex = 0; rowIndex < map.height; rowIndex++) {
@@ -190,8 +242,7 @@ function convertArrayOfRowsToTableNode(tableNode: Node, arrayOfNodes: (Node | nu
190
242
  const rowCells = []
191
243
 
192
244
  for (let colIndex = 0; colIndex < map.width; colIndex++) {
193
- if (!arrayOfNodes[rowIndex]![colIndex])
194
- continue
245
+ if (!arrayOfNodes[rowIndex]![colIndex]) continue
195
246
 
196
247
  const cellPos = map.map[rowIndex * map.width + colIndex]!
197
248
 
@@ -200,7 +251,7 @@ function convertArrayOfRowsToTableNode(tableNode: Node, arrayOfNodes: (Node | nu
200
251
  const newCell = oldCell.type.createChecked(
201
252
  Object.assign({}, cell.attrs),
202
253
  cell.content,
203
- cell.marks,
254
+ cell.marks
204
255
  )
205
256
  rowCells.push(newCell)
206
257
  }
@@ -211,7 +262,7 @@ function convertArrayOfRowsToTableNode(tableNode: Node, arrayOfNodes: (Node | nu
211
262
  const newTable = tableNode.type.createChecked(
212
263
  tableNode.attrs,
213
264
  rowsPM,
214
- tableNode.marks,
265
+ tableNode.marks
215
266
  )
216
267
 
217
268
  return newTable
@@ -243,7 +294,12 @@ function convertTableNodeToArrayOfRows(tableNode: Node) {
243
294
  return rows
244
295
  }
245
296
 
246
- function moveRowInArrayOfRows(rows: (Node | null)[][], indexesOrigin: number[], indexesTarget: number[], directionOverride: -1 | 1 | 0) {
297
+ function moveRowInArrayOfRows(
298
+ rows: (Node | null)[][],
299
+ indexesOrigin: number[],
300
+ indexesTarget: number[],
301
+ directionOverride: -1 | 1 | 0
302
+ ) {
247
303
  const direction = indexesOrigin[0]! > indexesTarget[0]! ? -1 : 1
248
304
 
249
305
  const rowsExtracted = rows.splice(indexesOrigin[0]!, indexesOrigin.length)
@@ -252,13 +308,11 @@ function moveRowInArrayOfRows(rows: (Node | null)[][], indexesOrigin: number[],
252
308
 
253
309
  if (directionOverride === -1 && direction === 1) {
254
310
  target = indexesTarget[0]! - 1
255
- }
256
- else if (directionOverride === 1 && direction === -1) {
311
+ } else if (directionOverride === 1 && direction === -1) {
257
312
  target = indexesTarget[indexesTarget.length - 1]! - positionOffset + 1
258
- }
259
- else {
260
- target
261
- = direction === -1
313
+ } else {
314
+ target =
315
+ direction === -1
262
316
  ? indexesTarget[0]!
263
317
  : indexesTarget[indexesTarget.length - 1]! - positionOffset
264
318
  }
@@ -267,7 +321,12 @@ function moveRowInArrayOfRows(rows: (Node | null)[][], indexesOrigin: number[],
267
321
  return rows
268
322
  }
269
323
 
270
- function moveTableColumn(table: ContentNodeWithPos, indexesOrigin: number[], indexesTarget: number[], direction: -1 | 1 | 0) {
324
+ function moveTableColumn(
325
+ table: ContentNodeWithPos,
326
+ indexesOrigin: number[],
327
+ indexesTarget: number[],
328
+ direction: -1 | 1 | 0
329
+ ) {
271
330
  let rows = transpose(convertTableNodeToArrayOfRows(table.node))
272
331
 
273
332
  rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction)
@@ -276,7 +335,12 @@ function moveTableColumn(table: ContentNodeWithPos, indexesOrigin: number[], ind
276
335
  return convertArrayOfRowsToTableNode(table.node, rows)
277
336
  }
278
337
 
279
- function moveTableRow(table: ContentNodeWithPos, indexesOrigin: number[], indexesTarget: number[], direction: -1 | 1 | 0) {
338
+ function moveTableRow(
339
+ table: ContentNodeWithPos,
340
+ indexesOrigin: number[],
341
+ indexesTarget: number[],
342
+ direction: -1 | 1 | 0
343
+ ) {
280
344
  let rows = convertTableNodeToArrayOfRows(table.node)
281
345
 
282
346
  rows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction)
@@ -294,11 +358,9 @@ function getSelectionRangeInColumn(columnIndex: number, tr: Transaction) {
294
358
  if (cells) {
295
359
  cells.forEach((cell) => {
296
360
  const maybeEndIndex = cell.node.attrs.colspan + i - 1
297
- if (maybeEndIndex >= startIndex)
298
- startIndex = i
361
+ if (maybeEndIndex >= startIndex) startIndex = i
299
362
 
300
- if (maybeEndIndex > endIndex)
301
- endIndex = maybeEndIndex
363
+ if (maybeEndIndex > endIndex) endIndex = maybeEndIndex
302
364
  })
303
365
  }
304
366
  }
@@ -318,8 +380,7 @@ function getSelectionRangeInColumn(columnIndex: number, tr: Transaction) {
318
380
  const indexes = []
319
381
  for (let i = startIndex; i <= endIndex; i++) {
320
382
  const maybeCells = getCellsInCol(i, tr.selection)
321
- if (maybeCells && maybeCells.length)
322
- indexes.push(i)
383
+ if (maybeCells && maybeCells.length) indexes.push(i)
323
384
  }
324
385
  startIndex = indexes[0]!
325
386
  endIndex = indexes[indexes.length - 1]!
@@ -327,7 +388,7 @@ function getSelectionRangeInColumn(columnIndex: number, tr: Transaction) {
327
388
  const firstSelectedColumnCells = getCellsInCol(startIndex, tr.selection)!
328
389
  const firstRowCells = getCellsInRow(0, tr.selection)!
329
390
  const $anchor = tr.doc.resolve(
330
- firstSelectedColumnCells[firstSelectedColumnCells.length - 1]!.pos,
391
+ firstSelectedColumnCells[firstSelectedColumnCells.length - 1]!.pos
331
392
  )
332
393
 
333
394
  let headCell: CellPos | undefined
@@ -340,8 +401,7 @@ function getSelectionRangeInColumn(columnIndex: number, tr: Transaction) {
340
401
  break
341
402
  }
342
403
  }
343
- if (headCell)
344
- break
404
+ if (headCell) break
345
405
  }
346
406
  }
347
407
 
@@ -357,11 +417,9 @@ function getSelectionRangeInRow(rowIndex: number, tr: Transaction) {
357
417
  const cells = getCellsInRow(i, tr.selection)
358
418
  cells!.forEach((cell) => {
359
419
  const maybeEndIndex = cell.node.attrs.rowspan + i - 1
360
- if (maybeEndIndex >= startIndex)
361
- startIndex = i
420
+ if (maybeEndIndex >= startIndex) startIndex = i
362
421
 
363
- if (maybeEndIndex > endIndex)
364
- endIndex = maybeEndIndex
422
+ if (maybeEndIndex > endIndex) endIndex = maybeEndIndex
365
423
  })
366
424
  }
367
425
  // looking for selection end row (endIndex)
@@ -378,15 +436,16 @@ function getSelectionRangeInRow(rowIndex: number, tr: Transaction) {
378
436
  const indexes = []
379
437
  for (let i = startIndex; i <= endIndex; i++) {
380
438
  const maybeCells = getCellsInRow(i, tr.selection)
381
- if (maybeCells && maybeCells.length)
382
- indexes.push(i)
439
+ if (maybeCells && maybeCells.length) indexes.push(i)
383
440
  }
384
441
  startIndex = indexes[0]!
385
442
  endIndex = indexes[indexes.length - 1]!
386
443
 
387
444
  const firstSelectedRowCells = getCellsInRow(startIndex, tr.selection)!
388
445
  const firstColumnCells = getCellsInCol(0, tr.selection)!
389
- const $anchor = tr.doc.resolve(firstSelectedRowCells[firstSelectedRowCells.length - 1]!.pos)
446
+ const $anchor = tr.doc.resolve(
447
+ firstSelectedRowCells[firstSelectedRowCells.length - 1]!.pos
448
+ )
390
449
 
391
450
  let headCell: CellPos | undefined
392
451
  for (let i = endIndex; i >= startIndex; i--) {
@@ -398,8 +457,7 @@ function getSelectionRangeInRow(rowIndex: number, tr: Transaction) {
398
457
  break
399
458
  }
400
459
  }
401
- if (headCell)
402
- break
460
+ if (headCell) break
403
461
  }
404
462
  }
405
463
 
@@ -407,35 +465,42 @@ function getSelectionRangeInRow(rowIndex: number, tr: Transaction) {
407
465
  return { $anchor, $head, indexes }
408
466
  }
409
467
 
468
+ export interface MoveColParams {
469
+ tr: Transaction
470
+ origin: number
471
+ target: number
472
+ select?: boolean
473
+ pos?: number
474
+ }
475
+
410
476
  /// If the selection is in a table,
411
477
  /// Move the columns at `origin` to `target` in current table.
412
478
  /// The `select` is true by default, which means the selection will be set to the moved column.
413
- export function moveCol(tr: Transaction, origin: number, target: number, select = true) {
414
- const table = findTable(tr.selection)
415
- if (!table)
416
- return tr
479
+ export function moveCol(moveColParams: MoveColParams) {
480
+ const { tr, origin, target, select = true, pos } = moveColParams
481
+ const $pos = pos != null ? tr.doc.resolve(pos) : tr.selection.$from
482
+ const table = findTable($pos)
483
+ if (!table) return tr
417
484
 
418
485
  const { indexes: indexesOriginColumn } = getSelectionRangeInColumn(origin, tr)
419
486
  const { indexes: indexesTargetColumn } = getSelectionRangeInColumn(target, tr)
420
487
 
421
- if (indexesOriginColumn.includes(target))
422
- return tr
488
+ if (indexesOriginColumn.includes(target)) return tr
423
489
 
424
490
  const newTable = moveTableColumn(
425
491
  table,
426
492
  indexesOriginColumn,
427
493
  indexesTargetColumn,
428
- 0,
494
+ 0
429
495
  )
430
496
 
431
497
  const _tr = cloneTr(tr).replaceWith(
432
498
  table.pos,
433
499
  table.pos + table.node.nodeSize,
434
- newTable,
500
+ newTable
435
501
  )
436
502
 
437
- if (!select)
438
- return _tr
503
+ if (!select) return _tr
439
504
 
440
505
  const map = TableMap.get(newTable)
441
506
  const start = table.start
@@ -451,35 +516,37 @@ export function moveCol(tr: Transaction, origin: number, target: number, select
451
516
  return _tr.setSelection(createCellSelection($lastCell, $firstCell))
452
517
  }
453
518
 
519
+ export interface MoveRowParams {
520
+ tr: Transaction
521
+ origin: number
522
+ target: number
523
+ select?: boolean
524
+ pos?: number
525
+ }
526
+
454
527
  /// If the selection is in a table,
455
528
  /// Move the rows at `origin` and `target` in current table.
456
529
  /// The `select` is true by default, which means the selection will be set to the moved row.
457
- export function moveRow(tr: Transaction, origin: number, target: number, select = true) {
458
- const table = findTable(tr.selection)
459
- if (!table)
460
- return tr
530
+ export function moveRow(moveRowParams: MoveRowParams) {
531
+ const { tr, origin, target, select = true, pos } = moveRowParams
532
+ const $pos = pos != null ? tr.doc.resolve(pos) : tr.selection.$from
533
+ const table = findTable($pos)
534
+ if (!table) return tr
461
535
 
462
536
  const { indexes: indexesOriginRow } = getSelectionRangeInRow(origin, tr)
463
537
  const { indexes: indexesTargetRow } = getSelectionRangeInRow(target, tr)
464
538
 
465
- if (indexesOriginRow.includes(target))
466
- return tr
539
+ if (indexesOriginRow.includes(target)) return tr
467
540
 
468
- const newTable = moveTableRow(
469
- table,
470
- indexesOriginRow,
471
- indexesTargetRow,
472
- 0,
473
- )
541
+ const newTable = moveTableRow(table, indexesOriginRow, indexesTargetRow, 0)
474
542
 
475
543
  const _tr = cloneTr(tr).replaceWith(
476
544
  table.pos,
477
545
  table.pos + table.node.nodeSize,
478
- newTable,
546
+ newTable
479
547
  )
480
548
 
481
- if (!select)
482
- return _tr
549
+ if (!select) return _tr
483
550
 
484
551
  const map = TableMap.get(newTable)
485
552
  const start = table.start