goodphp / grapesjs-plugin-ckeditor5 Goto Github PK
View Code? Open in Web Editor NEWThis plugin replaces the default Rich Text Editor with the one from CKEditor5
This plugin replaces the default Rich Text Editor with the one from CKEditor5
I am following README.md and I have the following index.html:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Ckeditor5</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="assets/grapes.min.css" rel="stylesheet">
<script src="assets/grapes.min.js"></script>
<script src="assets/grapesjs-preset-webpage.min.js"></script>
<link href="assets/grapesjs-preset-webpage.min.css" rel="stylesheet">
<script src="assets/ckeditor5.js"></script>
<script src="assets/grapesjs-plugin-ckeditor5.min.js"></script>
</head>
<body>
<div id="gjs">
</div>
<script type="text/javascript">
var editor = grapesjs.init({
container : '#gjs',
plugins: ['gjs-plugin-ckeditor5'],
pluginsOpts: {
'gjs-plugin-ckeditor5': {
position: 'left',
options: {
trackChanges: {},
toolbar: {
items: [
'heading',
'|',
'fontColor',
'fontSize',
'fontFamily',
'fontBackgroundColor',
'alignment',
'bold',
'italic',
'underline',
'strikethrough',
'link',
'bulletedList',
'numberedList',
'horizontalLine',
'|',
'outdent',
'indent',
'|',
'blockQuote',
'insertTable',
'|',
'undo',
'redo'
]
},
language: 'en',
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells',
'tableCellProperties',
'tableProperties'
]
},
licenseKey: ''
}
}
}
});
</script>
<app-root></app-root>
</body>
</html>
But when I load it, I get console error:
Uncaught ReferenceError: ClassicEditor is not defined
at grapesjs-plugin-ckeditor5.min.js:2:8361
at grapes.min.js:2:676285
at Array.forEach (<anonymous>)
at Object.init (grapes.min.js:2:676122)
at (index):21:27
The versions that I have installed and put in the assets
folder (to load them from index.html
following the README.md):
"grapesjs": "0.18.2",
"grapesjs-plugin-ckeditor5": "0.0.33",
"grapesjs-preset-webpage": "^0.1.11",
This plugin is also missing guidance on how to use it when installed as package from npm (with
import 'grapesjs-plugin-ckeditor5'`).
When I use this lib for Angular (14) I still have the default text editor.
angular.json
"styles": [
"src/styles.scss",
"./node_modules/grapesjs/dist/css/grapes.min.css",
],
"scripts": [
"./node_modules/grapesjs/dist/grapes.min.js",
"./node_modules/grapesjs-preset-newsletter/dist/index.js",
"./node_modules/grapesjs-plugin-ckeditor5/ckeditor5/build/ckeditor.js",
"./node_modules/grapesjs-plugin-ckeditor5/dist/grapesjs-plugin-ckeditor5.min.js"
]
web-builder.component.ts
(I cannot perform import pluginCkEditor from 'grapesjs-plugin-ckeditor5';
)
import { Component, OnInit } from '@angular/core';
import grapesjs from 'grapesjs';
import plugin from 'grapesjs-preset-newsletter';
@Component({
selector: 'app-web-builder',
templateUrl: './web-builder.component.html',
styleUrls: ['./web-builder.component.scss']
})
export class WebBuilderComponent implements OnInit {
public editor:any = null
constructor() { }
ngOnInit(): void {
this.editor = grapesjs.init({
container: '#gjs',
fromElement: true,
height: '700px',
width: 'auto',
storageManager: false,
panels: { defaults: [] },
plugins: [plugin, 'gjs-plugin-ckeditor5'],
pluginsOpts: {
'gjs-plugin-ckeditor5': {
position: 'left',
options: {
trackChanges: {},
toolbar: {
items: [
'heading',
'|',
'fontColor',
'fontSize',
'fontFamily',
'fontBackgroundColor',
'alignment',
'bold',
'italic',
'underline',
'strikethrough',
'link',
'bulletedList',
'numberedList',
'horizontalLine',
'|',
'outdent',
'indent',
'|',
'blockQuote',
'insertTable',
'|',
'undo',
'redo'
]
},
language: 'en',
table: {
contentToolbar: [
'tableColumn',
'tableRow',
'mergeTableCells',
'tableCellProperties',
'tableProperties'
]
},
licenseKey: ''
}
}
}
});
}
}
We have a problem with using this ckeditor5 grapesjs plugin. We are providing an external css that is loaded inside the grapesjs iframe
to style the grapesjs content the user creates. But when the user double-clicks a text in grapesjs editor to open ckeditor5 popup, the content inside the ckeditor does not use the css loaded inside grapesjs - this makes the content inside the ckeditor5 popup different compared to what the user sees in grapesjs. Our question is can the plugin somehow open the ckeditor5 editor inside the grapesjs iframe so the same css is applied to the ckeditor5 editor content ?
The dist
folder contains older version of the plug in compared to what it has in the src/index.js
. The dist
version is 4 months older compared to src/index.js
.
This plugin (this one in dist
folder) relies on the presence of variable named editor
in the global window
object. This has to be removed fixed - editor.Modal.close()
.
The sample code in the repository does not provide correct information - the blocks list is empty and the user cannot actually test the plug in. I needed to install and use gjs-preset-webpage
grapesjs plug in to actually make the sample workable.
How to reproduce:
gjs-preset-webpage
- see how to in the official grapesjs page grapesjs.com )index.html
page renaming var editor = grapesjs.init(...
to var abc = grapesjs.init(...
(because we don't use hard coded names in our code)What happens:
The modal editor is not closed. Error is shown in the browser console:
(index):1 Uncaught ReferenceError: editor is not defined
at HTMLInputElement.onclick
The error is because the plugin code in the dist
folder relies on the presence of variable named editor
in the window
object.
I wanted to incorporate this plugin for Grapes but it is not available in npm
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.