UNPKG

rhino-editor

Version:

A custom element wrapped rich text editor

92 lines (88 loc) 1.95 kB
import { Mark, markInputRule, markPasteRule, mergeAttributes } from "./chunk-TVRRLXKH.js"; // node_modules/.pnpm/@tiptap+extension-strike@2.9.1_@tiptap+core@2.9.1_@tiptap+pm@2.9.1_/node_modules/@tiptap/extension-strike/dist/index.js var inputRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/; var pasteRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g; var Strike = Mark.create({ name: "strike", addOptions() { return { HTMLAttributes: {} }; }, parseHTML() { return [ { tag: "s" }, { tag: "del" }, { tag: "strike" }, { style: "text-decoration", consuming: false, getAttrs: (style) => style.includes("line-through") ? {} : false } ]; }, renderHTML({ HTMLAttributes }) { return ["s", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; }, addCommands() { return { setStrike: () => ({ commands }) => { return commands.setMark(this.name); }, toggleStrike: () => ({ commands }) => { return commands.toggleMark(this.name); }, unsetStrike: () => ({ commands }) => { return commands.unsetMark(this.name); } }; }, addKeyboardShortcuts() { return { "Mod-Shift-s": () => this.editor.commands.toggleStrike() }; }, addInputRules() { return [ markInputRule({ find: inputRegex, type: this.type }) ]; }, addPasteRules() { return [ markPasteRule({ find: pasteRegex, type: this.type }) ]; } }); // src/exports/extensions/strike.ts var CustomStrike = Strike.extend({ name: "rhino-strike", renderHTML({ HTMLAttributes }) { return [ "del", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0 ]; } }); export { Strike, CustomStrike }; //# sourceMappingURL=chunk-QZU22EPA.js.map