Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wiris MathType plugin is not working with ckeditor5 in React/Vue #2048

Closed
mstermaaten opened this issue Sep 13, 2019 · 19 comments
Closed

Wiris MathType plugin is not working with ckeditor5 in React/Vue #2048

mstermaaten opened this issue Sep 13, 2019 · 19 comments
Labels
package:mathtype resolution:duplicate This issue is a duplicate of another issue and was merged into it. type:docs This issue reports a task related to documentation (e.g. an idea for a guide). type:task This issue reports a chore (non-production change) and other types of "todos".

Comments

@mstermaaten
Copy link

Bug report

@ckeditor/ckeditor5-react: v1.1.3,
@wiris/mathtype-ckeditor5: v7.16.1,
....

Schermafdruk 2019-09-13 11 52 59

I simply try to implement the MathType plugin following this documentation:

I'm getting an error and this only happens when i try to implement the MathType plugin. I'm not sure if i'm missing any config settings that i have to parse to
initialize the plugin but reading trough the documentation i'm not seeing anything i'm missing. Maybe I have to buy a licence or something??

📋 Steps to reproduce

  1. Clone this Repo: https://github.com/mstermaaten/CKEditor-Issue
  2. npm i && npm start

✅ Expected result

Schermafdruk 2019-09-13 11 56 03

@Mgsy
Copy link
Member

Mgsy commented Sep 16, 2019

Hello, thank you for the report. I'm able to reproduce this issue - adding MathType plugin to the editor built from source with React triggers the error. It looks like some changes in Webpack config are required.

Steps to reproduce:

  1. Follow the Integrating CKEditor 5 built from source guide.
  2. Add MathType plugin to the editor.
  3. Run the application.

We're in touch with Wiris about this issue.

@Mgsy Mgsy added status:confirmed type:bug This issue reports a buggy (incorrect) behavior. labels Sep 16, 2019
@Mgsy Mgsy added this to the backlog milestone Sep 16, 2019
@SudhirTrisys
Copy link

any alternative for the time being?

@mlewand
Copy link
Contributor

mlewand commented Sep 18, 2019

This issue occurs also with vue too, see #2057.

@mlewand mlewand changed the title Wiris MathType plugin is not working with ckeditor5 in React Wiris MathType plugin is not working with ckeditor5 in React/Vue Sep 18, 2019
@Silencer-1984
Copy link

Here's how I do it
file vue.config.js

  chainWebpack: config => {
    svgRule.exclude.add(path.join(__dirname, 'node_modules', '@ckeditor'))
    svgRule.exclude.add(path.join(__dirname, 'node_modules', '@wiris'))

 config.module
      .rule('cke-svg')
      .test(/theme[/\\]icons[/\\][^/\\]+\.svg$/)
      .use('raw-loader')
      .loader('raw-loader')

    config.module
      .rule('cke-css')
      .test(/ckeditor5-[^/\\]+[/\\].+\.css$/)
      .use('postcss-loader')
      .loader('postcss-loader')
      .tap(() => {

That's not all。Because mathtype does not match the current filtering rules, the icon cannot be found。

@nnabinh
Copy link

nnabinh commented Sep 22, 2019

@duzhihao-github thanks a lot man, you saved my day!

I confirm that adding this line

svgRule.exclude.add(path.join(__dirname, 'node_modules', '@wiris'))

and by updating the cke-svg config rule from
/ckeditor5-[^/\\]+[/\]theme[/\]icons[/\][^/\\]+.svg$/
(as being described here) to
/theme[/\]icons[/\][^/\\]+.svg$/
it works great since all svg icons are loaded now

config.module
      .rule('cke-svg')
      .test(/theme[/\\]icons[/\\][^/\\]+\.svg$/)
      .use('raw-loader')
      .loader('raw-loader')

@mstermaaten
Copy link
Author

Okay we are getting closer but it's not very clear for me how i can implement this also for React.
Anybody that can help me out here?
@nnabinh
@duzhihao-github
@Mgsy

@Silencer-1984
Copy link

Silencer-1984 commented Sep 23, 2019

@mstermaaten
Copy link
Author

This is my first time i had to go add & change stuff in my webpack.config so i find it difficult to find where to add all these additional configs...
If anybody could show me how this would apply in a react webpack.config would be super awesome :)

@cy-nimitha-cherian
Copy link

cy-nimitha-cherian commented Oct 10, 2019

Add two new elements to the exported object under the module.rules array (as new items of the oneOf array). These are SVG and CSS loaders required to handle the CKEditor 5 source:
{
test: /theme[/\]icons[/\][^/\\]+.svg$/,
use: [ 'raw-loader' ]
},
{
test: /ckeditor5-[^/\\]+[/\]theme[/\].+.css/,
use: [
{
loader: 'style-loader',
options: {
injectType: 'singletonStyleTag'
}
},
{
loader: 'postcss-loader',
options: styles.getPostCssConfig( {
themeImporter: {
themePath: require.resolve( '@ckeditor/ckeditor5-theme-lark' )
},
minify: true
} )
}
]
},

Note the change: test: /theme[/\]icons[/\][^/\\]+.svg$/,

This works in React!!! (Mathtype and Chemtype) . Hope this helps! Thanks!

@Reinmar
Copy link
Member

Reinmar commented Nov 13, 2019

@mlewand did the recent changes with icons solve this issue?

@mstermaaten
Copy link
Author

mstermaaten commented Nov 14, 2019

I've actually fixed this problem by:

and by updating the cke-svg config rule from:

/ckeditor5-[^/\]+[/\]theme[/\]icons[/\][^/\]+.svg$/

(as being described here) to:

/theme[/\]icons[/\][^/\]+.svg$/

it works great since all svg icons are loaded now

@Reinmar
Copy link
Member

Reinmar commented Nov 15, 2019

Hm... That makes sense. The problem comes from the fact that MathType comes in @wiris/mathtype-ckeditor5 and not @wiris/ckeditor5-mathtype. That's why the original regexp doesn't work.

I'll talk with guys from Wiris, maybe they'll be fine with renaming their package to follow the convention.

@Reinmar Reinmar added type:docs This issue reports a task related to documentation (e.g. an idea for a guide). type:task This issue reports a chore (non-production change) and other types of "todos". and removed type:bug This issue reports a buggy (incorrect) behavior. labels Nov 15, 2019
@tuannd255
Copy link

@mstermaaten Hello, I clone your app fixed this issues but I still error when run project. Can you support me fix it? Thank you!!!
image

@vmarcosp
Copy link

Hey everyone, any news about this issue? @tuannd255

@vmarcosp
Copy link

vmarcosp commented May 25, 2020

@tuannd255 I fixed this error making the file loader from the CRA config ignore icons from ckeditor plugins, something like:

svgRule.exclude.add(/theme[/\]icons[/\][^/\]+.svg$/)

Adding this line to your CRA config the file loader will ignore icons from any plugin that you are using with ckeditor.

@vmarcosp
Copy link

@Reinmar what do you think to add to the official docs a section to help people with similar problems with loaders and config for custom builds?

@vmarcosp
Copy link

@Reinmar Take a look at this PR please

@mohitsehgal
Copy link

Frankly this thread saved my day.!! Awesome

@Reinmar
Copy link
Member

Reinmar commented Sep 21, 2020

Hi all! This issue will be resolved with #8114. We want to change the default regexp that we're proposing to cover packages that are named sth-ckeditor5 too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:mathtype resolution:duplicate This issue is a duplicate of another issue and was merged into it. type:docs This issue reports a task related to documentation (e.g. an idea for a guide). type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

No branches or pull requests