This commit is contained in:
Mateusz Gruszczyński
2026-07-29 11:48:44 +02:00
parent 904f59146b
commit 0655cfe48c
12 changed files with 938 additions and 191 deletions
+12
View File
@@ -11,6 +11,18 @@ function toggleWrap(editor, before, after = before, placeholder = "tekst") {
editor.setRangeText(selected, start - before.length, end + after.length, "select");
return;
}
if (selected.includes("\n") && !before.includes("\n") && !after.includes("\n")) {
const lines = selected.split("\n");
const nonEmpty = lines.filter(line => line.length > 0);
const allWrapped = nonEmpty.length > 0 && nonEmpty.every(line => line.startsWith(before) && line.endsWith(after) && line.length >= before.length + after.length);
const replacement = lines.map(line => {
if (!line) return line;
return allWrapped ? line.slice(before.length, line.length - after.length) : `${before}${line}${after}`;
}).join("\n");
editor.setRangeText(replacement, start, end, "select");
return;
}
if (selected.startsWith(before) && selected.endsWith(after) && selected.length >= before.length + after.length) {
editor.setRangeText(selected.slice(before.length, -after.length), start, end, "select");
return;