Skip to content

Commit 74a3f28

Browse files
committed
add ueditor
1 parent 1839eba commit 74a3f28

File tree

289 files changed

+129095
-140
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+129095
-140
lines changed

manong_manager/manong_manager_web/manong_manager_web.iml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,8 @@
8080
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.3.1" level="project" />
8181
<orderEntry type="library" name="Maven: commons-io:commons-io:2.2" level="project" />
8282
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.1" level="project" />
83+
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.6" level="project" />
84+
<orderEntry type="library" name="Maven: com.json:json:1.1" level="project" />
85+
<orderEntry type="library" name="Maven: com.baidu:ueditor:1.1.2" level="project" />
8386
</component>
8487
</module>

manong_manager/manong_manager_web/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,21 @@
3838
<artifactId>commons-lang3</artifactId>
3939
</dependency>
4040

41+
<dependency>
42+
<groupId>commons-codec</groupId>
43+
<artifactId>commons-codec</artifactId>
44+
</dependency>
45+
46+
<dependency>
47+
<groupId>com.json</groupId>
48+
<artifactId>json</artifactId>
49+
</dependency>
50+
51+
<dependency>
52+
<groupId>com.baidu</groupId>
53+
<artifactId>ueditor</artifactId>
54+
</dependency>
55+
4156
</dependencies>
4257

4358

manong_manager/manong_manager_web/src/main/resources/spring/springmvc.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<context:component-scan base-package="com.manong.controller"></context:component-scan>
1111

1212
<mvc:annotation-driven/>
13+
<mvc:default-servlet-handler/>
1314

1415
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
1516
<property name="prefix" value="/WEB-INF/jsp/"/>
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<%--
2+
User: wistbean
3+
Date: 2018/12/4
4+
Time: 1:09
5+
--%>
6+
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
7+
<html>
8+
<head>
9+
<title>完整demo</title>
10+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
11+
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.config.js"></script>
12+
<script type="text/javascript" charset="utf-8" src="ueditor/ueditor.all.min.js"> </script>
13+
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
14+
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
15+
<script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script>
16+
17+
<style type="text/css">
18+
div{
19+
width:100%;
20+
}
21+
</style>
22+
</head>
23+
<body>
24+
<div>
25+
<h1>完整demo</h1>
26+
<script id="editor" type="text/plain" style="width:1024px;height:500px;"></script>
27+
</div>
28+
<div id="btns">
29+
<div>
30+
<button onclick="getAllHtml()">获得整个html的内容</button>
31+
<button onclick="getContent()">获得内容</button>
32+
<button onclick="setContent()">写入内容</button>
33+
<button onclick="setContent(true)">追加内容</button>
34+
<button onclick="getContentTxt()">获得纯文本</button>
35+
<button onclick="getPlainTxt()">获得带格式的纯文本</button>
36+
<button onclick="hasContent()">判断是否有内容</button>
37+
<button onclick="setFocus()">使编辑器获得焦点</button>
38+
<button onmousedown="isFocus(event)">编辑器是否获得焦点</button>
39+
<button onmousedown="setblur(event)" >编辑器失去焦点</button>
40+
41+
</div>
42+
<div>
43+
<button onclick="getText()">获得当前选中的文本</button>
44+
<button onclick="insertHtml()">插入给定的内容</button>
45+
<button id="enable" onclick="setEnabled()">可以编辑</button>
46+
<button onclick="setDisabled()">不可编辑</button>
47+
<button onclick=" UE.getEditor('editor').setHide()">隐藏编辑器</button>
48+
<button onclick=" UE.getEditor('editor').setShow()">显示编辑器</button>
49+
<button onclick=" UE.getEditor('editor').setHeight(300)">设置高度为300默认关闭了自动长高</button>
50+
</div>
51+
52+
<div>
53+
<button onclick="getLocalData()" >获取草稿箱内容</button>
54+
<button onclick="clearLocalData()" >清空草稿箱</button>
55+
</div>
56+
57+
</div>
58+
<div>
59+
<button onclick="createEditor()">
60+
创建编辑器</button>
61+
<button onclick="deleteEditor()">
62+
删除编辑器</button>
63+
</div>
64+
65+
<script type="text/javascript">
66+
67+
//实例化编辑器
68+
//建议使用工厂方法getEditor创建和引用编辑器实例,如果在某个闭包下引用该编辑器,直接调用UE.getEditor('editor')就能拿到相关的实例
69+
var ue = UE.getEditor('editor');
70+
71+
72+
function isFocus(e){
73+
alert(UE.getEditor('editor').isFocus());
74+
UE.dom.domUtils.preventDefault(e)
75+
}
76+
function setblur(e){
77+
UE.getEditor('editor').blur();
78+
UE.dom.domUtils.preventDefault(e)
79+
}
80+
function insertHtml() {
81+
var value = prompt('插入html代码', '');
82+
UE.getEditor('editor').execCommand('insertHtml', value)
83+
}
84+
function createEditor() {
85+
enableBtn();
86+
UE.getEditor('editor');
87+
}
88+
function getAllHtml() {
89+
alert(UE.getEditor('editor').getAllHtml())
90+
}
91+
function getContent() {
92+
var arr = [];
93+
arr.push("使用editor.getContent()方法可以获得编辑器的内容");
94+
arr.push("内容为:");
95+
arr.push(UE.getEditor('editor').getContent());
96+
alert(arr.join("\n"));
97+
}
98+
function getPlainTxt() {
99+
var arr = [];
100+
arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
101+
arr.push("内容为:");
102+
arr.push(UE.getEditor('editor').getPlainTxt());
103+
alert(arr.join('\n'))
104+
}
105+
function setContent(isAppendTo) {
106+
var arr = [];
107+
arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
108+
UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
109+
alert(arr.join("\n"));
110+
}
111+
function setDisabled() {
112+
UE.getEditor('editor').setDisabled('fullscreen');
113+
disableBtn("enable");
114+
}
115+
116+
function setEnabled() {
117+
UE.getEditor('editor').setEnabled();
118+
enableBtn();
119+
}
120+
121+
function getText() {
122+
//当你点击按钮时编辑区域已经失去了焦点,如果直接用getText将不会得到内容,所以要在选回来,然后取得内容
123+
var range = UE.getEditor('editor').selection.getRange();
124+
range.select();
125+
var txt = UE.getEditor('editor').selection.getText();
126+
alert(txt)
127+
}
128+
129+
function getContentTxt() {
130+
var arr = [];
131+
arr.push("使用editor.getContentTxt()方法可以获得编辑器的纯文本内容");
132+
arr.push("编辑器的纯文本内容为:");
133+
arr.push(UE.getEditor('editor').getContentTxt());
134+
alert(arr.join("\n"));
135+
}
136+
function hasContent() {
137+
var arr = [];
138+
arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
139+
arr.push("判断结果为:");
140+
arr.push(UE.getEditor('editor').hasContents());
141+
alert(arr.join("\n"));
142+
}
143+
function setFocus() {
144+
UE.getEditor('editor').focus();
145+
}
146+
function deleteEditor() {
147+
disableBtn();
148+
UE.getEditor('editor').destroy();
149+
}
150+
function disableBtn(str) {
151+
var div = document.getElementById('btns');
152+
var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
153+
for (var i = 0, btn; btn = btns[i++];) {
154+
if (btn.id == str) {
155+
UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
156+
} else {
157+
btn.setAttribute("disabled", "true");
158+
}
159+
}
160+
}
161+
function enableBtn() {
162+
var div = document.getElementById('btns');
163+
var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
164+
for (var i = 0, btn; btn = btns[i++];) {
165+
UE.dom.domUtils.removeAttributes(btn, ["disabled"]);
166+
}
167+
}
168+
169+
function getLocalData () {
170+
alert(UE.getEditor('editor').execCommand( "getlocaldata" ));
171+
}
172+
173+
function clearLocalData () {
174+
UE.getEditor('editor').execCommand( "clearlocaldata" );
175+
alert("已清空草稿箱")
176+
}
177+
</script>
178+
</body>
179+
</html>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2+
"http://www.w3.org/TR/html4/loose.dtd">
3+
<html>
4+
<head>
5+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6+
<title></title>
7+
<style type="text/css">
8+
*{color: #838383;margin: 0;padding: 0}
9+
html,body {font-size: 12px;overflow: hidden; }
10+
.content{padding:5px 0 0 15px;}
11+
input{width:210px;height:21px;line-height:21px;margin-left: 4px;}
12+
</style>
13+
</head>
14+
<body>
15+
<div class="content">
16+
<span><var id="lang_input_anchorName"></var></span><input id="anchorName" value="" />
17+
</div>
18+
<script type="text/javascript" src="../internal.js"></script>
19+
<script type="text/javascript">
20+
var anchorInput = $G('anchorName'),
21+
node = editor.selection.getRange().getClosedNode();
22+
if(node && node.tagName == 'IMG' && (node = node.getAttribute('anchorname'))){
23+
anchorInput.value = node;
24+
}
25+
anchorInput.onkeydown = function(evt){
26+
evt = evt || window.event;
27+
if(evt.keyCode == 13){
28+
editor.execCommand('anchor', anchorInput.value);
29+
dialog.close();
30+
domUtils.preventDefault(evt)
31+
}
32+
};
33+
dialog.onok = function (){
34+
editor.execCommand('anchor', anchorInput.value);
35+
dialog.close();
36+
};
37+
$focus(anchorInput);
38+
</script>
39+
</body>
40+
</html>

0 commit comments

Comments
 (0)