编译错误,TypeError:类遗产 Us.MenuOption 不是对象或 null [closed]

compilation error, TypeError: class heritage Us.MenuOption is not an object or null [closed]

提问人:Alim 提问时间:11/17/2023 最后编辑:Alim 更新时间:11/17/2023 访问量:25

问:


编辑问题以包括所需的行为、特定问题或错误以及重现问题所需的最短代码。这将帮助其他人回答这个问题。

5天前关闭。

编译时会给出错误,可能错误与词法编辑器有关。在localhost上一切正常。TypeError:类遗产 Us.MenuOption 不是对象或 nullenter image description here

尝试寻找解决方案,但找不到。

export default function ContextMenuPlugin(): JSX.Element {

const [editor] = useLexicalComposerContext();

const 选项 = useMemo(() => { 返回 [ 新 ContextMenuOption(, { onSelect:(_node) => { editor.dispatchCommand(COPY_COMMAND, null); }, }), 新 ContextMenuOption(, { onSelect:(_node) => { editor.dispatchCommand(CUT_COMMAND, null); }, }), 新 ContextMenuOption(, { onSelect:(_node) => { navigator.clipboard.read().then(async (...参数) => { 常量数据 = new DataTransfer();CopyCutPaste

        const items = await navigator.clipboard.read();
        const item = items[0];

        const permission = await navigator.permissions.query({
          // @ts-ignore These types are incorrect.
          name: 'clipboard-read',
        });
        if (permission.state === 'denied') {
          alert('Not allowed to paste from clipboard.');
          return;
        }

        for (const type of item.types) {
          const dataString = await (await item.getType(type)).text();
          data.setData(type, dataString);
        }

        const event = new ClipboardEvent('paste', {
          clipboardData: data,
        });

        editor.dispatchCommand(PASTE_COMMAND, event);
      });
    },
  }),
  new ContextMenuOption(`Paste as Plain Text`, {
    onSelect: (_node) => {
      navigator.clipboard.read().then(async (...args) => {
        const permission = await navigator.permissions.query({
          // @ts-ignore These types are incorrect.
          name: 'clipboard-read',
        });

        if (permission.state === 'denied') {
          alert('Not allowed to paste from clipboard.');
          return;
        }

        const data = new DataTransfer();
        const items = await navigator.clipboard.readText();
        data.setData('text/plain', items);

        const event = new ClipboardEvent('paste', {
          clipboardData: data,
        });
        editor.dispatchCommand(PASTE_COMMAND, event);
      });
    },
  }),
  new ContextMenuOption(`Delete Node`, {
    onSelect: (_node) => {
      const selection = $getSelection();
      if ($isRangeSelection(selection)) {
        const currentNode = selection.anchor.getNode();
        const ancestorNodeWithRootAsParent = currentNode
          .getParents()
          .at(-2);

        ancestorNodeWithRootAsParent?.remove();
      }
    },
  }),
];

}, [编辑]);

javascript reactjs 打字稿

评论


答: 暂无答案