Skip to content

Commit

Permalink
Calculate allowLineBreaks in localization string on request #8961
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Oct 23, 2024
1 parent 4c81bad commit bbb1586
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/survey-core/src/itemvalue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export class ItemValue extends BaseAction implements ILocalizableOwner, IShortcu
public get locText(): LocalizableString {
return this.locTextValue;
}
setLocText(locText: LocalizableString) {
setLocText(locText: LocalizableString): void {
this.locTextValue = locText;
}
private _locOwner: ILocalizableOwner;
Expand Down Expand Up @@ -291,7 +291,7 @@ export class ItemValue extends BaseAction implements ILocalizableOwner, IShortcu
public set text(newText: string) {
this.locText.text = newText;
}
public get calculatedText() {
public get calculatedText(): string {
return this.locText.calculatedText;
}
public get shortcutText(): string {
Expand Down
11 changes: 7 additions & 4 deletions packages/survey-core/src/localizablestring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ export class LocalizableString implements ILocalizableString {
this.strChanged();
}
}
private _allowLineBreaks: boolean = false;
private _allowLineBreaks: boolean;
public get allowLineBreaks(): boolean {
if(this._allowLineBreaks === undefined) {
this._allowLineBreaks = false;
if (!!this.name && this.owner instanceof SurveyElementCore) {
this._allowLineBreaks = Serializer.findProperty((this.owner as SurveyElementCore).getType(), this.name)?.type == "text";
}
}
return this._allowLineBreaks;
}
public onGetTextCallback: (str: string) => string;
Expand All @@ -67,9 +73,6 @@ export class LocalizableString implements ILocalizableString {
public useMarkdown: boolean = false,
public name?: string
) {
if (owner instanceof SurveyElementCore) {
this._allowLineBreaks = Serializer.findProperty((owner as SurveyElementCore).getType(), name)?.type == "text";
}
this.onCreating();
}
public getIsMultiple(): boolean { return false; }
Expand Down

0 comments on commit bbb1586

Please sign in to comment.