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();
 | 
			
		||||
 | 
			
		||||
  await UIExampleFactory.registerExtraColumn();
 | 
			
		||||
 | 
			
		||||
  await UIExampleFactory.registerExtraColumnWithCustomCell();
 | 
			
		||||
 | 
			
		||||
  UIExampleFactory.registerItemPaneSection();
 | 
			
		||||
 | 
			
		||||
  UIExampleFactory.registerReaderItemPaneSection();
 | 
			
		||||
 | 
			
		||||
  await onMainWindowLoad(window);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -67,16 +75,8 @@ async function onMainWindowLoad(win: Window): Promise<void> {
 | 
			
		||||
 | 
			
		||||
  UIExampleFactory.registerWindowMenuWithSeparator();
 | 
			
		||||
 | 
			
		||||
  await UIExampleFactory.registerExtraColumn();
 | 
			
		||||
 | 
			
		||||
  await UIExampleFactory.registerExtraColumnWithCustomCell();
 | 
			
		||||
 | 
			
		||||
  await UIExampleFactory.registerCustomItemBoxRow();
 | 
			
		||||
 | 
			
		||||
  UIExampleFactory.registerLibraryTabPanel();
 | 
			
		||||
 | 
			
		||||
  UIExampleFactory.registerReaderTabPanel();
 | 
			
		||||
 | 
			
		||||
  PromptExampleFactory.registerNormalCommandExample();
 | 
			
		||||
 | 
			
		||||
  PromptExampleFactory.registerAnonymousCommandExample();
 | 
			
		||||
 | 
			
		||||
@ -192,37 +192,28 @@ export class UIExampleFactory {
 | 
			
		||||
 | 
			
		||||
  @example
 | 
			
		||||
  static async registerExtraColumn() {
 | 
			
		||||
    await ztoolkit.ItemTree.register(
 | 
			
		||||
      "test1",
 | 
			
		||||
      "text column",
 | 
			
		||||
      (
 | 
			
		||||
        field: string,
 | 
			
		||||
        unformatted: boolean,
 | 
			
		||||
        includeBaseMapped: boolean,
 | 
			
		||||
        item: Zotero.Item,
 | 
			
		||||
      ) => {
 | 
			
		||||
    const field = "test1";
 | 
			
		||||
    await Zotero.ItemTreeManager.registerColumns({
 | 
			
		||||
      pluginID: config.addonID,
 | 
			
		||||
      dataKey: field,
 | 
			
		||||
      label: "text column",
 | 
			
		||||
      dataProvider: (item: Zotero.Item, dataKey: string) => {
 | 
			
		||||
        return field + String(item.id);
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
      iconPath: "chrome://zotero/skin/cross.png",
 | 
			
		||||
      },
 | 
			
		||||
    );
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @example
 | 
			
		||||
  static async registerExtraColumnWithCustomCell() {
 | 
			
		||||
    await ztoolkit.ItemTree.register(
 | 
			
		||||
      "test2",
 | 
			
		||||
      "custom column",
 | 
			
		||||
      (
 | 
			
		||||
        field: string,
 | 
			
		||||
        unformatted: boolean,
 | 
			
		||||
        includeBaseMapped: boolean,
 | 
			
		||||
        item: Zotero.Item,
 | 
			
		||||
      ) => {
 | 
			
		||||
        return String(item.id);
 | 
			
		||||
    const field = "test2";
 | 
			
		||||
    await Zotero.ItemTreeManager.registerColumns({
 | 
			
		||||
      pluginID: config.addonID,
 | 
			
		||||
      dataKey: field,
 | 
			
		||||
      label: "custom column",
 | 
			
		||||
      dataProvider: (item: Zotero.Item, dataKey: string) => {
 | 
			
		||||
        return field + String(item.id);
 | 
			
		||||
      },
 | 
			
		||||
      {
 | 
			
		||||
      renderCell(index, data, column) {
 | 
			
		||||
        ztoolkit.log("Custom column cell is rendered!");
 | 
			
		||||
        const span = document.createElementNS(
 | 
			
		||||
@ -234,8 +225,7 @@ export class UIExampleFactory {
 | 
			
		||||
        span.innerText = "⭐" + data;
 | 
			
		||||
        return span;
 | 
			
		||||
      },
 | 
			
		||||
      },
 | 
			
		||||
    );
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @example
 | 
			
		||||
@ -279,7 +269,7 @@ export class UIExampleFactory {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @example
 | 
			
		||||
  static registerLibraryTabPanel() {
 | 
			
		||||
  static registerItemPaneSection() {
 | 
			
		||||
    Zotero.ItemPaneManager.registerSection({
 | 
			
		||||
      paneID: "example",
 | 
			
		||||
      pluginID: config.addonID,
 | 
			
		||||
@ -302,7 +292,7 @@ export class UIExampleFactory {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @example
 | 
			
		||||
  static async registerReaderTabPanel() {
 | 
			
		||||
  static async registerReaderItemPaneSection() {
 | 
			
		||||
    Zotero.ItemPaneManager.registerSection({
 | 
			
		||||
      paneID: "reader-example",
 | 
			
		||||
      pluginID: config.addonID,
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user