-
Notifications
You must be signed in to change notification settings - Fork 185
Insert table content #3258
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
base: master
Are you sure you want to change the base?
Insert table content #3258
Conversation
| editor.formatContentModel( | ||
| (model, context) => { | ||
| const insertPosition = deleteSelection(model, [], context).insertPoint; | ||
| const copiedModel = cloneModel(model); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why we need to clone a model?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used the cloned model, because it returns the content model types, not readonly types, making it easier to insert the content into the table that is ContentModelTable type.
| } | ||
|
|
||
| if (path.length == 1 && block) { | ||
| table.rows[index].cells[0].blocks = [block]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if only part of a block is selected? Do we still expect to insert the whole block into table?
| } | ||
| } | ||
|
|
||
| function insertTableContent( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks more like a model API, so you can create a separate file under modelAPI folder
When inserting a table in a range selection, insert the selected content inside the table.
