fixes
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user