| author | wenzelm |
| Sat, 25 Oct 2025 19:54:47 +0200 | |
| changeset 83388 | 8d90bd0e4f39 |
| parent 83386 | 5294055465d3 |
| child 83389 | 8d9c494b78cf |
| permissions | -rw-r--r-- |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
1 |
(function () {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
2 |
const vscode = acquireVsCodeApi(); |
| 83386 | 3 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
4 |
window.addEventListener("message", event => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
5 |
const message = event.data; |
| 83386 | 6 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
7 |
if (message.command === "update" && Array.isArray(message.sections)) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
8 |
renderDocumentation(message.sections); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
9 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
10 |
}); |
| 83386 | 11 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
12 |
function renderDocumentation(sections) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
13 |
const container = document.getElementById("documentation-container");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
14 |
if (!container) return; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
15 |
container.innerHTML = ""; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
16 |
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
17 |
vscode.setState({ sections: sections });
|
| 83386 | 18 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
19 |
const list = document.createElement("ul");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
20 |
list.classList.add("doc-list");
|
| 83386 | 21 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
22 |
let selectedEntry = null; |
| 83386 | 23 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
24 |
sections.forEach(section => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
25 |
const sectionItem = document.createElement("li");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
26 |
sectionItem.classList.add("doc-section");
|
| 83386 | 27 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
28 |
const titleElement = document.createElement("span");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
29 |
titleElement.textContent = section.title; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
30 |
titleElement.classList.add("section-title");
|
| 83386 | 31 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
32 |
const subList = document.createElement("ul");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
33 |
subList.classList.add("doc-sublist");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
34 |
subList.style.display = section.important ? "block" : "none"; |
| 83386 | 35 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
36 |
titleElement.addEventListener("click", () => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
37 |
subList.style.display = subList.style.display === "none" ? "block" : "none"; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
38 |
}); |
| 83386 | 39 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
40 |
section.entries.forEach(entry => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
41 |
const entryItem = document.createElement("li");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
42 |
entryItem.classList.add("doc-entry");
|
| 83386 | 43 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
44 |
const entryLink = document.createElement("a");
|
|
83388
8d90bd0e4f39
more accurate Doc_Entry: print_html like Isabelle/jEdit, proper platform_path;
wenzelm
parents:
83386
diff
changeset
|
45 |
entryLink.innerHTML = entry.print_html; |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
46 |
entryLink.href = "#"; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
47 |
entryLink.classList.add("doc-link");
|
| 83386 | 48 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
49 |
entryLink.addEventListener("click", event => {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
50 |
event.preventDefault(); |
| 83386 | 51 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
52 |
if (selectedEntry && selectedEntry !== entryItem) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
53 |
selectedEntry.classList.remove("selected");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
54 |
} |
| 83386 | 55 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
56 |
if (selectedEntry === entryItem) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
57 |
selectedEntry.classList.remove("selected");
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
58 |
selectedEntry = null; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
59 |
} else {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
60 |
selectedEntry = entryItem; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
61 |
entryItem.classList.add("selected");
|
|
83388
8d90bd0e4f39
more accurate Doc_Entry: print_html like Isabelle/jEdit, proper platform_path;
wenzelm
parents:
83386
diff
changeset
|
62 |
open_document(entry.platform_path); |
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
63 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
64 |
}); |
| 83386 | 65 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
66 |
entryItem.appendChild(entryLink); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
67 |
subList.appendChild(entryItem); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
68 |
}); |
| 83386 | 69 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
70 |
sectionItem.appendChild(titleElement); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
71 |
sectionItem.appendChild(subList); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
72 |
list.appendChild(sectionItem); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
73 |
}); |
| 83386 | 74 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
75 |
container.appendChild(list); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
76 |
} |
| 83386 | 77 |
|
|
83388
8d90bd0e4f39
more accurate Doc_Entry: print_html like Isabelle/jEdit, proper platform_path;
wenzelm
parents:
83386
diff
changeset
|
78 |
function open_document(platform_path) {
|
|
8d90bd0e4f39
more accurate Doc_Entry: print_html like Isabelle/jEdit, proper platform_path;
wenzelm
parents:
83386
diff
changeset
|
79 |
vscode.postMessage({ command: "open_document", platform_path: platform_path });
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
80 |
} |
| 83386 | 81 |
|
|
83363
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
82 |
window.onload = function () {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
83 |
const savedState = vscode.getState(); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
84 |
if (savedState && savedState.sections) {
|
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
85 |
renderDocumentation(savedState.sections); |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
86 |
} |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
87 |
}; |
|
486e094b676c
various improvements of Isabelle/VSCode: original changeset by Diana Korchmar, LMU München;
wenzelm
parents:
diff
changeset
|
88 |
})(); |