Skip to content

Commit 1d421b7

Browse files
committed
feat: also impose the text size limit on the s-web text box
1 parent 7f0a196 commit 1d421b7

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

packages/studio-web/src/app/upload/upload.component.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,25 @@ Please check it to make sure all words are spelled out completely, e.g. write "4
334334
}
335335
if (this.studioService.inputMethod.text === "edit") {
336336
if (this.studioService.$textInput.value) {
337-
let inputText = new Blob([this.studioService.$textInput.value], {
338-
type: "text/plain",
339-
});
340-
this.studioService.textControl$.setValue(inputText);
337+
const inputLength = this.studioService.$textInput.value.length;
338+
if (inputLength > this.maxTxtSizeKB * 1024) {
339+
this.toastr.error(
340+
$localize`Text too large. Max size: ` +
341+
this.maxTxtSizeKB +
342+
$localize` KB.` +
343+
$localize` Current size: ` +
344+
Math.ceil(inputLength / 1024) +
345+
$localize` KB.`,
346+
$localize`Sorry!`,
347+
{ timeOut: 15000 },
348+
);
349+
return;
350+
} else {
351+
let inputText = new Blob([this.studioService.$textInput.value], {
352+
type: "text/plain",
353+
});
354+
this.studioService.textControl$.setValue(inputText);
355+
}
341356
} else {
342357
this.toastr.error(
343358
$localize`Please enter text to align.`,
@@ -527,8 +542,9 @@ Please check it to make sure all words are spelled out completely, e.g. write "4
527542
: this.maxTxtSizeKB;
528543
if (file.size > maxSizeKB * 1024) {
529544
this.toastr.error(
530-
$localize`File too large. Max size: ` + maxSizeKB + $localize` KB`,
545+
$localize`File too large. Max size: ` + maxSizeKB + $localize` KB.`,
531546
$localize`Sorry!`,
547+
{ timeOut: 15000 },
532548
);
533549
this.textInputElement.nativeElement.value = "";
534550
} else {

0 commit comments

Comments
 (0)