add: itemBox examples
This commit is contained in:
parent
47fdd995d5
commit
080736cd0f
@ -76,6 +76,7 @@ Search `@example` in `src/examples.ts`. The examples are called in `src/hooks.ts
|
|||||||
- registerWindowMenuWithSeprator
|
- registerWindowMenuWithSeprator
|
||||||
- registerExtraColumn
|
- registerExtraColumn
|
||||||
- registerExtraColumnWithCustomCell
|
- registerExtraColumnWithCustomCell
|
||||||
|
- registerCustomItemBoxRow
|
||||||
- registerCustomCellRenderer
|
- registerCustomCellRenderer
|
||||||
- registerLibraryTabPanel
|
- registerLibraryTabPanel
|
||||||
- registerReaderTabPanel
|
- registerReaderTabPanel
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/windingwind/zotero-addon-template#readme",
|
"homepage": "https://github.com/windingwind/zotero-addon-template#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"zotero-plugin-toolkit": "^2.0.0"
|
"zotero-plugin-toolkit": "^2.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^18.11.17",
|
"@types/node": "^18.11.17",
|
||||||
|
@ -50,7 +50,7 @@ async function onStartup() {
|
|||||||
|
|
||||||
UIExampleFactory.registerRightClickMenuPopup();
|
UIExampleFactory.registerRightClickMenuPopup();
|
||||||
|
|
||||||
UIExampleFactory.registerWindowMenuWithSeprator();
|
UIExampleFactory.registerWindowMenuWithSeparator();
|
||||||
|
|
||||||
await UIExampleFactory.registerExtraColumn();
|
await UIExampleFactory.registerExtraColumn();
|
||||||
|
|
||||||
@ -58,6 +58,8 @@ async function onStartup() {
|
|||||||
|
|
||||||
await UIExampleFactory.registerCustomCellRenderer();
|
await UIExampleFactory.registerCustomCellRenderer();
|
||||||
|
|
||||||
|
await UIExampleFactory.registerCustomItemBoxRow();
|
||||||
|
|
||||||
UIExampleFactory.registerLibraryTabPanel();
|
UIExampleFactory.registerLibraryTabPanel();
|
||||||
|
|
||||||
await UIExampleFactory.registerReaderTabPanel();
|
await UIExampleFactory.registerReaderTabPanel();
|
||||||
|
@ -233,7 +233,7 @@ export class UIExampleFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static registerWindowMenuWithSeprator() {
|
static registerWindowMenuWithSeparator() {
|
||||||
ztoolkit.Menu.register("menuFile", {
|
ztoolkit.Menu.register("menuFile", {
|
||||||
tag: "menuseparator",
|
tag: "menuseparator",
|
||||||
});
|
});
|
||||||
@ -302,11 +302,49 @@ export class UIExampleFactory {
|
|||||||
return span;
|
return span;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
// @ts-ignore
|
|
||||||
// This is a private method. Make it public in toolkit.
|
|
||||||
await ztoolkit.ItemTree.refresh();
|
await ztoolkit.ItemTree.refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@example
|
||||||
|
static async registerCustomItemBoxRow() {
|
||||||
|
await ztoolkit.ItemBox.register(
|
||||||
|
"itemBoxFieldEditable",
|
||||||
|
"Editable Custom Field",
|
||||||
|
(field, unformatted, includeBaseMapped, item, original) => {
|
||||||
|
return (
|
||||||
|
ztoolkit.ExtraField.getExtraField(item, "itemBoxFieldEditable") || ""
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
editable: true,
|
||||||
|
setFieldHook: (field, value, loadIn, item, original) => {
|
||||||
|
window.alert("Custom itemBox value is changed and saved to extra!");
|
||||||
|
ztoolkit.ExtraField.setExtraField(
|
||||||
|
item,
|
||||||
|
"itemBoxFieldEditable",
|
||||||
|
value
|
||||||
|
);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
index: 1,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
await ztoolkit.ItemBox.register(
|
||||||
|
"itemBoxFieldNonEditable",
|
||||||
|
"Non-Editable Custom Field",
|
||||||
|
(field, unformatted, includeBaseMapped, item, original) => {
|
||||||
|
return (
|
||||||
|
"[CANNOT EDIT THIS]" + (item.getField("title") as string).slice(0, 10)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{
|
||||||
|
editable: false,
|
||||||
|
index: 2,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static registerLibraryTabPanel() {
|
static registerLibraryTabPanel() {
|
||||||
const tabId = ztoolkit.LibraryTabPanel.register(
|
const tabId = ztoolkit.LibraryTabPanel.register(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user