mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Resolves #22.
This commit is contained in:
parent
10e17557a8
commit
824a3b0a3b
4 changed files with 20 additions and 11 deletions
|
@ -211,9 +211,10 @@ Returns self.
|
|||
|
||||
Makes the currently selected text a link. If no text is selected, the URL or email will be inserted as text at the current cursor point and made into a link.
|
||||
|
||||
This method takes one argument:
|
||||
This method takes two arguments:
|
||||
|
||||
* **url**: The url or email to link to.
|
||||
* **attributes**: (optional) An object containing other attributes to set on the `<a>` node. e.g. `{ target: '_blank' }`. Any `href` attribute will be overwritten by the url given as the first argument.
|
||||
|
||||
Returns self (the Squire instance).
|
||||
|
||||
|
@ -344,4 +345,4 @@ Returns self (the Squire instance).
|
|||
|
||||
Decreases by 1 the nesting level of any at-least-partially selected blocks which are part of a list.
|
||||
|
||||
Returns self (the Squire instance).
|
||||
Returns self (the Squire instance).
|
||||
|
|
|
@ -3299,7 +3299,7 @@ proto.removeStrikethrough = command( 'changeFormat', null, { tag: 'S' } );
|
|||
proto.removeSubscript = command( 'changeFormat', null, { tag: 'SUB' } );
|
||||
proto.removeSuperscript = command( 'changeFormat', null, { tag: 'SUP' } );
|
||||
|
||||
proto.makeLink = function ( url ) {
|
||||
proto.makeLink = function ( url, attributes ) {
|
||||
var range = this.getSelection();
|
||||
if ( range.collapsed ) {
|
||||
var protocolEnd = url.indexOf( ':' ) + 1;
|
||||
|
@ -3311,11 +3311,15 @@ proto.makeLink = function ( url ) {
|
|||
this._doc.createTextNode( url.slice( protocolEnd ) )
|
||||
);
|
||||
}
|
||||
|
||||
if ( !attributes ) {
|
||||
attributes = {};
|
||||
}
|
||||
attributes.href = url;
|
||||
|
||||
this.changeFormat({
|
||||
tag: 'A',
|
||||
attributes: {
|
||||
href: url
|
||||
}
|
||||
attributes: attributes
|
||||
}, {
|
||||
tag: 'A'
|
||||
}, range );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2214,7 +2214,7 @@ proto.removeStrikethrough = command( 'changeFormat', null, { tag: 'S' } );
|
|||
proto.removeSubscript = command( 'changeFormat', null, { tag: 'SUB' } );
|
||||
proto.removeSuperscript = command( 'changeFormat', null, { tag: 'SUP' } );
|
||||
|
||||
proto.makeLink = function ( url ) {
|
||||
proto.makeLink = function ( url, attributes ) {
|
||||
var range = this.getSelection();
|
||||
if ( range.collapsed ) {
|
||||
var protocolEnd = url.indexOf( ':' ) + 1;
|
||||
|
@ -2226,11 +2226,15 @@ proto.makeLink = function ( url ) {
|
|||
this._doc.createTextNode( url.slice( protocolEnd ) )
|
||||
);
|
||||
}
|
||||
|
||||
if ( !attributes ) {
|
||||
attributes = {};
|
||||
}
|
||||
attributes.href = url;
|
||||
|
||||
this.changeFormat({
|
||||
tag: 'A',
|
||||
attributes: {
|
||||
href: url
|
||||
}
|
||||
attributes: attributes
|
||||
}, {
|
||||
tag: 'A'
|
||||
}, range );
|
||||
|
|
Loading…
Reference in a new issue