Skip to content

Commit 8f7df18

Browse files
loco-odooFrancoisGe
authored andcommitted
Do not start all plugins in translate mode
1 parent 6c4ac95 commit 8f7df18

19 files changed

+227
-120
lines changed

addons/html_builder/static/src/builder.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { CustomizeTab } from "./sidebar/customize_tab";
2525
import { ThemeTab } from "@html_builder/website_builder/plugins/theme/theme_tab";
2626
import { CORE_PLUGINS } from "./core/core_plugins";
2727
import { EDITOR_COLOR_CSS_VARIABLES, getCSSVariableValue } from "./utils/utils_css";
28+
import { withSequence } from "@html_editor/utils/resource";
2829

2930
export class Builder extends Component {
3031
static template = "html_builder.Builder";
@@ -76,7 +77,8 @@ export class Builder extends Component {
7677
"BannerPlugin",
7778
]
7879
);
79-
const Plugins = [...mainPlugins, ...CORE_PLUGINS, ...(this.props.Plugins || [])];
80+
const corePlugins = this.props.isTranslation ? [] : CORE_PLUGINS;
81+
const Plugins = [...mainPlugins, ...corePlugins, ...(this.props.Plugins || [])];
8082
// TODO: maybe do a different config for the translate mode and the
8183
// "regular" mode.
8284
this.editor = new Editor(
@@ -103,9 +105,9 @@ export class Builder extends Component {
103105
trigger_dom_updated: () => {
104106
editorBus.trigger("DOM_UPDATED");
105107
},
106-
on_mobile_preview_clicked: () => {
108+
on_mobile_preview_clicked: withSequence(20, () => {
107109
editorBus.trigger("DOM_UPDATED");
108-
},
110+
}),
109111
change_current_options_containers_listeners: (currentOptionsContainers) => {
110112
this.state.currentOptionsContainers = currentOptionsContainers;
111113
if (!currentOptionsContainers.length) {

addons/html_builder/static/src/builder.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
<BlockTab />
3535
</t>
3636
<t t-if="state.activeTab === 'customize'">
37-
<CustomizeTab currentOptionsContainers="state.currentOptionsContainers" snippetModel="snippetModel"/>
37+
<t t-if="props.isTranslation" t-call="html_builder.CustomizeTranslationTab"/>
38+
<CustomizeTab t-else="" currentOptionsContainers="state.currentOptionsContainers" snippetModel="snippetModel"/>
3839
</t>
3940
<t t-if="state.activeTab === 'theme'">
4041
<ThemeTab/>

addons/html_builder/static/src/core/builder_options_plugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class BuilderOptionsPlugin extends Plugin {
2020
"getContainers",
2121
"updateContainers",
2222
"deactivateContainers",
23+
"getTarget",
2324
"getPageContainers",
2425
"getRemoveDisabledReason",
2526
"getCloneDisabledReason",
@@ -150,6 +151,10 @@ export class BuilderOptionsPlugin extends Plugin {
150151
this.dispatchTo("change_current_options_containers_listeners", this.lastContainers);
151152
}
152153

154+
getTarget() {
155+
return this.target;
156+
}
157+
153158
deactivateContainers() {
154159
this.target = null;
155160
this.lastContainers = [];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Plugin } from "@html_editor/plugin";
2+
import { registry } from "@web/core/registry";
3+
4+
export class BuilderOptionsPlugin extends Plugin {
5+
static id = "builder-options";
6+
static shared = ["deactivateContainers", "getTarget"];
7+
8+
deactivateContainers() {}
9+
getTarget() {}
10+
}
11+
12+
registry.category("translation-plugins").add(BuilderOptionsPlugin.id, BuilderOptionsPlugin);

addons/html_builder/static/src/core/builder_overlay/builder_overlay_plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { throttleForAnimation } from "@web/core/utils/timing";
33
import { getScrollingElement, getScrollingTarget } from "@web/core/utils/scrolling";
44
import { checkElement } from "../builder_options_plugin";
55
import { BuilderOverlay, sizingY, sizingX, sizingGrid } from "./builder_overlay";
6+
import { withSequence } from "@html_editor/utils/resource";
67

78
function isResizable(el) {
89
const isResizableY = el.matches(sizingY.selector) && !el.matches(sizingY.exclude);
@@ -18,7 +19,7 @@ export class BuilderOverlayPlugin extends Plugin {
1819
resources = {
1920
step_added_handlers: this.refreshOverlays.bind(this),
2021
change_current_options_containers_listeners: this.openBuilderOverlays.bind(this),
21-
on_mobile_preview_clicked: this.refreshOverlays.bind(this),
22+
on_mobile_preview_clicked: withSequence(20, this.refreshOverlays.bind(this)),
2223
has_overlay_options: { hasOption: (el) => isResizable(el) },
2324
};
2425

addons/html_builder/static/src/core/disable_snippets_plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import { omit } from "@web/core/utils/objects";
22
import { Plugin } from "@html_editor/plugin";
3+
import { withSequence } from "@html_editor/utils/resource";
34

45
export class DisableSnippetsPlugin extends Plugin {
56
static id = "disableSnippets";
67
static dependencies = ["setup_editor_plugin", "dropzone", "dropzone_selector"];
78
static shared = ["disableUndroppableSnippets"];
89
resources = {
910
after_remove_handlers: this.disableUndroppableSnippets.bind(this),
10-
on_mobile_preview_clicked: this.disableUndroppableSnippets.bind(this),
1111
post_undo_handlers: this.disableUndroppableSnippets.bind(this),
1212
post_redo_handlers: this.disableUndroppableSnippets.bind(this),
13+
on_mobile_preview_clicked: withSequence(20, this.disableUndroppableSnippets.bind(this)),
1314
};
1415

1516
setup() {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Plugin } from "@html_editor/plugin";
2+
import { registry } from "@web/core/registry";
3+
4+
export class DisableSnippetsPlugin extends Plugin {
5+
static id = "disableSnippets";
6+
static shared = ["disableUndroppableSnippets"];
7+
8+
disableUndroppableSnippets() {}
9+
}
10+
11+
registry.category("translation-plugins").add(DisableSnippetsPlugin.id, DisableSnippetsPlugin);

addons/html_builder/static/src/core/overlay_buttons/overlay_buttons_plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { throttleForAnimation } from "@web/core/utils/timing";
44
import { getScrollingElement, getScrollingTarget } from "@web/core/utils/scrolling";
55
import { checkElement } from "../builder_options_plugin";
66
import { OverlayButtons } from "./overlay_buttons";
7+
import { withSequence } from "@html_editor/utils/resource";
78

89
export class OverlayButtonsPlugin extends Plugin {
910
static id = "overlayButtons";
@@ -17,7 +18,7 @@ export class OverlayButtonsPlugin extends Plugin {
1718
resources = {
1819
step_added_handlers: this.refreshButtons.bind(this),
1920
change_current_options_containers_listeners: this.addOverlayButtons.bind(this),
20-
on_mobile_preview_clicked: this.refreshButtons.bind(this),
21+
on_mobile_preview_clicked: withSequence(20, this.refreshButtons.bind(this)),
2122
};
2223

2324
setup() {

addons/html_builder/static/src/core/save_plugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Plugin } from "@html_editor/plugin";
22
import { rpc } from "@web/core/network/rpc";
3+
import { registry } from "@web/core/registry";
34

45
const oeStructureSelector = "#wrapwrap .oe_structure[data-oe-xpath][data-oe-id]";
56
const oeFieldSelector = "#wrapwrap [data-oe-field]:not([data-oe-sanitize-prevent-edition])";
@@ -222,3 +223,4 @@ export class SavePlugin extends Plugin {
222223
}
223224
}
224225
}
226+
registry.category("translation-plugins").add(SavePlugin.id, SavePlugin);

addons/html_builder/static/src/core/setup_editor_plugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Plugin } from "@html_editor/plugin";
22
import { _t } from "@web/core/l10n/translation";
33
import { getTranslationEditableEls } from "@html_builder/website_builder/plugins/translation_plugin";
4+
import { registry } from "@web/core/registry";
45

56
export class SetupEditorPlugin extends Plugin {
67
static id = "setup_editor_plugin";
@@ -103,3 +104,4 @@ export class SetupEditorPlugin extends Plugin {
103104
return editablesAreaEls;
104105
}
105106
}
107+
registry.category("translation-plugins").add(SetupEditorPlugin.id, SetupEditorPlugin);

0 commit comments

Comments
 (0)