"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Slate = require("slate");
const AnchorElement = require("./AnchorElement.cjs");
class AnchorModifications {
  static unwrapAnchor(editor) {
    Slate.Transforms.unwrapNodes(editor, { match: AnchorElement.isAnchorElement });
  }
  static wrapAnchor(editor, url) {
    if (AnchorElement.isAnchorElementActive(editor)) {
      AnchorModifications.unwrapAnchor(editor);
    }
    const selection = editor.selection;
    const isCollapsed = selection ? Slate.Range.isCollapsed(selection) : false;
    const anchor = {
      type: "anchor",
      href: url,
      children: isCollapsed ? [{ text: url }] : [{ text: "" }]
    };
    if (isCollapsed) {
      Slate.Transforms.insertNodes(editor, anchor);
    } else {
      Slate.Transforms.wrapNodes(editor, anchor, { split: true });
      Slate.Transforms.collapse(editor, { edge: "end" });
    }
  }
}
exports.AnchorModifications = AnchorModifications;
//# sourceMappingURL=AnchorModifications.cjs.map
