Kindeditor version: 4.1.10 (2013-11-23), specific can go to the official website download: http://kindeditor.net/down.php
The basic configuration does not say here, the official website has the document, pastes the code:
<textarea id= "Content" style= "width:80%;height:100px;" ></textarea>
Defines the editor object Var editor; Load editor asynchronously $.getscript (' ... /kindeditor/kindeditor-min.js ', function () {Kindeditor.basepath = ' ...
/kindeditor/'; Editor = kindeditor.create (' textarea[id= "content"] ', {ID: ' editor_id ', Uploadjson: ' ... /kindeditor/asp.net/upload_json.ashx ', Filemanagerjson: '. /kindeditor/asp.net/file_manager_json.ashx ', allowfilemanager:true,//Default false Resizetype:1, items: [' UN Do ', ' Redo ', ' | ', ' fontname ', ' fontsize ', ' | ', ' forecolor ', ' hilitecolor ', ' bold ', ' italic ', ' underline ', ' REMOVEF Ormat ', ' | ', ' justifyleft ', ' justifycenter ', ' justifyright ', ' insertorderedlist ', ' insertunorderedlist ', ' | ', ' IMA GE ', ' link ', ' | ', ' preview ', autoheightmode:true,//default value: False Aftercreate:function () {This.loadplugin (' a
Utoheight ');
var __doc = This.edit.doc;
Kindeditor.ctrl (__doc, ' V ', function () {//alert (' 123 ');
//}); $ (__doc). bind (' paste ', null, function () {//right-paste, including Ctrl + V settimeout (function () {parent.uploadwebimg (editor);
}, 200);
}); }, Afterchange:function () {$ ('. Word_count '). HTML (This.count ());//(Word count contains HTML code.)
) }, });
});
notice here that you want to modify the next kindeditor-min.js in this file, or the pasted text after the event response (the expression is no content pasted into the editor)
From the source code can be seen here: https://github.com/kindsoft/kindeditor/blob/master/kindeditor-all.js
The impact of the specific way to see yourself so written, my uploadwebimg code affixed to the following, with the Layer window components, specifically to see its official website API, here is not much to say.
Upload remote picture function uploadwebimg (editor) {var relacesrc = [];//Picture Address Object container var IMGs = $ (editor.html ()). FIND (' img ');
Imgs.map (function () {var _src = $ (this). attr (' src '); if ((_src.indexof (' http://') >= 0 | | _src.indexof (' https://') >= 0) && Checkimgok (_SRC)) {if (_sr C.indexof (' http://') >= 0 | |
_src.indexof (' https://') >= 0) {//Consider the possible dynamically generated picture Relacesrc.push ({k: _src});
};
});
if (Relacesrc.length = = 0) return; var msg = ' content contains ' + relaceSrc.length.toString () + ' remote picture, whether to upload now.
';
Confirmlayernormal (msg, function (_index) {var loading = layer.load (0);
var paramdata = {action: "791c252eee12530f4f3af326674b7d97", arg: {imgs:relacesrc},};
Doajaxpost (Paramdata, function (result) {layer.close (loading);
if (!result.success) {supersite.msgerror (result.msg);
Return
} Replace editor picture source var _content = editor.html ();
$ (RELACESRC). each (function (IDX, dom) {_content = _content.replace (DOM.K, Result.data[idx].value);
});
Editor.html (_content);
Supersite.msgok (' Remote image upload success ');
});
Layer.close (_index);
}); };
Service-Side code:
<summary>///upload remote picture///</summary> private void uploadwebimg () {var ajaxdata = base.
Getactionparamdata<parguploadwebimg> ();
if (Ajaxdata = null | | ajaxdata.imgs = NULL | | | | ajaxdata.imgs.Count = 0) outmsg (false, Outmsg: "No uploaded picture address");
var len = Ajaxdata.imgs.Count;
var tempurl = new list<keyvaluedesc> (); var stkimg = new stack<keyvalue> (len);
Upload stack for (int i = 0; i < len; i++) {var img = Ajaxdata.imgs[i].k.trim (); if (stkimg. Any (x => x.value = img))//Just uploaded (description has duplicate pictures to upload) {var loadedpath = stkimg.
A (x => x.value = img). value; Tempurl. ADD (new Keyvaluedesc {key = i.ToString (), value = Loadedpath, desc = (int) EnumCenter.UploadImgStatus.Repea
T});
Continue
var TB = downloadwebimg (IMG); Stkimg. Push (new KeyValue {key = i.ToString (), value = tb. ITEM2}); Push into Stack tempurl. ADD (new Keyvaluedesc {key = i.ToString (), value = tb. ITEM2, desc = tb.
Item1? (int) Enumcenter.uploAdimgstatus.ok: (int) EnumCenter.UploadImgStatus.Error});
} outmsg (True, Outdata:tempurl);
Private Tuple<bool, string> downloadwebimg (string url) {try {var dt = DateTime.Now; var folder = "/upload/image/" + dt.
ToString ("YyyyMMdd", Datetimeformatinfo.invariantinfo) + "/"; var newfile = dt. ToString ("Hhmmss_ffff", datetimeformatinfo.invariantinfo) + URL. Substring (URL. LastIndexOf ('. '));
Extension (band. number) var filepath = Server.MapPath (folder); if (!
Directory.Exists (filepath)) {directory.createdirectory (filepath); The using (WebClient mywebclient = new WebClient ()) {mywebclient.
DownloadFile (URL, filepath + newfile);
return new Tuple<bool, string> (true, folder + NewFile);
} catch (Exception ex) {Tools.LogHelp.WriteLog ("Download remote picture failed", ex); return new Tuple<bool, string> (false, URL); Return to original Address}}