Skip to content

Commit 065add3

Browse files
author
mokimo
committed
fix(newline): shift enter at end of text adds data tag to the added <br> tag
1 parent 41df23f commit 065add3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/create-default-behavior.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,14 @@ export default function createDefaultBehavior (editable) {
4848
},
4949

5050
newline (element, cursor) {
51-
cursor.insertBefore(document.createElement('br'))
5251

53-
if (cursor.isAtEnd()) {
54-
log('at the end')
5552

56-
const noWidthSpace = document.createTextNode('\u200B')
57-
cursor.insertAfter(noWidthSpace)
58-
59-
// var trailingBr = document.createElement('br')
60-
// trailingBr.setAttribute('type', '-editablejs')
61-
// cursor.insertAfter(trailingBr)
53+
if (cursor.isAtTextEnd()) {
54+
const trailingBr = document.createElement('br')
55+
trailingBr.setAttribute('data-editable', 'remove')
56+
cursor.insertBefore(trailingBr)
6257
} else {
63-
log('not at the end')
58+
cursor.insertBefore(document.createElement('br'))
6459
}
6560

6661
cursor.setVisibleSelection()

0 commit comments

Comments
 (0)