"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fixPastePlugin = void 0;
const prosemirror_model_1 = require("prosemirror-model");
const prosemirror_state_1 = require("prosemirror-state");
const CheckboxSpecs_1 = require("../CheckboxSpecs/index.js");
const fixPastePlugin = () => new prosemirror_state_1.Plugin({
    props: {
        transformPasted(slice) {
            const { firstChild } = slice.content;
            if (firstChild && firstChild.type === (0, CheckboxSpecs_1.checkboxType)(firstChild.type.schema)) {
                // When paste html with checkboxes and checkbox is first node,
                // pm creates slice with broken openStart and openEnd.
                // And content is inserted without a container block for checkboxes.
                // It is fixed by create new slice with zeroed openStart and openEnd.
                return new prosemirror_model_1.Slice(slice.content, 0, 0);
            }
            return slice;
        },
    },
});
exports.fixPastePlugin = fixPastePlugin;
//# sourceMappingURL=fix-paste.js.map
