UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

68 lines (66 loc) 1.43 kB
import { Mark, mergeAttributes } from "../../../chunks/chunk-MDIOFKJQ.js"; import "../../../chunks/chunk-U5RRZUYZ.js"; // src/input/richtext/extensions/Link.ts var Link = Mark.create({ name: "link", priority: 1e3, keepOnSplit: false, addOptions() { return { HTMLAttributes: { rel: "noopener noreferrer nofollow" } }; }, addAttributes() { return { "data-id": { default: null }, "data-entry": { default: null }, "data-type": { default: null }, href: { default: null }, target: { default: this.options.HTMLAttributes.target }, title: { default: null } }; }, parseHTML() { return [{ tag: 'a:not([href *= "javascript:" i])' }]; }, renderHTML({ HTMLAttributes }) { return [ "a", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0 ]; }, addCommands() { return { setLink: (attributes) => ({ chain }) => { return chain().setMark(this.name, attributes).run(); }, toggleLink: (attributes) => ({ chain }) => { return chain().toggleMark(this.name, attributes, { extendEmptyMarkRange: true }).run(); }, unsetLink: () => ({ chain }) => { return chain().unsetMark(this.name, { extendEmptyMarkRange: true }).run(); } }; } }); export { Link };