避免 TinyMCE 保存 <html> 标签

Avoid TinyMCE saving <html> tags

即使我的文本区域为空,我的编辑器也会保存完整的 HTML 结构,这是我在数据库中保存文本区域为空的 post 时的结果:

<!DOCTYPE html>
<html>
<head>
</head>
<body>

</body>
</html>

它应该是 null 即使我的文本区域中有内容仍然这个 HTML 结构在我的数据库中

代码

text-area

<textarea class="form-control editor" name="description" id="description" cols="30" rows="10"></textarea>

script

<script>
  var editor_config = {
    path_absolute : "/",
    selector: "textarea.editor",
    plugins: [
      "advlist autolink lists link image charmap print preview hr anchor pagebreak",
      "searchreplace wordcount visualblocks visualchars code fullscreen",
      "insertdatetime media nonbreaking save table contextmenu directionality",
      "emoticons template paste textcolor colorpicker textpattern codesample",
      "fullpage toc tinymcespellchecker imagetools help"
    ],
    toolbar: "insertfile undo redo | styleselect | bold italic strikethrough | alignleft aligncenter alignright alignjustify | ltr rtl | bullist numlist outdent indent removeformat formatselect| link image media | emoticons charmap | code codesample | forecolor backcolor",
    external_plugins: { "nanospell": "http://xxxxxxxx/js/tinymce/plugins/nanospell/plugin.js" },
    nanospell_server:"php",
    browser_spellcheck: true,
    relative_urls: true,
    remove_script_host: false,
    branding: false,
    file_browser_callback : function(field_name, url, type, win) {
      var x = window.innerWidth || document.documentElement.clientWidth || document.getElementsByTagName('body')[0].clientWidth;
      var y = window.innerHeight|| document.documentElement.clientHeight|| document.getElementsByTagName('body')[0].clientHeight;

      var cmsURL = editor_config.path_absolute + 'laravel-filemanager?field_name=' + field_name;
      if (type == 'image') {
        cmsURL = cmsURL + "&type=Images";
      } else {
        cmsURL = cmsURL + "&type=Files";
      }

      tinymce.activeEditor.windowManager.open({
        file: '<?= route('elfinder.tinymce4') ?>',// use an absolute path!
        title: 'xxxxxx file manager',
        width: 900,
        height: 450,
        resizable: 'yes'
      }, {
        setUrl: function (url) {
          win.document.getElementById(field_name).value = url;
        }
      });
    }
  };

  tinymce.init(editor_config);
</script>

问:

如何避免在我的文本区域中出现这种 HTML 结构? I just need my content tags and not HTML,Head,Body tags

您正在使用 fullpage 插件,它使 TinyMCE 可以处理整个 HTML 文档:

https://www.tinymce.com/docs/plugins/fullpage/

如果您不想让 TinyMCE 管理整个 HTML 文档,请不要加载该插件。