Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions web/src/i18n/ar.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "المتغير";
"web_live_ph_code" = "شيفرتك";
"web_live_ph_end" = "النهاية";
"web_editor_title" = "المخطط";
"web_editor_show" = "إظهار المخطط";
"web_editor_hide" = "إخفاء المخطط";
3 changes: 3 additions & 0 deletions web/src/i18n/da.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "variabel";
"web_live_ph_code" = "Din kode";
"web_live_ph_end" = "slut";
"web_editor_title" = "Strukturdiagram";
"web_editor_show" = "Vis strukturdiagram";
"web_editor_hide" = "Skjul strukturdiagram";
3 changes: 3 additions & 0 deletions web/src/i18n/de.strings
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@
"web_live_ph_selector" = "Variable";
"web_live_ph_code" = "Dein Code";
"web_live_ph_end" = "Ende";
"web_editor_title" = "Struktogramm";
"web_editor_show" = "Struktogramm aufklappen";
"web_editor_hide" = "Struktogramm einklappen";
3 changes: 3 additions & 0 deletions web/src/i18n/el.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "μεταβλητή";
"web_live_ph_code" = "Ο κώδικάς σου";
"web_live_ph_end" = "τέλος";
"web_editor_title" = "Διάγραμμα";
"web_editor_show" = "Εμφάνιση διαγράμματος";
"web_editor_hide" = "Απόκρυψη διαγράμματος";
3 changes: 3 additions & 0 deletions web/src/i18n/en.strings
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,6 @@
"web_live_ph_selector" = "variable";
"web_live_ph_code" = "Your code";
"web_live_ph_end" = "end";
"web_editor_title" = "Diagram";
"web_editor_show" = "Show diagram";
"web_editor_hide" = "Hide diagram";
3 changes: 3 additions & 0 deletions web/src/i18n/es.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "variable";
"web_live_ph_code" = "Tu código";
"web_live_ph_end" = "fin";
"web_editor_title" = "Diagrama";
"web_editor_show" = "Mostrar diagrama";
"web_editor_hide" = "Ocultar diagrama";
3 changes: 3 additions & 0 deletions web/src/i18n/fr.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "variable";
"web_live_ph_code" = "Ton code";
"web_live_ph_end" = "fin";
"web_editor_title" = "Diagramme";
"web_editor_show" = "Afficher le diagramme";
"web_editor_hide" = "Masquer le diagramme";
3 changes: 3 additions & 0 deletions web/src/i18n/he.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "משתנה";
"web_live_ph_code" = "הקוד שלך";
"web_live_ph_end" = "סוף";
"web_editor_title" = "תרשים";
"web_editor_show" = "הצגת התרשים";
"web_editor_hide" = "הסתרת התרשים";
3 changes: 3 additions & 0 deletions web/src/i18n/it.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "variabile";
"web_live_ph_code" = "Il tuo codice";
"web_live_ph_end" = "fine";
"web_editor_title" = "Diagramma";
"web_editor_show" = "Mostra diagramma";
"web_editor_hide" = "Nascondi diagramma";
3 changes: 3 additions & 0 deletions web/src/i18n/ja.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "変数";
"web_live_ph_code" = "ここにコード";
"web_live_ph_end" = "終了";
"web_editor_title" = "構造図";
"web_editor_show" = "構造図を表示";
"web_editor_hide" = "構造図を隠す";
3 changes: 3 additions & 0 deletions web/src/i18n/ko.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "변수";
"web_live_ph_code" = "코드 작성";
"web_live_ph_end" = "끝";
"web_editor_title" = "구조도";
"web_editor_show" = "구조도 표시";
"web_editor_hide" = "구조도 숨기기";
3 changes: 3 additions & 0 deletions web/src/i18n/nb.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "variabel";
"web_live_ph_code" = "Din kode";
"web_live_ph_end" = "slutt";
"web_editor_title" = "Strukturdiagram";
"web_editor_show" = "Vis strukturdiagram";
"web_editor_hide" = "Skjul strukturdiagram";
3 changes: 3 additions & 0 deletions web/src/i18n/nl.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "variabele";
"web_live_ph_code" = "Jouw code";
"web_live_ph_end" = "einde";
"web_editor_title" = "Diagram";
"web_editor_show" = "Diagram tonen";
"web_editor_hide" = "Diagram verbergen";
3 changes: 3 additions & 0 deletions web/src/i18n/pl.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "zmienna";
"web_live_ph_code" = "Twój kod";
"web_live_ph_end" = "koniec";
"web_editor_title" = "Diagram";
"web_editor_show" = "Pokaż diagram";
"web_editor_hide" = "Ukryj diagram";
3 changes: 3 additions & 0 deletions web/src/i18n/pt-PT.strings
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,6 @@
"web_live_ph_selector" = "variável";
"web_live_ph_code" = "O teu código";
"web_live_ph_end" = "fim";
"web_editor_title" = "Diagrama";
"web_editor_show" = "Mostrar diagrama";
"web_editor_hide" = "Ocultar diagrama";
3 changes: 3 additions & 0 deletions web/src/i18n/ru.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "переменная";
"web_live_ph_code" = "Твой код";
"web_live_ph_end" = "конец";
"web_editor_title" = "Диаграмма";
"web_editor_show" = "Показать диаграмму";
"web_editor_hide" = "Скрыть диаграмму";
3 changes: 3 additions & 0 deletions web/src/i18n/sv.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "variabel";
"web_live_ph_code" = "Din kod";
"web_live_ph_end" = "slut";
"web_editor_title" = "Strukturdiagram";
"web_editor_show" = "Visa strukturdiagram";
"web_editor_hide" = "Dölj strukturdiagram";
3 changes: 3 additions & 0 deletions web/src/i18n/tr.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "değişken";
"web_live_ph_code" = "Kodun";
"web_live_ph_end" = "bitiş";
"web_editor_title" = "Diyagram";
"web_editor_show" = "Diyagramı göster";
"web_editor_hide" = "Diyagramı gizle";
3 changes: 3 additions & 0 deletions web/src/i18n/uk.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "змінна";
"web_live_ph_code" = "Твій код";
"web_live_ph_end" = "кінець";
"web_editor_title" = "Діаграма";
"web_editor_show" = "Показати діаграму";
"web_editor_hide" = "Сховати діаграму";
3 changes: 3 additions & 0 deletions web/src/i18n/zh-Hans.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "变量";
"web_live_ph_code" = "你的代码";
"web_live_ph_end" = "结束";
"web_editor_title" = "结构图";
"web_editor_show" = "显示结构图";
"web_editor_hide" = "隐藏结构图";
3 changes: 3 additions & 0 deletions web/src/i18n/zh-Hant.strings
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@
"web_live_ph_selector" = "變數";
"web_live_ph_code" = "你的程式碼";
"web_live_ph_end" = "結束";
"web_editor_title" = "結構圖";
"web_editor_show" = "顯示結構圖";
"web_editor_hide" = "隱藏結構圖";
70 changes: 66 additions & 4 deletions web/src/ui/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ const learnKey = 'visustruct.learn.open'
const learnWidthKey = 'visustruct.learn.width'
const liveKey = 'visustruct.live.open'
const liveWidthKey = 'visustruct.live.width'
const editorHiddenKey = 'visustruct.editor.hidden'

/** Wie `VisuStructEditHistory.defaultMaxSteps`. */
const maxUndoSteps = 80
Expand Down Expand Up @@ -223,6 +224,10 @@ export class App {
private shell: HTMLElement
private railButton?: HTMLButtonElement
private liveRailButton?: HTMLButtonElement
private editorRailButton?: HTMLButtonElement
/** Werkzeugleiste über allen Spalten. */
private topbar = h('div', { class: 'topbar' })
private editorHidden = false
private exerciseSaveTimer?: number
private resizeObserver?: ResizeObserver
private renderedHostSize = { width: -1, height: -1 }
Expand Down Expand Up @@ -272,7 +277,19 @@ export class App {
this.render()
},
)
this.shell.append(this.learnRail(), this.learn.element, this.learnResizer(), root, this.liveResizer(), this.live.element, this.liveRail())
// Oben die Werkzeugleiste, darunter drei Spalten: Lernen | Struktogramm | Code live, jede einklappbar.
const columns = h('div', { class: 'columns' })
columns.append(
this.learnRail(),
this.learn.element,
this.learnResizer(),
this.editorRail(),
root,
this.liveResizer(),
this.live.element,
this.liveRail(),
)
this.shell.append(this.topbar, columns)
const learnOpen = storedValue(learnKey)
// Link „Zu den Lektionen“ der Webseite: …/app/?learn. Danach aus der Adresse nehmen,
// sonst öffnet jedes Neuladen den Lernbereich wieder, obwohl man ihn eingeklappt hat.
Expand All @@ -287,6 +304,7 @@ export class App {
const z = Number(storedValue(zoomKey))
if (zoomSteps.some((s) => s.value === z)) this.zoom = z
this.setLiveCoding(storedValue(liveKey) === '1')
this.setEditorHidden(storedValue(editorHiddenKey) === '1')
this.buildUI()
this.render()
window.addEventListener('pointermove', (e) => this.onPointerMove(e))
Expand Down Expand Up @@ -362,7 +380,9 @@ export class App {
</footer>
<input type="file" accept=".visustruct,.strk,.xml" hidden />
`
const $ = <T extends Element>(s: string) => this.root.querySelector(s) as T
// Die Werkzeugleiste steht über allen Spalten, nicht im Editor.
this.topbar.replaceChildren(this.root.querySelector('.toolbar')!)
const $ = <T extends Element>(s: string) => (this.root.querySelector(s) ?? this.topbar.querySelector(s)) as T
this.canvasHost = $('.canvas')
this.inspector = $('.inspector')
this.captionInput = $('.caption')
Expand Down Expand Up @@ -481,16 +501,48 @@ export class App {
this.learn.render()
this.labelLearnRail()
this.labelLiveRail()
this.labelEditorRail()
}

// MARK: - Lernbereich

private setLearning(on: boolean, remember = true) {
this.shell.classList.toggle('learning', on)
if (remember) storeValue(learnKey, on ? '1' : '0')
this.keepAColumnOpen()
if (this.canvasHost) this.renderDiagramOnly()
}

// MARK: - Spalte Struktogramm

/** Struktogramm-Spalte einklappen, z. B. um nur Code live (wie in einer IDE) oder nur Lektionen zu sehen. */
private setEditorHidden(hidden: boolean) {
this.editorHidden = hidden
this.shell.classList.toggle('editor-hidden', hidden)
storeValue(editorHiddenKey, hidden ? '1' : '0')
// Ohne Struktogramm soll der Code zu sehen sein, nicht eine leere Fläche.
if (hidden && !this.liveCoding && !this.shell.classList.contains('learning')) this.setLiveCoding(true)
if (!hidden && this.canvasHost) this.render()
}

/** Mindestens eine Spalte bleibt offen; sonst kommt das Struktogramm zurück. */
private keepAColumnOpen() {
if (this.editorHidden && !this.liveCoding && !this.shell.classList.contains('learning')) this.setEditorHidden(false)
}

private editorRail(): HTMLElement {
this.editorRailButton = h('button', { class: 'learn-rail editor-rail' }) as HTMLButtonElement
this.labelEditorRail()
this.editorRailButton.addEventListener('click', () => this.setEditorHidden(false))
return this.editorRailButton
}

private labelEditorRail() {
if (!this.editorRailButton) return
this.editorRailButton.title = t('web_editor_show')
this.editorRailButton.innerHTML = `${sidebarIcon}<span>✎ ${e(t('web_editor_title'))}</span>`
}

/** Schmale Leiste am Rand, solange der Lernbereich eingeklappt ist. */
private learnRail(): HTMLElement {
this.railButton = h('button', { class: 'learn-rail' }) as HTMLButtonElement
Expand Down Expand Up @@ -523,6 +575,7 @@ export class App {
return {
collapse: () => this.setLearning(false),
openExercise: (ex: Exercise, doc: VSDocument) => {
this.setEditorHidden(false)
const existing = this.tabs.findIndex((tab) => tab.exerciseId === ex.id)
if (existing >= 0) {
this.switchTab(existing)
Expand All @@ -541,6 +594,7 @@ export class App {
this.render()
},
openDiagram: (doc: VSDocument, fileName: string) => {
this.setEditorHidden(false)
// Tab nach der Diagrammüberschrift benennen, nicht nach der Datei (l1-tee)
this.loadXML(encodeDocument(doc), doc.caption.trim() ? `${doc.caption.trim()}.visustruct` : fileName)
},
Expand Down Expand Up @@ -827,6 +881,7 @@ export class App {
this.simButton.title = t(on ? 'web_simulation_end_title' : 'web_simulation_start_title')
if (on) {
this.setCoding(false)
this.setEditorHidden(false)
this.sim.begin()
} else {
this.sim.end()
Expand All @@ -841,7 +896,10 @@ export class App {
private setCoding(on: boolean) {
if (on === this.coding) return
// Beide Code-Spalten nebeneinander wären zu eng.
if (on) this.setLiveCoding(false)
if (on) {
this.setLiveCoding(false)
this.setEditorHidden(false)
}
this.coding = on
this.root.classList.toggle('coding', on)
this.codeButton.setAttribute('aria-pressed', String(on))
Expand All @@ -857,6 +915,7 @@ export class App {
this.liveCoding = on
this.shell.classList.toggle('live', on)
storeValue(liveKey, on ? '1' : '0')
this.keepAColumnOpen()
if (this.canvasHost) this.render()
}

Expand Down Expand Up @@ -1050,7 +1109,10 @@ export class App {
add.title = t('a11y_new_diagram_tab')
add.setAttribute('aria-label', t('a11y_new_diagram_tab'))
add.addEventListener('click', () => this.addTab())
strip.append(add)
const hide = h('button', { class: 'learn-hide editor-hide', title: t('web_editor_hide'), 'aria-label': t('web_editor_hide') })
hide.innerHTML = sidebarIcon
hide.addEventListener('click', () => this.setEditorHidden(true))
strip.append(add, hide)
}

// MARK: - Zwischenablage (Element)
Expand Down
Loading
Loading