added option to replace new lines with spaces

closes #3630
This commit is contained in:
Miodec 2022-10-10 18:50:05 +02:00
parent a3b3387f01
commit 944028cdd5
3 changed files with 29 additions and 6 deletions

View file

@ -91,6 +91,11 @@
align-items: center;
width: 100%;
gap: 1rem;
&.disabled {
opacity: 0.5;
pointer-events: none;
user-select: none;
}
}
}
}

View file

@ -25,9 +25,9 @@ export function show(): void {
if ($(wrapper).hasClass("hidden")) {
updateLongTextWarning();
if ($(`${popup} .checkbox input`).prop("checked")) {
$(`${popup} .inputs .randomInputFields`).removeClass("hidden");
$(`${popup} .inputs .randomInputFields`).removeClass("disabled");
} else {
$(`${popup} .inputs .randomInputFields`).addClass("hidden");
$(`${popup} .inputs .randomInputFields`).addClass("disabled");
}
$(wrapper)
.stop(true, true)
@ -105,9 +105,9 @@ $(wrapper).on("mousedown", (e) => {
$(`${popup} .inputs .checkbox input`).on("change", () => {
if ($(`${popup} .checkbox input`).prop("checked")) {
$(`${popup} .inputs .randomInputFields`).removeClass("hidden");
$(`${popup} .inputs .randomInputFields`).removeClass("disabled");
} else {
$(`${popup} .inputs .randomInputFields`).addClass("hidden");
$(`${popup} .inputs .randomInputFields`).addClass("disabled");
}
});
@ -160,6 +160,11 @@ function apply(): void {
if ($(`${popup} .typographyCheck input`).prop("checked")) {
text = Misc.cleanTypographySymbols(text);
}
if ($(`${popup} .replaceNewlineWithSpace input`).prop("checked")) {
text = text.replace(/\n/gm, ". ");
text = text.replace(/\.\. /gm, ". ");
text = text.replace(/ +/gm, " ");
}
// text = Misc.remove_non_ascii(text);
text = text.replace(/[\u2060]/g, "");
CustomText.setText(text.split(CustomText.delimiter));

View file

@ -461,9 +461,9 @@
Randomize the above words, and control how many words are generated.
</span>
</label>
<div class="randomInputFields hidden">
<div class="randomInputFields disabled">
<label class="wordcount">
Word count
Words
<input type="number" value="" min="1" max="10000" />
</label>
<div style="color: var(--sub-color)">or</div>
@ -497,6 +497,19 @@
randomize groups of words.
</span>
</label>
<label class="checkbox replaceNewlineWithSpace">
<input type="checkbox" />
<div class="customTextCheckbox">
<div class="check">
<i class="fas fa-fw fa-check"></i>
</div>
</div>
Replace new lines with spaces
<span>
Replace all new line characters with spaces. Automatically adds
periods to the end of lines.
</span>
</label>
</div>
<div class="button apply">ok</div>
</div>