import { Extension as a } from "@tiptap/core";
import { Plugin as l, PluginKey as c } from "@tiptap/pm/state";
const u = a.create({
  name: "openLinkOnModClick",
  /**
   * Registers a ProseMirror plugin that intercepts click events.
   * Only handles Ctrl/Cmd+Click on link marks; all other clicks
   * fall through to the default editor behaviour.
   */
  addProseMirrorPlugins() {
    return [
      new l({
        key: new c("openLinkOnModClick"),
        props: {
          /**
           * ProseMirror click handler.
           *
           * @param view  - The editor view instance.
           * @param pos   - The document position under the cursor.
           * @param event - The native mouse event.
           * @returns `true` to consume the event, `false` to let other handlers process it.
           */
          handleClick(o, t, e) {
            if (!(e.ctrlKey || e.metaKey))
              return !1;
            const { doc: s } = o.state, r = s.resolve(t).marks().find((i) => i.type.name === "link");
            if (!r || !r.attrs.href)
              return !1;
            const n = String(r.attrs.href);
            return /^(javascript|data|vbscript):/i.test(n.trim()) ? !1 : (window.open(n, "_blank", "noopener,noreferrer"), e.preventDefault(), !0);
          }
        }
      })
    ];
  }
});
export {
  u as default
};
//# sourceMappingURL=openLinkOnModClickExtension.js.map
