1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials'; import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold'; import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic'; import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
class WindsCKEditor { constructor(element, options = {}) { this.element = element; this.options = Object.assign({}, this.defaultOptions, options); this.init(); } async init() { try { this.editor = await ClassicEditor.create(this.element, { plugins: [ Essentials, Bold, Italic, Paragraph, ], toolbar: [ 'heading', '|', 'bold', 'italic', 'link', '|', 'bulletedList', 'numberedList', '|', 'outdent', 'indent', '|', 'blockQuote', 'insertTable', '|', 'undo', 'redo' ], ...this.options }); this.bindEvents(); } catch (error) { console.error('CKEditor初始化失败:', error); } } }
|
文章评论 (0)