GithubHelp home page GithubHelp logo

Load plugins about ckeditor5-vue HOT 18 CLOSED

ckeditor avatar ckeditor commented on July 22, 2024
Load plugins

from ckeditor5-vue.

Comments (18)

ggirodda avatar ggirodda commented on July 22, 2024 7

@jodator Thank you for your answer, now it works. Here you can find a valid exemple for integration with nuxtjs:

const CKEditorWebpackPlugin = require("@ckeditor/ckeditor5-dev-webpack-plugin")
const CKEditorStyles = require("@ckeditor/ckeditor5-dev-utils").styles

module.exports = {
  // some config before
  build: {
    plugins: [
      // CKEditor needs its own plugin to be built using webpack.
      new CKEditorWebpackPlugin({
          // See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
          language: "en"
      })
    ],
    // Various modules in the CKEditor source code import .css files.
    // These files must be transpiled using PostCSS in order to load properly.
    postcss: CKEditorStyles.getPostCssConfig({
        themeImporter: {
            themePath: require.resolve("@ckeditor/ckeditor5-theme-lark")
        },
        minify: true
    }),
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
      const filesRuleIndex = config.module.rules.findIndex(item => {
        return `${item.test}` == "/\\.(png|jpe?g|gif|svg|webp)$/i"
      })
      if (filesRuleIndex !== -1) {
        config.module.rules[filesRuleIndex].test = /\.(png|jpe?g|gif|webp)$/
        const svgRule = config.module.rules[filesRuleIndex]
        svgRule.test = /\.svg/
        svgRule.exclude = svgRule.exclude || []
        svgRule.exclude.push(__dirname + "/node_modules/@ckeditor")
        config.module.rules.push(svgRule)
      }
      // Vue CLI would normally use its own loader to load .svg files. The icons used by
      // CKEditor should be loaded using raw-loader instead.
      config.module.rules.push({
        test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
        use: ["raw-loader"]
      })
    }
}

from ckeditor5-vue.

ponpondev avatar ponpondev commented on July 22, 2024 2

The price for adding plugins and configuring is so much I decided to build the custom editor. And it just WORKS. Here's how to do it

Aside from the issues in this thread, I also ran into Some CKEditor 5 modules are duplicated and Cannot read property 'getAttribute' of null

The custom build reduces my nuxt.config.js by a BUNCH, and makes the project much cleaner. For those who run into SSR failing, check this

I have strong thoughts the repo is not very well compatible with nuxt, so this workaround is imo the most optimal way to go for now...

from ckeditor5-vue.

Reinmar avatar Reinmar commented on July 22, 2024

I guess you're trying to use an existing editor build. That won't work. You need to use it with the editor integrated from source – e.g. @ckeditor/ckeditor5-editor-classic. See https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/vuejs.html#using-the-editor-from-source

from ckeditor5-vue.

kl3sk avatar kl3sk commented on July 22, 2024

That true, I installed this build and now (with all plugins enabled)

TypeError: "svg is null"

from ckeditor5-vue.

Reinmar avatar Reinmar commented on July 22, 2024

That's covered a bit earlier in the docs :) https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/vuejs.html#configuring-vueconfigjs. In general, you have to go through the entire "Integrating CKEditor 5 from source" section.

from ckeditor5-vue.

kl3sk avatar kl3sk commented on July 22, 2024

My bad I've read it earlier ...

So I'am going to build my own editor.

from ckeditor5-vue.

kl3sk avatar kl3sk commented on July 22, 2024

I think i have a conflict with css-loader used by vuetify

An extra config is maybe require for postcss-loader inside vue.config.js

from ckeditor5-vue.

kl3sk avatar kl3sk commented on July 22, 2024

I did not achieve it in conjunction with Vuetify that seems to use css-loader. I don't know how to modify (I think vue.config.js) to make it working.

Does this component will allow pulugin customisation ?

from ckeditor5-vue.

ggirodda avatar ggirodda commented on July 22, 2024

I have the same problem with nuxt. I follow the docs but I still have 'svg is null'. Here is my nuxt.config.js file:

const CKEditorWebpackPlugin = require("@ckeditor/ckeditor5-dev-webpack-plugin")
const CKEditorStyles = require("@ckeditor/ckeditor5-dev-utils").styles

module.exports = {
  // some config before
  build: {
    plugins: [
      // CKEditor needs its own plugin to be built using webpack.
      new CKEditorWebpackPlugin({
          // See https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html
          language: "en"
      })
    ],
    // Various modules in the CKEditor source code import .css files.
    // These files must be transpiled using PostCSS in order to load properly.
    postcss: CKEditorStyles.getPostCssConfig({
        themeImporter: {
            themePath: require.resolve("@ckeditor/ckeditor5-theme-lark")
        },
        minify: true
    }),
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
      // Vue CLI would normally use its own loader to load .svg files. The icons used by
      // CKEditor should be loaded using raw-loader instead.
      config.module.rules.push({
        test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/,
        use: ["file-loader","raw-loader"]
      })
    }
}

I don't know if the config is correct, I follow the following guides to interact with webpack from nuxt config:
https://nuxtjs.org/faq/webpack-plugins
https://nuxtjs.org/faq/postcss-plugins
https://nuxtjs.org/faq/extend-webpack

from ckeditor5-vue.

jodator avatar jodator commented on July 22, 2024

@ggirodda please check updated vue guide for loading SVGs:https://github.com/ckeditor/ckeditor5/blob/bc613e17b68e17ac0487af30b75f7566c21f2186/docs/builds/guides/frameworks/vuejs.md#configuring-vueconfigjs (its only availble on master ATM). Does it solve your issue?

from ckeditor5-vue.

narisada014 avatar narisada014 commented on July 22, 2024

@ggirodda
In nuxt, how did you transplice a plugin library such as HeadingButtonsUI?

from ckeditor5-vue.

iamKyun avatar iamKyun commented on July 22, 2024

@ggirodda It works fine! But in my case, this line is still need to modify

const filesRuleIndex = config.module.rules.findIndex(item => {
     return `${item.test}` == "/\\.(png|jpe?g|gif|svg|webp)$/"
})

to :

const filesRuleIndex = config.module.rules.findIndex((item) => {
   // add a 'i' at the end of this line
    return `${item.test}` == '/\\.(png|jpe?g|gif|svg|webp)$/i'
})

from ckeditor5-vue.

iamKyun avatar iamKyun commented on July 22, 2024

@ggirodda
In nuxt, how did you transplice a plugin library such as HeadingButtonsUI?

https://nuxtjs.org/api/configuration-build/#transpile

from ckeditor5-vue.

ggirodda avatar ggirodda commented on July 22, 2024

@iamKyun ok thank you, I updated my example

from ckeditor5-vue.

Mgsy avatar Mgsy commented on July 22, 2024

Note for people using Nuxt.js - I've created a feature request for Nuxt.js integration, so feel free to add 👍 to the first post to bump its popularity and join the discussion.

@kl3sk, did you manage to solve your issue? If not, could you provide some more information about your problem?

from ckeditor5-vue.

yamenarahman avatar yamenarahman commented on July 22, 2024

In my case I had to edit these lines:

return `${item.test}` === '/\\.(jpg|JPG|jpeg|png|gif|mp3|svg|ttf|woff2|woff|eot)$/gi';
svgRule.exclude.push(path.join(__dirname, '/node_modules/@ckeditor'));

But also still the same error exits

It was not possible to load the plugin.
Cannot read property 'getAttribute' of null.

@Mgsy @ggirodda @iamKyun Any advice?

from ckeditor5-vue.

jeck5895 avatar jeck5895 commented on July 22, 2024

The price for adding plugins and configuring is so much I decided to build the custom editor. And it just WORKS. Here's how to do it

Aside from the issues in this thread, I also ran into Some CKEditor 5 modules are duplicated and Cannot read property 'getAttribute' of null

The custom build reduces my nuxt.config.js by a BUNCH, and makes the project much cleaner. For those who run into SSR failing, check this

I have strong thoughts the repo is not very well compatible with nuxt, so this workaround is imo the most optimal way to go for now...

I have custom build for my project. but the problem is it exceeds babel 500kb limit and won't compile. have you encountered the same?

from ckeditor5-vue.

Mgsy avatar Mgsy commented on July 22, 2024

As the discussion seems to be focused around Nuxt.js, I'm closing it and all people interested in Nuxt.js integration, please refer to the Nuxt.js feature request.

from ckeditor5-vue.

Related Issues (20)

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.