@elementor/editor-controls 3.32.0-94 → 3.33.0-100
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.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +177 -60
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -60
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/components/css-code-editor/css-editor.styles.ts +9 -2
- package/src/components/css-code-editor/css-editor.tsx +48 -72
- package/src/components/css-code-editor/css-validation.ts +13 -0
- package/src/components/css-code-editor/visual-content-change-protection.ts +69 -0
- package/src/components/unstable-repeater/context/repeater-context.tsx +16 -1
- package/src/controls/transition-control/trainsition-events.ts +28 -0
- package/src/controls/transition-control/transition-repeater-control.tsx +3 -0
- package/src/services/event-bus.ts +38 -0
package/dist/index.mjs
CHANGED
|
@@ -1186,6 +1186,42 @@ import { __ as __5, sprintf } from "@wordpress/i18n";
|
|
|
1186
1186
|
import * as React24 from "react";
|
|
1187
1187
|
import { createContext as createContext6, useState as useState6 } from "react";
|
|
1188
1188
|
import { usePopupState as usePopupState3 } from "@elementor/ui";
|
|
1189
|
+
|
|
1190
|
+
// src/services/event-bus.ts
|
|
1191
|
+
var EventBus = class {
|
|
1192
|
+
listeners = /* @__PURE__ */ new Map();
|
|
1193
|
+
subscribe(eventName, callback) {
|
|
1194
|
+
if (!this.listeners.has(eventName)) {
|
|
1195
|
+
this.listeners.set(eventName, /* @__PURE__ */ new Set());
|
|
1196
|
+
}
|
|
1197
|
+
const eventListeners = this.listeners.get(eventName);
|
|
1198
|
+
if (eventListeners) {
|
|
1199
|
+
eventListeners.add(callback);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
unsubscribe(eventName, callback) {
|
|
1203
|
+
const eventListeners = this.listeners.get(eventName);
|
|
1204
|
+
if (!eventListeners) {
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
eventListeners.delete(callback);
|
|
1208
|
+
if (eventListeners.size === 0) {
|
|
1209
|
+
this.listeners.delete(eventName);
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
emit(eventName, data) {
|
|
1213
|
+
const eventListeners = this.listeners.get(eventName);
|
|
1214
|
+
if (eventListeners) {
|
|
1215
|
+
eventListeners.forEach((callback) => callback(data));
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
clearAll() {
|
|
1219
|
+
this.listeners.clear();
|
|
1220
|
+
}
|
|
1221
|
+
};
|
|
1222
|
+
var eventBus = new EventBus();
|
|
1223
|
+
|
|
1224
|
+
// src/components/unstable-repeater/context/repeater-context.tsx
|
|
1189
1225
|
var RepeaterContext = createContext6(null);
|
|
1190
1226
|
var EMPTY_OPEN_ITEM = -1;
|
|
1191
1227
|
var useRepeaterContext = () => {
|
|
@@ -1234,9 +1270,16 @@ var RepeaterContextProvider = ({
|
|
|
1234
1270
|
setItems(newItems);
|
|
1235
1271
|
setOpenItemIndex(newIndex);
|
|
1236
1272
|
popoverState.open(rowRef ?? ev);
|
|
1273
|
+
eventBus.emit(`${propTypeUtil.key}-item-added`, {
|
|
1274
|
+
itemValue: initial.value
|
|
1275
|
+
});
|
|
1237
1276
|
};
|
|
1238
1277
|
const removeItem = (index) => {
|
|
1278
|
+
const itemToRemove = items2[index];
|
|
1239
1279
|
setItems(items2.filter((_, pos) => pos !== index));
|
|
1280
|
+
eventBus.emit(`${propTypeUtil.key}-item-removed`, {
|
|
1281
|
+
itemValue: itemToRemove?.value
|
|
1282
|
+
});
|
|
1240
1283
|
};
|
|
1241
1284
|
const updateItem = (updatedItem, index) => {
|
|
1242
1285
|
const newItems = [...items2.slice(0, index), updatedItem, ...items2.slice(index + 1)];
|
|
@@ -5068,6 +5111,29 @@ var transitionsItemsList = transitionProperties.map((category) => ({
|
|
|
5068
5111
|
items: category.properties.map((property) => property.label)
|
|
5069
5112
|
}));
|
|
5070
5113
|
|
|
5114
|
+
// src/controls/transition-control/trainsition-events.ts
|
|
5115
|
+
import { getSelectedElements } from "@elementor/editor-elements";
|
|
5116
|
+
import { sendMixpanelEvent } from "@elementor/utils";
|
|
5117
|
+
var transitionRepeaterMixpanelEvent = {
|
|
5118
|
+
eventName: "click_added_transition",
|
|
5119
|
+
location: "V4 Style Tab",
|
|
5120
|
+
secondaryLocation: "Transition control",
|
|
5121
|
+
trigger: "click"
|
|
5122
|
+
};
|
|
5123
|
+
function subscribeToTransitionEvent() {
|
|
5124
|
+
eventBus.subscribe("transition-item-added", (data) => {
|
|
5125
|
+
const payload = data;
|
|
5126
|
+
const value = payload?.itemValue?.selection?.value?.value?.value;
|
|
5127
|
+
const selectedElements = getSelectedElements();
|
|
5128
|
+
const widgetType = selectedElements[0]?.type ?? null;
|
|
5129
|
+
sendMixpanelEvent({
|
|
5130
|
+
transition_type: value ?? "unknown",
|
|
5131
|
+
...transitionRepeaterMixpanelEvent,
|
|
5132
|
+
widget_type: widgetType
|
|
5133
|
+
});
|
|
5134
|
+
});
|
|
5135
|
+
}
|
|
5136
|
+
|
|
5071
5137
|
// src/controls/transition-control/transition-selector.tsx
|
|
5072
5138
|
import * as React89 from "react";
|
|
5073
5139
|
import { useRef as useRef23 } from "react";
|
|
@@ -5225,6 +5291,7 @@ var disableAddItemTooltipContent = /* @__PURE__ */ React90.createElement(
|
|
|
5225
5291
|
/* @__PURE__ */ React90.createElement(AlertTitle2, null, __47("Transitions", "elementor")),
|
|
5226
5292
|
/* @__PURE__ */ React90.createElement(Box18, { component: "span" }, /* @__PURE__ */ React90.createElement(Typography6, { variant: "body2" }, __47("Switch to 'Normal' state to add a transition.", "elementor")))
|
|
5227
5293
|
);
|
|
5294
|
+
subscribeToTransitionEvent();
|
|
5228
5295
|
var TransitionRepeaterControl = createControl(
|
|
5229
5296
|
({
|
|
5230
5297
|
recentlyUsedListGetter,
|
|
@@ -5272,8 +5339,15 @@ var EditorWrapper = styled9(Box19)`
|
|
|
5272
5339
|
position: relative;
|
|
5273
5340
|
height: 200px;
|
|
5274
5341
|
|
|
5275
|
-
.monaco-editor .
|
|
5276
|
-
|
|
5342
|
+
.monaco-editor .suggest-widget {
|
|
5343
|
+
width: 220px !important;
|
|
5344
|
+
max-width: 220px !important;
|
|
5345
|
+
}
|
|
5346
|
+
|
|
5347
|
+
.visual-content-dimmed {
|
|
5348
|
+
opacity: 0.6;
|
|
5349
|
+
color: #aaa !important;
|
|
5350
|
+
pointer-events: none;
|
|
5277
5351
|
}
|
|
5278
5352
|
`;
|
|
5279
5353
|
var ResizeHandle = styled9(Button5)`
|
|
@@ -5364,6 +5438,16 @@ function validate(editor, monaco) {
|
|
|
5364
5438
|
const allMarkers = monaco.editor.getModelMarkers({ resource: model.uri });
|
|
5365
5439
|
return allMarkers.filter((marker) => marker.severity === monaco.MarkerSeverity.Error).length === 0;
|
|
5366
5440
|
}
|
|
5441
|
+
function clearMarkersFromVisualContent(editor, monaco) {
|
|
5442
|
+
const model = editor.getModel();
|
|
5443
|
+
if (!model) {
|
|
5444
|
+
return;
|
|
5445
|
+
}
|
|
5446
|
+
const allMarkers = monaco.editor.getModelMarkers({ resource: model.uri });
|
|
5447
|
+
const filteredMarkers = allMarkers.filter((marker) => marker.startLineNumber !== 1);
|
|
5448
|
+
const nonCustomMarkers = filteredMarkers.filter((m) => m.source !== "custom-css-rules");
|
|
5449
|
+
monaco.editor.setModelMarkers(model, "css", nonCustomMarkers);
|
|
5450
|
+
}
|
|
5367
5451
|
|
|
5368
5452
|
// src/components/css-code-editor/resize-handle.tsx
|
|
5369
5453
|
import * as React91 from "react";
|
|
@@ -5410,6 +5494,60 @@ var ResizeHandleComponent = ({ onResize, containerRef, onHeightChange }) => {
|
|
|
5410
5494
|
);
|
|
5411
5495
|
};
|
|
5412
5496
|
|
|
5497
|
+
// src/components/css-code-editor/visual-content-change-protection.ts
|
|
5498
|
+
var preventChangeOnVisualContent = (editor) => {
|
|
5499
|
+
const model = editor.getModel();
|
|
5500
|
+
if (!model) {
|
|
5501
|
+
return;
|
|
5502
|
+
}
|
|
5503
|
+
const decorationsCollection = editor.createDecorationsCollection();
|
|
5504
|
+
const applyVisualContentStyling = () => {
|
|
5505
|
+
const totalLines = model.getLineCount();
|
|
5506
|
+
const decorations = [];
|
|
5507
|
+
decorations.push({
|
|
5508
|
+
range: {
|
|
5509
|
+
startLineNumber: 1,
|
|
5510
|
+
startColumn: 1,
|
|
5511
|
+
endLineNumber: 1,
|
|
5512
|
+
endColumn: model.getLineContent(1).length + 1
|
|
5513
|
+
},
|
|
5514
|
+
options: {
|
|
5515
|
+
inlineClassName: "visual-content-dimmed",
|
|
5516
|
+
isWholeLine: false
|
|
5517
|
+
}
|
|
5518
|
+
});
|
|
5519
|
+
if (totalLines > 1) {
|
|
5520
|
+
decorations.push({
|
|
5521
|
+
range: {
|
|
5522
|
+
startLineNumber: totalLines,
|
|
5523
|
+
startColumn: 1,
|
|
5524
|
+
endLineNumber: totalLines,
|
|
5525
|
+
endColumn: model.getLineContent(totalLines).length + 1
|
|
5526
|
+
},
|
|
5527
|
+
options: {
|
|
5528
|
+
inlineClassName: "visual-content-dimmed",
|
|
5529
|
+
isWholeLine: false
|
|
5530
|
+
}
|
|
5531
|
+
});
|
|
5532
|
+
}
|
|
5533
|
+
decorationsCollection.set(decorations);
|
|
5534
|
+
};
|
|
5535
|
+
applyVisualContentStyling();
|
|
5536
|
+
model.onDidChangeContent(() => {
|
|
5537
|
+
applyVisualContentStyling();
|
|
5538
|
+
});
|
|
5539
|
+
const originalPushEditOperations = model.pushEditOperations;
|
|
5540
|
+
model.pushEditOperations = function(beforeCursorState, editOperations, cursorStateComputer) {
|
|
5541
|
+
const totalLines = model.getLineCount();
|
|
5542
|
+
const filteredOperations = editOperations.filter((operation) => {
|
|
5543
|
+
const range = operation.range;
|
|
5544
|
+
const affectsProtectedLine = range.startLineNumber === 1 || range.endLineNumber === 1 || range.startLineNumber === totalLines || range.endLineNumber === totalLines;
|
|
5545
|
+
return !affectsProtectedLine;
|
|
5546
|
+
});
|
|
5547
|
+
return originalPushEditOperations.call(this, beforeCursorState, filteredOperations, cursorStateComputer);
|
|
5548
|
+
};
|
|
5549
|
+
};
|
|
5550
|
+
|
|
5413
5551
|
// src/components/css-code-editor/css-editor.tsx
|
|
5414
5552
|
var setVisualContent = (value) => {
|
|
5415
5553
|
const trimmed = value.trim();
|
|
@@ -5423,63 +5561,16 @@ var getActual = (value) => {
|
|
|
5423
5561
|
}
|
|
5424
5562
|
return lines.slice(1, -1).map((line) => line.replace(/^ {2}/, "")).join("\n");
|
|
5425
5563
|
};
|
|
5426
|
-
var
|
|
5427
|
-
const model = editor.getModel();
|
|
5428
|
-
if (!model) {
|
|
5429
|
-
return;
|
|
5430
|
-
}
|
|
5431
|
-
editor.onKeyDown((e) => {
|
|
5432
|
-
const position = editor.getPosition();
|
|
5433
|
-
if (!position) {
|
|
5434
|
-
return;
|
|
5435
|
-
}
|
|
5436
|
-
const totalLines = model.getLineCount();
|
|
5437
|
-
const isInProtectedRange = position.lineNumber === 1 || position.lineNumber === totalLines;
|
|
5438
|
-
if (isInProtectedRange) {
|
|
5439
|
-
const allowedKeys = [
|
|
5440
|
-
monaco.KeyCode.UpArrow,
|
|
5441
|
-
monaco.KeyCode.DownArrow,
|
|
5442
|
-
monaco.KeyCode.LeftArrow,
|
|
5443
|
-
monaco.KeyCode.RightArrow,
|
|
5444
|
-
monaco.KeyCode.Home,
|
|
5445
|
-
monaco.KeyCode.End,
|
|
5446
|
-
monaco.KeyCode.PageUp,
|
|
5447
|
-
monaco.KeyCode.PageDown,
|
|
5448
|
-
monaco.KeyCode.Tab,
|
|
5449
|
-
monaco.KeyCode.Escape
|
|
5450
|
-
];
|
|
5451
|
-
if (!allowedKeys.includes(e.keyCode)) {
|
|
5452
|
-
e.preventDefault();
|
|
5453
|
-
e.stopPropagation();
|
|
5454
|
-
}
|
|
5455
|
-
}
|
|
5456
|
-
});
|
|
5457
|
-
};
|
|
5458
|
-
var createEditorDidMountHandler = (editorRef, monacoRef, debounceTimer, onChange) => {
|
|
5564
|
+
var createEditorDidMountHandler = (editorRef, monacoRef) => {
|
|
5459
5565
|
return (editor, monaco) => {
|
|
5460
5566
|
editorRef.current = editor;
|
|
5461
5567
|
monacoRef.current = monaco;
|
|
5462
|
-
preventChangeOnVisualContent(editor
|
|
5568
|
+
preventChangeOnVisualContent(editor);
|
|
5463
5569
|
setCustomSyntaxRules(editor, monaco);
|
|
5464
|
-
editor.
|
|
5465
|
-
|
|
5466
|
-
const userContent = getActual(code);
|
|
5467
|
-
setCustomSyntaxRules(editor, monaco);
|
|
5468
|
-
const currentTimer = debounceTimer.current;
|
|
5469
|
-
if (currentTimer) {
|
|
5470
|
-
clearTimeout(currentTimer);
|
|
5471
|
-
}
|
|
5472
|
-
const newTimer = setTimeout(() => {
|
|
5473
|
-
if (!editorRef.current || !monacoRef.current) {
|
|
5474
|
-
return;
|
|
5475
|
-
}
|
|
5476
|
-
const hasNoErrors = validate(editorRef.current, monacoRef.current);
|
|
5477
|
-
if (hasNoErrors) {
|
|
5478
|
-
onChange(userContent);
|
|
5479
|
-
}
|
|
5480
|
-
}, 500);
|
|
5481
|
-
debounceTimer.current = newTimer;
|
|
5570
|
+
monaco.editor.onDidChangeMarkers(() => {
|
|
5571
|
+
setTimeout(() => clearMarkersFromVisualContent(editor, monaco), 0);
|
|
5482
5572
|
});
|
|
5573
|
+
editor.setPosition({ lineNumber: 2, column: (editor.getModel()?.getLineContent(2).length ?? 0) + 1 });
|
|
5483
5574
|
};
|
|
5484
5575
|
};
|
|
5485
5576
|
var CssEditor = ({ value, onChange }) => {
|
|
@@ -5497,7 +5588,27 @@ var CssEditor = ({ value, onChange }) => {
|
|
|
5497
5588
|
containerRef.current.style.height = `${height}px`;
|
|
5498
5589
|
}
|
|
5499
5590
|
}, []);
|
|
5500
|
-
const
|
|
5591
|
+
const handleEditorChange = () => {
|
|
5592
|
+
if (!editorRef.current || !monacoRef.current) {
|
|
5593
|
+
return;
|
|
5594
|
+
}
|
|
5595
|
+
const code = editorRef.current?.getModel()?.getValue() ?? "";
|
|
5596
|
+
const userContent = getActual(code);
|
|
5597
|
+
setCustomSyntaxRules(editorRef?.current, monacoRef.current);
|
|
5598
|
+
const currentTimer = debounceTimer.current;
|
|
5599
|
+
if (currentTimer) {
|
|
5600
|
+
clearTimeout(currentTimer);
|
|
5601
|
+
}
|
|
5602
|
+
const newTimer = setTimeout(() => {
|
|
5603
|
+
if (!editorRef.current || !monacoRef.current) {
|
|
5604
|
+
return;
|
|
5605
|
+
}
|
|
5606
|
+
const hasNoErrors = validate(editorRef.current, monacoRef.current);
|
|
5607
|
+
onChange(userContent, hasNoErrors);
|
|
5608
|
+
}, 500);
|
|
5609
|
+
debounceTimer.current = newTimer;
|
|
5610
|
+
};
|
|
5611
|
+
const handleEditorDidMount = createEditorDidMountHandler(editorRef, monacoRef);
|
|
5501
5612
|
React92.useEffect(() => {
|
|
5502
5613
|
const timerRef = debounceTimer;
|
|
5503
5614
|
return () => {
|
|
@@ -5514,18 +5625,24 @@ var CssEditor = ({ value, onChange }) => {
|
|
|
5514
5625
|
height: "100%",
|
|
5515
5626
|
language: "css",
|
|
5516
5627
|
theme: theme.palette.mode === "dark" ? "vs-dark" : "vs",
|
|
5517
|
-
|
|
5628
|
+
value: setVisualContent(value),
|
|
5518
5629
|
onMount: handleEditorDidMount,
|
|
5630
|
+
onChange: handleEditorChange,
|
|
5519
5631
|
options: {
|
|
5520
|
-
lineNumbers: "
|
|
5521
|
-
folding:
|
|
5522
|
-
showFoldingControls: "never",
|
|
5632
|
+
lineNumbers: "on",
|
|
5633
|
+
folding: true,
|
|
5523
5634
|
minimap: { enabled: false },
|
|
5524
5635
|
fontFamily: "Roboto, Arial, Helvetica, Verdana, sans-serif",
|
|
5525
5636
|
fontSize: 12,
|
|
5526
5637
|
renderLineHighlight: "none",
|
|
5527
5638
|
hideCursorInOverviewRuler: true,
|
|
5528
|
-
fixedOverflowWidgets: true
|
|
5639
|
+
fixedOverflowWidgets: true,
|
|
5640
|
+
suggestFontSize: 10,
|
|
5641
|
+
suggestLineHeight: 14,
|
|
5642
|
+
stickyScroll: {
|
|
5643
|
+
enabled: false
|
|
5644
|
+
},
|
|
5645
|
+
lineDecorationsWidth: 2
|
|
5529
5646
|
}
|
|
5530
5647
|
}
|
|
5531
5648
|
), /* @__PURE__ */ React92.createElement(
|