[IMP] web_editor: better show active entry in the text style dropdown
Replace the "¶" icon with the name of the current active text style entry. Part of https://github.com/odoo/odoo/pull/73565 task-2496339 Part-of: odoo/odoo#73565
This commit is contained in:
committed by
stefanorigano (SRI)
parent
2aea38467e
commit
7c1c6ecc52
@@ -1482,7 +1482,9 @@ export class OdooEditor extends EventTarget {
|
||||
}
|
||||
}
|
||||
this.updateColorpickerLabels();
|
||||
|
||||
const block = closestBlock(sel.anchorNode);
|
||||
let activeLabel = undefined;
|
||||
for (const [style, tag, isList] of [
|
||||
['paragraph', 'P', false],
|
||||
['pre', 'PRE', false],
|
||||
@@ -1505,8 +1507,21 @@ export class OdooEditor extends EventTarget {
|
||||
? block.tagName === 'LI' && getListMode(block.parentElement) === tag
|
||||
: block.tagName === tag;
|
||||
button.classList.toggle('active', isActive);
|
||||
|
||||
if (!isList && isActive) {
|
||||
activeLabel = button.textContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!activeLabel) {
|
||||
// If no element from the text style dropdown was marked as active,
|
||||
// mark the paragraph one as active and use its label.
|
||||
const firstButtonEl = this.toolbar.querySelector('#paragraph');
|
||||
firstButtonEl.classList.add('active');
|
||||
activeLabel = firstButtonEl.textContent;
|
||||
}
|
||||
this.toolbar.querySelector('#style button span').textContent = activeLabel;
|
||||
|
||||
const linkNode = getInSelection(this.document, 'a');
|
||||
const linkButton = this.toolbar.querySelector('#createLink');
|
||||
linkButton && linkButton.classList.toggle('active', linkNode);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<button type="button" class="btn dropdown-toggle"
|
||||
data-toggle="dropdown" title="Text style" tabindex="-1" data-display="static"
|
||||
data-original-title="Style" aria-expanded="false">
|
||||
<i class="fa fa-paragraph"></i>
|
||||
<span>Normal</span>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li id="paragraph-dropdown-item">
|
||||
|
||||
Reference in New Issue
Block a user