Add glossary hover presentation

This commit is contained in:
2026-05-19 07:34:52 +02:00
parent 751ac5f62b
commit 121b174f2c
19 changed files with 2356 additions and 1912 deletions
+35 -3
View File
@@ -276,10 +276,10 @@ export class InkEngine {
for (const part of parts) {
if (!node) return null;
if (Array.isArray(node) && node.length > 0 && this.isNamedContainerMap(node[node.length - 1]) && part in node[node.length - 1]) {
node = node[node.length - 1][part];
} else if (Array.isArray(node) && /^\d+$/.test(part)) {
if (Array.isArray(node) && /^\d+$/.test(part)) {
node = node[Number(part)];
} else if (Array.isArray(node)) {
node = this.findNamedInkChild(node, part);
} else if (this.isNamedContainerMap(node) && part in node) {
node = node[part];
} else {
@@ -290,6 +290,38 @@ export class InkEngine {
return node;
}
private findNamedInkChild(container: any[], part: string): any {
for (let index = container.length - 1; index >= 0; index -= 1) {
const item = container[index];
if (this.isNamedContainerMap(item) && part in item) {
return item[part];
}
if (!Array.isArray(item)) continue;
const namedMap = this.getInkContainerMap(item);
if (namedMap?.['#n'] === part) {
return item;
}
if (namedMap && part in namedMap) {
return namedMap[part];
}
}
return null;
}
private getInkContainerMap(container: any[]): Record<string, unknown> | null {
for (let index = container.length - 1; index >= 0; index -= 1) {
const item = container[index];
if (this.isNamedContainerMap(item)) {
return item;
}
}
return null;
}
private isNamedContainerMap(value: unknown): value is Record<string, unknown> {
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
}