fix: extra column examples
fix: register example in onStartup
This commit is contained in:
parent
7dc303e189
commit
ff478a7dff
16
src/hooks.ts
16
src/hooks.ts
@ -32,6 +32,14 @@ async function onStartup() {
|
|||||||
|
|
||||||
KeyExampleFactory.registerShortcuts();
|
KeyExampleFactory.registerShortcuts();
|
||||||
|
|
||||||
|
await UIExampleFactory.registerExtraColumn();
|
||||||
|
|
||||||
|
await UIExampleFactory.registerExtraColumnWithCustomCell();
|
||||||
|
|
||||||
|
UIExampleFactory.registerItemPaneSection();
|
||||||
|
|
||||||
|
UIExampleFactory.registerReaderItemPaneSection();
|
||||||
|
|
||||||
await onMainWindowLoad(window);
|
await onMainWindowLoad(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,16 +75,8 @@ async function onMainWindowLoad(win: Window): Promise<void> {
|
|||||||
|
|
||||||
UIExampleFactory.registerWindowMenuWithSeparator();
|
UIExampleFactory.registerWindowMenuWithSeparator();
|
||||||
|
|
||||||
await UIExampleFactory.registerExtraColumn();
|
|
||||||
|
|
||||||
await UIExampleFactory.registerExtraColumnWithCustomCell();
|
|
||||||
|
|
||||||
await UIExampleFactory.registerCustomItemBoxRow();
|
await UIExampleFactory.registerCustomItemBoxRow();
|
||||||
|
|
||||||
UIExampleFactory.registerLibraryTabPanel();
|
|
||||||
|
|
||||||
UIExampleFactory.registerReaderTabPanel();
|
|
||||||
|
|
||||||
PromptExampleFactory.registerNormalCommandExample();
|
PromptExampleFactory.registerNormalCommandExample();
|
||||||
|
|
||||||
PromptExampleFactory.registerAnonymousCommandExample();
|
PromptExampleFactory.registerAnonymousCommandExample();
|
||||||
|
@ -192,50 +192,40 @@ export class UIExampleFactory {
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
static async registerExtraColumn() {
|
static async registerExtraColumn() {
|
||||||
await ztoolkit.ItemTree.register(
|
const field = "test1";
|
||||||
"test1",
|
await Zotero.ItemTreeManager.registerColumns({
|
||||||
"text column",
|
pluginID: config.addonID,
|
||||||
(
|
dataKey: field,
|
||||||
field: string,
|
label: "text column",
|
||||||
unformatted: boolean,
|
dataProvider: (item: Zotero.Item, dataKey: string) => {
|
||||||
includeBaseMapped: boolean,
|
|
||||||
item: Zotero.Item,
|
|
||||||
) => {
|
|
||||||
return field + String(item.id);
|
return field + String(item.id);
|
||||||
},
|
},
|
||||||
{
|
iconPath: "chrome://zotero/skin/cross.png",
|
||||||
iconPath: "chrome://zotero/skin/cross.png",
|
});
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static async registerExtraColumnWithCustomCell() {
|
static async registerExtraColumnWithCustomCell() {
|
||||||
await ztoolkit.ItemTree.register(
|
const field = "test2";
|
||||||
"test2",
|
await Zotero.ItemTreeManager.registerColumns({
|
||||||
"custom column",
|
pluginID: config.addonID,
|
||||||
(
|
dataKey: field,
|
||||||
field: string,
|
label: "custom column",
|
||||||
unformatted: boolean,
|
dataProvider: (item: Zotero.Item, dataKey: string) => {
|
||||||
includeBaseMapped: boolean,
|
return field + String(item.id);
|
||||||
item: Zotero.Item,
|
|
||||||
) => {
|
|
||||||
return String(item.id);
|
|
||||||
},
|
},
|
||||||
{
|
renderCell(index, data, column) {
|
||||||
renderCell(index, data, column) {
|
ztoolkit.log("Custom column cell is rendered!");
|
||||||
ztoolkit.log("Custom column cell is rendered!");
|
const span = document.createElementNS(
|
||||||
const span = document.createElementNS(
|
"http://www.w3.org/1999/xhtml",
|
||||||
"http://www.w3.org/1999/xhtml",
|
"span",
|
||||||
"span",
|
);
|
||||||
);
|
span.className = `cell ${column.className}`;
|
||||||
span.className = `cell ${column.className}`;
|
span.style.background = "#0dd068";
|
||||||
span.style.background = "#0dd068";
|
span.innerText = "⭐" + data;
|
||||||
span.innerText = "⭐" + data;
|
return span;
|
||||||
return span;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
@ -279,7 +269,7 @@ export class UIExampleFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static registerLibraryTabPanel() {
|
static registerItemPaneSection() {
|
||||||
Zotero.ItemPaneManager.registerSection({
|
Zotero.ItemPaneManager.registerSection({
|
||||||
paneID: "example",
|
paneID: "example",
|
||||||
pluginID: config.addonID,
|
pluginID: config.addonID,
|
||||||
@ -302,7 +292,7 @@ export class UIExampleFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@example
|
@example
|
||||||
static async registerReaderTabPanel() {
|
static async registerReaderItemPaneSection() {
|
||||||
Zotero.ItemPaneManager.registerSection({
|
Zotero.ItemPaneManager.registerSection({
|
||||||
paneID: "reader-example",
|
paneID: "reader-example",
|
||||||
pluginID: config.addonID,
|
pluginID: config.addonID,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user