Skip to content

Commit be11207

Browse files
authored
fix: πŸ› backward select text in table cell (#1766)
βœ… Closes: #1751
1 parent 1e3ffcb commit be11207

File tree

1 file changed

+11
-1
lines changed
  • packages/components/src/table-block/view

1 file changed

+11
-1
lines changed

Diff for: β€Žpackages/components/src/table-block/view/view.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
ViewMutationRecord,
99
} from '@milkdown/prose/view'
1010
import type { Ctx } from '@milkdown/ctx'
11-
import { NodeSelection } from '@milkdown/prose/state'
11+
import { NodeSelection, TextSelection } from '@milkdown/prose/state'
1212
import { findParent } from '@milkdown/prose'
1313
import { CellSelection } from '@milkdown/prose/tables'
1414
import { defIfNotExists } from '../../__internal__/helper'
@@ -69,8 +69,18 @@ export class TableNodeView implements NodeView {
6969
(node) =>
7070
node.type.name === 'table_cell' || node.type.name === 'table_header'
7171
)($pos)
72+
7273
if (!node) return false
7374

75+
// if the selection is a text selection, and the current node is the same as the node, return false
76+
if (state.selection instanceof TextSelection) {
77+
const currentNode = findParent(
78+
(node) =>
79+
node.type.name === 'table_cell' || node.type.name === 'table_header'
80+
)(state.selection.$from)
81+
if (currentNode?.node === node.node) return false
82+
}
83+
7484
const { from } = node
7585

7686
const selection = NodeSelection.create(state.doc, from + 1)

0 commit comments

Comments
Β (0)