[英]Integrate TinyMCE 5 in Vue 3 with external plugin
I want to integrate TinyMCE 5 into Vue 3, while allowing for the usage of external plugins, in my case the TinyMCE MathJax Plugin .我想将 TinyMCE 5 集成到 Vue 3 中,同时允许使用外部插件,在我的例子中是TinyMCE MathJax 插件。
TinyMCE and all the plugins are self-hosted. TinyMCE,所有插件都是自托管的。 With this StackOverflow Post I managed to integrate the editor.
通过这篇StackOverflow 帖子,我设法集成了编辑器。 Still, I cannot get the external plugin to work solely by following the usage instructions .
尽管如此,我仍然无法仅按照使用说明使外部插件正常工作。 The respective button does not appear in the toolbar.
相应的按钮不会出现在工具栏中。
Instead, the console logs The resource from "http://localhost:8080/node_modules/@dimakorotkov/tinymce-mathjax/plugin.min.js" was blocked due to MIME type mismatch ("text/html", X-Content-Type-Options: nosniff)
.相反,控制台记录
The resource from "http://localhost:8080/node_modules/@dimakorotkov/tinymce-mathjax/plugin.min.js" was blocked due to MIME type mismatch ("text/html", X-Content-Type-Options: nosniff)
。 This message is also logged for other default TinyMCE plugins and even the whole TinyMCE editor ( "http://localhost:8080/node_modules/tinymce/tinymce.min.js"
)?其他默认 TinyMCE 插件甚至整个 TinyMCE 编辑器(
"http://localhost:8080/node_modules/tinymce/tinymce.min.js"
)也会记录此消息?
I seem to do pretty much what this blog post suggests (I just don't copy the plugin somewhere else).我似乎做了很多这篇博文所建议的事情(我只是不将插件复制到其他地方)。
How can I integrate external plugins like this one?我怎样才能集成这样的外部插件?
Editor.vue (Note to import the TinyMCE JS file in the page header ) Editor.vue (注意在header页面导入TinyMCE的JS文件)
<template>
<div>
<h1>Editor Test TinyMCE</h1>
<Editor
:init="{
external_plugins: {
'mathjax': '../@dimakorotkov/tinymce-mathjax/plugin.min.js',
},
mathjax: {
lib: '../mathjax/es5/tex-mml-chtml.js',
},
toolbar: 'mathjax',
}"
/>
</div>
</template>
<script setup lang="ts">
/**
* Uses local TinyMCE instance, prohibits loading of cloud-hosted instance.
* https://stackoverflow.com/questions/67425439/tinymce-vue-integration-selfhosted
*/
import 'tinymce/tinymce'
import 'tinymce/plugins/table'
import 'tinymce/themes/silver'
import 'tinymce/icons/default'
import 'tinymce/skins/ui/oxide/skin.css'
/**
* Import Editor component
*/
import Editor from '@tinymce/tinymce-vue'
</script>
Facing a similar issue and the blog post you linked provided the solution: move the plugin files to your dist or public folder, then provide the relative URL from the public folder within external_plugins.面对类似的问题,您链接的博客文章提供了解决方案:将插件文件移动到您的 dist 或公共文件夹,然后从 external_plugins 中的公共文件夹提供相对 URL。
So in your case (after moving the plugin files) it would read:因此,在您的情况下(移动插件文件后),它将显示为:
external_plugins: {
'mathjax': '/public/tinymce-mathjax/plugin.min.js',
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.