@@ -1332,6 +1332,27 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
1332
1332
_redo ( ) ;
1333
1333
event . preventDefault ( ) ;
1334
1334
}
1335
+ /* istanbul ignore next: difficult to test as can't seem to select */
1336
+ } else if ( event . keyCode === 13 && ! event . shiftKey ) {
1337
+ var selection = taSelection . getSelectionElement ( ) ;
1338
+ if ( ! selection . tagName . match ( VALIDELEMENTS ) ) return ;
1339
+ var _new = angular . element ( _defaultVal ) ;
1340
+ if ( / ^ < b r ( | \/ ) > $ / i. test ( selection . innerHTML . trim ( ) ) && selection . parentNode . tagName . toLowerCase ( ) === 'blockquote' && ! selection . nextSibling ) {
1341
+ // if last element in blockquote and element is blank, pull element outside of blockquote.
1342
+ $selection = angular . element ( selection ) ;
1343
+ var _parent = $selection . parent ( ) ;
1344
+ _parent . after ( _new ) ;
1345
+ $selection . remove ( ) ;
1346
+ if ( _parent . children ( ) . length === 0 ) _parent . remove ( ) ;
1347
+ taSelection . setSelectionToElementStart ( _new [ 0 ] ) ;
1348
+ event . preventDefault ( ) ;
1349
+ } else if ( / ^ < [ ^ > ] + > < b r ( | \/ ) > < \/ [ ^ > ] + > $ / i. test ( selection . innerHTML . trim ( ) ) && selection . tagName . toLowerCase ( ) === 'blockquote' ) {
1350
+ $selection = angular . element ( selection ) ;
1351
+ $selection . after ( _new ) ;
1352
+ $selection . remove ( ) ;
1353
+ taSelection . setSelectionToElementStart ( _new [ 0 ] ) ;
1354
+ event . preventDefault ( ) ;
1355
+ }
1335
1356
}
1336
1357
}
1337
1358
} ) ;
@@ -1349,6 +1370,7 @@ See README.md or https://github.com/fraywing/textAngular/wiki for requirements a
1349
1370
while ( ! selection . tagName . match ( VALIDELEMENTS ) && selection !== element [ 0 ] ) {
1350
1371
selection = selection . parentNode ;
1351
1372
}
1373
+
1352
1374
if ( selection . tagName . toLowerCase ( ) !== attrs . taDefaultWrap && selection . tagName . toLowerCase ( ) !== 'li' && ( selection . innerHTML . trim ( ) === '' || selection . innerHTML . trim ( ) === '<br>' ) ) {
1353
1375
var _new = angular . element ( _defaultVal ) ;
1354
1376
angular . element ( selection ) . replaceWith ( _new ) ;
0 commit comments