-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathauto_choice_editor.js
62 lines (54 loc) · 1.41 KB
/
auto_choice_editor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* 第三方编辑器脚本文件名
*
* normal 普通笔记
* markdown Markdown笔记
*/
var editorScriptFile = {
normal :"baidu_editor.js",
markdown:"md_editor.js"
}
function autoRunScriptFile () {
var objApp = WizExplorerApp;
var objWindow = objApp.Window;
var objDocument = objWindow.CurrentDocument;
var objCommon = null;
if (objDocument == null) {
return;
};
if (isMarkdown()) {
runScriptFile(editorScriptFile.markdown);
} else{
runScriptFile(editorScriptFile.normal);
};
function isMarkdown() {
var title = objDocument.Title;
if (!title)
return false;
if (-1 != title.indexOf(".md "))
return true;
if (-1 != title.indexOf(".md@"))
return true;
if (title.match(/\.md$/i))
return true;
return false;
};
function runScriptFile (file) {
if (file == "") {
getObjCommon().EditDocument(objApp, null, objDocument, 0);
} else{
objApp.RunScriptFile(objApp.GetPluginPathByScriptFileName(file) + file, "js");
};
};
function getObjCommon() {
if (objCommon == null) {
try {
objCommon = objApp.CreateWizObject("WizKMControls.WizCommonUI");
}
catch (err) {
}
};
return objCommon;
};
};
autoRunScriptFile();