@elementor/editor-canvas 4.3.0-960 → 4.3.0-961
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +43 -43
- package/dist/index.mjs +8 -8
- package/package.json +20 -20
- package/src/components/__tests__/elements-overlays.test.tsx +7 -0
- package/src/components/elements-overlays.tsx +6 -6
- package/src/components/grid-outline/__tests__/grid-outline-overlay.test.tsx +13 -15
- package/src/components/grid-outline/grid-outline-overlay.tsx +3 -4
package/dist/index.js
CHANGED
|
@@ -870,7 +870,6 @@ var GridEmptyCellPositioner = ({ element }) => {
|
|
|
870
870
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
871
871
|
var React6 = __toESM(require("react"));
|
|
872
872
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
873
|
-
var import_editor_props2 = require("@elementor/editor-props");
|
|
874
873
|
var import_ui2 = require("@elementor/ui");
|
|
875
874
|
var import_react11 = require("@floating-ui/react");
|
|
876
875
|
|
|
@@ -1143,8 +1142,8 @@ function GridOutline({ element, tracks, width, height }) {
|
|
|
1143
1142
|
|
|
1144
1143
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
1145
1144
|
var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
1146
|
-
const
|
|
1147
|
-
const enabled =
|
|
1145
|
+
const settings = (0, import_editor_elements4.useElementEditorSettings)(id);
|
|
1146
|
+
const enabled = settings?.grid_outline;
|
|
1148
1147
|
const rect = useElementRect(element);
|
|
1149
1148
|
const tracks = useGridTracks(element, rect);
|
|
1150
1149
|
const { floating } = useFloatingOnElement({ element, isSelected });
|
|
@@ -1167,9 +1166,10 @@ var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
|
1167
1166
|
};
|
|
1168
1167
|
|
|
1169
1168
|
// src/components/elements-overlays.tsx
|
|
1169
|
+
var hasGridStyleDisplay = (element) => {
|
|
1170
|
+
return element.computedStyleMap().get("display")?.toString() === "grid";
|
|
1171
|
+
};
|
|
1170
1172
|
var ELEMENTS_DATA_ATTR = "atomic";
|
|
1171
|
-
var E_GRID_TYPE = "e-grid";
|
|
1172
|
-
var isGridElement = (element) => [element.dataset.eType, element.dataset.element_type].includes(E_GRID_TYPE);
|
|
1173
1173
|
var overlayRegistry = [
|
|
1174
1174
|
{
|
|
1175
1175
|
component: OutlineOverlay,
|
|
@@ -1177,11 +1177,11 @@ var overlayRegistry = [
|
|
|
1177
1177
|
},
|
|
1178
1178
|
{
|
|
1179
1179
|
component: GridEmptyCellPositioner,
|
|
1180
|
-
shouldRender: ({ element }) =>
|
|
1180
|
+
shouldRender: ({ element }) => hasGridStyleDisplay(element)
|
|
1181
1181
|
},
|
|
1182
1182
|
{
|
|
1183
1183
|
component: GridOutlineOverlay,
|
|
1184
|
-
shouldRender: ({
|
|
1184
|
+
shouldRender: ({ isSelected, element }) => isSelected && hasGridStyleDisplay(element)
|
|
1185
1185
|
}
|
|
1186
1186
|
];
|
|
1187
1187
|
function ElementsOverlays() {
|
|
@@ -1467,7 +1467,7 @@ var import_editor_styles = require("@elementor/editor-styles");
|
|
|
1467
1467
|
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
1468
1468
|
|
|
1469
1469
|
// src/renderers/create-props-resolver.ts
|
|
1470
|
-
var
|
|
1470
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
1471
1471
|
|
|
1472
1472
|
// src/renderers/multi-props.ts
|
|
1473
1473
|
var isMultiProps = (propValue) => {
|
|
@@ -1505,7 +1505,7 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1505
1505
|
if (value === null || value === void 0) {
|
|
1506
1506
|
return null;
|
|
1507
1507
|
}
|
|
1508
|
-
if (!(0,
|
|
1508
|
+
if (!(0, import_editor_props2.isTransformable)(value)) {
|
|
1509
1509
|
return value;
|
|
1510
1510
|
}
|
|
1511
1511
|
if (depth > TRANSFORM_DEPTH_LIMIT) {
|
|
@@ -1563,13 +1563,13 @@ function createPropsResolver({ transformers, schema: initialSchema, onPropResolv
|
|
|
1563
1563
|
}
|
|
1564
1564
|
|
|
1565
1565
|
// src/renderers/enqueue-font-from-style-prop.ts
|
|
1566
|
-
var
|
|
1566
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
1567
1567
|
var maybeEnqueueFontFromStyleProp = (propType, propValue, enqueue) => {
|
|
1568
|
-
if (!(0,
|
|
1568
|
+
if (!(0, import_editor_props3.isTransformable)(propValue) || propValue.disabled) {
|
|
1569
1569
|
return;
|
|
1570
1570
|
}
|
|
1571
1571
|
const typeKey = propType.kind === "union" ? propValue.$$type : propType.key;
|
|
1572
|
-
const propTypeUtil = (0,
|
|
1572
|
+
const propTypeUtil = (0, import_editor_props3.getPropSchemaFromCache)(typeKey);
|
|
1573
1573
|
if (!propTypeUtil || !("getEnqueueFontFamily" in propTypeUtil) || typeof propTypeUtil.getEnqueueFontFamily !== "function") {
|
|
1574
1574
|
return;
|
|
1575
1575
|
}
|
|
@@ -3425,7 +3425,7 @@ var import_client = require("react-dom/client");
|
|
|
3425
3425
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
3426
3426
|
var React11 = __toESM(require("react"));
|
|
3427
3427
|
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3428
|
-
var
|
|
3428
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
3429
3429
|
var import_editor_v1_adapters13 = require("@elementor/editor-v1-adapters");
|
|
3430
3430
|
var import_i18n3 = require("@wordpress/i18n");
|
|
3431
3431
|
|
|
@@ -3702,11 +3702,11 @@ var InlineEditingToolbar = ({ anchor, editor, id }) => {
|
|
|
3702
3702
|
};
|
|
3703
3703
|
|
|
3704
3704
|
// src/legacy/replacements/inline-editing/inline-editing-eligibility.ts
|
|
3705
|
-
var
|
|
3705
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
3706
3706
|
var hasKey = (propType) => {
|
|
3707
3707
|
return "key" in propType;
|
|
3708
3708
|
};
|
|
3709
|
-
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([
|
|
3709
|
+
var TEXT_PROP_TYPE_KEYS = /* @__PURE__ */ new Set([import_editor_props4.htmlV3PropTypeUtil.key, import_editor_props4.stringPropTypeUtil.key]);
|
|
3710
3710
|
var isCoreTextPropTypeKey = (key) => {
|
|
3711
3711
|
return TEXT_PROP_TYPE_KEYS.has(key);
|
|
3712
3712
|
};
|
|
@@ -3726,7 +3726,7 @@ var isInlineEditingAllowed = ({ rawValue, propTypeFromSchema }) => {
|
|
|
3726
3726
|
if (rawValue === null || rawValue === void 0) {
|
|
3727
3727
|
return isAllowedBySchema(propTypeFromSchema);
|
|
3728
3728
|
}
|
|
3729
|
-
return
|
|
3729
|
+
return import_editor_props4.htmlV3PropTypeUtil.isValid(rawValue) || import_editor_props4.stringPropTypeUtil.isValid(rawValue);
|
|
3730
3730
|
};
|
|
3731
3731
|
|
|
3732
3732
|
// src/legacy/replacements/inline-editing/inline-editing-elements.tsx
|
|
@@ -3811,15 +3811,15 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3811
3811
|
}
|
|
3812
3812
|
getExtractedContentValue() {
|
|
3813
3813
|
const propValue = this.getInlineEditablePropValue();
|
|
3814
|
-
const extracted =
|
|
3815
|
-
return
|
|
3814
|
+
const extracted = import_editor_props5.htmlV3PropTypeUtil.extract(propValue);
|
|
3815
|
+
return import_editor_props5.stringPropTypeUtil.extract(extracted?.content ?? null) ?? "";
|
|
3816
3816
|
}
|
|
3817
3817
|
setContentValue(value) {
|
|
3818
3818
|
const settingKey = this.getInlineEditablePropertyName();
|
|
3819
3819
|
const html = value || "";
|
|
3820
|
-
const parsed = (0,
|
|
3821
|
-
const valueToSave =
|
|
3822
|
-
content: parsed.content ?
|
|
3820
|
+
const parsed = (0, import_editor_props5.parseHtmlChildren)(html);
|
|
3821
|
+
const valueToSave = import_editor_props5.htmlV3PropTypeUtil.create({
|
|
3822
|
+
content: parsed.content ? import_editor_props5.stringPropTypeUtil.create(parsed.content) : null,
|
|
3823
3823
|
children: parsed.children
|
|
3824
3824
|
});
|
|
3825
3825
|
(0, import_editor_v1_adapters13.undoable)(
|
|
@@ -3850,7 +3850,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3850
3850
|
return null;
|
|
3851
3851
|
}
|
|
3852
3852
|
if (propType.kind === "union") {
|
|
3853
|
-
const textKeys = [
|
|
3853
|
+
const textKeys = [import_editor_props5.htmlV3PropTypeUtil.key, import_editor_props5.stringPropTypeUtil.key];
|
|
3854
3854
|
for (const key of textKeys) {
|
|
3855
3855
|
if (propType.prop_types[key]) {
|
|
3856
3856
|
return key;
|
|
@@ -3879,7 +3879,7 @@ var InlineEditingReplacement = class extends ReplacementBase {
|
|
|
3879
3879
|
getExpectedTag() {
|
|
3880
3880
|
const tagPropType = this.getTagPropType();
|
|
3881
3881
|
const tagSettingKey = "tag";
|
|
3882
|
-
return
|
|
3882
|
+
return import_editor_props5.stringPropTypeUtil.extract(this.getSetting(tagSettingKey) ?? null) ?? import_editor_props5.stringPropTypeUtil.extract(tagPropType?.default ?? null) ?? null;
|
|
3883
3883
|
}
|
|
3884
3884
|
getTagPropType() {
|
|
3885
3885
|
const propsSchema = (0, import_editor_elements9.getElementType)(this.type)?.propsSchema;
|
|
@@ -4106,7 +4106,7 @@ function createNestedTemplatedType(type, renderer, element) {
|
|
|
4106
4106
|
}
|
|
4107
4107
|
|
|
4108
4108
|
// src/legacy/tabs-model-extensions.ts
|
|
4109
|
-
var
|
|
4109
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
4110
4110
|
var tabModelExtensions = {
|
|
4111
4111
|
modifyDefaultChildren(elements) {
|
|
4112
4112
|
if (!Array.isArray(elements) || elements.length === 0) {
|
|
@@ -4122,8 +4122,8 @@ var tabModelExtensions = {
|
|
|
4122
4122
|
...paragraphElement,
|
|
4123
4123
|
settings: {
|
|
4124
4124
|
...paragraphElement.settings,
|
|
4125
|
-
paragraph:
|
|
4126
|
-
content:
|
|
4125
|
+
paragraph: import_editor_props6.htmlV3PropTypeUtil.create({
|
|
4126
|
+
content: import_editor_props6.stringPropTypeUtil.create(`Tab ${position}`),
|
|
4127
4127
|
children: []
|
|
4128
4128
|
})
|
|
4129
4129
|
}
|
|
@@ -4136,7 +4136,7 @@ function initTabsModelExtensions() {
|
|
|
4136
4136
|
}
|
|
4137
4137
|
|
|
4138
4138
|
// src/mcp/canvas-mcp.ts
|
|
4139
|
-
var
|
|
4139
|
+
var import_editor_props11 = require("@elementor/editor-props");
|
|
4140
4140
|
|
|
4141
4141
|
// src/mcp/resources/available-widgets-resource.ts
|
|
4142
4142
|
var import_editor_v1_adapters15 = require("@elementor/editor-v1-adapters");
|
|
@@ -4288,7 +4288,7 @@ function extractElementData(element) {
|
|
|
4288
4288
|
}
|
|
4289
4289
|
|
|
4290
4290
|
// src/mcp/resources/dynamic-tags-resource.ts
|
|
4291
|
-
var
|
|
4291
|
+
var import_editor_props7 = require("@elementor/editor-props");
|
|
4292
4292
|
|
|
4293
4293
|
// src/mcp/utils/resolve-dynamic-tag.ts
|
|
4294
4294
|
var import_editor_v1_adapters17 = require("@elementor/editor-v1-adapters");
|
|
@@ -4356,7 +4356,7 @@ var defaultSettingValue = (propType) => {
|
|
|
4356
4356
|
var DYNAMIC_TAGS_URI = "elementor://dynamic-tags";
|
|
4357
4357
|
var settingsSchema = (propsSchema) => {
|
|
4358
4358
|
return Object.fromEntries(
|
|
4359
|
-
Object.entries(propsSchema ?? {}).filter(([key]) => !OMITTED_DYNAMIC_SETTING_KEYS.includes(key)).map(([key, propType]) => [key,
|
|
4359
|
+
Object.entries(propsSchema ?? {}).filter(([key]) => !OMITTED_DYNAMIC_SETTING_KEYS.includes(key)).map(([key, propType]) => [key, import_editor_props7.Schema.propTypeToJsonSchema(propType)])
|
|
4360
4360
|
);
|
|
4361
4361
|
};
|
|
4362
4362
|
var buildDynamicTagsList = () => {
|
|
@@ -4713,7 +4713,7 @@ var import_editor_elements15 = require("@elementor/editor-elements");
|
|
|
4713
4713
|
|
|
4714
4714
|
// src/mcp/utils/do-update-element-property.ts
|
|
4715
4715
|
var import_editor_elements14 = require("@elementor/editor-elements");
|
|
4716
|
-
var
|
|
4716
|
+
var import_editor_props8 = require("@elementor/editor-props");
|
|
4717
4717
|
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
4718
4718
|
var import_editor_v1_adapters21 = require("@elementor/editor-v1-adapters");
|
|
4719
4719
|
|
|
@@ -4790,7 +4790,7 @@ var LOCAL_STYLE_META = {
|
|
|
4790
4790
|
};
|
|
4791
4791
|
function resolvePropValue(value, forceKey) {
|
|
4792
4792
|
const Utils = window.elementorV2.editorVariables.Utils;
|
|
4793
|
-
return
|
|
4793
|
+
return import_editor_props8.Schema.adjustLlmPropValueSchema(value, {
|
|
4794
4794
|
forceKey,
|
|
4795
4795
|
transformers: {
|
|
4796
4796
|
...Utils.globalVariablesLLMResolvers,
|
|
@@ -4849,7 +4849,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4849
4849
|
}
|
|
4850
4850
|
if (propertyRawSchema.kind === "plain") {
|
|
4851
4851
|
if (typeof propertyMapValue[stylePropName] !== "object") {
|
|
4852
|
-
const propUtil = (0,
|
|
4852
|
+
const propUtil = (0, import_editor_props8.getPropSchemaFromCache)(propertyRawSchema.key);
|
|
4853
4853
|
if (propUtil) {
|
|
4854
4854
|
const plainValue = propUtil.create(propertyMapValue[stylePropName]);
|
|
4855
4855
|
propertyMapValue[stylePropName] = plainValue;
|
|
@@ -4902,7 +4902,7 @@ var doUpdateElementProperty = (params) => {
|
|
|
4902
4902
|
}
|
|
4903
4903
|
const propKey = elementPropSchema[propertyName].key;
|
|
4904
4904
|
const value = resolvePropValue(propertyValue, propKey);
|
|
4905
|
-
const { valid, jsonSchema } =
|
|
4905
|
+
const { valid, jsonSchema } = import_editor_props8.Schema.validatePropValue(elementPropSchema[propertyName], propertyValue);
|
|
4906
4906
|
if (!valid) {
|
|
4907
4907
|
throw new Error(
|
|
4908
4908
|
`Invalid PropValue for elementId: ${elementId}. PropKey: ${propKey}, PropValue: ${JSON.stringify(
|
|
@@ -5647,7 +5647,7 @@ function onElementAdded(element) {
|
|
|
5647
5647
|
// src/mcp/tools/configure-element/tool.ts
|
|
5648
5648
|
var import_editor_elements17 = require("@elementor/editor-elements");
|
|
5649
5649
|
var import_editor_mcp5 = require("@elementor/editor-mcp");
|
|
5650
|
-
var
|
|
5650
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
5651
5651
|
|
|
5652
5652
|
// src/mcp/tools/configure-element/prompt.ts
|
|
5653
5653
|
var import_editor_mcp4 = require("@elementor/editor-mcp");
|
|
@@ -5836,7 +5836,7 @@ var initConfigureElementTool = (reg) => {
|
|
|
5836
5836
|
const propertiesToUpdate = resolveCanonicalPropKeys(elementType, propertiesToChange);
|
|
5837
5837
|
const toUpdate = Object.entries(propertiesToUpdate);
|
|
5838
5838
|
for (const [propertyName, propertyValue] of toUpdate) {
|
|
5839
|
-
if (!
|
|
5839
|
+
if (!import_editor_props9.Schema.isPropKeyConfigurable(propertyName)) {
|
|
5840
5840
|
throw new Error(`Not allowed to update ${propertyName}`);
|
|
5841
5841
|
}
|
|
5842
5842
|
try {
|
|
@@ -5913,7 +5913,7 @@ Provide styling as raw CSS via the "style" parameter (a flat map of CSS property
|
|
|
5913
5913
|
|
|
5914
5914
|
// src/mcp/tools/get-element-config/tool.ts
|
|
5915
5915
|
var import_editor_elements18 = require("@elementor/editor-elements");
|
|
5916
|
-
var
|
|
5916
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
5917
5917
|
var import_schema5 = require("@elementor/schema");
|
|
5918
5918
|
var schema = {
|
|
5919
5919
|
elementId: import_schema5.z.string()
|
|
@@ -5970,7 +5970,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
5970
5970
|
}
|
|
5971
5971
|
const propValues = {};
|
|
5972
5972
|
const stylePropValues = {};
|
|
5973
|
-
|
|
5973
|
+
import_editor_props10.Schema.configurableKeys(propSchema).forEach((key) => {
|
|
5974
5974
|
propValues[key] = structuredClone(elementRawSettings.get(key));
|
|
5975
5975
|
});
|
|
5976
5976
|
const elementStyles = (0, import_editor_elements18.getElementStyles)(elementId) || {};
|
|
@@ -6006,7 +6006,7 @@ var initGetElementConfigTool = (reg) => {
|
|
|
6006
6006
|
|
|
6007
6007
|
// src/mcp/canvas-mcp.ts
|
|
6008
6008
|
var initCanvasMcp = (reg) => {
|
|
6009
|
-
|
|
6009
|
+
import_editor_props11.Schema.setDynamicTagNamesResolver(getDynamicTagNamesByCategories);
|
|
6010
6010
|
initWidgetsSchemaResource(reg);
|
|
6011
6011
|
initAvailableWidgetsResource(reg);
|
|
6012
6012
|
initDocumentStructureResource(reg);
|
|
@@ -6213,12 +6213,12 @@ function shouldBlock(sourceElements, targetElements) {
|
|
|
6213
6213
|
|
|
6214
6214
|
// src/style-commands/paste-style.ts
|
|
6215
6215
|
var import_editor_elements22 = require("@elementor/editor-elements");
|
|
6216
|
-
var
|
|
6216
|
+
var import_editor_props13 = require("@elementor/editor-props");
|
|
6217
6217
|
var import_editor_v1_adapters24 = require("@elementor/editor-v1-adapters");
|
|
6218
6218
|
|
|
6219
6219
|
// src/utils/command-utils.ts
|
|
6220
6220
|
var import_editor_elements20 = require("@elementor/editor-elements");
|
|
6221
|
-
var
|
|
6221
|
+
var import_editor_props12 = require("@elementor/editor-props");
|
|
6222
6222
|
var import_i18n5 = require("@wordpress/i18n");
|
|
6223
6223
|
function hasAtomicWidgets(args) {
|
|
6224
6224
|
const { containers = [args.container] } = args;
|
|
@@ -6236,7 +6236,7 @@ function getClassesProp(container) {
|
|
|
6236
6236
|
return null;
|
|
6237
6237
|
}
|
|
6238
6238
|
const [propKey] = Object.entries(propsSchema).find(
|
|
6239
|
-
([, propType]) => propType.kind === "plain" && propType.key ===
|
|
6239
|
+
([, propType]) => propType.kind === "plain" && propType.key === import_editor_props12.CLASSES_PROP_KEY
|
|
6240
6240
|
) ?? [];
|
|
6241
6241
|
return propKey ?? null;
|
|
6242
6242
|
}
|
|
@@ -6385,8 +6385,8 @@ function pasteClasses(containers, classes) {
|
|
|
6385
6385
|
return;
|
|
6386
6386
|
}
|
|
6387
6387
|
const classesSetting = (0, import_editor_elements22.getElementSetting)(container.id, classesProp);
|
|
6388
|
-
const currentClasses =
|
|
6389
|
-
const newClasses =
|
|
6388
|
+
const currentClasses = import_editor_props13.classesPropTypeUtil.extract(classesSetting) ?? [];
|
|
6389
|
+
const newClasses = import_editor_props13.classesPropTypeUtil.create(Array.from(/* @__PURE__ */ new Set([...classes, ...currentClasses])));
|
|
6390
6390
|
(0, import_editor_elements22.updateElementSettings)({
|
|
6391
6391
|
id: container.id,
|
|
6392
6392
|
props: { [classesProp]: newClasses }
|
package/dist/index.mjs
CHANGED
|
@@ -807,8 +807,7 @@ var GridEmptyCellPositioner = ({ element }) => {
|
|
|
807
807
|
|
|
808
808
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
809
809
|
import * as React6 from "react";
|
|
810
|
-
import {
|
|
811
|
-
import { booleanPropTypeUtil } from "@elementor/editor-props";
|
|
810
|
+
import { useElementEditorSettings } from "@elementor/editor-elements";
|
|
812
811
|
import { Box as Box2 } from "@elementor/ui";
|
|
813
812
|
import { FloatingPortal as FloatingPortal2 } from "@floating-ui/react";
|
|
814
813
|
|
|
@@ -1081,8 +1080,8 @@ function GridOutline({ element, tracks, width, height }) {
|
|
|
1081
1080
|
|
|
1082
1081
|
// src/components/grid-outline/grid-outline-overlay.tsx
|
|
1083
1082
|
var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
1084
|
-
const
|
|
1085
|
-
const enabled =
|
|
1083
|
+
const settings = useElementEditorSettings(id);
|
|
1084
|
+
const enabled = settings?.grid_outline;
|
|
1086
1085
|
const rect = useElementRect(element);
|
|
1087
1086
|
const tracks = useGridTracks(element, rect);
|
|
1088
1087
|
const { floating } = useFloatingOnElement({ element, isSelected });
|
|
@@ -1105,9 +1104,10 @@ var GridOutlineOverlay = ({ element, id, isSelected }) => {
|
|
|
1105
1104
|
};
|
|
1106
1105
|
|
|
1107
1106
|
// src/components/elements-overlays.tsx
|
|
1107
|
+
var hasGridStyleDisplay = (element) => {
|
|
1108
|
+
return element.computedStyleMap().get("display")?.toString() === "grid";
|
|
1109
|
+
};
|
|
1108
1110
|
var ELEMENTS_DATA_ATTR = "atomic";
|
|
1109
|
-
var E_GRID_TYPE = "e-grid";
|
|
1110
|
-
var isGridElement = (element) => [element.dataset.eType, element.dataset.element_type].includes(E_GRID_TYPE);
|
|
1111
1111
|
var overlayRegistry = [
|
|
1112
1112
|
{
|
|
1113
1113
|
component: OutlineOverlay,
|
|
@@ -1115,11 +1115,11 @@ var overlayRegistry = [
|
|
|
1115
1115
|
},
|
|
1116
1116
|
{
|
|
1117
1117
|
component: GridEmptyCellPositioner,
|
|
1118
|
-
shouldRender: ({ element }) =>
|
|
1118
|
+
shouldRender: ({ element }) => hasGridStyleDisplay(element)
|
|
1119
1119
|
},
|
|
1120
1120
|
{
|
|
1121
1121
|
component: GridOutlineOverlay,
|
|
1122
|
-
shouldRender: ({
|
|
1122
|
+
shouldRender: ({ isSelected, element }) => isSelected && hasGridStyleDisplay(element)
|
|
1123
1123
|
}
|
|
1124
1124
|
];
|
|
1125
1125
|
function ElementsOverlays() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "4.3.0-
|
|
4
|
+
"version": "4.3.0-961",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "4.3.0-
|
|
41
|
-
"@elementor/editor-controls": "4.3.0-
|
|
42
|
-
"@elementor/editor-documents": "4.3.0-
|
|
43
|
-
"@elementor/editor-elements": "4.3.0-
|
|
44
|
-
"@elementor/editor-interactions": "4.3.0-
|
|
45
|
-
"@elementor/editor-mcp": "4.3.0-
|
|
46
|
-
"@elementor/editor-notifications": "4.3.0-
|
|
47
|
-
"@elementor/editor-props": "4.3.0-
|
|
48
|
-
"@elementor/editor-responsive": "4.3.0-
|
|
49
|
-
"@elementor/editor-styles": "4.3.0-
|
|
50
|
-
"@elementor/editor-styles-repository": "4.3.0-
|
|
51
|
-
"@elementor/editor-ui": "4.3.0-
|
|
52
|
-
"@elementor/editor-v1-adapters": "4.3.0-
|
|
53
|
-
"@elementor/events": "4.3.0-
|
|
54
|
-
"@elementor/http-client": "4.3.0-
|
|
55
|
-
"@elementor/schema": "4.3.0-
|
|
56
|
-
"@elementor/twing": "4.3.0-
|
|
40
|
+
"@elementor/editor": "4.3.0-961",
|
|
41
|
+
"@elementor/editor-controls": "4.3.0-961",
|
|
42
|
+
"@elementor/editor-documents": "4.3.0-961",
|
|
43
|
+
"@elementor/editor-elements": "4.3.0-961",
|
|
44
|
+
"@elementor/editor-interactions": "4.3.0-961",
|
|
45
|
+
"@elementor/editor-mcp": "4.3.0-961",
|
|
46
|
+
"@elementor/editor-notifications": "4.3.0-961",
|
|
47
|
+
"@elementor/editor-props": "4.3.0-961",
|
|
48
|
+
"@elementor/editor-responsive": "4.3.0-961",
|
|
49
|
+
"@elementor/editor-styles": "4.3.0-961",
|
|
50
|
+
"@elementor/editor-styles-repository": "4.3.0-961",
|
|
51
|
+
"@elementor/editor-ui": "4.3.0-961",
|
|
52
|
+
"@elementor/editor-v1-adapters": "4.3.0-961",
|
|
53
|
+
"@elementor/events": "4.3.0-961",
|
|
54
|
+
"@elementor/http-client": "4.3.0-961",
|
|
55
|
+
"@elementor/schema": "4.3.0-961",
|
|
56
|
+
"@elementor/twing": "4.3.0-961",
|
|
57
57
|
"@elementor/ui": "1.37.5",
|
|
58
|
-
"@elementor/utils": "4.3.0-
|
|
59
|
-
"@elementor/wp-media": "4.3.0-
|
|
58
|
+
"@elementor/utils": "4.3.0-961",
|
|
59
|
+
"@elementor/wp-media": "4.3.0-961",
|
|
60
60
|
"@floating-ui/react": "^0.27.5",
|
|
61
61
|
"@wordpress/i18n": "^5.13.0",
|
|
62
62
|
"dompurify": "^3.2.6"
|
|
@@ -19,6 +19,10 @@ jest.mock( '@elementor/editor-v1-adapters', () => ( {
|
|
|
19
19
|
isExperimentActive: jest.fn(),
|
|
20
20
|
} ) );
|
|
21
21
|
|
|
22
|
+
function mockGridComputedStyle( element: HTMLElement ) {
|
|
23
|
+
element.computedStyleMap = jest.fn().mockReturnValue( new Map( [ [ 'display', { toString: () => 'grid' } ] ] ) );
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
describe( '<ElementsOverlays />', () => {
|
|
23
27
|
beforeEach( () => {
|
|
24
28
|
const documentEl = createDOMElement( { tag: 'div' } );
|
|
@@ -26,6 +30,9 @@ describe( '<ElementsOverlays />', () => {
|
|
|
26
30
|
const atomic1El = createDOMElement( { tag: 'div', attrs: { 'data-atomic': '', id: '10' } } );
|
|
27
31
|
const atomic2El = createDOMElement( { tag: 'div', attrs: { 'data-atomic': '', id: '20' } } );
|
|
28
32
|
|
|
33
|
+
mockGridComputedStyle( atomic1El );
|
|
34
|
+
mockGridComputedStyle( atomic2El );
|
|
35
|
+
|
|
29
36
|
jest.mocked( useEditMode ).mockReturnValue( 'edit' );
|
|
30
37
|
jest.mocked( useIsRouteActive ).mockReturnValue( false );
|
|
31
38
|
jest.mocked( isExperimentActive ).mockReturnValue( true );
|
|
@@ -11,11 +11,11 @@ import type { ElementOverlayConfig } from '../types/element-overlay';
|
|
|
11
11
|
import { GridEmptyCellPositioner, GridOutlineOverlay } from './grid-outline';
|
|
12
12
|
import { OutlineOverlay } from './outline-overlay';
|
|
13
13
|
|
|
14
|
-
const
|
|
15
|
-
|
|
14
|
+
const hasGridStyleDisplay = ( element: HTMLElement ): boolean => {
|
|
15
|
+
return element.computedStyleMap().get( 'display' )?.toString() === 'grid';
|
|
16
|
+
};
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
-
[ element.dataset.eType, element.dataset.element_type ].includes( E_GRID_TYPE );
|
|
18
|
+
const ELEMENTS_DATA_ATTR = 'atomic';
|
|
19
19
|
|
|
20
20
|
const overlayRegistry: ElementOverlayConfig[] = [
|
|
21
21
|
{
|
|
@@ -24,11 +24,11 @@ const overlayRegistry: ElementOverlayConfig[] = [
|
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
26
|
component: GridEmptyCellPositioner,
|
|
27
|
-
shouldRender: ( { element } ) =>
|
|
27
|
+
shouldRender: ( { element } ) => hasGridStyleDisplay( element ),
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
30
|
component: GridOutlineOverlay,
|
|
31
|
-
shouldRender: ( {
|
|
31
|
+
shouldRender: ( { isSelected, element } ) => isSelected && hasGridStyleDisplay( element ),
|
|
32
32
|
},
|
|
33
33
|
];
|
|
34
34
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { createDOMElement, renderWithTheme } from 'test-utils';
|
|
3
|
-
import {
|
|
3
|
+
import { useElementEditorSettings } from '@elementor/editor-elements';
|
|
4
4
|
import { screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
import { useElementRect } from '../../../hooks/use-element-rect';
|
|
@@ -34,12 +34,10 @@ const EMPTY_TRACKS: GridTracks = {
|
|
|
34
34
|
borderColor: '',
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
function mockGridOutlineSetting(
|
|
38
|
-
jest.mocked(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
settings: { grid_outline: value },
|
|
42
|
-
} );
|
|
37
|
+
function mockGridOutlineSetting( gridOutline: boolean | undefined ) {
|
|
38
|
+
jest.mocked( useElementEditorSettings ).mockReturnValue(
|
|
39
|
+
gridOutline === undefined ? {} : { grid_outline: gridOutline }
|
|
40
|
+
);
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
function mockFloating() {
|
|
@@ -87,7 +85,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
87
85
|
} );
|
|
88
86
|
|
|
89
87
|
it( 'renders the outline svg with the element id when the setting is enabled', () => {
|
|
90
|
-
mockGridOutlineSetting(
|
|
88
|
+
mockGridOutlineSetting( true );
|
|
91
89
|
|
|
92
90
|
renderOverlay();
|
|
93
91
|
|
|
@@ -97,8 +95,8 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
97
95
|
expect( overlay.querySelector( 'svg' ) ).toBeInTheDocument();
|
|
98
96
|
} );
|
|
99
97
|
|
|
100
|
-
it( 'treats
|
|
101
|
-
mockGridOutlineSetting(
|
|
98
|
+
it( 'treats an unset setting as default-on and renders the outline', () => {
|
|
99
|
+
mockGridOutlineSetting( undefined );
|
|
102
100
|
|
|
103
101
|
renderOverlay();
|
|
104
102
|
|
|
@@ -106,7 +104,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
106
104
|
} );
|
|
107
105
|
|
|
108
106
|
it( 'renders nothing when the setting is explicitly disabled', () => {
|
|
109
|
-
mockGridOutlineSetting(
|
|
107
|
+
mockGridOutlineSetting( false );
|
|
110
108
|
|
|
111
109
|
renderOverlay();
|
|
112
110
|
|
|
@@ -114,7 +112,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
114
112
|
} );
|
|
115
113
|
|
|
116
114
|
it( 'renders nothing while tracks have not resolved yet', () => {
|
|
117
|
-
mockGridOutlineSetting(
|
|
115
|
+
mockGridOutlineSetting( true );
|
|
118
116
|
jest.mocked( useGridTracks ).mockReturnValue( EMPTY_TRACKS );
|
|
119
117
|
|
|
120
118
|
renderOverlay();
|
|
@@ -123,7 +121,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
123
121
|
} );
|
|
124
122
|
|
|
125
123
|
it( 'renders one rect per cell when the grid has a gap', () => {
|
|
126
|
-
mockGridOutlineSetting(
|
|
124
|
+
mockGridOutlineSetting( undefined );
|
|
127
125
|
jest.mocked( useGridTracks ).mockReturnValue( {
|
|
128
126
|
...NON_EMPTY_TRACKS,
|
|
129
127
|
columns: [ 100, 100, 100 ],
|
|
@@ -140,7 +138,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
140
138
|
} );
|
|
141
139
|
|
|
142
140
|
it( 'renders boundary lines when the grid has no gap', () => {
|
|
143
|
-
mockGridOutlineSetting(
|
|
141
|
+
mockGridOutlineSetting( undefined );
|
|
144
142
|
jest.mocked( useGridTracks ).mockReturnValue( {
|
|
145
143
|
...NON_EMPTY_TRACKS,
|
|
146
144
|
columns: [ 100, 100, 100 ],
|
|
@@ -157,7 +155,7 @@ describe( '<GridOutlineOverlay />', () => {
|
|
|
157
155
|
} );
|
|
158
156
|
|
|
159
157
|
it( 'mounts inside the canvas wrapper portal', () => {
|
|
160
|
-
mockGridOutlineSetting(
|
|
158
|
+
mockGridOutlineSetting( undefined );
|
|
161
159
|
|
|
162
160
|
renderOverlay();
|
|
163
161
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { booleanPropTypeUtil } from '@elementor/editor-props';
|
|
2
|
+
import { useElementEditorSettings } from '@elementor/editor-elements';
|
|
4
3
|
import { Box } from '@elementor/ui';
|
|
5
4
|
import { FloatingPortal } from '@floating-ui/react';
|
|
6
5
|
|
|
@@ -12,8 +11,8 @@ import { CANVAS_WRAPPER_ID } from '../outline-overlay';
|
|
|
12
11
|
import { GridOutline } from './grid-outline';
|
|
13
12
|
|
|
14
13
|
export const GridOutlineOverlay = ( { element, id, isSelected }: ElementOverlayProps ): React.ReactElement | null => {
|
|
15
|
-
const
|
|
16
|
-
const enabled =
|
|
14
|
+
const settings = useElementEditorSettings( id );
|
|
15
|
+
const enabled = settings?.grid_outline;
|
|
17
16
|
const rect = useElementRect( element );
|
|
18
17
|
const tracks = useGridTracks( element, rect );
|
|
19
18
|
const { floating } = useFloatingOnElement( { element, isSelected } );
|