@madgex/design-system-ce 5.5.1 → 5.5.3
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.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,21 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.5.3](https://github.com/wiley/madgex-design-system/compare/@madgex/design-system-ce@5.5.2...@madgex/design-system-ce@5.5.3) (2024-08-05)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- added minimum search characters to component ([7d6b88c](https://github.com/wiley/madgex-design-system/commit/7d6b88c04347fb04f3899a66f8b481463a6f302c))
|
|
11
|
+
- adding prop to trigger inactive state ([ff7cbe4](https://github.com/wiley/madgex-design-system/commit/ff7cbe4e0c2adfaedba52536892fd4833387b6d8))
|
|
12
|
+
- removing returned empty functionality ([f68f46c](https://github.com/wiley/madgex-design-system/commit/f68f46c450373620322bb9e744135503e1d06a1b))
|
|
13
|
+
- updating variables ([abb6c3c](https://github.com/wiley/madgex-design-system/commit/abb6c3c8782365210c4accfee7b65bde480d3ecf))
|
|
14
|
+
|
|
15
|
+
## [5.5.2](https://github.com/wiley/madgex-design-system/compare/@madgex/design-system-ce@5.5.1...@madgex/design-system-ce@5.5.2) (2024-07-11)
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- rename `mds-edited-text` to `mds-prose` ([d6519ed](https://github.com/wiley/madgex-design-system/commit/d6519edb43c62ba8c8cc54a02c6af46bc7e7440a))
|
|
20
|
+
|
|
6
21
|
## [5.5.1](https://github.com/wiley/madgex-design-system/compare/@madgex/design-system-ce@5.5.0...@madgex/design-system-ce@5.5.1) (2024-05-14)
|
|
7
22
|
|
|
8
23
|
### Bug Fixes
|
|
@@ -107,6 +107,10 @@ export default {
|
|
|
107
107
|
type: String,
|
|
108
108
|
default: ''
|
|
109
109
|
},
|
|
110
|
+
minSearchCharacters: {
|
|
111
|
+
type: Number,
|
|
112
|
+
default: 2
|
|
113
|
+
}
|
|
110
114
|
},
|
|
111
115
|
emits: ['search', 'select-option', 'clear-all'],
|
|
112
116
|
data() {
|
|
@@ -220,7 +224,7 @@ export default {
|
|
|
220
224
|
},
|
|
221
225
|
handleChange() {
|
|
222
226
|
if (this.searchValue.length === 0) this.clearField();
|
|
223
|
-
if (this.searchValue.length
|
|
227
|
+
if (this.searchValue.length >= this.minSearchCharacters) {
|
|
224
228
|
this.makeActive();
|
|
225
229
|
this.updateCount();
|
|
226
230
|
} else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as h,o as a,c as o,a as c,w as r,t as x,b as v,r as y,n as g,d as p,e as f,f as
|
|
1
|
+
import{_ as h,o as a,c as o,a as c,w as r,t as x,b as v,r as y,n as g,d as p,e as f,f as C,g as _,F as B,h as k,i as w}from"../plugin-vue_export-helper.js";const L={name:"ComboboxClear",inject:["iconPath","clearInput"]},S=["aria-label","title"],V={"aria-hidden":"true",focusable:"false",class:"mds-icon mds-icon--close mds-icon--sm"},E=["href"];function K(t,n,s,u,l,e){return a(),o("button",{class:"mds-combobox__clear mds-button mds-button--plain",type:"button",onClick:n[0]||(n[0]=d=>t.$emit("clear",d)),onKeydown:n[1]||(n[1]=r(d=>t.$emit("clear",d),["enter"])),"aria-label":e.clearInput,title:e.clearInput},[(a(),o("svg",V,[c("use",{href:`${e.iconPath}#icon-close`},null,8,E)]))],40,S)}var M=h(L,[["render",K]]);const T={name:"ListBox",props:{hidden:{type:Boolean,default:!0},isLoading:{type:Boolean,default:!0},comboboxid:{type:String,required:!0}},inject:["iconPath","loadingText"]},H=["aria-labelledby","hidden"],F={key:0,class:"mds-combobox-loading"},D={"aria-hidden":"true",focusable:"true",class:"mds-icon mds-icon--spinner mds-icon--after"},A=["href"],q={class:"mds-visually-hidden"};function G(t,n,s,u,l,e){return a(),o("ul",{class:"mds-combobox__listbox",role:"listbox","aria-labelledby":`${s.comboboxid}-label`,hidden:s.hidden},[s.isLoading?(a(),o("li",F,[(a(),o("svg",D,[c("use",{href:`${e.iconPath}#icon-spinner`},null,8,A)])),c("span",q,x(e.loadingText),1)])):v("",!0),y(t.$slots,"default")],8,H)}var N=h(T,[["render",G]]);const P={name:"ListBoxOption",props:{option:{type:Object,required:!0},focused:{type:Boolean,default:!1},searchValue:{type:String,default:""}},watch:{searchValue(t){return t},focused(t){t&&this.$refs.listItem.scrollIntoView(!1)}},methods:{highlightOption(){return this.option.label.replace(new RegExp(this.searchValue,"gi"),n=>`<span class="mds-combobox__option--marked">${n}</span>`)}}},j=["aria-selected","innerHTML"];function R(t,n,s,u,l,e){return a(),o("li",{ref:"listItem",class:g(["mds-combobox__option",{"mds-combobox__option--focused":s.focused}]),role:"option","aria-selected":s.focused.toString(),onMousedown:n[0]||(n[0]=d=>t.$emit("mousedown",d)),innerHTML:e.highlightOption()},null,42,j)}var U=h(P,[["render",R]]);const $={name:"Combobox",components:{ComboboxClear:M,ListBox:N,ListBoxOption:U},provide(){return{iconPath:this.iconpath,loadingText:this.i18nText.loadingText,clearInput:this.i18nText.clearInput}},props:{comboboxid:{type:String,required:!0},placeholder:{type:String,default:""},name:{type:[String,Boolean],default:!1},value:{type:String,default:""},options:{type:Array,default:()=>[]},filterOptions:{type:Boolean,default:!0},iconpath:{type:String,default:"/assets/icons.svg"},dataAriaInvalid:{type:String,default:""},i18n:{type:String,default:""},describedbyId:{type:String,default:""},minSearchCharacters:{type:Number,default:2}},emits:["search","select-option","clear-all"],data(){return{expanded:!1,selected:null,chosen:null,searchValue:this.$props.value,resultCountMessage:null}},computed:{inputValue(){return this.chosenOption?this.chosenOption.label:this.searchValue},selectedOption:{get(){return this.selected},set(t){this.selected=t}},chosenOption:{get(){return this.chosen},set(t){this.chosen=t,this.selectedOption=t,this.$emit("select-option",this.chosen)}},visibleOptions(){return this.filterOptions?this.options.filter(t=>t.label.toLowerCase().includes(this.searchValue.toLowerCase())):this.options},listBoxId(){return`${this.comboboxid}-listbox`},optionId(){return`${this.comboboxid}-option`},isLoading(){return this.options.length===0&&this.expanded},selectedOptionId(){const t=this.visibleOptions.indexOf(this.selectedOption);if(t>-1)return`${this.optionId}-${t}`},listBoxHidden(){return!this.expanded},lastOptionIndex(){return this.visibleOptions.length-1},ariaExpanded(){return this.expanded?"true":"false"},ariaInvalid(){return this.dataAriaInvalid?"true":"false"},i18nText(){return this.i18n?JSON.parse(this.i18n):{loadingText:"Loading",resultsMessage:"{count} result available",resultsMessage_plural:"{count} results available",clearInput:"clear input"}}},mounted(){var s,u,l,e;const t=(u=(s=this.$el.parentElement)==null?void 0:s.parentElement)==null?void 0:u.querySelector(".mds-form-element__fallback input"),n=(e=(l=this.$el.parentElement)==null?void 0:l.parentElement)==null?void 0:e.querySelector(".mds-form-element__fallback select");t&&t.remove(),n&&n.removeAttribute("id")},methods:{makeActive(){this.expanded=!0},makeInactive(){this.expanded=!1},handleInput(t){this.chosenOption=null,this.searchValue=t.target?t.target.value:"",this.handleChange(),this.$emit("search",this.searchValue),this.visibleOptions.length>0&&this.updateCount()},handleChange(){this.searchValue.length===0&&this.clearField(),this.searchValue.length>=this.minSearchCharacters?(this.makeActive(),this.updateCount()):this.makeInactive()},handleFocus(){this.handleChange(),this.visibleOptions.length>1&&this.updateCount()},handleClear(){this.clearField(),this.$refs.comboInput.focus()},clearField(){this.searchValue="",this.chosenOption=null,this.$emit("clear-all")},clickOption(t=this.selectedOption){this.chosenOption=t,this.makeInactive()},handleKeyDownEnter(t){this.expanded&&(t.preventDefault(),this.chooseOption())},chooseOption(){this.chosenOption=this.selectedOption,this.makeInactive(),this.clearCount()},hiddenGuard(t){this.listBoxHidden||t.call(this)},onInputBlur(){this.makeInactive(),this.clearCount()},onKeyDown(){if(this.selectedOption){const t=this.visibleOptions.findIndex(s=>s.value===this.selectedOption.value),n=t===this.lastOptionIndex?t:t+1;this.selectedOption=this.visibleOptions[n]}else[this.selectedOption]=this.visibleOptions},onKeyUp(){if(this.selectedOption){const t=this.visibleOptions.findIndex(s=>s.value===this.selectedOption.value),n=t===0?t:t-1;this.selectedOption=this.visibleOptions[n]}else this.selectedOption=this.visibleOptions[this.lastOptionIndex]},onKeyHome(){[this.selectedOption]=this.visibleOptions},onKeyEnd(){this.selectedOption=this.visibleOptions[this.lastOptionIndex]},updateCount(){this.clearCount(),setTimeout(()=>{const t=this.visibleOptions.length===1?this.i18nText.resultsMessage:this.i18nText.resultsMessage_plural;this.resultCountMessage=t.replace("{count}",this.visibleOptions.length)},1400)},clearCount(){this.resultCountMessage=null}}},z=["id","value","name","placeholder","aria-owns","aria-expanded","aria-describedby","aria-activedescendant","aria-invalid"],J={"aria-live":"polite",role:"status",class:"mds-visually-hidden"};function Q(t,n,s,u,l,e){const d=p("ComboboxClear"),O=p("ListBoxOption"),I=p("ListBox");return a(),o("div",{class:g(["mds-combobox",{"mds-combobox--active":!e.listBoxHidden}]),onKeydown:[n[4]||(n[4]=r(i=>e.hiddenGuard(e.onKeyDown),["down"])),n[5]||(n[5]=r(i=>e.hiddenGuard(e.onKeyUp),["up"])),n[6]||(n[6]=r(i=>e.hiddenGuard(e.onKeyHome),["home"])),n[7]||(n[7]=r(i=>e.hiddenGuard(e.onKeyEnd),["end"])),n[8]||(n[8]=r((...i)=>e.makeInactive&&e.makeInactive(...i),["esc"])),n[9]||(n[9]=r((...i)=>e.handleKeyDownEnter&&e.handleKeyDownEnter(...i),["enter"]))]},[c("input",{id:s.comboboxid,ref:"comboInput",value:e.inputValue,class:"mds-form-control",autocomplete:"off",type:"text",role:"combobox",name:s.name,placeholder:s.placeholder,"aria-owns":e.listBoxId,"aria-expanded":e.ariaExpanded,"aria-autocomplete":"list","aria-describedby":s.describedbyId,"aria-activedescendant":e.selectedOptionId,"aria-invalid":e.ariaInvalid,onInput:n[0]||(n[0]=(...i)=>e.handleInput&&e.handleInput(...i)),onChange:n[1]||(n[1]=(...i)=>e.handleChange&&e.handleChange(...i)),onBlur:n[2]||(n[2]=(...i)=>e.onInputBlur&&e.onInputBlur(...i)),onFocus:n[3]||(n[3]=(...i)=>e.handleFocus&&e.handleFocus(...i))},null,40,z),l.searchValue.length>0?(a(),f(d,{key:0,onClear:e.handleClear},null,8,["onClear"])):v("",!0),C(I,{id:e.listBoxId,hidden:e.listBoxHidden,"is-loading":e.isLoading,comboboxid:s.comboboxid},{default:_(()=>[(a(!0),o(B,null,k(e.visibleOptions,(i,m)=>{var b;return a(),f(O,{id:`${e.optionId}-${m}`,key:m,option:i,focused:((b=e.selectedOption)==null?void 0:b.value)===(i==null?void 0:i.value),"search-value":l.searchValue,onMousedown:X=>e.clickOption(i)},null,8,["id","option","focused","search-value","onMousedown"])}),128))]),_:1},8,["id","hidden","is-loading","comboboxid"]),c("div",J,x(l.resultCountMessage),1)],34)}var W=h($,[["render",Q]]);const Z=w(W,{shadowRoot:!1});export{Z as default};
|
|
@@ -93,4 +93,4 @@ img.ProseMirror-separator {
|
|
|
93
93
|
`,I0="\uFE0F",L0="\u200D";let zr=null,Hr=null;function P0(n){n===void 0&&(n=[]);const e={};be.groups=e;const t=new be;zr==null&&(zr=Na(O0)),Hr==null&&(Hr=Na(E0)),w(t,"'",Oi),w(t,"{",Xn),w(t,"}",Qn),w(t,"[",fi),w(t,"]",hi),w(t,"(",pi),w(t,")",mi),w(t,"<",gi),w(t,">",yi),w(t,"\uFF08",bi),w(t,"\uFF09",vi),w(t,"\u300C",ki),w(t,"\u300D",xi),w(t,"\u300E",Si),w(t,"\u300F",wi),w(t,"\uFF1C",Mi),w(t,"\uFF1E",Ti),w(t,"&",Ci),w(t,"*",Ei),w(t,"@",kt),w(t,"`",Ni),w(t,"^",Di),w(t,":",St),w(t,",",Uo),w(t,"$",Ri),w(t,".",qe),w(t,"=",Ii),w(t,"!",Jo),w(t,"-",Ue),w(t,"%",Li),w(t,"|",Pi),w(t,"+",Bi),w(t,"#",Fi),w(t,"?",zi),w(t,'"',_o),w(t,"/",Je),w(t,";",Go),w(t,"~",Zn),w(t,"_",Hi),w(t,"\\",Ai);const r=Ce(t,Ps,Ko,{[so]:!0});Ce(r,Ps,r);const i=Ce(t,un,at,{[oo]:!0});Ce(i,un,i);const s=Ce(t,Is,co,{[lo]:!0});Ce(s,un),Ce(s,Is,s);const o=Ce(t,Ea,Ru,{[Ca]:!0});w(t,Aa,qo,{[Ca]:!0}),w(o,Aa),Ce(o,Ea,o);const l=Ce(t,Ls,Iu,{[Du]:!0});Ce(l,Ls,l),w(l,I0,l);const a=w(l,L0);Ce(a,Ls,l);const c=[[un,i]],u=[[un,null],[Is,s]];for(let d=0;d<zr.length;d++)gt(t,zr[d],uo,at,c);for(let d=0;d<Hr.length;d++)gt(t,Hr[d],fo,co,u);Kt(uo,{tld:!0,ascii:!0},e),Kt(fo,{utld:!0,alpha:!0},e),gt(t,"file",Ur,at,c),gt(t,"mailto",Ur,at,c),gt(t,"http",pn,at,c),gt(t,"https",pn,at,c),gt(t,"ftp",pn,at,c),gt(t,"ftps",pn,at,c),Kt(Ur,{scheme:!0,ascii:!0},e),Kt(pn,{slashscheme:!0,ascii:!0},e),n=n.sort((d,f)=>d[0]>f[0]?1:-1);for(let d=0;d<n.length;d++){const f=n[d][0],p=n[d][1]?{[A0]:!0}:{[N0]:!0};f.indexOf("-")>=0?p[ao]=!0:un.test(f)?Ps.test(f)?p[qr]=!0:p[oo]=!0:p[so]=!0,Oa(t,f,f,p)}return Oa(t,"localhost",dr,{ascii:!0}),t.jd=new be(Vi),{start:t,tokens:Dn({groups:e},Lu)}}function B0(n,e){const t=F0(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,i=[];let s=0,o=0;for(;o<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;o<r&&(a=l.go(t[o]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[o].length,f++),c+=t[o].length,s+=t[o].length,o++;s-=d,o-=f,c-=d,i.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return i}function F0(n){const e=[],t=n.length;let r=0;for(;r<t;){let i=n.charCodeAt(r),s,o=i<55296||i>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(o),r+=o.length}return e}function gt(n,e,t,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const a=e[l];n.j[a]?s=n.j[a]:(s=new be(r),s.jr=i.slice(),n.j[a]=s),n=s}return s=new be(t),s.jr=i.slice(),n.j[e[o-1]]=s,s}function Na(n){const e=[],t=[];let r=0,i="0123456789";for(;r<n.length;){let s=0;for(;i.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let o=parseInt(n.substring(r,r+s),10);o>0;o--)t.pop();r+=s}else t.push(n[r]),r++}return e}const fr={defaultProtocol:"http",events:null,format:Da,formatHref:Da,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function Yo(n,e){e===void 0&&(e=null);let t=Dn({},fr);n&&(t=Dn(t,n instanceof Yo?n.o:n));const r=t.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=i}Yo.prototype={o:fr,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let i=this.o[n];return i&&(typeof i=="object"?(i=t.t in i?i[t.t]:fr[n],typeof i=="function"&&r&&(i=i(e,t))):typeof i=="function"&&r&&(i=i(e,t.t,t)),i)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function Da(n){return n}function Pu(n,e){this.t="token",this.v=n,this.tk=e}Pu.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=fr.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),i=n.get("tagName",t,e),s=this.toFormattedString(n),o={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return o.href=r,l&&(o.class=l),a&&(o.target=a),c&&(o.rel=c),u&&Dn(o,u),{tagName:i,attributes:o,content:s,eventListeners:d}}};function ns(n,e){class t extends Pu{constructor(i,s){super(i,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const Ra=ns("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ia=ns("text"),z0=ns("nl"),Vr=ns("url",{isLink:!0,toHref(n){return n===void 0&&(n=fr.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==dr&&n[1].t===St}}),Oe=n=>new be(n);function H0(n){let{groups:e}=n;const t=e.domain.concat([Ci,Ei,kt,Ai,Ni,Di,Ri,Ii,Ue,Ko,Li,Pi,Bi,Fi,Je,Vi,Zn,Hi]),r=[Oi,St,Uo,qe,Jo,zi,_o,Go,gi,yi,Xn,Qn,hi,fi,pi,mi,bi,vi,ki,xi,Si,wi,Mi,Ti],i=[Ci,Oi,Ei,Ai,Ni,Di,Ri,Ii,Ue,Xn,Qn,Li,Pi,Bi,Fi,zi,Je,Vi,Zn,Hi],s=Oe(),o=w(s,Zn);L(o,i,o),L(o,e.domain,o);const l=Oe(),a=Oe(),c=Oe();L(s,e.domain,l),L(s,e.scheme,a),L(s,e.slashscheme,c),L(l,i,o),L(l,e.domain,l);const u=w(l,kt);w(o,kt,u),w(a,kt,u),w(c,kt,u);const d=w(o,qe);L(d,i,o),L(d,e.domain,o);const f=Oe();L(u,e.domain,f),L(f,e.domain,f);const h=w(f,qe);L(h,e.domain,f);const p=Oe(Ra);L(h,e.tld,p),L(h,e.utld,p),w(u,dr,p);const m=w(f,Ue);L(m,e.domain,f),L(p,e.domain,f),w(p,qe,h),w(p,Ue,m);const g=w(p,St);L(g,e.numeric,Ra);const b=w(l,Ue),x=w(l,qe);L(b,e.domain,l),L(x,i,o),L(x,e.domain,l);const T=Oe(Vr);L(x,e.tld,T),L(x,e.utld,T),L(T,e.domain,l),L(T,i,o),w(T,qe,x),w(T,Ue,b),w(T,kt,u);const y=w(T,St),A=Oe(Vr);L(y,e.numeric,A);const k=Oe(Vr),D=Oe();L(k,t,k),L(k,r,D),L(D,t,k),L(D,r,D),w(T,Je,k),w(A,Je,k);const H=w(a,St),E=w(c,St),F=w(E,Je),j=w(F,Je);L(a,e.domain,l),w(a,qe,x),w(a,Ue,b),L(c,e.domain,l),w(c,qe,x),w(c,Ue,b),L(H,e.domain,k),w(H,Je,k),L(j,e.domain,k),L(j,t,k),w(j,Je,k);const W=[[Xn,Qn],[fi,hi],[pi,mi],[gi,yi],[bi,vi],[ki,xi],[Si,wi],[Mi,Ti]];for(let K=0;K<W.length;K++){const[le,ne]=W[K],G=w(k,le);w(D,le,G),w(G,ne,k);const q=Oe(Vr);L(G,t,q);const U=Oe();L(G,r),L(q,t,q),L(q,r,U),L(U,t,q),L(U,r,U),w(q,ne,k),w(U,ne,k)}return w(s,dr,T),w(s,qo,z0),{start:s,tokens:Lu}}function V0(n,e,t){let r=t.length,i=0,s=[],o=[];for(;i<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;i<r&&!(a=l.go(t[i].t));)o.push(t[i++]);for(;i<r&&(c=a||l.go(t[i].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,i++,u++;if(f<0)i-=u,i<r&&(o.push(t[i]),i++);else{o.length>0&&(s.push(Bs(Ia,e,o)),o=[]),i-=f,u-=f;const h=d.t,p=t.slice(i-u,i);s.push(Bs(h,e,p))}}return o.length>0&&s.push(Bs(Ia,e,o)),s}function Bs(n,e,t){const r=t[0].s,i=t[t.length-1].e,s=e.slice(r,i);return new n(s,t)}const $0=typeof console!="undefined"&&console&&console.warn||(()=>{}),j0="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",J={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function W0(){be.groups={},J.scanner=null,J.parser=null,J.tokenQueue=[],J.pluginQueue=[],J.customSchemes=[],J.initialized=!1}function La(n,e){if(e===void 0&&(e=!1),J.initialized&&$0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${j0}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
|
|
94
94
|
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
95
95
|
2. Cannot start or end with "-"
|
|
96
|
-
3. "-" cannot repeat`);J.customSchemes.push([n,e])}function K0(){J.scanner=P0(J.customSchemes);for(let n=0;n<J.tokenQueue.length;n++)J.tokenQueue[n][1]({scanner:J.scanner});J.parser=H0(J.scanner.tokens);for(let n=0;n<J.pluginQueue.length;n++)J.pluginQueue[n][1]({scanner:J.scanner,parser:J.parser});J.initialized=!0}function q0(n){return J.initialized||K0(),V0(J.parser.start,n,B0(J.scanner.start,n))}function Xo(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Yo(t),i=q0(n),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}function U0(n){return new oe({key:new Me("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=om(t.doc,[...e]);if(mm(l).forEach(({newRange:c})=>{const u=am(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1?(d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&f){const h=f.split(" ").filter(g=>g!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;Xo(p).filter(g=>g.isLink).map(g=>({...g,from:m+g.start+1,to:m+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate?n.validate(g.value):!0).forEach(g=>{Lo(g.from,g.to,r.doc).some(b=>b.mark.type===n.type)||o.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!o.steps.length)return o}})}function J0(n){return new oe({key:new Me("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||r.target.nodeName!=="A")return!1;const l=su(e.state,n.type.name),a=r.target,c=(i=a==null?void 0:a.href)!==null&&i!==void 0?i:l.href,u=(s=a==null?void 0:a.target)!==null&&s!==void 0?s:l.target;return a&&c?(e.editable&&window.open(c,u),!0):!1}}})}function _0(n){return new oe({key:new Me("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Xo(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(n.editor.commands.setMark(n.type,{href:a.href}),!0)}}})}const G0=Ve.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){La(n);return}La(n.scheme,n.optionalSlashes)})},onDestroy(){W0()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",Y(this.options.HTMLAttributes,{...n,href:""}),0]:["a",Y(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[en({find:(n,e)=>{var t;const r=(t=e==null?void 0:e.clipboardData)===null||t===void 0?void 0:t.getData("text/html"),i=[];if(r){const s=new DOMParser().parseFromString(r,"text/html"),o=s.querySelectorAll("a");o.length&&[...o].forEach(l=>i.push({text:l.innerText,data:{href:l.getAttribute("href")},index:s.body.innerText.indexOf(l.innerText)+l.innerText.length}))}if(n){const s=Xo(n).filter(o=>o.isLink);s.length&&s.forEach(o=>i.push({text:o.value,data:{href:o.href},index:o.start}))}return i},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(U0({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(J0({type:this.type})),this.options.linkOnPaste&&n.push(_0({editor:this.editor,type:this.type})),n}}),Y0={name:"MdsIcon",props:{iconName:{type:String,default:""},classes:{type:String,default:""},visuallyHiddenLabel:{type:String,default:""}},inject:["iconPath"]},X0=["href"],Q0={key:0,class:"mds-visually-hidden"};function Z0(n,e,t,r,i,s){return dt(),Ct("span",null,[(dt(),Ct("svg",{"aria-hidden":"true",focusable:"false",class:Ba(["mds-icon",`mds-icon--${t.iconName} ${t.classes}`])},[Fa("use",{href:`${s.iconPath}#icon-${t.iconName}`},null,8,X0)],2)),t.visuallyHiddenLabel?(dt(),Ct("span",Q0,Yu(t.visuallyHiddenLabel),1)):za("",!0)])}var eb=pr(Y0,[["render",Z0]]);const tb={name:"TextEditorButton",components:{MdsIcon:eb},emits:["updateTabIndex"],props:{id:{type:String,required:!0},label:{type:String,default:""},iconName:{type:String,default:""},isActive:{type:Boolean,default:!1},initialTabindex:{type:Number,default:-1},ariaPressed:{type:Boolean,default:!1},disabled:{type:Boolean}},data(){return{tabindex:this.initialTabindex}}},nb=["title","aria-label","tabindex","aria-disabled","aria-pressed"];function rb(n,e,t,r,i,s){const o=er("MdsIcon");return dt(),Ct("button",{type:"button",title:t.label,"aria-label":t.label,class:Ba(["mds-text-editor__button",{"mds-text-editor__button--active":t.isActive}]),tabindex:i.tabindex,"aria-disabled":t.disabled,"aria-pressed":t.ariaPressed,onFocus:e[0]||(e[0]=l=>n.$emit("updateTabIndex",t.id))},[Jr(o,{"icon-name":t.iconName},null,8,["icon-name"])],42,nb)}var ib=pr(tb,[["render",rb]]);const sb={name:"TextEditorToolbar",components:{TextEditorButton:ib},inject:["id","customMenuButtons","i18nText"],props:{editor:{type:Object,required:!0}},data(){return{defaultMenuButtons:[{id:"bold",label:"Bold",iconName:"text-bold",onClick:n=>n.commands.toggleBold(),isActive:n=>n.isActive("bold")},{id:"italic",label:"Italic",iconName:"text-italic",onClick:n=>n.commands.toggleItalic(),isActive:n=>n.isActive("italic")},{id:"strike",label:"Strike",iconName:"text-strike-through",onClick:n=>n.commands.toggleStrike(),isActive:n=>n.isActive("strike")},{id:"bulletList",label:"Bullet list",iconName:"list-bullets",onClick:n=>n.commands.toggleBulletList(),isActive:n=>n.isActive("bulletList")},{id:"orderedList",label:"Ordered list",iconName:"list-numbers",onClick:n=>n.commands.toggleOrderedList(),isActive:n=>n.isActive("orderedList")},{id:"undo",label:"Undo",iconName:"undo",onClick:n=>n.commands.undo(),isDisabled:n=>!n.can().undo()},{id:"redo",label:"Redo",iconName:"redo",onClick:n=>n.commands.redo(),isDisabled:n=>!n.can().redo()}]}},computed:{menuButtons(){var n;if((n=this.customMenuButtons)!=null&&n.length){const e=[];return this.customMenuButtons.forEach(t=>{const r=this.defaultMenuButtons.find(i=>i.id===t.id);e.push({...r,...t})}),e}return this.defaultMenuButtons},firstFocusableButton(){return this.menuButtons.find(n=>{var e;return!((e=n.isDisabled)!=null&&e.call(n,this.editor))})}},methods:{findSiblings(n,e){let t=e==="previous"?n.previousElementSibling:n.nextElementSibling;return t!=null&&t.hasAttribute("disabled")&&(t=this.findSiblings(t,e)),t},setFocusToSibling(n,e){const t=this.findSiblings(e.target,n);t&&t.focus()},updateTabIndex(n){n||(n=this.firstFocusableButton.id),this.$refs.menuButton.forEach(e=>{e.id===n?e.tabindex=0:e.tabindex=-1})}}},ob=["aria-label","aria-controls"];function lb(n,e,t,r,i,s){const o=er("TextEditorButton");return dt(),Ct("div",{class:"mds-text-editor__menu",role:"toolbar","aria-label":s.i18nText.toolbarLabel,"aria-controls":s.id},[(dt(!0),Ct(Xu,null,Qu(s.menuButtons,l=>{var a,c,u,d;return dt(),Zu(o,{id:l.id,ref_for:!0,ref:"menuButton",key:l.id,label:l.label,"icon-name":l.iconName,"is-active":(a=l.isActive)==null?void 0:a.call(l,t.editor),disabled:(c=l.isDisabled)==null?void 0:c.call(l,t.editor),"initial-tabindex":s.firstFocusableButton.id===l.id?0:-1,"aria-pressed":l.id==="undo"||l.id==="redo"?null:(u=l.isActive)==null?void 0:u.call(l,t.editor),"aria-expanded":(d=l.ariaExpanded)==null?void 0:d.call(l),onClick:f=>l.onClick(t.editor),onKeyup:[e[0]||(e[0]=Nr(f=>s.setFocusToSibling("previous",f),["left"])),e[1]||(e[1]=Nr(f=>s.setFocusToSibling("previous",f),["up"])),e[2]||(e[2]=Nr(f=>s.setFocusToSibling("next",f),["right"])),e[3]||(e[3]=Nr(f=>s.setFocusToSibling("next",f),["down"]))],onUpdateTabIndex:s.updateTabIndex},null,8,["id","label","icon-name","is-active","disabled","initial-tabindex","aria-pressed","aria-expanded","onClick","onUpdateTabIndex"])}),128))],8,ob)}var ab=pr(sb,[["render",lb]]);const cb={name:"TextEditorContent",components:{EditorContent:C0,TextEditorToolbar:ab},inject:["id","ariaDescribedBy"],props:{modelValue:{type:String,default:""}},emits:["update:modelValue"],data(){return{editor:null}},watch:{modelValue(n){this.editor.getHTML()!==n&&this.editor.commands.setContent(n,!1)}},mounted(){this.editor=new T0({extensions:[Jg,G0.configure({protocols:["http","https","mailto"],openOnClick:!1})],editorProps:{attributes:{class:"mds-text-editor__content mds-edited-text",id:this.id,role:"textbox",["aria-labelledby"]:`text-editor-label-${this.id}`,...this.ariaDescribedBy&&{["aria-describedby"]:this.ariaDescribedBy}}},content:this.modelValue,onUpdate:()=>{this.$emit("update:modelValue",this.editor.getHTML())}})},beforeUnmount(){this.editor.destroy()}},ub={key:0,class:"mds-text-editor"};function db(n,e,t,r,i,s){const o=er("TextEditorToolbar"),l=er("EditorContent");return i.editor?(dt(),Ct("div",ub,[Jr(o,{editor:i.editor},null,8,["editor"]),Jr(l,{editor:i.editor},null,8,["editor"])])):za("",!0)}var fb=pr(cb,[["render",db]]);const hb={name:"TextEditor",components:{TextEditorContent:fb},provide(){return{iconPath:this.iconpath,id:this.editorid,customMenuButtons:this.customMenuButtons,i18nText:this.i18nText,ariaDescribedBy:this.describedbyId}},props:{editorid:{type:String,required:!0},iconpath:{type:String,default:"/assets/icons.svg"},menuButtons:{type:String,default:""},i18n:{type:String,default:""},value:{type:String,default:""},describedbyId:{type:String,default:""}},data(){return{content:this.value}},computed:{customMenuButtons(){return this.menuButtons?JSON.parse(this.menuButtons):null},i18nText(){const n=this.i18n?JSON.parse(this.i18n):{};return{toolbarLabel:"Text formatting",addLink:"Add link",removeLink:"Remove link",visuallyHiddenLinkUrlLabel:"Link url",...n}}},mounted(){const n=document.querySelector(`#text-editor-fallback-${this.editorid}`);n&&n.remove()}},pb=["name","value"];function mb(n,e,t,r,i,s){const o=er("TextEditorContent");return dt(),Ct("div",null,[Jr(o,{modelValue:i.content,"onUpdate:modelValue":e[0]||(e[0]=l=>i.content=l)},null,8,["modelValue"]),Fa("input",{type:"hidden",name:t.editorid,value:i.content},null,8,pb)])}var gb=pr(hb,[["render",mb]]);const bb=ed(gb,{shadowRoot:!1});export{bb as default};
|
|
96
|
+
3. "-" cannot repeat`);J.customSchemes.push([n,e])}function K0(){J.scanner=P0(J.customSchemes);for(let n=0;n<J.tokenQueue.length;n++)J.tokenQueue[n][1]({scanner:J.scanner});J.parser=H0(J.scanner.tokens);for(let n=0;n<J.pluginQueue.length;n++)J.pluginQueue[n][1]({scanner:J.scanner,parser:J.parser});J.initialized=!0}function q0(n){return J.initialized||K0(),V0(J.parser.start,n,B0(J.scanner.start,n))}function Xo(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new Yo(t),i=q0(n),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}function U0(n){return new oe({key:new Me("autolink"),appendTransaction:(e,t,r)=>{const i=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=om(t.doc,[...e]);if(mm(l).forEach(({newRange:c})=>{const u=am(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1?(d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&f){const h=f.split(" ").filter(g=>g!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;Xo(p).filter(g=>g.isLink).map(g=>({...g,from:m+g.start+1,to:m+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate?n.validate(g.value):!0).forEach(g=>{Lo(g.from,g.to,r.doc).some(b=>b.mark.type===n.type)||o.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!o.steps.length)return o}})}function J0(n){return new oe({key:new Me("handleClickLink"),props:{handleClick:(e,t,r)=>{var i,s;if(r.button!==0||r.target.nodeName!=="A")return!1;const l=su(e.state,n.type.name),a=r.target,c=(i=a==null?void 0:a.href)!==null&&i!==void 0?i:l.href,u=(s=a==null?void 0:a.target)!==null&&s!==void 0?s:l.target;return a&&c?(e.editable&&window.open(c,u),!0):!1}}})}function _0(n){return new oe({key:new Me("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:i}=e,{selection:s}=i,{empty:o}=s;if(o)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Xo(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(n.editor.commands.setMark(n.type,{href:a.href}),!0)}}})}const G0=Ve.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){La(n);return}La(n.scheme,n.optionalSlashes)})},onDestroy(){W0()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",Y(this.options.HTMLAttributes,{...n,href:""}),0]:["a",Y(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[en({find:(n,e)=>{var t;const r=(t=e==null?void 0:e.clipboardData)===null||t===void 0?void 0:t.getData("text/html"),i=[];if(r){const s=new DOMParser().parseFromString(r,"text/html"),o=s.querySelectorAll("a");o.length&&[...o].forEach(l=>i.push({text:l.innerText,data:{href:l.getAttribute("href")},index:s.body.innerText.indexOf(l.innerText)+l.innerText.length}))}if(n){const s=Xo(n).filter(o=>o.isLink);s.length&&s.forEach(o=>i.push({text:o.value,data:{href:o.href},index:o.start}))}return i},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(U0({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(J0({type:this.type})),this.options.linkOnPaste&&n.push(_0({editor:this.editor,type:this.type})),n}}),Y0={name:"MdsIcon",props:{iconName:{type:String,default:""},classes:{type:String,default:""},visuallyHiddenLabel:{type:String,default:""}},inject:["iconPath"]},X0=["href"],Q0={key:0,class:"mds-visually-hidden"};function Z0(n,e,t,r,i,s){return dt(),Ct("span",null,[(dt(),Ct("svg",{"aria-hidden":"true",focusable:"false",class:Ba(["mds-icon",`mds-icon--${t.iconName} ${t.classes}`])},[Fa("use",{href:`${s.iconPath}#icon-${t.iconName}`},null,8,X0)],2)),t.visuallyHiddenLabel?(dt(),Ct("span",Q0,Yu(t.visuallyHiddenLabel),1)):za("",!0)])}var eb=pr(Y0,[["render",Z0]]);const tb={name:"TextEditorButton",components:{MdsIcon:eb},emits:["updateTabIndex"],props:{id:{type:String,required:!0},label:{type:String,default:""},iconName:{type:String,default:""},isActive:{type:Boolean,default:!1},initialTabindex:{type:Number,default:-1},ariaPressed:{type:Boolean,default:!1},disabled:{type:Boolean}},data(){return{tabindex:this.initialTabindex}}},nb=["title","aria-label","tabindex","aria-disabled","aria-pressed"];function rb(n,e,t,r,i,s){const o=er("MdsIcon");return dt(),Ct("button",{type:"button",title:t.label,"aria-label":t.label,class:Ba(["mds-text-editor__button",{"mds-text-editor__button--active":t.isActive}]),tabindex:i.tabindex,"aria-disabled":t.disabled,"aria-pressed":t.ariaPressed,onFocus:e[0]||(e[0]=l=>n.$emit("updateTabIndex",t.id))},[Jr(o,{"icon-name":t.iconName},null,8,["icon-name"])],42,nb)}var ib=pr(tb,[["render",rb]]);const sb={name:"TextEditorToolbar",components:{TextEditorButton:ib},inject:["id","customMenuButtons","i18nText"],props:{editor:{type:Object,required:!0}},data(){return{defaultMenuButtons:[{id:"bold",label:"Bold",iconName:"text-bold",onClick:n=>n.commands.toggleBold(),isActive:n=>n.isActive("bold")},{id:"italic",label:"Italic",iconName:"text-italic",onClick:n=>n.commands.toggleItalic(),isActive:n=>n.isActive("italic")},{id:"strike",label:"Strike",iconName:"text-strike-through",onClick:n=>n.commands.toggleStrike(),isActive:n=>n.isActive("strike")},{id:"bulletList",label:"Bullet list",iconName:"list-bullets",onClick:n=>n.commands.toggleBulletList(),isActive:n=>n.isActive("bulletList")},{id:"orderedList",label:"Ordered list",iconName:"list-numbers",onClick:n=>n.commands.toggleOrderedList(),isActive:n=>n.isActive("orderedList")},{id:"undo",label:"Undo",iconName:"undo",onClick:n=>n.commands.undo(),isDisabled:n=>!n.can().undo()},{id:"redo",label:"Redo",iconName:"redo",onClick:n=>n.commands.redo(),isDisabled:n=>!n.can().redo()}]}},computed:{menuButtons(){var n;if((n=this.customMenuButtons)!=null&&n.length){const e=[];return this.customMenuButtons.forEach(t=>{const r=this.defaultMenuButtons.find(i=>i.id===t.id);e.push({...r,...t})}),e}return this.defaultMenuButtons},firstFocusableButton(){return this.menuButtons.find(n=>{var e;return!((e=n.isDisabled)!=null&&e.call(n,this.editor))})}},methods:{findSiblings(n,e){let t=e==="previous"?n.previousElementSibling:n.nextElementSibling;return t!=null&&t.hasAttribute("disabled")&&(t=this.findSiblings(t,e)),t},setFocusToSibling(n,e){const t=this.findSiblings(e.target,n);t&&t.focus()},updateTabIndex(n){n||(n=this.firstFocusableButton.id),this.$refs.menuButton.forEach(e=>{e.id===n?e.tabindex=0:e.tabindex=-1})}}},ob=["aria-label","aria-controls"];function lb(n,e,t,r,i,s){const o=er("TextEditorButton");return dt(),Ct("div",{class:"mds-text-editor__menu",role:"toolbar","aria-label":s.i18nText.toolbarLabel,"aria-controls":s.id},[(dt(!0),Ct(Xu,null,Qu(s.menuButtons,l=>{var a,c,u,d;return dt(),Zu(o,{id:l.id,ref_for:!0,ref:"menuButton",key:l.id,label:l.label,"icon-name":l.iconName,"is-active":(a=l.isActive)==null?void 0:a.call(l,t.editor),disabled:(c=l.isDisabled)==null?void 0:c.call(l,t.editor),"initial-tabindex":s.firstFocusableButton.id===l.id?0:-1,"aria-pressed":l.id==="undo"||l.id==="redo"?null:(u=l.isActive)==null?void 0:u.call(l,t.editor),"aria-expanded":(d=l.ariaExpanded)==null?void 0:d.call(l),onClick:f=>l.onClick(t.editor),onKeyup:[e[0]||(e[0]=Nr(f=>s.setFocusToSibling("previous",f),["left"])),e[1]||(e[1]=Nr(f=>s.setFocusToSibling("previous",f),["up"])),e[2]||(e[2]=Nr(f=>s.setFocusToSibling("next",f),["right"])),e[3]||(e[3]=Nr(f=>s.setFocusToSibling("next",f),["down"]))],onUpdateTabIndex:s.updateTabIndex},null,8,["id","label","icon-name","is-active","disabled","initial-tabindex","aria-pressed","aria-expanded","onClick","onUpdateTabIndex"])}),128))],8,ob)}var ab=pr(sb,[["render",lb]]);const cb={name:"TextEditorContent",components:{EditorContent:C0,TextEditorToolbar:ab},inject:["id","ariaDescribedBy"],props:{modelValue:{type:String,default:""}},emits:["update:modelValue"],data(){return{editor:null}},watch:{modelValue(n){this.editor.getHTML()!==n&&this.editor.commands.setContent(n,!1)}},mounted(){this.editor=new T0({extensions:[Jg,G0.configure({protocols:["http","https","mailto"],openOnClick:!1})],editorProps:{attributes:{class:"mds-text-editor__content mds-prose",id:this.id,role:"textbox",["aria-labelledby"]:`text-editor-label-${this.id}`,...this.ariaDescribedBy&&{["aria-describedby"]:this.ariaDescribedBy}}},content:this.modelValue,onUpdate:()=>{this.$emit("update:modelValue",this.editor.getHTML())}})},beforeUnmount(){this.editor.destroy()}},ub={key:0,class:"mds-text-editor"};function db(n,e,t,r,i,s){const o=er("TextEditorToolbar"),l=er("EditorContent");return i.editor?(dt(),Ct("div",ub,[Jr(o,{editor:i.editor},null,8,["editor"]),Jr(l,{editor:i.editor},null,8,["editor"])])):za("",!0)}var fb=pr(cb,[["render",db]]);const hb={name:"TextEditor",components:{TextEditorContent:fb},provide(){return{iconPath:this.iconpath,id:this.editorid,customMenuButtons:this.customMenuButtons,i18nText:this.i18nText,ariaDescribedBy:this.describedbyId}},props:{editorid:{type:String,required:!0},iconpath:{type:String,default:"/assets/icons.svg"},menuButtons:{type:String,default:""},i18n:{type:String,default:""},value:{type:String,default:""},describedbyId:{type:String,default:""}},data(){return{content:this.value}},computed:{customMenuButtons(){return this.menuButtons?JSON.parse(this.menuButtons):null},i18nText(){const n=this.i18n?JSON.parse(this.i18n):{};return{toolbarLabel:"Text formatting",addLink:"Add link",removeLink:"Remove link",visuallyHiddenLinkUrlLabel:"Link url",...n}}},mounted(){const n=document.querySelector(`#text-editor-fallback-${this.editorid}`);n&&n.remove()}},pb=["name","value"];function mb(n,e,t,r,i,s){const o=er("TextEditorContent");return dt(),Ct("div",null,[Jr(o,{modelValue:i.content,"onUpdate:modelValue":e[0]||(e[0]=l=>i.content=l)},null,8,["modelValue"]),Fa("input",{type:"hidden",name:t.editorid,value:i.content},null,8,pb)])}var gb=pr(hb,[["render",mb]]);const bb=ed(gb,{shadowRoot:!1});export{bb as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@madgex/design-system-ce",
|
|
3
|
-
"version": "5.5.
|
|
3
|
+
"version": "5.5.3",
|
|
4
4
|
"description": "Custom Elements built in Vue3",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
},
|
|
46
46
|
"author": "",
|
|
47
47
|
"license": "UNLICENSED",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "53a2afb020575b576ab5b8ca2da1af17b0c17e71"
|
|
49
49
|
}
|