diff --git a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js index 76a8438d952..32f0ba20662 100644 --- a/addons/web_editor/static/src/js/wysiwyg/widgets/link.js +++ b/addons/web_editor/static/src/js/wysiwyg/widgets/link.js @@ -1,6 +1,8 @@ /** @odoo-module **/ import * as OdooEditorLib from "@web_editor/js/editor/odoo-editor/src/OdooEditor"; +import { _t } from "@web/core/l10n/translation"; +import { isVisible } from "@web/core/utils/ui"; import weUtils from "@web_editor/js/common/utils"; import { Component, @@ -15,7 +17,6 @@ import { const getDeepRange = OdooEditorLib.getDeepRange; const getInSelection = OdooEditorLib.getInSelection; const EMAIL_REGEX = OdooEditorLib.EMAIL_REGEX; -import { _t } from "@web/core/l10n/translation"; /** * Allows to customize link content and style. @@ -133,6 +134,15 @@ export class Link extends Component { } } } + // When multiple buttons follow each other, they may break on 2 lines + // or more on mobile, so they need a margin-bottom. + if (data.classes.split(" ").includes("btn")) { + const closestButtonSiblingEls = this._getDirectButtonSiblings(this.linkEl); + if (closestButtonSiblingEls.length) { + data.classes += " mb-2"; + closestButtonSiblingEls.forEach(btnEl => btnEl.classList.add("mb-2")); + } + } if (['btn-custom', 'btn-outline-custom', 'btn-fill-custom'].some(className => data.classes.includes(className) )) { @@ -552,16 +562,45 @@ export class Link extends Component { const allBtnColorPrefixes = /(^|\s+)(bg|text|border)(-[a-z0-9_-]*)?/gi; const allBtnClassSuffixes = /(^|\s+)btn(-[a-z0-9_-]*)?/gi; const allBtnShapes = /\s*(rounded-circle|flat)\s*/gi; + const btnMarginBottom = /(? { + let siblingNode = el[`${side}Sibling`]; + while (siblingNode) { + // If the node is an empty text node, or if it is a
tag or + // an invisible element, it is not taken into account. + if ((siblingNode.nodeType === 3 && !!siblingNode.textContent.match(/^\s*$/)) || + (siblingNode.nodeType === 1 && + (siblingNode.nodeName === "BR" || !isVisible(siblingNode)))) { + siblingNode = siblingNode[`${side}Sibling`]; + continue; + } + if (siblingNode.nodeType === 1 && siblingNode.classList.contains("btn")) { + buttonSiblingsEls.push(siblingNode); + } + break; + } + return buttonSiblingsEls; + }, []); + } //-------------------------------------------------------------------------- // Handlers diff --git a/addons/website/views/snippets/s_banner.xml b/addons/website/views/snippets/s_banner.xml index 7cc6a07de67..fd7dfda7f2a 100644 --- a/addons/website/views/snippets/s_banner.xml +++ b/addons/website/views/snippets/s_banner.xml @@ -9,7 +9,7 @@

Sell Online. Easily.

This is a simple hero unit, a simple jumbotron-style component for calling extra attention to featured content or information.

- Contact Us + Contact Us
diff --git a/addons/website/views/snippets/s_call_to_action.xml b/addons/website/views/snippets/s_call_to_action.xml index 4b610066860..10f0e240177 100644 --- a/addons/website/views/snippets/s_call_to_action.xml +++ b/addons/website/views/snippets/s_call_to_action.xml @@ -11,7 +11,7 @@

- Contact us + Contact us

diff --git a/addons/website/views/snippets/s_carousel.xml b/addons/website/views/snippets/s_carousel.xml index 8476fb8afe4..e87a6db88a1 100644 --- a/addons/website/views/snippets/s_carousel.xml +++ b/addons/website/views/snippets/s_carousel.xml @@ -21,7 +21,7 @@

Slide Title

Use this snippet to presents your content in a slideshow-like format. Don't write about products or services here, write about solutions.

- Contact us + Contact us

@@ -37,7 +37,7 @@

Storytelling is powerful.
It draws readers in and engages them.

-

Start your journey

+

Start your journey

diff --git a/addons/website/views/snippets/s_color_blocks_2.xml b/addons/website/views/snippets/s_color_blocks_2.xml index cb8ef1e9b3e..3fec376dac2 100644 --- a/addons/website/views/snippets/s_color_blocks_2.xml +++ b/addons/website/views/snippets/s_color_blocks_2.xml @@ -9,13 +9,13 @@

A color block

Color blocks are a simple and effective way to present and highlight your content. Choose an image or a color for the background. You can even resize and duplicate the blocks to create your own layout. Add images or icons to customize the blocks.

- More Details + More Details

Another color block

Color blocks are a simple and effective way to present and highlight your content. Choose an image or a color for the background. You can even resize and duplicate the blocks to create your own layout. Add images or icons to customize the blocks.

- More Details + More Details
diff --git a/addons/website/views/snippets/s_comparisons.xml b/addons/website/views/snippets/s_comparisons.xml index 02b9bb54b2f..30ca1432e43 100644 --- a/addons/website/views/snippets/s_comparisons.xml +++ b/addons/website/views/snippets/s_comparisons.xml @@ -24,7 +24,7 @@ @@ -47,7 +47,7 @@ @@ -70,7 +70,7 @@ diff --git a/addons/website/views/snippets/s_cover.xml b/addons/website/views/snippets/s_cover.xml index 0afcd95aef1..17f17da2b22 100644 --- a/addons/website/views/snippets/s_cover.xml +++ b/addons/website/views/snippets/s_cover.xml @@ -9,7 +9,7 @@

Catchy Headline

Write one or two paragraphs describing your product, services or a specific feature.
To be successful your content needs to be useful to your readers.

- Contact us + Contact us

diff --git a/addons/website/views/snippets/s_image_text.xml b/addons/website/views/snippets/s_image_text.xml index ee8dedf8f95..cea17f74a41 100644 --- a/addons/website/views/snippets/s_image_text.xml +++ b/addons/website/views/snippets/s_image_text.xml @@ -12,7 +12,7 @@

Section Subtitle

Write one or two paragraphs describing your product or services. To be successful your content needs to be useful to your readers.

Start with the customer – find out what they want and give it to them.

-

Discover more

+

Discover more

diff --git a/addons/website/views/snippets/s_media_list.xml b/addons/website/views/snippets/s_media_list.xml index 176c1a165bb..0c200cf1561 100644 --- a/addons/website/views/snippets/s_media_list.xml +++ b/addons/website/views/snippets/s_media_list.xml @@ -13,7 +13,7 @@

Media heading

Use this snippet to build various types of components that feature a left- or right-aligned image alongside textual content. Duplicate the element to create a list that fits your needs.

- Discover + Discover
diff --git a/addons/website/views/snippets/s_popup.xml b/addons/website/views/snippets/s_popup.xml index f710d37f917..a786683475d 100644 --- a/addons/website/views/snippets/s_popup.xml +++ b/addons/website/views/snippets/s_popup.xml @@ -17,7 +17,7 @@

Win $20

Check out now and get $20 off your first order.

- New customer + New customer
diff --git a/addons/website/views/snippets/s_showcase.xml b/addons/website/views/snippets/s_showcase.xml index 4aab5d166ee..88f6da5e1cb 100644 --- a/addons/website/views/snippets/s_showcase.xml +++ b/addons/website/views/snippets/s_showcase.xml @@ -49,7 +49,7 @@ diff --git a/addons/website/views/snippets/s_text_cover.xml b/addons/website/views/snippets/s_text_cover.xml index fc1dd862a80..eaa76f5fc97 100644 --- a/addons/website/views/snippets/s_text_cover.xml +++ b/addons/website/views/snippets/s_text_cover.xml @@ -8,7 +8,7 @@

Sell Online.
Easily.

Write one or two paragraphs describing your product, services or a specific feature. To be successful your content needs to be useful to your readers.

- Contact us + Contact us
diff --git a/addons/website/views/snippets/s_text_image.xml b/addons/website/views/snippets/s_text_image.xml index 779a747d780..efbee3b12a2 100644 --- a/addons/website/views/snippets/s_text_image.xml +++ b/addons/website/views/snippets/s_text_image.xml @@ -9,7 +9,7 @@

A Section Subtitle

Write one or two paragraphs describing your product or services. To be successful your content needs to be useful to your readers.

Start with the customer – find out what they want and give it to them.

-

Learn more

+

Learn more