-
-
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
Support for nested tables #3232
Comments
Quote from #1260 (comment)
|
@Reinmar I have a specific use case that would require editing nested tables. This would be a must have feature for my team so if there is anyway to put it on the roadmap that would be very much appreciated. Many of our current users are used to using Microsoft Word, so to properly convert some of these files to a web editing interface they would need to be able to nest tables inside of table like their current documents support. |
@Reinmar is there any update on supporting a table in table feature? |
@Reinmar I hate to keep bugging you about this but is there anyway for me to help implement this. Is there documentation I can read to try to help contribute to this project so I can attempt to add table in table support. This is a very important feature for my team to have for our specific use case. |
Hi Austin! The good news is that nested tables are actually supported, but this is disabled for simplicity via the schema. We had to reduce the scope initially, but from what I can see it's working quite fine. To enable tables inside tables, you need to override the schema check which disables them. This check is a callback to editor.model.schema.on( 'checkChild', ( evt, args ) => {
const context = args[ 0 ];
const childDefinition = args[ 1 ];
if ( context.endsWith( 'tableCell' ) && childDefinition && childDefinition.name == 'table' ) {
// Prevent next listeners from being called.
evt.stop();
// Set the checkChild()'s return value.
evt.return = true;
}
}, { priority: 'highest' } ); You will need to wrap this code with function and pass it to The bad news is that there's not much interest in this so far, so if there will be some issues, we're not going to prioritize them at the moment. If you'd like help with resolving them you can always contact us. |
@Reinmar, unfortunately, there are some minor issues with selecting the table inside the table with a mouse - it will select the uppermost table. |
@Reinmar This helps a lot. Thank you for spending time to teach me how to enable this feature. I will be testing it extensively in a development and production environment and can hopefully help solve bugs and any issues that arise. Update 1: Update 2: |
@Reinmar I looked into this and based off the sample Chat with mentions I was able to figure out what you ment by:
JavaScript Snippet below: ClassicEditor
.create(document.querySelector('.editor'), {
extraPlugins: [allowNestedTables], // this is the missing link
toolbar: {
items: [
'heading',
'|',
'fontFamily',
'fontBackgroundColor',
'fontColor',
'bold',
//...
]
},
//...
})
.then(editor => {
window.editor = editor;
})
.catch(error => {
console.error('Oops, something gone wrong!');
console.error(
'Please, report the following error in the https://github.com/ckeditor/ckeditor5 with the build id and the error stack trace:'
);
console.warn('Build id: kwgdr5ln3fje-waex6uolg10x');
console.error(error);
});
// here we create the function
function allowNestedTables ( editor ) {
editor.model.schema.on('checkChild', (evt, args) => {
const context = args[0];
const childDefinition = args[1];
if (context.endsWith('tableCell') && childDefinition && childDefinition.name == 'table') {
// Prevent next listeners from being called.
evt.stop();
// Set the checkChild()'s return value.
evt.return = true;
}
}, {
priority: 'highest'
});
} 2020/07/14 - Updated code for brevity |
i have seen the above code snippet. I am using this editor in my react project. Can any one show me how to solve the issues with the above mentioned code in a react class component. As i am new to this, a help will be great full. |
@athuldom so, I googled for |
How to implement this in Angular, I tried below code but not working ClassicEditor.extraPlugins = [ allowNestedTables ]
|
Solved this shifted extra plugins in
|
Feature (table): Enabled support for nested tables. Check out the migration guide for how to disable it again if you do not want to allow nested tables. Closes #3232.
Add support for nesting one table inside another.
This feature wasn't on our roadmap yet, but let's gather a feedback if this is a common requirement.
NOTE: It is possible to enable support for nested tables. See https://github.com/ckeditor/ckeditor5-table/issues/121#issuecomment-528251188 for how to do that.
If you'd like this to be officially supported add 👍 to this ticket.
The text was updated successfully, but these errors were encountered: