- I m trying to get ckeditor with html support to work within svelte.
<script>
import { onMount } from svelte ;
import ClassicEditor from @ckeditor/ckeditor5-build-classic ;
import { FullPage } from @ckeditor/ckeditor5-html-support ;
export let text = "";
onMount( () => {
ClassicEditor.create( document.querySelector( #editor ), {plugins : [FullPage]})
.then( editor => {
console.log( editor );
editor.setData( text );
editor.model.document.on( change:data , () => {
text = editor.getData();
} );
} )
.catch( error => {
console.error( error );
} );
});
</script>
<textarea id= editor ></textarea>
✔️ Expected result
I would expect the above code to result in a ckeditor instance with html support.
❌ Actual result
my js build using rollup gives me the below error
(!) Circular dependencies
node_modules/@ckeditor/ckeditor5-engine/src/view/position.js -> node_modules/@ckeditor/ckeditor5-engine/src/view/treewalker.js -> node_modules/@ckeditor/ckeditor5-engine/src/view/position.js
node_modules/@ckeditor/ckeditor5-engine/src/view/documentselection.js -> node_modules/@ckeditor/ckeditor5-engine/src/view/selection.js -> node_modules/@ckeditor/ckeditor5-engine/src/view/documentselection.js
node_modules/@ckeditor/ckeditor5-engine/src/model/position.js -> node_modules/@ckeditor/ckeditor5-engine/src/model/treewalker.js -> node_modules/@ckeditor/ckeditor5-engine/src/model/position.js
...and 4 more
created static/js/bundle.js in 13.7s
❓ Possible solution
If I remove the line as well as FullPage from the plugins array then I have no issues.
import { FullPage } from @ckeditor/ckeditor5-html-support ;
The editor will be instantiated. this could be an issue with my rollup.config.js --
import svelte from rollup-plugin-svelte ;
import resolve from @rollup/plugin-node-resolve ;
import commonjs from @rollup/plugin-commonjs ;
import livereload from rollup-plugin-livereload ;
import { terser } from rollup-plugin-terser ;
import css from "rollup-plugin-css-only";
import autoPreprocess from svelte-preprocess ;
import copy from rollup-plugin-copy ;
import scss from rollup-plugin-scss ;
import polyfillNode from rollup-plugin-polyfill-node ;
import svg from rollup-plugin-svg ;
const production = !process.env.ROLLUP_WATCH;
export default {
input: svelte-components/src/main.js , // (1)
output: {
sourcemap: true,
format: iife ,
name: app ,
file: static/js/bundle.js
},
plugins: [
svg(),
css({ output: "extra_bundle.css" }),
scss({
fileName: "bootstrap.css",
failOnError: true,
runtime: require("sass"),
}),
svelte({
// enable run-time checks when not in production
dev: !production,
// we ll extract any component CSS out into
// a separate file - better for performance
css: css => {
css.write( bundle.css ); // (3)
}
}),
// If you have external dependencies installed from
// npm, you ll most likely need these plugins. In
// some cases you ll need additional configuration -
// consult the documentation for details:
// https://github.com/rollup/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: [ svelte ]
}),
commonjs(),
// In dev mode, call `npm run start` once
// the bundle has been generated
!production && serve(),
// Watch the `public` directory and refresh the
// browser on changes when not in production
!production && livereload( svelte-components ), // (4)
// If we re building for production (npm run build
// instead of npm run dev), minify
production && terser(),
copy({
targets: [
{ src: node_modules/bootstrap/dist/js/bootstrap.min.js , dest: static/js },
],
verbose: true,
}),
polyfillNode(), // Add this plugin
terser()
],
watch: {
clearScreen: false
}
};
function serve() {
let started = false;
return {
writeBundle() {
if (!started) {
started = true;
require( child_process ).spawn( npm , [ run , start , -- , --dev ], {
stdio: [ ignore , inherit , inherit ],
shell: true
});
}
}
};
}
If you d like to see this fixed sooner, add a ? reaction to this post.