MCPcopy
hub / github.com/udecode/plate / useRemoveNodeButton

Function useRemoveNodeButton

packages/utils/src/react/hooks/useRemoveNodeButton.ts:4–19  ·  view source on GitHub ↗
({ element }: { element: TElement })

Source from the content-addressed store, hash-verified

2import type { TElement } from '@platejs/slate';
3
4export const useRemoveNodeButton = ({ element }: { element: TElement }) => {
5 const editor = useEditorRef();
6
7 return {
8 props: {
9 onClick: () => {
10 const path = editor.api.findPath(element);
11
12 editor.tf.removeNodes({ at: path });
13 },
14 onMouseDown: (e: React.MouseEvent<HTMLButtonElement>) => {
15 e.preventDefault();
16 },
17 },
18 };
19};

Callers 7

ColumnFloatingToolbarFunction · 0.90
MediaToolbarFunction · 0.90
ColumnFloatingToolbarFunction · 0.90
MediaToolbarFunction · 0.90

Calls 1

useEditorRefFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…