mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Ensure there is always a normal block at the bottom of the page.
This commit is contained in:
parent
f0bd5138e1
commit
e108c18c38
3 changed files with 28 additions and 6 deletions
|
@ -2570,6 +2570,14 @@ var cleanupBRs = function ( root ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
proto._ensureBottomLine = function () {
|
||||||
|
var body = this._body,
|
||||||
|
div = body.lastChild;
|
||||||
|
if ( !div || div.nodeName !== 'DIV' || !isBlock( div ) ) {
|
||||||
|
body.appendChild( this.createDefaultBlock() );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// --- Cut and Paste ---
|
// --- Cut and Paste ---
|
||||||
|
|
||||||
proto._onCut = function () {
|
proto._onCut = function () {
|
||||||
|
@ -2582,7 +2590,7 @@ proto._onCut = function () {
|
||||||
setTimeout( function () {
|
setTimeout( function () {
|
||||||
try {
|
try {
|
||||||
// If all content removed, ensure div at start of body.
|
// If all content removed, ensure div at start of body.
|
||||||
fixCursor( self._body );
|
self._ensureBottomLine();
|
||||||
} catch ( error ) {
|
} catch ( error ) {
|
||||||
self.didError( error );
|
self.didError( error );
|
||||||
}
|
}
|
||||||
|
@ -2689,8 +2697,8 @@ proto._onPaste = function ( event ) {
|
||||||
if ( doPaste ) {
|
if ( doPaste ) {
|
||||||
insertTreeFragmentIntoRange( range, frag );
|
insertTreeFragmentIntoRange( range, frag );
|
||||||
self._docWasChanged();
|
self._docWasChanged();
|
||||||
|
|
||||||
range.collapse( false );
|
range.collapse( false );
|
||||||
|
self._ensureBottomLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2768,6 +2776,7 @@ var afterDelete = function ( self ) {
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range );
|
self._updatePath( range );
|
||||||
}
|
}
|
||||||
|
self._ensureBottomLine();
|
||||||
} catch ( error ) {
|
} catch ( error ) {
|
||||||
self.didError( error );
|
self.didError( error );
|
||||||
}
|
}
|
||||||
|
@ -2940,6 +2949,7 @@ var keyHandlers = {
|
||||||
self._getRangeAndRemoveBookmark( range );
|
self._getRangeAndRemoveBookmark( range );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
deleteContentsOfRange( range );
|
deleteContentsOfRange( range );
|
||||||
|
self._ensureBottomLine();
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range, true );
|
self._updatePath( range, true );
|
||||||
}
|
}
|
||||||
|
@ -3006,6 +3016,7 @@ var keyHandlers = {
|
||||||
self._getRangeAndRemoveBookmark( range );
|
self._getRangeAndRemoveBookmark( range );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
deleteContentsOfRange( range );
|
deleteContentsOfRange( range );
|
||||||
|
self._ensureBottomLine();
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range, true );
|
self._updatePath( range, true );
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1457,6 +1457,14 @@ var cleanupBRs = function ( root ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
proto._ensureBottomLine = function () {
|
||||||
|
var body = this._body,
|
||||||
|
div = body.lastChild;
|
||||||
|
if ( !div || div.nodeName !== 'DIV' || !isBlock( div ) ) {
|
||||||
|
body.appendChild( this.createDefaultBlock() );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// --- Cut and Paste ---
|
// --- Cut and Paste ---
|
||||||
|
|
||||||
proto._onCut = function () {
|
proto._onCut = function () {
|
||||||
|
@ -1469,7 +1477,7 @@ proto._onCut = function () {
|
||||||
setTimeout( function () {
|
setTimeout( function () {
|
||||||
try {
|
try {
|
||||||
// If all content removed, ensure div at start of body.
|
// If all content removed, ensure div at start of body.
|
||||||
fixCursor( self._body );
|
self._ensureBottomLine();
|
||||||
} catch ( error ) {
|
} catch ( error ) {
|
||||||
self.didError( error );
|
self.didError( error );
|
||||||
}
|
}
|
||||||
|
@ -1576,8 +1584,8 @@ proto._onPaste = function ( event ) {
|
||||||
if ( doPaste ) {
|
if ( doPaste ) {
|
||||||
insertTreeFragmentIntoRange( range, frag );
|
insertTreeFragmentIntoRange( range, frag );
|
||||||
self._docWasChanged();
|
self._docWasChanged();
|
||||||
|
|
||||||
range.collapse( false );
|
range.collapse( false );
|
||||||
|
self._ensureBottomLine();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1655,6 +1663,7 @@ var afterDelete = function ( self ) {
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range );
|
self._updatePath( range );
|
||||||
}
|
}
|
||||||
|
self._ensureBottomLine();
|
||||||
} catch ( error ) {
|
} catch ( error ) {
|
||||||
self.didError( error );
|
self.didError( error );
|
||||||
}
|
}
|
||||||
|
@ -1827,6 +1836,7 @@ var keyHandlers = {
|
||||||
self._getRangeAndRemoveBookmark( range );
|
self._getRangeAndRemoveBookmark( range );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
deleteContentsOfRange( range );
|
deleteContentsOfRange( range );
|
||||||
|
self._ensureBottomLine();
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range, true );
|
self._updatePath( range, true );
|
||||||
}
|
}
|
||||||
|
@ -1893,6 +1903,7 @@ var keyHandlers = {
|
||||||
self._getRangeAndRemoveBookmark( range );
|
self._getRangeAndRemoveBookmark( range );
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
deleteContentsOfRange( range );
|
deleteContentsOfRange( range );
|
||||||
|
self._ensureBottomLine();
|
||||||
self.setSelection( range );
|
self.setSelection( range );
|
||||||
self._updatePath( range, true );
|
self._updatePath( range, true );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue