"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "extractSliceFromStep", {
  enumerable: true,
  get: function get() {
    return _extractSliceFromStep.extractSliceFromStep;
  }
});
Object.defineProperty(exports, "filterChildrenBetween", {
  enumerable: true,
  get: function get() {
    return _filterChildrenBetween.filterChildrenBetween;
  }
});
Object.defineProperty(exports, "isElementInTableCell", {
  enumerable: true,
  get: function get() {
    return _isElementInTableCell.isElementInTableCell;
  }
});
Object.defineProperty(exports, "isEmptyParagraph", {
  enumerable: true,
  get: function get() {
    return _isEmptyParagraph.isEmptyParagraph;
  }
});
Object.defineProperty(exports, "isInLayoutColumn", {
  enumerable: true,
  get: function get() {
    return _isInLayoutColumn.isInLayoutColumn;
  }
});
Object.defineProperty(exports, "isLastItemMediaGroup", {
  enumerable: true,
  get: function get() {
    return _isLastItemMediaGroup.isLastItemMediaGroup;
  }
});
Object.defineProperty(exports, "isTextSelection", {
  enumerable: true,
  get: function get() {
    return _isTextSelection.isTextSelection;
  }
});
Object.defineProperty(exports, "isValidPosition", {
  enumerable: true,
  get: function get() {
    return _isValidPosition.isValidPosition;
  }
});
Object.defineProperty(exports, "nonNullable", {
  enumerable: true,
  get: function get() {
    return _nonNullable.nonNullable;
  }
});
exports.removeBlockMarks = void 0;
Object.defineProperty(exports, "setAllSelection", {
  enumerable: true,
  get: function get() {
    return _setAllSelection.setAllSelection;
  }
});
Object.defineProperty(exports, "setCellSelection", {
  enumerable: true,
  get: function get() {
    return _setCellSelection.setCellSelection;
  }
});
Object.defineProperty(exports, "setNodeSelection", {
  enumerable: true,
  get: function get() {
    return _setNodeSelection.setNodeSelection;
  }
});
Object.defineProperty(exports, "setTextSelection", {
  enumerable: true,
  get: function get() {
    return _setTextSelection.setTextSelection;
  }
});
exports.stepAddsOneOf = stepAddsOneOf;
Object.defineProperty(exports, "stepHasSlice", {
  enumerable: true,
  get: function get() {
    return _stepHasSlice.stepHasSlice;
  }
});
var _stepHasSlice = require("./stepHasSlice");
var _isEmptyParagraph = require("./isEmptyParagraph");
var _extractSliceFromStep = require("./extractSliceFromStep");
var _isTextSelection = require("./isTextSelection");
var _isElementInTableCell = require("./isElementInTableCell");
var _isLastItemMediaGroup = require("./isLastItemMediaGroup");
var _setNodeSelection = require("./setNodeSelection");
var _setTextSelection = require("./setTextSelection");
var _setAllSelection = require("./setAllSelection");
var _setCellSelection = require("./setCellSelection");
var _nonNullable = require("./nonNullable");
var _isValidPosition = require("./isValidPosition");
var _isInLayoutColumn = require("./isInLayoutColumn");
var _filterChildrenBetween = require("./filterChildrenBetween");
/**
 * Checks whether a given step is adding nodes of given nodeTypes
 *
 * @param step Step to check
 * @param nodeTypes NodeTypes being added
 */
function stepAddsOneOf(step, nodeTypes) {
  var adds = false;
  if (!(0, _stepHasSlice.stepHasSlice)(step)) {
    return adds;
  }
  step.slice.content.descendants(function (node) {
    if (nodeTypes.has(node.type)) {
      adds = true;
    }
    return !adds;
  });
  return adds;
}
var removeBlockMarks = exports.removeBlockMarks = function removeBlockMarks(state, marks) {
  var selection = state.selection,
    schema = state.schema;
  var tr = state.tr;

  // Marks might not exist in Schema
  var marksToRemove = marks.filter(Boolean);
  if (marksToRemove.length === 0) {
    return undefined;
  }

  /** Saves an extra dispatch */
  var blockMarksExists = false;
  var hasMark = function hasMark(mark) {
    return marksToRemove.indexOf(mark.type) > -1;
  };
  /**
   * When you need to toggle the selection
   * when another type which does not allow alignment is applied
   */
  state.doc.nodesBetween(selection.from, selection.to, function (node, pos) {
    if (node.type === schema.nodes.paragraph && node.marks.some(hasMark)) {
      blockMarksExists = true;
      var resolvedPos = state.doc.resolve(pos);
      var withoutBlockMarks = node.marks.filter(not(hasMark));
      tr = tr.setNodeMarkup(resolvedPos.pos, undefined, node.attrs, withoutBlockMarks);
    }
  });
  return blockMarksExists ? tr : undefined;
};
var not = function not(fn) {
  return function (arg) {
    return !fn(arg);
  };
};
// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export

// eslint-disable-next-line @atlaskit/editor/no-re-export