Skip to content

Commit 04fb2b0

Browse files
authored
Improve table selection (#3167)
1 parent 2ce5311 commit 04fb2b0

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/roosterjs-content-model-core/lib/corePlugin/selection/SelectionPlugin.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ class SelectionPlugin implements PluginWithState<SelectionPluginState> {
559559

560560
range.setStart(posStart.node, posStart.offset);
561561
range.setEnd(posEnd.node, posEnd.offset);
562+
563+
if (range.toString() === '') {
564+
range.collapse(true /* toStart */);
565+
}
562566
} else {
563567
// Get deepest editable position in the cell
564568
const { node, offset } = normalizePos(cell, nodeOffset);

packages/roosterjs-content-model-plugins/lib/edit/EditPlugin.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,7 @@ export class EditPlugin implements EditorPlugin {
177177
) {
178178
const selection = this.editor.getDOMSelection();
179179
const startContainer =
180-
selection?.type == 'range' && selection.range.collapsed
181-
? selection.range.startContainer
182-
: null;
180+
selection?.type == 'range' ? selection.range.startContainer : null;
183181
const table = startContainer
184182
? this.editor.getDOMHelper().findClosestElementAncestor(startContainer, 'table')
185183
: null;
@@ -320,4 +318,4 @@ export class EditPlugin implements EditorPlugin {
320318
return false;
321319
}
322320
}
323-
}
321+
}

0 commit comments

Comments
 (0)