fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
1eeb030
)
auto fill url when obvious
author
Jan Szejko
<janek37@gmail.com>
Thu, 11 Jan 2018 14:24:11 +0000
(15:24 +0100)
committer
Jan Szejko
<janek37@gmail.com>
Thu, 11 Jan 2018 14:24:11 +0000
(15:24 +0100)
src/editor/plugins/core/core.js
patch
|
blob
|
history
diff --git
a/src/editor/plugins/core/core.js
b/src/editor/plugins/core/core.js
index
3839a39
..
6dce4ef
100644
(file)
--- a/
src/editor/plugins/core/core.js
+++ b/
src/editor/plugins/core/core.js
@@
-522,13
+522,21
@@
var createWrapTextAction = function(createParams) {
var createLinkFromSelection = function(callback, params) {
var createLinkFromSelection = function(callback, params) {
- var doc = params.fragment.document,
- dialog = Dialog.create({
+ var fragment = params.fragment,
+ doc = fragment.document,
+ text = fragment.startNode.nativeNode.data.substring(fragment.startOffset, fragment.endOffset),
+ url;
+ if (text.indexOf('//') >= 0 && text.indexOf(' ') < 0) {
+ url = text;
+ } else if (text.substr(0, 4) === 'www.' && text.indexOF(' ') < 0) {
+ url = 'http://' + text;
+ }
+ var dialog = Dialog.create({
title: gettext('Create link'),
executeButtonText: gettext('Apply'),
cancelButtonText: gettext('Cancel'),
fields: [
title: gettext('Create link'),
executeButtonText: gettext('Apply'),
cancelButtonText: gettext('Cancel'),
fields: [
- {label: gettext('Link'), name: 'href', type: 'input',
+ {label: gettext('Link'), name: 'href', type: 'input',
initialValue: url || '',
prePasteHandler: function(text) {
return params.fragment.document.getLinkForUrl(text);
}.bind(this)
prePasteHandler: function(text) {
return params.fragment.document.getLinkForUrl(text);
}.bind(this)