diff options
| author | Danilo M. <danix@danix.xyz> | 2026-05-05 10:22:58 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-05-05 10:22:58 +0200 |
| commit | 7bc1e99f0720598ff7af74361eb1d9029694ede3 (patch) | |
| tree | 59f6d7006946c1147a0f60446202c35d5113a8a9 | |
| parent | 0b192692a3108ca9def1f462aa5bb2489fa87690 (diff) | |
| download | publisher-1.4.tar.gz publisher-1.4.zip | |
feat: add multi-token autocomplete for categories in FrontmatterEditorv1.4
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 <noreply@anthropic.com>
| -rw-r--r-- | ui/frontmatter_editor.py | 8 |
1 files changed, 7 insertions, 1 deletions
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 |
