mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -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 () {
|
proto.getSelectedText = function () {
|
||||||
var range = this.getSelection(),
|
var range = this.getSelection();
|
||||||
walker = new TreeWalker(
|
if ( !range || range.collapsed ) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
var walker = new TreeWalker(
|
||||||
range.commonAncestorContainer,
|
range.commonAncestorContainer,
|
||||||
SHOW_TEXT|SHOW_ELEMENT,
|
SHOW_TEXT|SHOW_ELEMENT,
|
||||||
function ( node ) {
|
function ( node ) {
|
||||||
return isNodeContainedInRange( range, node, true );
|
return isNodeContainedInRange( range, node, true );
|
||||||
}
|
}
|
||||||
),
|
);
|
||||||
startContainer = range.startContainer,
|
var startContainer = range.startContainer;
|
||||||
endContainer = range.endContainer,
|
var endContainer = range.endContainer;
|
||||||
node = walker.currentNode = startContainer,
|
var node = walker.currentNode = startContainer;
|
||||||
textContent = '',
|
var textContent = '';
|
||||||
addedTextInBlock = false,
|
var addedTextInBlock = false;
|
||||||
value;
|
var value;
|
||||||
|
|
||||||
if ( !walker.filter( node ) ) {
|
if ( !walker.filter( node ) ) {
|
||||||
node = walker.nextNode();
|
node = walker.nextNode();
|
||||||
|
@ -595,6 +598,9 @@ proto._removeZWS = function () {
|
||||||
// --- Path change events ---
|
// --- Path change events ---
|
||||||
|
|
||||||
proto._updatePath = function ( range, force ) {
|
proto._updatePath = function ( range, force ) {
|
||||||
|
if ( !range ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var anchor = range.startContainer,
|
var anchor = range.startContainer,
|
||||||
focus = range.endContainer,
|
focus = range.endContainer,
|
||||||
newPath;
|
newPath;
|
||||||
|
@ -1639,7 +1645,9 @@ proto.setHTML = function ( html ) {
|
||||||
};
|
};
|
||||||
|
|
||||||
proto.insertElement = function ( el, range ) {
|
proto.insertElement = function ( el, range ) {
|
||||||
if ( !range ) { range = this.getSelection(); }
|
if ( !range ) {
|
||||||
|
range = this.getSelection();
|
||||||
|
}
|
||||||
range.collapse( true );
|
range.collapse( true );
|
||||||
if ( isInline( el ) ) {
|
if ( isInline( el ) ) {
|
||||||
insertNodeInRange( range, el );
|
insertNodeInRange( range, el );
|
||||||
|
|
Loading…
Reference in a new issue