Add autocomplete for mentions
This commit is contained in:
@@ -686,9 +686,10 @@ class NWIndex:
|
|||||||
"""Return all tags used by a specific document."""
|
"""Return all tags used by a specific document."""
|
||||||
return self._itemIndex.allItemTags(tHandle) if tHandle else []
|
return self._itemIndex.allItemTags(tHandle) if tHandle else []
|
||||||
|
|
||||||
def getClassTags(self, itemClass: nwItemClass) -> list[str]:
|
def getClassTags(self, itemClass: nwItemClass | None) -> list[str]:
|
||||||
"""Return all tags based on itemClass."""
|
"""Return all tags based on itemClass."""
|
||||||
return self._tagsIndex.filterTagNames(itemClass.name)
|
name = None if itemClass is None else itemClass.name
|
||||||
|
return self._tagsIndex.filterTagNames(name)
|
||||||
|
|
||||||
def getTagsData(
|
def getTagsData(
|
||||||
self, activeOnly: bool = True
|
self, activeOnly: bool = True
|
||||||
@@ -785,11 +786,16 @@ class TagsIndex:
|
|||||||
"""Get the class of a given tag."""
|
"""Get the class of a given tag."""
|
||||||
return self._tags.get(tagKey.lower(), {}).get("class", None)
|
return self._tags.get(tagKey.lower(), {}).get("class", None)
|
||||||
|
|
||||||
def filterTagNames(self, className: str) -> list[str]:
|
def filterTagNames(self, className: str | None) -> list[str]:
|
||||||
"""Get a list of tag names for a given class."""
|
"""Get a list of tag names for a given class."""
|
||||||
return [
|
if className is None:
|
||||||
x.get("name", "") for x in self._tags.values() if x.get("class", "") == className
|
return [
|
||||||
]
|
x.get("name", "") for x in self._tags.values()
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
return [
|
||||||
|
x.get("name", "") for x in self._tags.values() if x.get("class", "") == className
|
||||||
|
]
|
||||||
|
|
||||||
##
|
##
|
||||||
# Pack/Unpack
|
# Pack/Unpack
|
||||||
|
|||||||
@@ -2176,7 +2176,7 @@ class MetaCompleter(QMenu):
|
|||||||
suffix = ""
|
suffix = ""
|
||||||
options = list(filter(
|
options = list(filter(
|
||||||
lambda x: lookup in x.lower(), SHARED.project.index.getClassTags(
|
lambda x: lookup in x.lower(), SHARED.project.index.getClassTags(
|
||||||
nwKeyWords.KEY_CLASS.get(kw.strip(), nwItemClass.NO_CLASS)
|
nwKeyWords.KEY_CLASS.get(kw.strip())
|
||||||
)
|
)
|
||||||
))[:15]
|
))[:15]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user