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

how to allow insert custom block element to document list? #11927

Closed
kuku711 opened this issue Jun 15, 2022 · 3 comments
Closed

how to allow insert custom block element to document list? #11927

kuku711 opened this issue Jun 15, 2022 · 3 comments
Labels
resolution:resolved This issue was already resolved (e.g. by another ticket). type:task This issue reports a chore (non-production change) and other types of "todos".

Comments

@kuku711
Copy link

kuku711 commented Jun 15, 2022

Provide a description of the task

I want to create custom element of block type and be able to insert the element inside a document list,
there is a way to do it? i dont see there is schema of document list that let me do allow children

@kuku711 kuku711 added the type:task This issue reports a chore (non-production change) and other types of "todos". label Jun 15, 2022
@dufipl
Copy link
Contributor

dufipl commented Jun 15, 2022

Hello @kuku711,

For the starters, please be aware that the document list is currently on the "experimental" level (#2973 (comment)) and we don't recommend using it in production without assessing the risk.

However, if you decide to give it a try, I can provide some tips for you.

If you would like to create your own custom widget and use it with the document lists, you need to register it inside of the schema as $blockObject:

schema.register( 'customWidget', {
	inheritAllFrom: '$blockObject',
	isBlock: true
} );

It is one of our generic items: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/deep-dive/schema.html#generic-items

Also, to insert that element you should use model.insertObject() instead of model.insertContent(). Example of that you can find here:

model.insertObject( htmlEmbedElement, null, null, { setSelection: 'on' } );

I hope that will help you, but please let me know if something remains unclear. :)

@kuku711
Copy link
Author

kuku711 commented Jun 15, 2022

thanks, its work !
i know its experimental i'm just checking my custom widgets because we will move to use it when it will be ready and will support to-dolist.

@dufipl
Copy link
Contributor

dufipl commented Jun 15, 2022

I'm very glad to hear that! :)

I will close the issue now but feel free to post new comments in case of any additional questions.

@dufipl dufipl closed this as completed Jun 15, 2022
@dufipl dufipl added the resolution:resolved This issue was already resolved (e.g. by another ticket). label Jun 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution:resolved This issue was already resolved (e.g. by another ticket). type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

No branches or pull requests

2 participants