Skip to content

Commit

Permalink
feat: also impose the text size limit on the s-web text box
Browse files Browse the repository at this point in the history
  • Loading branch information
joanise committed Jan 24, 2025
1 parent 7f0a196 commit 1d421b7
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions packages/studio-web/src/app/upload/upload.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,25 @@ Please check it to make sure all words are spelled out completely, e.g. write "4
}
if (this.studioService.inputMethod.text === "edit") {
if (this.studioService.$textInput.value) {
let inputText = new Blob([this.studioService.$textInput.value], {
type: "text/plain",
});
this.studioService.textControl$.setValue(inputText);
const inputLength = this.studioService.$textInput.value.length;
if (inputLength > this.maxTxtSizeKB * 1024) {
this.toastr.error(
$localize`Text too large. Max size: ` +
this.maxTxtSizeKB +
$localize` KB.` +
$localize` Current size: ` +
Math.ceil(inputLength / 1024) +
$localize` KB.`,
$localize`Sorry!`,
{ timeOut: 15000 },
);
return;
} else {
let inputText = new Blob([this.studioService.$textInput.value], {
type: "text/plain",
});
this.studioService.textControl$.setValue(inputText);
}
} else {
this.toastr.error(
$localize`Please enter text to align.`,
Expand Down Expand Up @@ -527,8 +542,9 @@ Please check it to make sure all words are spelled out completely, e.g. write "4
: this.maxTxtSizeKB;
if (file.size > maxSizeKB * 1024) {
this.toastr.error(
$localize`File too large. Max size: ` + maxSizeKB + $localize` KB`,
$localize`File too large. Max size: ` + maxSizeKB + $localize` KB.`,
$localize`Sorry!`,
{ timeOut: 15000 },
);
this.textInputElement.nativeElement.value = "";
} else {
Expand Down

0 comments on commit 1d421b7

Please sign in to comment.