Giter Site home page Giter Site logo

strapi-plugin-tinymce's Introduction

Strapi plugin TinyMCE

Replaces the default Strapi WYSIWYG editor with a customized build of TinyMCE editor.

👋 Intro

✨ Key features

  • Anchor: Add an anchor/bookmark button to the toolbar that inserts an anchor at the editor’s cursor insertion point.
  • Autolink: Create hyperlinks automatically when a user inputs a valid and complete URL.
  • Autoresize: Resize the editor automatically to the content inside it, and prevent the editor from expanding infinitely.
  • Code: Add a toolbar button that allows a user to edit the HTML code hidden by the WYSIWYG view.
  • Code sample: Insert and embed syntax color highlighted code snippets into the editable area.

And much more ! List of all features.

🔧 Installation

Inside your Strapi app, add the package:

With npm:

npm install @sklinet/strapi-plugin-tinymce

With yarn:

yarn add @sklinet/strapi-plugin-tinymce

In config/plugins.js file add:

tinymce:{
    enabled:true
};

If you do not yet have this file, then create and add:

module.exports = () => ({
    tinymce:{
      enabled:true
    };
})

You will also have to update strapi::security middleware in your middlewares.js file in config folder. If you didn't update this file yet, then replace "strapi::security" with following code (object)

//middlewares.js

 {
    name: "strapi::security",
    config: {
      contentSecurityPolicy: {
        useDefaults: true,  
        directives: {
          "script-src": ["'self'", "*.tinymce.com", "*.tiny.cloud", "https:"],
          "connect-src": ["'self'", "*.tinymce.com", "*.tiny.cloud", "blob:", "*.strapi.io"],
          "img-src": [
            "'self'",
            "*.tinymce.com",
            "*.tiny.cloud",
            "data:",
            "blob:",
            "dl.airtable.com",
            "strapi.io",
            "s3.amazonaws.com",
            "cdn.jsdelivr.net",
          ],
          "style-src": [
            "'self'",
            "'unsafe-inline'",
            "*.tinymce.com",
            "*.tiny.cloud",
          ],
          "font-src": ["'self'", "*.tinymce.com", "*.tiny.cloud"],
        },
        upgradeInsecureRequests: null,
      },
    },
  },

Then run build:

npm run build

or

yarn build

After starting your project please add API key for your TinyMCE editor in admin panel in settings/tinymce/configuration

If TinyMCE editor doesn't appear in your richtext field, please check your console for any hints, you might have incorrectly set your middlewares.

⚙️ Configuration

TinyMCE outputFormat should be defined in config.editor, and init object should be defined in config.editor.editorConfig field in plugins.js file.

⚠️ plugins.js not plugin.js ⚠️

plugins.js file should be placed in config folder.

Learn more about configuration from official documentation.

Default configuration:

// plugins.js
module.exports = ({ env }) => ({
    tinymce: {
        enabled: true,
        config: {
            editor: {
                outputFormat: "html",
                editorConfig: {
                    language: "sk",
                    height: 500,
                    menubar: false,
                    extended_valid_elements: "span, img, small",
                    forced_root_block: "",
                    convert_urls: false,
                    entity_encoding: "raw",
                    plugins:
                        "advlist autolink lists link image charmap preview anchor \
                        searchreplace visualblocks code fullscreen table emoticons nonbreaking \
                        insertdatetime media table code help wordcount",
                    toolbar:
                        "undo redo | styles | bold italic forecolor backcolor | \
                        alignleft aligncenter alignright alignjustify | \
                        media table emoticons visualblocks code|\
                        nonbreaking bullist numlist outdent indent | removeformat | help",
                    style_formats: [
                        {
                            title: "Headings",
                            items: [
                                { title: "h1", block: "h1" },
                                { title: "h2", block: "h2" },
                                { title: "h3", block: "h3" },
                                { title: "h4", block: "h4" },
                                { title: "h5", block: "h5" },
                                { title: "h6", block: "h6" },
                            ],
                        },

                        {
                            title: "Text",
                            items: [
                                { title: "Paragraph", block: "p" },
                                {
                                    title: "Paragraph with small letters",
                                    block: "small",
                                },
                            ],
                        },
                    ],
                },
            },
        },
    },
});

⚠️ Requirements

Strapi v4.x.x+

Node 14 - 16

Tested on v4.3.4

strapi-plugin-tinymce's People

Contributors

jbednar97 avatar sklico avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

strapi-plugin-tinymce's Issues

Cannot assign to 'current' because it is a read-only property

Hi there,

I'm trying to add the package to my strapi install, but get the above error when I build (immediately following the install).

I'm using Strapi 4.3.8 with strapi-plugin-package 1.0.0.
Node is 16.17.0 and npm is 8.15.0.

I've cleared .cache folder and rebuilt, but still problem appears.

It seems to be due to a ref being assigned a null. This can maybe be avoided by using 'string | null' or similar as the type for that ref.

[Media library] Upload image to media library by "drag on drop" or "ctrl v"

Hi I didn't find any solution to use default media library upload by some event such as drag on drop or ctrl v when we copy some image we store it as blob and maybe there are any solution to fix it. It is be better if we can use default uploads and after copied we save it to uploads and use link from upload such as <img src="/uploads/[name].[format] />

TinyMCE doesn't show up

Hello!

I'm using Strapi 4.4.0 on Node v14.20

I've installed the plugin, ran yarn build and set the API key in the configuration page, but I'm greeted with the following:

image

Also, my config/plugins.ts file looks like so:

module.exports = ({ env }) => ({
    tinymce: {
        enabled: true,
    },
    // other plugins

});

There are no info in the server console, and no error (related) in the browser console, so I don't really know where I should go from there... Any suggestion?

Thank you in advance

[Video] Handle video from media library

Hi, I have a question about media, can we add some changes and handle video types from media library? I want to add to content a video from media library, but I didn't find some handlers for it, we handle onlu img types, thanks

Textbox doesnot open

Bug report

Required System information

  • Node.js version: 18.18.2
  • NPM version: 9.8.1
  • Strapi version: 4.19.0
  • Database: mysql
  • Operating system: Windows
  • Is your project Javascript or Typescript: Typescript
  • @sklinet/strapi-plugin-tinymce: 1.0.7

Describe the bug

The textboxes don't open neither locally nor in production mode

Steps to reproduce the behavior

  1. Create a Rich text (Markdown)
  2. go to Content Manager and check it
  3. It never shows textbox
  4. Uninstall "@sklinet/strapi-plugin-tinymce" textbox works fine

Expected behavior

I want to see the textbox field opened, I have tried in the browser without any extension, and even in macos same issue

Screenshots

image

Some plugins cannot load

Hello (again)!

I've set my configuration as follows:

tinymce: {
    enabled: true,
    config: {
        editor: {
            outputFormat: 'html',
            editorConfig: {
                menubar: false,
                forced_root_block: '',
                extended_valid_elements: 'span, img, div, section',
                plugins: [
                    "advlist autolink lists link image charmap print preview anchor",
                    "searchreplace visualblocks code fullscreen",
                    "table nonbreaking",
                    "insertdatetime media table paste code wordcount",
                ],
                toolbar:
                    "undo redo | styleselect | bold italic forecolor backcolor | \
                    alignleft aligncenter alignright alignjustify | \
                    table visualblocks |\
                    nonbreaking bullist numlist | removeformat code",
            }
        }
    }
}, 

So, excepted a few elements, it's the default configuration from your documentation. However, I noticed 2 problems:

The following extensions cannot load :

  • table
  • visualblock
  • code
  • fullscreen
  • insertdatetime
  • bulllist / numlist

When looking at the console, I see lots of 404 errors on the cdn.tiny.cloud, and the messages:

Failed to load plugin: advlist autolink lists link image charmap print preview anchor from url plugins/advlist autolink lists link image charmap print preview anchor/plugin.min.js

and

Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' *.tinymce.com *.tiny.cloud https:". Either the 'unsafe-inline' keyword, a hash ('sha256-O54ofw+GT0llr7Stt8/ICH/2tWUzm7YKv4Y/4GwwnY8='), or a nonce ('nonce-...') is required to enable inline execution.

Please tell me if you need more infos

Initial api key from .env variable

Hi I have a question about apiKey could we initialize it from env varibale such as by config, now we can it by admin panel, maybe we can it by config?

strapi-plugin-tinymce and Typescript

When I use @sklinet/strapi-plugin-tinymce 1.0.4 with Strapi 4.4.5 like described on the doc page he tells me

file: './.cache/admin/src/tsconfig.json',
message: `TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["../../../src/admin/","../../../src///admin/src/"]' and 'exclude' paths were '["node_modules","**/.test.js",".js"]'.

I have created ./src/index.ts

export default {
  register(/*{ strapi }*/) {},
  bootstrap(/*{ strapi }*/) {},
};

but it does not help.

Tiny Editor API KEY issue - Strapi

I have Tiny Editor's API key.

Where I put the API key of the tiny editor. I am getting this error(image attached). due to this error, I can not able to use Editor.

Anyone can Help!

I have attached package.json and Screenshot.

Node version - 18.17.0
Starpi version - 4.20.0

package.json :
{
"name": "cms",
"private": true,
"version": "0.1.0",
"description": "A Strapi application",
"scripts": {
"develop": "strapi develop",
"start": "strapi start",
"build": "strapi build",
"strapi": "strapi"
},
"dependencies": {
"@ckeditor/strapi-plugin-ckeditor": "^0.0.11",
"@sklinet/strapi-plugin-tinymce": "^1.0.9",
"@strapi/plugin-cloud": "4.20.0",
"@strapi/plugin-graphql": "^4.20.0",
"@strapi/plugin-i18n": "4.20.0",
"@strapi/plugin-users-permissions": "4.20.0",
"@strapi/provider-upload-aws-s3": "^4.24.0",
"@strapi/strapi": "4.20.0",
"better-sqlite3": "8.6.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-router-dom": "5.3.4",
"strapi-plugin-publisher": "^1.5.7",
"strapi-plugin-tagsinput": "^1.0.1",
"styled-components": "5.3.3"
},
"author": {
"name": "A Strapi developer"
},
"strapi": {
"uuid": "544ed501-773f-4b1d-9c95-b3f7ef1e5356"
},
"engines": {
"node": ">=18.0.0 <=20.x.x",
"npm": ">=6.0.0"
},
"license": "MIT"
}

Screenshot 2024-05-13 161540

Unauthenticated API Key Disclosure

Hello,

Settings API is publicly available
example: GET: /tinymce/settings

is there a way to limit the access to this endpoint to only allow authenticated users?

is there a way to add media button to tinymce ui?

checking ckeditor, somehow, it is possible to add the media library button to ckeditor UI (controls bar). so the question is, is there a way to do the same to tinymce plugin so in full screen mode, it is possible to add media without exiting the full screen mode?

Self-Hosted TinyMCE

I am wondering why an API key is needed? We should be able to add the package and configure it as a self-hosted application within the Strapi app.

According to https://www.tiny.cloud/docs/tinymce/6/react-pm-host/, we shouldn't need an API key if we are hosting it on our own hosting service.

Also, how to integrate a react app into Strapi.. https://docs.strapi.io/dev-docs/integrations/react

Using the API is senseless and requires depending on another server to load the editor..what if that server is slow or offline?

After installing TinyMCE Strapi Marketplace stops working

Hello!

After installing TinyMCE plugin Strapi Marketplace stops working. More precisely after adding plugin code to middlewares.ts

If I remove plugin code from middlewares.ts marketplace works normally

The same error occurs on both Node v16.17.0 (on Windows, Strapi v4.4.3) and Node v18.12.1 (on Mac, Strapi v4.5.6).

Strapi with Typescript and Postgresql (14 and 15)

Screenshot 2023-01-17 at 11 54 24

Disable "Media library button"

Hi,

What would be the best way to disable the Media library button displayed before every tiny editor?

Thanks for your help!

Error: ./src/plugins/tinymce couldn't be resolved

Hi,

I'm trying to install your plugin, but when I do, I get this ^^ error on build.

I followed the install process as described. Build runs without issue with the default tincymce config (just the 'enabled' property). But the TinyMCE editor doesn't appear in rich text field. So I added the config example from the documentation and then I get that error above.

I've looked and there is no TinyMCE folder in plugins directory. It looks like it's not being added there, but I can see the correct structure is in the node_modules folder for this package. Should the config entry be pointing to this, or hsould the folder be copied/moved during install to the src/plugins folder?

I'm using Strapi 4.4.0 on windows, with this package version 1.0.0.

API Key not being used by TinyMCE

Hello (I swear it's the last time)!

I have set a pre-existing API key for TinyMCE in the configuration page as said in the documentation, but I still have the "This domain is not registered with Tiny Cloud." message.

Also, when checking the network to see from where Tiny loads its plugins, I can see the following request being made: https://cdn.tiny.cloud/1/no-api-key/tinymce/6.2.0-10/plugins/... which makes me believe that the API key is not taken in account.

Update Strapi version to support Node 20.

Upgrading Strapi version to 4.15 is breaking up, if this plugin is used.
Here is the error thrown.

error @sklinet/[email protected]: The engine "node" is incompatible with this module. Expected version ">=14.19.1 <=18.x.x". Got "20.0.0"
error Found incompatible module.

How to add custom functionality?

Hi there,
thanks for the plugin!
I tried to add a simple testButton in the toolbar, but it doesn't work.
I followed the documentation but nothing happens.

This is my plugins.js:

module.exports = () => ({
	tinymce: {
		enabled:true,
		config: {
			editor: {
				editorConfig: {
					language: 'de',
					plugins: 'lists link',
					menubar: false,
					toolbar: 'bold italic bullist numlist blockquote alignleft aligncenter alignright link hr removeformat testButton',
					setup: function (editor) {
						editor.ui.registry.addButton('testButton', {
							text: 'testButton',
							tooltip: 'testButton',
							onAction: (_) => alert('hi'),
						});
					}
				}
			}
		}
	}
});

Save button is enabled whenever open a document in a content manager in Strapi TinyMCE

As strapi admin if user open the any documents or records in collection which is already saved. But still the save button is enabled even though user does not make any changes in the document.

Steps to reproduce
1.Open any save/published document/record in the collection.
2.Record which already has TinyMCE editor do not make any changes to the record
3.You can find the Save button is enabled.

Due to this issue the user will click the save button without any changes to the record.This could be a performance issues.

This issue occurs in the published pages with TinyMCE editor. unpublished pages does not occurs this issue

image image

Strapi Version. : 4.9.1
Node version: 18
@sklinet/strapi-plugin-tinymce :1.0.7
DB : postgres
Operating System: Mac Os

Save Issue in cms due to TinyMCE.

Am facing a issue with TinyMCE, after installing tinyMCE replacing with default WYSIWYG editor. I can able to see the save option enabled in collection type everytime I reload a collection, without any modification in content inside the tinyMCE editor.
Expected behaviour is that the save button of collection type to be enabled only on any content change inside tinyMCE editor

TinyMCE editor does not show up even when configured Plugin, CSP, API Key

Hi guys.

I'm using Strapi v4.11.2 and after following your installation and configuration guide in readme, the editor still does not show up

image

These are my config files:

plugins.ts

image

middlewares.ts

image

API Key:

image

When checking network requests, I can see it's getting config from tinymce/config/editor but the result is an empty object
image

I also checked the console, but no error logged besides network requests.
Is there any fault in my installation and configuration steps?

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.