Closed DanielOnosov closed 2 years ago
Hi, I see that you're trying to add plugins to a preconfigured editor build, which is not possible. If you want to customise your editor in React app, there are three options here:
Hi! I am trying to customize ckeditor in strapi app, but ckeditor is the react app.
Hi, I see that you're trying to add plugins to a preconfigured editor build, which is not possible. If you want to customise your editor in React app, there are three options here:
- build editor from source in your React app
- use Online Builder to create a custom build and then import it in your React app
- create a custom build yourself and then import it in your React app
How can i add files from Online Builder to my code:
import React from 'react';
import PropTypes from 'prop-types';
import { CKEditor } from '@ckeditor/ckeditor5-react';
import styled from 'styled-components';
import ClassicEditor from '@ckeditor/ckeditor5-build-classic'
const Wrapper = styled.div`
.ck-editor__main {
min-height: 200px;
> div {
min-height: 200px;
}
}
`;
const configuration = {
toolbar: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'|',
'indent',
'outdent',
'|',
'blockQuote',
'insertTable',
'mediaEmbed',
'undo',
'redo',
],
};
const Editor = ({ onChange, name, value }) => {
return (
<Wrapper>
<CKEditor
editor={ClassicEditor}
config={configuration}
data={value}
onReady={editor => editor.setData(value)}
onChange={(event, editor) => {
const data = editor.getData();
onChange({ target: { name, value: data } });
}}
/>
</Wrapper>
);
};
Editor.propTypes = {
onChange: PropTypes.func.isRequired,
name: PropTypes.string.isRequired,
value: PropTypes.string,
};
export default Editor;
and ckeditor.js from builder:
class Editor extends ClassicEditor {}
// Plugins to include in the build.
Editor.builtinPlugins = [
Autoformat,
AutoImage,
BlockQuote,
Bold,
CKFinder,
CKFinderUploadAdapter,
CloudServices,
Essentials,
Heading,
Image,
ImageCaption,
ImageResize,
ImageStyle,
ImageToolbar,
ImageUpload,
Indent,
Italic,
Link,
List,
MediaEmbed,
Paragraph,
PasteFromOffice,
Table,
TableToolbar,
TextTransformation
];
// Editor configuration.
Editor.defaultConfig = {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'|',
'outdent',
'indent',
'|',
'blockQuote',
'insertTable',
'mediaEmbed',
'undo',
'redo',
'imageUpload',
'CKFinder'
]
},
language: 'ru',
image: {
toolbar: [
'imageTextAlternative',
'imageStyle:inline',
'imageStyle:block',
'imageStyle:side'
]
},
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells'
]
}
};
export default Editor;
Please see the docs on integration with Online Builder.
Closing due to lack of activity. If you think the issue is still not resolved, please, re-open it and provide the feedback we asked for.
Image resizing not work
/**
* @license Copyright (c) 2014-2024, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/
import { ClassicEditor } from '@ckeditor/ckeditor5-editor-classic';
import { Alignment } from '@ckeditor/ckeditor5-alignment';
import { Autoformat } from '@ckeditor/ckeditor5-autoformat';
import { Bold, Italic } from '@ckeditor/ckeditor5-basic-styles';
import { BlockQuote } from '@ckeditor/ckeditor5-block-quote';
import { CKBox, CKBoxImageEdit } from '@ckeditor/ckeditor5-ckbox';
import { CloudServices } from '@ckeditor/ckeditor5-cloud-services';
import type { EditorConfig } from '@ckeditor/ckeditor5-core';
import { Essentials } from '@ckeditor/ckeditor5-essentials';
import { Heading } from '@ckeditor/ckeditor5-heading';
import {
AutoImage,
Image,
ImageCaption,
ImageStyle,
ImageToolbar,
ImageUpload,
PictureEditing,
ImageResize,
ImageResizeEditing, ImageResizeHandles,
} from '@ckeditor/ckeditor5-image';
import { Indent } from '@ckeditor/ckeditor5-indent';
import { AutoLink, Link } from '@ckeditor/ckeditor5-link';
import { List } from '@ckeditor/ckeditor5-list';
import { MediaEmbed } from '@ckeditor/ckeditor5-media-embed';
import { Paragraph } from '@ckeditor/ckeditor5-paragraph';
import { PasteFromOffice } from '@ckeditor/ckeditor5-paste-from-office';
import { Table, TableToolbar } from '@ckeditor/ckeditor5-table';
import { TextTransformation } from '@ckeditor/ckeditor5-typing';
import { Undo } from '@ckeditor/ckeditor5-undo';
// You can read more about extending the build with additional plugins in the "Installing plugins" guide.
// See https://ckeditor.com/docs/ckeditor5/latest/installation/plugins/installing-plugins.html for details.
class Editor extends ClassicEditor {
public static override builtinPlugins = [
ImageResize,
Alignment,
Image,
ImageResizeEditing,
ImageResizeHandles,
AutoImage,
AutoLink,
Autoformat,
BlockQuote,
Bold,
CKBox,
CKBoxImageEdit,
CloudServices,
Essentials,
Heading,
Image,
ImageCaption,
ImageStyle,
ImageToolbar,
ImageUpload,
Indent,
Italic,
Link,
List,
MediaEmbed,
Paragraph,
PasteFromOffice,
PictureEditing,
Table,
TableToolbar,
TextTransformation,
Undo,
];
public static override defaultConfig: EditorConfig = {
toolbar: {
items: [
'resizeImage',
'heading',
'bold',
'imageUpload',
'italic',
'link',
'bulletedList',
'numberedList',
'|',
'outdent',
'indent',
'|',
'blockQuote',
'insertTable',
'mediaEmbed',
'undo',
'redo',
'imageUpload',
'ckbox',
'ckboxImageEdit',
],
},
language: 'ru',
image: {
toolbar: [
'resizeImage:50',
'resizeImage:75',
'resizeImage:original',
'imageTextAlternative',
'toggleImageCaption',
'imageStyle:inline',
'imageStyle:block',
'imageStyle:side',
],
resizeUnit: 'px',
resizeOptions: [
{
name: 'resizeImage:original',
value: null,
icon: 'original',
},
{
name: 'resizeImage:50',
value: '50',
icon: 'medium',
},
{
name: 'resizeImage:75',
value: '75',
icon: 'large',
},
],
},
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells',
],
},
};
}
export default Editor;
Hi! I am trying to make a image resizing at ckeditor but I idk how to do that. I tried to make sthing but I have an error. I attached some snippets of my code and architecture of my project
Error: Module not found: Error: Can't resolve './@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css' I have this error when i am trying to build the project.
I am using ckeditor in strapi. Here is my code structure.
Threre is my code when i tried to use image resizing:
and index.js file: