UNPKG

alinea

Version:
73 lines (71 loc) 1.53 kB
import { Mark, mergeAttributes } from "../../../chunks/chunk-FKWEJTSK.js"; import "../../../chunks/chunk-NZLE2WMY.js"; // src/field/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-link": { 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 ]; }, addKeyboardShortcuts() { return { "Mod-k": () => this.editor.commands.setLink({}) }; }, 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 };