Skip to content

so_content_addition_selector #4500

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

Merged
merged 2 commits into from
Apr 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions addons/html_builder/static/src/core/dropzone_selector_plugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Plugin } from "@html_editor/plugin";

// TODO s_website_form, s_searchbar_input were added by extending xpath.
const so_content_addition_selector = `blockquote, .s_alert, .o_facebook_page, .s_share, .s_social_media, .s_rating, .s_hr, .s_google_map, .s_map, .s_countdown, .s_chart, .s_text_highlight, .s_progress_bar, .s_badge, .s_embed_code, .s_donation, .s_add_to_cart, .s_online_appointment, .o_snippet_drop_in_only, .s_image, .s_cta_badge, .s_accordion, .s_website_form, .s_searchbar_input, .s_rental_search, .s_card`;
const card_parent_handlers =
".s_three_columns .row > div, .s_comparisons .row > div, .s_cards_grid .row > div, .s_cards_soft .row > div, .s_product_list .row > div, .s_newsletter_centered .row > div, .s_company_team_spotlight .row > div, .s_comparisons_horizontal .row > div, .s_company_team_grid .row > div, .s_company_team_card .row > div, .s_carousel_cards_item";
const special_cards_selector = `.s_card.s_timeline_card, div:is(${card_parent_handlers}) > .s_card`;
Expand All @@ -27,10 +25,20 @@ export class DropZoneSelectorPlugin extends Plugin {
dropIn: so_snippet_addition_drop_in,
},
{
selector: `${so_content_addition_selector}, .s_card`, // TODO check extend so_content_addition_selector
plugin: this,
get selector() {
return [
...this.plugin.getResource("so_content_addition_selector"),
".s_card",
].join(", ");
},
exclude: `${special_cards_selector}`,
dropNear: `p, h1, h2, h3, ul, ol, div:not(.o_grid_item_image) > img, div:not(.o_grid_item_image) > a, .btn, ${so_content_addition_selector}, .s_card:not(${special_cards_selector})`,
dropIn: "nav",
get dropNear() {
return `p, h1, h2, h3, ul, ol, div:not(.o_grid_item_image) > img, div:not(.o_grid_item_image) > a, .btn, ${this.plugin
.getResource("so_content_addition_selector")
.join(", ")}, .s_card:not(${special_cards_selector})`;
},
excludeNearParent: so_snippet_addition_drop_in,
},
{
Expand All @@ -51,12 +59,11 @@ export class DropZoneSelectorPlugin extends Plugin {
},
],
so_snippet_addition_selector: ["section", ".parallax", ".s_hr"],
so_content_addition_selector: [
"blockquote",
".s_text_highlight",
".s_donation", // TODO: move to plugin
".o_snippet_drop_in_only",
],
};
}

/** TODO add xpath
* <xpath expr:"//div[@id='so_content_addition']" position="attributes">
<attribute name="selector" add=".s_progress_bar" separator:","/>
<attribute name="dropNear" add=".s_progress_bar" separator:","/>
</xpath>
*/
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class AlertOptionPlugin extends Plugin {
selector: ".s_alert",
}),
],
so_content_addition_selector: [".s_alert"],
};
}
registry.category("website-plugins").add(AlertOptionPlugin.id, AlertOptionPlugin);
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CountdownOptionPlugin extends Plugin {
cleanForSave: this.cleanForSave.bind(this),
}),
],
so_content_addition_selector: [".s_countdown"],
builder_actions: {
// TODO AGAU: update after merging generalized restart interactions
// remove this and xml BuilderContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class RatingOptionPlugin extends Plugin {
template: "html_builder.RatingOption",
selector: ".s_rating",
},
so_content_addition_selector: [".s_rating"],
builder_actions: this.getActions(),
};
getActions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class SeparatorOptionPlugin extends Plugin {
selector: ".s_hr",
dropNear: "p, h1, h2, h3, blockquote, .s_hr",
},
so_content_addition_selector: [".s_hr"],
};
}
registry.category("website-plugins").add(SeparatorOptionPlugin.id, SeparatorOptionPlugin);
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export class FormOptionPlugin extends Plugin {
selector: ".s_website_form",
excludeAncestor: "form",
},
so_content_addition_selector: [".s_website_form"],
};
getActions() {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class accordionOptionPlugin extends Plugin {
selector: ".s_accordion .accordion-item",
}),
],
so_content_addition_selector: [".s_accordion"],
builder_actions: this.getActions(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BadgeOptionPlugin extends Plugin {
selector: ".s_badge",
}),
],
so_content_addition_selector: [".s_badge"],
};
}
registry.category("website-plugins").add(BadgeOptionPlugin.id, BadgeOptionPlugin);
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ChartOptionPlugin extends Plugin {
},
},
],
so_content_addition_selector: [".s_chart"],
builder_actions: this.getActions(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class CTABadgeOptionPlugin extends Plugin {
selector: ".s_cta_badge",
},
],
so_content_addition_selector: [".s_cta_badge"],
};
}
registry.category("website-plugins").add(CTABadgeOptionPlugin.id, CTABadgeOptionPlugin);
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class EmbedCodeOptionPlugin extends Plugin {
selector: ".s_embed_code",
}),
],
so_content_addition_selector: [".s_embed_code"],
builder_actions: this.getActions(),
clean_for_save_handlers: this.cleanForSave.bind(this),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class FacebookOptionPlugin extends Plugin {
selector: ".o_facebook_page",
},
],
so_content_addition_selector: [".o_facebook_page"],
builder_actions: {
dataAttributeListAction: {
isApplied: ({ editingElement, param: { mainParam } = {}, value }) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class GoogleMapsOptionPlugin extends Plugin {
},
},
],
so_content_addition_selector: [".s_google_map"],
builder_actions: this.getActions(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class ImageSnippetOptionPlugin extends Plugin {
static dependencies = ["media"];
resources = {
on_snippet_dropped_handlers: this.onSnippetDropped.bind(this),
so_content_addition_selector: [".s_image"],
};

async onSnippetDropped({ snippetEl }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MapOptionPlugin extends Plugin {
selector: ".s_map",
},
],
so_content_addition_selector: [".s_map"],
builder_actions: this.getActions(),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class ProgressBarOptionPlugin extends Plugin {
cleanForSave: this.cleanForSave.bind(this),
},
builder_actions: this.getActions(),
so_content_addition_selector: [".s_progress_bar"],
};

cleanForSave(editingEl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SearchbarOptionPlugin extends Plugin {
},
],
builder_actions: this.getActions(),
so_content_addition_selector: [".s_searchbar_input"],
searchbar_option_order_by_items: {
label: _t("Name (A-Z)"),
orderBy: "name asc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class SocialMediaOptionPlugin extends Plugin {
selector: ".s_social_media",
}),
],
so_content_addition_selector: [".s_share", ".s_social_media"],
builder_actions: {
deleteSocialMediaLink: {
apply: ({ editingElement }) => {
Expand Down
11 changes: 11 additions & 0 deletions addons/html_builder/static/src/website_event/speaker_bio_plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Plugin } from "@html_editor/plugin";
import { registry } from "@web/core/registry";

class SpeakerBioPlugin extends Plugin {
static id = "speakerBio";
resources = {
so_content_addition_selector: [".s_speaker_bio"],
};
}

registry.category("website-plugins").add(SpeakerBioPlugin.id, SpeakerBioPlugin);
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class AddToCartOptionPlugin extends Plugin {
selector: ".s_add_to_cart",
},
],
so_content_addition_selector: [".s_add_to_cart"],
builder_actions: {
productToCartAction: {
apply: ({ editingElement, value }) => {
Expand Down