Skip to content

Commit

Permalink
Fix link hotkey prevent default (#2005)
Browse files Browse the repository at this point in the history
* Fix link hotkey prevent default

* Create cool-grapes-jam.md
  • Loading branch information
O4epegb authored Nov 21, 2022
1 parent 383b03e commit eb6c51e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-grapes-jam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/plate-link": patch
---

Fix link hotkey prevent default
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,11 @@ export const useFloatingLinkEdit = ({
useHotkeys(
triggerFloatingLinkHotkeys!,
(e) => {
e.preventDefault();

if (floatingLinkSelectors.mode() === 'edit') {
triggerFloatingLinkEdit(editor);
if (
floatingLinkSelectors.mode() === 'edit' &&
triggerFloatingLinkEdit(editor)
) {
e.preventDefault();
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ export const useFloatingLinkInsert = ({
useHotkeys(
triggerFloatingLinkHotkeys!,
(e) => {
e.preventDefault();

triggerFloatingLinkInsert(editor, {
focused,
});
if (triggerFloatingLinkInsert(editor, { focused })) {
e.preventDefault();
}
},
{
enableOnContentEditable: true,
Expand Down
2 changes: 2 additions & 0 deletions packages/nodes/link/src/utils/triggerFloatingLinkEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ export const triggerFloatingLinkEdit = <V extends Value>(
floatingLinkActions.text(text);

floatingLinkActions.isEditing(true);

return true;
};
2 changes: 2 additions & 0 deletions packages/nodes/link/src/utils/triggerFloatingLinkInsert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,6 @@ export const triggerFloatingLinkInsert = <V extends Value>(

floatingLinkActions.text(getEditorString(editor, editor.selection));
floatingLinkActions.show('insert', editor.id);

return true;
};

2 comments on commit eb6c51e

@vercel
Copy link

@vercel vercel bot commented on eb6c51e Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plate-examples – ./

plate-examples.vercel.app
plate-examples-udecode.vercel.app
plate-examples-git-main-udecode.vercel.app

@vercel
Copy link

@vercel vercel bot commented on eb6c51e Nov 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

plate – ./

plate.udecode.io
plate-udecode.vercel.app
plate-git-main-udecode.vercel.app
www.plate.udecode.io

Please sign in to comment.