diff --git a/jpress-web/src/main/webapp/static/admin/js/jpressadmin.js b/jpress-web/src/main/webapp/static/admin/js/jpressadmin.js
index f92c7313ae7da30e4d84d633bfbb2748e1497fad..e979256317e6ae5e0105871a4b012d0e3871ace5 100755
--- a/jpress-web/src/main/webapp/static/admin/js/jpressadmin.js
+++ b/jpress-web/src/main/webapp/static/admin/js/jpressadmin.js
@@ -144,8 +144,8 @@ function initEditor(editor, height, type) {
height = height || 467;
type = type || 'html'; //默认用ckeditor
- if (type == 'html') {
- return initCkEdtior(editor, height);
+ if (type == 'html' || type == 'html-source') {
+ return initCkEdtior(editor, height, type);
} else if (type == 'markdown') {
return initMarkdownEditor(editor, height);
}
@@ -176,7 +176,7 @@ function doListenerCtrlsAndCommands(func) {
});
}
-function initCkEdtior(editor, height) {
+function initCkEdtior(editor, height,type) {
CKEDITOR.config.toolbar =
[
['Bold', 'Italic', 'Underline', 'Strike', 'RemoveFormat'],
@@ -205,6 +205,11 @@ function initCkEdtior(editor, height) {
extraPlugins: 'entities,codesnippet,uploadimage,flash,image,wordcount,notification,html5audio,html5video,widget,widgetselection,clipboard,lineutils',
codeSnippet_theme: 'monokai_sublime',
height: height,
+ allowedContent: true, // 保存内容包含javascript、style标签的时候,数据库中有javascript、style标签 ,
+ pasteFromWordRemoveFontStyles: false, // 保证word导入格式
+ pasteFromWordRemoveStyles: false, // 保证word导入格式
+ forcePasteAsPlainText: false, // 不强制复制来的内容去除格式
+ startupMode: (type == 'html-source') ? 'source' : 'wysiwyg', // 源码模式:source、 所见所得模式:wysiwyg
uploadUrl: jpress.cpath + '/commons/ckeditor/upload',
imageUploadUrl: jpress.cpath + '/commons/ckeditor/upload',
filebrowserUploadUrl: jpress.cpath + '/commons/ckeditor/upload',
@@ -223,10 +228,11 @@ function initCkEdtior(editor, height) {
ds && ds();
}
});
+ // 编辑组件准备完毕时,加载全局事件
+ var der = window.doEditorReady;
+ der && der(ed);
});
-
-
ed.on("dialogShow", function (event) {
// 方便调试
_dialogShowEvent = event;
diff --git a/module-page/module-page-web/src/main/webapp/WEB-INF/views/admin/page/page_write.html b/module-page/module-page-web/src/main/webapp/WEB-INF/views/admin/page/page_write.html
index c63de411823f2881307808adc6994d297e3c2efe..391d9fe157c7c8cd12aa42e83d33447544c0524b 100755
--- a/module-page/module-page-web/src/main/webapp/WEB-INF/views/admin/page/page_write.html
+++ b/module-page/module-page-web/src/main/webapp/WEB-INF/views/admin/page/page_write.html
@@ -27,6 +27,16 @@
toastr.success('内容保存成功。');
});
}
+ // 全局函数,在CKEditor组件初始化完成后,调用此方法
+ window.doEditorReady = function (editor) {
+ // 切换到源码的按钮,增加点击事件,保存当前组件是否在源码编辑框
+ $(".cke_button__source").on("click", function () {
+ setTimeout(function () {
+ var mode = editor.mode == "source"?'html-source':"html";
+ $("#editModeId").val(mode);
+ }, 300);
+ });
+ }
$("#removeThumbnail").on("click", function () {
$("#thumbnail").attr("src", "#(CPATH)/static/commons/img/nothumbnail.jpg");
@@ -38,7 +48,7 @@
function doChangeEditor(id) {
if (confirm('确定要切换编辑器吗?切换可能出现前台渲染内容缺失的问题。')) {
- var changeMode = editMode == "html" ? "markdown" : "html";
+ var changeMode = editMode == "markdown" ? "html" : "markdown";
if (id != '0') {
ajaxGet('#(CPATH)/admin/page/doChangeEditMode?id=' + id + "&mode=" + changeMode);
} else {
@@ -113,10 +123,10 @@
#end
- #if(editMode && editMode == 'html')
- 使用 markdown 编辑
- #else
+ #if(editMode && editMode == 'markdown')
可视化编辑
+ #else
+ 使用 markdown 编辑
#end