mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 13:16:31 -05:00
Added option to persist splits in inline nodes when fetching range from bookmark.
This commit is contained in:
parent
83a1b4c520
commit
d16de00a23
2 changed files with 14 additions and 10 deletions
|
@ -1983,7 +1983,7 @@ proto._saveRangeToBookmark = function ( range ) {
|
||||||
range.setEndBefore( endNode );
|
range.setEndBefore( endNode );
|
||||||
};
|
};
|
||||||
|
|
||||||
proto._getRangeAndRemoveBookmark = function ( range ) {
|
proto._getRangeAndRemoveBookmark = function ( range, persistSplits ) {
|
||||||
var doc = this._doc,
|
var doc = this._doc,
|
||||||
start = doc.getElementById( startSelectionId ),
|
start = doc.getElementById( startSelectionId ),
|
||||||
end = doc.getElementById( endSelectionId );
|
end = doc.getElementById( endSelectionId );
|
||||||
|
@ -2007,11 +2007,13 @@ proto._getRangeAndRemoveBookmark = function ( range ) {
|
||||||
detach( start );
|
detach( start );
|
||||||
detach( end );
|
detach( end );
|
||||||
|
|
||||||
|
if ( !persistSplits ) {
|
||||||
// Merge any text nodes we split
|
// Merge any text nodes we split
|
||||||
mergeInlines( startContainer, _range );
|
mergeInlines( startContainer, _range );
|
||||||
if ( startContainer !== endContainer ) {
|
if ( startContainer !== endContainer ) {
|
||||||
mergeInlines( endContainer, _range );
|
mergeInlines( endContainer, _range );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !range ) {
|
if ( !range ) {
|
||||||
range = doc.createRange();
|
range = doc.createRange();
|
||||||
|
|
|
@ -525,7 +525,7 @@ proto._saveRangeToBookmark = function ( range ) {
|
||||||
range.setEndBefore( endNode );
|
range.setEndBefore( endNode );
|
||||||
};
|
};
|
||||||
|
|
||||||
proto._getRangeAndRemoveBookmark = function ( range ) {
|
proto._getRangeAndRemoveBookmark = function ( range, persistSplits ) {
|
||||||
var doc = this._doc,
|
var doc = this._doc,
|
||||||
start = doc.getElementById( startSelectionId ),
|
start = doc.getElementById( startSelectionId ),
|
||||||
end = doc.getElementById( endSelectionId );
|
end = doc.getElementById( endSelectionId );
|
||||||
|
@ -549,11 +549,13 @@ proto._getRangeAndRemoveBookmark = function ( range ) {
|
||||||
detach( start );
|
detach( start );
|
||||||
detach( end );
|
detach( end );
|
||||||
|
|
||||||
|
if ( !persistSplits ) {
|
||||||
// Merge any text nodes we split
|
// Merge any text nodes we split
|
||||||
mergeInlines( startContainer, _range );
|
mergeInlines( startContainer, _range );
|
||||||
if ( startContainer !== endContainer ) {
|
if ( startContainer !== endContainer ) {
|
||||||
mergeInlines( endContainer, _range );
|
mergeInlines( endContainer, _range );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !range ) {
|
if ( !range ) {
|
||||||
range = doc.createRange();
|
range = doc.createRange();
|
||||||
|
|
Loading…
Reference in a new issue