reactjs-tiptap-editor
Version:
A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React
2 lines (1 loc) • 1.57 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-CSvnpArE.cjs"),r=require("./RichTextEditor-DaQRHXru.cjs"),a=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,i=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,o=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,l=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,c=e.Mark.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",e.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[e.markInputRule({find:a,type:this.type}),e.markInputRule({find:o,type:this.type})]},addPasteRules(){return[e.markPasteRule({find:i,type:this.type}),e.markPasteRule({find:l,type:this.type})]}}),u=c.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button({editor:s,t:n}){return{component:r.ActionButton,componentProps:{action:()=>s.commands.toggleItalic(),isActive:()=>s.isActive("italic")||!1,disabled:!1,shortcutKeys:["mod","I"],icon:"Italic",tooltip:n("editor.italic.tooltip")}}}}}});exports.Italic=u;