joplin-plugin-checkboxes-sum-calculator 1.0.28 → 1.0.29
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/README.md
CHANGED
|
@@ -37,16 +37,19 @@ Here are 5 practical ways to automate your workflows using the **Checkbox Sum Ca
|
|
|
37
37
|
|
|
38
38
|
The calculator follows strict processing protocols based on structural markdown and layout formats to ensure calculations remain robust and predictable:
|
|
39
39
|
|
|
40
|
-
### 1.
|
|
40
|
+
### 1. Same units required
|
|
41
|
+
Numbers must be in the same unit. Unit conversion is not supported yet.
|
|
42
|
+
|
|
43
|
+
### 2. Standard Markdown Checklists
|
|
41
44
|
* **Counted Values:** Ordinary whole or fractional numbers contained anywhere along a standard bullet list line (e.g., `- [x] Oats — 225.5 kcal`) are parsed completely.
|
|
42
45
|
* **Checked vs. Unchecked:** Checked tasks (`- [x]`) map directly into the **Checked** sum bucket. Empty checklist items (`- [ ]`) map directly to **Unchecked (Remaining)**.
|
|
43
46
|
|
|
44
|
-
###
|
|
47
|
+
### 3. Advanced HTML Tables
|
|
45
48
|
Tables apply an automated structural analysis matrix tailored for tabular accounting:
|
|
46
49
|
* **Single Checkbox Row Profile:** If a row contains **exactly one** checkbox (either filled or empty), the state of that single checkbox dictates the mathematical fate of the entire row. If marked checked, *all* regular numeric cell tokens across the entire horizontal row add up into **Checked**.
|
|
47
50
|
* **Multi-Checkbox Row Profile:** If a row contains **more than one** distinct checkbox cell, the plugin flips into a hyper-granular **cell-by-cell matrix layout mode**. Numbers are summed into **Checked** strictly within cells where the checkbox is marked active. Cells holding unselected checkboxes, text strings, or no checkboxes at all flow into **Unchecked**.
|
|
48
51
|
|
|
49
|
-
###
|
|
52
|
+
### 4. Bold Number Isolation Rule
|
|
50
53
|
* If any number is formatted inside **bold text** (`**number**` or `__number__`) or placed inside a bold cell (`<b>`, `<strong>`), the engine marks it as a system metadata bypass token.
|
|
51
54
|
* It highlights the value in **yellow** inside the list views and **completely excludes it from all calculations**. This allows you to list sizes, years, model iterations, or dimensions (e.g., `MacBook Pro **15-inch** — 650`) without breaking your monetary or calorie math.
|
|
52
55
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={998(t,e){e.default=joplin},156(t,e,o){var n=this&&this.__awaiter||function(t,e,o,n){return new(o||(o=Promise))(function(r,i){function l(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(l,s)}a((n=n.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=o(998);r.default.plugins.register({onStart:function(){return n(this,void 0,void 0,function*(){const t=r.default.views.panels,e=yield t.create("checkbox_sum_panel");let o=!0;function i(t){return t?t.replace(/<\/?[^>]+(>|\$)/g,"").replace(/ /gi,"").replace(/\s+/g," ").trim():""}function l(){return n(this,void 0,void 0,function*(){const o=yield r.default.workspace.selectedNote();if(!o||!o.body)return void(yield t.setHtml(e,'<div style="padding: 10px; font-family: sans-serif;"><h3>Checked Sum:</h3><h1 style="color: #2da44e; font-size: 36px; margin: 0;"><b>0</b></h1></div>'));let n=0,l=0;const s=/\d+(?:[\.,]\d+)?/g;let a=[];const d=o.body,c=[],p=/<tr[^>]*>([\s\(\S\)]*?)<\/tr>/gi;let f;for(;null!==(f=p.exec(d));)c.push({index:f.index,type:"html",content:f});const
|
|
1
|
+
(()=>{"use strict";var t={998(t,e){e.default=joplin},156(t,e,o){var n=this&&this.__awaiter||function(t,e,o,n){return new(o||(o=Promise))(function(r,i){function l(t){try{a(n.next(t))}catch(t){i(t)}}function s(t){try{a(n.throw(t))}catch(t){i(t)}}function a(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o(function(t){t(e)})).then(l,s)}a((n=n.apply(t,e||[])).next())})};Object.defineProperty(e,"__esModule",{value:!0});const r=o(998);r.default.plugins.register({onStart:function(){return n(this,void 0,void 0,function*(){const t=r.default.views.panels,e=yield t.create("checkbox_sum_panel");let o=!0;function i(t){return t?t.replace(/<\/?[^>]+(>|\$)/g,"").replace(/ /gi,"").replace(/\s+/g," ").trim():""}function l(){return n(this,void 0,void 0,function*(){const o=yield r.default.workspace.selectedNote();if(!o||!o.body)return void(yield t.setHtml(e,'<div style="padding: 10px; font-family: sans-serif;"><h3>Checked Sum:</h3><h1 style="color: #2da44e; font-size: 36px; margin: 0;"><b>0</b></h1></div>'));let n=0,l=0;const s=/\d+(?:[\.,]\d+)?/g;let a=[];const d=o.body,c=[],p=/<tr[^>]*>([\s\(\S\)]*?)<\/tr>/gi;let f;for(;null!==(f=p.exec(d));)c.push({index:f.index,type:"html",content:f});const u=/^\s*-\s+\[([ xX])\]([^\n\r]*)/gm;let b;for(;null!==(b=u.exec(d));)c.push({index:b.index,type:"md",content:b});c.sort((t,e)=>t.index-e.index);for(const t of c)if("html"===t.type){const e=t.content[0],o=/<td[^>]*>([\s\(\S\)]*?)<\/td>/gi;let r;const d=[];for(;null!==(r=o.exec(e));)d.push(r[0]);o.lastIndex=0;let c=0,p=!1;for(const t of d)(/class="[^"]*(?:checked|checkbox|joplin-checklist)[^"]*"/i.test(t)||/<li[^>]*>/i.test(t))&&(c++,/class="[^"]*checked[^"]*"/i.test(t)&&(p=!0));if(c>0){let t=[],d=0,f=0,u=!1;for(;null!==(r=o.exec(e));){const e=r[0],o=i(e);if(o.length>0){const n=/class="[^"]*checked[^"]*"/i.test(e);let r=o;if(/<b[^>]*>.*?<\/b>|<strong[^>]*>.*?<\/strong>|font-weight:\s*bold/gi.test(e))r=o.replace(s,t=>`<mark style="background-color: #fff2a3; color: #5d4037; padding: 0 2px; border-radius: 2px;">${t}</mark>`);else{const t=o.match(s);if(c<=1){if(p){if(u=!0,r=o.replace(s,t=>`<mark style="background-color: #d1f5d3; color: #1b5e20; padding: 0 2px; border-radius: 2px; font-weight: bold;">${t}</mark>`),t)for(const e of t)d+=parseFloat(e.replace(",","."))}else if(r=o.replace(s,t=>`<mark style="background-color: #f0f0f0; color: #666; padding: 0 2px; border-radius: 2px;">${t}</mark>`),t)for(const e of t)f+=parseFloat(e.replace(",","."))}else if(n){if(u=!0,r=o.replace(s,t=>`<mark style="background-color: #d1f5d3; color: #1b5e20; padding: 0 2px; border-radius: 2px; font-weight: bold;">${t}</mark>`),t)for(const e of t)d+=parseFloat(e.replace(",","."))}else if(r=o.replace(s,t=>`<mark style="background-color: #f0f0f0; color: #666; padding: 0 2px; border-radius: 2px;">${t}</mark>`),t)for(const e of t)f+=parseFloat(e.replace(",","."))}t.push(r)}}if(n+=d,l+=f,u&&d>0){const e=Number(d.toFixed(2));a.push(`<b>${e}</b> (${t.join(" - ")})`)}}}else{const e="x"===t.content[1].trim().toLowerCase(),o=t.content[2];if(o&&o.trim().length>0){let t=0,r=o.trim().replace(/\*\*([\s\(\S\)]*?)\*\*/g,(t,e)=>`<b>${e.replace(s,t=>`<mark class="sum-ignored" style="background-color: #fff2a3; color: #5d4037; padding: 0 2px; border-radius: 2px; font-weight: bold;">${t}</mark>`)}</b>`).replace(/__([\s\(\S\)]*?)__/g,(t,e)=>`<b>${e.replace(s,t=>`<mark class="sum-ignored" style="background-color: #fff2a3; color: #5d4037; padding: 0 2px; border-radius: 2px; font-weight: bold;">${t}</mark>`)}</b>`),i=r;i=i.replace(/<mark class=["']sum-ignored["'][^>]*>.*?<\/mark>/gi,"");const d=i.match(s);if(d)for(const e of d){const o=parseFloat(e.replace(",","."));isNaN(o)||(t+=o)}const c=r.split(/(<mark[^>]*>.*?<\/mark>|<b>.*?<\/b>)/g);let p=[];for(const t of c)if(t.startsWith("<mark")||t.startsWith("<b>"))p.push(t);else{let o=t;o=e?t.replace(s,t=>`<mark style="background-color: #d1f5d3; color: #1b5e20; padding: 0 2px; border-radius: 2px; font-weight: bold;">${t}</mark>`):t.replace(s,t=>`<mark style="background-color: #f0f0f0; color: #666; padding: 0 2px; border-radius: 2px;">${t}</mark>`),p.push(o)}let f=p.join("");f=f.replace(/<\/?b[^>]*>/gi,"");const u=Number(t.toFixed(2));e?(n+=Number(t),a.push(`<b>${u}</b> (${f})`)):l+=Number(t)}}let g="";if(a.length>0){g='<h4 style="margin-top: 20px; margin-bottom: 5px; color: #666; border-top: 1px solid #ddd; padding-top: 10px;">Details:</h4>',g+='<ul style="padding-left: 20px; margin: 0; font-size: 14px; color: #333; line-height: 1.4;">';for(const t of a)g+=`<li style="margin-bottom: 4px;">${t}</li>`;g+="</ul>"}const h=Number(n.toFixed(2)),m=`\n\t\t\t\t<div style="margin-top: 15px; padding-top: 10px; border-top: 1px dashed #bbb; font-size: 13px; color: #444; line-height: 1.6;">\n\t\t\t\t\t<div style="display: flex; justify-content: space-between; margin-bottom: 2px;">\n\t\t\t\t\t\t<span>Сhecked:</span>\n\t\t\t\t\t\t<span style="color: #2da44e; font-weight: bold;">${h}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div style="display: flex; justify-content: space-between; margin-bottom: 4px;">\n\t\t\t\t\t\t<span>Unchecked (Remaining):</span>\n\t\t\t\t\t\t<span style="color: #c93b3b; font-weight: bold;">${Number(l.toFixed(2))}</span>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div style="display: flex; justify-content: space-between; color: #000; margin-top: 4px; padding: 2px 0;">\n\t\t\t\t\t\t<span>Total:</span>\n\t\t\t\t\t\t<span>${Number((n+l).toFixed(2))}</span>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t`;yield t.setHtml(e,`\n\t\t\t\t<div style="padding: 10px; font-family: sans-serif; box-sizing: border-box; height: 100vh; overflow-y: auto;">\n\t\t\t\t\t<h3 style="margin-bottom: 5px; color: #555;">Checked Sum:</h3>\n\t\t\t\t\t<h1 style="color: #2da44e; font-size: 36px; margin: 0;"><b>${h}</b></h1>\n\t\t\t\t\t${g}\n\t\t\t\t\t${m}\n\t\t\t\t\t<p style="font-size: 11px; color: #888; margin-top: 20px; border-top: 1px dashed #ccc; padding-top: 8px; line-height: 1.4; padding-bottom: 20px;">\n\t\t\t\t\t\t<i>Notice: Same units required. All numbers in the row are added up (e.g., model IDs or serial numbers), except those formatted in <b>bold</b>. Counted numbers are highlighted in <span style="background-color: #d1f5d3; color: #1b5e20; padding: 0 2px; border-radius: 2px; font-weight: bold;">green</span>. Ignored numbers are highlighted in <span style="background-color: #fff2a3; color: #5d4037; padding: 0 2px; border-radius: 2px; font-weight: bold;">yellow</span>.</i>\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t`)})}yield t.setHtml(e,'<div style="padding: 10px; font-family: sans-serif;"><h3>Checked Sum:</h3><h1 style="color: #2da44e; font-size: 36px; margin: 0;"><b>0</b></h1></div>'),yield t.show(e),yield r.default.commands.register({name:"toggleCheckboxSumPanel",label:"Toggle Checkbox Sum Panel",iconName:"fas fa-plus-square",execute:()=>n(this,void 0,void 0,function*(){o=!o,o?(yield t.show(e),l()):yield t.hide(e)})}),yield r.default.views.toolbarButtons.create("toggleCheckboxSumPanelButton","toggleCheckboxSumPanel","noteToolbar"),yield r.default.workspace.onNoteChange(()=>{o&&l()}),yield r.default.workspace.onNoteSelectionChange(()=>{o&&l()}),l()})}})}};const e={};!function o(n){const r=e[n];if(void 0!==r)return r.exports;const i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,o),i.exports}(156)})();
|
package/package.json
CHANGED
|
Binary file
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifest_version": 1,
|
|
3
3
|
"id": "com.giicha.joplin-plugin-checkboxes-sum-calculator",
|
|
4
4
|
"app_min_version": "3.7",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.29",
|
|
6
6
|
"name": "Checkbox Sum Calculator",
|
|
7
7
|
"description": "Summing up all numbers in strings, rows or cells with checked checkboxes.",
|
|
8
8
|
"author": "giicha",
|
|
@@ -39,6 +39,6 @@
|
|
|
39
39
|
"src": "images/CSC_Promo.png",
|
|
40
40
|
"label": "Checkbox Sum Calculator"
|
|
41
41
|
},
|
|
42
|
-
"_publish_hash": "sha256:
|
|
43
|
-
"_publish_commit": "master:
|
|
42
|
+
"_publish_hash": "sha256:8e3669eb9c87684d682b9c0dc646f8e6ece433a8d53fba994ffe117cf72bcce2",
|
|
43
|
+
"_publish_commit": "master:428aea62befc601f6641bdf0bdab94daa692cdf6"
|
|
44
44
|
}
|