"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Slate = require("slate");
const isAlignTarget = (editor, it, direction) => Slate.Element.isElement(it) && editor.acceptsAttributes(it.type, { align: direction });
const createAlignHandler = (direction) => ({
  shouldDisplay: ({ editor }) => {
    return Array.from(Slate.Editor.nodes(editor, { match: (it) => isAlignTarget(editor, it, direction) })).length > 0;
  },
  isActive: ({ editor }) => {
    return Array.from(Slate.Editor.nodes(editor, { match: (it) => isAlignTarget(editor, it, direction) && it.align === direction })).length > 0;
  },
  toggle: ({ editor }) => {
    Slate.Transforms.setNodes(editor, {
      align: direction
    }, {
      match: (it) => isAlignTarget(editor, it, direction)
    });
  }
});
const alignStartButton = {
  label: "Align left",
  blueprintIcon: "align-left",
  ...createAlignHandler(void 0)
};
const alignEndButton = {
  label: "Align right",
  blueprintIcon: "align-right",
  ...createAlignHandler("end")
};
const alignCenterButton = {
  label: "Align center",
  blueprintIcon: "align-center",
  ...createAlignHandler("center")
};
const alignJustifyButton = {
  label: "Justify",
  blueprintIcon: "align-justify",
  ...createAlignHandler("justify")
};
exports.alignCenterButton = alignCenterButton;
exports.alignEndButton = alignEndButton;
exports.alignJustifyButton = alignJustifyButton;
exports.alignStartButton = alignStartButton;
//# sourceMappingURL=alignButton.cjs.map
