()
| 68 | } |
| 69 | |
| 70 | render() { |
| 71 | this.destroy(); // Cleanup potential drag states before re-rendering |
| 72 | this.container.textContent = ""; |
| 73 | |
| 74 | // --- Active Tools Section --- |
| 75 | const activeSection = <div className="section active-tools"></div>; |
| 76 | activeSection.appendChild( |
| 77 | <div className="section-title">{strings["active tools"]}</div>, |
| 78 | ); |
| 79 | |
| 80 | this.activeGrid = <div className="quicktools-grid active-grid"></div>; |
| 81 | |
| 82 | const totalSlots = |
| 83 | settings.QUICKTOOLS_ROWS * |
| 84 | settings.QUICKTOOLS_GROUPS * |
| 85 | settings.QUICKTOOLS_GROUP_CAPACITY; |
| 86 | |
| 87 | for (let i = 0; i < totalSlots; i++) { |
| 88 | const itemIndex = settings.value.quicktoolsItems[i]; |
| 89 | const itemDef = items[itemIndex]; |
| 90 | const el = this.createItemElement(itemDef, i, "active"); |
| 91 | this.activeGrid.appendChild(el); |
| 92 | } |
| 93 | |
| 94 | activeSection.appendChild(this.activeGrid); |
| 95 | this.container.appendChild(activeSection); |
| 96 | |
| 97 | // --- Available Tools Section --- |
| 98 | this.availableSection = <div className="section available-tools"></div>; |
| 99 | this.availableSection.appendChild( |
| 100 | <div className="section-title">{strings["available tools"]}</div>, |
| 101 | ); |
| 102 | |
| 103 | // Group items |
| 104 | const categories = { |
| 105 | Modifiers: ["ctrl", "shift", "alt", "meta"], |
| 106 | Commands: ["command", "undo", "redo", "save", "search"], |
| 107 | Navigation: ["key"], |
| 108 | Symbols: ["insert"], |
| 109 | Other: [], |
| 110 | }; |
| 111 | |
| 112 | const groupedItems = {}; |
| 113 | items.forEach((item, index) => { |
| 114 | let category = "Other"; |
| 115 | for (const [cat, actions] of Object.entries(categories)) { |
| 116 | if (actions.includes(item.action)) { |
| 117 | category = cat; |
| 118 | break; |
| 119 | } |
| 120 | } |
| 121 | if (!groupedItems[category]) groupedItems[category] = []; |
| 122 | groupedItems[category].push({ item, index }); |
| 123 | }); |
| 124 | |
| 125 | Object.entries(groupedItems).forEach(([category, list]) => { |
| 126 | const catHeader = <div className="category-header">{category}</div>; |
| 127 | const catGrid = <div className="quicktools-grid source-grid"></div>; |
no test coverage detected