Skip to content

Instantly share code, notes, and snippets.

@alexisselorm
Created December 25, 2023 18:23
Show Gist options
  • Save alexisselorm/2791db69949ca1771a604920000a41ff to your computer and use it in GitHub Desktop.
Save alexisselorm/2791db69949ca1771a604920000a41ff to your computer and use it in GitHub Desktop.
CKEditor config
/**
* @license Copyright (c) 2014-2023, 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 { Autoformat } from '@ckeditor/ckeditor5-autoformat';
import { Bold, Italic, Underline } from '@ckeditor/ckeditor5-basic-styles';
import { BlockQuote } from '@ckeditor/ckeditor5-block-quote';
import type { EditorConfig } from '@ckeditor/ckeditor5-core';
import { Essentials } from '@ckeditor/ckeditor5-essentials';
import { Heading } from '@ckeditor/ckeditor5-heading';
import {
Image,
ImageCaption,
ImageStyle,
ImageToolbar,
ImageUpload,
ImageResize,
} from '@ckeditor/ckeditor5-image';
import { Indent } from '@ckeditor/ckeditor5-indent';
import { 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';
import { WordCount } from '@ckeditor/ckeditor5-word-count';
import { MyCustomUploadAdapterPlugin } from './MyUploadAdapter';
import { FileRepository } from '@ckeditor/ckeditor5-upload';
// 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 = [
FileRepository,
MyCustomUploadAdapterPlugin,
Autoformat,
BlockQuote,
Bold,
Essentials,
Heading,
Image,
ImageCaption,
ImageStyle,
ImageToolbar,
ImageUpload,
ImageResize,
Indent,
Italic,
Link,
List,
MediaEmbed,
Paragraph,
PasteFromOffice,
Table,
TableToolbar,
TextTransformation,
Underline,
Undo,
WordCount,
];
public static override defaultConfig: EditorConfig = {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'|',
'outdent',
'indent',
'|',
'imageUpload',
'blockQuote',
'insertTable',
'mediaEmbed',
'undo',
'redo',
'underline',
],
},
language: 'en',
image: {
resizeOptions: [
{
name: 'resizeImage:original',
value: null,
label: 'Original',
},
{
name: 'resizeImage:40',
value: '40',
label: '40%',
},
{
name: 'resizeImage:50',
value: '50',
label: '50%',
},
{
name: 'resizeImage:60',
value: '60',
label: '60%',
},
],
toolbar: [
'resizeImage',
'imageTextAlternative',
'toggleImageCaption',
'imageStyle:inline',
'imageStyle:block',
'imageStyle:side',
],
},
table: {
contentToolbar: ['tableColumn', 'tableRow', 'mergeTableCells'],
},
};
}
export default Editor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment