This repository has been archived by the owner on Jan 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
API
Otstar Lin edited this page May 11, 2019
·
2 revisions
XK Editor开放的一些函数方法,若您未找到想要的函数方法,可以提交issues请求添加或者自行添加。
window.XKEditor.getMarkdown();
window.XKEditor.getHTML();
//window.XKEditor.setMarkdown(val, valueType = 'markdown')
window.XKEditor.setMarkdown("Hello world!", "markdown");
window.XKEditor.setMarkdown("Hello world!", "html");
//window.XKEditor.setHTML(val, valueType = 'html')
window.XKEditor.setHTML("Hello world!", "markdown");
window.XKEditor.setHTML("Hello world!", "html");
window.XKEditor.switchEditor();
window.XKEditor.switchPreview();
window.XKEditor.switchFullPreview();
window.XKEditor.switchFullScreen();
window.XKEditor.toLine();
window.XKEditor.toc();
window.XKEditor.toolbar();
window.XKEditor.resize();
var keys = [
{
name: "copy",
win: "Ctrl-C",
mac: "Command-C",
exec: fucntion() {
//do something
}
},
{
name: "paste",
win: "Ctrl-V",
mac: "Command-V",
exec: function() {
//do something
}
}
];
window.XKEditor.addKeys(keys);
var keys = [
"copy",
"paste"
];
window.XKEditor.removeKeys(keys);
//window.XKEditor.getEditor(name);
window.XKEditor.getEditor("ace");
window.XKEditor.getEditor("tinymce");
window.XKEditor.switchTypewriter();
//window.XKEditor.setLocalStorage(filename);
window.XKEditor.setLocalStorage("text1");
//window.XKEditor.getLocalStorage(filename);
window.XKEditor.getLocalStorage("text2");
window.XKEditor.listLocalStorage();
//window.XKEditor.removeLocalStorage(filename);
window.XKEditor.removeLocalStorage("text1");
//window.XKEditor.download(filename, type = 'markdown');
window.XKEditor.download("download1", type = 'markdown');
window.XKEditor.download("download1", type = 'html');
window.XKEditor.download("download1", type = 'fullhtml');
//window.XKEditorAPI.imgUpload(file, success, failure);
let file = document.getElementById('img-upload').files[0];
var success = function(response) {
//do something
}
var failure = function(error) {
//do something
}
window.XKEditorAPI.imgUpload(file, success, failure);
API还在扩充中,敬请期待。