Monday, September 30, 2024
1 change
Code cleanup and technical improvements
Knowledge now uses Odoo's newer editor to make articles more interactive and consistent, including public article pages. Comments load more efficiently, large articles should open with less server load, and embedded content such as files, views, templates, and tables of contents is handled more reliably.
Original PR description
Refactor Knowledge to use the new features of the editor. Behaviors are converted to Embedded Components which are now natively supported in the html_editor module. (Embedded Components is a feature…
Refactor Knowledge to use the new features of the editor. Behaviors are converted to Embedded Components which are now natively supported in the html_editor module. (Embedded Components is a feature of the HtmlField allowing to mount Owl components inside an HtmlField value, based on metadata stored in the attributes of html nodes) ### website_knowledge is no longer forgotten Public version of an article is now using the HtmlViewer to render the Html value, and this allows to mount embedded components as they would be in the backend view. This results in a far better reading experience for public users. ### Comments Overhaul of the feature, in a concise way: anchoring a comment in the HtmlField value is way less expensive in terms of amount of characters since it uses 2 self closing `<a>` nodes instead of wrapping every text node in a `<span>` (which could be hundreds for a comment spanning over an entire document). This is also easier to manage during edition, since new nodes between the boundaries of a comment don't need to be processed so that they are marked as part of a comment anymore. Loading threads and messages is now centralized in a `comments_service` which batches rpc calls together, significantly reducing the load when opening an article. The comment panel now has a "load more" feature, meaning that it does not load every single existing thread and their messages at once when opening it. Floating "Comment boxes" are now perfectly aligned with their anchor in the HtmlField when they are focused (previously they were pushed by other Comments boxes above them when there was not enough space, even when active). ### Embedded Components All existing Behaviors are converted to embedded components, and some of them are moved in the html_editor module #### knowledge: - Article Link - Article Index - Clipboard - Embedded View - Embedded view Link #### html_editor: - Excalidraw - File - Table of Content - Video ### Migration Since metadata for Behaviors differ from those of Embedded Components, and upgrading an html value is expensive, this transition will be handled client-side for starts. A small JS upgrade feature for html values is introduced. The "upgrade" will be attempted once, and won't result in a crash if it fails. Instead, the previous value will be conserved, and the user will be able to adjust the content manually by using editor commands. Odoo Community: https://github.com/odoo/odoo/pull/173997 task-3672747 Co-authored-by: Damien Abeloos <abd@odoo.com> Co-authored-by: Adrien Schoffeniels <adsc@odoo.com> Co-authored-by: Julien Banken <jbn@odoo.com> Co-authored-by: Thomas Josse <thjo@odoo.com>