add:Neditor

master
bobi 2019-11-03 15:36:26 +08:00
parent 6dd7be7f15
commit d6e58f5a24
1 changed files with 163 additions and 178 deletions

View File

@ -2,39 +2,21 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>用户列表</title> <title>Neditor</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="../../css/oksub.css"> <link rel="stylesheet" href="../../css/oksub.css">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script type="text/javascript" charset="utf-8" src="../../lib/neditor/neditor.config.js"></script> <script type="text/javascript" charset="utf-8" src="../../lib/neditor/neditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../lib/neditor/neditor.all.min.js"></script> <script type="text/javascript" charset="utf-8" src="../../lib/neditor/neditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../lib/neditor/neditor.service.js"></script> <script type="text/javascript" charset="utf-8" src="../../lib/neditor/neditor.service.js"></script>
<!--建议手动加在语言避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型,比如你在配置项目里配置的是英文,这里加载的中文,那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="../../lib/neditor/i18n/zh-cn/zh-cn.js"></script> <script type="text/javascript" charset="utf-8" src="../../lib/neditor/i18n/zh-cn/zh-cn.js"></script>
<script type="text/javascript" src="../../lib/neditor/third-party/browser-md5-file.min.js"></script> <script type="text/javascript" src="../../lib/neditor/third-party/browser-md5-file.min.js"></script>
<script type="text/javascript" src="../../lib/neditor/third-party/jquery-1.10.2.min.js"></script> <script type="text/javascript" src="../../lib/neditor/third-party/jquery-1.10.2.min.js"></script>
<style type="text/css"> <style type="text/css">
.content{
padding: 20px;
}
</style> </style>
</head> </head>
<body> <body>
<div class="ok-body"> <div class="ok-body">
<!--面包屑导航区域-->
<div class="ok-body-breadcrumb">
<span class="layui-breadcrumb">
<a><cite>首页</cite></a>
<a><cite>文本编辑</cite></a>
<a><cite>Neditor</cite></a>
</span>
<a class="layui-btn layui-btn-sm" href="javascript:location.replace(location.href);" title="刷新">
<i class="layui-icon layui-icon-refresh"></i>
</a>
</div>
<div class="content">
<script id="editor" type="text/plain" style="width:1024px;height:300px;"></script> <script id="editor" type="text/plain" style="width:1024px;height:300px;"></script>
<div id="btns"> <div id="btns">
@ -61,24 +43,14 @@
<button onclick=" UE.getEditor('editor').setHeight(300)">设置高度为300默认关闭了自动长高</button> <button onclick=" UE.getEditor('editor').setHeight(300)">设置高度为300默认关闭了自动长高</button>
<button onclick=" UE.getEditor('editor').setPlaceholder('请输入内容')">设置placeholder</button> <button onclick=" UE.getEditor('editor').setPlaceholder('请输入内容')">设置placeholder</button>
</div> </div>
<div> <div>
<button onclick="getLocalData()">获取草稿箱内容</button> <button onclick="getLocalData()">获取草稿箱内容</button>
<button onclick="clearLocalData()">清空草稿箱</button> <button onclick="clearLocalData()">清空草稿箱</button>
</div> </div>
</div>
</div> </div>
</div> </div>
<!--js逻辑--> <!--js逻辑-->
<script src="../../lib/layui/layui.js"></script>
<script type="text/javascript"> <script type="text/javascript">
layui.use(["element"], function () {
});
</script>
<script type="text/javascript">
//实例化编辑器 //实例化编辑器
//建议使用工厂方法getEditor创建和引用编辑器实例如果在某个闭包下引用该编辑器直接调用UE.getEditor('editor')就能拿到相关的实例 //建议使用工厂方法getEditor创建和引用编辑器实例如果在某个闭包下引用该编辑器直接调用UE.getEditor('editor')就能拿到相关的实例
var ue = UE.getEditor('editor'); var ue = UE.getEditor('editor');
@ -88,21 +60,26 @@
alert(UE.getEditor('editor').isFocus()); alert(UE.getEditor('editor').isFocus());
UE.dom.domUtils.preventDefault(e) UE.dom.domUtils.preventDefault(e)
} }
function setblur(e) { function setblur(e) {
UE.getEditor('editor').blur(); UE.getEditor('editor').blur();
UE.dom.domUtils.preventDefault(e) UE.dom.domUtils.preventDefault(e)
} }
function insertHtml() { function insertHtml() {
var value = prompt('插入html代码', ''); var value = prompt('插入html代码', '');
UE.getEditor('editor').execCommand('insertHtml', value) UE.getEditor('editor').execCommand('insertHtml', value)
} }
function createEditor() { function createEditor() {
enableBtn(); enableBtn();
UE.getEditor('editor'); UE.getEditor('editor');
} }
function getAllHtml() { function getAllHtml() {
alert(UE.getEditor('editor').getAllHtml()) alert(UE.getEditor('editor').getAllHtml())
} }
function getContent() { function getContent() {
var arr = []; var arr = [];
arr.push("使用editor.getContent()方法可以获得编辑器的内容"); arr.push("使用editor.getContent()方法可以获得编辑器的内容");
@ -110,6 +87,7 @@
arr.push(UE.getEditor('editor').getContent()); arr.push(UE.getEditor('editor').getContent());
alert(arr.join("\n")); alert(arr.join("\n"));
} }
function getPlainTxt() { function getPlainTxt() {
var arr = []; var arr = [];
arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容"); arr.push("使用editor.getPlainTxt()方法可以获得编辑器的带格式的纯文本内容");
@ -117,12 +95,14 @@
arr.push(UE.getEditor('editor').getPlainTxt()); arr.push(UE.getEditor('editor').getPlainTxt());
alert(arr.join('\n')) alert(arr.join('\n'))
} }
function setContent(isAppendTo) { function setContent(isAppendTo) {
var arr = []; var arr = [];
arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容"); arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo); UE.getEditor('editor').setContent('欢迎使用ueditor', isAppendTo);
alert(arr.join("\n")); alert(arr.join("\n"));
} }
function setDisabled() { function setDisabled() {
UE.getEditor('editor').setDisabled('fullscreen'); UE.getEditor('editor').setDisabled('fullscreen');
disableBtn("enable"); disableBtn("enable");
@ -148,6 +128,7 @@
arr.push(UE.getEditor('editor').getContentTxt()); arr.push(UE.getEditor('editor').getContentTxt());
alert(arr.join("\n")); alert(arr.join("\n"));
} }
function hasContent() { function hasContent() {
var arr = []; var arr = [];
arr.push("使用editor.hasContents()方法判断编辑器里是否有内容"); arr.push("使用editor.hasContents()方法判断编辑器里是否有内容");
@ -155,13 +136,16 @@
arr.push(UE.getEditor('editor').hasContents()); arr.push(UE.getEditor('editor').hasContents());
alert(arr.join("\n")); alert(arr.join("\n"));
} }
function setFocus() { function setFocus() {
UE.getEditor('editor').focus(); UE.getEditor('editor').focus();
} }
function deleteEditor() { function deleteEditor() {
disableBtn(); disableBtn();
UE.getEditor('editor').destroy(); UE.getEditor('editor').destroy();
} }
function disableBtn(str) { function disableBtn(str) {
var div = document.getElementById('btns'); var div = document.getElementById('btns');
var btns = UE.dom.domUtils.getElementsByTagName(div, "button"); var btns = UE.dom.domUtils.getElementsByTagName(div, "button");
@ -173,6 +157,7 @@
} }
} }
} }
function enableBtn() { function enableBtn() {
var div = document.getElementById('btns'); var div = document.getElementById('btns');
var btns = UE.dom.domUtils.getElementsByTagName(div, "button"); var btns = UE.dom.domUtils.getElementsByTagName(div, "button");