@witchcraft/editor
    Preparing search index...

    Type Alias WithOnTriggerByEmbeddedBlockOptions

    type WithOnTriggerByEmbeddedBlockOptions = {
        embeddedBlockCommandRedirect?: (
            commandName: string,
            args: any,
            context: {
                dispatch: Dispatch;
                editor: Editor;
                embedId: MaybeEmbedId;
                nodePos: number | undefined;
                rootEditor: Editor;
            },
        ) => boolean
        | undefined;
    }

    Hierarchy (View Summary)

    Index

    Properties

    embeddedBlockCommandRedirect?: (
        commandName: string,
        args: any,
        context: {
            dispatch: Dispatch;
            editor: Editor;
            embedId: MaybeEmbedId;
            nodePos: number | undefined;
            rootEditor: Editor;
        },
    ) => boolean
    | undefined

    When the editor is embedded and it's embedding a single block, certain commands are nullified and just return true and do nothing because they would break the embedding (e.g. enter, split, indent, etc).

    All such commands forward to the embeddedCommandRedirect command if it's available (otherwise a warning is logged). The Embedded extension takes care of registering this redirect and can redirect some of the commands to the root editor, but not all of them.

    You can use this function to handle the redirection yourself. You will get passed both editor instances (root and embedded) to facilitate communication. If you can handle the command, you should return a boolean as with a regular command. Otherwise you can return undefined to let the default handler take care of it.

    Note that if the change moves the node, the component will get remounted and the embedded editor will no longer exist (to, for example, focus it).

    The included EmbeddedNodeView takes care of auto-focusing when the selection matches it's position. So as a workaround for focus at least, you can use tr.setNodeSelection(nodePos + offset). Note the use of offset. The node's position will have probably changed depending on the command so you will need to know how much to offset it or have some way to find it's position again. While the embedId is provided, it's not guaranteed there is only one node embedding that id, there might be multiple. A better way is to first find the parent embedding item id before executing your command, note the blockId, then use it to find the node again.

    See redirectFromEmbedded for creating redirectable commands.