synced with master

This commit is contained in:
Gani Georgiev
2023-12-24 11:23:50 +02:00
36 changed files with 64 additions and 43 deletions
+8 -1
View File
@@ -249,7 +249,14 @@
editableCompartment.of(EditorView.editable.of(true)),
readOnlyCompartment.of(EditorState.readOnly.of(false)),
EditorState.transactionFilter.of((tr) => {
return singleLine && tr.newDoc.lines > 1 ? [] : tr;
if (singleLine && tr.newDoc.lines > 1) {
if (!tr.changes?.inserted?.filter((i) => !!i.text.find((t) => t))?.length) {
return []; // only empty lines
}
// it is ok to mutate the current transaction as we don't change the doc length
tr.newDoc.text = [tr.newDoc.text.join(" ")];
}
return tr;
}),
EditorView.updateListener.of((v) => {
if (!v.docChanged || disabled) {
@@ -494,7 +494,14 @@
readOnlyCompartment.of(EditorState.readOnly.of(disabled)),
langCompartment.of(ruleLang()),
EditorState.transactionFilter.of((tr) => {
return singleLine && tr.newDoc.lines > 1 ? [] : tr;
if (singleLine && tr.newDoc.lines > 1) {
if (!tr.changes?.inserted?.filter((i) => !!i.text.find((t) => t))?.length) {
return []; // only empty lines
}
// it is ok to mutate the current transaction as we don't change the doc length
tr.newDoc.text = [tr.newDoc.text.join(" ")];
}
return tr;
}),
EditorView.updateListener.of((v) => {
if (!v.docChanged || disabled) {