UNPKG

reactjs-tiptap-editor

Version:

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

2 lines (1 loc) 2.04 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./clsx-CXbNJWDD.cjs"),s=require("react/jsx-runtime"),d=require("./index-BnVcq33n.cjs");require("react");require("./theme.cjs");var h=a.Mark.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",a.mergeAttributes(this.options.HTMLAttributes,e),0]},parseMarkdown(e,n){return n.applyMark(this.name||"underline",n.parseInline(e.tokens||[]))},renderMarkdown(e,n){return`++${n.renderChildren(e)}++`},markdownTokenizer:{name:"underline",level:"inline",start(e){return e.indexOf("++")},tokenize(e,n,t){const r=/^(\+\+)([\s\S]+?)(\+\+)/.exec(e);if(!r)return;const i=r[2].trim();return{type:"underline",raw:r[0],text:i,tokens:t.inlineTokens(i)}}},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),k=h;function v(){const e=d.useButtonProps(l.name),{icon:n=void 0,tooltip:t=void 0,shortcutKeys:o=void 0,tooltipOptions:r={},action:i=void 0,isActive:c=void 0}=(e==null?void 0:e.componentProps)??{},{dataState:m,disabled:u,update:p}=d.useToggleActive(c),g=()=>{u||i&&(i(),p())};return e?s.jsx(d.ActionButton,{action:g,dataState:m,disabled:u,icon:n,shortcutKeys:o,tooltip:t,tooltipOptions:r}):s.jsx(s.Fragment,{})}const l=k.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),button({editor:n,t,extension:o}){return{componentProps:{action:()=>n.commands.toggleUnderline(),isActive:()=>n.isActive("underline")||!1,disabled:!1,icon:"Underline",shortcutKeys:o.options.shortcutKeys??["mod","U"],tooltip:t("editor.underline.tooltip")}}}}}});exports.RichTextUnderline=v;exports.TextUnderline=l;