diff --git a/static/js/Editor.js b/static/js/Editor.js index d94aa08..19841af 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -456,7 +456,7 @@ Editor.prototype.position_cursor = function ( div_range ) { } // otherwise, just move the text cursor to the end of the text - if ( this.iframe.contentWindow && this.iframe.contentWindow.getSelection ) { // browsers such as Firefox + if ( this.iframe && this.iframe.contentWindow && this.iframe.contentWindow.getSelection ) { // browsers such as Firefox var selection = this.iframe.contentWindow.getSelection(); var last_node = this.document.body.lastChild; diff --git a/static/js/Wiki.js b/static/js/Wiki.js index 14c790c..1c182e9 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -1080,6 +1080,16 @@ Wiki.prototype.make_byline = function ( username, creation, note_id ) { ' | permalink'; } +Wiki.prototype.remove_byline = function ( editor ) { + if ( editor.document && editor.read_write ) { + var byline = getFirstElementByTagAndClassName( "div", "byline", editor.document ); + if ( byline ) { + removeElement( byline ); + editor.resize(); + } + } +} + Wiki.prototype.editor_mouse_hovered = function ( editor, target ) { var pulldowns = getElementsByTagAndClassName( "div", "pulldown" ); @@ -1124,13 +1134,7 @@ Wiki.prototype.key_pressed = function ( event ) { } Wiki.prototype.editor_key_pressed = function ( editor, event ) { - if ( editor.document && editor.read_write ) { - var byline = getFirstElementByTagAndClassName( "div", "byline", editor.document ); - if ( byline ) { - removeElement( byline ); - editor.resize(); - } - } + this.remove_byline( editor ); var code = event.key().code; @@ -1718,6 +1722,7 @@ Wiki.prototype.save_editor = function ( editor, fire_and_forget, callback, synch if ( editor && editor.read_write && !editor.closed && ( ( !editor.empty() && editor.dirty() ) || position_after || position_before ) ) { editor.scrape_title(); + this.remove_byline( editor ); this.invoker.invoke( "/notebooks/save_note", "POST", { "notebook_id": this.notebook.object_id,