var l=globalThis.__LEPTOS_TIPTAP_BRIDGE__;if(l==null||l.modules==null)throw new Error("leptos-tiptap bridge bindings are unavailable");var t=l.modules["@tiptap/core"];if(t==null)throw new Error('leptos-tiptap bridge module "@tiptap/core" is unavailable');var f=t.CommandManager,h=t.Editor,a=t.Extension,E=t.InputRule,d=t.Mark,S=t.Node,R=t.NodePos,C=t.NodeView,T=t.PasteRule,A=t.Tracker,P=t.callOrReturn,N=t.canInsertNode,O=t.combineTransactionSteps,v=t.createChainableState,B=t.createDocument,w=t.createNodeFromContent,M=t.createStyleTag,I=t.defaultBlockAt,F=t.deleteProps,D=t.elementFromString,j=t.escapeForRegEx,L=t.extensions,H=t.findChildren,K=t.findChildrenInRange,q=t.findDuplicates,G=t.findParentNode,z=t.findParentNodeClosestToPos,J=t.fromString,$=t.generateHTML,U=t.generateJSON,V=t.generateText,Y=t.getAttributes,Q=t.getAttributesFromExtensions,W=t.getChangedRanges,X=t.getDebugJSON,Z=t.getExtensionField,tt=t.getHTMLFromFragment,et=t.getMarkAttributes,nt=t.getMarkRange,ot=t.getMarkType,rt=t.getMarksBetween,it=t.getNodeAtPosition,st=t.getNodeAttributes,lt=t.getNodeType,at=t.getRenderedAttributes,dt=t.getSchema,pt=t.getSchemaByResolvedExtensions,ct=t.getSchemaTypeByName,ut=t.getSchemaTypeNameByName,gt=t.getSplittedAttributes,_t=t.getText,xt=t.getTextBetween,mt=t.getTextContentFromNodes,kt=t.getTextSerializersFromSchema,bt=t.injectExtensionAttributesToParseRule,yt=t.inputRulesPlugin,ft=t.isActive,ht=t.isAtEndOfNode,Et=t.isAtStartOfNode,St=t.isEmptyObject,Rt=t.isExtensionRulesEnabled,Ct=t.isFunction,Tt=t.isList,At=t.isMacOS,Pt=t.isMarkActive,Nt=t.isNodeActive,Ot=t.isNodeEmpty,vt=t.isNodeSelection,Bt=t.isNumber,wt=t.isPlainObject,Mt=t.isRegExp,It=t.isSafari,Ft=t.isString,Dt=t.isTextSelection,jt=t.isiOS,Lt=t.markInputRule,Ht=t.markPasteRule,p=t.mergeAttributes,Kt=t.mergeDeep,qt=t.minMax,Gt=t.nodeInputRule,zt=t.nodePasteRule,Jt=t.objectIncludes,$t=t.pasteRulesPlugin,Ut=t.posToDOMRect,Vt=t.removeDuplicates,Yt=t.resolveFocusPosition,Qt=t.rewriteUnknownContent,Wt=t.selectionToInsertionEnd,Xt=t.splitExtensions,Zt=t.textInputRule,te=t.textPasteRule,ee=t.textblockTypeInputRule,ne=t.wrappingInputRule;var k=e=>{if(!e.children.length)return;let n=e.querySelectorAll("span");n&&n.forEach(o=>{var i,r;let s=o.getAttribute("style"),m=(r=(i=o.parentElement)===null||i===void 0?void 0:i.closest("span"))===null||r===void 0?void 0:r.getAttribute("style");o.setAttribute("style",`${m};${s}`)})},c=d.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&k(e),{}):!1}]},renderHTML({HTMLAttributes:e}){return["span",p(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:e})=>{let{selection:n}=e;return e.doc.nodesBetween(n.from,n.to,(o,i)=>{if(o.isTextblock)return!0;o.marks.filter(r=>r.type===this.type).some(r=>Object.values(r.attrs).some(s=>!!s))||e.removeMark(i,i+o.nodeSize,this.type)}),!0}}}});var u=a.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var n;return(n=e.style.color)===null||n===void 0?void 0:n.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:n})=>n().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});var g="__LEPTOS_TIPTAP_BRIDGE__";function b(){let e=globalThis,n=e[g];if(n!=null)return n;let o={modules:{},registerExtension:()=>{throw new Error("leptos-tiptap bridge runtime is not initialized")}};return e[g]=o,o}function _(){return b()}function x(e){_().registerExtension(e)}var y={name:"text_style",create:()=>[c,u],commands:{set_color:(e,n)=>n.kind==="set_color"?e.chain().focus().setColor(n.attributes.color).run():!1,unset_color:e=>e.chain().focus().unsetColor().run()},selection_keys:["text_style"],selection_state:e=>({text_style:e.isActive("textStyle")})};function xe(){x(y)}export{xe as register_text_style};
