Wednesday, January 31, 2024
1 change · 17.0
Enhancements to existing features
Odoo now marks copied HTML content in a more compatible way so it can be recognized when pasted back into Odoo. This helps clipboard-based content, such as Knowledge copy actions, keep the right formatting and behavior without affecting paste into other apps.
Original PR description
The `OdooEditor` handles `html` content on paste differently if it comes from Odoo or not. Currently, to detect content coming from odoo, `copy` and `paste` event handlers manage a custom data type…
The `OdooEditor` handles `html` content on paste differently if it comes from Odoo or not. Currently, to detect content coming from odoo, `copy` and `paste` event handlers manage a custom data type named `text/odoo-editor`. In Knowledge, there is a `Copy` button on the `/clipboard` command which writes `html` content in the clipboard. The issue is that `text/odoo-editor` is not a valid MIME type and therefore it is not possible add data under this key in a `Blob` for the `ClipboardItem` during `clipboard.write`. This commit suggests an alternative way of handling of Odoo `html` content by prefixing it with a html comment node containing the custom MIME type: `<!-- text/odoo-editor -->`: - It won't cause an issue if the content is pasted outside Odoo (since the comment nodes are usually not shown) - The `paste` handler will treat the `html` properly as Odoo content Some test functions are modified so that `clipboardData.getData` properly returns an empty string instead of `undefined` or `null` in case a data key that is not present is accessed. task-3700875