TINYMCE Editor External Templates: Uncaught TypeError: Cannot read property 'indexOf' of undefined

TINYMCE Editor External Templates: Uncaught TypeError: Cannot read property 'indexOf' of undefined

我正在使用 TINYMCE Editor 版本 4.8.2 (2018-08-09) 并尝试在列表的 .html 中添加一些预建模板。我在插件目录中安装了模板插件,并在 init-tinymce.js 中启动它,如下所示。

tinymce.init({
/* replace textarea having class .tinymce with tinymce editor */
selector: "textarea",   

/* plugin */
plugins: [
    "template"
],

/* toolbar */
toolbar: "template",

/* templates */
templates: [
    {
      title : "Default Template 1",
      src : "tinymce-templates/template1.html",
      description : "Default Template"
    },
    {
        title : "Default Template 2",
        src : "tinymce-templates/template2.html",
        description : "Default Template"
    }
]

});

现在,当我尝试打开并插入我添加的模板时,我可以在下拉列表中看到我的两个模板,但是当我看不到预览时。在检查时,我发现下面分享了这个错误。

Uncaught TypeError: Cannot read property 'indexOf' of undefined           plugin.min.js:1 
    at S (plugin.min.js:1)
    at i.onselect (plugin.min.js:1)
    at Vg.c.fire (tinymce.min.js:2)
    at i.fire (theme.min.js:1)
    at w (plugin.min.js:1)
    at plugin.min.js:1
    at i.<anonymous> (plugin.min.js:1)
    at Vg.c.fire (tinymce.min.js:2)
    at i.fire (theme.min.js:1)
    at HTMLDivElement.o (theme.min.js:1)
S   @   plugin.min.js:1
onselect    @   plugin.min.js:1
Vg.c.fire   @   tinymce.min.js:2
fire    @   theme.min.js:1
w   @   plugin.min.js:1
(anonymous) @   plugin.min.js:1
(anonymous) @   plugin.min.js:1
Vg.c.fire   @   tinymce.min.js:2
fire    @   theme.min.js:1
o   @   theme.min.js:1
C   @   tinymce.min.js:2
d

我的模板如下所示...

<div class="mceTmpl">
  <div class="row">
    <div class="box">
      <div class="col-lg-12">
        <hr>
        <h2 class="intro-text text-center">Build a website
          <strong>worth visiting</strong>
        </h2>
        <hr>
        <hr class="visible-xs">
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc placerat diam quis nisl vestibulum dignissim. In hac habitasse platea dictumst. Interdum et malesuada fames ac ante ipsum primis in faucibus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.</p>
      </div>
    </div>
  </div>
</div>

我相信你有 src 属性,正确的属性是 url。根据我看到的文档:

This option lets you specify a predefined list of templates to be inserted by the user into the editable area. It is structured as an array with each item having a title, description and content/url.