mirror of
https://gitee.com/ulthon/ulthon_information.git
synced 2026-03-03 16:24:28 +08:00
开始优化标点,有问题;
This commit is contained in:
@@ -68,6 +68,10 @@
|
||||
min-height: 500px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#settle-content-mark {
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@@ -94,8 +98,11 @@
|
||||
<div id="editor-text-area"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content-state" style="height: 30px;line-height: 30px;padding-left: 15px;border-top: 1px solid #e8e8e8;color: #666;">
|
||||
内容变动自动提交
|
||||
<div style="height: 30px;line-height: 30px;padding-left: 15px;border-top: 1px solid #e8e8e8;color: #666;">
|
||||
<span id="content-state">内容变动自动提交</span>
|
||||
<span id="settle-content-mark">
|
||||
智能优化标点
|
||||
</span>
|
||||
</div>
|
||||
<div id="content-data" style="display: none;">{:rawurlencode($post->content_html)}</div>
|
||||
</div>
|
||||
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user