mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2025-09-24 16:40:55 -06:00
allow drawImage to take an optional description argument
This commit is contained in:
parent
0c63959382
commit
85ecc582b4
File diff suppressed because one or more lines are too long
@ -16360,8 +16360,9 @@ function drawLink(editor) {
|
||||
/**
|
||||
* Action for drawing an img.
|
||||
*/
|
||||
function drawImage(editor, url) {
|
||||
function drawImage(editor, url, desc) {
|
||||
url = (typeof url != "undefined") ? url : "http://";
|
||||
desc = (typeof desc != "undefined") ? desc : "";
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
var options = editor.options;
|
||||
@ -16371,7 +16372,7 @@ function drawImage(editor, url) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_replaceSelection(cm, stat.image, options.insertTexts.image, url);
|
||||
_replaceSelection(cm, stat.image, options.insertTexts.image, url, desc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -16518,7 +16519,8 @@ function togglePreview(editor) {
|
||||
toggleSideBySide(editor);
|
||||
}
|
||||
|
||||
function _replaceSelection(cm, active, startEnd, url) {
|
||||
function _replaceSelection(cm, active, startEnd, url, desc) {
|
||||
desc = (typeof desc != "undefined") ? desc : "";
|
||||
if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||
return;
|
||||
|
||||
@ -16528,6 +16530,7 @@ function _replaceSelection(cm, active, startEnd, url) {
|
||||
var startPoint = cm.getCursor("start");
|
||||
var endPoint = cm.getCursor("end");
|
||||
if(url) {
|
||||
start = start.replace("#desc#", desc);
|
||||
end = end.replace("#url#", url);
|
||||
}
|
||||
if(active) {
|
||||
@ -16972,7 +16975,7 @@ var toolbarBuiltInButtons = {
|
||||
|
||||
var insertTexts = {
|
||||
link: ["[", "](#url#)"],
|
||||
image: [""],
|
||||
image: [""],
|
||||
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
|
||||
horizontalRule: ["", "\n\n-----\n\n"]
|
||||
};
|
||||
@ -17677,8 +17680,8 @@ SimpleMDE.prototype.cleanBlock = function() {
|
||||
SimpleMDE.prototype.drawLink = function() {
|
||||
drawLink(this);
|
||||
};
|
||||
SimpleMDE.prototype.drawImage = function(url) {
|
||||
drawImage(this, url);
|
||||
SimpleMDE.prototype.drawImage = function(url, desc) {
|
||||
drawImage(this, url, desc);
|
||||
};
|
||||
SimpleMDE.prototype.drawTable = function() {
|
||||
drawTable(this);
|
||||
|
2
dist/simplemde.min.js
vendored
2
dist/simplemde.min.js
vendored
File diff suppressed because one or more lines are too long
@ -630,8 +630,9 @@ function drawLink(editor) {
|
||||
/**
|
||||
* Action for drawing an img.
|
||||
*/
|
||||
function drawImage(editor, url) {
|
||||
function drawImage(editor, url, desc) {
|
||||
url = (typeof url != "undefined") ? url : "http://";
|
||||
desc = (typeof desc != "undefined") ? desc : "";
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
var options = editor.options;
|
||||
@ -641,7 +642,7 @@ function drawImage(editor, url) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_replaceSelection(cm, stat.image, options.insertTexts.image, url);
|
||||
_replaceSelection(cm, stat.image, options.insertTexts.image, url, desc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -788,7 +789,8 @@ function togglePreview(editor) {
|
||||
toggleSideBySide(editor);
|
||||
}
|
||||
|
||||
function _replaceSelection(cm, active, startEnd, url) {
|
||||
function _replaceSelection(cm, active, startEnd, url, desc) {
|
||||
desc = (typeof desc != "undefined") ? desc : "";
|
||||
if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
|
||||
return;
|
||||
|
||||
@ -798,6 +800,7 @@ function _replaceSelection(cm, active, startEnd, url) {
|
||||
var startPoint = cm.getCursor("start");
|
||||
var endPoint = cm.getCursor("end");
|
||||
if(url) {
|
||||
start = start.replace("#desc#", desc);
|
||||
end = end.replace("#url#", url);
|
||||
}
|
||||
if(active) {
|
||||
@ -1242,7 +1245,7 @@ var toolbarBuiltInButtons = {
|
||||
|
||||
var insertTexts = {
|
||||
link: ["[", "](#url#)"],
|
||||
image: [""],
|
||||
image: [""],
|
||||
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
|
||||
horizontalRule: ["", "\n\n-----\n\n"]
|
||||
};
|
||||
@ -1947,8 +1950,8 @@ SimpleMDE.prototype.cleanBlock = function() {
|
||||
SimpleMDE.prototype.drawLink = function() {
|
||||
drawLink(this);
|
||||
};
|
||||
SimpleMDE.prototype.drawImage = function(url) {
|
||||
drawImage(this, url);
|
||||
SimpleMDE.prototype.drawImage = function(url, desc) {
|
||||
drawImage(this, url, desc);
|
||||
};
|
||||
SimpleMDE.prototype.drawTable = function() {
|
||||
drawTable(this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user