@ni/nimble-components 20.5.0 → 20.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7964,7 +7964,7 @@ return new ER(e,t)}}FR=NR,NR.markdownSerializer=FR.initializeMarkdownSerializerF
7964
7964
  class PR extends Nt{constructor(){super(...arguments),this.editor=this.createEditor(),this.tiptapEditor=this.createTiptapEditor(),this.disabled=!1,this.footerHidden=!1,this.errorVisible=!1,this.scrollbarWidth=-1,this.updateScrollbarWidthQueued=!1,this.xmlSerializer=new XMLSerializer}get empty(){return 0===this.tiptapEditor.state.doc.textContent.trim().length}connectedCallback(){super.connectedCallback(),this.editor.isConnected||this.editorContainer.append(this.editor),this.bindEditorTransactionEvent(),this.bindEditorUpdateEvent(),this.stopNativeInputEventPropagation(),this.resizeObserver=new ResizeObserver((()=>this.onResize())),this.resizeObserver.observe(this)}disconnectedCallback(){super.disconnectedCallback(),this.unbindEditorTransactionEvent(),this.unbindEditorUpdateEvent(),this.unbindNativeInputEvent(),this.resizeObserver?.disconnect()}disabledChanged(){this.tiptapEditor.setEditable(!this.disabled),this.setEditorTabIndex(),this.editor.setAttribute("aria-disabled",this.disabled?"true":"false")}placeholderChanged(){this.getTipTapExtension("placeholder").options.placeholder=this.placeholder??"",this.tiptapEditor.view.dispatch(this.tiptapEditor.state.tr),this.queueUpdateScrollbarWidth()}ariaLabelChanged(){null!==this.ariaLabel&&void 0!==this.ariaLabel?this.editor.setAttribute("aria-label",this.ariaLabel):this.editor.removeAttribute("aria-label")}boldButtonClick(){this.tiptapEditor.chain().focus().toggleBold().run()}boldButtonKeyDown(e){return!this.keyActivatesButton(e)||(this.tiptapEditor.chain().focus().toggleBold().run(),!1)}italicsButtonClick(){this.tiptapEditor.chain().focus().toggleItalic().run()}italicsButtonKeyDown(e){return!this.keyActivatesButton(e)||(this.tiptapEditor.chain().focus().toggleItalic().run(),!1)}bulletListButtonClick(){this.tiptapEditor.chain().focus().toggleBulletList().run()}bulletListButtonKeyDown(e){return!this.keyActivatesButton(e)||(this.tiptapEditor.chain().focus().toggleBulletList().run(),!1)}numberedListButtonClick(){this.tiptapEditor.chain().focus().toggleOrderedList().run()}numberedListButtonKeyDown(e){return!this.keyActivatesButton(e)||(this.tiptapEditor.chain().focus().toggleOrderedList().run(),!1)}setMarkdown(e){const t=this.getHtmlContent(e)
7965
7965
  this.tiptapEditor.commands.setContent(t)}getMarkdown(){return NR.serializeDOMToMarkdown(this.tiptapEditor.state.doc)}stopEventPropagation(e){return e.stopPropagation(),!1}createEditor(){const e=document.createElement("div")
7966
7966
  return e.className="editor",e.setAttribute("aria-multiline","true"),e.setAttribute("role","textbox"),e.setAttribute("aria-disabled","false"),e}createTiptapEditor(){const e=this.getCustomLinkExtension()
7967
- return new FM({element:this.editor,extensions:[JM,gI,vI,KM,fI,dI,jM,x_,m_,mI.configure({placeholder:"",showOnlyWhenEditable:!1}),bI,e.configure({HTMLAttributes:{rel:"noopener noreferrer",target:null},autolink:!0,openOnClick:!1,linkOnPaste:!1,validate:e=>/^https?:\/\//i.test(e)})]})}getCustomLinkExtension(){return cI.extend({excludes:"_",inclusive:!1,parseHTML:()=>[{tag:wd}],renderHTML:({HTMLAttributes:e})=>["a",e]})}getHtmlContent(e){const t=LR.parseMarkdownToDOM(e)
7967
+ return new FM({element:this.editor,enableInputRules:[KM,fI],enablePasteRules:!1,extensions:[JM,gI,vI,KM,fI,dI,jM,x_,m_,mI.configure({placeholder:"",showOnlyWhenEditable:!1}),bI,e.configure({HTMLAttributes:{rel:"noopener noreferrer",target:null},autolink:!0,openOnClick:!1,linkOnPaste:!1,validate:e=>/^https?:\/\//i.test(e)})]})}getCustomLinkExtension(){return cI.extend({excludes:"_",inclusive:!1,parseHTML:()=>[{tag:wd}],renderHTML:({HTMLAttributes:e})=>["a",e]})}getHtmlContent(e){const t=LR.parseMarkdownToDOM(e)
7968
7968
  return this.xmlSerializer.serializeToString(t)}bindEditorTransactionEvent(){this.tiptapEditor.on("transaction",(()=>{this.updateEditorButtonsState()}))}unbindEditorTransactionEvent(){this.tiptapEditor.off("transaction")}updateEditorButtonsState(){const{extensionManager:e,state:t}=this.tiptapEditor,{extensions:n}=e,{selection:i}=t,o=bM((e=>SM(e.type.name,n)))(i)
7969
7969
  this.boldButton.checked=this.tiptapEditor.isActive("bold"),this.italicsButton.checked=this.tiptapEditor.isActive("italic"),this.bulletListButton.checked=o?.node.type.name===RI,this.numberedListButton.checked=o?.node.type.name===DI}keyActivatesButton(e){switch(e.key){case" ":case Ks:return!0
7970
7970
  default:return!1}}unbindEditorUpdateEvent(){this.tiptapEditor.off("update")}bindEditorUpdateEvent(){this.tiptapEditor.on("update",(()=>{this.$emit("input"),this.queueUpdateScrollbarWidth()}))}stopNativeInputEventPropagation(){this.tiptapEditor.view.dom.addEventListener("input",(e=>{e.stopPropagation()}))}unbindNativeInputEvent(){this.tiptapEditor.view.dom.removeEventListener("input",(()=>{}))}queueUpdateScrollbarWidth(){this.$fastController.isConnected&&(this.updateScrollbarWidthQueued||(this.updateScrollbarWidthQueued=!0,u.queueUpdate((()=>this.updateScrollbarWidth()))))}updateScrollbarWidth(){this.updateScrollbarWidthQueued=!1,this.scrollbarWidth=this.tiptapEditor.view.dom.offsetWidth-this.tiptapEditor.view.dom.clientWidth}onResize(){this.scrollbarWidth=this.tiptapEditor.view.dom.offsetWidth-this.tiptapEditor.view.dom.clientWidth}getTipTapExtension(e){return this.tiptapEditor.extensionManager.extensions.find((t=>t.name===e))}setEditorTabIndex(){this.tiptapEditor.setOptions({editorProps:{attributes:{tabindex:this.disabled?"-1":"0"}}})}}e([se({mode:"boolean"})],PR.prototype,"disabled",void 0),e([se({attribute:"footer-hidden",mode:"boolean"})],PR.prototype,"footerHidden",void 0),e([se({attribute:"error-visible",mode:"boolean"})],PR.prototype,"errorVisible",void 0),e([se({attribute:"error-text"})],PR.prototype,"errorText",void 0),e([se],PR.prototype,"placeholder",void 0),e([m],PR.prototype,"boldButton",void 0),e([m],PR.prototype,"italicsButton",void 0),e([m],PR.prototype,"bulletListButton",void 0),e([m],PR.prototype,"numberedListButton",void 0),e([m],PR.prototype,"scrollbarWidth",void 0),Vt(PR,hn)