Feature #43950
closedAdd support for pasting spreadsheet tables as CommonMark/Textile tables in wiki textareas
Description
I think Redmine is often used alongside spreadsheet applications such as Microsoft Excel and Google Sheets. In such cases, it would be useful to paste tables from those applications directly into Redmine issues, wiki pages, and other wiki textareas as CommonMark or Textile tables. A similar feature has long been available on GitHub.
This issue adds support for converting pasted spreadsheet tables into CommonMark/Textile table syntax when they are pasted into wiki textareas.
- Convert
tableelements contained in pastedtext/htmlclipboard data into CommonMark/Textile table syntax - Support both CommonMark and Textile
- Text and cell styles are not preserved
- Confirmed to work with Microsoft Excel, Excel for the web, Google Sheets, and Numbers
- As implemented, this also ends up supporting pasted HTML tables
- Confirmed that all tests and lint checks pass: https://github.com/hidakatsuya/redmine/pull/37
Google Sheets:

CommonMark:


Textile:


About patch 0001:
Automatic list marker insertion was added to the search field in #43095, but that feature is unnecessary that field. Patch 0001 removes that unnecessary implementation.
Files
Updated by Katsuya HIDAKA 18 days ago
- File 0002-Add-support-for-pasting-spreadsheet-tables-as-CommonMark-Textile-tables-in-wiki-textareas.patch 0002-Add-support-for-pasting-spreadsheet-tables-as-CommonMark-Textile-tables-in-wiki-textareas.patch added
I updated patch 0002.
The main reason for the update is to avoid dropping non-table content unexpectedly. For example, with the previous implementation, if pasted HTML contained both a table and other content, the non-table content could be lost.
The revised patch now applies table paste only when the pasted HTML consists of a single standalone table, and otherwise leaves the paste to the browser's normal handling. In other words, it now converts the paste only when the pasted content is a single table.
I also limited the feature to tables with at least 2 rows and 2 columns, so that single-row or single-column tables are not converted.
It also includes some refactoring to improve code readability.