UNPKG

reactjs-tiptap-editor

Version:

A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React

2 lines (1 loc) 2.05 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./index-CSvnpArE.cjs"),n=require("./RichTextEditor-DaQRHXru.cjs"),a="listItem",i="textStyle",o=/^(\d+)\.\s$/,d=r.Node.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...s}=t;return e===1?["ol",r.mergeAttributes(this.options.HTMLAttributes,s),0]:["ol",r.mergeAttributes(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(a,this.editor.getAttributes(i)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=r.wrappingInputRule({find:o,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,s)=>s.childCount+s.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=r.wrappingInputRule({find:o,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(i)}),joinPredicate:(e,s)=>s.childCount+s.attrs.start===+e[1],editor:this.editor})),[t]}}),u=d.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),button:({editor:e,t:s})=>({component:n.ActionButton,componentProps:{action:()=>e.commands.toggleOrderedList(),isActive:()=>e.isActive("orderedList")||!1,disabled:!1,icon:"ListOrdered",shortcutKeys:["mod","shift","7"],tooltip:s("editor.orderedlist.tooltip")}})}}});exports.OrderedList=u;