import { SharedStateKey } from "../../behavior/SharedState/index.js";
import { generateEntityId } from "../../../utils/entity-id.js";
import { YfmHtmlBlockConsts, yfmHtmlBlockNodeType } from "./YfmHtmlBlockSpecs/const.js";
export const addYfmHtmlBlock = {
    isEnable(state) {
        return state.selection.empty;
    },
    run(state, dispatch, _view) {
        const entityId = generateEntityId(YfmHtmlBlockConsts.NodeName);
        const sharedKey = SharedStateKey.define({ name: entityId });
        const tr = state.tr.insert(state.selection.from, yfmHtmlBlockNodeType(state.schema).create({
            [YfmHtmlBlockConsts.NodeAttrs.srcdoc]: '\n',
            [YfmHtmlBlockConsts.NodeAttrs.newCreated]: true,
            [YfmHtmlBlockConsts.NodeAttrs.EntityId]: entityId,
        }));
        sharedKey.appendTransaction.set(tr, { editing: true });
        dispatch(tr);
    },
};
//# sourceMappingURL=actions.js.map
