Open GW00234847 opened 6 months ago
Latest commit: 815d6070b44213b56d456cd3b3a94a87f2db360f
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Description When we tried to use this library on our project, we encountered some issues, so I temporarily fixed them through some scripts, here comes the issues. The following issues have been fixed: Page collapse issues caused by copied table:
Issue
Fixes: (link to issue)
Example
after![copy_table_rowspan_colspan_issue_after](https://github.com/guoxiaona-gwm/editable/assets/149048134/4fd6c8c7-449a-4c93-8c5e-db7ab8523e3c)
before![last_missing_cell](https://github.com/guoxiaona-gwm/editable/assets/149048134/68fd1d1c-d3d9-4679-8f52-0346ca1baa24)
after![last_missing_cell_after](https://github.com/guoxiaona-gwm/editable/assets/149048134/226a333c-2737-4884-a64e-d4b381f4daa9)
after![Link_enter_after](https://github.com/guoxiaona-gwm/editable/assets/149048134/d2cea9de-7ef3-43b4-8446-7388f8b6d3e6)
before![drag_table_column](https://github.com/guoxiaona-gwm/editable/assets/149048134/c7dbd057-2583-4505-93f1-ae8ca14a82fd)
after![drag_table_column_after](https://github.com/guoxiaona-gwm/editable/assets/149048134/dd87abd7-a5bc-45e9-8753-28805d00d74e)
after![partial_table_col_after](https://github.com/guoxiaona-gwm/editable/assets/149048134/73fc452e-651b-4f8f-957a-5234c78978e2)
Context 1: The raw HTML for the table, it will not display an empty dom cell for colspan or rowspan that is greater than 1, but just reduce the corresponding number of the cell. But in editablejs, the table will render every one of the cells even if it may ignored by the raw table. My solution is to fill the missing cell, calculate each line's colspan and rowspan, and if it is greater than 1, add another td empty element with displaynone||||||, so when displaying the cell, it will also need to check if it contains displaynone|||||| to hide that cell. Once the data structure works fit to editablejs, it works fine. 2: TH works as a cell, so just need to remove- it from TR to TD. So TH will work as expected. 3: Calculate the total cells of the first row of the table, when it comes to the final line of the table, check if the cell number fits = the same as the first row, if not, patch the missing cell. 4: when copying content into editablejs, its data structure didn't match what the editablejs requires, for it missing another wrapper outside children, it should be wrapped by children with children as the first element. 5: When dragging columns, it didn't update the height of the left border cell, however height of cells might update, whether gets smaller or higher. So it should recalculate the left border's height. 6: If the table has been wrapped inside by colgroup, it will auto-set each cols' with to 0 which finally causes column's width to 0, so what should be done is to check if there are any colgroup inside each table, and to reset each column's width to offsetWidth Checks
pnpm test
.pnpm lint
. (Fix errors withpnpm fix
.)pnpm start
.)pnpm changeset
.)