Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Simplified the structure of a build's source files #46

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions bin/build-ckeditor.sh

This file was deleted.

18 changes: 0 additions & 18 deletions bin/create-entry-file.js

This file was deleted.

61 changes: 0 additions & 61 deletions build-config.js

This file was deleted.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@
"url": "https://github.com/ckeditor/ckeditor5-build-classic.git"
},
"scripts": {
"build": "npm run create-entry-file && npm run build-ckeditor",
"create-entry-file": "node bin/create-entry-file.js",
"build-ckeditor": "sh bin/build-ckeditor.sh",
"build": "webpack",
"preversion": "npm run build; if [ -n \"$(git status src/ckeditor.js build/ --porcelain)\" ]; then git add -u src/ckeditor.js build/ && git commit -m 'Internal: Build.'; fi"
}
}
114 changes: 62 additions & 52 deletions src/ckeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,67 +5,77 @@

import ClassicEditorBase from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials';
import UploadadapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import UploadAdapterPlugin from '@ckeditor/ckeditor5-adapter-ckfinder/src/uploadadapter';
import AutoformatPlugin from '@ckeditor/ckeditor5-autoformat/src/autoformat';
import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold';
import ItalicPlugin from '@ckeditor/ckeditor5-basic-styles/src/italic';
import BlockquotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
import EasyimagePlugin from '@ckeditor/ckeditor5-easy-image/src/easyimage';
import BlockQuotePlugin from '@ckeditor/ckeditor5-block-quote/src/blockquote';
import EasyImagePlugin from '@ckeditor/ckeditor5-easy-image/src/easyimage';
import HeadingPlugin from '@ckeditor/ckeditor5-heading/src/heading';
import ImagePlugin from '@ckeditor/ckeditor5-image/src/image';
import ImagecaptionPlugin from '@ckeditor/ckeditor5-image/src/imagecaption';
import ImagestylePlugin from '@ckeditor/ckeditor5-image/src/imagestyle';
import ImagetoolbarPlugin from '@ckeditor/ckeditor5-image/src/imagetoolbar';
import ImageuploadPlugin from '@ckeditor/ckeditor5-image/src/imageupload';
import ImageCaptionPlugin from '@ckeditor/ckeditor5-image/src/imagecaption';
import ImageStylePlugin from '@ckeditor/ckeditor5-image/src/imagestyle';
import ImageToolbarPlugin from '@ckeditor/ckeditor5-image/src/imagetoolbar';
import ImageUploadPlugin from '@ckeditor/ckeditor5-image/src/imageupload';
import LinkPlugin from '@ckeditor/ckeditor5-link/src/link';
import ListPlugin from '@ckeditor/ckeditor5-list/src/list';
import ParagraphPlugin from '@ckeditor/ckeditor5-paragraph/src/paragraph';

export default class ClassicEditor extends ClassicEditorBase {}

ClassicEditor.build = {
plugins: [
EssentialsPlugin,
UploadadapterPlugin,
AutoformatPlugin,
BoldPlugin,
ItalicPlugin,
BlockquotePlugin,
EasyimagePlugin,
HeadingPlugin,
ImagePlugin,
ImagecaptionPlugin,
ImagestylePlugin,
ImagetoolbarPlugin,
ImageuploadPlugin,
LinkPlugin,
ListPlugin,
ParagraphPlugin
],
config: {
toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'imageUpload',
'blockQuote',
'undo',
'redo'
]
},
image: {
toolbar: [
'imageStyle:full',
'imageStyle:side',
'|',
'imageTextAlternative'
]
},
language: 'en'
}
// Plugins which will be automatically loaded when creating an instance of this editor build.
// Note: New plugins should not be added to an existing editor build. They should be added at this stage.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New plugins -> Additional plugins

ClassicEditor.defaultPlugins = [
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of calling it "buildInPlugins" because this is exactly what it is, and emphasize the fact that you can not change it in the runtime.

EssentialsPlugin,
UploadAdapterPlugin,
AutoformatPlugin,
BoldPlugin,
ItalicPlugin,
BlockQuotePlugin,
EasyImagePlugin,
HeadingPlugin,
ImagePlugin,
ImageCaptionPlugin,
ImageStylePlugin,
ImageToolbarPlugin,
ImageUploadPlugin,
LinkPlugin,
ListPlugin,
ParagraphPlugin
];

// The default configuration of this editor build.
// It can be overridden by passing your own options to the `create()` method.
//
// See all the configuration options:
// https://docs.ckeditor.com/ckeditor5/latest/api/module_core_editor_editorconfig-EditorConfig.html
ClassicEditor.defaultConfig = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, I would not use buildInConfig. This it defaultConfig, which can be easily overwritten.

toolbar: {
items: [
'heading',
'|',
'bold',
'italic',
'link',
'bulletedList',
'numberedList',
'imageUpload',
'blockQuote',
'undo',
'redo'
]
},
image: {
toolbar: [
'imageStyle:full',
'imageStyle:side',
'|',
'imageTextAlternative'
]
},

// UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
//
// See: https://docs.ckeditor.com/ckeditor5/latest/features/ui-language.html
language: 'en'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to deduplicate it, this variable could be also overwritten by CKEditorWebpackPlugin since it already replaces some strings in the editor.

};
13 changes: 9 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,29 @@ const webpack = require( 'webpack' );
const { bundler, styles } = require( '@ckeditor/ckeditor5-dev-utils' );
const CKEditorWebpackPlugin = require( '@ckeditor/ckeditor5-dev-webpack-plugin' );
const BabiliPlugin = require( 'babel-minify-webpack-plugin' );
const buildConfig = require( './build-config' );

module.exports = {
devtool: 'source-map',

entry: path.resolve( __dirname, 'src', 'ckeditor.js' ),

output: {
// The name under which the editor will be exported.
library: 'ClassicEditor',

path: path.resolve( __dirname, 'build' ),
filename: 'ckeditor.js',
libraryTarget: 'umd',
libraryExport: 'default',
library: buildConfig.moduleName
libraryExport: 'default'
},

plugins: [
new CKEditorWebpackPlugin( {
language: buildConfig.config.language,
// UI language. Language codes follow the https://en.wikipedia.org/wiki/ISO_639-1 format.
// When changing the builtin language, remember to also change it in the ditor's config (src/ckeditor.js).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// When changing the built-in language, remember to also change it in the editor's configuration (src/ckeditor.js).

//
// See: https://docs.ckeditor.com/ckeditor5/latest/features/ui-language.html
language: 'en',
additionalLanguages: 'all'
} ),
new BabiliPlugin( null, {
Expand Down