diff --git a/shaarli-pro/dist/a11y.min.js b/shaarli-pro/dist/a11y.min.js new file mode 100644 index 0000000..f6df1bc --- /dev/null +++ b/shaarli-pro/dist/a11y.min.js @@ -0,0 +1 @@ +!function(t){"use strict";const e=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function n(t,n){if(!t)return null;const o=Array.prototype.slice.call(t.querySelectorAll(e));return n?o[0]:o[o.length-1]}t.ShaarliProA11y={focusFirst:function(t){const e=n(t,!0);e&&e.focus()},trapFocus:function(t){if(!t)return function(){};function e(e){if("Tab"!==e.key)return;const o=n(t,!0),i=n(t,!1);o&&i&&(e.shiftKey&&document.activeElement===o?(e.preventDefault(),i.focus()):e.shiftKey||document.activeElement!==i||(e.preventDefault(),o.focus()))}return t.addEventListener("keydown",e),function(){t.removeEventListener("keydown",e)}},getFocusable:n}}(window); \ No newline at end of file diff --git a/shaarli-pro/dist/awesomplete.min.js b/shaarli-pro/dist/awesomplete.min.js new file mode 100644 index 0000000..ccaf6b0 --- /dev/null +++ b/shaarli-pro/dist/awesomplete.min.js @@ -0,0 +1,2 @@ +// Awesomplete - Lea Verou - MIT license +!function(){function t(t){var e=Array.isArray(t)?{label:t[0],value:t[1]}:"object"==typeof t&&"label"in t&&"value"in t?t:{label:t,value:t};this.label=e.label||e.value,this.value=e.value}function e(t,e,i){for(var n in e){var s=e[n],r=t.input.getAttribute("data-"+n.toLowerCase());"number"==typeof s?t[n]=parseInt(r):!1===s?t[n]=null!==r:s instanceof Function?t[n]=null:t[n]=r,t[n]||0===t[n]||(t[n]=n in i?i[n]:s)}}function i(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(t,e){return o.call((e||document).querySelectorAll(t))}function s(){n("input.awesomplete").forEach(function(t){new r(t)})}var r=function(t,n){var s=this;r.count=(r.count||0)+1,this.count=r.count,this.isOpened=!1,this.input=i(t),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("aria-owns","awesomplete_list_"+this.count),this.input.setAttribute("role","combobox"),this.options=n=n||{},e(this,{minChars:2,maxItems:10,autoFirst:!1,data:r.DATA,filter:r.FILTER_CONTAINS,sort:!1!==n.sort&&r.SORT_BYLENGTH,container:r.CONTAINER,item:r.ITEM,replace:r.REPLACE,tabSelect:!1},n),this.index=-1,this.container=this.container(t),this.ul=i.create("ul",{hidden:"hidden",role:"listbox",id:"awesomplete_list_"+this.count,inside:this.container}),this.status=i.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-atomic":!0,inside:this.container,textContent:0!=this.minChars?"Type "+this.minChars+" or more characters for results.":"Begin typing for results."}),this._events={input:{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(t){var e=t.keyCode;s.opened&&(13===e&&s.selected?(t.preventDefault(),s.select()):9===e&&s.selected&&s.tabSelect?s.select():27===e?s.close({reason:"esc"}):38!==e&&40!==e||(t.preventDefault(),s[38===e?"previous":"next"]()))}},form:{submit:this.close.bind(this,{reason:"submit"})},ul:{mousedown:function(t){t.preventDefault()},click:function(t){var e=t.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===t.button&&(t.preventDefault(),s.select(e,t.target))}}}},i.bind(this.input,this._events.input),i.bind(this.input.form,this._events.form),i.bind(this.ul,this._events.ul),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||n.list||[],r.all.push(this)};r.prototype={set list(t){if(Array.isArray(t))this._list=t;else if("string"==typeof t&&t.indexOf(",")>-1)this._list=t.split(/\s*,\s*/);else if((t=i(t))&&t.children){var e=[];o.apply(t.children).forEach(function(t){if(!t.disabled){var i=t.textContent.trim(),n=t.value||i,s=t.label||i;""!==n&&e.push({label:s,value:n})}}),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(t){this.opened&&(this.input.setAttribute("aria-expanded","false"),this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,this.status.setAttribute("hidden",""),i.fire(this.input,"awesomplete-close",t||{}))},open:function(){this.input.setAttribute("aria-expanded","true"),this.ul.removeAttribute("hidden"),this.isOpened=!0,this.status.removeAttribute("hidden"),this.autoFirst&&-1===this.index&&this.goto(0),i.fire(this.input,"awesomplete-open")},destroy:function(){if(i.unbind(this.input,this._events.input),i.unbind(this.input.form,this._events.form),!this.options.container){var t=this.container.parentNode;t.insertBefore(this.input,this.container),t.removeChild(this.container)}this.input.removeAttribute("autocomplete"),this.input.removeAttribute("aria-autocomplete");var e=r.all.indexOf(this);-1!==e&&r.all.splice(e,1)},next:function(){var t=this.ul.children.length;this.goto(this.index-1&&e.length>0&&(e[t].setAttribute("aria-selected","true"),this.status.textContent=e[t].textContent+", list item "+(t+1)+" of "+e.length,this.input.setAttribute("aria-activedescendant",this.ul.id+"_item_"+this.index),this.ul.scrollTop=e[t].offsetTop-this.ul.clientHeight+e[t].clientHeight,i.fire(this.input,"awesomplete-highlight",{text:this.suggestions[this.index]}))},select:function(t,e){if(t?this.index=i.siblingIndex(t):t=this.ul.children[this.index],t){var n=this.suggestions[this.index];i.fire(this.input,"awesomplete-select",{text:n,origin:e||t})&&(this.replace(n),this.close({reason:"select"}),i.fire(this.input,"awesomplete-selectcomplete",{text:n}))}},evaluate:function(){var e=this,i=this.input.value;i.length>=this.minChars&&this._list&&this._list.length>0?(this.index=-1,this.ul.innerHTML="",this.suggestions=this._list.map(function(n){return new t(e.data(n,i))}).filter(function(t){return e.filter(t,i)}),!1!==this.sort&&(this.suggestions=this.suggestions.sort(this.sort)),this.suggestions=this.suggestions.slice(0,this.maxItems),this.suggestions.forEach(function(t,n){e.ul.appendChild(e.item(t,i,n))}),0===this.ul.children.length?(this.status.textContent="No results found",this.close({reason:"nomatches"})):(this.open(),this.status.textContent=this.ul.children.length+" results found")):(this.close({reason:"nomatches"}),this.status.textContent="No results found")}},r.all=[],r.FILTER_CONTAINS=function(t,e){return RegExp(i.regExpEscape(e.trim()),"i").test(t)},r.FILTER_STARTSWITH=function(t,e){return RegExp("^"+i.regExpEscape(e.trim()),"i").test(t)},r.SORT_BYLENGTH=function(t,e){return t.length!==e.length?t.length-e.length:t$&"),role:"option","aria-selected":"false",id:"awesomplete_list_"+this.count+"_item_"+n})},r.REPLACE=function(t){this.input.value=t.value},r.DATA=function(t){return t},Object.defineProperty(t.prototype=Object.create(String.prototype),"length",{get:function(){return this.label.length}}),t.prototype.toString=t.prototype.valueOf=function(){return""+this.label};var o=Array.prototype.slice;i.create=function(t,e){var n=document.createElement(t);for(var s in e){var r=e[s];if("inside"===s)i(r).appendChild(n);else if("around"===s){var o=i(r);o.parentNode.insertBefore(n,o),n.appendChild(o),null!=o.getAttribute("autofocus")&&o.focus()}else s in n?n[s]=r:n.setAttribute(s,r)}return n},i.bind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.addEventListener(e,n)})}},i.unbind=function(t,e){if(t)for(var i in e){var n=e[i];i.split(/\s+/).forEach(function(e){t.removeEventListener(e,n)})}},i.fire=function(t,e,i){var n=document.createEvent("HTMLEvents");n.initEvent(e,!0,!0);for(var s in i)n[s]=i[s];return t.dispatchEvent(n)},i.regExpEscape=function(t){return t.replace(/[-\\^$*+?.()|[\]{}]/g,"\\$&")},i.siblingIndex=function(t){for(var e=0;t=t.previousElementSibling;e++);return e},"undefined"!=typeof self&&(self.Awesomplete=r),"undefined"!=typeof Document&&("loading"!==document.readyState?s():document.addEventListener("DOMContentLoaded",s)),r.$=i,r.$$=n,"object"==typeof module&&module.exports&&(module.exports=r)}(); diff --git a/shaarli-pro/dist/bulk-actions.min.js b/shaarli-pro/dist/bulk-actions.min.js new file mode 100644 index 0000000..e08ffe0 --- /dev/null +++ b/shaarli-pro/dist/bulk-actions.min.js @@ -0,0 +1 @@ +document.addEventListener("DOMContentLoaded",()=>{"use strict";const e=window.ShaarliProI18n||{t:function(e){return e}},t=document.getElementById("select-mode-btn"),n=document.getElementById("bulk-actions-bar"),l=document.getElementById("bulk-count"),i=document.getElementById("bulk-select-all"),o=document.getElementById("bulk-cancel"),c=document.getElementById("bulk-delete"),a=document.getElementById("bulk-public"),s=document.getElementById("bulk-private"),d=document.getElementById("bulk-confirm-modal"),r=document.getElementById("bulk-modal-title"),u=document.getElementById("bulk-modal-subtitle"),m=document.getElementById("bulk-modal-list"),k=document.getElementById("bulk-modal-confirm"),b=document.getElementById("bulk-modal-cancel"),f=document.getElementById("bulk-modal-close");let p=!1,E=new Set,y=null,h=null;const v=window.ShaarliProA11y||{focusFirst:function(){},trapFocus:function(){return function(){}}},g={delete:{title:t=>e.t("Are you sure to delete {count} link{plural}?",{count:t,plural:t>1?"s":""}),subtitle:e.t("The following links will be irretrievably deleted:"),confirm:t=>e.t("DELETE {count} LINK{plural}",{count:t,plural:t>1?"S":""}).toUpperCase(),confirmClass:"bulk-confirm-delete"},public:{title:t=>e.t("Are you sure to set {count} link{plural} public?",{count:t,plural:t>1?"s":""}),subtitle:e.t("The following links will be set as public:"),confirm:t=>e.t("SET {count} LINK{plural} PUBLIC",{count:t,plural:t>1?"S":""}).toUpperCase(),confirmClass:"bulk-confirm-public"},private:{title:t=>e.t("Are you sure to set {count} link{plural} private?",{count:t,plural:t>1?"s":""}),subtitle:e.t("The following links will be set as private:"),confirm:t=>e.t("SET {count} LINK{plural} PRIVATE",{count:t,plural:t>1?"S":""}).toUpperCase(),confirmClass:"bulk-confirm-private"}};function L(){l&&(l.textContent=E.size),document.querySelectorAll(".link-outer").forEach(e=>{const t=e.dataset.id;E.has(t)?e.classList.add("selected"):e.classList.remove("selected")}),document.querySelectorAll(".link-checkbox").forEach(e=>{e.checked=E.has(e.dataset.id)})}function w(){p=!0,document.body.classList.add("selection-mode"),n?.classList.add("show"),t?.classList.add("active")}function I(){p=!1,E.clear(),document.body.classList.remove("selection-mode"),n?.classList.remove("show"),t?.classList.remove("active"),L()}function C(e){E.has(e)?E.delete(e):E.add(e),E.size>0&&!p?w():0===E.size&&p&&I(),L()}function B(){return Array.from(E)}function S(t){if(!d||0===E.size)return;const n=g[t];if(!n)return;const l=B();y=t,r&&(r.textContent=n.title(l.length)),u&&(u.textContent=n.subtitle),k&&(k.textContent=n.confirm(l.length),k.className=`bulk-modal-btn bulk-modal-confirm ${n.confirmClass}`),function(t){m&&(m.innerHTML="",t.forEach(t=>{const n=document.querySelector(`.link-outer[data-id="${t}"]`),l=n?.querySelector(".link-title")?.textContent?.trim()||n?.querySelector(".link-url")?.textContent?.trim()||e.t("Untitled link"),i=document.createElement("div");i.className="bulk-modal-item";const o=document.createElement("span");o.className="bulk-modal-item-id",o.textContent=`#${t}`;const c=document.createElement("span");c.className="bulk-modal-item-title",c.textContent=l,i.appendChild(o),i.appendChild(c),m.appendChild(i)}))}(l),d.classList.add("show"),d.setAttribute("aria-hidden","false"),document.body.style.overflow="hidden",v.focusFirst(d),h=v.trapFocus(d)}function A(){d&&(y=null,d.classList.remove("show"),d.setAttribute("aria-hidden","true"),document.body.style.overflow="","function"==typeof h&&(h(),h=null))}t?.addEventListener("click",()=>{p?I():w()}),o?.addEventListener("click",I),i?.addEventListener("click",()=>{document.querySelectorAll(".link-outer").forEach(e=>{e.dataset.id&&E.add(e.dataset.id)}),!p&&E.size>0&&w(),L()}),document.addEventListener("change",e=>{e.target.classList.contains("link-checkbox")&&C(e.target.dataset.id)}),document.addEventListener("click",e=>{if(!p)return;const t=e.target.closest(".link-outer");if(t&&t.dataset.id){if(e.target.closest(".link-actions")||e.target.closest(".link-hover-actions")||"A"===e.target.tagName||"INPUT"===e.target.tagName||e.target.closest("label"))return;C(t.dataset.id)}}),c?.addEventListener("click",()=>{0!==E.size&&S("delete")}),a?.addEventListener("click",()=>{0!==E.size&&S("public")}),s?.addEventListener("click",()=>{0!==E.size&&S("private")}),k?.addEventListener("click",function(){if(!y||0===E.size)return;const t=B(),n=(window.shaarli?.token||"").trim()||document.querySelector('input[name="token"]')?.value||"";if(!n)return void alert(e.t("Missing security token. Please refresh the page and try again."));const l=window.shaarli?.basePath||"",i=function(e){return e.map(e=>encodeURIComponent(e)).join("+")}(t);let o="";if("delete"===y)o=`${l}/admin/shaare/delete?id=${i}&token=${encodeURIComponent(n)}`;else{const e="public"===y?"public":"private";o=`${l}/admin/shaare/visibility?token=${encodeURIComponent(n)}&newVisibility=${e}&id=${i}`}A(),window.location.href=o}),b?.addEventListener("click",A),f?.addEventListener("click",A),d?.addEventListener("click",e=>{e.target===d&&A()}),document.addEventListener("keydown",e=>{"Escape"===e.key&&d?.classList.contains("show")&&A()})}); \ No newline at end of file diff --git a/shaarli-pro/dist/custom_views.min.js b/shaarli-pro/dist/custom_views.min.js new file mode 100644 index 0000000..2e45c70 --- /dev/null +++ b/shaarli-pro/dist/custom_views.min.js @@ -0,0 +1 @@ +!function(){"use strict";function t(t){return"undefined"!=typeof window&&"function"==typeof window.renderMarkdown?window.renderMarkdown(t):String(t||"").replace(/\n/g,"
")}function e(t,e){if("undefined"!=typeof window&&"function"==typeof window.applyKeepNoteFormatting)return window.applyKeepNoteFormatting(t,e)}document.addEventListener("DOMContentLoaded",function(){const t=new URLSearchParams(window.location.search),e=t.get("searchtags")||t.get("searchTags")||"",o=window.location.pathname.match(/\/tag\/(.+)$/),n=(e+" "+(o?decodeURIComponent(o[1]):"")).toLowerCase().split(/[\s,]+/).filter(t=>t),d=!!document.querySelector('.sidebar-link[aria-label="Notes"].active, .header-nav-link[aria-label="Notes"].active, .sidebar-link[href*="searchtags=note"].active, .sidebar-link[href*="searchtags=shaarli-note"].active')||!!document.querySelector('.sidebar-link[aria-label="'+window.ShaarliProI18n.t("Notes")+'"].active, .header-nav-link[aria-label="'+window.ShaarliProI18n.t("Notes")+'"].active'),c=!!document.querySelector('.sidebar-link[aria-label="Mes tâches"].active, .header-nav-link[aria-label="Mes tâches"].active, .sidebar-link[href*="searchtags=shaarli-todo"].active, .sidebar-link[href*="searchtags=todo"].active')||!!document.querySelector('.sidebar-link[aria-label="'+window.ShaarliProI18n.t("My tasks")+'"].active, .header-nav-link[aria-label="'+window.ShaarliProI18n.t("My tasks")+'"].active'),p=!!document.querySelector('.sidebar-link[aria-label="Archive"].active, .header-nav-link[aria-label="Archive"].active, .sidebar-link[href*="searchtags=shaarli-archive"].active, .sidebar-link[href*="searchtags=shaarli-archiver"].active')||!!document.querySelector('.sidebar-link[aria-label="'+window.ShaarliProI18n.t("Archive")+'"].active, .header-nav-link[aria-label="'+window.ShaarliProI18n.t("Archive")+'"].active'),b=Array.from(document.querySelectorAll(".search-tag-chip")).map(t=>(t.textContent||"").trim().toLowerCase()),y=t=>"shaarli-archive"===t||"shaarli-archiver"===t,v=t=>"note"===t||"shaarli-note"===t||"#note"===t,w=t=>"todo"===t||"shaarli-todo"===t||"#todo"===t,S=n.some(v)||d||b.some(v),E=n.some(w)||c||b.some(w),C=n.some(y)||p||b.some(y),q=document.getElementById("links-list"),I=document.querySelector(".content-container"),x=()=>{try{document.body.classList.remove("view-todo","view-notes","view-archive")}catch(t){}const t=document.querySelector(".content-toolbar");t&&(t.style.display="");const e=document.getElementById("links-list");e&&(e.style.display=""),document.querySelectorAll(".notes-wrapper.todo-wrapper").forEach(t=>t.remove())};window.renderMarkdown=function(t){if(!t)return"";const e=String(t).replace(/\r\n?/g,"\n"),o=t=>String(t).replace(/&/g,"&").replace(//g,">"),n=t=>String(t).replace(/&/g,"&").replace(/"/g,""").replace(//g,">"),r=t=>{const e=String(t||"").trim();return e&&/^(https?:|mailto:|\/)/i.test(e)?e:""},a=t=>{let e=o(t||"");const a=[];return e=e.replace(/`([^`\n]+)`/g,(t,e)=>{const o=`__MD_CODE_${a.length}__`;return a.push(`${e}`),o}),e=e.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(t,e,o)=>{const a=r(o);return a?`${n(e)}`:t}),e=e.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,e,o)=>{const a=r(o);return a?`${e}`:t}),e=e.replace(/\*\*(.+?)\*\*/g,"$1"),e=e.replace(/__(.+?)__/g,"$1"),e=e.replace(/~~(.+?)~~/g,"$1"),e=e.replace(/\*(.+?)\*/g,"$1"),e=e.replace(/_(.+?)_/g,"$1"),e=e.replace(/<u>([\s\S]*?)<\/u>/g,"$1"),e=e.replace(/__MD_CODE_(\d+)__/g,(t,e)=>a[Number(e)]||""),e},i=e.split("\n"),l=[];let s=!1,d=!1,c=!1,u=!1,m="",p=[];const f=()=>{s&&(l.push(""),s=!1),d&&(l.push(""),d=!1),c&&(l.push(""),c=!1)};if(i.forEach(t=>{const e=t.trim(),r=e.match(/^```\s*([\w-]+)?\s*$/);if(r){if(f(),u){const t=m?` data-lang="${n(m)}"`:"";l.push(`
${o(p.join("\n"))}
`),u=!1,m="",p=[]}else u=!0,m=r[1]||"",p=[];return}if(u)return void p.push(t);if(!e)return f(),void l.push('
');const i=t.match(/^\s*(#{1,6})\s+(.+)$/);if(i){f();const t=i[1].length;return void l.push(`${a(i[2])}`)}const h=t.match(/^\s*>\s?(.*)$/);if(h)return f(),void l.push(`
${a(h[1])}
`);const g=t.match(/^\s*[-*]\s+\[( |x|X)\]\s+(.+)$/);if(g){s&&(l.push(""),s=!1),d&&(l.push(""),d=!1),c||(l.push('"),s=!1),c&&(l.push(""),c=!1),d||(l.push("
    "),d=!0),void l.push(`
  1. ${a(b[1])}
  2. `);const y=t.match(/^\s*[-*+]\s+(.+)$/);if(y)return d&&(l.push("
"),d=!1),c&&(l.push(""),c=!1),s||(l.push("