import { $insertNodeToNearestRoot } from "@lexical/utils";
import { COMMAND_PRIORITY_EDITOR, createCommand, defineExtension } from "lexical";
import { $createYouTubeNode, YouTubeNode } from "./youtube-node.js";
const INSERT_YOUTUBE_COMMAND = createCommand('INSERT_YOUTUBE_COMMAND');
const YouTubeExtension = defineExtension({
    name: '@byline/richtext-lexical/YouTube',
    nodes: ()=>[
            YouTubeNode
        ],
    register: (editor)=>editor.registerCommand(INSERT_YOUTUBE_COMMAND, (payload)=>{
            const youTubeNode = $createYouTubeNode(payload);
            $insertNodeToNearestRoot(youTubeNode);
            return true;
        }, COMMAND_PRIORITY_EDITOR)
});
export { INSERT_YOUTUBE_COMMAND, YouTubeExtension };
