From 7bc1e99f0720598ff7af74361eb1d9029694ede3 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 5 May 2026 10:22:58 +0200 Subject: feat: add multi-token autocomplete for categories in FrontmatterEditor Mirror the tags autocomplete behaviour for the categories field, loading suggestions from docs/categories.txt via load_categories(). Co-Authored-By: Claude Sonnet 4.6 --- ui/frontmatter_editor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ui/frontmatter_editor.py b/ui/frontmatter_editor.py index add9a41..f1fe0df 100644 --- a/ui/frontmatter_editor.py +++ b/ui/frontmatter_editor.py @@ -8,7 +8,7 @@ from PyQt6.QtCore import Qt from pathlib import Path from core.models import Article, ARTICLE_TYPES from core.frontmatter import parse_frontmatter, write_frontmatter -from core.taxonomy import load_taxonomy +from core.taxonomy import load_taxonomy, load_categories class MultiTokenCompleter(QCompleter): """QCompleter that completes only the last comma-separated token.""" @@ -83,6 +83,12 @@ class FrontmatterEditor(QDialog): widget = QLineEdit(", ".join(str(v) for v in val) if isinstance(val, list) else str(val)) MultiTokenCompleter(known_tags, widget).attach(widget) self._fields[key] = widget + elif key == "categories": + cats_path = self._blog_root / "docs" / "categories.txt" + known_cats = load_categories(cats_path) + widget = QLineEdit(", ".join(str(v) for v in val) if isinstance(val, list) else str(val)) + MultiTokenCompleter(known_cats, widget).attach(widget) + self._fields[key] = widget elif isinstance(val, list): widget = QLineEdit(", ".join(str(v) for v in val)) self._fields[key] = widget -- cgit v1.2.3