mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-12 08:54:57 +03:00
Merge branch 'dev'
This commit is contained in:
@@ -137,10 +137,11 @@ Manually highlight a UI element by name (fuzzy match). Places a semi-transparent
|
||||
|
||||
| Parameter | Type | Description |
|
||||
|-----------|------|-------------|
|
||||
| `text` | string | Element name — button, link, field, section, or command |
|
||||
| `text` | string | Element name — button, link, field, group/panel, section, or command |
|
||||
|
||||
- Fuzzy match order: exact → startsWith → includes
|
||||
- Searches form elements first, then sections/commands
|
||||
- Search priority: popup items → commands → form elements (buttons, fields) → **form groups/panels** → sections
|
||||
- Groups are matched by visible title or internal name (e.g., `highlight('Оргструктура')` finds the group panel)
|
||||
- `pointer-events: none` — does not block clicks
|
||||
|
||||
### `unhighlight()`
|
||||
|
||||
@@ -3579,7 +3579,37 @@ export async function highlight(text, opts = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Fallback: sections (sidebar navigation)
|
||||
// 3. Form groups/panels (containers with title text or matching ID name)
|
||||
if (!elId) {
|
||||
const formNum = elId === null ? await page.evaluate(detectFormScript()) : null;
|
||||
if (formNum !== null) {
|
||||
elId = await page.evaluate(`(() => {
|
||||
const norm = s => (s?.trim().replace(/\\u00a0/g, ' ') || '').replace(/ё/gi, 'е');
|
||||
const target = ${JSON.stringify(normYo(text.toLowerCase()))};
|
||||
const p = 'form' + ${formNum} + '_';
|
||||
// Collect visible group containers — _container or _div elements
|
||||
const groups = [...document.querySelectorAll('[id^="' + p + '"][id$="_container"], [id^="' + p + '"][id$="_div"]')]
|
||||
.filter(el => el.offsetWidth > 0 && el.offsetHeight > 0);
|
||||
const items = groups.map(el => {
|
||||
const idName = el.id.replace(p, '').replace(/_(container|div)$/, '');
|
||||
// Try to find a visible title/label for this group
|
||||
const titleEl = document.getElementById(p + idName + '#title_text')
|
||||
|| document.getElementById(p + idName + '_title_text');
|
||||
const label = norm(titleEl?.innerText || '').toLowerCase();
|
||||
const name = norm(idName).toLowerCase();
|
||||
return { id: el.id, name, label };
|
||||
});
|
||||
// Fuzzy match: exact label → exact name → startsWith → includes
|
||||
let found = items.find(i => i.label === target);
|
||||
if (!found) found = items.find(i => i.name === target);
|
||||
if (!found) found = items.find(i => i.label.startsWith(target) || i.name.startsWith(target));
|
||||
if (!found) found = items.find(i => i.label.includes(target) || i.name.includes(target));
|
||||
return found ? found.id : null;
|
||||
})()`);
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Fallback: sections (sidebar navigation)
|
||||
if (!elId) {
|
||||
elId = await page.evaluate(`(() => {
|
||||
const norm = s => (s?.trim().replace(/\\u00a0/g, ' ') || '').replace(/ё/gi, 'е');
|
||||
|
||||
Reference in New Issue
Block a user