FOSCKEditorBundle有时有效,有时无效,与bootsnav.js冲突

问题描述 投票:1回答:1

我正在使用Symfony 4和webPack附加包。我对Fosckeditorbundle有一个奇怪的问题,有时效果很好,有时在控制台中出现错误,我应该刷新浏览器很多次,直到捆绑包工作为止。

FOSCkeditor捆绑包未与Webpack Encore一起使用,但使用Webpack Encore捆绑包后出现了问题。

Uncaught TypeError: Cannot read property 'getClientRect' of null
at p.getClientRect (ckeditor.js:1253)
at p.queryViewport (ckeditor.js:1253)
at new p (ckeditor.js:1238)
at a.<anonymous> (ckeditor.js:1274)
at a.p (ckeditor.js:10)
at a.<anonymous> (ckeditor.js:12)
at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13)
at $.<anonymous> (ckeditor.js:944)
at ckeditor.js:30

编辑:

我进行了一些测试,发现问题来自bootsnav.js,将其删除后,没有任何错误。

javascript symfony symfony4 webpack-encore
1个回答
0
投票

如果使用Webpack Encore,则应将FosCKEditorBundle与Webpack Encore一起使用。

  1. 删除您的CKEditor副本(不是FosCKEditorBundle)。
  2. 重新安装通过 Webpack Encore。根据官方文档,您只需要:

    yarn add ckeditor@^4.0.0

然后在webpack配置中:

var Encore = require('@symfony/webpack-encore');

Encore
    // ...
    .copyFiles([
        {from: './node_modules/ckeditor/', to: 'ckeditor/[path][name].[ext]', pattern: /\.(js|css)$/, includeSubdirectories: false},
        {from: './node_modules/ckeditor/adapters', to: 'ckeditor/adapters/[path][name].[ext]'},
        {from: './node_modules/ckeditor/lang', to: 'ckeditor/lang/[path][name].[ext]'},
        {from: './node_modules/ckeditor/plugins', to: 'ckeditor/plugins/[path][name].[ext]'},
        {from: './node_modules/ckeditor/skins', to: 'ckeditor/skins/[path][name].[ext]'}
    ])

;

这样,您将避免js冲突。

© www.soinside.com 2019 - 2024. All rights reserved.