[FIX] web_editor: keep style of copy-pasted tables
Previously, copy-pasted tables from other spreadsheet editors did not
keep their style once in our editor. This is simply because the way
style information is embedded in the HTML is not inter-compatible across
editors.
Google Sheets places all the cell's style on <td> tags, which can't be
styled in Odoo 15. This has been fixed by moving all possible style
attributes to a direct <span> children, which is created if necessary.
In Odoo 16 and forward, the styles are left on <td> tags.
Microsoft Excel defines the style in the standard <style> tag (in the
<head> of the HTML), using custom CSS classes on tags. We parse that
<style> and copy it to the style attribute of <td> tags with matching
classes. Those styled <td> tags are later handled as described above.
Libre Office makes use of deprecated <font> tags and its specific
attributes. Those attributes are mapped to equivalent values for the
standard style attribute. It also places eventual <s> and <u> tags as
parents of <font> tags, which means the strike or underline doesn't
inherit the style of the text. We invert those for nicer styling as is
the default in our editor.
Tests have been added for each of those aforementioned Spreadsheet
editors, ensuring we save exactly their style values that are compatible
with the Odoo editor, nothing less and nothing more.
Note that for v15.0, background color of cells is discarded as it is not
supported in our own editor. For v16.0 and on, it is supported and kept.
Task-3255167
closes odoo/odoo#124527
X-original-commit: b241c59982232b1a4b96518311ec12d81d5ad001
Signed-off-by:
David Monjoie (dmo) <dmo@odoo.com>
Showing
- addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js 40 additions, 1 deletion...editor/static/src/js/editor/odoo-editor/src/OdooEditor.js
- addons/web_editor/static/src/js/editor/odoo-editor/test/editor-test.js 1 addition, 0 deletions...itor/static/src/js/editor/odoo-editor/test/editor-test.js
- addons/web_editor/static/src/js/editor/odoo-editor/test/spec/copyPaste.test.js 3 additions, 19 deletions...tic/src/js/editor/odoo-editor/test/spec/copyPaste.test.js
- addons/web_editor/static/src/js/editor/odoo-editor/test/spec/htmlTables.test.js 498 additions, 0 deletions...ic/src/js/editor/odoo-editor/test/spec/htmlTables.test.js
- addons/web_editor/static/src/js/editor/odoo-editor/test/utils.js 19 additions, 0 deletions...web_editor/static/src/js/editor/odoo-editor/test/utils.js
Loading
Please register or sign in to comment