import { Editor, Transforms, Element } from "slate";
const isAlignTarget = (editor, it, direction) => Element.isElement(it) && editor.acceptsAttributes(it.type, { align: direction });
const createAlignHandler = (direction) => ({
  shouldDisplay: ({ editor }) => {
    return Array.from(Editor.nodes(editor, { match: (it) => isAlignTarget(editor, it, direction) })).length > 0;
  },
  isActive: ({ editor }) => {
    return Array.from(Editor.nodes(editor, { match: (it) => isAlignTarget(editor, it, direction) && it.align === direction })).length > 0;
  },
  toggle: ({ editor }) => {
    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")
};
export {
  alignCenterButton,
  alignEndButton,
  alignJustifyButton,
  alignStartButton
};
//# sourceMappingURL=alignButton.js.map
