mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Code tidying
This commit is contained in:
parent
0b59a746f7
commit
0ae8322d04
1 changed files with 23 additions and 15 deletions
|
@ -503,20 +503,23 @@ function restoreSelection () {
|
|||
}
|
||||
|
||||
proto.getSelectedText = function () {
|
||||
var range = this.getSelection(),
|
||||
walker = new TreeWalker(
|
||||
range.commonAncestorContainer,
|
||||
SHOW_TEXT|SHOW_ELEMENT,
|
||||
function ( node ) {
|
||||
return isNodeContainedInRange( range, node, true );
|
||||
}
|
||||
),
|
||||
startContainer = range.startContainer,
|
||||
endContainer = range.endContainer,
|
||||
node = walker.currentNode = startContainer,
|
||||
textContent = '',
|
||||
addedTextInBlock = false,
|
||||
value;
|
||||
var range = this.getSelection();
|
||||
if ( !range || range.collapsed ) {
|
||||
return '';
|
||||
}
|
||||
var walker = new TreeWalker(
|
||||
range.commonAncestorContainer,
|
||||
SHOW_TEXT|SHOW_ELEMENT,
|
||||
function ( node ) {
|
||||
return isNodeContainedInRange( range, node, true );
|
||||
}
|
||||
);
|
||||
var startContainer = range.startContainer;
|
||||
var endContainer = range.endContainer;
|
||||
var node = walker.currentNode = startContainer;
|
||||
var textContent = '';
|
||||
var addedTextInBlock = false;
|
||||
var value;
|
||||
|
||||
if ( !walker.filter( node ) ) {
|
||||
node = walker.nextNode();
|
||||
|
@ -595,6 +598,9 @@ proto._removeZWS = function () {
|
|||
// --- Path change events ---
|
||||
|
||||
proto._updatePath = function ( range, force ) {
|
||||
if ( !range ) {
|
||||
return;
|
||||
}
|
||||
var anchor = range.startContainer,
|
||||
focus = range.endContainer,
|
||||
newPath;
|
||||
|
@ -1639,7 +1645,9 @@ proto.setHTML = function ( html ) {
|
|||
};
|
||||
|
||||
proto.insertElement = function ( el, range ) {
|
||||
if ( !range ) { range = this.getSelection(); }
|
||||
if ( !range ) {
|
||||
range = this.getSelection();
|
||||
}
|
||||
range.collapse( true );
|
||||
if ( isInline( el ) ) {
|
||||
insertNodeInRange( range, el );
|
||||
|
|
Loading…
Reference in a new issue