Skip to content

Objects

Zotero : object

Typedefs

SectionIcon : Object
SectionL10n : Object
SectionButton : Object
SectionBasicHookArgs : Object
SectionUIHookArgs : Object
SectionHookArgs : Object
SectionInitHookArgs : Object
SectionEventHookArgs : Object
SectionInitHookvoid
SectionBasicHook : function
SectionItemChangeHookboolean
SectionRenderHookvoid
SectionAsyncRenderHookvoid | Promise.<void>
SectionToggleHookvoid
SectionEventHookvoid
SetSectionL10nArgsvoid
SetEnabledvoid
SetSectionSummaryvoid
SetSectionButtonStatusvoid
SectionRefreshPromise.<void>
InfoRowL10n : Object
InfoRowPosition : "start" | "afterCreators" | "end"

Position of the row.

InfoRowGetDataHookArgs : Object
InfoRowSetDataHookArgs : Object
InfoRowItemChangeHookArgs : Object
InfoRowGetDataHookstring
InfoRowSetDataHookvoid
InfoRowItemChangeHookvoid
SetInfoRowEnabledvoid
SetInfoRowEditablevoid

Zotero : object

Kind: global namespace

Zotero.ItemPaneManager

Manages item pane APIs.

Kind: static property of Zotero

ItemPaneManager.registerSection(options) ⇒ string | false

Register a custom item pane section.

Kind: static method of ItemPaneManager
Returns: string | false - - The registered pane ID or false if failed.

ParamTypeDescription
optionsObjectSection options.
options.paneIDstringUnique pane ID.
options.pluginIDstringSet plugin ID to auto-remove section when the plugin is disabled or removed.
options.headerSectionL10n | SectionIconHeader options. Icon should be 16*16 and label need to be localized.
options.sidenavSectionL10n | SectionIconSidenav options. Icon should be 20*20 and tooltiptext need to be localized.
[options.bodyXHTML]stringPane body's innerHTML, defaults to XUL namespace.
[options.onInit]SectionInitHookLifecycle hook called when section is initialized. Do: 1. Initialize data if necessary 2. Set up hooks, e.g. notifier callback Don't: 1. Render/refresh UI
[options.onDestroy]SectionBasicHookLifecycle hook called when section is destroyed. Do: 1. Remove data and release resource 2. Remove hooks, e.g. notifier callback Don't: 1. Render/refresh UI
[options.onItemChange]SectionItemChangeHookLifecycle hook called when the section's target item is changed. Do: 1. Update data (no need to render or refresh); 2. Update the section enabled state with props.setEnabled. Don't: 1. Render/refresh UI
options.onRenderSectionRenderHookLifecycle hook called for initial render. Cannot be async. Create elements and append them to props.body. If the rendering is slow, you should make the bottleneck async and move it to onAsyncRender.
[options.onAsyncRender]SectionAsyncRenderHookLifecycle hook for asynchronous rendering. The best practice to time-consuming rendering with runtime decided section height is: 1. Compute height and create a box in sync onRender; 2. Render actual contents in async onAsyncRender.
[options.onToggle]SectionToggleHookCalled when section is toggled.
[options.sectionButtons]Array.<SectionButton>Section button options.

Example

javascript
Zotero.ItemPaneManager.registerSection({
  paneID: "my-plugin-pane",
  pluginID: "my-plugin@my-namespace.com",
  header: {
    l10nID: "my-plugin-pane-header", // Must inject the corresponding `ftl` file
    icon: "chrome://my-plugin/content/icon16.svg",
  },
  sidenav: {
    l10nID: "my-plugin-pane-sidenav", // Must inject the corresponding `ftl` file
    icon: "chrome://my-plugin/content/icon20.svg",
  },
  onInit: ({ paneID, doc, body }) => {
    // Initialize data
    Zotero.debug("Section initialized");
  },
  onDestroy: ({ paneID, doc, body }) => {
    // Release resource
    Zotero.debug("Section destroyed");
  },
  onItemChange: ({
    paneID,
    doc,
    body,
    item,
    tabType,
    editable,
    setEnabled,
  }) => {
    // In this example, the section is enabled only for regular items
    setEnabled(item.isRegularItem());
  },
  onRender: ({ doc, body, item }) => {
    // Create elements and append them to `body`
    const div = doc.createElement("div");
    div.classList.add("my-plugin-section");
    div.textContent = item.getField("title");
    body.appendChild(div);
  },
  onAsyncRender: async ({ body }) => {
    // Put time-consuming rendering here
    await new Promise((resolve) => setTimeout(resolve, 1000));
    body.querySelector(".my-plugin-section")?.style.setProperty("color", "red");
  },
  onToggle: ({ paneID, doc, body, item, tabType, editable, setEnabled }) => {
    // Handle section toggle
    Zotero.debug("Section toggled");
  },
  sectionButtons: [
    // Section button will appear in the header
  ],
});

ItemPaneManager.unregisterSection(paneID) ⇒ boolean

Unregister a custom item pane section.

Kind: static method of ItemPaneManager
Returns: boolean - - True if the section is successfully unregistered, false if the paneID is not found.

ParamTypeDescription
paneIDstringPane ID to unregister. This is the value returned by registerSection.

ItemPaneManager.registerInfoRow(options) ⇒ string | false

Register a custom item pane info section row.

Kind: static method of ItemPaneManager
Returns: string | false - - The registered row ID or false if failed.

ParamTypeDescription
optionsObjectRow options.
options.rowIDstringUnique row ID.
options.pluginIDstringSet plugin ID to auto-remove row when the plugin is disabled or removed.
options.labelInfoRowL10nLabel options. label need to be localized.
[options.position]InfoRowPositionPosition of the row.
[options.multiline]booleanWhether the row is multiline.
[options.nowrap]booleanWhether the row is nowrap.
[options.editable]booleanWhether the row is editable.
options.onGetDataInfoRowGetDataHookLifecycle hook for getting row data for rendering. This is called when the row is rendered or refreshed.
[options.onSetData]InfoRowSetDataHookLifecycle hook for saving row data changes after editing. Do: 1. Save the new value of the row Don't: 1. Render/refresh UI 2. Change the value in this hook
[options.onItemChange]InfoRowItemChangeHookLifecycle hook for target item changes. Do: 1. Update the row attribute, e.g. enabled, editable Don't: 1. Render/refresh UI

Example

javascript
Zotero.ItemPaneManager.registerInfoRow({
  rowID: "my-plugin-row",
  pluginID: "my-plugin@my-namespace.com",
  label: {
    l10nID: "my-plugin-row-label", // Must inject the corresponding `ftl` file
  },
  position: "afterCreators",
  multiline: true,
  nowrap: false,
  editable: true,
  onGetData: ({ rowID, item, tabType, editable }) => {
    return item.getField("title").toUpperCase();
  },
  onSetData: ({ rowID, item, tabType, editable, value }) => {
    Zotero.debug("Info row data changed:", value);
  },
  onItemChange: ({
    rowID,
    item,
    tabType,
    editable,
    setEnabled,
    setEditable,
  }) => {
    // In this example, the row is enabled only for library tab
    setEnabled(tabType === "library");
  },
});

ItemPaneManager.unregisterInfoRow(rowID) ⇒ boolean

Unregister a custom item pane info section row.

Kind: static method of ItemPaneManager
Returns: boolean - - True if the row is successfully unregistered, false if the rowID is not found.

ParamTypeDescription
rowIDstringRow ID to unregister. This is the value returned by registerInfoRow.

ItemPaneManager.refreshInfoRow(rowID) ⇒ void

Refresh a custom item pane info section row.

Kind: static method of ItemPaneManager

ParamTypeDescription
rowIDstringRow ID to refresh. This is the value returned by registerInfoRow.

SectionIcon : Object

Kind: global typedef
Properties

NameTypeDescription
iconstringIcon URI.
[darkIcon]stringIcon URI in dark mode. If not set, use icon.

SectionL10n : Object

Kind: global typedef
Properties

NameTypeDescription
l10nIDstringdata-l10n-id for localization of section header label.
[l10nArgs]stringdata-l10n-args for localization.

SectionButton : Object

Kind: global typedef
Properties

NameTypeDescription
typestringButton type, must be valid DOMString and without ",".
iconstringIcon URI.
[darkIcon]stringIcon URI in dark mode. If not set, use icon.
[l10nID]stringdata-l10n-id for localization of button tooltiptext.
onClickSectionEventHookButton click callback.

SectionBasicHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
paneIDstringRegistered pane id.
docDocumentDocument of section.
bodyHTMLDivElementSection body.

SectionUIHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
itemZotero.ItemCurrent item.
tabTypestringCurrent tab type.
editablebooleanWhether the section is in edit mode.
setL10nArgsSetSectionL10nArgsSet l10n args for section header.
setEnabledSetEnabledSet pane enabled state.
setSectionSummarySetSectionSummarySet pane section summary, shown in collapsed header.
setSectionButtonStatusSetSectionButtonStatusSet pane section button status.

SectionHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
paneIDstringRegistered pane id.
docDocumentDocument of section.
bodyHTMLDivElementSection body.
itemZotero.ItemCurrent item.
tabTypestringCurrent tab type.
editablebooleanWhether the section is in edit mode.
setL10nArgsSetSectionL10nArgsSet l10n args for section header.
setEnabledSetEnabledSet pane enabled state.
setSectionSummarySetSectionSummarySet pane section summary, shown in collapsed header.
setSectionButtonStatusSetSectionButtonStatusSet pane section button status.

SectionInitHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
paneIDstringRegistered pane id.
docDocumentDocument of section.
bodyHTMLDivElementSection body.
itemZotero.ItemCurrent item.
tabTypestringCurrent tab type.
editablebooleanWhether the section is in edit mode.
setL10nArgsSetSectionL10nArgsSet l10n args for section header.
setEnabledSetEnabledSet pane enabled state.
setSectionSummarySetSectionSummarySet pane section summary, shown in collapsed header.
setSectionButtonStatusSetSectionButtonStatusSet pane section button status.
refreshSectionRefreshRefresh the section. A refresh is exposed to plugins to allows plugins to refresh the section when necessary, e.g. item modify notifier callback. Note that calling refresh during initialization have no effect.

SectionEventHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
paneIDstringRegistered pane id.
docDocumentDocument of section.
bodyHTMLDivElementSection body.
itemZotero.ItemCurrent item.
tabTypestringCurrent tab type.
editablebooleanWhether the section is in edit mode.
setL10nArgsSetSectionL10nArgsSet l10n args for section header.
setEnabledSetEnabledSet pane enabled state.
setSectionSummarySetSectionSummarySet pane section summary, shown in collapsed header.
setSectionButtonStatusSetSectionButtonStatusSet pane section button status.
eventEventEvent object.

SectionInitHook ⇒ void

Kind: global typedef

ParamTypeDescription
propsSectionInitHookArgsProps provided during section initialization.

SectionBasicHook : function

Kind: global typedef

ParamTypeDescription
propsSectionBasicHookArgsBasic hook arguments.

SectionItemChangeHook ⇒ boolean

Kind: global typedef

ParamTypeDescription
propsSectionHookArgsHook arguments for item changes.

SectionRenderHook ⇒ void

Kind: global typedef

ParamTypeDescription
propsSectionHookArgsHook arguments for rendering.

SectionAsyncRenderHook ⇒ void | Promise.<void>

Kind: global typedef

ParamTypeDescription
propsSectionHookArgsHook arguments for asynchronous rendering.

SectionToggleHook ⇒ void

Kind: global typedef

ParamTypeDescription
propsSectionEventHookArgsEvent hook arguments.

SectionEventHook ⇒ void

Kind: global typedef

ParamTypeDescription
propsSectionEventHookArgsEvent hook arguments.

SetSectionL10nArgs ⇒ void

Kind: global typedef

ParamTypeDescription
l10nArgsstringLocalization arguments.

SetEnabled ⇒ void

Kind: global typedef

ParamTypeDescription
enabledbooleanEnabled state.

SetSectionSummary ⇒ void

Kind: global typedef

ParamTypeDescription
summarystringThe summary for the section header.

SetSectionButtonStatus ⇒ void

Kind: global typedef

ParamTypeDescription
buttonTypestringThe button type.
optionsObjectOptions for the button status.
[options.disabled]booleanWhether the button is disabled.
[options.hidden]booleanWhether the button is hidden.

SectionRefresh ⇒ Promise.<void>

Kind: global typedef

InfoRowL10n : Object

Kind: global typedef
Properties

NameTypeDescription
l10nIDstringdata-l10n-id for localization of row label.

InfoRowPosition : "start" | "afterCreators" | "end"

Position of the row.

Kind: global typedef

InfoRowGetDataHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
rowIDstringRow ID.
itemZotero.ItemCurrent item.
tabTypestringCurrent tab type.
editablebooleanWhether the row is in edit mode.

InfoRowSetDataHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
rowIDstringRow ID.
itemZotero.ItemCurrent item.
tabTypestringCurrent tab type.
editablestringWhether the row is in edit mode.
valuestringNew value.

InfoRowItemChangeHookArgs : Object

Kind: global typedef
Properties

NameTypeDescription
rowIDstringRow ID.
itemZotero.ItemCurrent item.
tabTypestringCurrent tab type.
editablebooleanWhether the row is in edit mode.
setEnabledSetInfoRowEnabledSet row enabled state.
setEditableSetInfoRowEditableSet row editable state.

InfoRowGetDataHook ⇒ string

Kind: global typedef
Returns: string - - Row data.

ParamTypeDescription
propsInfoRowGetDataHookArgsHook arguments for getting data.

InfoRowSetDataHook ⇒ void

Kind: global typedef

ParamTypeDescription
propsInfoRowSetDataHookArgsHook arguments for setting data.

InfoRowItemChangeHook ⇒ void

Kind: global typedef

ParamTypeDescription
propsInfoRowItemChangeHookArgsHook arguments for item changes.

SetInfoRowEnabled ⇒ void

Kind: global typedef

ParamTypeDescription
enabledbooleanEnabled state.

SetInfoRowEditable ⇒ void

Kind: global typedef

ParamTypeDescription
editablebooleanEditable state.