Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
智布道
OneBlog
提交
d51b91d9
O
OneBlog
项目概览
智布道
/
OneBlog
9 个月 前同步成功
通知
11
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OneBlog
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d51b91d9
编写于
10月 28, 2021
作者:
智布道
👁
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
新增 TinyMCE 编辑器 (#I4FOB0)
上级
47d23c6f
变更
18
隐藏空白更改
内联
并排
Showing
18 changed file
with
337 addition
and
85 deletion
+337
-85
blog-admin/src/main/java/com/zyd/blog/controller/RenderController.java
...c/main/java/com/zyd/blog/controller/RenderController.java
+14
-14
blog-admin/src/main/resources/static/assets/js/zhyd.core.js
blog-admin/src/main/resources/static/assets/js/zhyd.core.js
+110
-40
blog-admin/src/main/resources/static/assets/js/zhyd.publish-article.js
...c/main/resources/static/assets/js/zhyd.publish-article.js
+39
-14
blog-admin/src/main/resources/templates/article/list.ftl
blog-admin/src/main/resources/templates/article/list.ftl
+1
-1
blog-admin/src/main/resources/templates/article/publish-md.ftl
...admin/src/main/resources/templates/article/publish-md.ftl
+12
-2
blog-admin/src/main/resources/templates/article/publish-tiny.ftl
...min/src/main/resources/templates/article/publish-tiny.ftl
+80
-0
blog-admin/src/main/resources/templates/config.ftl
blog-admin/src/main/resources/templates/config.ftl
+15
-2
blog-admin/src/main/resources/templates/include/macros.ftl
blog-admin/src/main/resources/templates/include/macros.ftl
+1
-1
blog-admin/src/main/resources/templates/layout/footer.ftl
blog-admin/src/main/resources/templates/layout/footer.ftl
+8
-2
blog-admin/src/main/resources/templates/login.ftl
blog-admin/src/main/resources/templates/login.ftl
+1
-1
blog-admin/src/main/resources/templates/other/editor.ftl
blog-admin/src/main/resources/templates/other/editor.ftl
+24
-6
blog-core/src/main/java/com/zyd/blog/business/entity/Article.java
...e/src/main/java/com/zyd/blog/business/entity/Article.java
+10
-1
blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java
.../main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java
+4
-0
blog-core/src/main/java/com/zyd/blog/persistence/beans/BizArticle.java
.../main/java/com/zyd/blog/persistence/beans/BizArticle.java
+2
-0
blog-core/src/main/resources/mybatis/BizArticleMapper.xml
blog-core/src/main/resources/mybatis/BizArticleMapper.xml
+4
-0
blog-web/src/main/resources/templates/layout/footer.ftl
blog-web/src/main/resources/templates/layout/footer.ftl
+1
-1
docs/db/update.sql
docs/db/update.sql
+6
-0
update.md
update.md
+5
-0
未找到文件。
blog-admin/src/main/java/com/zyd/blog/controller/RenderController.java
浏览文件 @
d51b91d9
...
...
@@ -17,6 +17,7 @@ import com.zyd.blog.business.enums.AdTypeEnum;
import
com.zyd.blog.business.service.BizArticleService
;
import
com.zyd.blog.core.BlogHunterConfigProvider
;
import
com.zyd.blog.core.websocket.server.ZydWebsocketServer
;
import
com.zyd.blog.framework.exception.ZhydException
;
import
com.zyd.blog.util.ResultUtil
;
import
me.zhyd.hunter.config.platform.Platform
;
import
me.zhyd.hunter.enums.ExitWayEnum
;
...
...
@@ -31,6 +32,8 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.servlet.ModelAndView
;
import
java.util.Arrays
;
/**
* 页面跳转类
*
...
...
@@ -86,17 +89,13 @@ public class RenderController {
}
@RequiresPermissions
(
"article:publish"
)
@BussinessLog
(
value
=
"进入发表文章页[html]"
)
@GetMapping
(
"/article/publish"
)
public
ModelAndView
publish
()
{
return
ResultUtil
.
view
(
"article/publish"
);
}
@RequiresPermissions
(
"article:publish"
)
@BussinessLog
(
value
=
"进入发表文章页[markdown]"
)
@GetMapping
(
"/article/publishMd"
)
public
ModelAndView
publishMd
()
{
return
ResultUtil
.
view
(
"article/publish-md"
);
@BussinessLog
(
value
=
"进入发表文章页[{1}]"
)
@GetMapping
(
"/article/publish-{type}"
)
public
ModelAndView
publish
(
@PathVariable
(
"type"
)
String
type
)
{
if
(!
Arrays
.
asList
(
"we"
,
"md"
,
"tiny"
).
contains
(
type
))
{
throw
new
ZhydException
(
"不支持的编辑器类型"
);
}
return
ResultUtil
.
view
(
"article/publish-"
+
type
);
}
@RequiresPermissions
(
"article:publish"
)
...
...
@@ -105,10 +104,11 @@ public class RenderController {
public
ModelAndView
edit
(
@PathVariable
(
"id"
)
Long
id
,
Model
model
)
{
model
.
addAttribute
(
"id"
,
id
);
Article
article
=
articleService
.
getByPrimaryKey
(
id
);
if
(
article
.
getIsMarkdown
())
{
return
ResultUtil
.
view
(
"article/publish-md"
);
if
(!
Arrays
.
asList
(
"we"
,
"md"
,
"tiny"
).
contains
(
article
.
getEditorType
()))
{
throw
new
ZhydException
(
"文章异常,未知的编辑器类型"
);
}
return
ResultUtil
.
view
(
"article/publish
"
);
return
ResultUtil
.
view
(
"article/publish
-"
+
article
.
getEditorType
()
);
}
@RequiresPermissions
(
"types"
)
...
...
blog-admin/src/main/resources/static/assets/js/zhyd.core.js
浏览文件 @
d51b91d9
...
...
@@ -85,7 +85,6 @@ var zhyd = window.zhyd || {
$
(
$bindBox
).
find
(
"
li
"
).
each
(
function
()
{
var
$li
=
$
(
this
);
console
.
log
(
222222
)
$li
.
bind
(
'
click
'
,
add
);
});
$
(
"
.bootstrap-tagsinput input
"
).
bind
(
'
keydown
'
,
function
(
event
)
{
...
...
@@ -168,13 +167,14 @@ var zhyd = window.zhyd || {
editor
=
new
E
(
config
.
container
);
// 配置编辑器 start
// 关闭粘贴样式的过滤
editor
.
customConfig
.
pasteFilterStyle
=
false
;
editor
.
customConfig
.
zIndex
=
100
;
editor
.
config
.
pasteFilterStyle
=
false
;
editor
.
config
.
zIndex
=
100
;
editor
.
config
.
withCredentials
=
true
;
if
(
config
.
textareaName
)
{
$
(
'
<textarea class="wangeditor-textarea" id="
'
+
config
.
textareaName
+
'
" name="
'
+
config
.
textareaName
+
'
" style="display: none" required="required"></textarea>
'
).
insertAfter
(
$
(
config
.
container
));
}
var
$contentBox
=
$
(
'
textarea[name=
'
+
config
.
textareaName
+
'
]
'
);
editor
.
c
ustomC
onfig
.
onchange
=
function
(
html
)
{
editor
.
config
.
onchange
=
function
(
html
)
{
// 监控变化,同步更新到 textarea
$contentBox
.
val
(
html
);
};
...
...
@@ -194,7 +194,6 @@ var zhyd = window.zhyd || {
// 配置编辑器 end
editor
.
create
();
// 注册全屏插件
zhyd
.
wangEditor
.
plugins
.
registerFullscreen
(
config
.
container
);
// 注册图片资源库
zhyd
.
wangEditor
.
plugins
.
registerMaterial
(
editor
,
$contentBox
);
...
...
@@ -207,52 +206,25 @@ var zhyd = window.zhyd || {
}
},
plugins
:
{
registerFullscreen
:
function
()
{
var
E
=
zhyd
.
wangEditor
.
_instance
;
// 全屏插件
E
.
fullscreen
=
{
init
:
function
(
editorBox
)
{
$
(
editorBox
+
"
.w-e-toolbar
"
).
append
(
'
<div class="w-e-menu"><a class="_wangEditor_btn_fullscreen" href="###" onclick="window.wangEditor.fullscreen.toggleFullscreen(
\'
'
+
editorBox
+
'
\'
)" data-toggle="tooltip" data-placement="bottom" title data-original-title="全屏编辑"><i class="fa fa-expand"></i></a></div>
'
)
},
toggleFullscreen
:
function
(
editorSelector
)
{
$
(
editorSelector
).
toggleClass
(
'
fullscreen-editor
'
);
var
$a
=
$
(
editorSelector
+
'
._wangEditor_btn_fullscreen
'
);
var
$i
=
$a
.
find
(
"
i:first-child
"
);
if
(
$i
.
hasClass
(
"
fa-expand
"
))
{
$a
.
attr
(
"
data-original-title
"
,
"
退出全屏
"
);
$i
.
removeClass
(
"
fa-expand
"
).
addClass
(
"
fa-compress
"
)
}
else
{
$a
.
attr
(
"
data-original-title
"
,
"
全屏编辑
"
);
$i
.
removeClass
(
"
fa-compress
"
).
addClass
(
"
fa-expand
"
)
}
}
};
// 初始化全屏插件
var
n
=
arguments
.
length
;
for
(
var
i
=
0
;
i
<
n
;
i
++
)
{
E
.
fullscreen
.
init
(
arguments
[
i
]);
}
},
registerUpload
:
function
(
editor
,
uploadUrl
,
uploadFileName
,
uploadType
,
callback
)
{
if
(
uploadUrl
)
{
// 上传图片到服务器
editor
.
c
ustomC
onfig
.
uploadImgServer
=
uploadUrl
;
editor
.
c
ustomC
onfig
.
uploadFileName
=
uploadFileName
;
editor
.
config
.
uploadImgServer
=
uploadUrl
;
editor
.
config
.
uploadFileName
=
uploadFileName
;
// 将图片大小限制为 50M
editor
.
c
ustomC
onfig
.
uploadImgMaxSize
=
50
*
1024
*
1024
;
editor
.
config
.
uploadImgMaxSize
=
50
*
1024
*
1024
;
// 超时时间
editor
.
c
ustomC
onfig
.
uploadImgTimeout
=
10000
;
editor
.
config
.
uploadImgTimeout
=
10000
;
// 自定义上传参数
editor
.
c
ustomC
onfig
.
uploadImgParams
=
{
editor
.
config
.
uploadImgParams
=
{
// 如果版本 <=v3.1.0 ,属性值会自动进行 encode ,此处无需 encode
// 如果版本 >=v3.1.1 ,属性值不会自动 encode ,如有需要自己手动 encode
uploadType
:
uploadType
};
editor
.
c
ustomC
onfig
.
customAlert
=
function
(
msg
)
{
editor
.
config
.
customAlert
=
function
(
msg
)
{
$
.
alert
.
error
(
msg
);
};
editor
.
c
ustomC
onfig
.
uploadImgHooks
=
{
editor
.
config
.
uploadImgHooks
=
{
error
:
function
(
xhr
,
editor
)
{
$
.
alert
.
error
(
"
图片上传出错
"
);
},
...
...
@@ -485,6 +457,104 @@ var zhyd = window.zhyd || {
}
}
},
tinymce
:
{
defaultConfig
:
{
selector
:
"
tinymceEditor
"
,
uploadUrl
:
""
,
uploadFileName
:
"
file
"
,
textareaName
:
"
content
"
,
},
init
:
function
(
options
)
{
var
$op
=
$
.
extend
(
zhyd
.
tinymce
.
defaultConfig
,
options
);
if
(
$op
.
textareaName
)
{
$
(
'
<textarea class="wangeditor-textarea" id="
'
+
$op
.
textareaName
+
'
" name="
'
+
$op
.
textareaName
+
'
" style="display: none" required="required"></textarea>
'
).
insertAfter
(
$
(
$op
.
selector
));
}
var
$contentBox
=
$
(
'
textarea[name=
'
+
$op
.
textareaName
+
'
]
'
);
tinymce
.
init
({
selector
:
$op
.
selector
,
toolbar_mode
:
'
floating
'
,
// width: 600,
height
:
500
,
plugins
:
[
'
powerpaste advlist autolink link image lists charmap print preview hr anchor pagebreak
'
,
'
searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking
'
,
'
table emoticons template paste help
'
],
menubar
:
'
file edit view insert format tools table
'
,
toolbar
:
'
undo redo | styleselect | code | bold italic | alignleft aligncenter alignright alignjustify |
'
+
'
bullist numlist outdent indent | link image | preview media fullscreen |
'
+
'
forecolor backcolor emoticons | help
'
,
content_langs
:
[
{
title
:
'
English
'
,
code
:
'
en
'
},
{
title
:
'
Chinese
'
,
code
:
'
zh
'
}
],
// language: 'zh_CN',
// directionality: 'rtl',
custom_undo_redo_levels
:
10
,
images_upload_url
:
$op
.
uploadUrl
,
images_upload_credentials
:
true
,
automatic_uploads
:
false
,
images_upload_handler
:
example_image_upload_handler
,
init_instance_callback
:
function
(
editor
)
{
editor
.
on
(
'
SetContent
'
,
function
(
e
)
{
$contentBox
.
val
(
zhyd
.
tinymce
.
getHtml
())
});
editor
.
on
(
'
Change
'
,
function
(
e
)
{
$contentBox
.
val
(
zhyd
.
tinymce
.
getHtml
())
});
}
});
function
example_image_upload_handler
(
blobInfo
,
success
,
failure
,
progress
)
{
var
xhr
,
formData
;
xhr
=
new
XMLHttpRequest
();
xhr
.
withCredentials
=
false
;
xhr
.
open
(
'
POST
'
,
$op
.
uploadUrl
);
xhr
.
upload
.
onprogress
=
function
(
e
)
{
progress
(
e
.
loaded
/
e
.
total
*
100
);
};
xhr
.
onload
=
function
()
{
var
json
;
if
(
xhr
.
status
===
403
)
{
failure
(
'
HTTP Error:
'
+
xhr
.
status
,
{
remove
:
true
});
return
;
}
if
(
xhr
.
status
<
200
||
xhr
.
status
>=
300
)
{
failure
(
'
HTTP Error:
'
+
xhr
.
status
);
return
;
}
json
=
JSON
.
parse
(
xhr
.
responseText
);
if
(
!
json
||
typeof
json
.
data
!=
'
string
'
)
{
failure
(
'
Invalid JSON:
'
+
xhr
.
responseText
);
return
;
}
success
(
json
.
data
);
};
xhr
.
onerror
=
function
()
{
failure
(
'
Image upload failed due to a XHR Transport error. Code:
'
+
xhr
.
status
);
};
formData
=
new
FormData
();
formData
.
append
(
$op
.
uploadFileName
,
blobInfo
.
blob
(),
blobInfo
.
filename
());
xhr
.
send
(
formData
);
}
},
getHtml
:
function
()
{
// 只有一个编辑器
return
tinymce
.
activeEditor
.
getContent
();
// 多个编辑器
// return tinymce.editors[0].getContent();
// 不带HTML标记的纯文本内容
// var activeEditor = tinymce.activeEditor;
// var editBody = activeEditor.getBody();
// activeEditor.selection.select(editBody);
// var text = activeEditor.selection.getContent( {'format' : 'text' });
},
setHtml
:
function
(
html
)
{
// 只有一个编辑器
return
tinymce
.
activeEditor
.
setContent
(
html
);
// 多个编辑器
// return tinymce.editors[0].setContent(html);
}
},
mask
:
{
_box
:
'
<div class="mask {{maskType}}"><div class="masker"><i class="{{icon}}"></i></div><h3 class="text">{{text}}</h3></div>
'
,
_icon
:
{
...
...
@@ -605,7 +675,7 @@ $(document).ready(function () {
/**
* 切换编辑器
*/
$
(
"
#
changeEditor
"
).
click
(
function
()
{
$
(
"
.
changeEditor
"
).
click
(
function
()
{
var
$this
=
$
(
this
);
$
.
alert
.
confirm
(
"
确定要切换编辑器吗?切换后本页内容将可能会丢失?
"
,
function
()
{
window
.
location
.
href
=
$this
.
data
(
"
href
"
);
...
...
blog-admin/src/main/resources/static/assets/js/zhyd.publish-article.js
浏览文件 @
d51b91d9
...
...
@@ -31,18 +31,37 @@ if(articleId){
if
(
info
[
'
coverImage
'
]){
$
(
"
.coverImage
"
).
attr
(
'
src
'
,
info
[
'
coverImage
'
]);
}
var
contentMd
=
info
[
'
contentMd
'
];
if
(
contentMd
){
$
(
"
#contentMd
"
).
val
(
contentMd
);
if
(
simplemde
){
simplemde
.
value
(
contentMd
);
var
contentHtml
=
''
;
if
(
editorType
===
'
md
'
)
{
var
contentMd
=
info
[
'
contentMd
'
];
if
(
contentMd
){
$
(
"
#contentMd
"
).
val
(
contentMd
);
if
(
simplemde
){
simplemde
.
value
(
contentMd
);
}
}
contentHtml
=
info
[
'
content
'
];
if
(
contentHtml
){
$
(
"
#content
"
).
val
(
contentHtml
);
if
(
editor
){
editor
.
txt
.
html
(
contentHtml
);
}
}
}
if
(
editorType
===
'
tiny
'
)
{
contentHtml
=
info
[
'
content
'
];
if
(
contentHtml
){
$
(
"
#content
"
).
val
(
contentHtml
);
zhyd
.
tinymce
.
setHtml
(
contentHtml
);
}
}
var
contentHtml
=
info
[
'
content
'
];
if
(
contentHtml
){
$
(
"
#content
"
).
val
(
contentHtml
);
if
(
editor
){
editor
.
txt
.
html
(
contentHtml
);
if
(
editorType
===
'
we
'
)
{
contentHtml
=
info
[
'
content
'
];
if
(
contentHtml
){
$
(
"
#content
"
).
val
(
contentHtml
);
if
(
editor
){
editor
.
txt
.
html
(
contentHtml
);
}
}
}
$publishForm
.
find
(
"
input[type!=checkbox], select, textarea
"
).
each
(
function
()
{
...
...
@@ -71,10 +90,16 @@ $(".publishBtn").click(function () {
$
.
alert
.
error
(
"
请填写SEO相关的内容,填写后更容易被收录哦
"
);
return
;
}
var
isMarkdown
=
$
(
"
input[name=isMarkdown]
"
).
val
();
if
(
isMarkdown
==
1
||
isMarkdown
==
'
true
'
){
$
(
"
#contentMd
"
).
val
(
simplemde
.
value
());
$
(
"
#content
"
).
val
(
simplemde
.
markdown
(
simplemde
.
value
()));
if
(
editorType
===
'
md
'
)
{
var
isMarkdown
=
$
(
"
input[name=isMarkdown]
"
).
val
();
if
(
isMarkdown
==
1
||
isMarkdown
==
'
true
'
){
$
(
"
#contentMd
"
).
val
(
simplemde
.
value
());
$
(
"
#content
"
).
val
(
simplemde
.
markdown
(
simplemde
.
value
()));
}
}
if
(
editorType
===
'
tiny
'
)
{
$
(
"
#content
"
).
val
(
zhyd
.
tinymce
.
getHtml
());
}
$publishForm
.
ajaxSubmit
({
...
...
blog-admin/src/main/resources/templates/article/list.ftl
浏览文件 @
d51b91d9
...
...
@@ -29,7 +29,7 @@
<div class="<#--table-responsive-->">
<div class="btn-group hidden-xs" id="toolbar">
<@shiro.hasPermission name="article:publish">
<a class="btn btn-success" title="发表文章" href="
${(config.articleEditor! == 'md')?string('/article/publishMd', '/article/publish')
}"> <i class="fa fa-pencil fa-fw"></i> </a>
<a class="btn btn-success" title="发表文章" href="
/article/publish-${config.articleEditor!
}"> <i class="fa fa-pencil fa-fw"></i> </a>
</@shiro.hasPermission>
<@shiro.hasPermission name="article:batchDelete">
<button id="btn_delete_ids" type="button" class="btn btn-danger" title="删除选中">
...
...
blog-admin/src/main/resources/templates/article/publish-md.ftl
浏览文件 @
d51b91d9
...
...
@@ -22,20 +22,29 @@
<ol class="breadcrumb">
<li><a href="/">首页</a></li>
<li><a href="/articles">文章列表</a></li>
<li class="active">发布文章-
Markdown编辑器
</li>
<li class="active">发布文章-
<a href="https://simplemde.com/" target="_blank">Markdown 编辑器</a>
</li>
</ol>
</@breadcrumb>
<div class="x_panel">
<div class="x_title">
<h2>发布文章 <small>可以通过右上角“系统配置”-“文章编辑器”选择默认的文章发布编辑器</small></h2>
<#if !id??>
<div class="pull-right"><small>切换到 <a class="pointer" id="changeEditor" data-href="/article/publish">wangEditor编辑器</a></small></div>
<ul class="nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a class="changeEditor" data-href="/article/publish-we">WangEditor 编辑器</a></li>
<li><a class="changeEditor" data-href="/article/publish-tiny">TinyMCE 编辑器</a></li>
</ul>
</li>
</ul>
</#if>
<div class="clearfix"></div>
</div>
<div class="x_content">
<input type="hidden" name="id">
<input type="hidden" name="isMarkdown" value="1">
<input type="hidden" name="editorType" value="md">
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 col-xs-1" for="title">标题 <span class="required">*</span></label>
<div class="col-md-8 col-sm-8 col-xs-8">
...
...
@@ -84,6 +93,7 @@
};
zhyd.simpleMDE.init(op);
articleId = '${id}';
editorType = 'md';
</script>
<script src="/assets/js/zhyd.publish-article.js"></script>
</@footer>
blog-admin/src/main/resources/templates/article/publish-tiny.ftl
0 → 100644
浏览文件 @
d51b91d9
<#include "/include/macros.ftl">
<@header>
</@header>
<div class="clearfix"></div>
<form id="publishForm" class="form-horizontal form-label-left" novalidate>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<@breadcrumb>
<ol class="breadcrumb">
<li><a href="/">首页</a></li>
<li><a href="/articles">文章列表</a></li>
<li class="active">发布文章-<a href="https://www.tiny.cloud/" target="_blank">TinyMCE 编辑器</a></li>
</ol>
</@breadcrumb>
<div class="x_panel">
<div class="x_title">
<h2>发布文章 <small>可以通过右上角“系统配置”-“文章编辑器”选择默认的文章发布编辑器</small></h2>
<#if !id??>
<ul class="nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<li><a class="changeEditor" data-href="/article/publish-md">Markdown 编辑器</a></li>
<li><a class="changeEditor" data-href="/article/publish-we">WangEditor 编辑器</a></li>
</ul>
</li>
</ul>
</#if>
<div class="clearfix"></div>
</div>
<div class="x_content">
<input type="hidden" name="id">
<input type="hidden" name="isMarkdown" value="0">
<input type="hidden" name="editorType" value="tiny">
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 col-xs-1" for="title">标题 <span class="required">*</span></label>
<div class="col-md-8 col-sm-8 col-xs-8">
<input type="text" class="form-control col-md-7 col-xs-12" name="title" id="title" required="required" placeholder="请输入标题"/>
</div>
<div class="col-md-1 col-sm-1 col-xs-1">
<div class="checkbox">
<label>
<input type="checkbox" class="square" checked name="original"> 原创
</label>
</div>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-1 col-sm-1 col-xs-12" for="content">内容 <span class="required">*</span></label>
<div class="col-md-10 col-sm-10 col-xs-10">
<div id="tinyEditor"></div>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-1 col-sm-1 col-xs-12"></label>
<div class="col-md-10 col-sm-10 col-xs-12">
<button type="button" class="btn btn-success to-choose-info"><i class="fa fa-pencil"> 发布文章</i></button>
</div>
</div>
</div>
</div>
</div>
</div>
<@publishModal></@publishModal>
</form>
</div>
<@chooseImgModal></@chooseImgModal>
<@footer>
<script>
zhyd.tinymce.init({
selector: "#tinyEditor",
uploadUrl: "/api/uploadFile",
uploadFileName: "file",
textareaName: "content",
})
articleId = '${id}';
editorType = 'tiny';
</script>
<script src="/assets/js/zhyd.publish-article.js"></script>
</@footer>
blog-admin/src/main/resources/templates/config.ftl
浏览文件 @
d51b91d9
...
...
@@ -385,11 +385,24 @@
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="articleEditor">默认文章编辑器 <i class="fa fa-question-circle" title="文章编辑器"></i></label>
<div class="col-md-6 col-sm-6 col-xs-12 fixed-radio-checkbox">
<select name="articleEditor" id="articleEditor" class="form-control">
<option value="md">Markdown编辑器</option>
<option value="we">WangEditor编辑器</option>
<option value="md">Markdown 编辑器</option>
<option value="we">WangEditor 编辑器</option>
<option value="tiny">TinyMCE 编辑器</option>
</select>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="tinyMCEKey">TinyMCE API Key</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" class="form-control col-md-7 col-xs-12" name="tinyMCEKey" id="tinyMCEKey" placeholder="请输入TinyMCE API Key"/>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12"></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<small>获取地址:<a href="https://www.tiny.cloud/my-account/dashboard/" target="_blank">点击获取 TinyMCE API Key</a></small>
</div>
</div>
<div class="item form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="comment"></label>
...
...
blog-admin/src/main/resources/templates/include/macros.ftl
浏览文件 @
d51b91d9
...
...
@@ -71,7 +71,7 @@
<
#if
footerHtml
>
<footer>
<div
class=
"pull-right"
>
Gentelella - Bootstrap Admin Template by
<a
href=
"https://colorlib.com
"
>
Colorlib
</a>
<a
href=
"https://colorlib.com/polygon/gentelella/index.html"
target=
"_blank"
>
Gentelella
</a>
- Bootstrap Admin Template by
<a
href=
"https://colorlib.com"
target=
"_blank
"
>
Colorlib
</a>
</div>
<div
class=
"clearfix"
></div>
</footer>
...
...
blog-admin/src/main/resources/templates/layout/footer.ftl
浏览文件 @
d51b91d9
...
...
@@ -25,9 +25,15 @@
<script src="https://cdn.jsdelivr.net/npm/@ztree/ztree_v3@3.5.37/js/jquery.ztree.core.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@ztree/ztree_v3@3.5.37/js/jquery.ztree.excheck.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/switchery-npm@0.8.2/index.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/wangeditor@
3.1.1/release
/wangEditor.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/wangeditor@
4.7.9/dist
/wangEditor.min.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/npm/@adactive/bootstrap-tagsinput@0.8.2/dist/bootstrap-tagsinput.min.js"></script>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<#--<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js"></script>-->
<#if config.tinyMCEKey?exists>
<script src="https://cdn.tiny.cloud/1/${config.tinyMCEKey!}/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<#else>
<script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js"></script>
</#if>
<#--
<script src="https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pnotify/3.2.1/pnotify.buttons.js"></script>
...
...
@@ -41,4 +47,4 @@
<script src="/assets/js/zhyd.upload-preview.js"></script>
<script src="/assets/js/gentelella.core.js"></script>
<script src="/assets/js/zhyd.core.js"></script>
<script src="/assets/js/zhyd.table.js"></script>
\ No newline at end of file
<script src="/assets/js/zhyd.table.js"></script>
blog-admin/src/main/resources/templates/login.ftl
浏览文件 @
d51b91d9
...
...
@@ -59,7 +59,7 @@
<div
class=
"separator"
>
<div
class=
"clearfix"
></div>
<div>
Gentelella - Bootstrap Admin Template by
<a
href=
"https://colorlib.com
"
>
Colorlib
</a>
<a
href=
"https://colorlib.com/polygon/gentelella/index.html"
target=
"_blank"
>
Gentelella
</a>
- Bootstrap Admin Template by
<a
href=
"https://colorlib.com"
target=
"_blank
"
>
Colorlib
</a>
</div>
</div>
</form>
...
...
blog-admin/src/main/resources/templates/other/editor.ftl
浏览文件 @
d51b91d9
...
...
@@ -17,14 +17,14 @@
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>
wangEditor富文本编辑器用例
<small><a href="http://www.wangeditor.com/" target="_blank">http://www.wangeditor.com/</a></small>
<h2>
编辑器用例
</h2>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div class="form-group row">
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">菜单和编辑器区域分开 </label>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">菜单和编辑器区域分开
wangEditor
</label>
<div class="col-md-8 col-sm-8 col-xs-12">
<div id="toolbar" class="toolbar"></div>
<div style="padding: 5px 0; color: #ccc">中间隔离带</div>
...
...
@@ -34,7 +34,7 @@
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">普通的编辑器 </label>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">普通的编辑器
wangEditor
</label>
<div class="col-md-8 col-sm-8 col-xs-12">
<div id="div2">
<p>第二个 demo(常规)</p>
...
...
@@ -43,7 +43,7 @@
</div>
<br>
<div class="form-group row">
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">oneBlog系统定制的编辑器 </label>
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">oneBlog系统定制的编辑器
wangEditor
</label>
<div class="col-md-8 col-sm-8 col-xs-12">
<div id="editor">
<p>第三个 demo(oneBlog系统单独定制,支持文件上传)</p>
...
...
@@ -62,6 +62,12 @@
</div>
</div>
</div>
<div class="form-group row">
<label class="control-label col-md-2 col-sm-2 col-xs-12" for="name">oneBlog系统定制的编辑器 TinyMCE</label>
<div class="col-md-8 col-sm-8 col-xs-12">
<div id="editor3"></div>
</div>
</div>
</div>
</div>
</div>
...
...
@@ -92,5 +98,17 @@
"max-height": "600px"
}
})
zhyd.tinymce.init({
selector: "#editor",
uploadUrl: "/api/uploadFile",
uploadFileName: "file",
textareaName: "content2",
})
setTimeout(function (){
console.log(tinymce.activeEditor.getContent())
console.log($('textarea[name=content2]').val())
}, 10000)
</script>
</@footer>
\ No newline at end of file
</@footer>
blog-core/src/main/java/com/zyd/blog/business/entity/Article.java
浏览文件 @
d51b91d9
...
...
@@ -76,11 +76,13 @@ public class Article {
this
.
bizArticle
.
setQrcodePath
(
qrcodePath
);
}
@Deprecated
public
boolean
getIsMarkdown
()
{
Boolean
value
=
this
.
bizArticle
.
getIsMarkdown
();
return
null
!=
value
&&
value
;
}
@Deprecated
public
void
setIsMarkdown
(
boolean
isMarkdown
)
{
this
.
bizArticle
.
setIsMarkdown
(
isMarkdown
);
}
...
...
@@ -149,7 +151,6 @@ public class Article {
this
.
bizArticle
.
setOriginal
(
original
);
}
public
String
getDescription
()
{
return
this
.
bizArticle
.
getDescription
();
}
...
...
@@ -158,6 +159,14 @@ public class Article {
this
.
bizArticle
.
setDescription
(
description
);
}
public
String
getEditorType
()
{
return
this
.
bizArticle
.
getEditorType
();
}
public
void
setEditorType
(
String
editorType
)
{
this
.
bizArticle
.
setEditorType
(
editorType
);
}
public
String
getKeywords
()
{
return
this
.
bizArticle
.
getKeywords
();
}
...
...
blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java
浏览文件 @
d51b91d9
...
...
@@ -181,6 +181,10 @@ public enum ConfigKeyEnum {
* 文章编辑器
*/
ARTICLE_EDITOR
(
"articleEditor"
),
/**
* TinyMCE API Key
*/
TINY_MCE_KEY
(
"tinyMCEKey"
),
/**
* 网站安装时间,默认为执行init_data.sql的时间
...
...
blog-core/src/main/java/com/zyd/blog/persistence/beans/BizArticle.java
浏览文件 @
d51b91d9
...
...
@@ -25,6 +25,7 @@ public class BizArticle extends AbstractDO {
private
Long
userId
;
private
String
coverImage
;
private
String
qrcodePath
;
@Deprecated
private
Boolean
isMarkdown
;
private
String
content
;
private
String
contentMd
;
...
...
@@ -37,6 +38,7 @@ public class BizArticle extends AbstractDO {
private
String
keywords
;
private
Boolean
comment
;
private
String
password
;
private
String
editorType
;
@Transient
private
Integer
lookCount
;
@Transient
...
...
blog-core/src/main/resources/mybatis/BizArticleMapper.xml
浏览文件 @
d51b91d9
...
...
@@ -17,6 +17,7 @@
<result
property=
"recommended"
jdbcType=
"BIT"
column=
"recommended"
/>
<result
property=
"original"
jdbcType=
"BIT"
column=
"original"
/>
<result
property=
"description"
jdbcType=
"VARCHAR"
column=
"description"
/>
<result
property=
"editorType"
jdbcType=
"VARCHAR"
column=
"editor_type"
/>
<result
property=
"keywords"
jdbcType=
"VARCHAR"
column=
"keywords"
/>
<result
property=
"createTime"
jdbcType=
"TIMESTAMP"
column=
"create_time"
/>
<result
property=
"updateTime"
jdbcType=
"TIMESTAMP"
column=
"update_time"
/>
...
...
@@ -55,6 +56,7 @@
a.description,
a.keywords,
a.`comment`,
a.`editor_type`,
a.`password`,
a.create_time,
a.update_time,
...
...
@@ -152,6 +154,7 @@
a.`status`,
a.recommended,
a.original,
a.editor_type,
a.description,
a.keywords,
a.`comment`,
...
...
@@ -218,6 +221,7 @@
a.`status`,
a.recommended,
a.original,
a.editor_type,
a.description,
a.keywords,
a.`comment`,
...
...
blog-web/src/main/resources/templates/layout/footer.ftl
浏览文件 @
d51b91d9
...
...
@@ -120,7 +120,7 @@
<li><a href="${config.siteUrl}/disclaimer" title="免责声明" data-toggle="tooltip" data-placement="bottom"><i class="fa fa-file-o fa-fw"></i>免责声明</a></li>
</ul>
</p>
<p>托管于<a href="https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=wylo59db" target="_blank" title="阿里云-为了无法计算的价值" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">阿里云</a> & <a href="https://portal.qiniu.com/signup?code=3l8yx2v0f21ci" target="_blank" title="七牛云-国内领先的企业级云服务商" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">七牛云</a><#if config.recordNumber!> · <a href="http
://www.miitbeian.gov.cn/publish/query/indexFirst.action
" target="_blank" title="查看备案信息" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">${config.recordNumber}</a></#if></p>
<p>托管于<a href="https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=wylo59db" target="_blank" title="阿里云-为了无法计算的价值" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">阿里云</a> & <a href="https://portal.qiniu.com/signup?code=3l8yx2v0f21ci" target="_blank" title="七牛云-国内领先的企业级云服务商" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">七牛云</a><#if config.recordNumber!> · <a href="http
s://beian.miit.gov.cn/#/Integrated/index
" target="_blank" title="查看备案信息" data-toggle="tooltip" data-placement="bottom" rel="external nofollow">${config.recordNumber}</a></#if></p>
</div>
<div class="col col-md-4"></div>
</div>
...
...
docs/db/update.sql
浏览文件 @
d51b91d9
...
...
@@ -33,3 +33,9 @@ INSERT INTO `dblog`.`sys_resources` VALUES (87, '新增广告', 'button', NULL,
INSERT
INTO
`dblog`
.
`sys_resources`
VALUES
(
88
,
'批量删除广告'
,
'button'
,
NULL
,
'bizAd:batchDelete'
,
86
,
3
,
0
,
1
,
NULL
,
now
(),
now
());
INSERT
INTO
`dblog`
.
`sys_resources`
VALUES
(
89
,
'编辑广告'
,
'button'
,
NULL
,
'bizAd:edit,bizAd:get'
,
86
,
4
,
0
,
1
,
NULL
,
now
(),
now
());
INSERT
INTO
`dblog`
.
`sys_resources`
VALUES
(
90
,
'删除广告'
,
'button'
,
NULL
,
'bizAd:delete'
,
86
,
5
,
0
,
1
,
NULL
,
now
(),
now
());
#
20211028
ALTER
TABLE
`dblog`
.
`biz_article`
ADD
COLUMN
`editor_type`
varchar
(
10
)
NULL
COMMENT
'当前文章适用的编辑器类型'
AFTER
`cover_image`
;
#
修改旧文章的编辑器类型
UPDATE
`dblog`
.
`biz_article`
SET
`editor_type`
=
'we'
WHERE
is_markdown
is
null
||
is_markdown
=
0
;
UPDATE
`dblog`
.
`biz_article`
SET
`editor_type`
=
'md'
WHERE
is_markdown
=
1
;
update.md
浏览文件 @
d51b91d9
...
...
@@ -3,6 +3,11 @@
----
### 2021-10-29
-
wangEditor 升级到 4.7.9
-
新增 TinyMCE 编辑器 (
[
#I4FOB0
](
https://gitee.com/yadong.zhang/DBlog/issues/I4FOB0
)
)
### 2021-10-27
-
**增加代码生成模块 `blog-codegen`,新业务支持一键生成所有代码**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录