Finally, when you start a link, the cursor no longer disappears!
Unfortunately, doing this required a total selection hack, and litters the note HTML with empty spans.
This commit is contained in:
parent
d68c12c9bb
commit
99c08bc3d1
|
@ -344,7 +344,7 @@ Editor.prototype.start_link = function () {
|
||||||
if ( this.iframe.contentWindow && this.iframe.contentWindow.getSelection ) { // browsers such as Firefox
|
if ( this.iframe.contentWindow && this.iframe.contentWindow.getSelection ) { // browsers such as Firefox
|
||||||
var selection = this.iframe.contentWindow.getSelection();
|
var selection = this.iframe.contentWindow.getSelection();
|
||||||
|
|
||||||
// if no text is selected, then insert a link with a placeholder nbsp as the link title, and
|
// if no text is selected, then insert a link with a placeholder span as the link title, and
|
||||||
// then immediately remove the link title once the link is created
|
// then immediately remove the link title once the link is created
|
||||||
if ( selection.toString().length == 0 ) {
|
if ( selection.toString().length == 0 ) {
|
||||||
this.insert_html( '<span id="placeholder_title"> </span>' );
|
this.insert_html( '<span id="placeholder_title"> </span>' );
|
||||||
|
@ -352,15 +352,17 @@ Editor.prototype.start_link = function () {
|
||||||
selection.selectAllChildren( placeholder );
|
selection.selectAllChildren( placeholder );
|
||||||
|
|
||||||
this.exec_command( "createLink", "/notebooks/" + this.notebook_id + "?note_id=new" );
|
this.exec_command( "createLink", "/notebooks/" + this.notebook_id + "?note_id=new" );
|
||||||
|
selection.collapseToEnd();
|
||||||
|
|
||||||
// hack to prevent Firefox from erasing spaces before links that happen to be at the end of list items
|
// hack to prevent Firefox from erasing spaces before links that happen to be at the end of list items
|
||||||
var sentinel = createDOM( "span" );
|
var sentinel = createDOM( "span" );
|
||||||
insertSiblingNodesBefore( placeholder.parentNode, sentinel );
|
var link = placeholder.parentNode;
|
||||||
|
insertSiblingNodesBefore( link, sentinel );
|
||||||
this.link_started = placeholder.parentNode;
|
this.link_started = placeholder.parentNode;
|
||||||
|
|
||||||
// nuke the link title and collapse the selection, yielding a tasty new link that's completely
|
// nuke the link title and collapse the selection, yielding a tasty new link that's titleless
|
||||||
// titleless and unselected
|
// (except for this span) and unselected
|
||||||
removeElement( placeholder );
|
link.innerHTML = "<span></span>";
|
||||||
// otherwise, just create a link with the selected text as the link title
|
// otherwise, just create a link with the selected text as the link title
|
||||||
} else {
|
} else {
|
||||||
this.link_started = null;
|
this.link_started = null;
|
||||||
|
|
Reference in New Issue
Block a user