Skip to content

Commit

Permalink
BC-5565 - classic toolbar mode (#13)
Browse files Browse the repository at this point in the history
* Add classic toolbar

* Add image via URL support
  • Loading branch information
christian-darsow authored Nov 24, 2023
1 parent a87ee7f commit b1a855e
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 14 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Custom version of CKEditor5 for the Schulcloud-Verbund-Software-Client
npm i @hpi-schul-cloud/ckeditor
```

## Supported editor modes

- classic toolbar
- balloon toolbar

## Built-in plugins

- AutoFormat
Expand All @@ -18,6 +23,8 @@ npm i @hpi-schul-cloud/ckeditor
- Heading
- Highlight
- HorizontalLine
- Image
- ImageInsertViaUrl
- Italic
- Link
- List
Expand All @@ -32,6 +39,8 @@ npm i @hpi-schul-cloud/ckeditor
- TableToolbar
- WordCount

Note: the included image plugins only support an image insertion via URL, not via upload

## Supported languages

- de
Expand Down
52 changes: 52 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hpi-schul-cloud/ckeditor",
"version": "0.4.0",
"version": "1.0.0",
"description": "Custom version of CKEditor5 for the Schulcloud-Verbund-Software-Client",
"author": "Dataport Schulcloud-Verbund-Software Team",
"repository": {
Expand All @@ -26,10 +26,12 @@
"@ckeditor/ckeditor5-dev-translations": "^32.1.2",
"@ckeditor/ckeditor5-dev-utils": "^32.1.2",
"@ckeditor/ckeditor5-editor-balloon": "^37.1.0",
"@ckeditor/ckeditor5-editor-classic": "^37.1.0",
"@ckeditor/ckeditor5-essentials": "^37.1.0",
"@ckeditor/ckeditor5-heading": "^37.1.0",
"@ckeditor/ckeditor5-highlight": "^37.1.0",
"@ckeditor/ckeditor5-horizontal-line": "^37.1.0",
"@ckeditor/ckeditor5-image": "^37.1.0",
"@ckeditor/ckeditor5-link": "^37.1.0",
"@ckeditor/ckeditor5-list": "^37.1.0",
"@ckeditor/ckeditor5-paragraph": "^37.1.0",
Expand Down
37 changes: 29 additions & 8 deletions sample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="de">
<head>
<meta charset="utf-8" />
<title>CKEditor 5 – Editor preview</title>
<title>CKEditor5 – Editor preview</title>
<style>
body {
max-width: 920px;
Expand All @@ -16,14 +16,21 @@
<link rel="stylesheet" href="../build/ckeditor.css" />
</head>
<body>
<h2>CKEditor 5 – edit</h2>
<h1>CKEditor5 – Editor preview</h1>

<div id="editor">
<h2>Classic toolbar (de Version)</h2>
<div id="classiceditor">
Initial <strong>content</strong> of
<mark class="marker-blue">editor</mark>
</div>

<h2>CKEditor 5 – view</h2>
<h2>Balloon toolbar (en Version)</h2>
<div id="ballooneditor">
Initial <strong>content</strong> of
<mark class="marker-blue">editor</mark>
</div>

<h2>CK content view</h2>
<div id="view" class="ck-content">
Initial <strong>content</strong> of
<mark class="marker-blue">editor</mark>
Expand All @@ -43,11 +50,25 @@ <h2>Formula rendering from markup</h2>
<script src="../build/translations/uk.js"></script>
<script>
console.log(
CustomCKEditor.builtinPlugins.map((plugin) => plugin.pluginName)
CustomCKEditor.ClassicEditor.builtinPlugins.map(
(plugin) => plugin.pluginName
)
);
CustomCKEditor.create(document.querySelector("#editor"), {
language: "de",
}).catch((error) => {
CustomCKEditor.ClassicEditor.create(
document.querySelector("#classiceditor"),
{
language: "de",
}
).catch((error) => {
console.error(error);
});

CustomCKEditor.BalloonEditor.create(
document.querySelector("#ballooneditor"),
{
language: "en",
}
).catch((error) => {
console.error(error);
});

Expand Down
23 changes: 18 additions & 5 deletions src/ckeditor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BalloonEditor from "@ckeditor/ckeditor5-editor-balloon/src/ballooneditor.js";
import { BalloonEditor as BalloonEditorBase } from "@ckeditor/ckeditor5-editor-balloon";
import { ClassicEditor as ClassicEditorBase } from "@ckeditor/ckeditor5-editor-classic";
import Autoformat from "@ckeditor/ckeditor5-autoformat/src/autoformat";
import BlockQuote from "@ckeditor/ckeditor5-block-quote/src/blockquote.js";
import Bold from "@ckeditor/ckeditor5-basic-styles/src/bold.js";
Expand All @@ -7,6 +8,8 @@ import Essentials from "@ckeditor/ckeditor5-essentials/src/essentials.js";
import Heading from "@ckeditor/ckeditor5-heading/src/heading.js";
import Highlight from "@ckeditor/ckeditor5-highlight/src/highlight.js";
import HorizontalLine from "@ckeditor/ckeditor5-horizontal-line/src/horizontalline.js";
import { Image } from "@ckeditor/ckeditor5-image";
import ImageInsertViaUrl from "@ckeditor/ckeditor5-image/src/imageinsertviaurl.js";
import Italic from "@ckeditor/ckeditor5-basic-styles/src/italic.js";
import Link from "@ckeditor/ckeditor5-link/src/link.js";
import List from "@ckeditor/ckeditor5-list/src/list.js";
Expand All @@ -30,9 +33,10 @@ import "./variables.css";
import "./content-styles.css";
import "./custom-content-styles.css";

class Editor extends BalloonEditor {}
class BalloonEditor extends BalloonEditorBase {}
class ClassicEditor extends ClassicEditorBase {}

Editor.builtinPlugins = [
const plugins = [
Autoformat,
BlockQuote,
Bold,
Expand All @@ -41,6 +45,8 @@ Editor.builtinPlugins = [
Heading,
Highlight,
HorizontalLine,
Image,
ImageInsertViaUrl,
Italic,
Link,
List,
Expand All @@ -57,7 +63,7 @@ Editor.builtinPlugins = [
WordCount,
];

Editor.defaultConfig = {
const config = {
toolbar: {
items: [
"undo",
Expand All @@ -74,6 +80,7 @@ Editor.defaultConfig = {
"subscript",
"|",
"link",
"insertImage",
"bulletedList",
"numberedList",
"math",
Expand All @@ -97,9 +104,15 @@ Editor.defaultConfig = {
},
};

BalloonEditor.builtinPlugins = plugins;
ClassicEditor.builtinPlugins = plugins;

BalloonEditor.defaultConfig = config;
ClassicEditor.defaultConfig = config;

addMissingTranslationsDe();
addMissingTranslationsEn();
addMissingTranslationsEs();
addMissingTranslationsUk();

export default Editor;
export default { BalloonEditor, ClassicEditor };

0 comments on commit b1a855e

Please sign in to comment.