| 666 | } |
| 667 | |
| 668 | private async updatePreviews() { |
| 669 | if (!this.computePreview || !this.previewContainerEl) return; |
| 670 | try { |
| 671 | const values: Record<string, string> = {}; |
| 672 | this.result.forEach((v, k) => (values[k] = v)); |
| 673 | const preview = await this.computePreview(values); |
| 674 | // Clear old preview lines (leave the label at index 0) |
| 675 | const children = Array.from(this.previewContainerEl.children); |
| 676 | for (let i = 1; i < children.length; i++) { |
| 677 | children[i].remove(); |
| 678 | } |
| 679 | Object.entries(preview).forEach(([k, v]) => { |
| 680 | const row = this.previewContainerEl!.createDiv({ |
| 681 | cls: "qa-onepage-preview-row", |
| 682 | }); |
| 683 | row.createEl("div", { |
| 684 | text: `${k}:`, |
| 685 | cls: "qa-preview-key", |
| 686 | }); |
| 687 | row.createEl("div", { text: String(v), cls: "qa-preview-val" }); |
| 688 | }); |
| 689 | } catch { |
| 690 | // Ignore preview errors |
| 691 | } |
| 692 | } |
| 693 | } |