var i=globalThis.__LEPTOS_TIPTAP_BRIDGE__;if(i==null||i.modules==null)throw new Error("leptos-tiptap bridge bindings are unavailable");var e=i.modules["@tiptap/core"];if(e==null)throw new Error('leptos-tiptap bridge module "@tiptap/core" is unavailable');var m=e.CommandManager,k=e.Editor,b=e.Extension,y=e.InputRule,h=e.Mark,r=e.Node,f=e.NodePos,E=e.NodeView,R=e.PasteRule,A=e.Tracker,T=e.callOrReturn,P=e.canInsertNode,v=e.combineTransactionSteps,C=e.createChainableState,S=e.createDocument,w=e.createNodeFromContent,N=e.createStyleTag,O=e.defaultBlockAt,B=e.deleteProps,M=e.elementFromString,I=e.escapeForRegEx,F=e.extensions,D=e.findChildren,H=e.findChildrenInRange,L=e.findDuplicates,j=e.findParentNode,K=e.findParentNodeClosestToPos,q=e.fromString,G=e.generateHTML,$=e.generateJSON,z=e.generateText,J=e.getAttributes,U=e.getAttributesFromExtensions,V=e.getChangedRanges,Y=e.getDebugJSON,Q=e.getExtensionField,W=e.getHTMLFromFragment,X=e.getMarkAttributes,Z=e.getMarkRange,ee=e.getMarkType,te=e.getMarksBetween,ne=e.getNodeAtPosition,oe=e.getNodeAttributes,ie=e.getNodeType,re=e.getRenderedAttributes,se=e.getSchema,le=e.getSchemaByResolvedExtensions,ae=e.getSchemaTypeByName,de=e.getSchemaTypeNameByName,pe=e.getSplittedAttributes,ue=e.getText,ce=e.getTextBetween,ge=e.getTextContentFromNodes,_e=e.getTextSerializersFromSchema,xe=e.injectExtensionAttributesToParseRule,me=e.inputRulesPlugin,ke=e.isActive,be=e.isAtEndOfNode,ye=e.isAtStartOfNode,he=e.isEmptyObject,fe=e.isExtensionRulesEnabled,Ee=e.isFunction,Re=e.isList,Ae=e.isMacOS,Te=e.isMarkActive,Pe=e.isNodeActive,ve=e.isNodeEmpty,Ce=e.isNodeSelection,Se=e.isNumber,we=e.isPlainObject,Ne=e.isRegExp,Oe=e.isSafari,Be=e.isString,Me=e.isTextSelection,Ie=e.isiOS,Fe=e.markInputRule,De=e.markPasteRule,s=e.mergeAttributes,He=e.mergeDeep,Le=e.minMax,je=e.nodeInputRule,Ke=e.nodePasteRule,qe=e.objectIncludes,Ge=e.pasteRulesPlugin,$e=e.posToDOMRect,ze=e.removeDuplicates,Je=e.resolveFocusPosition,Ue=e.rewriteUnknownContent,Ve=e.selectionToInsertionEnd,Ye=e.splitExtensions,Qe=e.textInputRule,We=e.textPasteRule,l=e.textblockTypeInputRule,Xe=e.wrappingInputRule;var a=r.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:n}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,s(this.options.HTMLAttributes,n),0]},addCommands(){return{setHeading:t=>({commands:n})=>this.options.levels.includes(t.level)?n.setNode(this.name,t):!1,toggleHeading:t=>({commands:n})=>this.options.levels.includes(t.level)?n.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,n)=>({...t,[`Mod-Alt-${n}`]:()=>this.editor.commands.toggleHeading({level:n})}),{})},addInputRules(){return this.options.levels.map(t=>l({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var d="__LEPTOS_TIPTAP_BRIDGE__";function c(){let t=globalThis,n=t[d];if(n!=null)return n;let o={modules:{},registerExtension:()=>{throw new Error("leptos-tiptap bridge runtime is not initialized")}};return t[d]=o,o}function p(){return c()}function u(t){p().registerExtension(t)}function g(t){return typeof t=="string"&&t.length>0?{"data-block-id":t,id:t}:{}}var _={name:"heading",create:()=>a.extend({addAttributes(){return{...this.parent?.(),blockId:{default:null,parseHTML:t=>t.getAttribute("data-block-id"),renderHTML:t=>g(t.blockId)},collapsed:{default:null,parseHTML:t=>{let n=t.getAttribute("data-collapsed");return n==="true"?!0:n==="false"?!1:null},renderHTML:t=>t.collapsed===!0?{"data-collapsed":"true"}:{}}}}}),commands:{set_heading:(t,n)=>n.kind==="set_heading"?t.chain().focus().setHeading({level:n.level,...n.collapsed==null?{}:{collapsed:n.collapsed}}).run():!1,toggle_heading:(t,n)=>n.kind==="toggle_heading"?t.chain().focus().toggleHeading({level:n.level,...n.collapsed==null?{}:{collapsed:n.collapsed}}).run():!1},selection_keys:["h1","h2","h3","h4","h5","h6"],selection_state:t=>({h1:t.isActive("heading",{level:1}),h2:t.isActive("heading",{level:2}),h3:t.isActive("heading",{level:3}),h4:t.isActive("heading",{level:4}),h5:t.isActive("heading",{level:5}),h6:t.isActive("heading",{level:6})})};function lt(){u(_)}export{lt as register_heading};
