简体   繁体   English

使用 webpack 将插件安装到 Laravel 5 中的 CKEditor 5

[英]Installing plugins to CKEditor 5 in Laravel 5 with webpack

I have got a small issue with installing plugins to CKEditor integrated to Laravel 5.6.我在为 Laravel 5.6 集成的 CKEditor 安装插件时遇到了一个小问题。 According to integration guide from CKEditor document, I was able to add@ckeditor/ckeditor5-build-classic dependency using npm to the project and it was working just fine with webpack.根据 CKEditor 文档中的集成指南,我能够使用 npm 将@ckeditor/ckeditor5-build-classic依赖项添加到项目中,并且它与 webpack 一起工作得很好。

But the problem is that I can't add custom plugin which is not included to the CKEditor by default.但问题是我无法添加默认情况下未包含在 CKEditor 中的自定义插件。 I'm following the guide to add custom plugin but it's not really working fine with webpack in laravel itself.我正在按照指南添加自定义插件,但在 laravel 本身中使用 webpack 并不能正常工作。 For example, I tried to add @ckeditor/ckeditor5-alignment , but didn't work and I got the following console error.例如,我尝试添加@ckeditor/ckeditor5-alignment ,但没有成功,并且出现以下控制台错误。

TypeError: Cannot read property 'getAttribute' of null

I guess this could be something that I have not added all necessary plugins when setup ClassicEditor instance.我想这可能是我在设置 ClassicEditor 实例时没有添加所有必要插件的原因。 So I tried another thing.所以我尝试了另一件事。 I have installed the plugin to ckeditor build and I got the custom build.我已经将插件安装到 ckeditor build 并获得了自定义构建。 But when I'm trying to import the build in the custom path with the following statement, it's not importing.但是当我尝试使用以下语句在自定义路径中导入构建时,它没有导入。

import ClassicEditor from '../plugins/vendor/ckeditor/build/ckeditor';

If I just remove build directory from node_modules and copy this custom build, I am able to make it work with the following statement.如果我只是从 node_modules 中删除构建目录并复制此自定义构建,则可以使用以下语句使其工作。

import ClassicEditor from '@ckeditor/ckeditor5-build-classic/build/ckeditor';

This is not a professional way to edit/update in node_modules.这不是在 node_modules 中编辑/更新的专业方法。

So my question is:所以我的问题是:

How can I install custom plugin to CKEditor on Laravel itself?如何在 Laravel 本身上为 CKEditor 安装自定义插件?

Or how can I add the custom CKEditor build to the project without customizing node_modules?或者如何在不自定义 node_modules 的情况下将自定义 CKEditor 构建添加到项目中?

I have used CKEditor among others in my Laravel projects, but here is how I went about it:我在我的 Laravel 项目中使用过 CKEditor 等,但这是我的做法:

  1. I downloaded the js and CSS files from CKEditor website and unzip the files我从 CKEditor 网站下载了 js 和 CSS 文件并解压文件
  2. I copy those files in the public folder of my Laravel Project我将这些文件复制到 Laravel 项目的公共文件夹中
  3. You can access and use them in your blade pages like this您可以像这样在刀片页面中访问和使用它们
<code>
   <script src="{{asset('js/ckeditor.js')}}"></script>
   <link rel="stylesheet: href="{{asset('js/ckeditor.js')}}" />
</code>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM