Skip to content
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

Templates support for CKEditor 5 #1585

Closed
eilskn opened this issue Feb 28, 2019 · 15 comments
Closed

Templates support for CKEditor 5 #1585

eilskn opened this issue Feb 28, 2019 · 15 comments
Labels
domain:v4-compatibility This issue reports a CKEditor 4 feature/option that's missing in CKEditor 5. squad:features Issue to be handled by the Features team. support:2 An issue reported by a commercially licensed client. type:feature This issue reports a feature request (an idea for a new functionality or a missing option).

Comments

@eilskn
Copy link

eilskn commented Feb 28, 2019

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;
};
@pomek

This comment has been minimized.

@pomek pomek closed this as completed Feb 28, 2019
@pomek pomek added the resolution:invalid This issue is invalid (e.g. reports a non-existent bug or a by-design behavior). label Feb 28, 2019
@Mgsy
Copy link
Member

Mgsy commented Feb 28, 2019

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.

@Mgsy Mgsy reopened this Feb 28, 2019
@Mgsy Mgsy added type:feature This issue reports a feature request (an idea for a new functionality or a missing option). status:confirmed and removed resolution:invalid This issue is invalid (e.g. reports a non-existent bug or a by-design behavior). labels Feb 28, 2019
@Mgsy Mgsy changed the title How to add template in ckeditor? React js Templates support for CKEditor 5 Feb 28, 2019
@wwalc
Copy link
Member

wwalc commented Feb 28, 2019

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

@dkrahn
Copy link
Contributor

dkrahn commented Mar 1, 2019

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.

@Reinmar Reinmar added this to the backlog milestone Mar 7, 2019
@jhhdk
Copy link

jhhdk commented Aug 12, 2019

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).

<root>
  <h1 locked='true'>1. Abstract<h1>
  <p>Lorem...</p>
</root>

@tbredin
Copy link

tbredin commented Aug 26, 2019

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

@celsowm
Copy link

celsowm commented Oct 20, 2019

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

@IshaVohra
Copy link

PLSS

@ghost
Copy link

ghost commented Jun 16, 2020

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).

<root>

  <h1 locked='true'>1. Abstract<h1>

  <p>Lorem...</p>

</root>

Did you manage to find something that functions like this?

@BloodBaz
Copy link

BloodBaz commented Aug 5, 2020

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.

@skerbis
Copy link

skerbis commented Aug 28, 2020

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

@eugene-f-ysbm
Copy link

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();
}

@martynawierzbicka martynawierzbicka added the support:2 An issue reported by a commercially licensed client. label Feb 19, 2021
@Reinmar Reinmar added domain:v4-compatibility This issue reports a CKEditor 4 feature/option that's missing in CKEditor 5. and removed domain:v4-compatibilty labels Mar 9, 2021
@MrStooby
Copy link

Hi,
I haven't found a plugin allowing to add predefined code in CkEditor and it doesn't seem to exist at the time of writing.
For the plugins, I imagine a function that calls a json or equivent file containing the predefined code with the possibility to add a title, a description, even a picture and keywords (to facilitate the search for templates).
The code would be integrated at the cursor location.

@Reinmar Reinmar added the squad:core Issue to be handled by the Core team. label Sep 27, 2021
@pomek pomek removed this from the backlog milestone Feb 21, 2022
@kmonty
Copy link

kmonty commented Mar 15, 2022

Noting this is a pretty popular feature in the Drupal ecosystem. More than 12,000 Drupal 8 / 9 / 10 sites use this feature in CKEditor 4. As Drupal 10 (to be released this summer) moves to CKEditor 5, I am worried about what the fallout of this feature being removed will look like for site editors.

I have one project that relies on it myself.

@mlewand
Copy link
Contributor

mlewand commented May 4, 2023

The feature has been shipped in version 37.1.0 and is available as a part of productivity pack feature set 🎉

You can give it a try in our content templates feature guide.

@mlewand mlewand closed this as completed May 4, 2023
@mlewand mlewand added this to the iteration 62 (v37.1.0) milestone May 4, 2023
@mlewand mlewand added squad:features Issue to be handled by the Features team. and removed squad:core Issue to be handled by the Core team. labels May 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:v4-compatibility This issue reports a CKEditor 4 feature/option that's missing in CKEditor 5. squad:features Issue to be handled by the Features team. support:2 An issue reported by a commercially licensed client. type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

No branches or pull requests