Skip to content

Commit

Permalink
fix: allow edges when using useEditorPopover
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas-C committed Feb 18, 2025
1 parent 92f7102 commit cec2f10
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 1 addition & 5 deletions packages/editor-components/src/hooks/useEditorPopover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ export const useEditorPopover = ({ triggerRef, ...opts }: UseEditorPopover) => {
const handleKeyDown = (event: KeyboardEvent) => {
const { selection } = editor;
if (event.key !== "Enter" || !isActive || !isFocused || !selection) return;
if (
Range.isCollapsed(selection) &&
!editor.isEdge(selection.anchor, selection.anchor.path) &&
document.activeElement?.contains(triggerRef.current)
) {
if (Range.isCollapsed(selection) && document.activeElement?.contains(triggerRef.current)) {
event.preventDefault();
popover.setOpen(!popover.open);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/editor/src/playground.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { breakPlugin } from "./plugins/break/breakPlugin";
import { softBreakPlugin } from "./plugins/break/softBreakPlugin";
import { headingPlugin } from "./plugins/heading/headingPlugin";
import { toggleHeading } from "./plugins/heading/transforms/toggleHeading";
import { inlineNavigationPlugin } from "./plugins/inlineNavigation/inlineNavigationPlugin";
import { linkPlugin } from "./plugins/link/linkPlugin";
import { type LinkElement } from "./plugins/link/linkTypes";
import { listPlugin } from "./plugins/list/listPlugin";
Expand Down Expand Up @@ -240,6 +241,7 @@ export const EditorPlayground: StoryFn = () => {
const [editor] = useState(() =>
createSlate({
plugins: [
inlineNavigationPlugin,
sectionPlugin,
headingPlugin,
configuredMarkPlugin,
Expand Down

0 comments on commit cec2f10

Please sign in to comment.