Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_14980201
ueditor
提交
2b2483a5
U
ueditor
项目概览
qq_14980201
/
ueditor
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
ueditor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2b2483a5
编写于
11月 28, 2013
作者:
Y
yancend
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #79 from Jinqn/dev-1.3.0
Dev1.3.5 修改demo
上级
23eca163
8bf208fb
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
186 addition
and
11 deletion
+186
-11
Gruntfile.js
Gruntfile.js
+20
-1
_examples/completeDemo.html
_examples/completeDemo.html
+1
-0
index.html
index.html
+165
-10
未找到文件。
Gruntfile.js
浏览文件 @
2b2483a5
...
...
@@ -113,6 +113,14 @@ module.exports = function ( grunt ) {
}
]
},
demo
:
{
files
:
[
{
src
:
'
_examples/completeDemo.html
'
,
dest
:
disDir
+
'
index.html
'
}
]
},
php
:
{
expand
:
true
,
...
...
@@ -159,6 +167,17 @@ module.exports = function ( grunt ) {
from
:
/utf-8/gi
,
to
:
'
gbk
'
}
]
},
demo
:{
src
:
disDir
+
'
index.html
'
,
overwrite
:
true
,
replacements
:
[
{
from
:
/
\.\.\/
/gi
,
to
:
''
},{
from
:
'
editor_api.js
'
,
to
:
'
<%= pkg.name %>.all.min.js
'
}
]
}
}
...
...
@@ -174,7 +193,7 @@ module.exports = function ( grunt ) {
grunt
.
registerTask
(
'
default
'
,
'
UEditor build
'
,
function
()
{
var
tasks
=
[
'
concat
'
,
'
cssmin
'
,
'
gcc
'
,
'
copy:base
'
,
'
copy:
'
+
server
];
var
tasks
=
[
'
concat
'
,
'
cssmin
'
,
'
gcc
'
,
'
copy:base
'
,
'
copy:
demo
'
,
'
copy:
'
+
server
];
if
(
encode
===
'
gbk
'
)
{
tasks
.
push
(
'
replace
'
);
...
...
_examples/completeDemo.html
浏览文件 @
2b2483a5
...
...
@@ -17,6 +17,7 @@
</head>
<body>
<div>
<h1>
完整demo
</h1>
<script
id=
"editor"
type=
"text/plain"
style=
"width:1024px;height:500px;"
></script>
</div>
<div
id=
"btns"
>
...
...
index.html
浏览文件 @
2b2483a5
<!DOCTYPE HTML>
<html
lang=
"en-US"
>
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
ueditor演示
</title>
<title>
完整demo
</title>
<meta
http-equiv=
"Content-Type"
content=
"text/html;charset=utf-8"
/>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"./ueditor.config.js"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"./ueditor.all.min.js"
>
</script>
<!--建议手动加在语言,避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"./lang/zh-cn/zh-cn.js"
></script>
<style
type=
"text/css"
>
.clear
{
clear
:
both
;
}
</style>
</head>
<body>
<h1>
ueditor演示
</h1>
<script
id=
"container"
name=
"content"
type=
"text/plain"
style=
"width:960px;height:500px;"
>
这里写你的初始化内容
</script>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"ueditor.config.js"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"ueditor.all.js"
></script>
<script
type=
"text/javascript"
charset=
"utf-8"
src=
"lang/zh-cn/zh-cn.js"
></script>
<div>
<h1>
ueditor 完整demo
</h1>
<script
id=
"editor"
type=
"text/plain"
style=
"width:1024px;height:500px;"
></script>
</div>
<div
id=
"btns"
>
<div>
<button
onclick=
"getAllHtml()"
>
获得整个html的内容
</button>
<button
onclick=
"getContent()"
>
获得内容
</button>
<button
onclick=
"setContent()"
>
写入内容
</button>
<button
onclick=
"setContent(true)"
>
追加内容
</button>
<button
onclick=
"getContentTxt()"
>
获得纯文本
</button>
<button
onclick=
"getPlainTxt()"
>
获得带格式的纯文本
</button>
<button
onclick=
"hasContent()"
>
判断是否有内容
</button>
<button
onclick=
"setFocus()"
>
使编辑器获得焦点
</button>
<button
onmousedown=
"isFocus(event)"
style=
"color:red"
>
new 编辑器是否获得焦点
</button>
<button
onmousedown=
"setblur(event)"
style=
"color:red"
>
new 编辑器失去焦点
</button>
</div>
<div>
<button
onclick=
"getText()"
>
获得当前选中的文本
</button>
<button
onclick=
"insertHtml()"
>
插入给定的内容
</button>
<button
id=
"enable"
onclick=
"setEnabled()"
>
可以编辑
</button>
<button
onclick=
"setDisabled()"
>
不可编辑
</button>
<button
onclick=
" UE.getEditor('editor').setHide()"
>
隐藏编辑器
</button>
<button
onclick=
" UE.getEditor('editor').setShow()"
>
显示编辑器
</button>
<button
onclick=
" UE.getEditor('editor').setHeight(300)"
>
设置编辑器的高度为300
</button>
</div>
<div>
<button
onclick=
"getLocalData()"
style=
"color:red"
>
new 获取草稿箱内容
</button>
<button
onclick=
"clearLocalData()"
style=
"color:red"
>
new 清空草稿箱
</button>
</div>
</div>
<div>
<button
onclick=
"createEditor()"
/>
创建编辑器
</button>
<button
onclick=
"deleteEditor()"
/>
删除编辑器
</button>
</div>
</body>
<script
type=
"text/javascript"
>
var
editor
=
UE
.
getEditor
(
'
container
'
);
//实例化编辑器
var
ue
=
UE
.
getEditor
(
'
editor
'
);
function
isFocus
(
e
){
alert
(
ue
.
isFocus
());
UE
.
dom
.
domUtils
.
preventDefault
(
e
)
}
function
setblur
(
e
){
ue
.
blur
();
UE
.
dom
.
domUtils
.
preventDefault
(
e
)
}
function
insertHtml
()
{
var
value
=
prompt
(
'
插入html代码
'
,
''
);
ue
.
execCommand
(
'
insertHtml
'
,
value
)
}
function
createEditor
()
{
enableBtn
();
UE
.
getEditor
(
'
editor
'
);
}
function
getAllHtml
()
{
alert
(
UE
.
getEditor
(
'
editor
'
).
getAllHtml
())
}
function
getContent
()
{
var
arr
=
[];
arr
.
push
(
"
使用editor.getContent()方法可以获得编辑器的内容
"
);
arr
.
push
(
"
内容为:
"
);
arr
.
push
(
UE
.
getEditor
(
'
editor
'
).
getContent
());
alert
(
arr
.
join
(
"
\n
"
));
}
function
getPlainTxt
()
{
var
arr
=
[];
arr
.
push
(
"
使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容
"
);
arr
.
push
(
"
内容为:
"
);
arr
.
push
(
UE
.
getEditor
(
'
editor
'
).
getPlainTxt
());
alert
(
arr
.
join
(
'
\n
'
))
}
function
setContent
(
isAppendTo
)
{
var
arr
=
[];
arr
.
push
(
"
使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容
"
);
UE
.
getEditor
(
'
editor
'
).
setContent
(
'
欢迎使用ueditor
'
,
isAppendTo
);
alert
(
arr
.
join
(
"
\n
"
));
}
function
setDisabled
()
{
UE
.
getEditor
(
'
editor
'
).
setDisabled
(
'
fullscreen
'
);
disableBtn
(
"
enable
"
);
}
function
setEnabled
()
{
UE
.
getEditor
(
'
editor
'
).
setEnabled
();
enableBtn
();
}
function
getText
()
{
//当你点击按钮时编辑区域已经失去了焦点,如果直接用getText将不会得到内容,所以要在选回来,然后取得内容
var
range
=
UE
.
getEditor
(
'
editor
'
).
selection
.
getRange
();
range
.
select
();
var
txt
=
UE
.
getEditor
(
'
editor
'
).
selection
.
getText
();
alert
(
txt
)
}
function
getContentTxt
()
{
var
arr
=
[];
arr
.
push
(
"
使用editor.getContentTxt()方法可以获得编辑器的纯文本内容
"
);
arr
.
push
(
"
编辑器的纯文本内容为:
"
);
arr
.
push
(
UE
.
getEditor
(
'
editor
'
).
getContentTxt
());
alert
(
arr
.
join
(
"
\n
"
));
}
function
hasContent
()
{
var
arr
=
[];
arr
.
push
(
"
使用editor.hasContents()方法判断编辑器里是否有内容
"
);
arr
.
push
(
"
判断结果为:
"
);
arr
.
push
(
UE
.
getEditor
(
'
editor
'
).
hasContents
());
alert
(
arr
.
join
(
"
\n
"
));
}
function
setFocus
()
{
UE
.
getEditor
(
'
editor
'
).
focus
();
}
function
deleteEditor
()
{
disableBtn
();
UE
.
getEditor
(
'
editor
'
).
destroy
();
}
function
disableBtn
(
str
)
{
var
div
=
document
.
getElementById
(
'
btns
'
);
var
btns
=
domUtils
.
getElementsByTagName
(
div
,
"
button
"
);
for
(
var
i
=
0
,
btn
;
btn
=
btns
[
i
++
];)
{
if
(
btn
.
id
==
str
)
{
domUtils
.
removeAttributes
(
btn
,
[
"
disabled
"
]);
}
else
{
btn
.
setAttribute
(
"
disabled
"
,
"
true
"
);
}
}
}
function
enableBtn
()
{
var
div
=
document
.
getElementById
(
'
btns
'
);
var
btns
=
domUtils
.
getElementsByTagName
(
div
,
"
button
"
);
for
(
var
i
=
0
,
btn
;
btn
=
btns
[
i
++
];)
{
domUtils
.
removeAttributes
(
btn
,
[
"
disabled
"
]);
}
}
function
getLocalData
()
{
alert
(
ue
.
execCommand
(
"
getlocaldata
"
));
}
function
clearLocalData
()
{
ue
.
execCommand
(
"
clearlocaldata
"
);
alert
(
"
已清空草稿箱
"
)
}
</script>
</body>
</html>
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录