Ckeditor5: Templates support for CKEditor 5

Created on 28 Feb 2019  Â·  12Comments  Â·  Source: ckeditor/ckeditor5

How to add custom Templates to CKEditor 5 like in CKEditor 4?

CKEDITOR.editorConfig = function( config ) {
    config.templates_files = ['/js/ckeditor/templates/default.js'];
    config.templates = 'default';
    config.allowedContent = true;
    config.templates_replaceContent = true;
};
feature

All 12 comments

This is a repository for CKEditor 5. You should create the issue in the CKEditor 4 React integration repository – https://github.com/ckeditor/ckeditor4-react/issues.

CKEditor 5 doesn't support templates as CKEditor 4, so there is no possibility to define them.

I'm re-opening this issue as a feature request for the templates support. Feel free to add a comment about it and describe your use case or thoughts on how it should be implemented.

I remember that someone asked about such a feature via support channel at least once too.

What I am seeking is a page template where there are editable areas. Some users will be able to edit the whole template and some will only be able to fill out the editable areas.

Was about to post duplicate, posting here instead:
I am wondering whether it is possible given the existing api's to create a plugin that would enforce a mandatory document structure? I am not thinking word like forms per say, more like a word template where the stuff inherited from the template would not be editable(/deletable).
html <root> <h1 locked='true'>1. Abstract<h1> <p>Lorem...</p> </root>

Use case example: my team is looking at building a document editor that allows users to set up reusable page layouts, including a header and footer (see: #1759 ) per-page (seems related to this). In our case, these are printable a4 documents, eg a legal document

I was looking for something similar, I found the one used by this company, I hope one day ckeditor has something like or better: https://ej2.syncfusion.com/demos/#/material/document-editor/headers-and-footers.html

PLSS

Was about to post duplicate, posting here instead:

I am wondering whether it is possible given the existing api's to create a plugin that would enforce a mandatory document structure? I am not thinking word like forms per say, more like a word template where the stuff inherited from the template would not be editable(/deletable).

````html

1. Abstract

Lorem...

````

Did you manage to find something that functions like this?

I am wondering whether it is possible given the existing api's to create a plugin that would enforce a mandatory document structure?

This is a separate feature to the one described in this thread. This thread is specifically about having a list of prepared content templates which can be selected to replace the current content (or insert as a snippet into an existing document content). It was a feature of older CKEditors but has not been implemented in v5.

Making parts of a content "readonly" / "locked" would be a separate feature.

Yes. That would be cool. Predefined Text or Content, but not to replace the content, better to insert at cursor position.

Yes. That would be cool. Predefined Text or Content, but not to replace the content, better to insert at cursor position.

public addTemplate(value: string | SafeHtml): void {
const viewFragment = this.ckEditor.data.processor.toView(value);
const modelFragment = this.ckEditor.data.toModel(viewFragment);
this.ckEditor.model.insertContent(modelFragment);
this.ckEditor.editing.view.scrollToTheSelection();
}

Was this page helpful?
0 / 5 - 0 ratings