parttio / tinymce-for-flow

TinyMCE wrapper for Vaadin 10+
Other
8 stars 6 forks source link

Issue with Vaadin 14.6 #15

Closed codescriptor closed 2 years ago

codescriptor commented 3 years ago

When switching from Vaadin 14.5.5 to Vaadin 14.6.4 (any minor version of Vaadin 14.6) next error appears in console:

Uncaught ReferenceError: tinymce is not defined
    at eval (theme.js?2f42:68)
    at Object.eval (theme.js?2f42:32457)
    at eval (theme.js:32459)
    at Object.../target/frontend/frontend/tinymce_addon/tinymce/themes/silver/theme.js (vaadin-bundle-a1a9c9ac6f496b1ce541.cache.js:4397)
    at __webpack_require__ (vaadin-bundle-a1a9c9ac6f496b1ce541.cache.js:20)
    at eval (generated-flow-imports.js?b518:1)
    at Module.../target/frontend/generated-flow-imports.js (vaadin-bundle-a1a9c9ac6f496b1ce541.cache.js:4420)
    at __webpack_require__ (vaadin-bundle-a1a9c9ac6f496b1ce541.cache.js:20)
    at vaadin-bundle-a1a9c9ac6f496b1ce541.cache.js:84
    at vaadin-bundle-a1a9c9ac6f496b1ce541.cache.js:87

It crashes all other custom styles and UI looks ugly.

The version of tinymce-for-flow is 3.1.0.

ado2000 commented 3 years ago

The same problem for me

ado2000 commented 3 years ago

May be the tinymce theme folder interfere with the theme management of vaadin

resources/META-INF/resources/frontend/tinymce_addon/tinymce/themes

PaulQDC commented 3 years ago

This error has also stopped us in our tracks from doing an upgrade to 14.6.x !!! Unfortunate as we heavily rely upon the tiny MCE component.

gagarina6794 commented 3 years ago

We found the solution, we migrated project to cloud

In class TinyMce, added annotation @JavaScript("https://cdn.tiny.cloud/1/no-api-key/tinymce/5/tinymce.min.js")

Removed package https://github.com/mstahv/tinymce-for-flow/tree/master/src/main/resources/META-INF/resources/frontend#:~:text=tinymce_addon/tinymce

Changed vaadin version to latest (14.6.8) in pom for

vaadin-bom vaadin-maven-plugin
PaulQDC commented 3 years ago

Unfortunately this solution will not work for us as we are not allowed to use and CDN references in our code. So still need this fixed to use a local copy of tinymce.min.js.

gagarina6794 commented 3 years ago

Seems like the problem with local tinymce is that it inside can't resolve all resources in right way in js library. I'm not sure is it possible to fix that with vaadin, maybe tinymce team can help with that.

gagarina6794 commented 3 years ago

Migrated TinyMce to a new addon template with local tiny js libraries. Works on my machine :) https://github.com/gagarina6794/pandateam-tinymce/tree/tiny-mce-for-flow

gagarina6794 commented 3 years ago

Hi all! I don't think that renaming the theme folder in tinymce library is a good idea, we shouldn't change that API, it's not a flexible solution for the future. I found one more solution.

  1. In pom:

-- change vaadin version to latest (14.6.8) for vaadin-bom vaadin-maven-plugin

  1. In TinyMce class

-- change import from @JavaScript("frontend://tinymceConnector.js") to @JavaScript("./tinymce_addon/tinymce/tinymce.min.js") @JavaScript("./tinymceConnector.js")

-- remove method - injectTinyMceScript();

-- set in initConnector() method next line config.put("base_url", "frontend/tinymce_addon/tinymce"); after this.initialContentSent = true;

tim12s commented 2 years ago

This works and successfully works with both 21.0.7 and the latest TinyMCE. Please note that with the latest production version of tiny MCE you need to rename/copy the .min.js files to .js. or set the suffix to ".min" as per https://www.tiny.cloud/docs/configure/integration-and-setup/#suffix .

Hi all! I don't think that renaming the theme folder in tinymce library is a good idea, we shouldn't change that API, it's not a flexible solution for the future. I found one more solution.

  1. In pom:

-- change vaadin version to latest (14.6.8) for vaadin-bom vaadin-maven-plugin

  1. In TinyMce class

-- change import from @javascript("frontend://tinymceConnector.js") to @javascript("./tinymce_addon/tinymce/tinymce.min.js") @javascript("./tinymceConnector.js")

-- remove method - injectTinyMceScript();

-- set in initConnector() method next line config.put("base_url", "frontend/tinymce_addon/tinymce"); after this.initialContentSent = true;

MathiasAugstein commented 2 years ago

As far as I see the changes are implemented in version 3.2.0. Should this issue be closed?

mstahv commented 2 years ago

Yup, thanks for the heads up!