首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用带类型记录的ckeditor

使用带类型记录的ckeditor
EN

Stack Overflow用户
提问于 2021-08-10 06:00:25
回答 2查看 1.2K关注 0票数 0

当我在打字稿中使用它时,我遇到了麻烦。

我已经用npm install --save @ckeditor/ckeditor5-react @ckeditor/ckeditor5-build-classic安装了它

并使用以下方法导入:

代码语言:javascript
复制
import { CKEditor } from "@ckeditor/ckeditor5-react";
import ClassicEditor from '@ckeditor/ckeditor5-build-classic';

但是,我得到了以下错误:TS7016: Could not find a declaration file for module '@ckeditor/ckeditor5-react'. '/Users/yifanwang/code/clideo-clone/node_modules/@ckeditor/ckeditor5-react/dist/ckeditor.js' implicitly has an 'any' type.

我尝试在我的项目中添加一个typing.d.ts文件:

代码语言:javascript
复制
declare module "@ckeditor/ckeditor5-react" {
    const CKEditor: any;
    export default CKEditor;
}
  
declare module "@ckeditor/ckeditor5-build-classic" {
    const ClassicEditor: any;
    export = ClassicEditor;
}

但效果不太好。

我怎么才能修好它?

EN

回答 2

Stack Overflow用户

发布于 2022-03-10 03:10:52

代码语言:javascript
复制
npm i --save-dev @types/ckeditor__ckeditor5-react

在文件夹node_modules中,您可以在@type中找到。在这个文件夹中创建一个子文件夹。名字是ckeditor__ckeditor 5-react。你粘贴了这段代码。

从‘@CKEditor/CKEditor 5-build- ClassicEditor’导入事件;从‘@CKEditor/CKEditor 5-utils/src/ClassicEditor’import { EditorConfig }‘从’React‘导入ClassicEditor*;const CKEditor: React.FunctionComponent<{ React.FunctionComponent<?禁用?:boolean编辑器: typeof ClassicEditor?数据?:string;id?:string;config?:EditorConfig;onReady?(编辑器: ClassicEditor) => void;onChange:(事件:编辑器: ClassicEditor) => void;onBlur?:(事件:事件,编辑器: ClassicEditor) => void;onFocus?:(事件:事件,编辑器: ClassicEditor) onError?:(事件:事件,编辑器: ClassicEditor) => ClassicEditor;}>导出{ CKEditor };

票数 0
EN

Stack Overflow用户

发布于 2022-06-25 09:03:37

对于那些仍然感兴趣的人,这里已经回答了这个问题:https://stackoverflow.com/a/65975437/19121380

链接到此解决方案> https://github.com/ckeditor/ckeditor5-react/issues/140#issuecomment-655453105

只需创建一个包含以下内容的文件./types/ckeditor/index.d.ts

代码语言:javascript
复制
declare module '@ckeditor/ckeditor5-react';
declare module '@ckeditor/ckeditor5-build-classic';
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68721707

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档