"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addImage = void 0;
const ImageSpecs_1 = require("./ImageSpecs/index.js");
const const_1 = require("./const.js");
const addImage = (schema) => {
    return {
        isEnable: (state) => state.selection.empty,
        run(state, dispatch, _view, attrs) {
            const params = attrs;
            if (params?.src) {
                const { src, title, alt } = params;
                const imgAttrs = {
                    [const_1.ImageAttr.Src]: src,
                    [const_1.ImageAttr.Title]: title ?? '',
                    [const_1.ImageAttr.Alt]: alt ?? '',
                };
                dispatch(state.tr.insert(state.selection.from, (0, ImageSpecs_1.imageType)(schema).create(imgAttrs)));
            }
        },
    };
};
exports.addImage = addImage;
//# sourceMappingURL=actions.js.map
