Skip to content

Commit

Permalink
Describe theme-related APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanTsukanov committed Feb 11, 2025
1 parent ffd3031 commit edab346
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
35 changes: 31 additions & 4 deletions packages/survey-creator-core/src/creator-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ export class SurveyCreatorModel extends Base
* @see saveThemeFunc
*/
@property({ defaultValue: false }) showThemeTab: boolean;
/**
* Specifies whether users can modify the [Survey Creator theme](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#creatorTheme). Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"buttons"`.
*
* Default value: `true`
*/
@property({ defaultValue: true }) showCreatorThemeSettings: boolean;
/**
* Specifies whether the "Zoom In", "Zoom Out", and "Zoom to 100%" buttons are available.
Expand Down Expand Up @@ -957,6 +962,9 @@ export class SurveyCreatorModel extends Base
* ```
*/
public onCreateCustomMessagePanel: EventBase<SurveyCreatorModel, CreateCustomMessagePanelEvent> = this.addCreatorEvent<SurveyCreatorModel, CreateCustomMessagePanelEvent>();
/**
* An event that is raised when users change a property in a [Survey Creator theme](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#creatorTheme).
*/
public onCreatorThemePropertyChanged: EventBase<SurveyCreatorModel, CreatorThemePropertyChangedEvent> = this.addCreatorEvent<SurveyCreatorModel, CreatorThemePropertyChangedEvent>();

public getSurveyJSONTextCallback: () => { text: string, isModified: boolean };
Expand Down Expand Up @@ -3085,20 +3093,34 @@ export class SurveyCreatorModel extends Base
return val;
}

/**
* Opens [Survey Creator theme](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#creatorTheme) settings in Property Grid. Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"buttons"`.
* @see closeCreatorThemeSettings
* @see showCreatorThemeSettings
*/
public openCreatorThemeSettings(): void {
const designerPlugin = this.getPlugin("designer") as TabDesignerPlugin;
if (designerPlugin) {
designerPlugin.openCreatorThemeSettings();
}
}

/**
* Closes [Survey Creator theme](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#creatorTheme) settings in Property Grid. Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"buttons"`.
* @see openCreatorThemeSettings
* @see showCreatorThemeSettings
*/
public closeCreatorThemeSettings(): void {
const designerPlugin = this.getPlugin("designer") as TabDesignerPlugin;
if (designerPlugin) {
designerPlugin.closeCreatorThemeSettings();
}
}

/**
* Activates a specified category in Property Grid. Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"buttons"`.
* @param name A [category name](https://surveyjs.io/form-library/documentation/customize-question-types/add-custom-properties-to-a-form#category).
*/
public activatePropertyGridCategory(name: string): void {
if (!!this.designerPropertyGrid) {
this.designerPropertyGrid.activateCategory(name);
Expand All @@ -3115,7 +3137,7 @@ export class SurveyCreatorModel extends Base
return this.designerPropertyGrid.survey;
}
/**
* Collapses a specified category in Property Grid.
* Collapses a specified category in Property Grid. Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"accordion"`.
* @param name A [category name](https://surveyjs.io/form-library/documentation/customize-question-types/add-custom-properties-to-a-form#category).
* @see expandPropertyGridCategory
*/
Expand All @@ -3125,17 +3147,18 @@ export class SurveyCreatorModel extends Base
}
}
/**
* Expands a specified category in Property Grid.
* Expands a specified category in Property Grid. Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"accordion"`.
* @param name A [category name](https://surveyjs.io/form-library/documentation/customize-question-types/add-custom-properties-to-a-form#category).
* @see collapsePropertyGridCategory
* @see activatePropertyGridCategory
*/
public expandPropertyGridCategory(name: string) {
if (!!this.designerPropertyGrid) {
this.designerPropertyGrid.expandCategory(name);
}
}
/**
* Collapses all categories in Property Grid.
* Collapses all categories in Property Grid. Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"accordion"`.
* @see expandAllPropertyGridCategories
*/
public collapseAllPropertyGridCategories() {
Expand All @@ -3144,7 +3167,7 @@ export class SurveyCreatorModel extends Base
}
}
/**
* Expands all categories in Property Grid.
* Expands all categories in Property Grid. Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#propertyGridNavigationMode) is `"accordion"`.
* @see collapseAllPropertyGridCategories
*/
public expandAllPropertyGridCategories() {
Expand Down Expand Up @@ -4264,6 +4287,10 @@ export class SurveyCreatorModel extends Base
}

@property({ defaultValue: {} }) themeVariables: { [index: string]: string } = {};
/**
* Gets or sets a theme for the Survey Creator UI.
* @see showCreatorThemeSettings
*/
@property() creatorTheme: ICreatorTheme;

public preferredColorPalette: string = "light";
Expand Down
6 changes: 6 additions & 0 deletions packages/survey-creator-core/src/creator-events-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,12 @@ export interface DragStartEndEvent {
toElement: IElement;
}
export interface CreatorThemePropertyChangedEvent {
/**
* A property name.
*/
name: string;
/**
* A new property value.
*/
value: any;
}
5 changes: 5 additions & 0 deletions packages/survey-creator-core/src/creator-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export interface ICreatorOptions {
* [Theme Editor](https://surveyjs.io/survey-creator/documentation/theme-editor (linkStyle))
*/
showThemeTab?: boolean;
/**
* Specifies whether users can modify the [Survey Creator theme](https://surveyjs.io/survey-creator/documentation/api-reference/survey-creator#creatorTheme). Applies only if [`propertyGridNavigationMode`](https://surveyjs.io/survey-creator/documentation/api-reference/icreatoroptions#propertyGridNavigationMode) is `"buttons"`.
*
* Default value: `true`
*/
showCreatorThemeSettings?: boolean;
/**
* Specifies whether the "Zoom In", "Zoom Out", and "Zoom to 100%" buttons are available.
Expand Down

0 comments on commit edab346

Please sign in to comment.