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