javascript 将 HTML 模板插入 tinymce 4 编辑器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20647629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 18:57:06  来源:igfitidea点击:

Inserting HTML template into tinymce 4 editor

javascripthtmltemplatestinymce-4

提问by Hyman

I have a HTML templates on one side. On the other hand, I have TinyMce Editor 4+ version. I have created a HTMl page with buttons(with name "Use Template") for each of the template I will be using.

我在一侧有一个 HTML 模板。另一方面,我有 TinyMce Editor 4+ 版本。我为我将使用的每个模板创建了一个带有按钮(名称为“使用模板”)的 HTMl 页面。

Basically, I want a user to click a corresponding template button and that should Insert the HTML template into the tinyMCE editor.

基本上,我希望用户单击相应的模板按钮,然后将 HTML 模板插入到 tinyMCE 编辑器中。

Could anyone give me some ideas how should I start doing this ? I found most of the people are searching online for how to insert HTML templates from the inbuilt option of "TinyMce" editor which I don't want.

谁能给我一些想法我应该如何开始这样做?我发现大多数人都在网上搜索如何从我不想要的“TinyMce”编辑器的内置选项中插入 HTML 模板。

Please provide your inputs.

请提供您的意见。

MORE CLARIFICATIONS

更多说明

I have a HTML page (say PAGE1) with several buttons named "USE TEMPLATE". So, basically, when a user clicks on "Use Template" button, he should be directed to next page(say PAGE2). Page 2 contains an email editor namely TinyMCE. The corresponding template for which the user has clicked the button must be inserted into the TinyMCE editor. I would like to know how should I proceed in this case?

我有一个 HTML 页面(比如 PAGE1),其中有几个名为“USE TEMPLATE”的按钮。所以,基本上,当用户点击“使用模板”按钮时,他应该被定向到下一页(比如 PAGE2)。第 2 页包含一个电子邮件编辑器,即 TinyMCE。用户单击按钮的相应模板必须插入到 TinyMCE 编辑器中。我想知道在这种情况下我应该如何处理?

Please don't confuse this with the INSERT --> INSERT TEMPLATE OPTION of the tinyMce. I know how to do this.

请不要将此与tinyMce 的INSERT --> INSERT TEMPLATE OPTION 混淆。我知道该怎么做。

回答by Zac

If I am not wrong, make sure you tinymce has /tinymce/plugins/template:

如果我没有错,请确保您的 tinymce 有 /tinymce/plugins/template:

tinymce.init({
    plugins: "xx,xxx,xxx,....,template",//<-- please add template as a plugin, also make sure you have [template] plugin in your tinymce/plugins
    templates: [ 
        {title: 'Some title 2', description: 'Some desc 2', url: 'development.html'} //remember put full path to url, and also the url can be a server side script file, such as: my_template.php?t=1
    ]
});

Reading: https://www.tinymce.com/docs/plugins/template/

阅读:https: //www.tinymce.com/docs/plugins/template/