Repository navigation
Expand file tree
/
Copy patheditor.js
More file actions
99 lines (93 loc) · 2.6 KB
/
Copy patheditor.js
File metadata and controls
99 lines (93 loc) · 2.6 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright (c) 2010-2017, b3log.org & hacpai.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview editor
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.1.0.5, Nov 8, 2016
*/
admin.editors = {};
/*
* @description Create SoloEditor can use all editor.
* e.g: TinyMCE, wnd
* @constructor
* @param conf 编辑器初始化参数
* @param conf.kind 编辑器类型 simple/all
* @param conf.id 编辑器渲染元素 id
* @param conf.language 编辑器使用语言
* @param conf.type 编辑器种类
* @param conf.codeMirrorLanguage codeMirror 编辑器当前解析语言
*/
var SoloEditor = function (conf) {
this._defaults = {
type: "tinyMCE",
kind: "",
id: "",
language: ""
};
conf.type = Label.editorType;
this.conf = conf;
this._init();
};
$.extend(SoloEditor.prototype, {
/*
* @description 初始化
*/
_init: function () {
this.init();
},
/*
* @description 初始化编辑器
*/
init: function (type) {
var conf = this.conf;
if (type) {
conf.type = type;
}
var types = conf.type.split("-");
if (types.length === 2) {
conf.codeMirrorLanguage = types[1];
conf.type = types[0];
}
admin.editors[conf.type].init(conf);
},
/*
* @description 获取编辑器值
* @returns {string} 编辑器值
*/
getContent: function () {
var conf = this.conf;
return admin.editors[conf.type].getContent(conf.id);
},
/*
* @description 设置编辑器值
* @param {string} content 编辑器回填内容
*/
setContent: function (content) {
var conf = this.conf;
admin.editors[conf.type].setContent(conf.id, content);
},
/*
* @description 移除编辑器值
*/
remove: function () {
var conf = this.conf;
admin.editors[conf.type].remove(conf.id);
}
});
admin.editors.articleEditor = {};
admin.editors.abstractEditor = {};
admin.editors.pageEditor = {};