-
Notifications
You must be signed in to change notification settings - Fork 406
Commit
Resolves #186.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1330,7 +1330,7 @@ var keyHandlers = { | |
// Remove any zws so we don't think there's content in an empty | ||
// block. | ||
self._recordUndoState( range ); | ||
addLinks( range.startContainer ); | ||
addLinks( range.startContainer, root, self ); | ||
self._removeZWS(); | ||
self._getRangeAndRemoveBookmark( range ); | ||
|
||
|
@@ -1596,7 +1596,7 @@ var keyHandlers = { | |
space: function ( self, _, range ) { | ||
var node, parent; | ||
self._recordUndoState( range ); | ||
addLinks( range.startContainer ); | ||
addLinks( range.startContainer, self._root, self ); | ||
self._getRangeAndRemoveBookmark( range ); | ||
|
||
// If the cursor is at the end of a link (<a>foo|</a>) then move it | ||
|
@@ -2374,7 +2374,8 @@ proto.setConfig = function ( config ) { | |
blockquote: null, | ||
ul: null, | ||
ol: null, | ||
li: null | ||
li: null, | ||
a: null | ||
} | ||
}, config ); | ||
|
||
|
@@ -3760,7 +3761,7 @@ proto.insertElement = function ( el, range ) { | |
if ( !canObserveMutations ) { | ||
this._docWasChanged(); | ||
} | ||
|
||
return this; | ||
}; | ||
|
||
|
@@ -3774,12 +3775,13 @@ proto.insertImage = function ( src, attributes ) { | |
|
||
var linkRegExp = /\b((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))|([\w\-.%+]+@(?:[\w\-]+\.)+[A-Z]{2,}\b)/i; | ||
|
||
var addLinks = function ( frag, root ) { | ||
var addLinks = function ( frag, root, self ) { | ||
var doc = frag.ownerDocument, | ||
walker = new TreeWalker( frag, SHOW_TEXT, | ||
function ( node ) { | ||
return !getNearest( node, root, 'A' ); | ||
}, false ), | ||
defaultAttributes = self._config.tagAttributes.a, | ||
node, data, parent, match, index, endIndex, child; | ||
while ( node = walker.nextNode() ) { | ||
data = node.data; | ||
|
@@ -3791,13 +3793,14 @@ var addLinks = function ( frag, root ) { | |
child = doc.createTextNode( data.slice( 0, index ) ); | ||
parent.insertBefore( child, node ); | ||
} | ||
child = doc.createElement( 'A' ); | ||
child = self.createElement( 'A', mergeObjects({ | ||
href: match[1] ? | ||
/^(?:ht|f)tps?:/.test( match[1] ) ? | ||
match[1] : | ||
'http://' + match[1] : | ||
'mailto:' + match[2] | ||
}, defaultAttributes )); | ||
child.textContent = data.slice( index, endIndex ); | ||
child.href = match[1] ? | ||
/^(?:ht|f)tps?:/.test( match[1] ) ? | ||
match[1] : | ||
'http://' + match[1] : | ||
'mailto:' + match[2]; | ||
parent.insertBefore( child, node ); | ||
node.data = data = data.slice( endIndex ); | ||
} | ||
|
@@ -3830,14 +3833,14 @@ proto.insertHTML = function ( html, isPaste ) { | |
defaultPrevented: false | ||
}; | ||
|
||
addLinks( frag, root ); | ||
addLinks( frag, frag, this ); | ||
cleanTree( frag ); | ||
cleanupBRs( frag, root ); | ||
cleanupBRs( frag, null ); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
neilj
Author
Member
|
||
removeEmptyInlines( frag ); | ||
frag.normalize(); | ||
|
||
while ( node = getNextBlock( node, root ) ) { | ||
fixCursor( node, root ); | ||
while ( node = getNextBlock( node, frag ) ) { | ||
fixCursor( node, null ); | ||
} | ||
|
||
if ( isPaste ) { | ||
|
@@ -3930,6 +3933,7 @@ proto.makeLink = function ( url, attributes ) { | |
if ( !attributes ) { | ||
attributes = {}; | ||
} | ||
mergeObjects( attributes, this._config.tagAttributes.a ); | ||
attributes.href = url; | ||
|
||
this.changeFormat({ | ||
|
Large diffs are not rendered by default.
Can you explain the reason for passing
null
here? This is causing some things to break for me, and knowing why this is null will help me fix it.