Preferences reference
src/utils/prefs.ts wraps Zotero.Prefs with the plugin's key prefix and the generated type map. Two preferences do not go through it, for reasons given below.
Prefix
config.prefsPrefix in package.json is extensions.zotero.zoterolinkedmindmaps. Every accessor in this file builds its key as `${PREFS_PREFIX}.${key}`.
addon/prefs.js declares defaults without the prefix; the scaffold adds it at build time. The single line in the source file:
pref("hideMindmapNotes", true);becomes, in .scaffold/build/addon/prefs.js:
pref("extensions.zotero.zoterolinkedmindmaps.hideMindmapNotes", true);PluginPrefsMap
typings/prefs.d.ts is generated by the scaffold from addon/prefs.js and augments _ZoteroTypes.Prefs:
declare namespace _ZoteroTypes {
interface Prefs {
PluginPrefsMap: {
hideMindmapNotes: boolean;
};
}
}One entry, because the map is derived from addon/prefs.js and that file declares one default. getPref and setPref are keyed on this map, so they reach hideMindmapNotes and nothing else. Three other keys are read and written directly through Zotero.Prefs and never appear here; they are listed below.
getPref<K extends keyof PluginPrefsMap>(key: K)
return Zotero.Prefs.get(`${PREFS_PREFIX}.${key}`, true) as PluginPrefsMap[K];Returns PluginPrefsMap[K]. The true marks the key as a plugin preference for Zotero.Prefs.
setPref<K extends keyof PluginPrefsMap>(key: K, value: PluginPrefsMap[K])
return Zotero.Prefs.set(`${PREFS_PREFIX}.${key}`, value, true);Returns whatever Zotero.Prefs.set returns.
clearPref(key: string)
return Zotero.Prefs.clear(`${PREFS_PREFIX}.${key}`, true);Takes a plain string, not keyof PluginPrefsMap, so it can clear a key that is not in the generated map. Clearing restores the default from prefs.js.
hideMindmapNotes
Boolean, default true.
Hides the plugin's container item and its storage notes from the item tree. Read by the wrapped getSearchObject in src/modules/mindmap/libraryFilter.ts on every item-tree query, and watched by a Zotero.Prefs.registerObserver on extensions.zotero.zoterolinkedmindmaps.hideMindmapNotes that redraws open item trees when it changes, so a toggle lands without a restart.
Exposed in the preferences pane as a checkbox with preference="hideMindmapNotes" in addon/content/preferences.xhtml. Its label is set from code rather than through data-l10n-id; see locale-reference.md.
Details in library-filter-reference.md, user-facing description in hide-plugin-data-reference.md.
Preferences outside the typed map
Two keys are read and written through Zotero.Prefs directly rather than through getPref/setPref. Neither appears in addon/prefs.js, so neither is in PluginPrefsMap and neither has a declared default; the reading code supplies the fallback.
linkTypes (JSON blob)
src/modules/mindmap/linkTypes.ts, key extensions.zotero.zoterolinkedmindmaps.linkTypes.
Holds the global link-type vocabulary as a JSON string. The types are shared across all mindmaps, which is why they live in a preference rather than in a mindmap document.
interface LinkType {
id: string;
label: string;
directional: boolean;
}getLinkTypes(): LinkType[] reads the raw value and returns DEFAULT_LINK_TYPES when it is not a string, when JSON.parse throws, when the parsed value is not an array, or when any element fails the LinkType shape check. It does not persist the fallback. A profile that never called setLinkTypes() therefore keeps tracking the defaults rather than being silently forked from a future revision of them.
setLinkTypes(types: LinkType[]): void writes JSON.stringify(types).
getLinkTypeById(id: string): LinkType | undefined looks up strictly by id, never by label, so a renamed type keeps its links. Returns undefined for an unknown id rather than throwing.
DEFAULT_LINK_TYPES is five entries: cites, supports, contradicts and primary-source-for (all directional), and related-to (not directional).
See link-types-reference.md and link-types-explanation.md.
sidebarCollapsed
src/modules/mindmap/mindmapTab.ts, key extensions.zotero.zoterolinkedmindmaps.sidebarCollapsed.
Boolean, read as Zotero.Prefs.get(key, true) === true, so an unset value means expanded. Written when the user toggles the mindmap tab's sidebar, and read at controller construction, which is what makes the collapsed state survive closing and reopening the tab.
legendCollapsed
src/modules/mindmap/graphRenderer.ts, key extensions.zotero.zoterolinkedmindmaps.legendCollapsed.
Boolean, read as Zotero.Prefs.get(key, true) === true, so an unset value means the graph legend is showing. Written when the user toggles the legend from the view toolbar, and read when the graph is built, which is what carries the choice across sessions.
It is deliberately a preference rather than a field on the mindmap document: whether you want the legend on screen is a property of you, not of the mindmap, and writing it into the document would make reading a graph mutate it.
See also
- configuration-reference.md for the
package.jsonconfigblock these keys derive from. - lifecycle-reference.md for where the pref observer is registered and torn down.