Comments (12)
Ok, after some search and tries I finally understand the problem.
Long answer:
As @jodator said, in a VueJs project, it used it own loader (for SVG in this case) and Ckeditor its own.
I said earlier I test two solutions proposed by Ckeditor docs. The first work for Ckeditor and no more for my project, in fact because this solution reset the SVG loader my Vue app is not able any more to load SVG.
After this, I follow the second solution.
I try to load an other rule in webpack-chain
and/or modify the .test
function inside the Ckeditor's one.
Nothing will work ! In fact fontawesome
package was ever loader inside my Vue app so for any reason can't be loaded twice with an other loader. This is the reason why it doesn't work.
The solution was copying my font to an other location and add a rule to load it through Ckeditor's loader aka: raw-loader
.
Short answer:
- Copy your font elsewere
my/custom/folder
- Exclude it from the
svgRules
:
svgRule.exclude.add(path.join(__dirname, 'my/custom/folder'))
- Create an new rule to load it
config.module
.rule('cke-plugin-browser')
.test(/my[/\\]custom[/\\]folder[/\\][^/\\]+\.svg$/)
.use('raw-loader')
.loader('raw-loader')
Idea
I don't know if it possible but, why not use Vue loader when ckeditor-vue
is used ?
Despite this last question, I close this issue because solved for me.
from ckeditor5-vue.
@kl3sk Quick question: where do you put the SVG icon? The icons from CKEditor 5 are put in specific folders in order to raw-loader
and not Vue's loader would load them:
// vue.config.js as in first linked docs:
config.module
.rule( 'cke-svg' )
.test( /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/ )
.use( 'raw-loader' )
.loader( 'raw-loader' );
The trick part here is that Vue uses other loader then CKEditor 5 for SVGs. This code tests for CKEditor 5 icons located under theme/icons
in every ckeditor5-package
. So if you put it in you plugin you should add a .test()
condition to match your icons and add it to the cke-svg
and check if they are loaded then.
I'd try with something like this:
config.module
.rule( 'cke-svg' )
.test( /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/ )
.test( /my-plugin[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/ ) // <- added
.use( 'raw-loader' )
.loader( 'raw-loader' );
from ckeditor5-vue.
@jodator thanks for your answer.
I try to add like this
config.module
.rule( 'cke-svg' )
.test( /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/ )
.test(/fontawesome-[^/\\]+[/\\]svgs[/\\](solid|regular|brand)[/\\][^/\\]+\.svg$/)
.use( 'raw-loader' )
.loader( 'raw-loader' )
Edit:
Here is a part of the error
error in ./node_modules/@ckeditor/ckeditor5-image/theme/icons/image_placeholder.svg
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 700 250"><rect rx="4"/></svg>
@ ./node_modules/@ckeditor/ckeditor5-image/src/imageupload/imageuploadprogress.js 21:0-75 54:72-92
@ ./node_modules/@ckeditor/ckeditor5-image/src/imageupload.js
@ ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Document/Document.vue?vue&type=script&lang=js&
@ ./src/views/Document/Document.vue?vue&type=script&lang=js&
@ ./src/views/Document/Document.vue
@ ./src/router.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://192.168.121.62:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.js
from ckeditor5-vue.
It must be something with the paths, I've used vue icon from FA and used in one of manual tests (no Vue integration and loaded from default location):
I don't recall exactly what part of path was checked but double check them for typos ;)
Also adding another rule with one test might help (I don't recall how this API worked TBH):
config.module
.rule( 'my-svg' )
// start with direct path (ie inside your project)
.test( /last\/part\/of\/path\/to\/icon.svg$/ )
.use( 'raw-loader' )
.loader( 'raw-loader' )
Edit: The error show that the loader didn't kick in so probably the path is wrong or the test should be written differently.
from ckeditor5-vue.
Ok i'll try to check my path. But @fortawesome/fontawesome-free/svgs/solid/search.svg
(for example) seem good because I test the regex.
BTW I tried to create an other rule too.
from ckeditor5-vue.
With this rule:
config.module
.rule('my-svg')
.test(/fontawesome-free\/svgs\/solid\/search\.svg$/)
.use('raw-loader')
.loader('raw-loader')
and this import:
import imageIcon from '@fortawesome/fontawesome-free/svgs/solid/search.svg'
I have still the error.
May I've made a typo I didn't saw ?
EDIT:
I have this in my console too
TypeError: "svg is null"
EDIT2:
Erreur d’analyse XML : mal formé -> XML parsing error: incorrectly formed
from ckeditor5-vue.
Alrighty:
you have two options (noted in the docs)
a) clear the rules (if you don't have other SVGs)
chainWebpack: config => {
const svgRule = config.module.rule( 'svg' );
svgRule.uses.clear();
svgRule.use( 'raw-loader' ).loader( 'raw-loader' );
}
Option b) leave other svg intact
chainWebpack: config => {
const svgRule = config.module.rule( 'svg' );
svgRule.exclude.add(__dirname + "/node_modules/@ckeditor");
svgRule.exclude.add(__dirname + "/node_modules/@fortawesome"); // ! this
config.module
.rule( 'cke-svg' )
// beautify this or use another rule
.test( /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg|svgs\/brands\/vuejs\.svg$/ )
.use( 'raw-loader' )
.loader( 'raw-loader' )
// add .rule( 'my-svg' ) below with one `test()` call per svg path.
}
the app:
<template>
<div id="app">
<ckeditor :editor="editor" v-model="editorData" :config="editorConfig"></ckeditor>
</div>
</template>
<script>
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import EssentialsPlugin from '@ckeditor/ckeditor5-essentials/src/essentials';
import BoldPlugin from '@ckeditor/ckeditor5-basic-styles/src/bold';
import ItalicPlugin from '@ckeditor/ckeditor5-basic-styles/src/italic';
import LinkPlugin from '@ckeditor/ckeditor5-link/src/link';
import ParagraphPlugin from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ButtonView from '@ckeditor/ckeditor5-ui/src/button/buttonview';
import vueIcon from '@fortawesome/fontawesome-free/svgs/brands/vuejs.svg'
// import vueIcon from '@ckeditor/ckeditor5-basic-styles/theme/icons/bold.svg'
class MyPlugin extends Plugin {
init() {
this.editor.ui.componentFactory.add( 'vuebutton', locale => {
const buttonView = new ButtonView( locale );
buttonView.set( {
label: 'Vue icon',
tooltip: true,
withText: true,
icon: vueIcon
} );
this.listenTo( buttonView, 'execute', () => {
// eslint-disable-next-line
console.log('uga')
} );
return buttonView;
} );
}
}
export default {
name: 'app',
data() {
return {
editor: ClassicEditor,
editorData: '<p>Content of the editor.</p>',
editorConfig: {
plugins: [
EssentialsPlugin,
BoldPlugin,
ItalicPlugin,
LinkPlugin,
ParagraphPlugin,
MyPlugin
],
toolbar: {
items: [
'bold',
'italic',
'link',
'undo',
'redo',
'vuebutton'
]
}
}
};
}
};
</script>
ps.: Don't forget to start & stop dev server since it needs to reload webpack config.
and works with Vue like this:
from ckeditor5-vue.
I read the docs, and I tried both solutions.
The first work but my others SVG doesn't works any more, so I jump to the other solution and even with your sample it does the same.
I ever try your solution without any working code.
edit: BTW I reload my dev server each time :)
from ckeditor5-vue.
Check the svgRule.exclude.add(__dirname + "/node_modules/@fortawesome");
part. If you use some Font Awesome SVGs for CKEditor 5 and some for other code of Vue app you might need to copy some of them to other location to be usable with CKEditor 5 icons (`raw-loader). I don't see any easy fix for this.
ps.: @kl3sk you can post your solution if you mange to make this working :)
from ckeditor5-vue.
Yes i'll do if i find.
An other clue, I use a custom build, maybe it is the problem ?
from ckeditor5-vue.
I don't know if it possible but, why not use Vue loader when
ckeditor-vue
is used ?
AFAIR the vue uses file-loader
which just outputs URI to a file. In CKE5 we're bundling the SVG contents into the package. We're using raw-loader
to load SVG contents and then use it to create an icon.
from ckeditor5-vue.
It could maybe be added to the docs.
from ckeditor5-vue.
Related Issues (20)
- ckeditor vue plugins css build error (with any plugin) HOT 4
- strikethrough and underline not listing as toolbar items
- Automated tests and coverage fails on Windows HOT 2
- CKFiner errors: CKEditorError: window.CKFinder is undefined & undefined (reading 'modal') HOT 1
- `emitDebouncedInputEvent` causes performance issue with long and complex content HOT 3
- Performance issues in processing content with multiple paragraphs containing multiple inline widgets HOT 2
- [VUE] Align the release process to the changes in ckeditor5-dev
- Custom build issues (object, instead of function) - Documentation issues? HOT 1
- v-model, events "input" or "update: model-value" do not work in source edit mode HOT 3
- Uncaught ReferenceError: global is not defined HOT 1
- Migrate to CircleCI in ckeditor/ckeditor5-vue
- Add link popup have wrong position in Modal with fixed mask HOT 3
- Uncaught SyntaxError when integrating a build from the online builder when using `npm add file:./ckeditor5` in Vue HOT 7
- Table captions is absent HOT 3
- Add support for multi-root editor
- How to set the height of the editor in Vue3? I set CSS, but none of it worked HOT 8
- vue3+ts+vite use custom build HOT 1
- Allow control of batchType options in model-value watcher
- Investigate warning
- Bug Report: Strikethrough Not Showing on Vue 3 with CKEditor
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ckeditor5-vue.