@aicupa/plugin-balance 1.0.4 → 1.0.5
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/package.json +1 -1
- package/service.js +20 -0
- package/view/index.html +62 -0
package/package.json
CHANGED
package/service.js
CHANGED
|
@@ -56,6 +56,22 @@ module.exports = createPlugin((api) => {
|
|
|
56
56
|
return total;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
function collectFocusedItems(tree) {
|
|
60
|
+
const items = [];
|
|
61
|
+
if (!Array.isArray(tree)) return items;
|
|
62
|
+
const stack = [...tree];
|
|
63
|
+
while (stack.length) {
|
|
64
|
+
const n = stack.pop();
|
|
65
|
+
if (n.todo?.focus && n.todo?.content) {
|
|
66
|
+
items.push(n.todo.content);
|
|
67
|
+
}
|
|
68
|
+
if (Array.isArray(n.children)) {
|
|
69
|
+
stack.push(...n.children);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return items;
|
|
73
|
+
}
|
|
74
|
+
|
|
59
75
|
function findNodeById(tree, id) {
|
|
60
76
|
const stack = [...tree];
|
|
61
77
|
while (stack.length) {
|
|
@@ -91,6 +107,10 @@ module.exports = createPlugin((api) => {
|
|
|
91
107
|
};
|
|
92
108
|
},
|
|
93
109
|
|
|
110
|
+
getFocusedItems({ tree }) {
|
|
111
|
+
return { ok: true, result: collectFocusedItems(tree) };
|
|
112
|
+
},
|
|
113
|
+
|
|
94
114
|
calculate({ tree }) {
|
|
95
115
|
if (!Array.isArray(tree) || !tempNodeId || !currentNodeId) {
|
|
96
116
|
return {
|
package/view/index.html
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
box-sizing: border-box;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
html, body {
|
|
14
|
+
height: auto;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
body {
|
|
14
19
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
15
20
|
background: transparent;
|
|
@@ -85,6 +90,37 @@
|
|
|
85
90
|
min-width: 36px;
|
|
86
91
|
text-align: right;
|
|
87
92
|
}
|
|
93
|
+
|
|
94
|
+
.focus-section {
|
|
95
|
+
margin-top: 6px;
|
|
96
|
+
padding: 0 2px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.focus-title {
|
|
100
|
+
font-size: 10px;
|
|
101
|
+
opacity: 0.5;
|
|
102
|
+
text-transform: uppercase;
|
|
103
|
+
letter-spacing: 0.5px;
|
|
104
|
+
margin-bottom: 3px;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.focus-list {
|
|
108
|
+
list-style: none;
|
|
109
|
+
display: flex;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
gap: 2px;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.focus-item {
|
|
115
|
+
font-size: 11px;
|
|
116
|
+
padding: 2px 6px;
|
|
117
|
+
border-radius: 3px;
|
|
118
|
+
background: rgba(64, 128, 255, 0.08);
|
|
119
|
+
border-left: 2px solid rgba(64, 128, 255, 0.4);
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
overflow: hidden;
|
|
122
|
+
text-overflow: ellipsis;
|
|
123
|
+
}
|
|
88
124
|
</style>
|
|
89
125
|
</head>
|
|
90
126
|
|
|
@@ -102,6 +138,10 @@
|
|
|
102
138
|
</div>
|
|
103
139
|
<span class="balance-ratio" id="ratio">0%</span>
|
|
104
140
|
</div>
|
|
141
|
+
<div class="focus-section" id="focusSection" style="display:none">
|
|
142
|
+
<div class="focus-title">In Progress</div>
|
|
143
|
+
<ul class="focus-list" id="focusList"></ul>
|
|
144
|
+
</div>
|
|
105
145
|
<script>
|
|
106
146
|
(function () {
|
|
107
147
|
let callId = 0
|
|
@@ -140,6 +180,8 @@
|
|
|
140
180
|
const currentInput = document.getElementById('currentId')
|
|
141
181
|
const barFill = document.getElementById('barFill')
|
|
142
182
|
const ratioEl = document.getElementById('ratio')
|
|
183
|
+
const focusSection = document.getElementById('focusSection')
|
|
184
|
+
const focusList = document.getElementById('focusList')
|
|
143
185
|
let debounceTimer = null
|
|
144
186
|
|
|
145
187
|
function onInputChange() {
|
|
@@ -172,6 +214,26 @@
|
|
|
172
214
|
ratioEl.textContent = pct + '%'
|
|
173
215
|
}
|
|
174
216
|
} catch (_) { }
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
const res = await callPlugin('getFocusedItems', { tree })
|
|
220
|
+
const inner = res?.result || res
|
|
221
|
+
const items = inner?.result || inner
|
|
222
|
+
if (Array.isArray(items) && items.length) {
|
|
223
|
+
focusList.innerHTML = ''
|
|
224
|
+
items.forEach(function (text) {
|
|
225
|
+
var li = document.createElement('li')
|
|
226
|
+
li.className = 'focus-item'
|
|
227
|
+
li.textContent = text
|
|
228
|
+
focusList.appendChild(li)
|
|
229
|
+
})
|
|
230
|
+
focusSection.style.display = ''
|
|
231
|
+
} else {
|
|
232
|
+
focusSection.style.display = 'none'
|
|
233
|
+
}
|
|
234
|
+
} catch (_) {
|
|
235
|
+
focusSection.style.display = 'none'
|
|
236
|
+
}
|
|
175
237
|
}
|
|
176
238
|
|
|
177
239
|
async function loadConfig() {
|