在没有apikey的情况下,用tinyMCE与angular 6配合使用(免费)。[英] use tinyMCE with angular 6 without apikey (free)

本文是小编为大家收集整理的关于在没有apikey的情况下,用tinyMCE与angular 6配合使用(免费)。的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我试图使用Angular 6安装Tinymce.我正在 https:https://www.tiny.cloud/docs/integrations/angular2/.

一切正常,但是我必须有一个apikey才能使用Tinymce云.

我发现了错误:"此域未用Tinymce Cloud注册.开始免费试用以发现我们的高级云服务和Pro支持."

我想使用无apikey的自托管版本.

因此,如doc doc/intemations/angular2/#loadingtinymcebyyourself 我们可以托管tinymce.min.js以禁用apikey.

如何使用Angular 6正确添加Tinymce.min.js?

推荐答案

1)安装Angular 2+的Tinymce:

安装Tinymce Angular NPM模块

npm install @tinymce/tinymce-angular

导入 editormodule on app.module.ts

import { EditorModule } from '@tinymce/tinymce-angular';

添加 editormodule 在 app.module.ts

上导入到进口
imports: [
...,
EditorModule
]

2)主持Tinymce JS

安装Tinymce NPM模块:

npm install tinymce --save

angular.json上的导入样式

"styles": [
  ...,
  "node_modules/tinymce/skins/lightgray/skin.min.css",
  "node_modules/tinymce/skins/lightgray/content.min.css",
  "node_modules/tinymce/skins/lightgray/content.inline.min.css"
]

在angular.json

上导入脚本
"script": [
  ...,
  "node_modules/tinymce/tinymce.min.js",
  "node_modules/tinymce/themes/modern/theme.js"
]

3)在HTML文件上使用Tinymce

添加此代码以使用:

<editor [(ngModel)]="dataModel"></editor>

其他推荐答案

在这里.而不是用硬编码的目录添加CSS文件,而只需在angular.json中使用它:

 "assets": [
   { "glob": "**/*", "input": "node_modules/tinymce", "output": "/tinymce/" }
 ]

其他推荐答案

该组件只需在尝试通过该组件加载Tinymce之前就需要可用的Tinymce.如果没有Tinymce,则该组件试图从Tinymce云平台加载Tinymce.它试图从云中获取它的事实告诉我,Tinymce还没有.

您有加载Tinymce的选项.

文档头的Tinymce标签(Easy)

如果您在Web服务器上有Tinymce,则可以使用脚本标签通过index.html页面加载Tinymce.然后,当应用程序首次加载时,应用程序的所有方面都可以访问tinymce.

仅在需要时通过模块加载器加载底漆(中度难度)

您可以使用模块加载器将丁香糖加载到需要Tinymce的组件中.从理论上讲,您只有在某人需要时才加载Tinymce,但是这种方法肯定是更多的工作.

文档: https://wwww.tiny.cloud/DOCS/ADVANDACD/usage-with-module-loaders/

我应该使用哪一个? 这些都不是"正确的"或"错误"的方法 - 它们既可行,又取决于您的需求,都可以正常工作.

本文地址:https://www.itbaoku.cn/post/1937884.html

问题描述

I tried to install tinyMCE with angular 6. I am following the docs on https://www.tiny.cloud/docs/integrations/angular2/.

Everything OK but I must to have an apiKey to use the tinyMCE cloud.

I got the error : "This domain is not registered with TinyMCE Cloud. Start a free trial to discover our premium cloud services and pro support."

I want to use the self hosted version without apiKey.

So as explained on the doc https://www.tiny.cloud/docs/integrations/angular2/#loadingtinymcebyyourself we can hosting the tinymce.min.js to disable apiKey.

How to add tinymce.min.js properly with angular 6 ?

推荐答案

1) install tinymce for angular 2+ :

install tinymce angular npm module

npm install @tinymce/tinymce-angular

import EditorModule on app.module.ts

import { EditorModule } from '@tinymce/tinymce-angular';

add EditorModule to imports on app.module.ts

imports: [
...,
EditorModule
]

2) host the tinymce JS

install the tinymce npm module :

npm install tinymce --save

import styles on angular.json

"styles": [
  ...,
  "node_modules/tinymce/skins/lightgray/skin.min.css",
  "node_modules/tinymce/skins/lightgray/content.min.css",
  "node_modules/tinymce/skins/lightgray/content.inline.min.css"
]

import scripts on angular.json

"script": [
  ...,
  "node_modules/tinymce/tinymce.min.js",
  "node_modules/tinymce/themes/modern/theme.js"
]

3) use tinyMCE on HTML file

add this code to use :

<editor [(ngModel)]="dataModel"></editor>

其他推荐答案

The selected answer can be much more simplified following it here. Instead of adding the CSS files with their directories hard-coded, simply use this in angular.json instead:

 "assets": [
   { "glob": "**/*", "input": "node_modules/tinymce", "output": "/tinymce/" }
 ]

其他推荐答案

That component simply needs TinyMCE available before you try to load TinyMCE via the component. If TinyMCE is not there the component tries to load TinyMCE from the TinyMCE Cloud platform. The fact that its trying to get it from the Cloud tells me TinyMCE was not already there.

You have options for loading TinyMCE.

TinyMCE tag in head of your document (Easy)

If you have TinyMCE on your web server you can just use a script tag to load TinyMCE via your index.html page. All aspects of your app would then have access to TinyMCE as its loaded when the app first loads

Load TinyMCE via Module Loaders only when needed (Moderate Difficulty)

You can use a module loader to load TinyMCE in the component(s) that need TinyMCE. In theory you then only load TinyMCE when someone could need it but this approach is certainly more work to setup.

Documentation: https://www.tiny.cloud/docs/advanced/usage-with-module-loaders/

Which of these should I use? Neither of these is the "right" or "wrong" approach - they are both viable and depending on your needs either can work just fine.