-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha11y-links.min.js
1 lines (1 loc) · 6.66 KB
/
a11y-links.min.js
1
!function(){"use strict";tinymce.PluginManager.add("a11y-links",function(u,e){u.ui.registry.addIcon("custom-links-icon",'<img src="https://wittjeff.github.io/tinymce-accessible-links-plugin/icons/box-with-ne-arrow.svg" style="height: 25px; width: 25px; margin-top:3px;"/>'),u.ui.registry.addButton("a11y-links",{icon:"custom-links-icon",tooltip:"Accessible Links",onAction:function(){var l=u.dom.select("a"),i=0,c=function(e){0<l.length&&(l.forEach(function(e){u.dom.setAttrib(e,"data-mce-selected",null)}),u.dom.setAttrib(l[i],"data-mce-selected","inline-boundary"),e.setData({linkHtml:u.serializer.serialize(l[i]),isFirstLink:0===i,isLastLink:i===l.length-1,noSymbol:!0,downArrow:!1,topPage:!1,neArrow:!1,rightArrow:!1,overlappingSquares:!1,customSvgSymbol:!1,customSvg:'<svg style="display: inline-block; width: 1em; height: 1em;" viewBox="0 0 48 48" aria-hidden="true" focusable="false"><path d="M36 24c-1.2 0-2 0.8-2 2v12c0 1.2-0.8 2-2 2h-22c-1.2 0-2-0.8-2-2v-22c0-1.2 0.8-2 2-2h12c1.2 0 2-0.8 2-2s-0.8-2-2-2h-12c-3.4 0-6 2.6-6 6v22c0 3.4 2.6 6 6 6h22c3.4 0 6-2.6 6-6v-12c0-1.2-0.8-2-2-2z"></path><path d="M43.8 5.2c-0.2-0.4-0.6-0.8-1-1-0.2-0.2-0.6-0.2-0.8-0.2h-12c-1.2 0-2 0.8-2 2s0.8 2 2 2h7.2l-18.6 18.6c-0.8 0.8-0.8 2 0 2.8 0.4 0.4 0.8 0.6 1.4 0.6s1-0.2 1.4-0.6l18.6-18.6v7.2c0 1.2 0.8 2 2 2s2-0.8 2-2v-12c0-0.2 0-0.6-0.2-0.8z"></path></svg>'}))},p=function(t){return{noSymbol:"",downArrow:'<span class="down-arrow" aria-hidden="true">↓</span>',topPage:'<span class="top-page" aria-hidden="true">↥</span>',neArrow:'<span class="ne-arrow" aria-hidden="true">↗</span>',rightArrow:'<span class="right-arrow" aria-hidden="true">→</span>',overlappingSquares:'<span class="overlapping-squares" aria-hidden="true">🗗</span>',customSvg:t.customSvgSymbol?t.customSvg:""}[["noSymbol","downArrow","topPage","neArrow","rightArrow","overlappingSquares","customSvg"].find(function(e){return t[e]})||"noSymbol"]},m=function(t){var a="",n=(t.srTextExternal&&(a+='<span class="sr-only"> external site</span>'),{srTextNone:"",srTextNewTab:'<span class="sr-only"> opens in a new tab</span>',srTextScrollDown:'<span class="sr-only"> scrolls down this page</span>',srTextTopPage:'<span class="sr-only"> returns to top of page</span>'});return Object.keys(n).forEach(function(e){t[e]&&"srTextNone"!==e&&(a+=n[e])}),a},h=function(e,t){return{title:"Link Accessibility Options",size:"medium",body:{type:"panel",items:[{type:"htmlpanel",html:'<p id="link-display" style="font-family: Courier Sans;">'.concat(u.serializer.serialize(l[i]),' <span style="font-weight: bold;">(Link ').concat(i+1," of ").concat(l.length,")</span></p>")},{type:"htmlpanel",html:"<label>Symbol</label>"},{type:"panel",items:[{type:"checkbox",name:"noSymbol",label:"No symbol"},{type:"checkbox",name:"downArrow",label:"↓"},{type:"checkbox",name:"topPage",label:"↥"},{type:"checkbox",name:"neArrow",label:"↗"},{type:"checkbox",name:"rightArrow",label:"→"},{type:"checkbox",name:"overlappingSquares",label:"🗗"},{type:"checkbox",name:"customSvgSymbol",label:"Custom SVG symbol"},{type:"input",name:"customSvg",label:"Custom SVG",inputType:"textarea",value:'<svg style="display: inline-block; width: 1em; height: 1em;" viewBox="0 0 48 48" aria-hidden="true" focusable="false"><path d="M36 24c-1.2 0-2 0.8-2 2v12c0 1.2-0.8 2-2 2h-22c-1.2 0-2-0.8-2-2v-22c0-1.2 0.8-2 2-2h12c1.2 0 2-0.8 2-2s-0.8-2-2-2h-12c-3.4 0-6 2.6-6 6v22c0 3.4 2.6 6 6 6h22c3.4 0 6-2.6 6-6v-12c0-1.2-0.8-2-2-2z"></path><path d="M43.8 5.2c-0.2-0.4-0.6-0.8-1-1-0.2-0.2-0.6-0.2-0.8-0.2h-12c-1.2 0-2 0.8-2 2s0.8 2 2 2h7.2l-18.6 18.6c-0.8 0.8-0.8 2 0 2.8 0.4 0.4 0.8 0.6 1.4 0.6s1-0.2 1.4-0.6l18.6-18.6v7.2c0 1.2 0.8 2 2 2s2-0.8 2-2v-12c0-0.2 0-0.6-0.2-0.8z"></path></svg>'}]},{type:"htmlpanel",html:"<label>Screen-reader text</label>"},{type:"panel",items:[{type:"checkbox",name:"srTextExternal",label:" external site"},{type:"checkbox",name:"srTextNone",label:"None"},{type:"checkbox",name:"srTextNewTab",label:" opens in a new tab"},{type:"checkbox",name:"srTextScrollDown",label:" scrolls down this page"},{type:"checkbox",name:"srTextTopPage",label:" returns to top of page"}]}]},initialData:{linkHtml:0<l.length?u.serializer.serialize(l[i]):"",isFirstLink:e,isLastLink:t,noSymbol:!0,downArrow:!1,topPage:!1,neArrow:!1,rightArrow:!1,overlappingSquares:!1,customSvgSymbol:!1,customSvg:'<svg style="display: inline-block; width: 1em; height: 1em;" viewBox="0 0 48 48" aria-hidden="true" focusable="false"><path d="M36 24c-1.2 0-2 0.8-2 2v12c0 1.2-0.8 2-2 2h-22c-1.2 0-2-0.8-2-2v-22c0-1.2 0.8-2 2-2h12c1.2 0 2-0.8 2-2s-0.8-2-2-2h-12c-3.4 0-6 2.6-6 6v22c0 3.4 2.6 6 6 6h22c3.4 0 6-2.6 6-6v-12c0-1.2-0.8-2-2-2z"></path><path d="M43.8 5.2c-0.2-0.4-0.6-0.8-1-1-0.2-0.2-0.6-0.2-0.8-0.2h-12c-1.2 0-2 0.8-2 2s0.8 2 2 2h7.2l-18.6 18.6c-0.8 0.8-0.8 2 0 2.8 0.4 0.4 0.8 0.6 1.4 0.6s1-0.2 1.4-0.6l18.6-18.6v7.2c0 1.2 0.8 2 2 2s2-0.8 2-2v-12c0-0.2 0-0.6-0.2-0.8z"></path></svg>'},buttons:[{type:"custom",name:"prev",text:"Previous",enabled:!e,primary:!1},{type:"custom",name:"next",text:"Next",enabled:!t,primary:!1},{type:"custom",name:"update",text:"Update",primary:!0},{type:"custom",name:"removeTarget",text:"Remove target=_blank",primary:!1},{type:"custom",name:"insertTarget",text:"Insert target=_blank",primary:!1},{type:"custom",name:"done",text:"Done",primary:!1}],onChange:function(a,n){var e=["noSymbol","downArrow","topPage","neArrow","rightArrow","overlappingSquares"];-1!==e.indexOf(n.name)&&(e.forEach(function(e){var t;e!==n.name&&a.setData(((t={})[e]=!1,t))}),"noSymbol"!==n.name)&&a.setData({noSymbol:!1}),"customSvgSymbol"===n.name&&(a.setData({customSvgSymbol:n.value}),n.value)&&a.setData({noSymbol:!1}),n.name.startsWith("srText")&&["srTextNone","srTextNewTab","srTextScrollDown","srTextTopPage"].forEach(function(e){var t;"srTextExternal"!==e&&e!==n.name&&a.setData(((t={})[e]=!1,t))})},onAction:function(e,t){var a=e.getData(),n=l[i];switch(t.name){case"prev":0<i&&(i--,e.redial(h(0===i,!1)),c(e));break;case"next":i<l.length-1&&(i++,e.redial(h(!1,i===l.length-1)),c(e));break;case"update":u.dom.select("span.sr-only",n).forEach(function(e){return u.dom.remove(e)});u.dom.select('span[aria-hidden="true"]',n).forEach(function(e){return u.dom.remove(e)});var r=n.innerHTML,o=m(a),s=p(a);r+="".concat(o).concat(s),u.dom.setHTML(n,r);break;case"removeTarget":u.dom.setAttrib(n,"target",null),u.dom.setAttrib(n,"rel",null);break;case"insertTarget":u.dom.setAttrib(n,"target","_blank"),u.dom.setAttrib(n,"rel","noopener noreferrer");break;case"skip":i<l.length-1&&(i++,e.redial(h(!1,i===l.length-1)),c(e));break;case"done":e.close()}}}},e=u.windowManager.open(h(0===i,i===l.length-1));c(e)}})}),tinymce.init({selector:"textarea.tinymce",plugins:"a11y-links",toolbar:"a11y-links",content_style:"tox-editor-container {background-color: red; }"})}();