-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dataprocessor and XML (and other formats) #417
Comments
Hi, thanks for asking! :) This is a great question and something we've kept in mind for a long time, but never explained publicly. Small disclaimer – some (most?) of the docs on https://github.com/ckeditor/ckeditor5-design/wiki/ are outdated because it turned out that maintaining even such a high-level docs takes an awful lot of time. So, this post takes precedence over what you can find in the design wiki. Fortunately, it shouldn't get outdated because we're very close to 1.0.0 now. We're yet to write an architecture overview, but we need a quick intro about it to be able to answer your question. This diagram shows (with some minor mistakes and outdated pieces) how the CKEditor 5 engine is structured: It's basically an MVC adjusted to the reality of text content editing.
Now, the default features the editor provides (everything, even typing is a pluggable feature) make some assumptions regarding the type of the content (e.g. the heading feature assumes that you can only apply it to the entire paragraph, not a half of it, like in MSWord). Then, there's There are like dozen of levels on which you can modify the editor behaviour. There are very few limitation imposed by the engine – you can pick and choose from it, however, developing the engine took us already 3 years, so you can imagine that if you'd like to replace one part, it may be like a year of work :D. Anyway, if you just need to output the content in a different data format (without changing the editing behaviour) you can just plug a different data processor. If you need to render things differently to the user, you need to work on converters. If you want to change what kind of content is allowed where (e.g. that bold can't be used in headings), you can use the schema. Finally, if some feature like typing should work differently (cause you need to impose special restrictions or something) you can tune up the existing typing feature (by listening on the model's I hope I answered your question or at least clarified a bit how it works. Let me know if something remained unclear :). |
Hi wow, thanks for the prompt and very complete answer. I think I have to read it multiple times before understanding it completely :) Anyway, the latest paragraph of your answer basically tells me everything I needed to know: we can render the XML in a human readable format, we can use the schema to control what is allowed and we can get back XML. kikkauz |
You may be interested in checking the (experimental) Markdown Data Processor: The approach is pretty simple. It uses HTML as the intermediary format between the target format (Markdown) and the Data View. You may go the same way. |
BTW, we miss an info how to easily plug in the data processor. An editor instance stores the data processor instance under We didn't make it straightforward yet how to inject a different DP (see https://github.com/ckeditor/ckeditor5-core/issues/11), but most likely each DP will have an accompanying plugin which will enable it. So, currently you can do this: import MarkdownDP from '@ckeditor/ckeditor5-markdown-gfm/src/gfmdataprocessor';
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classic';
import ArticlePreset from '@ckeditor/ckeditor5-presets/src/article';
// A plugin which will replace the default DP with MarkdownDP.
class MarkdownDPPlugin extends Plugin {
constructor( editor ) {
super( editor );
editor.data.processor = new MarkdownDP();
}
}
ClassicEditor.create( element, {
plugins: [ ArticlePreset, MarkdownDPPlugin ]
} )
.then( ( editor ) => {
console.log( editor );
} )
.catch( ( err ) => {
console.error( err );
} ); I think it should do the job. |
Hello
I hope I'm asking the question in the right place.
According to what I read here
https://github.com/ckeditor/ckeditor5-design/wiki/Data-Processing
I understand that it should be possible to have the server-side content in any format and that it is then possible to customize the "dataprocess process" to convert it in and out CKEditor.
This is something that really interests me as I'm asked to provide a wysiwyg online editor for structures XML content (with a complex schema).
But if I have a look to the xmlprocess file, for instance, it's hard for me to understand how I could extend or configure it to respond to my need.
Could someone please shed some light on this aspect of version 5? It looks very promising for me!
Thanks!
kikkauz
The text was updated successfully, but these errors were encountered: