eLabSDK2.Journal.Experiment.Section.ExperimentSection
Hierarchy
-
↳
ExperimentSection↳↳
FileSection↳↳
ImageSection
Methods
addSubMenuItem
Static addSubMenuItem(config, id, targetSectionType?): void
Add a custom menu item to the experiment section hamburger dropdown menu.
This adds a custom action button to the section dropdown menu (hamburger icon) that appears
in the top-right corner of each experiment section. You can target all sections or limit the
menu item to specific section types (e.g., PARAGRAPH, IMAGE, CHEMICAL). The action callback
is executed when the user clicks the menu item. Use this to add section-specific functionality
like custom transformations, exports, validations, or integrations.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
config | ExperimentSectionSubmenuItem | undefined | {id: string, label: string, icon: string, action: () => void} |
id | string | undefined | String reference/identifier for this handler (used for removal with removeSubMenuItem). |
targetSectionType? | any | null | Optional section type to limit this menu item to. Can be 'CANVAS', 'COMMENT', 'IMAGE', 'NOTES', 'FILES', 'OUTPUTSAMPLES', 'BASESAMPLES', 'PARAGRAPH', 'PROCEDURE', 'DATATABLE', 'SAMPLESIN', 'SAMPLESOUT', 'FILE', 'EXCEL', 'MARVINJS', 'CHEMICAL', or 'CUSTOM'. If not specified, appears in all section types. |
Returns
void
Example
// Add menu item to all section types
eLabSDK2.Journal.Experiment.ExperimentSection.addSubMenuItem(
{
id: 'validate-section',
label: 'Validate Section',
action: () => {
console.log('Validating section...');
validateCurrentSection();
},
icon: 'fas fa-check-circle'
},
'validate-handler'
);Example
// Add menu item only to PARAGRAPH sections
eLabSDK2.Journal.Experiment.ExperimentSection.addSubMenuItem(
{
id: 'export-text',
label: 'Export Text',
action: () => {
exportSectionText();
},
icon: 'fas fa-file-export'
},
'export-text-handler',
'PARAGRAPH'
);Example
// Add menu item only to CHEMICAL sections
eLabSDK2.Journal.Experiment.ExperimentSection.addSubMenuItem(
{
id: 'analyze-structure',
label: 'Analyze Structure',
action: () => {
analyzeChemicalStructure();
},
icon: 'fas fa-flask'
},
'analyze-chem-handler',
'CHEMICAL'
);registerAction
Static registerAction(action, targetSectionTypes?): void
Register a custom action on rebuilt experiment sections (e.g. an "Add
file from Box.com" entry contributed by a marketplace add-on).
The host renders each registered action as a toolbar button in the
section header, next to that section's own buttons. onClick is invoked
with { sectionId } so the handler learns which section was clicked
without reading any race-prone shared state. Actions are only shown to
users who may edit the experiment.
Parameters
| Name | Type | Description |
|---|---|---|
action | Action | {id: string, label: string, onClick?: (context: { sectionId: number }) => void, icon?: string, title?: string, isVisible?: (() => boolean) | boolean} |
targetSectionTypes? | ExperimentSectionTypeInput[] | Section types to limit the action to: 'CHEMICAL', 'COMMENT', 'CUSTOM', 'DRAWING', 'EQUIPMENT', 'FILES', 'GENERATED_SAMPLES', 'IMAGES', 'LEGACY_CHEMICAL', 'LEGACY_TABLE', 'MICROSOFT_EXCEL', 'MICROSOFT_POWERPOINT', 'MICROSOFT_WORD', 'PARAGRAPH', 'PROTOCOL_VERSION' or 'USED_SAMPLES'. The legacy spellings used by addSubMenuItem ('IMAGE', 'MARVINJS', 'CANVAS', 'SAMPLESIN', …) are accepted too; note that 'CHEMICAL' means the modern chemical section, so use 'LEGACY_CHEMICAL' for the old one. Omit to show the action on every section type; an empty array shows it on none. |
Returns
void
Example
// Show on every section type
eLabSDK2.Journal.Experiment.ExperimentSection.registerAction({
id: 'send-to-archive',
label: 'Send to archive',
icon: 'fas fa-box-archive',
onClick: (ctx) => sendSectionToArchive(ctx.sectionId),
});Example
// Limit to file and equipment sections
eLabSDK2.Journal.Experiment.ExperimentSection.registerAction(
{
id: 'box-add-file',
label: 'Add file from Box.com',
icon: 'fas fa-plus',
onClick: (ctx) => openBoxPicker(ctx.sectionId),
},
['FILES', 'EQUIPMENT']
);removeSubMenuItem
Static removeSubMenuItem(id): void
Remove a custom menu item from experiment section hamburger dropdown menus.
This unsubscribes and removes a previously added custom menu item from all experiment section
dropdown menus (hamburger icon). Use the same ID that was passed as the second parameter when
adding the menu item with addSubMenuItem(). This is useful for cleaning up menu items when
they're no longer needed, such as when a feature is disabled or an add-on is deactivated.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The reference ID that was passed as the second parameter in the addSubMenuItem() call. |
Returns
void
Example
// Remove a previously added menu item
eLabSDK2.Journal.Experiment.ExperimentSection.removeSubMenuItem('validate-handler');Example
// Add and later remove menu item
// Add menu item
eLabSDK2.Journal.Experiment.ExperimentSection.addSubMenuItem(
{
id: 'temp-action',
label: 'Temporary Action',
action: () => { console.log('action'); },
icon: 'fas fa-clock'
},
'temp-handler',
'PARAGRAPH'
);
// Later, remove it
eLabSDK2.Journal.Experiment.ExperimentSection.removeSubMenuItem('temp-handler');Example
// Conditionally remove menu item
function cleanupSectionMenuItems() {
if (!window.featureEnabled) {
eLabSDK2.Journal.Experiment.ExperimentSection.removeSubMenuItem('feature-handler');
}
}unregisterAction
Static unregisterAction(id): void
Remove a previously-registered section action.
Parameters
| Name | Type | Description |
|---|---|---|
id | string | The id used at registration time. |
Returns
void
Example
eLabSDK2.Journal.Experiment.ExperimentSection.unregisterAction('send-to-archive');© 2026 eLabNext
Updated 7 days ago