-
Notifications
You must be signed in to change notification settings - Fork 61
SD-1621 - add table insertion example #1825
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: main
Are you sure you want to change the base?
Conversation
…587) (#1806) * fix: remove dead code * refactor: table and paragraph converters to avoid redirection * test: adjust existing tests * fix: remove unused imports and dead code * fix: pass theme colors to node handlers * refactor: simplify type definitions for converters --------- Co-authored-by: Luccas Correa <luccas@superdoc.dev>
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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0d23c204cf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // Delete the empty template row | ||
| editorInstance.commands.deleteRow(); |
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.
Delete row call is a no-op outside table
The example inserts the table and then immediately calls deleteRow, but insertTable moves the selection after the new table and appendRowsWithContent does not move it. The table command deletes the row containing the current selection (see packages/super-editor/src/extensions/table/table.js), so this call will typically do nothing and leave the empty template row in the output. This shows up any time a user imports a sheet because the cursor is not inside the table when deleteRow runs.
Useful? React with 👍 / 👎.
| const tables = editorInstance.getNodesOfType('table'); | ||
| if (!tables?.length) return; | ||
|
|
||
| const tablePos = tables[tables.length - 1].pos; |
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.
Appending data can target the wrong table
The inserted table is located by taking the last table in the document. If the cursor is in the middle of a document that already has a table after it, tables[tables.length - 1] will point to an existing table instead of the one just inserted, so the XLSX rows will append to the wrong table. This occurs whenever users import into a document that already contains later tables.
Useful? React with 👍 / 👎.
No description provided.