mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-09 17:32:19 +02:00
customize insert action
This commit is contained in:
parent
250a75164a
commit
dc3c9b51c3
18243
debug/simplemde.debug.js
18243
debug/simplemde.debug.js
File diff suppressed because one or more lines are too long
18240
debug/simplemde.js
18240
debug/simplemde.js
File diff suppressed because it is too large
Load diff
18
dist/simplemde.min.js
vendored
18
dist/simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -618,13 +618,29 @@ function drawLink(editor) {
|
|||
var stat = getState(cm);
|
||||
var options = editor.options;
|
||||
var url = "http://";
|
||||
if(options.promptURLs) {
|
||||
url = prompt(options.promptTexts.link);
|
||||
if(!url) {
|
||||
return false;
|
||||
if(options.drawLink) {
|
||||
options.drawLink(__drawLink(editor));
|
||||
} else {
|
||||
if(options.promptURLs) {
|
||||
url = prompt(options.promptTexts.link);
|
||||
if(!url) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_replaceSelection(cm, stat.link, options.insertTexts.link, url);
|
||||
}
|
||||
_replaceSelection(cm, stat.link, options.insertTexts.link, url);
|
||||
}
|
||||
/**
|
||||
* Custom Action for drawing a link
|
||||
* by ucev
|
||||
*/
|
||||
function __drawLink(editor) {
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
var options = editor.options;
|
||||
return function(url) {
|
||||
_replaceSelection(cm, stat.link, options.insertTexts.link, url);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -634,14 +650,30 @@ function drawImage(editor) {
|
|||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
var options = editor.options;
|
||||
var url = "http://";
|
||||
if(options.promptURLs) {
|
||||
url = prompt(options.promptTexts.image);
|
||||
if(!url) {
|
||||
return false;
|
||||
if(options.drawImage) {
|
||||
options.drawImage(__drawImage(editor));
|
||||
} else {
|
||||
var url = "http://";
|
||||
if(options.promptURLs) {
|
||||
url = prompt(options.promptTexts.image);
|
||||
if(!url) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_replaceSelection(cm, stat.image, options.insertTexts.image, url);
|
||||
}
|
||||
_replaceSelection(cm, stat.image, options.insertTexts.image, url);
|
||||
}
|
||||
/**
|
||||
* Custom Action for drawing am img.
|
||||
* by ucev
|
||||
*/
|
||||
function __drawImage(editor) {
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
var options = editor.options;
|
||||
return function(url) {
|
||||
_replaceSelection(cm, stat.image, options.insertTexts.image, url);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2025,4 +2057,4 @@ SimpleMDE.prototype.toTextArea = function() {
|
|||
}
|
||||
};
|
||||
|
||||
module.exports = SimpleMDE;
|
||||
module.exports = SimpleMDE;
|
Loading…
Reference in a new issue