diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js index c5f9c1f69c1..04a62824843 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/OdooEditor.js @@ -3172,7 +3172,10 @@ export class OdooEditor extends EventTarget { const block = closestBlock(sel.anchorNode); let activeLabel = undefined; for (const [style, cssSelector, isList] of [ - ['paragraph', 'p:not(.small, .lead)', false], + // TODO we might want to review this list to not mention o_xxx + // classes but be a setting instead? Probably after current + // refactorings being made in master. + ['paragraph', 'p:not(.small, .lead, .o_small)', false], ['pre', 'pre', false], ['heading1', 'h1:not(.display-1, .display-2, .display-3, .display-4)', false], ['heading2', 'h2', false], @@ -3185,7 +3188,10 @@ export class OdooEditor extends EventTarget { ['display-3', 'h1.display-3', false], ['display-4', 'h1.display-4', false], ['blockquote', 'blockquote', false], - ['small', '.small', false], + // Note: this button will apply the "o_small" class but as an + // approximation, we display "Small" if this actually use the + // Bootstrap "small" class. + ['small', '.small, .o_small', false], ['light', '.lead', false], ['unordered', 'UL', true], ['ordered', 'OL', true], @@ -3247,7 +3253,7 @@ export class OdooEditor extends EventTarget { const range = getDeepRange(this.editable, { sel, correctTripleClick: true }); const spansBlocks = [...range.commonAncestorContainer.childNodes].some(isBlock); linkButton?.classList.toggle('d-none', spansBlocks || isInMedia); - + // Hide link button group if it has no visible button. const linkBtnGroup = this.toolbar.querySelector('#link.btn-group'); linkBtnGroup?.classList.toggle('d-none', !linkBtnGroup.querySelector('.btn:not(.d-none)')); diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js index 36e4b0b84b1..519e10cea28 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/utils/utils.js @@ -63,14 +63,22 @@ export const PROTECTED_BLOCK_TAG = ['TR','TD','TABLE','TBODY','UL','OL','LI']; /** * Array of all the classes used by the editor to change the font size. + * + * Note: the Bootstrap "small" class is an exception, the editor does not allow + * to set it but it did in the past and we want to remove it when applying an + * override of the font-size. */ export const FONT_SIZE_CLASSES = ["display-1-fs", "display-2-fs", "display-3-fs", "display-4-fs", "h1-fs", - "h2-fs", "h3-fs", "h4-fs", "h5-fs", "h6-fs", "base-fs", "small"]; + "h2-fs", "h3-fs", "h4-fs", "h5-fs", "h6-fs", "base-fs", "o_small-fs", "small"]; /** * Array of all the classes used by the editor to change the text style. + * + * Note: the Bootstrap "small" class was actually part of "text style" + * configuration in the past... but also of the "font size" configuration (see + * FONT_SIZE_CLASSES). It should be mentioned here too. */ -export const TEXT_STYLE_CLASSES = ["display-1", "display-2", "display-3", "display-4", "lead"]; +export const TEXT_STYLE_CLASSES = ["display-1", "display-2", "display-3", "display-4", "lead", "o_small", "small"]; //------------------------------------------------------------------------------ // Position and sizes diff --git a/addons/web_editor/static/src/scss/bootstrap_overridden.scss b/addons/web_editor/static/src/scss/bootstrap_overridden.scss index f80dd76c1e2..dda72169439 100644 --- a/addons/web_editor/static/src/scss/bootstrap_overridden.scss +++ b/addons/web_editor/static/src/scss/bootstrap_overridden.scss @@ -84,3 +84,13 @@ $gray-900: map-get($grays, '900') !default; $black: map-get($grays, 'black') !default; $o-color-system-initialized: true; + +// This was added by compatibility but it actually became a nice behavior: the +// bootstrap default "small" behavior will use the ratio of the configured base +// font size (if configured, e.g. with website settings) and the Odoo own's +// "small" font size. Grep: SMALLER_FONT_SIZE_RATIO. +$small-font-size: if( + variable-exists('font-size-base'), + ($o-small-font-size / $font-size-base) * 1em, + null +) !default; diff --git a/addons/web_editor/static/src/scss/secondary_variables.scss b/addons/web_editor/static/src/scss/secondary_variables.scss index e90c3452133..17e83bb9399 100644 --- a/addons/web_editor/static/src/scss/secondary_variables.scss +++ b/addons/web_editor/static/src/scss/secondary_variables.scss @@ -140,3 +140,9 @@ $o-we-auto-contrast-exclusions: () !default; $colors: str-replace($colors, ' ', '%20'); @return $colors; } + +//------------------------------------------------------------------------------ +// Fonts +//------------------------------------------------------------------------------ + +$o-small-font-size: 0.875rem !default; diff --git a/addons/web_editor/static/src/scss/web_editor.common.scss b/addons/web_editor/static/src/scss/web_editor.common.scss index db4fe2f841a..b203d9e59ec 100644 --- a/addons/web_editor/static/src/scss/web_editor.common.scss +++ b/addons/web_editor/static/src/scss/web_editor.common.scss @@ -90,7 +90,6 @@ @include print-variable('h5-font-size', $h5-font-size); @include print-variable('h6-font-size', $h6-font-size); @include print-variable('font-size-base', $font-size-base); - @include print-variable('small-font-size', $small-font-size); } html, body { @@ -250,6 +249,19 @@ img.ms-auto, img.mx-auto { width: auto; } +%o-small-font-size { + @include font-size($o-small-font-size); +} +// Dedicated class to be able to keep the default "small" behavior of bootstrap: +// being "smaller" that the context where it is used (em units). Here we want to +// define a specific fixed font-size for a smaller font-size than the base font +// size. Note that this class is designed to work as the display-x classes: an +// extra "styling" class to go on an element. For the "font-size class" +// equivalent, see o_small-fs below. +.o_small { + @extend %o-small-font-size; +} + @for $index from 1 through 4 { .display-#{$index}-fs { @include font-size(map-get($display-font-sizes, $index)); @@ -276,6 +288,12 @@ img.ms-auto, img.mx-auto { .base-fs { @include font-size($font-size-base); } +// Equivalent "font-size" only for the Odoo own "o_small" class. Note that the +// "o_small" class currently also changes the font-size only but this is to stay +// consistent with the other classes which act that way (as display-x). +.o_small-fs { + @extend %o-small-font-size; +} div.media_iframe_video { margin: 0 auto; diff --git a/addons/web_editor/static/src/xml/editor.xml b/addons/web_editor/static/src/xml/editor.xml index 6f7f60b1eff..de439d81826 100644 --- a/addons/web_editor/static/src/xml/editor.xml +++ b/addons/web_editor/static/src/xml/editor.xml @@ -50,7 +50,7 @@ Light