[IMP] web_editor: update Jabberwock library to commit b8d73691

Changelog:
[IMP] Odoo: allow empty structure nodes
[IMP] Odoo: expand parsing range of OdooStructureNode
[FIX] DomHelpers: removeNodes only when they exist
[FIX] withDomMutations : getParentModifiers
[FIX] withDomMutations: don't get node loosely
[FIX] withDomMutations: remove the proper observer
[FIX] OdooField: do not apply empty class if placeholder
[FIX] OdooWebsiteEditor: add expected Theme plugin

X-original-commit: 537c3318a6f2751d83a011345602456125420590
This commit is contained in:
David Monjoie
2020-12-11 15:32:36 +00:00
parent a692cf42f4
commit 7498d58edc
@@ -20068,7 +20068,10 @@ odoo.define('web_editor.jabberwock', (function(require) {
if (!node.fieldInfo.isValid.get()) {
classList.add('jw-odoo-field-invalid');
}
if (!node.descendants(AtomicNode).length) {
if (!node.descendants(AtomicNode).length &&
// A placeholder is visible, we don't want to collapse the field if
// it gives the impression of having content.
!node.modifiers.find(Attributes).has('placeholder')) {
classList.add('jw-odoo-field-empty');
}
container.attributes.class = classList;
@@ -21809,6 +21812,7 @@ odoo.define('web_editor.jabberwock', (function(require) {
super(params);
this.breakable = false;
this.dirty = false;
this.allowEmpty = true;
this.xpath = params.xpath;
this.viewId = params.viewId;
}
@@ -21818,9 +21822,12 @@ odoo.define('web_editor.jabberwock', (function(require) {
constructor() {
super(...arguments);
this.predicate = (item) => {
var _a, _b;
return (item instanceof Element &&
item.classList.contains('oe_structure') &&
item.attributes &&
(item.classList.contains('oe_structure') ||
(((_a = item.attributes['data-oe-model']) === null || _a === void 0 ? void 0 : _a.value) === 'ir.ui.view' &&
((_b = item.attributes['data-oe-field']) === null || _b === void 0 ? void 0 : _b.value) === 'arch')) &&
item.attributes['data-oe-xpath'] &&
item.attributes['data-oe-id']);
};
@@ -24075,6 +24082,7 @@ odoo.define('web_editor.jabberwock', (function(require) {
[Iframe],
[Button],
[ReactiveEditorInfo],
[Theme],
...(options.plugins || []),
],
});
@@ -24451,7 +24459,7 @@ odoo.define('web_editor.jabberwock', (function(require) {
for (const mutation of mutations) {
if (mutation.type === 'attributes') {
const formats = getFormats(domEngine, mutation.target);
let vnodesOrFormats = ((formats === null || formats === void 0 ? void 0 : formats.length) && formats) || domEngine.getNodes(mutation.target);
let vnodesOrFormats = ((formats === null || formats === void 0 ? void 0 : formats.length) && formats) || domEngine.getNodes(mutation.target, false);
const value = mutation.target.getAttribute(mutation.attributeName);
if (vnodesOrFormats.length) {
if (vnodesOrFormats[0] instanceof ContainerNode) {
@@ -24521,7 +24529,7 @@ odoo.define('web_editor.jabberwock', (function(require) {
for (const [observerNode, activeObservation] of activeObservers.entries()) {
// The observation might have been already removed by another call
// so we only delete and disconnect when it's still active.
if (activeObservation === activeObservation) {
if (activeObservation === observer) {
activeObservers.delete(observerNode);
observer.disconnect();
break;
@@ -24555,6 +24563,8 @@ odoo.define('web_editor.jabberwock', (function(require) {
break;
ancestorsFormats.push(format);
}
if (!ancestorsFormats.length)
return [];
const greatestAncestorVNode = getVNodes(ancestors[0]);
const allParentFormat = greatestAncestorVNode[0].modifiers.filter(m => m instanceof Format);
// Now we can retrieve the format of `inlineNode`.
@@ -24678,7 +24688,7 @@ odoo.define('web_editor.jabberwock', (function(require) {
function removeNodes(originalParents, removedDomNodes, getVNode, getFirstFormat, replacementMap) {
for (const removedDomNode of removedDomNodes) {
const removedVNodes = getVNode(removedDomNode);
if (removedVNodes) {
if (removedVNodes === null || removedVNodes === void 0 ? void 0 : removedVNodes.length) {
const firstVNode = removedVNodes[0];
// If we remove a text node that has a format, as no textnode will
// represent the format after removing it, we need to insert an