Daily updates from Odoo
Tuesday, October 1, 2024
4 changes · 18.0
Code cleanup and technical improvements
The HTML editor’s internal plugin resource system was simplified so developers can define and access shared editor resources more consistently. This is an internal refactor that should make future editor maintenance easier without changing day-to-day user behavior.
Original PR description
This commit change the resource API for the plugins in 3 ways. # 1) The disposal of resources Instead of ```js class MyPlugin extends Plugin { /** @type { (p: MyPlugin) => Record<string, any> } */…
This commit change the resource API for the plugins in 3 ways.
# 1) The disposal of resources
Instead of
```js
class MyPlugin extends Plugin {
/** @type { (p: MyPlugin) => Record<string, any> } */
static resources = (p) => ({
my_handlers: p.handler.bind(p)
})
}
```
We now have
```js
class MyPlugin extends Plugin {
resources = {
my_handlers: this.handler.bind(this)
}
}
```
# 2) Resource getter
To access a specific resource within a plugin, instead of
```js
this.resources['my_handler']
```
We now have
```js
this.getResource('my_handler')
```
If no other plugin disposed the specified resource, the getter will return an empty array.
# 3) Sequences for all resources
This commit give the ability to specify a sequence for any resource item, removing the need for the consumer of the resource to have to setup it.
Instead of
```js
class MyPluginA extends Plugin {
resources = {
my_handlers: {handler: this.handler.bind(this), sequence: 100}
my_data: {id: 'some-id', sequence: 100}
}
}
class MyPluginB extends Plugin {
constructor() {
this.handlers = this.getResource('my_handlers')
.sort((a, b) => a.sequence - b.sequence)
}
myMethod() {
for (const {handler} of this.myHandlers) {
handler();
}
}
}
```
We now have
```js
class MyPluginA extends Plugin {
resources = {
my_handlers: withSequence(100, this.handler.bind(this)),
my_data: withSequence(100, {id: 'some-id'}),
}
}
class MyPluginB extends Plugin {
myMethod() {
for (const handler of this.getResource('my_handlers')) {
handler();
}
}
}
```
---
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-prEditor dialogs now share a common way to restore the user's cursor or selection after the dialog closes. This reduces duplicated logic and helps make editing interactions more reliable across features such as media and AI-assisted content dialogs.
Original PR description
The purpose of this commit is to add a dialog plugin that will centralise the behaviour shared between dialogs opened from the editor. The behaviour shared by all the editor dialogs is the repositioning of the selection in the editable when a dialog closes. Description of the issue/feature this PR addresses: Current behavior before PR: Desired behavior after PR is merged: --- I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr
The editor plugin resource API was updated to stay aligned with related platform changes. This is an internal cleanup that helps appointment and knowledge editor features remain maintainable without changing day-to-day user workflows.
Original PR description
This commit adapt the api of plugin resources to match the changes made in community.
Editor dialogs now share a common handling process so the editing cursor returns to the right place when a dialog closes. This reduces inconsistent behavior across areas such as appointments and knowledge articles, making editing smoother for users.
Original PR description
The purpose of this commit is to add a dialog plugin that will centralise the behaviour shared between dialogs opened from the editor. The behaviour shared by all the editor dialogs is the repositioning of the selection in the editable when a dialog closes.