0

我为我的客户接管了一个用非常旧的代码编写的网站。但是,我认为迁移到 tiny mce 5 不会有问题。在客户端的编辑 php 文件中,代码为:

<script src="//cdn.tinymce.com/4/tinymce.min.js"></script>
<script type="text/javascript">
  tinymce.init({
    selector: 'textarea',
    theme: 'modern',
    plugins: [
      'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
      'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
      'save table contextmenu directionality template paste textcolor'
    ],
    //content_css: 'css/content.css',
    menubar: 'edit view format',
    style_formats: [
    {title: 'Blocks', items: [
      {title: 'Paragraph', format: 'p'},
    ]},
    {title: 'Headers', items: [
      {title: 'Header 1', format: 'h1'},
      {title: 'Header 2', format: 'h2'},
      {title: 'Header 3', format: 'h3'},
      {title: 'Header 4', format: 'h4'},
      {title: 'Header 5', format: 'h5'},
      {title: 'Header 6', format: 'h6'}
    ]},
    {title: 'Alignment', items: [
      {title: 'Left', icon: 'alignleft', format: 'alignleft'},
      {title: 'Center', icon: 'aligncenter', format: 'aligncenter'},
      {title: 'Right', icon: 'alignright', format: 'alignright'},
      {title: 'Justify', icon: 'alignjustify', format: 'alignjustify'}
    ]}
  ],
    toolbar: 'removeformat | bold italic | bullist numlist outdent indent | link anchor | nonbreaking charmap hr | print preview fullpage | code'
  });
  </script>

现在,为了迁移到 5,我更新为:

<script src="//cdn.tiny.cloud/1/my api key here/tinymce/5/tinymce.min.js" referrerpolicy="origin"></script>
<script type="text/javascript">
  tinymce.init({
    selector: 'textarea',
    theme: 'modern',
    plugins: [
      'advlist autolink link image lists charmap print preview hr anchor pagebreak spellchecker',
      'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
      'save table contextmenu directionality template paste textcolor'
    ],
    //content_css: 'css/content.css',
    menubar: 'edit view format',
    style_formats: [
    {title: 'Blocks', items: [
      {title: 'Paragraph', format: 'p'},
    ]},
    {title: 'Headers', items: [
      {title: 'Header 1', format: 'h1'},
      {title: 'Header 2', format: 'h2'},
      {title: 'Header 3', format: 'h3'},
      {title: 'Header 4', format: 'h4'},
      {title: 'Header 5', format: 'h5'},
      {title: 'Header 6', format: 'h6'}
    ]},
    {title: 'Alignment', items: [
      {title: 'Left', icon: 'alignleft', format: 'alignleft'},
      {title: 'Center', icon: 'aligncenter', format: 'aligncenter'},
      {title: 'Right', icon: 'alignright', format: 'alignright'},
      {title: 'Justify', icon: 'alignjustify', format: 'alignjustify'}
    ]}
  ],
    toolbar: 'removeformat | bold italic | bullist numlist outdent indent | link anchor | nonbreaking charmap hr | print preview fullpage | code'
  });
  </script>

但是现在重新加载页面后,在清除我的站点缓存后,我收到 404 错误:“加载资源失败:服务器响应状态为 404 ()”

任何帮助将不胜感激。谢谢!

4

1 回答 1

0

什么资源导致了 404?查看您收到的完整错误消息将非常有用。

我的猜测是问题出在配置中的这一行:

theme: 'modern'

TinyMCE 5 中没有现代主题,因此尝试加载该主题可能会导致错误。

以下是从 TinyMCE 4 迁移到 TinyMCE 5 的完整文档: https ://www.tiny.cloud/docs/migration-from-4x/

于 2020-12-15T22:06:30.950 回答