When starting the editor in a web page, if there is no content, the oe_structure is not editable. Adding snippet at that moment will trigger `idSet` on the node with isUnbreakable returning `false` for the node that is unbreakable because of the check `!node.isContentEditable` in `isUnbreakable`. When setting the ouid for the first time with `idSet`, `getOuid` is called with `optimize` to `true`. So all the ancestor of a node that should be unbreakable will have the wrong ouid. Performing any command to a node with a wrong ouid is suceptible to wrongly be reverted. By removing `!node.isContentEditable`, the node will have the proper ouid in case an ancestor is not editable. task-2633368 closes odoo/odoo#79108 X-original-commit: 13804df7740317b8198e7c1de418ff019c05862b Signed-off-by: David Monjoie (dmo) <dmo@odoo.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.