From cb58ac59ac33870dd87fc507750cb14e4cece818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=88=90=E5=8D=93?= <405966530@qq.com> Date: Fri, 29 Jan 2016 10:36:34 +0800 Subject: [PATCH] add insert image uri --- src/editor.js | 4 ++++ src/intro.js | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/editor.js b/src/editor.js index c2e21a3..147ae0a 100644 --- a/src/editor.js +++ b/src/editor.js @@ -234,6 +234,7 @@ Editor.toggleUnOrderedList = toggleUnOrderedList; Editor.toggleOrderedList = toggleOrderedList; Editor.drawLink = drawLink; Editor.drawImage = drawImage; +Editor.drawImageUri = drawImageUri; Editor.undo = undo; Editor.redo = redo; Editor.togglePreview = togglePreview; @@ -263,6 +264,9 @@ Editor.prototype.drawLink = function() { Editor.prototype.drawImage = function() { drawImage(this); }; +Editor.prototype.drawImageUri = function() { + drawImageUri(this); +}; Editor.prototype.undo = function() { undo(this); }; diff --git a/src/intro.js b/src/intro.js index 53efe94..c870b83 100644 --- a/src/intro.js +++ b/src/intro.js @@ -190,6 +190,14 @@ function drawImage(editor) { _replaceSelection(cm, stat.image, '![', '](http://)'); } +/** + * Action for drawing an img with uri. + */ +function drawImageUri(editor,uri) { + var cm = editor.codemirror; + var stat = getState(cm); + _replaceSelection(cm, stat.image, '![', ']('+uri+')'); +} /** * Undo action.