This commit is contained in:
team3
2026-09-22 13:14:06 +02:00
parent a62b587340
commit 2472e89b9c
15 changed files with 461 additions and 28 deletions

View File

@@ -4,7 +4,7 @@ import GObject from 'gi://GObject';
import Pango from 'gi://Pango';
import St from 'gi://St';
import {renderMarkdown} from './markdown.js';
import {continueList, renderMarkdown} from './markdown.js';
import {contextMenu, multilineEntry, Popover, scrollBox, textButton} from './widgets.js';
const AUTOSAVE_SECONDS = 5;
@@ -50,6 +50,7 @@ class NotesPanel extends St.BoxLayout {
[this._editScroll, this._editor] = multilineEntry('', 'note-editor', 'note-editor-scroll');
this._editor.clutter_text.connect('text-changed', () => (this._dirty = true));
this._editor.clutter_text.connect('key-focus-out', () => this._stopEdit());
this._editor.clutter_text.connect('key-press-event', (text, event) => this._onEditorKey(text, event));
right.add_child(this._editScroll);
this.add_child(right);
@@ -102,13 +103,34 @@ class NotesPanel extends St.BoxLayout {
this._rowMenu(type, node);
else
onClick();
}, `tree-row ${type}`, type === 'folder' ? (this._expanded.has(node.path) ? 'folder-open-symbolic' : 'folder-symbolic') : 'text-x-generic-symbolic');
row.set_style(`padding-left: ${8 + depth * 16}px`);
}, `tree-row ${type}`, type === 'folder' ? (this._expanded.has(node.path) ? 'pan-down-symbolic' : 'pan-end-symbolic') : null);
// Notizen ohne Symbol, aber bündig mit dem Ordnernamen (Pfeil 14px + Abstand 6px)
row.set_style(`padding-left: ${8 + depth * 16 + (type === 'note' ? 20 : 0)}px`);
if (this._selected?.path === node.path)
row.add_style_class_name('selected');
this._tree.add_child(row);
}
// Enter in einer Liste setzt den nächsten Punkt, Enter auf einem leeren Punkt beendet die Liste.
_onEditorKey(clutterText, event) {
const symbol = event.get_key_symbol();
if (symbol !== Clutter.KEY_Return && symbol !== Clutter.KEY_KP_Enter)
return Clutter.EVENT_PROPAGATE;
if (event.get_state() & (Clutter.ModifierType.CONTROL_MASK | Clutter.ModifierType.SHIFT_MASK))
return Clutter.EVENT_PROPAGATE;
const text = clutterText.get_text();
const pos = clutterText.cursor_position < 0 ? text.length : clutterText.cursor_position;
const lineStart = text.lastIndexOf('\n', pos - 1) + 1;
const next = continueList(text.slice(lineStart, pos));
if (next === null)
return Clutter.EVENT_PROPAGATE;
if (next === '')
clutterText.delete_text(lineStart, pos);
else
clutterText.insert_text(`\n${next}`, pos);
return Clutter.EVENT_STOP;
}
// Auswahl wechseln. Ein offener Editor wird vorher gespeichert.
_select(selected) {
this._stopEdit();