Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Mark } from 'tiptap';
- import { toggleMark, markInputRule, markPasteRule } from 'tiptap-commands';
- export default class MarkNode extends Mark {
- get name() {
- return 'mark';
- }
- get schema() {
- return {
- attrs: {
- id: {
- default: null
- },
- class: {
- default: null
- }
- },
- selectable: false,
- parseDOM: [
- {
- tag: 'mark',
- getAttrs: function(dom) {
- return {
- id: dom.getAttribute('id'),
- class: dom.getAttribute('class')
- };
- }
- }
- ],
- toDOM: function(node) {
- return [
- 'mark',
- {
- id: node.attrs.id,
- class: node.attrs.class
- }
- ];
- }
- };
- }
- keys({ type }) {
- return {
- 'Mod-mark': toggleMark(type)
- };
- }
- commands({ type }) {
- return () => toggleMark(type);
- }
- inputRules({ type }) {
- return [markInputRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)$/, type)];
- }
- pasteRules({ type }) {
- return [markPasteRule(/(?:\*\*|__)([^*_]+)(?:\*\*|__)/g, type)];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement