Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe the addPluginTab method #5504

Merged
merged 2 commits into from
May 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,21 @@ export class SurveyCreatorModel extends Base

protected plugins: { [name: string]: ICreatorPlugin } = {};

/**
* Adds a custom tab to Survey Creator.
*
* [View Demo](https://surveyjs.io/survey-creator/examples/modify-tab-bar/ (linkStyle))
* @param name A unique tab ID.
* @param plugin An object that allows you to handle user interactions with the tab.
* @param title A tab caption. If `title` is undefined, the `name` argument value is displayed instead. To localize the caption, add its translations to the `ed` object within [localization dictionaries](https://github.com/surveyjs/survey-creator/tree/master/packages/survey-creator-core/src/localization) and pass `ed.propertyName` as the `title` argument.
* @param componentName The name of the component that renders tab markup. Default value: `"svc-tab-" + name`.
* @param index A zero-based index that specifies the tab's position relative to other tabs.
*/
public addPluginTab(
name: string,
plugin: ICreatorPlugin,
title?: string,
componentContent?: string,
componentName?: string,
index?: number
) {
const locStrName = !title ? "ed." + name : (title.indexOf("ed.") == 0 ? title : "");
Expand All @@ -361,7 +371,7 @@ export class SurveyCreatorModel extends Base
id: name,
locTitleName: locStrName,
title: title,
componentContent: componentContent ? componentContent : "svc-tab-" + name,
componentContent: componentName ? componentName : "svc-tab-" + name,
data: plugin,
action: () => { this.makeNewViewActive(name); },
active: this.viewType === name,
Expand Down
Loading