mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
基本完成新的编辑器;
This commit is contained in:
@@ -7,8 +7,6 @@
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>内容管理</title>
|
||||
{include file="common/_require"}
|
||||
<link rel="stylesheet" href="/static/lib/quill/quill.snow.css">
|
||||
<script src="/static/lib/quill/quill.min.js"></script>
|
||||
|
||||
<script>
|
||||
var currentHeaderNavItem = 'Post-{$Request.param.type|default="1"}';
|
||||
@@ -42,7 +40,7 @@
|
||||
<div class="layui-row">
|
||||
<form action="{:url('update')}" method="POST" class="layui-form" lay-filter="*">
|
||||
<input type="hidden" name="id" value="{$post.id}">
|
||||
<div class="layui-col-md9 layui-col-lg10">
|
||||
<div class="layui-col-md6 layui-col-lg8">
|
||||
<fieldset class="layui-elem-field">
|
||||
<legend>编辑</legend>
|
||||
<div class="layui-field-box">
|
||||
@@ -67,61 +65,30 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">描述</div>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="desc" class="layui-textarea">{$post->getData('desc')}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">内容</div>
|
||||
<div class="layui-form-label">
|
||||
作者名称
|
||||
<p class="layui-word-aux">不填使用系统设置的名称</p>
|
||||
</div>
|
||||
<div class="layui-input-block">
|
||||
<div id="toolbar">
|
||||
<!-- Add font size dropdown -->
|
||||
<select class="ql-size" lay-ignore="lay-ignore">
|
||||
<option value="small">小号</option>
|
||||
<!-- Note a missing, thus falsy value, is used to reset to default -->
|
||||
<option selected>正常</option>
|
||||
<option value="large">大号</option>
|
||||
<option value="huge">特大号</option>
|
||||
</select>
|
||||
<!-- Add a bold button -->
|
||||
<button class="ql-bold"></button>
|
||||
<button class="ql-italic"></button>
|
||||
<button class="ql-link"></button>
|
||||
<button class="ql-underline"></button>
|
||||
<button class="ql-strike"></button>
|
||||
<button class="ql-blockquote"></button>
|
||||
<button class="ql-code-block"></button>
|
||||
<button class="ql-header" value="1" title="大标题"></button>
|
||||
<button class="ql-header" value="2" title="小标题"></button>
|
||||
<button class="ql-list" value="ordered" title="有序列表"></button>
|
||||
<button class="ql-list" value="bullet" title="无序列表"></button>
|
||||
|
||||
<!-- Add subscript and superscript buttons -->
|
||||
<button class="ql-script" value="sub"></button>
|
||||
<button class="ql-script" value="super"></button>
|
||||
<button class="ql-indent" value="-1"></button>
|
||||
<button class="ql-indent" value="+1"></button>
|
||||
<button class="ql-direction" value="rtl"></button>
|
||||
<select class="ql-color" lay-ignore="lay-ignore"></select>
|
||||
<select class="ql-background" lay-ignore="lay-ignore"></select>
|
||||
<select class="ql-font" lay-ignore="lay-ignore"></select>
|
||||
<button class="ql-align" value="center"></button>
|
||||
<button class="ql-align" value=""></button>
|
||||
<button class="ql-align" value="right"></button>
|
||||
<button class="ql-align" value="justify"></button>
|
||||
<button class="ql-image" title="选择图片"></button>
|
||||
|
||||
|
||||
</div>
|
||||
<div id="editor" style="height: 600px;">
|
||||
|
||||
</div>
|
||||
<div id="content" style="display: none;">{:base64_encode(json_encode($post->content))}</div>
|
||||
<input type="text" name="author_name" value="{$post->getData('author_name')}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">是否置顶</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_top" value="1" title="置顶">
|
||||
<input type="radio" name="is_top" value="0" title="不置顶">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<button class="layui-btn layui-btn-fluid" type="submit" lay-submit lay-filter="save">保存</button>
|
||||
@@ -134,6 +101,8 @@
|
||||
<fieldset class="layui-elem-field sm-form">
|
||||
<legend>信息</legend>
|
||||
<div class="layui-field-box">
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">状态</div>
|
||||
<div class="layui-input-block">
|
||||
@@ -147,6 +116,53 @@
|
||||
<input type="text" name="publish_time" value="{$post->publish_time_datetime}" class="layui-input publish-time">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">跳转链接</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="jump_to_url" value="{$post->getData('jump_to_url')}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">跳转按钮名称</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="jump_to_btn_title" value="{$post->getData('jump_to_btn_title')}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">跳转链接状态</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="jump_to_url_status" value="0" title="不显示">
|
||||
<input type="radio" name="jump_to_url_status" value="1" title="仅显示">
|
||||
<input type="radio" name="jump_to_url_status" value="2" title="自动跳转">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">排序</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="{$post->getData('sort')}" class="layui-input">
|
||||
<div class="layui-form-mid layui-word-aux">越大越靠前</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">模板</div>
|
||||
<div class="layui-input-block">
|
||||
<select name="tpl_name">
|
||||
{volist name=':config("view_type.post")' id='tpl_name'}
|
||||
<option value="{$key}">{$tpl_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div class="layui-col-md3 layui-col-lg2">
|
||||
<fieldset class="layui-elem-field sm-form">
|
||||
<legend>分类和标签</legend>
|
||||
<div class="layui-field-box">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">分类</div>
|
||||
<div class="layui-input-block ">
|
||||
@@ -183,60 +199,8 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">是否置顶</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="is_top" value="1" title="置顶">
|
||||
<input type="radio" name="is_top" value="0" title="不置顶">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">跳转链接</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="jump_to_url" value="{$post->getData('jump_to_url')}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">跳转按钮名称</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="jump_to_btn_title" value="{$post->getData('jump_to_btn_title')}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">跳转链接状态</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="jump_to_url_status" value="0" title="不显示">
|
||||
<input type="radio" name="jump_to_url_status" value="1" title="仅显示">
|
||||
<input type="radio" name="jump_to_url_status" value="2" title="自动跳转">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">
|
||||
作者名称
|
||||
<p class="layui-word-aux">不填使用系统设置的名称</p>
|
||||
</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="author_name" value="{$post->getData('author_name')}" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">排序</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="{$post->getData('sort')}" class="layui-input">
|
||||
<div class="layui-form-mid layui-word-aux">越大越靠前</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">模板</div>
|
||||
<div class="layui-input-block">
|
||||
<select name="tpl_name">
|
||||
{volist name=':config("view_type.post")' id='tpl_name'}
|
||||
<option value="{$key}">{$tpl_name}</option>
|
||||
{/volist}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
@@ -283,79 +247,7 @@
|
||||
index: 0,
|
||||
lenght: 0
|
||||
}
|
||||
var quill = new Quill('#editor', {
|
||||
theme: 'snow',
|
||||
modules: {
|
||||
toolbar: '#toolbar',
|
||||
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
|
||||
quill.setContents(JSON.parse(window.atob($('#content').text())))
|
||||
|
||||
quill.on('selection-change', function (range, oldRange, source) {
|
||||
if (range) {
|
||||
if (range.length == 0) {
|
||||
console.log('User cursor is on', range.index);
|
||||
} else {
|
||||
var text = quill.getText(range.index, range.length);
|
||||
console.log('User has highlighted', text);
|
||||
}
|
||||
currentRange = range;
|
||||
console.log(currentRange);
|
||||
|
||||
} else {
|
||||
console.log('Cursor not in the editor');
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
quill.on('text-change', function (delta, oldDelta, source) {
|
||||
currentRange.index = delta.ops[0].retain
|
||||
if (source == 'api') {
|
||||
console.log("An API call triggered this change.");
|
||||
} else if (source == 'user') {
|
||||
console.log("A user action triggered this change.");
|
||||
}
|
||||
if (currentSecond - lastUpdateSecond > 30) {
|
||||
|
||||
var formData = {
|
||||
'id': '{$post.id}'
|
||||
};
|
||||
|
||||
formData.content = quill.getContents().ops
|
||||
formData.content_html = $('#editor .ql-editor').html()
|
||||
|
||||
$.post('{:url("update")}', formData, function (result) {
|
||||
lastUpdateSecond = currentSecond
|
||||
layer.msg('自动保存成功', {
|
||||
offset: 't'
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
upload.render({
|
||||
elem: '.ql-image',
|
||||
url: '{:url("File/save")}',
|
||||
data: {
|
||||
type: 4,
|
||||
dir: 'article'
|
||||
},
|
||||
accept: 'images',
|
||||
done: function (result) {
|
||||
if (result.code == 0) {
|
||||
layer.msg('上传成功');
|
||||
quill.insertEmbed(++currentRange.index, 'image', result.data.src);
|
||||
} else {
|
||||
layer.msg(result.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
upload.render({
|
||||
elem: '.upload-poster',
|
||||
url: '{:url("File/save")}',
|
||||
@@ -374,10 +266,7 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
var toolbar = quill.getModule('toolbar');
|
||||
toolbar.addHandler('image', function () {
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
form.val('*', {
|
||||
status: '{$post->getData("status")}',
|
||||
@@ -390,8 +279,6 @@
|
||||
|
||||
var formData = data.field;
|
||||
|
||||
formData.content = quill.getContents().ops
|
||||
formData.content_html = $('#editor .ql-editor').html()
|
||||
window.loading = layer.load()
|
||||
$.post('{:url("update")}', formData, function (result) {
|
||||
layer.close(window.loading)
|
||||
|
||||
Reference in New Issue
Block a user