Friday, September 29, 2023
1 change · master
Code cleanup and technical improvements
This update reorganizes and simplifies the internal handling of Knowledge editor blocks and embedded content. It improves reliability when inserting or refreshing content in collaborative editing, while making future maintenance easier for developers.
Original PR description
This is a refactoring PR which intends to: - Reorganize and rename `Behavior` templates so that it is more clear what purpose a specific template has. There are 3 types of template per `Behavior`: -…
This is a refactoring PR which intends to:
- Reorganize and rename `Behavior` templates so that it is more clear what
purpose a specific template has.
There are 3 types of template per `Behavior`:
- `command` template: it should include nodes that are required by the
`Behaviors engine` to mount a `Behavior` when it is inserted for the first
time (`blueprint`). It is most often rendered by the `wysiwyg` when the
user types a `/command` in the editor and is not rendered by `Owl`.
- `Component` template: used by `Owl` to populate the `anchor` of a `Behavior`
(which is the `parent` node of the `command` template)
- non-protected "content" templates: rendered manually during the lifecycle of
the `Behavior` `Component`. Those are rendered manually without `Owl`,
because they can be altered by the collaboration (since they are
`data-protected="false"`) and `Owl` does not support that the nodes it
rendered be altered by something else than itself (will crash).
- Reorganize the js code of `Behavior` components and the `HtmlField` patch, so
that there is some consistency between them and a foreign reader can better
understand their structure.
- Refactor and rename `updateBehaviors` into `mountBehaviors` because the
function is becoming quite long and complex, and handles some side effects in
a pretty ugly way. Notably:
- add some utils for common/complex use cases
- add a `validator` object to formalize cases where a `Behavior` mounting can
become obsolete
- display warning messages upon `Behavior` `mount` failure only in debug mode
Read more details in each commits.
task-3383561