fix: preserve filtered command actions (#60)
This commit is contained in:
1 parent
36f500d58b
commit
3e1ce3e72a
3 files changed
+36
-3
No files matched your search
@@ -0,0 +1,10 @@
|
||||
(function (root, factory) {
|
||||
const filterCommands = factory();
|
||||
if (typeof module === 'object' && module.exports) module.exports = filterCommands;
|
||||
if (root) root.filterCommands = filterCommands;
|
||||
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
|
||||
return function filterCommands(commands, filter) {
|
||||
const term = String(filter || '').toLowerCase();
|
||||
return commands.filter(command => command.name.toLowerCase().includes(term));
|
||||
};
|
||||
});
|
||||
+3
-3
@@ -160,6 +160,7 @@ textarea { resize: vertical; min-height: 120px; }
|
||||
<div class="footer">Creative AI-imbued UI • stackchain-dashboard</div>
|
||||
|
||||
<script src="/static/markdown.js"></script>
|
||||
<script src="/static/commands.js"></script>
|
||||
<script>
|
||||
(function(){
|
||||
const qs = (s, el=document) => el.querySelector(s);
|
||||
@@ -340,11 +341,10 @@ textarea { resize: vertical; min-height: 120px; }
|
||||
];
|
||||
function renderCommands(filter) {
|
||||
const el = qs('#cmd-results');
|
||||
const term = String(filter||'').toLowerCase();
|
||||
const items = commands.filter(c => c.name.toLowerCase().includes(term));
|
||||
const items = filterCommands(commands, filter);
|
||||
el.innerHTML = items.map((c, idx) => '<div class="cmd-item" data-idx="' + idx + '">' + escapeHtml(c.name) + '</div>').join('');
|
||||
el.querySelectorAll('.cmd-item').forEach((item) => {
|
||||
item.addEventListener('click', () => { commands[Number(item.dataset.idx)].run(); qs('#cmd-palette').classList.remove('open'); qs('#cmd-input').value=''; });
|
||||
item.addEventListener('click', () => { items[Number(item.dataset.idx)].run(); qs('#cmd-palette').classList.remove('open'); qs('#cmd-input').value=''; });
|
||||
});
|
||||
}
|
||||
qs('#open-palette').addEventListener('click', () => { qs('#cmd-palette').classList.add('open'); qs('#cmd-input').focus(); renderCommands(''); });
|
||||
|
||||
Reference in new issue
Block a user