避免使用TinyMCE保存标签

时间:2018-04-07 14:52:03

标签: html database tinymce-4

我的编辑器保存完整的HTML结构,即使我的文本区域为空,这是我在数据库中保存带空文本区域的帖子时的内容:

<!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

1 个答案:

答案 0 :(得分:0)

您正在使用导致TinyMCE处理整个HTML文档的fullpage插件:

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

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