This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +17
-6
lines changed
src/components/views/rooms Expand file tree Collapse file tree 1 file changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -387,17 +387,28 @@ export default class MessageComposerInput extends React.Component {
387
387
const anchorText = editorState . anchorText ;
388
388
if ( ( ! anchorText || anchorText . text === '' ) && editorState . anchorBlock . nodes . size === 1 ) {
389
389
// replace the current block rather than split the block
390
+ // XXX: this destroys our focus by deleting the thing we are anchored/focused on
390
391
change = change . replaceNodeByKey ( editorState . anchorBlock . key , quote ) ;
391
- }
392
- else {
392
+ } else {
393
393
// insert it into the middle of the block (splitting it)
394
394
change = change . insertBlock ( quote ) ;
395
395
}
396
- change = change . insertFragmentByKey ( quote . key , 0 , fragment . document )
397
- . focus ( ) ;
396
+
397
+ // XXX: heuristic to strip out wrapping <p> which breaks quoting in RT mode
398
+ if ( fragment . document . nodes . size && fragment . document . nodes . get ( 0 ) . type === DEFAULT_NODE ) {
399
+ change = change . insertFragmentByKey ( quote . key , 0 , fragment . document . nodes . get ( 0 ) ) ;
400
+ } else {
401
+ change = change . insertFragmentByKey ( quote . key , 0 , fragment . document ) ;
402
+ }
403
+
404
+ // XXX: this is to bring back the focus in a sane place and add a paragraph after it
405
+ change = change . select ( {
406
+ anchorKey : quote . key ,
407
+ focusKey : quote . key ,
408
+ } ) . collapseToEndOfBlock ( ) . insertBlock ( Block . create ( DEFAULT_NODE ) ) . focus ( ) ;
409
+
398
410
this . onChange ( change ) ;
399
- }
400
- else {
411
+ } else {
401
412
let fragmentChange = fragment . change ( ) ;
402
413
fragmentChange . moveToRangeOf ( fragment . document )
403
414
. wrapBlock ( quote ) ;
You can’t perform that action at this time.
0 commit comments