Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…js.io - Wrong icon version - Refactored API
  • Loading branch information
tsv2013 committed Feb 12, 2025
1 parent 29f798d commit 782cca6
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class TabDesignerPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("designer", this, undefined, "icon-config");
creator.addPluginTab({ name: "designer", plugin: this, iconName: "icon-config" });
this.tabControlModel = new TabControlModel(this.creator.sidebar);
this.propertyGrid = new PropertyGridModel(undefined, creator, creator.getPropertyGridDefinition());
this.showOneCategoryInPropertyGrid = creator.showOneCategoryInPropertyGrid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export class TabJsonEditorAcePlugin
implements ICreatorPlugin {
constructor(creator: SurveyCreatorModel) {
super(creator);
creator.addPluginTab("json", this, undefined, "icon-codeeditor-24x24", "svc-tab-json-editor-ace");
creator.addPluginTab({ name: "json", plugin: this, iconName: "icon-codeeditor-24x24", componentName: "svc-tab-json-editor-ace" });
}
protected createModel(
creator: SurveyCreatorModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TabJsonEditorTextareaPlugin
implements ICreatorPlugin {
constructor(creator: SurveyCreatorModel) {
super(creator);
creator.addPluginTab("json", this, undefined, "icon-codeeditor-24x24", "svc-tab-json-editor-textarea");
creator.addPluginTab({ name: "json", plugin: this, iconName: "icon-codeeditor-24x24", componentName: "svc-tab-json-editor-textarea" });
}
protected createModel(
creator: SurveyCreatorModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class TabLogicPlugin implements ICreatorPlugin {
private fastEntryAction: Action;
public model: SurveyLogicUI;
constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("logic", this, undefined, "icon-logic-24x24");
creator.addPluginTab({ name: "logic", plugin: this, iconName: "icon-logic-24x24" });
this.createActions().forEach(action => creator.toolbar.actions.push(action));
}
public activate(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class TabTestPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("preview", this, undefined, "icon-preview");
creator.addPluginTab({ name: "preview", plugin: this, iconName: "icon-preview" });
this.setPreviewTheme(this.creator.previewTheme);
this.createActions().forEach(action => creator.toolbar.actions.push(action));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class ThemeTabPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("theme", this, undefined, "icon-theme");
creator.addPluginTab({ name: "theme", plugin: this, iconName: "icon-theme" });
this.simulatorCssClasses = surveyCss[defaultThemeName];
this.tabControlModel = new TabControlModel(this.creator.sidebar);
this.createActions().forEach(action => creator.toolbar.actions.push(action));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class TabTranslationPlugin implements ICreatorPlugin {
}

constructor(private creator: SurveyCreatorModel) {
creator.addPluginTab("translation", this, undefined, "icon-language");
creator.addPluginTab({ name: "translation", plugin: this, iconName: "icon-language" });
this.showOneCategoryInPropertyGrid = creator.showOneCategoryInPropertyGrid;
this.tabControlModel = new TabControlModel(this.creator.sidebar);
this.sidebarTab = this.creator.sidebar.addPage("translation");
Expand Down
28 changes: 24 additions & 4 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,18 +467,38 @@ export class SurveyCreatorModel extends Base
* @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/90de47d2c9da49b06a7f97414026d70f7acf05c6/packages/survey-creator-core/src/localization) and pass `ed.propertyName` as the `title` argument.
* @param iconName A tab icon. If `iconName` is undefined, the default icon is displayed.
* @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,
nameOrParams: string | {
name: string,
plugin: ICreatorPlugin,
title?: string,
iconName?: string,
componentName?: string,
index?: number
},
plugin?: ICreatorPlugin,
title?: string,
iconName?: string,
componentName?: string,
index?: number
) {
let name = nameOrParams as string;
let iconName: string = undefined;
if (typeof nameOrParams === "object") {
({
name,
plugin,
title,
iconName,
componentName,
index
} = nameOrParams);
}
if (!name || !plugin) {
throw new Error("Plugin or name is not set");
}
this.tabbedMenu.addTab(name, plugin, title, iconName, componentName, index);
this.addPlugin(name, plugin);
}
Expand Down

0 comments on commit 782cca6

Please sign in to comment.