WIN-2308041133\Administrator 7 months ago
parent
commit
10c8170547

+ 12 - 3
app/admin/view/article/article/create.php

@@ -97,7 +97,10 @@
                <div class="form-group">
                    <div class="col-md-12">
                        <label style="color:#aaa">文章内容</label>
-                       <textarea type="text/plain" id="myEditor" style="width:100%;">{$news['content']}</textarea>
+<!--                       <textarea type="text/plain" id="myEditor" style="width:100%;">{$news['content']}</textarea>-->
+                       <textarea type="text/plain" id="myEditor" style="width:100%;">
+    {php}echo htmlspecialchars_decode($news['content'], ENT_QUOTES | ENT_HTML5);{/php}
+</textarea>
                    </div>
                </div>
                <div class="form-group">
@@ -231,9 +234,15 @@
                 list.title = $('#title').val();/* 标题 */
                 list.author = $('#author').val();/* 作者 */
                 list.image_input = $('#image_input').val();/* 图片 */
-                list.content = UM.getEditor('myEditor').body.innerHTML; // 直接获取原始HTML
-                console.log("原始内容:", list.content);
                 // list.content = getContent();/* 内容 */
+                // list.content = UM.getEditor('myEditor').body.innerHTML;
+                list.content = list.content
+                    .replace(/\\"/g, '"')
+                    .replace(/\\\//g, '/')
+                    .replace(/\\'/g, "'")
+                    .replace(/\\\\/g, "\\")
+                    .replace(/&quot;/g, '"')
+                    .replace(/&amp;/g, '&');
                 list.synopsis = $('#synopsis').val();/* 简介 */
                 list.url = $('#url').val();/* 原文链接 */
                 list.id = $('#id').val();/* 原文链接 */

+ 7 - 5
public/system/plug/umeditor/umeditor.config.js

@@ -153,11 +153,12 @@ etpl.config({
             '| justifyleft justifycenter justifyright justifyjustify |',
             'link unlink | emotion image video  | map',
             '| horizontal print preview fullscreen', 'drafts', 'formula'
-        ]
-        ,escape: false, // 关闭HTML转义功能 ★ 核心修改
-        allowDivTransToP: false, // 防止div转p导致结构变化
-        autoClearinitialContent: true // 清除初始占位内容
-
+        ],
+        escape: false,  // 关闭自动转义 ★核心
+        allowDivTransToP: false,
+        autoClearinitialContent: true,
+        // 新增配置:禁用自动转换引号
+        autoTransWord: false
         //语言配置项,默认是zh-cn。有需要的话也可以使用如下这样的方式来自动多语言切换,当然,前提条件是lang文件夹下存在对应的语言文件:
         //lang值也可以通过自动获取 (navigator.language||navigator.browserLanguage ||navigator.userLanguage).toLowerCase()
         //,lang:"zh-cn"
@@ -329,4 +330,5 @@ etpl.config({
 			video:  ['autoplay', 'controls', 'loop', 'preload', 'src', 'height', 'width', 'style', 'class', 'id']
         }
     };
+    var um = UM.getEditor('myEditor');
 })();