首页 > 解决方案 > 未捕获的 ReferenceError:ExportWord 未定义 CkEditor5

问题描述

我正在尝试在我们的 MVC .NET Core 项目中实现 CkEditor5 的 ExportWord 功能。下面是我为实现它而编写的代码。但我收到错误 Uncaught ReferenceError: ExportWord is not defined。

<script src="https://cdn.ckeditor.com/ckeditor5/27.1.0/decoupled-document/ckeditor.js"></script>
<script>
import ExportWord from '@@ckeditor/ckeditor5-export-word/src/exportword';

DecoupledEditor
       .create(document.querySelector('#editor'), {
          cloudServices: {
               tokenUrl:'https://79399.cke-cs.com/token/dev/d650c302199a11c66a2282a459be96af7c917d9be8b2956c0af4b580446f',
               },
        plugins: [ExportWord],
        toolbar: {
             items: [
                     'exportWord', '|',
                     'heading', '|',
                     'alignment', '|',
                     'bold', 'italic', 'strikethrough', 'underline', 'subscript', 'superscript', '|',
                     'link', '|',
                     'bulletedList', 'numberedList', 'todoList',
                     'fontfamily', 'fontsize', 'fontColor', 'fontBackgroundColor', '|',
                     'code', 'codeBlock', '|',
                     'insertTable', '|',
                     'outdent', 'indent', '|',
                     'uploadImage', 'blockQuote', '|',
                     'undo', 'redo'
                   ],
            exportWord: {
                     stylesheets: ['EDITOR_STYLES'],
                     fileName: 'file.docx',
                     converterOptions: {
                          converterUrl: 'https://docx-converter.cke-cs.com/v1/convert',
                          format: 'A4',   
                          margin_top: '20mm',
                          margin_bottom: '20mm',
                          margin_right: '12mm',
                          margin_left: '12mm'
                          }
                    },
                    shouldNotGroupWhenFull: true
             },
         })
         .then(editor => {
              const toolbarContainer = document.querySelector('#toolbar-container');

              toolbarContainer.appendChild(editor.ui.view.toolbar.element);
          })
         .catch(error => {
             console.error(error);
         });

我该如何实施?

标签: ckeditor5ckeditor5-plugin

解决方案


推荐阅读