如何将链接图像添加到React中的CKeditor?

发布于 2025-01-25 00:36:57 字数 869 浏览 2 评论 0 原文

我想将链接图像链接到我的React应用程序的功能,该应用程序使用“

@ckeditor/ckeditor5-build-decoupled-document

代码:

import React from 'react'
import { CKEditor } from "@ckeditor/ckeditor5-react";
import * as  DecoupledEditor from "@ckeditor/ckeditor5-build-decoupled-document";

但是当我导入时:

import linkimage from '@ckeditor/ckeditor5-link/src/linkimage';

我会收到一个错误:

untured ckeditorError:ckeditor-duplicated-modules

更多有关

“在此处输入图像描述”

如何添加链接图像?

I want to add Linking images feature to my React app that uses '

@ckeditor/ckeditor5-build-decoupled-document

code:

import React from 'react'
import { CKEditor } from "@ckeditor/ckeditor5-react";
import * as  DecoupledEditor from "@ckeditor/ckeditor5-build-decoupled-document";

but when I import:

import linkimage from '@ckeditor/ckeditor5-link/src/linkimage';

I get an error:

Uncaught CKEditorError: ckeditor-duplicated-modules

more info about images linking

enter image description here

How can I add linking images?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

絕版丫頭 2025-02-01 00:36:57

我假设您已经完成了:

npm install --save @ckeditor/ckeditor5-image

并启用了插件:

import LinkImage from '@ckeditor/ckeditor5-link/src/linkimage';

然后将其添加到您的编辑器配置中:

image: {
    toolbar: [
        'imageStyle:block',
        'imageStyle:side',
        '|',
        'toggleImageCaption',
        'imageTextAlternative',
        '|',
        'linkImage' <---- here
    ]
}

即使错误仍然持续存在,请尝试使用错误代码文档在这里

Packages were duplicated in node_modules

In some situations, especially when calling npm install multiple times, it may happen that npm will not correctly "deduplicate" packages.

Normally, npm deduplicates all packages so, for example, @ckeditor/ckeditor5-core is installed only once in node_modules/. However, it is known to fail to do so from time to time.

We recommend checking if any of the steps listed below help:

    rm -rf node_modules && npm install to make sure you have a clean node_modules/ directory. This step is known to help in most cases.
    If you use yarn.lock or package-lock.json, remove it before npm install.
    Check whether all CKEditor 5 packages are up to date and reinstall them if you changed anything (rm -rf node_modules && npm install).

I assume you have done:

npm install --save @ckeditor/ckeditor5-image

and enabled the plugin with:

import LinkImage from '@ckeditor/ckeditor5-link/src/linkimage';

then add this into your editor config:

image: {
    toolbar: [
        'imageStyle:block',
        'imageStyle:side',
        '|',
        'toggleImageCaption',
        'imageTextAlternative',
        '|',
        'linkImage' <---- here
    ]
}

even if the error still persist, try the error code docs for it here

Packages were duplicated in node_modules

In some situations, especially when calling npm install multiple times, it may happen that npm will not correctly "deduplicate" packages.

Normally, npm deduplicates all packages so, for example, @ckeditor/ckeditor5-core is installed only once in node_modules/. However, it is known to fail to do so from time to time.

We recommend checking if any of the steps listed below help:

    rm -rf node_modules && npm install to make sure you have a clean node_modules/ directory. This step is known to help in most cases.
    If you use yarn.lock or package-lock.json, remove it before npm install.
    Check whether all CKEditor 5 packages are up to date and reinstall them if you changed anything (rm -rf node_modules && npm install).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文