How to use CKEditor as an NPM module built with webpack or similar

后端 未结 5 2112
情歌与酒
情歌与酒 2020-12-30 01:26

How can I use CKEditor from npm with webpack?

Ideally I want npm install ckeditor --save then var CK = require(\'ckeditor\'); without any g

5条回答
  •  情书的邮戳
    2020-12-30 01:47

    Install

    npm install ckeditor --save-dev
    

    Load

    require('ckeditor');
    

    After loading chkeditor becomes available as global variable CKEDITOR

    Replace

    CKEDITOR.replace('elementId');
    

    Issues

    The editor loads it's own required CSS/JS assets, likely these cannot be found. You can refer to the CDN version for these resources or you can copy the CKeditor directory to an public reachable folder. Define the URL of the public reachable resources with CKEDITOR_BASEPATH.

    window.CKEDITOR_BASEPATH    = '//cdn.ckeditor.com/4.6.2/full-all/';
    

    Note: Define window.CKEDITOR_BASEPATH before your import statement!

提交回复
热议问题