Skip to content

Commit

Permalink
Use editor API isCollapsed
Browse files Browse the repository at this point in the history
  • Loading branch information
cskrov committed Feb 5, 2025
1 parent 8191a7a commit ff15b40
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
3 changes: 1 addition & 2 deletions frontend/src/plate/toolbar/toolbars/floating-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { useSelection } from '@app/plate/hooks/use-selection';
import { FloatingRedaktoerToolbarButtons } from '@app/plate/toolbar/toolbars/floating-redaktoer-toolbar-buttons';
import { FloatingSaksbehandlerToolbarButtons } from '@app/plate/toolbar/toolbars/floating-saksbehandler-toolbar-buttons';
import { useMyPlateEditorRef } from '@app/plate/types';
import { RangeApi } from '@udecode/plate';
import { BaseTablePlugin } from '@udecode/plate-table';
import { useMemo, useState } from 'react';
import { styled } from 'styled-components';
Expand Down Expand Up @@ -38,7 +37,7 @@ const FloatingToolbar = ({ editorId, container, children }: FloatingToolbarProps
[container, position, toolbarRef],
);

if (isInTable || !isFocused || position === null || RangeApi.isCollapsed(selection)) {
if (isInTable || !isFocused || position === null || editor.api.isCollapsed()) {
return null;
}

Expand Down
13 changes: 2 additions & 11 deletions frontend/src/plate/utils/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@ import type {
RichTextEditor,
RichTextEditorElement,
} from '@app/plate/types';
import {
type Descendant,
ElementApi,
NodeApi,
RangeApi,
type TElement,
type TNode,
type TText,
TextApi,
} from '@udecode/plate';
import { type Descendant, ElementApi, NodeApi, type TElement, type TNode, type TText, TextApi } from '@udecode/plate';
import type { PlateEditor } from '@udecode/plate-core/react';
import { HEADING_KEYS } from '@udecode/plate-heading';
import { BaseBulletedListPlugin, BaseNumberedListPlugin } from '@udecode/plate-list';
Expand Down Expand Up @@ -87,7 +78,7 @@ const isContained = (editor: PlateEditor, type: string) => {
const match = { type };
const anchorPlaceholderEntry = editor.api.node({ match, at: editor.selection.anchor });

if (RangeApi.isCollapsed(editor.selection)) {
if (editor.api.isCollapsed()) {
return anchorPlaceholderEntry !== undefined;
}

Expand Down

0 comments on commit ff15b40

Please sign in to comment.