diff --git a/view/admin/post/edit_content.html b/view/admin/post/edit_content.html
index a3d5e2a..752bddb 100644
--- a/view/admin/post/edit_content.html
+++ b/view/admin/post/edit_content.html
@@ -68,6 +68,10 @@
min-height: 500px;
margin-top: 20px;
}
+
+ #settle-content-mark {
+ cursor: pointer;
+ }
@@ -94,8 +98,11 @@
- 内容变动自动提交
+
+ 内容变动自动提交
+
+ 智能优化标点
+
{:rawurlencode($post->content_html)}
@@ -162,7 +169,6 @@
editorConfig.customPaste = function (editor, event) {
var pasteStr = event.clipboardData.getData('text/html');
-
//1,匹配出图片img标签(即匹配出所有图片),过滤其他不需要的字符
//2.从匹配出来的结果(img标签中)循环匹配出图片地址(即src属性)
@@ -245,6 +251,56 @@
}, 300);
+ $('#settle-content-mark').click(function () {
+ var content = editor.getHtml();
+ var contentDom = $(content);
+
+ var newContentDom = [];
+ contentDom.each(function (index, elem) {
+ var tagName = elem.tagName;
+
+ var settleTagList = [
+ 'P',
+ 'H1',
+ 'H2',
+ 'H3',
+ 'H4',
+ 'UL',
+ ];
+ if (settleTagList.indexOf(tagName) < 0) {
+ newContentDom.push(elem)
+ return true;
+ }
+
+ var html = $(elem).html();
+ html = html.replaceAll(',', ',');
+ html = html.replaceAll('.', '。');
+ html = html.replaceAll('!', '!');
+ html = html.replaceAll(':', ';');
+ html = html.replaceAll(':', ':');
+ html = html.replaceAll('?', '?');
+ // html = html.replaceAll('<', '《');
+ // html = html.replaceAll('>', '》');
+ html = html.replaceAll('/', '、');
+
+ $(elem).html(html)
+
+ newContentDom.push(elem)
+
+
+ })
+
+ editor.clear()
+
+ newContentDom.forEach(elem => {
+ var outerHTML = $(elem).prop('outerHTML');
+ console.log(outerHTML);
+ editor.dangerouslyInsertHtml(outerHTML)
+ });
+
+ })
+
+
// 点击空白处 focus 编辑器
document.getElementById('editor-text-area').addEventListener('click', e => {
if (e.target.id === 'editor-text-area') {