mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -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:
parent
60842e3b71
commit
306230d0df
4 changed files with 10 additions and 6 deletions
|
@ -939,7 +939,8 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
block = getStartBlockOfRange( range, root );
|
block = getStartBlockOfRange( range, root );
|
||||||
firstBlockInFrag = getNextBlock( frag, frag );
|
firstBlockInFrag = getNextBlock( frag, frag );
|
||||||
if ( block && firstBlockInFrag &&
|
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' ) ) {
|
!getNearest( firstBlockInFrag, frag, 'TABLE' ) ) {
|
||||||
moveRangeBoundariesUpTree( range, block, block, root );
|
moveRangeBoundariesUpTree( range, block, block, root );
|
||||||
range.collapse( true ); // collapse to start
|
range.collapse( true ); // collapse to start
|
||||||
|
@ -3677,7 +3678,8 @@ proto.changeFormat = function ( add, remove, range, partial ) {
|
||||||
var tagAfterSplit = {
|
var tagAfterSplit = {
|
||||||
DT: 'DD',
|
DT: 'DD',
|
||||||
DD: 'DT',
|
DD: 'DT',
|
||||||
LI: 'LI'
|
LI: 'LI',
|
||||||
|
PRE: 'PRE'
|
||||||
};
|
};
|
||||||
|
|
||||||
var splitBlock = function ( self, block, node, offset ) {
|
var splitBlock = function ( self, block, node, offset ) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1240,7 +1240,8 @@ proto.changeFormat = function ( add, remove, range, partial ) {
|
||||||
var tagAfterSplit = {
|
var tagAfterSplit = {
|
||||||
DT: 'DD',
|
DT: 'DD',
|
||||||
DD: 'DT',
|
DD: 'DT',
|
||||||
LI: 'LI'
|
LI: 'LI',
|
||||||
|
PRE: 'PRE'
|
||||||
};
|
};
|
||||||
|
|
||||||
var splitBlock = function ( self, block, node, offset ) {
|
var splitBlock = function ( self, block, node, offset ) {
|
||||||
|
|
|
@ -207,7 +207,8 @@ var insertTreeFragmentIntoRange = function ( range, frag, root ) {
|
||||||
block = getStartBlockOfRange( range, root );
|
block = getStartBlockOfRange( range, root );
|
||||||
firstBlockInFrag = getNextBlock( frag, frag );
|
firstBlockInFrag = getNextBlock( frag, frag );
|
||||||
if ( block && firstBlockInFrag &&
|
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' ) ) {
|
!getNearest( firstBlockInFrag, frag, 'TABLE' ) ) {
|
||||||
moveRangeBoundariesUpTree( range, block, block, root );
|
moveRangeBoundariesUpTree( range, block, block, root );
|
||||||
range.collapse( true ); // collapse to start
|
range.collapse( true ); // collapse to start
|
||||||
|
|
Loading…
Reference in a new issue