0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Better handling of <pre>

* Pasting <pre> should not attempt to merge with block.
* Hitting enter should produce a new <pre>, otherwise all new lines after the
  break are lost.
This commit is contained in:
Neil Jenkins 2017-09-05 11:42:54 +10:00
parent 60842e3b71
commit 306230d0df
4 changed files with 10 additions and 6 deletions

View file

@ -939,7 +939,8 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
block = getStartBlockOfRange( range, root );
firstBlockInFrag = getNextBlock( frag, frag );
if ( block && firstBlockInFrag &&
// Don't merge table cell into block
// Don't merge table cells or PRE elements into block
!getNearest( firstBlockInFrag, frag, 'PRE' ) &&
!getNearest( firstBlockInFrag, frag, 'TABLE' ) ) {
moveRangeBoundariesUpTree( range, block, block, root );
range.collapse( true ); // collapse to start
@ -3677,7 +3678,8 @@ proto.changeFormat = function ( add, remove, range, partial ) {
var tagAfterSplit = {
DT: 'DD',
DD: 'DT',
LI: 'LI'
LI: 'LI',
PRE: 'PRE'
};
var splitBlock = function ( self, block, node, offset ) {

File diff suppressed because one or more lines are too long

View file

@ -1240,7 +1240,8 @@ proto.changeFormat = function ( add, remove, range, partial ) {
var tagAfterSplit = {
DT: 'DD',
DD: 'DT',
LI: 'LI'
LI: 'LI',
PRE: 'PRE'
};
var splitBlock = function ( self, block, node, offset ) {

View file

@ -207,7 +207,8 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
block = getStartBlockOfRange( range, root );
firstBlockInFrag = getNextBlock( frag, frag );
if ( block && firstBlockInFrag &&
// Don't merge table cell into block
// Don't merge table cells or PRE elements into block
!getNearest( firstBlockInFrag, frag, 'PRE' ) &&
!getNearest( firstBlockInFrag, frag, 'TABLE' ) ) {
moveRangeBoundariesUpTree( range, block, block, root );
range.collapse( true ); // collapse to start