mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
parent
b14ae45b38
commit
79e65240bd
4 changed files with 34 additions and 22 deletions
|
@ -498,3 +498,9 @@ Change the **inline** formatting of the current selection. This is a high-level
|
|||
Takes in a function that can modify the document without the modifications being treated as input.
|
||||
|
||||
This is useful when the document needs to be changed programmatically, but those changes should not raise input events or modify the undo state.
|
||||
|
||||
### linkRegExp
|
||||
|
||||
This is the regular expression used to automatically mark up links when inserting HTML or after pressing space. You can change it if you want to use a custom regular expression for detecting links, or set to `null` to turn off link detection.
|
||||
|
||||
|
||||
|
|
|
@ -4320,20 +4320,23 @@ proto.insertImage = function ( src, attributes ) {
|
|||
return img;
|
||||
};
|
||||
|
||||
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)(?:\?[^&?\s]+=[^&?\s]+(?:&[^&?\s]+=[^&?\s]+)*)?/i;
|
||||
proto.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)(?:\?[^&?\s]+=[^&?\s]+(?:&[^&?\s]+=[^&?\s]+)*)?/i;
|
||||
|
||||
var addLinks = function ( frag, root, self ) {
|
||||
var doc = frag.ownerDocument,
|
||||
walker = new TreeWalker( frag, SHOW_TEXT,
|
||||
function ( node ) {
|
||||
return !getNearest( node, root, 'A' );
|
||||
}),
|
||||
defaultAttributes = self._config.tagAttributes.a,
|
||||
node, data, parent, match, index, endIndex, child;
|
||||
while ( node = walker.nextNode() ) {
|
||||
var doc = frag.ownerDocument;
|
||||
var walker = new TreeWalker( frag, SHOW_TEXT, function ( node ) {
|
||||
return !getNearest( node, root, 'A' );
|
||||
});
|
||||
var linkRegExp = self.linkRegExp;
|
||||
var defaultAttributes = self._config.tagAttributes.a;
|
||||
var node, data, parent, match, index, endIndex, child;
|
||||
if ( !linkRegExp ) {
|
||||
return;
|
||||
}
|
||||
while (( node = walker.nextNode() )) {
|
||||
data = node.data;
|
||||
parent = node.parentNode;
|
||||
while ( match = linkRegExp.exec( data ) ) {
|
||||
while (( match = linkRegExp.exec( data ) )) {
|
||||
index = match.index;
|
||||
endIndex = index + match[0].length;
|
||||
if ( index ) {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1786,20 +1786,23 @@ proto.insertImage = function ( src, attributes ) {
|
|||
return img;
|
||||
};
|
||||
|
||||
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)(?:\?[^&?\s]+=[^&?\s]+(?:&[^&?\s]+=[^&?\s]+)*)?/i;
|
||||
proto.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)(?:\?[^&?\s]+=[^&?\s]+(?:&[^&?\s]+=[^&?\s]+)*)?/i;
|
||||
|
||||
var addLinks = function ( frag, root, self ) {
|
||||
var doc = frag.ownerDocument,
|
||||
walker = new TreeWalker( frag, SHOW_TEXT,
|
||||
function ( node ) {
|
||||
return !getNearest( node, root, 'A' );
|
||||
}),
|
||||
defaultAttributes = self._config.tagAttributes.a,
|
||||
node, data, parent, match, index, endIndex, child;
|
||||
while ( node = walker.nextNode() ) {
|
||||
var doc = frag.ownerDocument;
|
||||
var walker = new TreeWalker( frag, SHOW_TEXT, function ( node ) {
|
||||
return !getNearest( node, root, 'A' );
|
||||
});
|
||||
var linkRegExp = self.linkRegExp;
|
||||
var defaultAttributes = self._config.tagAttributes.a;
|
||||
var node, data, parent, match, index, endIndex, child;
|
||||
if ( !linkRegExp ) {
|
||||
return;
|
||||
}
|
||||
while (( node = walker.nextNode() )) {
|
||||
data = node.data;
|
||||
parent = node.parentNode;
|
||||
while ( match = linkRegExp.exec( data ) ) {
|
||||
while (( match = linkRegExp.exec( data ) )) {
|
||||
index = match.index;
|
||||
endIndex = index + match[0].length;
|
||||
if ( index ) {
|
||||
|
|
Loading…
Reference in a new issue