chore: update prefs window
add: links in prefs window fix: prefs window search shows all sections
This commit is contained in:
parent
2d5b78f648
commit
7a6f3f9f5e
|
|
@ -1,111 +1,127 @@
|
|||
<linkset>
|
||||
<html:link rel="localization" href="__addonRef__-preferences.ftl" />
|
||||
</linkset>
|
||||
<vbox
|
||||
id="zotero-prefpane-__addonRef__"
|
||||
onload="Zotero.__addonInstance__.hooks.onPrefsEvent('load', {window})"
|
||||
>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="basic-title"></html:h2></label>
|
||||
<checkbox
|
||||
data-l10n-id="basic-openNote-takeover"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.openNote.takeover"
|
||||
/>
|
||||
<checkbox
|
||||
data-l10n-id="basic-openNote-defaultAsWindow"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.openNote.defaultAsWindow"
|
||||
/>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="editor-title"></html:h2></label>
|
||||
<hbox align="center">
|
||||
<html:label
|
||||
for="__addonRef__-editor-expandLevel"
|
||||
data-l10n-id="editor-expandLevel-label"
|
||||
></html:label>
|
||||
<html:input
|
||||
type="number"
|
||||
min="1"
|
||||
max="6"
|
||||
step="1"
|
||||
id="__addonRef__-editor-expandLevel"
|
||||
preference="__prefsPrefix__.workspace.outline.expandLevel"
|
||||
></html:input>
|
||||
</hbox>
|
||||
<checkbox
|
||||
data-l10n-id="editor-keepLinks"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.workspace.outline.keepLinks"
|
||||
/>
|
||||
<checkbox
|
||||
data-l10n-id="editor-noteLinkPreview"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.editor.noteLinkPreview"
|
||||
/>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="sync-title"></html:h2></label>
|
||||
<hbox align="center">
|
||||
<html:label
|
||||
for="__addonRef__-sync-period"
|
||||
data-l10n-id="sync-period-label"
|
||||
></html:label>
|
||||
<html:input
|
||||
type="number"
|
||||
min="-1"
|
||||
max="3600"
|
||||
step="1"
|
||||
placeholder="-1 for disable"
|
||||
id="__addonRef__-sync-period"
|
||||
preference="__prefsPrefix__.syncPeriodSeconds"
|
||||
></html:input>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<html:label
|
||||
for="__addonRef__-sync-attachmentFolder"
|
||||
data-l10n-id="sync-attachmentFolder-label"
|
||||
></html:label>
|
||||
<html:input
|
||||
id="__addonRef__-sync-attachmentFolder"
|
||||
preference="__prefsPrefix__.syncAttachmentFolder"
|
||||
></html:input>
|
||||
</hbox>
|
||||
<checkbox
|
||||
data-l10n-id="sync-updateTags"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.sync.updateTags"
|
||||
/>
|
||||
<hbox align="center">
|
||||
<button
|
||||
onclick="Zotero.__addonInstance__.hooks.onShowSyncManager()"
|
||||
data-l10n-id="sync-manager"
|
||||
></button>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="template-title"></html:h2></label>
|
||||
<hbox align="center">
|
||||
<button
|
||||
onclick="Zotero.__addonInstance__.hooks.onShowTemplateEditor()"
|
||||
data-l10n-id="template-editor"
|
||||
></button>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="annotation-title"></html:h2></label>
|
||||
<!-- <checkbox
|
||||
id="__addonRef__-enableAddToNote"
|
||||
data-l10n-id="annotation-autoAnnotation"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.autoAnnotation"
|
||||
/> -->
|
||||
</groupbox>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<script>
|
||||
Zotero.__addonInstance__.hooks.onPrefsEvent("load", { window });
|
||||
</script>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="basic-title"></html:h2></label>
|
||||
<checkbox
|
||||
data-l10n-id="basic-openNote-takeover"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.openNote.takeover"
|
||||
/>
|
||||
<checkbox
|
||||
data-l10n-id="basic-openNote-defaultAsWindow"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.openNote.defaultAsWindow"
|
||||
/>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="editor-title"></html:h2></label>
|
||||
<hbox align="center">
|
||||
<html:label
|
||||
for="__addonRef__-editor-expandLevel"
|
||||
data-l10n-id="editor-expandLevel-label"
|
||||
></html:label>
|
||||
<html:input
|
||||
type="number"
|
||||
min="1"
|
||||
max="6"
|
||||
step="1"
|
||||
id="__addonRef__-editor-expandLevel"
|
||||
preference="__prefsPrefix__.workspace.outline.expandLevel"
|
||||
></html:input>
|
||||
</hbox>
|
||||
<checkbox
|
||||
data-l10n-id="editor-keepLinks"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.workspace.outline.keepLinks"
|
||||
/>
|
||||
<checkbox
|
||||
data-l10n-id="editor-noteLinkPreview"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.editor.noteLinkPreview"
|
||||
/>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="sync-title"></html:h2></label>
|
||||
<hbox align="center">
|
||||
<html:label
|
||||
for="__addonRef__-sync-period"
|
||||
data-l10n-id="sync-period-label"
|
||||
></html:label>
|
||||
<html:input
|
||||
type="number"
|
||||
min="-1"
|
||||
max="3600"
|
||||
step="1"
|
||||
placeholder="-1 for disable"
|
||||
id="__addonRef__-sync-period"
|
||||
preference="__prefsPrefix__.syncPeriodSeconds"
|
||||
></html:input>
|
||||
</hbox>
|
||||
<hbox align="center">
|
||||
<html:label
|
||||
for="__addonRef__-sync-attachmentFolder"
|
||||
data-l10n-id="sync-attachmentFolder-label"
|
||||
></html:label>
|
||||
<html:input
|
||||
id="__addonRef__-sync-attachmentFolder"
|
||||
preference="__prefsPrefix__.syncAttachmentFolder"
|
||||
></html:input>
|
||||
</hbox>
|
||||
<checkbox
|
||||
data-l10n-id="sync-updateTags"
|
||||
native="true"
|
||||
preference="__prefsPrefix__.sync.updateTags"
|
||||
/>
|
||||
<hbox align="center">
|
||||
<button
|
||||
onclick="Zotero.__addonInstance__.hooks.onShowSyncManager()"
|
||||
data-l10n-id="sync-manager"
|
||||
></button>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="template-title"></html:h2></label>
|
||||
<hbox align="center">
|
||||
<button
|
||||
onclick="Zotero.__addonInstance__.hooks.onShowTemplateEditor()"
|
||||
data-l10n-id="template-editor"
|
||||
></button>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
<groupbox>
|
||||
<label><html:h2 data-l10n-id="about-title"></html:h2></label>
|
||||
|
||||
<hbox>
|
||||
<label
|
||||
class="zotero-text-link keyboard-clickable"
|
||||
is="zotero-text-link"
|
||||
role="link"
|
||||
href="https://github.com/windingwind/zotero-better-notes"
|
||||
value="Homepage - GitHub"
|
||||
></label>
|
||||
<label value="|"></label>
|
||||
<label
|
||||
class="zotero-text-link keyboard-clickable"
|
||||
is="zotero-text-link"
|
||||
role="link"
|
||||
href="https://github.com/windingwind/zotero-better-notes/issues"
|
||||
value="Bug Report, Feature Request"
|
||||
></label>
|
||||
<label value="|"></label>
|
||||
<label
|
||||
class="zotero-text-link keyboard-clickable"
|
||||
is="zotero-text-link"
|
||||
role="link"
|
||||
href="https://github.com/windingwind/zotero-better-notes/discussions/categories/q-a"
|
||||
value="Q&A"
|
||||
></label>
|
||||
</hbox>
|
||||
<label
|
||||
data-l10n-id="help"
|
||||
data-l10n-args='{"time": "__buildTime__","name": "__addonName__","version":"__buildVersion__"}'
|
||||
></label>
|
||||
</vbox>
|
||||
</groupbox>
|
||||
|
|
|
|||
|
|
@ -26,5 +26,7 @@ template-editor =
|
|||
annotation-title = PDF Annotation
|
||||
annotation-autoAnnotation =
|
||||
.label = Automatically add new annotations to workspace note
|
||||
|
||||
about-title = About
|
||||
help =
|
||||
.value = { $name } VERSION { $version } Build { $time }
|
||||
|
|
@ -26,5 +26,7 @@ template-editor =
|
|||
annotation-title = Annotazione PDF
|
||||
annotation-autoAnnotation =
|
||||
.label = Aggiungi automaticamente le nuove annotazioni alla nota di lavoro
|
||||
|
||||
about-title = About
|
||||
help =
|
||||
.value = { $name } VERSION { $version } Build { $time }
|
||||
|
|
|
|||
|
|
@ -26,5 +26,7 @@ template-editor =
|
|||
annotation-title = PDF Аннотация
|
||||
annotation-autoAnnotation =
|
||||
.label = Автодобавлять новые аннотации к заметкам раб.пространства
|
||||
|
||||
about-title = About
|
||||
help =
|
||||
.value = { $name } VERSION { $version } Build { $time }
|
||||
|
|
@ -26,5 +26,7 @@ template-editor =
|
|||
annotation-title = PDF Dipnotları
|
||||
annotation-autoAnnotation =
|
||||
.label = Çalışma alanı notuna otomatik olarak yeni dipnotlar ekle
|
||||
|
||||
about-title = About
|
||||
help =
|
||||
.value = { $name } Versiyon { $version } İnşa { $time }
|
||||
|
|
@ -26,5 +26,7 @@ template-editor =
|
|||
annotation-title = PDF批注
|
||||
annotation-autoAnnotation =
|
||||
.label = 自动添加新批注到工作区笔记
|
||||
|
||||
about-title = 关于
|
||||
help =
|
||||
.value = { $name } 版本 { $version } 构建 { $time }
|
||||
|
|
@ -25,8 +25,6 @@ class Addon {
|
|||
};
|
||||
prefs?: {
|
||||
window: Window;
|
||||
columns: Array<ColumnOptions>;
|
||||
rows: Array<{ [dataKey: string]: string }>;
|
||||
};
|
||||
export: {
|
||||
pdf: { promise?: _ZoteroTypes.PromiseObject };
|
||||
|
|
|
|||
|
|
@ -16,131 +16,8 @@ export function registerPrefsScripts(_window: Window) {
|
|||
if (!addon.data.prefs) {
|
||||
addon.data.prefs = {
|
||||
window: _window,
|
||||
columns: [
|
||||
{
|
||||
dataKey: "title",
|
||||
label: "prefs.table.title",
|
||||
fixedWidth: true,
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
dataKey: "detail",
|
||||
label: "prefs.table.detail",
|
||||
},
|
||||
],
|
||||
rows: [
|
||||
{
|
||||
title: "Orange",
|
||||
detail: "It's juicy",
|
||||
},
|
||||
{
|
||||
title: "Banana",
|
||||
detail: "It's sweet",
|
||||
},
|
||||
{
|
||||
title: "Apple",
|
||||
detail: "I mean the fruit APPLE",
|
||||
},
|
||||
],
|
||||
};
|
||||
} else {
|
||||
addon.data.prefs.window = _window;
|
||||
}
|
||||
updatePrefsUI();
|
||||
bindPrefEvents();
|
||||
}
|
||||
|
||||
async function updatePrefsUI() {
|
||||
// You can initialize some UI elements on prefs window
|
||||
// with addon.data.prefs.window.document
|
||||
// Or bind some events to the elements
|
||||
if (!addon.data.prefs?.window) {
|
||||
return;
|
||||
}
|
||||
const renderLock = ztoolkit.getGlobal("Zotero").Promise.defer();
|
||||
const tableHelper = new ztoolkit.VirtualizedTable(addon.data.prefs.window)
|
||||
.setContainerId(`${config.addonRef}-table-container`)
|
||||
.setProp({
|
||||
id: `${config.addonRef}-prefs-table`,
|
||||
// Do not use setLocale, as it modifies the Zotero.Intl.strings
|
||||
// Set locales directly to columns
|
||||
columns: addon.data.prefs?.columns.map((column) =>
|
||||
Object.assign(column, {
|
||||
label: getString(column.label) || column.label,
|
||||
}),
|
||||
),
|
||||
showHeader: true,
|
||||
multiSelect: true,
|
||||
staticColumns: true,
|
||||
disableFontSizeScaling: true,
|
||||
})
|
||||
.setProp("getRowCount", () => addon.data.prefs?.rows.length || 0)
|
||||
.setProp(
|
||||
"getRowData",
|
||||
(index) =>
|
||||
addon.data.prefs?.rows[index] || {
|
||||
title: "no data",
|
||||
detail: "no data",
|
||||
},
|
||||
)
|
||||
// Show a progress window when selection changes
|
||||
.setProp("onSelectionChange", (selection) => {
|
||||
new ztoolkit.ProgressWindow(config.addonName)
|
||||
.createLine({
|
||||
text: `Selected line: ${addon.data.prefs?.rows
|
||||
.filter((v, i) => selection.isSelected(i))
|
||||
.map((row) => row.title)
|
||||
.join(",")}`,
|
||||
progress: 100,
|
||||
})
|
||||
.show();
|
||||
})
|
||||
// When pressing delete, delete selected line and refresh table.
|
||||
// Returning false to prevent default event.
|
||||
.setProp("onKeyDown", (event: KeyboardEvent) => {
|
||||
if (event.key == "Delete" || (Zotero.isMac && event.key == "Backspace")) {
|
||||
addon.data.prefs!.rows =
|
||||
addon.data.prefs?.rows.filter(
|
||||
(v, i) => !tableHelper.treeInstance.selection.isSelected(i),
|
||||
) || [];
|
||||
tableHelper.render();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
})
|
||||
// For find-as-you-type
|
||||
.setProp(
|
||||
"getRowString",
|
||||
(index) => addon.data.prefs?.rows[index].title || "",
|
||||
)
|
||||
// Render the table.
|
||||
.render(-1, () => {
|
||||
renderLock.resolve();
|
||||
});
|
||||
await renderLock.promise;
|
||||
ztoolkit.log("Preference table rendered!");
|
||||
}
|
||||
|
||||
function bindPrefEvents() {
|
||||
addon.data
|
||||
.prefs!.window.document.querySelector(
|
||||
`#zotero-prefpane-${config.addonRef}-enable`,
|
||||
)
|
||||
?.addEventListener("command", (e) => {
|
||||
ztoolkit.log(e);
|
||||
addon.data.prefs!.window.alert(
|
||||
`Successfully changed to ${(e.target as XUL.Checkbox).checked}!`,
|
||||
);
|
||||
});
|
||||
|
||||
addon.data
|
||||
.prefs!.window.document.querySelector(
|
||||
`#zotero-prefpane-${config.addonRef}-input`,
|
||||
)
|
||||
?.addEventListener("change", (e) => {
|
||||
ztoolkit.log(e);
|
||||
addon.data.prefs!.window.alert(
|
||||
`Successfully changed to ${(e.target as HTMLInputElement).value}!`,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ export async function showSyncManager() {
|
|||
})
|
||||
.setProp(
|
||||
"getRowString",
|
||||
(index) => addon.data.prefs?.rows[index].title || "",
|
||||
(index) => addon.data.sync.manager?.data[index].noteName || "",
|
||||
)
|
||||
.setProp("onColumnSort", (columnIndex, ascending) => {
|
||||
addon.data.sync.manager.columnIndex = columnIndex;
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ export async function showTemplateEditor() {
|
|||
})
|
||||
.setProp(
|
||||
"getRowString",
|
||||
(index) => addon.data.prefs?.rows[index].title || "",
|
||||
(index) => addon.data.template.editor.templates[index] || "",
|
||||
)
|
||||
.render();
|
||||
_window.document
|
||||
|
|
|
|||
Loading…
Reference in New Issue