On windows when you copy paste text in and into Odoo (for example in the description when creating a ticket) a traceback occurs.
There is an isWhitelist function which verifies that a node is indeed in the authorized items via the following instruction
`item.matches (CLIPBOARD_WHITELISTS.nodes.join (','))`
But on windows there is a comment node containing `<--StartFragment-->`
Here is the clipboard data on linux and on windows for the same copied text (Hello):
- Linux
```
<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">
<span style=\"color: rgb(102, 102, 102); font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;\">Hello</span>
```
- Windows
```
<html>
<body>
<!--StartFragment--><span style="color: rgb(102, 102, 102); font-family: "Lucida Grande", Helvetica, Verdana, Arial, sans-serif; font-size: 13px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Hello</span><!--EndFragment-->
</body>
</html>
```
Except for this additional comment on Windows, the `.matches()` method does not exist.
This PR uses the `Array.includes` function on the item's `nodeName`, which should work in all cases while keeping the same behavior.
opw-2591597
closes odoo/odoo#74029
X-original-commit: 41802bc518b4bcd1c71d8659ac560cb748befd95
Signed-off-by: Achraf <abz-odoo@users.noreply.github.com>
Odoo editor
A fast wysiwyg editor targeting documents and website structures.
Key features
Unbreakable nodes
When editing some sections of a website, there is a possibility for a selection to start or end within a node that is contained in an unbreakable.
If the user deletes the content of the selection, the unbreakable node should not be merged with another one.
Demo
To open the demo page:
http://<host:port>/web_editor/static/lib/odoo-editor/demo/index.html
Tests
To open the test page, go to
http://<host:port>/web_editor/static/lib/odoo-editor/test/editor-test.html
Prettify
# install prettier
npm install -g prettier
# prettify
prettier --config '<odoo-path>/addons/web_editor/static/lib/odoo-editor/_prettierrc.js' --ignore-path='<odoo-path>/odoo/addons/web_editor/static/lib/odoo-editor/_prettierignore' '<odoo-path>/odoo/addons/web_editor/static/lib/odoo-editor/**/*.js' --write
Prettify with vscode
Install vscode extention esbenp.prettier-vscode.
Add the following configuration in your vscode user config or workspace config:
"prettier.requireConfig": true,
"prettier.configPath": "<odoo-path>/odoo/addons/web_editor/static/lib/odoo-editor/.prettierrc.js",
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
Then you can use the command Format Document or use ctrl+h to format a file.