import { VideoAttr } from "./VideoSpecs/const.js";
import { parseVideoUrl } from "./VideoSpecs/md-video.js";
import { videoType } from "./VideoSpecs/utils.js";
export const addVideo = {
    isEnable(state) {
        return state.selection.empty;
    },
    run(state, dispatch, _view, attrs) {
        if (!attrs || !attrs.service || !attrs.url) {
            return;
        }
        const { service } = attrs;
        const videoID = parseVideoUrl(service, attrs.url);
        dispatch(state.tr.insert(state.selection.from, videoType(state.schema).create({
            [VideoAttr.Service]: service,
            [VideoAttr.VideoID]: videoID,
        })));
    },
};
//# sourceMappingURL=actions.js.map
