diff --git a/.gitignore b/.gitignore index aedce2c6..fc20c978 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ resources/ # Hugo .hugo_build.lock jsconfig.json +.hugo_cache # NPM node_modules/ diff --git a/apps/test/content/posts/mathjax-test.md b/apps/test/content/posts/mathjax-test.md index 40c7ced0..d9f31d1a 100644 --- a/apps/test/content/posts/mathjax-test.md +++ b/apps/test/content/posts/mathjax-test.md @@ -141,5 +141,4 @@ For formula blocks: $$ \bbox[border: solid .4pt magenta, pink]{x^2=4} $$ -{.auto-dark-mode} {{< /auto-dark >}} diff --git a/apps/test/content/posts/task-list-test.md b/apps/test/content/posts/task-list-test.md index e69ec023..6f4d5485 100644 --- a/apps/test/content/posts/task-list-test.md +++ b/apps/test/content/posts/task-list-test.md @@ -19,17 +19,6 @@ This post tests the rendering of task lists in Markdown. - [x] Checked Task - Regular list item -## Nested Task Lists (Bug Fix Verification) - -- [ ] Parent Task 1 - - [ ] Child Task 1.1 - - [x] Child Task 1.2 - - Regular list item -- [x] Parent Task 2 - - [ ] Child Task 2.1 - - [ ] Grandchild Task 2.1.1 - - [x] Grandchild Task 2.1.2 - ## Extended Task Lists (Custom Icons) - [-] Cancelled Task @@ -40,6 +29,22 @@ This post tests the rendering of task lists in Markdown. - [?] Question Task - Regular list item +## Nested Task Lists (Bug Fix Verification) + +- [ ] Parent Task 1 + - [ ] Child Task 1.1 + - [x] Child Task 1.2 + - Regular list item +- [/] Parent Task 2 + - Regular list item + - [ ] Child Task 2.1 + - [x] Grandchild Task 2.1.1 + - [-] Grandchild Task 2.1.2 + - [<] Scheduled Task + - [>] Rescheduled Task + - [!] Important Task + - [?] Question Task + ## Mixed Content in List Items - [ ] Task with **bold** and _italic_ text diff --git a/assets/css/_core/_mixin/_index.scss b/assets/css/_core/_mixin/_index.scss index 4a5ad7d3..d7f77fc6 100644 --- a/assets/css/_core/_mixin/_index.scss +++ b/assets/css/_core/_mixin/_index.scss @@ -7,6 +7,7 @@ @import 'media'; @import 'scrollbar-width'; @import 'sticky-top'; +@import 'task-list'; @import 'theme-switch'; @import 'theme-vars'; @import 'z-index'; diff --git a/assets/css/_core/_mixin/_task-list.scss b/assets/css/_core/_mixin/_task-list.scss new file mode 100644 index 00000000..075a858f --- /dev/null +++ b/assets/css/_core/_mixin/_task-list.scss @@ -0,0 +1,34 @@ +// Task list utility mixins +// ---------------------------------------- + +/// Set task list icon color and allow custom styles via @content +/// @param {Color | Null} $color - Icon color (optional) +/// Usage: +/// @include task-icon(fixit-var(secondary)) { +/// opacity: 0.8; +/// } +@mixin task-icon($color: null) { + > i { + // Set icon color (optional) + @if $color != null { + @include set-fixit-var(task-icon-color, $color); + } + @content; + } +} + +/// Set task list text color and allow custom styles via @content +/// @param {Color | Null} $color - Text color (optional) +/// Usage: +/// @include task-text(fixit-var(secondary)) { +/// text-decoration: line-through fixit-var(secondary); +/// } +@mixin task-text($color: null) { + > span { + // Set text color (optional) + @if $color != null { + @include set-fixit-var(task-text-color, $color); + } + @content; + } +} diff --git a/assets/css/_core/_widgets/_cell-tooltip.scss b/assets/css/_core/_widgets/_cell-tooltip.scss index e1bb98e1..4995bbbf 100644 --- a/assets/css/_core/_widgets/_cell-tooltip.scss +++ b/assets/css/_core/_widgets/_cell-tooltip.scss @@ -1,6 +1,7 @@ body { .cell-tooltip { - --tooltip-bg: light-dark(#ffffff, #39393c); - --tooltip-color: light-dark(#0f172a, #e2e2e6); + --tooltip-bg: light-dark(#ffffff, #3d444d); + --tooltip-color: fixit-var(global-font-color); + --tooltip-shadow-color: light-dark(rgba(0, 0, 0, 0.18), rgba(255, 255, 255, 0.18)); } } diff --git a/assets/css/_page/_single/_index.scss b/assets/css/_page/_single/_index.scss index 431f07cf..298fcd84 100644 --- a/assets/css/_page/_single/_index.scss +++ b/assets/css/_page/_single/_index.scss @@ -120,7 +120,6 @@ left: 5%; top: 50%; transform: translateY(-50%); - @include z-index(base); color: fixit-var(hr-active-color); font-size: 20px; line-height: 1; @@ -128,6 +127,7 @@ font-family: var(--fa-family-classic); font-weight: 600; content: '\f0c4'; + @include z-index(base); } &:hover::before { @@ -218,50 +218,52 @@ margin-block: 0.5em; } - ol ol, - ol ul, - ul ol, - ul ul { + :is(ol, ul) :is(ol, ul) { padding-left: 20px; } li::marker { - color: fixit-var(global-font-secondary-color); + color: fixit-var(secondary); } li:hover::marker { color: fixit-var(single-link-hover-color); } // Task lists - li[data-task] { - list-style: none; - color: fixit-var(task-color); - - .checkbox-icon { - margin: 0 .25em 0 -1.5em; - color: fixit-var(checkbox-color); + li { + &[data-task] { + list-style: none; + @include task-icon { + margin: 0 0.25em 0 -1.5em; + color: fixit-var(task-icon-color, fixit-var(secondary)); + }; + @include task-text { + color: fixit-var(task-text-color); + } } - } - li[data-task='x'] { - @include set-fixit-var(checkbox-color, fixit-var(global-font-secondary-color)); - .checkbox-icon { - opacity: 0.6; + &[data-task='-'] { + @include task-icon { + opacity: 0.7; + }; + @include task-text(fixit-var(secondary)) { + opacity: 0.7; + text-decoration: line-through fixit-var(secondary); + } + } + + &[data-task='/'] { + @include task-icon(fixit-var(success)); + @include task-text(fixit-var(success)); + } + + &[data-task='!'] { + @include task-icon(fixit-var(danger)); + } + + &[data-task='?'] { + @include task-icon(fixit-var(warning)); } - } - li[data-task='-'] { - opacity: 0.6; - text-decoration: line-through rgba(145, 145, 145, 0.6); - @include set-fixit-var(task-color, fixit-var(global-font-secondary-color)); - } - li[data-task='/'] { - @include set-fixit-var(task-color, fixit-var(success)); - } - li[data-task='!'] { - @include set-fixit-var(checkbox-color, fixit-var(danger)); - } - li[data-task='?'] { - @include set-fixit-var(checkbox-color, fixit-var(warning)); } dl { diff --git a/assets/data/cdn/jsdelivr.yml b/assets/data/cdn/jsdelivr.yml index fe2f72a5..a40758bf 100644 --- a/assets/data/cdn/jsdelivr.yml +++ b/assets/data/cdn/jsdelivr.yml @@ -19,8 +19,8 @@ libFiles: # autocomplete-js@0.38.1 https://github.com/algolia/autocomplete # TODO update autocompleteJS: '@algolia/autocomplete-js@1.7.1/dist/umd/index.production.js' autocompleteJS: autocomplete.js@0.38.1/dist/autocomplete.min.js - # cell-tooltip@0.3.0 https://github.com/Lruihao/cell-tooltip - cellTooltipJS: cell-tooltip@0.3.0/dist/cell-tooltip.umd.js + # cell-tooltip@0.3.1 https://github.com/Lruihao/cell-tooltip + cellTooltipJS: cell-tooltip@0.3.1/dist/cell-tooltip.umd.js # cell-watermark@1.0.3 https://github.com/Lruihao/watermark cellWatermarkJS: cell-watermark@1.0.3/src/watermark.min.js # cookieconsent@3.1.1 https://github.com/osano/cookieconsent diff --git a/assets/data/cdn/unpkg.yml b/assets/data/cdn/unpkg.yml index 3e61aef9..d6033739 100644 --- a/assets/data/cdn/unpkg.yml +++ b/assets/data/cdn/unpkg.yml @@ -19,8 +19,8 @@ libFiles: # autocomplete-js@0.38.1 https://github.com/algolia/autocomplete # TODO update autocompleteJS: '@algolia/autocomplete-js@1.7.1/dist/umd/index.production.js' autocompleteJS: autocomplete.js@0.38.1/dist/autocomplete.min.js - # cell-tooltip@0.3.0 https://github.com/Lruihao/cell-tooltip - cellTooltipJS: cell-tooltip@0.3.0/dist/cell-tooltip.umd.js + # cell-tooltip@0.3.1 https://github.com/Lruihao/cell-tooltip + cellTooltipJS: cell-tooltip@0.3.1/dist/cell-tooltip.umd.js # cell-watermark@1.0.3 https://github.com/Lruihao/watermark cellWatermarkJS: cell-watermark@1.0.3/src/watermark.min.js # cookieconsent@3.1.1 https://github.com/osano/cookieconsent diff --git a/assets/js/theme.js b/assets/js/theme.js index 309268e9..0c588239 100644 --- a/assets/js/theme.js +++ b/assets/js/theme.js @@ -1409,7 +1409,14 @@ class FixIt { initTooltip() { if (!this.config.tooltip) return; - window.CellTooltip.initAll('[data-ct-tooltip]'); + // task list items tooltip + window.CellTooltip.initAll('li[data-task] > span[title]', { + placement: 'right', + }); + // code block action buttons tooltip + window.CellTooltip.initAll('.action-btn[title]'); + // footnote refs tooltip + this.initFootnotes(); } /** @@ -1427,7 +1434,6 @@ class FixIt { this.initEcharts(); this.initTypeit(target); this.initMapbox(); - this.initFootnotes(); this.initTooltip(); if (includeToc) { window.setTimeout(() => { diff --git a/assets/lib/cell-tooltip/cell-tooltip.umd.js b/assets/lib/cell-tooltip/cell-tooltip.umd.js index 3639ab33..d05ccab0 100644 --- a/assets/lib/cell-tooltip/cell-tooltip.umd.js +++ b/assets/lib/cell-tooltip/cell-tooltip.umd.js @@ -1 +1 @@ -(function(p,l){typeof exports=="object"&&typeof module<"u"?module.exports=l():typeof define=="function"&&define.amd?define(l):(p=typeof globalThis<"u"?globalThis:p||self,p.CellTooltip=l())})(this,(function(){"use strict";const p=".cell-tooltip{position:absolute;z-index:999;pointer-events:none;opacity:0;transform:scale(.97);transition:opacity .12s ease,transform .12s ease;filter:drop-shadow(0 10px 24px rgba(15,23,42,.2));--tooltip-bg: #111827;--tooltip-color: #f8fafc;--tooltip-arrow-size: 8px}.cell-tooltip[data-theme=light],.cell-tooltip[data-theme=auto]{--tooltip-bg: #ffffff;--tooltip-color: #0f172a}@media(prefers-color-scheme:dark){.cell-tooltip[data-theme=auto]{--tooltip-bg: #111827;--tooltip-color: #f8fafc}}.cell-tooltip.show{opacity:1;transform:scale(1)}.cell-tooltip-inner{max-width:240px;padding:6px 10px;border-radius:8px;font-size:12px;line-height:1.35;color:var(--tooltip-color);background:var(--tooltip-bg);text-align:center;word-wrap:break-word}.cell-tooltip-arrow{position:absolute;width:0;height:0;transform:translate(-50%,-50%)}.cell-tooltip[data-placement=top] .cell-tooltip-arrow{bottom:calc(-1 * var(--tooltip-arrow-size));border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-top:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=bottom] .cell-tooltip-arrow{top:0;border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=left] .cell-tooltip-arrow{right:calc(-1 * var(--tooltip-arrow-size));border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-left:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=right] .cell-tooltip-arrow{left:0;border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid var(--tooltip-bg)}",l={placement:"top",trigger:"hover focus",theme:"dark",offset:8,html:!1},w={show:120,hide:80},v=["top","bottom","right","left"],m=new WeakMap;let b=0;function x(o){return b+=1,`${o}-${b}`}function T(o){return o instanceof HTMLElement}function L(o){return typeof o=="number"?{show:o,hide:o}:{show:o?.show??w.show,hide:o?.hide??w.hide}}function z(o){const t=o.trim().split(/\s+/).filter(Boolean);if(t.length===0)return["hover","focus"];const e=[];for(const i of t)(i==="hover"||i==="focus"||i==="click"||i==="manual")&&e.push(i);return e.length>0?e:["hover","focus"]}function g(o,t,e){return Math.min(Math.max(o,t),e)}function C(o){return o==="light"||o==="dark"||o==="auto"?o:l.theme}class u{element;config;tip=null;arrow=null;isEnabled=!0;timeoutId=null;hoverState=null;activeTrigger={click:!1,hover:!1,focus:!1};listeners=[];constructor(t,e={}){this.element=t;const i=h=>h.dataset.ctTitle??h.dataset.ctOriginalTitle??h.getAttribute("title")??"",a=t.getAttribute("data-ct-placement")??void 0,r=t.getAttribute("data-ct-trigger")??void 0,s=t.getAttribute("data-ct-theme")??void 0;this.config={title:e.title??i,placement:e.placement??a??l.placement,trigger:e.trigger??r??l.trigger,theme:C(e.theme??s??l.theme),container:e.container??document.body,offset:e.offset??l.offset,html:e.html??l.html,delay:L(e.delay)},t.title&&(t.setAttribute("data-ct-original-title",t.title),t.removeAttribute("title")),this.addListeners(),m.set(t,this)}static getOrCreateInstance(t,e){return m.get(t)??new u(t,e)}static initAll(t="[data-ct-title]",e){return Array.from(document.querySelectorAll(t)).map(i=>u.getOrCreateInstance(i,e))}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}toggleEnabled(){this.isEnabled=!this.isEnabled}toggle(){if(this.tip&&this.tip.classList.contains("show")){this.leave();return}this.enter()}show(){if(!this.isEnabled||!this.hasContent())return;const t=this.getTipElement();t.dataset.theme=this.config.theme;const e=t.classList.contains("show");t.isConnected||this.config.container.appendChild(t),this.setContent(t),e||(this.updatePosition(),t.classList.add("show"),this.element.setAttribute("aria-describedby",t.id))}hide(){const t=this.tip;t&&(t.classList.remove("show"),this.activeTrigger.click=!1,this.activeTrigger.focus=!1,this.activeTrigger.hover=!1,this.hoverState=null,this.element.removeAttribute("aria-describedby"),window.setTimeout(()=>{t.classList.contains("show")||t.remove()},150))}update(){this.tip&&this.tip.classList.contains("show")&&this.updatePosition()}refresh(){!this.tip||!this.tip.classList.contains("show")||(this.setContent(this.tip),this.updatePosition())}setTitle(t){this.config.title=t,this.refresh()}dispose(){this.clearTimer(),this.listeners.forEach(t=>t()),this.listeners=[],this.hide(),m.delete(this.element)}addListeners(){const t=z(this.config.trigger);for(const e of t)e!=="manual"&&(e==="hover"&&(this.bind(this.element,"mouseenter",()=>{this.activeTrigger.hover=!0,this.enter()}),this.bind(this.element,"mouseleave",()=>{this.activeTrigger.hover=!1,this.leave()})),e==="focus"&&(this.bind(this.element,"focusin",()=>{this.activeTrigger.focus=!0,this.enter()}),this.bind(this.element,"focusout",()=>{this.activeTrigger.focus=!1,this.leave()})),e==="click"&&this.bind(this.element,"click",i=>{i.preventDefault(),this.activeTrigger.click=!this.activeTrigger.click,this.toggle()}));this.bind(window,"resize",()=>this.update()),this.bind(window,"scroll",()=>{if(this.activeTrigger.hover||this.activeTrigger.focus){this.hide();return}this.update()})}bind(t,e,i){t.addEventListener(e,i),this.listeners.push(()=>t.removeEventListener(e,i))}clearTimer(){this.timeoutId!==null&&(window.clearTimeout(this.timeoutId),this.timeoutId=null)}enter(){this.isEnabled&&(this.clearTimer(),this.hoverState="show",this.timeoutId=window.setTimeout(()=>{this.hoverState==="show"&&this.show()},this.config.delay.show))}leave(){this.hasActiveTrigger()||(this.clearTimer(),this.hoverState="out",this.timeoutId=window.setTimeout(()=>{this.hoverState==="out"&&this.hide()},this.config.delay.hide))}hasActiveTrigger(){return this.activeTrigger.click||this.activeTrigger.focus||this.activeTrigger.hover}hasContent(){return this.getTitle().trim().length>0}getTitle(){const{title:t}=this.config;return typeof t=="function"?t(this.element):t}getTipElement(){if(this.tip)return this.tip;const t=document.createElement("div");t.className="cell-tooltip",t.id=x("cell-tooltip"),t.setAttribute("role","tooltip"),t.dataset.theme=this.config.theme,t.innerHTML='
';const e=t.querySelector(".cell-tooltip-arrow");if(!T(e))throw new Error("Tooltip arrow element is missing");return this.tip=t,this.arrow=e,t}setContent(t){const e=t.querySelector(".cell-tooltip-inner");if(!T(e))throw new Error("Tooltip inner element is missing");const i=this.getTitle();if(this.config.html){e.innerHTML=i;return}e.textContent=i}updatePosition(){const t=this.getTipElement();t.style.top="0",t.style.left="0";const e=this.element.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.resolvePlacement(e,i);t.dataset.placement=a;const r=window.scrollX,s=window.scrollY,h=window.innerWidth,f=window.innerHeight,c=this.config.offset;let n=0,d=0;switch(a){case"top":n=e.top+s-i.height-c,d=e.left+r+(e.width-i.width)/2;break;case"bottom":n=e.bottom+s+c,d=e.left+r+(e.width-i.width)/2;break;case"left":n=e.top+s+(e.height-i.height)/2,d=e.left+r-i.width-1.5*c;break;case"right":n=e.top+s+(e.height-i.height)/2,d=e.right+r+c;break}const E=g(n,s+4,s+f-i.height-4),A=g(d,r+4,r+h-i.width-4);t.style.top=`${Math.round(E)}px`,t.style.left=`${Math.round(A)}px`,this.updateArrowPosition(a,e,{top:E,left:A,width:i.width,height:i.height})}resolvePlacement(t,e){if(this.config.placement!=="auto")return this.config.placement;const i=this.config.offset,a=t.top,r=window.innerHeight-t.bottom,s=t.left,h=window.innerWidth-t.right,f={top:a>=e.height+i,bottom:r>=e.height+i,left:s>=e.width+i,right:h>=e.width+i};for(const n of v)if(f[n])return n;const c={top:a,bottom:r,left:s,right:h};return v.reduce((n,d)=>c[d]>c[n]?d:n,"top")}updateArrowPosition(t,e,i){if(!this.arrow)return;const a=e.left+window.scrollX+e.width/2,r=e.top+window.scrollY+e.height/2;if(t==="top"||t==="bottom"){const f=a-i.left,c=g(f,10,i.width-10);this.arrow.style.left=`${c}px`,this.arrow.style.top="";return}const s=r-i.top,h=g(s,10,i.height-10);this.arrow.style.top=`${h}px`,this.arrow.style.left=""}}const y="cell-tooltip-runtime-style";function k(){if(typeof document>"u"||document.getElementById(y))return;const o=document.createElement("style");o.id=y,o.textContent=p,document.head.appendChild(o)}return k(),u})); +(function(p,l){typeof exports=="object"&&typeof module<"u"?module.exports=l():typeof define=="function"&&define.amd?define(l):(p=typeof globalThis<"u"?globalThis:p||self,p.CellTooltip=l())})(this,(function(){"use strict";const p=".cell-tooltip{position:absolute;z-index:999;pointer-events:none;opacity:0;transform:scale(.97);transition:opacity .12s ease,transform .12s ease;filter:drop-shadow(0 0 4px var(--tooltip-shadow-color, rgba(255, 255, 255, .18)));--tooltip-bg: #111827;--tooltip-color: #f8fafc;--tooltip-arrow-size: 8px}.cell-tooltip[data-theme=auto],.cell-tooltip[data-theme=light]{--tooltip-bg: #ffffff;--tooltip-color: #0f172a;--tooltip-shadow-color: rgba(0, 0, 0, .18)}@media(prefers-color-scheme:dark){.cell-tooltip[data-theme=auto]{--tooltip-bg: #111827;--tooltip-color: #f8fafc;--tooltip-shadow-color: rgba(255, 255, 255, .18)}}.cell-tooltip.show{opacity:1;transform:scale(1)}.cell-tooltip-inner{max-width:240px;padding:6px 10px;border-radius:8px;font-size:12px;line-height:1.35;color:var(--tooltip-color);background:var(--tooltip-bg);text-align:center;word-wrap:break-word}.cell-tooltip-arrow{position:absolute;width:0;height:0;transform:translate(-50%,-50%)}.cell-tooltip[data-placement=top] .cell-tooltip-arrow{bottom:calc(-1 * var(--tooltip-arrow-size));border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-top:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=bottom] .cell-tooltip-arrow{top:0;border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=left] .cell-tooltip-arrow{right:calc(-1 * var(--tooltip-arrow-size));border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-left:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=right] .cell-tooltip-arrow{left:0;border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid var(--tooltip-bg)}",l={placement:"top",trigger:"hover focus",theme:"dark",offset:8,html:!1},w={show:120,hide:80},v=["top","bottom","right","left"],m=new WeakMap;let b=0;function x(o){return b+=1,`${o}-${b}`}function T(o){return o instanceof HTMLElement}function L(o){return typeof o=="number"?{show:o,hide:o}:{show:o?.show??w.show,hide:o?.hide??w.hide}}function z(o){const t=o.trim().split(/\s+/).filter(Boolean);if(t.length===0)return["hover","focus"];const e=[];for(const i of t)(i==="hover"||i==="focus"||i==="click"||i==="manual")&&e.push(i);return e.length>0?e:["hover","focus"]}function g(o,t,e){return Math.min(Math.max(o,t),e)}function C(o){return o==="light"||o==="dark"||o==="auto"?o:l.theme}class u{element;config;tip=null;arrow=null;isEnabled=!0;timeoutId=null;hoverState=null;activeTrigger={click:!1,hover:!1,focus:!1};listeners=[];constructor(t,e={}){this.element=t;const i=h=>h.dataset.ctTitle??h.dataset.ctOriginalTitle??h.getAttribute("title")??"",a=t.getAttribute("data-ct-placement")??void 0,r=t.getAttribute("data-ct-trigger")??void 0,s=t.getAttribute("data-ct-theme")??void 0;this.config={title:e.title??i,placement:e.placement??a??l.placement,trigger:e.trigger??r??l.trigger,theme:C(e.theme??s??l.theme),container:e.container??document.body,offset:e.offset??l.offset,html:e.html??l.html,delay:L(e.delay)},t.title&&(t.setAttribute("data-ct-original-title",t.title),t.removeAttribute("title")),this.addListeners(),m.set(t,this)}static getOrCreateInstance(t,e){return m.get(t)??new u(t,e)}static initAll(t="[data-ct-title]",e){return Array.from(document.querySelectorAll(t)).map(i=>u.getOrCreateInstance(i,e))}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}toggleEnabled(){this.isEnabled=!this.isEnabled}toggle(){if(this.tip&&this.tip.classList.contains("show")){this.leave();return}this.enter()}show(){if(!this.isEnabled||!this.hasContent())return;const t=this.getTipElement();t.dataset.theme=this.config.theme;const e=t.classList.contains("show");t.isConnected||this.config.container.appendChild(t),this.setContent(t),e||(this.updatePosition(),t.classList.add("show"),this.element.setAttribute("aria-describedby",t.id))}hide(){const t=this.tip;t&&(t.classList.remove("show"),this.activeTrigger.click=!1,this.activeTrigger.focus=!1,this.activeTrigger.hover=!1,this.hoverState=null,this.element.removeAttribute("aria-describedby"),window.setTimeout(()=>{t.classList.contains("show")||t.remove()},150))}update(){this.tip&&this.tip.classList.contains("show")&&this.updatePosition()}refresh(){!this.tip||!this.tip.classList.contains("show")||(this.setContent(this.tip),this.updatePosition())}setTitle(t){this.config.title=t,this.refresh()}dispose(){this.clearTimer(),this.listeners.forEach(t=>t()),this.listeners=[],this.hide(),m.delete(this.element)}addListeners(){const t=z(this.config.trigger);for(const e of t)e!=="manual"&&(e==="hover"&&(this.bind(this.element,"mouseenter",()=>{this.activeTrigger.hover=!0,this.enter()}),this.bind(this.element,"mouseleave",()=>{this.activeTrigger.hover=!1,this.leave()})),e==="focus"&&(this.bind(this.element,"focusin",()=>{this.activeTrigger.focus=!0,this.enter()}),this.bind(this.element,"focusout",()=>{this.activeTrigger.focus=!1,this.leave()})),e==="click"&&this.bind(this.element,"click",i=>{i.preventDefault(),this.activeTrigger.click=!this.activeTrigger.click,this.toggle()}));this.bind(window,"resize",()=>this.update()),this.bind(window,"scroll",()=>{if(this.activeTrigger.hover||this.activeTrigger.focus){this.hide();return}this.update()})}bind(t,e,i){t.addEventListener(e,i),this.listeners.push(()=>t.removeEventListener(e,i))}clearTimer(){this.timeoutId!==null&&(window.clearTimeout(this.timeoutId),this.timeoutId=null)}enter(){this.isEnabled&&(this.clearTimer(),this.hoverState="show",this.timeoutId=window.setTimeout(()=>{this.hoverState==="show"&&this.show()},this.config.delay.show))}leave(){this.hasActiveTrigger()||(this.clearTimer(),this.hoverState="out",this.timeoutId=window.setTimeout(()=>{this.hoverState==="out"&&this.hide()},this.config.delay.hide))}hasActiveTrigger(){return this.activeTrigger.click||this.activeTrigger.focus||this.activeTrigger.hover}hasContent(){return this.getTitle().trim().length>0}getTitle(){const{title:t}=this.config;return typeof t=="function"?t(this.element):t}getTipElement(){if(this.tip)return this.tip;const t=document.createElement("div");t.className="cell-tooltip",t.id=x("cell-tooltip"),t.setAttribute("role","tooltip"),t.dataset.theme=this.config.theme,t.innerHTML='
';const e=t.querySelector(".cell-tooltip-arrow");if(!T(e))throw new Error("Tooltip arrow element is missing");return this.tip=t,this.arrow=e,t}setContent(t){const e=t.querySelector(".cell-tooltip-inner");if(!T(e))throw new Error("Tooltip inner element is missing");const i=this.getTitle();if(this.config.html){e.innerHTML=i;return}e.textContent=i}updatePosition(){const t=this.getTipElement();t.style.top="0",t.style.left="0";const e=this.element.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.resolvePlacement(e,i);t.dataset.placement=a;const r=window.scrollX,s=window.scrollY,h=window.innerWidth,f=window.innerHeight,c=this.config.offset;let n=0,d=0;switch(a){case"top":n=e.top+s-i.height-c,d=e.left+r+(e.width-i.width)/2;break;case"bottom":n=e.bottom+s+c,d=e.left+r+(e.width-i.width)/2;break;case"left":n=e.top+s+(e.height-i.height)/2,d=e.left+r-i.width-1.5*c;break;case"right":n=e.top+s+(e.height-i.height)/2,d=e.right+r+c;break}const E=g(n,s+4,s+f-i.height-4),A=g(d,r+4,r+h-i.width-4);t.style.top=`${Math.round(E)}px`,t.style.left=`${Math.round(A)}px`,this.updateArrowPosition(a,e,{top:E,left:A,width:i.width,height:i.height})}resolvePlacement(t,e){if(this.config.placement!=="auto")return this.config.placement;const i=this.config.offset,a=t.top,r=window.innerHeight-t.bottom,s=t.left,h=window.innerWidth-t.right,f={top:a>=e.height+i,bottom:r>=e.height+i,left:s>=e.width+i,right:h>=e.width+i};for(const n of v)if(f[n])return n;const c={top:a,bottom:r,left:s,right:h};return v.reduce((n,d)=>c[d]>c[n]?d:n,"top")}updateArrowPosition(t,e,i){if(!this.arrow)return;const a=e.left+window.scrollX+e.width/2,r=e.top+window.scrollY+e.height/2;if(t==="top"||t==="bottom"){const f=a-i.left,c=g(f,10,i.width-10);this.arrow.style.left=`${c}px`,this.arrow.style.top="";return}const s=r-i.top,h=g(s,10,i.height-10);this.arrow.style.top=`${h}px`,this.arrow.style.left=""}}const y="cell-tooltip-runtime-style";function k(){if(typeof document>"u"||document.getElementById(y))return;const o=document.createElement("style");o.id=y,o.textContent=p,document.head.appendChild(o)}return k(),u})); diff --git a/layouts/_partials/function/code-header.html b/layouts/_partials/function/code-header.html index 780361c0..852fa44b 100644 --- a/layouts/_partials/function/code-header.html +++ b/layouts/_partials/function/code-header.html @@ -18,27 +18,27 @@ {{- end -}} {{- if $config.linenostoggler -}} {{- $lineNosIcon := dict "Class" "fa-solid fa-list-ol" | partial "plugin/icon.html" -}} - {{- $lineNosBtn = printf `%s` (T "assets.toggleLineNumbers") (T "assets.toggleLineNumbers") $lineNosIcon -}} + {{- $lineNosBtn = printf `%s` (T "assets.toggleLineNumbers") (T "assets.toggleLineNumbers") $lineNosIcon -}} {{- end -}} {{- if $config.linewraptoggler -}} {{- $lineWrapIcon := dict "Class" "fa-solid fa-right-left" | partial "plugin/icon.html" -}} - {{- $lineWrapBtn = printf `%s` (T "assets.toggleLineWrap") (T "assets.toggleLineWrap") $lineWrapIcon -}} + {{- $lineWrapBtn = printf `%s` (T "assets.toggleLineWrap") (T "assets.toggleLineWrap") $lineWrapIcon -}} {{- end -}} {{- if $config.editable -}} {{- $editIcon := dict "Class" "fa-solid fa-pen-to-square" | partial "plugin/icon.html" -}} - {{- $editBtn = printf `%s` (T "assets.toggleCodeEditable") (T "assets.toggleCodeEditable") $editIcon -}} + {{- $editBtn = printf `%s` (T "assets.toggleCodeEditable") (T "assets.toggleCodeEditable") $editIcon -}} {{- end -}} {{- if $config.copyable -}} {{- $copyIcon := dict "Class" "fa-regular fa-clone" | partial "plugin/icon.html" -}} - {{- $copyBtn = printf `%s` (T "assets.copyToClipboard") (T "assets.copyToClipboard") (T "assets.copiedText") $copyIcon -}} + {{- $copyBtn = printf `%s` (T "assets.copyToClipboard") (T "assets.copyToClipboard") (T "assets.copiedText") $copyIcon -}} {{- end -}} {{- if $config.downloadable -}} {{- $downloadIcon := dict "Class" "fa-solid fa-download" | partial "plugin/icon.html" -}} - {{- $downloadBtn = printf `%s` (T "assets.downloadCode") (T "assets.downloadCode") $downloadIcon -}} + {{- $downloadBtn = printf `%s` (T "assets.downloadCode") (T "assets.downloadCode") $downloadIcon -}} {{- end -}} {{- if $config.fullscreen -}} {{- $fullscreenIcon := dict "Class" "fa-solid fa-expand" | partial "plugin/icon.html" -}} - {{- $fullscreenBtn = printf `%s` (T "assets.toggleCodeFullscreen") (T "assets.toggleCodeFullscreen") $fullscreenIcon -}} + {{- $fullscreenBtn = printf `%s` (T "assets.toggleCodeFullscreen") (T "assets.toggleCodeFullscreen") $fullscreenIcon -}} {{- end -}} {{- with $config.name -}} {{- $titleEl = replace $titleEl `` (printf `` .) -}} diff --git a/layouts/_partials/function/task-lists.html b/layouts/_partials/function/task-lists.html index e2f8d90f..75ed8343 100644 --- a/layouts/_partials/function/task-lists.html +++ b/layouts/_partials/function/task-lists.html @@ -26,12 +26,12 @@ - [ ] Unchecked - [x] Checked */ -}} -{{- $icon := dict "Class" (add "checkbox-icon " (index $iconMap " ")) | partial "plugin/icon.html" -}} +{{- $icon := dict "Class" (index $iconMap " ") | partial "plugin/icon.html" -}} {{- $label := T (printf "taskList.%v" " ") -}} -{{- $content := replaceRE `(?s)
  • ((\n

    )*)\s?` (printf `

  • $1%s` $label $icon) . -}} +{{- $content := replaceRE `(?s)
  • ((\n

    )*)\s?([\s\S]*?)()` (printf `

  • $1%s$3$4` $icon $label) . -}} {{- $label := T (printf "taskList.%v" "x") -}} -{{- $icon := dict "Class" (add "checkbox-icon " (index $iconMap "x")) | partial "plugin/icon.html" -}} -{{- $content = replaceRE `(?s)
  • ((\n

    )*)\s?` (printf `

  • $1%s` $label $icon) $content -}} +{{- $icon := dict "Class" (index $iconMap "x") | partial "plugin/icon.html" -}} +{{- $content = replaceRE `(?s)
  • ((\n

    )*)\s?([\s\S]*?)()` (printf `

  • $1%s$3$4` $icon $label) $content -}} {{- /* The extended syntax is compatible with Obsidian. @@ -45,11 +45,11 @@ */ -}} {{- range $extendedSigns -}} {{- $class := index $iconMap . | default "fa-solid fa-check-square" -}} - {{- $icon := dict "Class" (add "checkbox-icon " $class) | partial "plugin/icon.html" -}} + {{- $icon := dict "Class" $class | partial "plugin/icon.html" -}} {{- $sign := htmlEscape . -}} {{- $originSign := replace . "\\" "" -}} {{- $label := (T (printf "taskList.%v" $originSign)) | default (T (printf "taskList.%v" " ")) -}} - {{- $content = replaceRE (printf `(?s)
  • ((\n

    )*)\[%s\]\s?` $sign) (printf `

  • $1%s` $originSign $label $icon) $content -}} + {{- $content = replaceRE (printf `(?s)
  • ((\n

    )*)\[%s\]\s?([\s\S]*?)()` $sign) (printf `

  • $1%s$3$4` $originSign $icon $label) $content -}} {{- end -}} {{- return $content -}}