synced with master
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user