Skip to content

Commit

Permalink
Merge pull request #3740 from udecode/focus/selection
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfeng33 authored Nov 7, 2024
2 parents be2d222 + 1f2ec22 commit 0b427c2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-dots-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-selection': patch
---

Fix enter can't unselect.
19 changes: 16 additions & 3 deletions packages/selection/src/react/BlockSelectionPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,22 @@ export const BlockSelectionAfterEditable: EditableSiblingComponent = () => {

export const BlockSelectionPlugin = createTPlatePlugin<BlockSelectionConfig>({
key: 'blockSelection',
extendEditor: ({ api, editor, getOptions }) => {
const { setSelection } = editor;

editor.setSelection = (...args) => {
if (
getOptions().selectedIds!.size > 0 &&
!editor.getOption(BlockMenuPlugin, 'openId')
) {
api.blockSelection.unselect();
}

setSelection(...args);
};

return editor;
},
options: {
areaOptions: {
behaviour: {
Expand Down Expand Up @@ -301,9 +317,6 @@ export const BlockSelectionPlugin = createTPlatePlugin<BlockSelectionConfig>({
const target = event.target as HTMLElement;

if (target.dataset.platePreventUnselect) return;

console.log(editor.getOption(BlockMenuPlugin, 'openId'), 'fj');

if (
event.button === 0 &&
getOptions().selectedIds!.size > 0 &&
Expand Down

0 comments on commit 0b427c2

Please sign in to comment.