Skip to content

Commit

Permalink
Avoid disabling eslint rules in registry
Browse files Browse the repository at this point in the history
  • Loading branch information
12joan committed Dec 22, 2023
1 parent 35936d1 commit 30a7572
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ const items = [
const defaultItem = items.find((item) => item.value === ELEMENT_PARAGRAPH)!;

export function PlaygroundTurnIntoDropdownMenu(props: DropdownMenuProps) {
const editor = useEditorRef();
const openState = useOpenState();

// eslint-disable-next-line @typescript-eslint/no-shadow
const value: string = useEditorSelector((editor) => {
if (!isSelectionExpanded(editor)) {
const entry = findNode<TElement>(editor!, {
Expand All @@ -127,6 +123,9 @@ export function PlaygroundTurnIntoDropdownMenu(props: DropdownMenuProps) {
return ELEMENT_PARAGRAPH;
}, []);

const editor = useEditorRef();
const openState = useOpenState();

const selectedItem =
items.find((item) => item.value === value) ?? defaultItem;
const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,12 @@ import {
import { ToolbarButton } from './toolbar';

export function TableDropdownMenu(props: DropdownMenuProps) {
const editor = useEditorRef();

const tableSelected = useEditorSelector(
// eslint-disable-next-line @typescript-eslint/no-shadow
(editor) => someNode(editor, { match: { type: ELEMENT_TABLE } }),
[]
);

const editor = useEditorRef();
const openState = useOpenState();

return (
Expand Down
10 changes: 5 additions & 5 deletions apps/www/src/registry/default/plate-ui/table-element.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ const TableFloatingToolbar = React.forwardRef<
const element = useElement<TTableElement>();
const { props: buttonProps } = useRemoveNodeButton({ element });

const readOnly = useReadOnly();
const selected = useSelected();
const editor = useEditorRef();

const selectionCollapsed = useEditorSelector(
// eslint-disable-next-line @typescript-eslint/no-shadow
(editor) => !isSelectionExpanded(editor),
[]
);

const readOnly = useReadOnly();
const selected = useSelected();
const editor = useEditorRef();

const collapsed = !readOnly && selected && selectionCollapsed;
const open = !readOnly && selected;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ const items = [
const defaultItem = items.find((item) => item.value === ELEMENT_PARAGRAPH)!;

export function TurnIntoDropdownMenu(props: DropdownMenuProps) {
const editor = useEditorRef();
const openState = useOpenState();

// eslint-disable-next-line @typescript-eslint/no-shadow
const value: string = useEditorSelector((editor) => {
if (isCollapsed(editor.selection)) {
const entry = findNode<TElement>(editor, {
Expand All @@ -97,6 +93,9 @@ export function TurnIntoDropdownMenu(props: DropdownMenuProps) {
return ELEMENT_PARAGRAPH;
}, []);

const editor = useEditorRef();
const openState = useOpenState();

const selectedItem =
items.find((item) => item.value === value) ?? defaultItem;
const { icon: SelectedItemIcon, label: selectedItemLabel } = selectedItem;
Expand Down

0 comments on commit 30a7572

Please sign in to comment.