import { SharedStateKey } from "../../behavior/SharedState/utils.js";
import { generateEntityId } from "../../../utils/entity-id.js";
import { MermaidConsts } from "./MermaidSpecs/index.js";
export const addMermaid = {
    isEnable(state) {
        return state.selection.empty;
    },
    run(state, dispatch, _view) {
        const newEntityId = generateEntityId(MermaidConsts.NodeName);
        const sharedKey = SharedStateKey.define({ name: newEntityId });
        const tr = state.tr.insert(state.selection.from, MermaidConsts.nodeType(state.schema).create({
            [MermaidConsts.NodeAttrs.content]: [
                'sequenceDiagram',
                '\tAlice->>Bob: Hi Bob',
                '\tBob->>Alice: Hi Alice',
            ].join('\n'),
            [MermaidConsts.NodeAttrs.newCreated]: true,
            [MermaidConsts.NodeAttrs.EntityId]: newEntityId,
        }));
        sharedKey.appendTransaction.set(tr, { editing: true });
        dispatch(tr);
    },
};
//# sourceMappingURL=actions.js.map
