import { imageType } from "./ImageSpecs/index.js";
import { ImageAttr } from "./const.js";
export 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 = {
                    [ImageAttr.Src]: src,
                    [ImageAttr.Title]: title ?? '',
                    [ImageAttr.Alt]: alt ?? '',
                };
                dispatch(state.tr.insert(state.selection.from, imageType(schema).create(imgAttrs)));
            }
        },
    };
};
//# sourceMappingURL=actions.js.map
