Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REF] html_builder: split website dependencies from the builder #4236

Open
wants to merge 113 commits into
base: master-mysterious-egg
Choose a base branch
from

Conversation

abd-msyukyu-odoo
Copy link

  • Introduce a hook to construct an Editor using snippets
  • Make the builder agnostic of the Editor
  • Introduce the concept of BuilderConfigurator which will holds scope-specific information/state and the editor.

fdardenne and others added 30 commits March 18, 2025 17:38
Rewrite `AddElementOption` and `SpacingOption` to be compatible with masonry snipet

Implement `AddElementOption` button functionalities
Before when applying undo/redo the container restored the current
target which is not always the target from the previous steps.

Now we restore the container correctly when applying undo/redo.
To do so, we store the container target on each step.
FrancoisGe and others added 19 commits March 18, 2025 17:42
Before this commit, a collapsed selection inside a
contenteditable=false element would open the floating toolbar. This is
not the expected behavior, as the toolbar should not be displayed for
collapsed selections. This would be particularly impactful for the
website builder (which will soon use this editor), as selecting snippets
often results in the scenario described above (collapsed selection in a
non-editable zone).

This happened due to a normalization step done by the selection plugin
when about to store the internal representation of the selection in the
editor's editable document (editableSelection). This normalization
expanded the selection around the non-editable root element, effectively
uncollapsing it. As a result, the toolbar plugin, which relies on the
editableSelection to determine whether to display or not, would display
the toolbar.

This commit removes the referred normalization step when about to
register a selection change by the user*, and instead applies it for the
particular cases where it is needed, namely when about to apply format
(or color) to a selection, and when an icon is selected.

(*) A selection set programmatically (via setSelection) is still subject
to this normalization, as many plugins seem to rely on this behavior.

task-4242213
This commit updates the callback for selection preservation around moved
nodes. Such callback is a helper for using Cursors.update to cursors'
positions when moving nodes in the DOM.

The new behaviour has more strict and symmetrical heuristics when
defining whether the cursor should be moved along with the moved node.

It is worth noting that this callback is optional and any other
behaviour for selection preservation can be implemented by the caller of
Cursors.update.

The new behaviour is a pre-requisite for the next commit, which relies
on proper selection preservation after delete operations.

task-4242213
Content in an uneditable zone should not be deleted (per definition).
On the other hand, a contenteditable=false element (and its children)
can be removed if it is fully included by the selection.

Before this commit, executing one of the delete_* commands with a
selection inside a uneditable zone would lead to the removal of the
whole uneditable subtree.

This happened because the DeletePlugin was performing a normalization
step (via setSelection) that fully included an originally partially
selected contenteditable=false element, making it impossible to
differentiate between a selection inside a non-editable zone and one
that fully includes it (selection on the outer boundaries of the
contenteditable=false element).

This commit, by avoiding the call to setSelection and normalizing it
with the suitable transformations achieves two goals:
- it fixes the issue above (no deletion of non editable content),
- it avoids unnecessarily setting the selection before doing the actual
deletion, which was previously done with the sole purpose of normalizing
it differently from the one returned by getEditableSelection.

task-4242213
This commit finishes the work started in a previous commit, that
removed normalization of the editorSelection around non-editables when
the selection was set by the user (or browser).

The referred normalization consists of expanding a selection originally
inside an contenteditable=false element to its outer boundaries,
effectively selecting it fully.

This commit removes such normalization also when the selection is set
programmatically, that is, via setSelection.

This gives the programmer more control over the selection to be set.
Interactions weren't stopped when exiting the builder (save / discard).
This is now done when the edit interaction plugin is destroyed
=> which happens when the editor is destroyed
=> which happens when the Builder is destroyed
@robodoo
Copy link

robodoo commented Mar 21, 2025

This PR targets the un-managed branch odoo-dev/odoo:master-mysterious-egg, it needs to be retargeted before it can be merged.

@abd-msyukyu-odoo abd-msyukyu-odoo force-pushed the master-mysterious-egg-abd branch 6 times, most recently from 4f4d51e to 2f89a67 Compare March 21, 2025 14:12
- Introduce a hook to construct an Editor using snippets
- Make the builder agnostic of the Editor
- Introduce the concept of `BuilderConfigurator` which will hold scope-specific
  information/state and the editor.
@abd-msyukyu-odoo abd-msyukyu-odoo force-pushed the master-mysterious-egg-abd branch from 2f89a67 to 6457c6c Compare March 21, 2025 14:29
@FrancoisGe FrancoisGe force-pushed the master-mysterious-egg branch from f468b7f to 80b3d5d Compare March 27, 2025 12:21
@ged-odoo ged-odoo force-pushed the master-mysterious-egg branch from 27a1402 to 8c6b756 Compare March 27, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.