@elementor/editor-controls 3.33.0-96 → 3.33.0-98
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 +156 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +156 -43
- 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 +21 -48
- 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.d.mts
CHANGED
|
@@ -317,7 +317,7 @@ declare const ControlFormLabel: (props: FormLabelProps) => React$1.JSX.Element;
|
|
|
317
317
|
|
|
318
318
|
type CssEditorProps = {
|
|
319
319
|
value: string;
|
|
320
|
-
onChange: (value: string) => void;
|
|
320
|
+
onChange: (value: string, isValid: boolean) => void;
|
|
321
321
|
};
|
|
322
322
|
declare const CssEditor: ({ value, onChange }: CssEditorProps) => React$1.JSX.Element;
|
|
323
323
|
|
package/dist/index.d.ts
CHANGED
|
@@ -317,7 +317,7 @@ declare const ControlFormLabel: (props: FormLabelProps) => React$1.JSX.Element;
|
|
|
317
317
|
|
|
318
318
|
type CssEditorProps = {
|
|
319
319
|
value: string;
|
|
320
|
-
onChange: (value: string) => void;
|
|
320
|
+
onChange: (value: string, isValid: boolean) => void;
|
|
321
321
|
};
|
|
322
322
|
declare const CssEditor: ({ value, onChange }: CssEditorProps) => React$1.JSX.Element;
|
|
323
323
|
|
package/dist/index.js
CHANGED
|
@@ -1264,6 +1264,42 @@ var import_i18n5 = require("@wordpress/i18n");
|
|
|
1264
1264
|
var React24 = __toESM(require("react"));
|
|
1265
1265
|
var import_react16 = require("react");
|
|
1266
1266
|
var import_ui19 = require("@elementor/ui");
|
|
1267
|
+
|
|
1268
|
+
// src/services/event-bus.ts
|
|
1269
|
+
var EventBus = class {
|
|
1270
|
+
listeners = /* @__PURE__ */ new Map();
|
|
1271
|
+
subscribe(eventName, callback) {
|
|
1272
|
+
if (!this.listeners.has(eventName)) {
|
|
1273
|
+
this.listeners.set(eventName, /* @__PURE__ */ new Set());
|
|
1274
|
+
}
|
|
1275
|
+
const eventListeners = this.listeners.get(eventName);
|
|
1276
|
+
if (eventListeners) {
|
|
1277
|
+
eventListeners.add(callback);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
unsubscribe(eventName, callback) {
|
|
1281
|
+
const eventListeners = this.listeners.get(eventName);
|
|
1282
|
+
if (!eventListeners) {
|
|
1283
|
+
return;
|
|
1284
|
+
}
|
|
1285
|
+
eventListeners.delete(callback);
|
|
1286
|
+
if (eventListeners.size === 0) {
|
|
1287
|
+
this.listeners.delete(eventName);
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
emit(eventName, data) {
|
|
1291
|
+
const eventListeners = this.listeners.get(eventName);
|
|
1292
|
+
if (eventListeners) {
|
|
1293
|
+
eventListeners.forEach((callback) => callback(data));
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
clearAll() {
|
|
1297
|
+
this.listeners.clear();
|
|
1298
|
+
}
|
|
1299
|
+
};
|
|
1300
|
+
var eventBus = new EventBus();
|
|
1301
|
+
|
|
1302
|
+
// src/components/unstable-repeater/context/repeater-context.tsx
|
|
1267
1303
|
var RepeaterContext = (0, import_react16.createContext)(null);
|
|
1268
1304
|
var EMPTY_OPEN_ITEM = -1;
|
|
1269
1305
|
var useRepeaterContext = () => {
|
|
@@ -1312,9 +1348,16 @@ var RepeaterContextProvider = ({
|
|
|
1312
1348
|
setItems(newItems);
|
|
1313
1349
|
setOpenItemIndex(newIndex);
|
|
1314
1350
|
popoverState.open(rowRef ?? ev);
|
|
1351
|
+
eventBus.emit(`${propTypeUtil.key}-item-added`, {
|
|
1352
|
+
itemValue: initial.value
|
|
1353
|
+
});
|
|
1315
1354
|
};
|
|
1316
1355
|
const removeItem = (index) => {
|
|
1356
|
+
const itemToRemove = items2[index];
|
|
1317
1357
|
setItems(items2.filter((_, pos) => pos !== index));
|
|
1358
|
+
eventBus.emit(`${propTypeUtil.key}-item-removed`, {
|
|
1359
|
+
itemValue: itemToRemove?.value
|
|
1360
|
+
});
|
|
1318
1361
|
};
|
|
1319
1362
|
const updateItem = (updatedItem, index) => {
|
|
1320
1363
|
const newItems = [...items2.slice(0, index), updatedItem, ...items2.slice(index + 1)];
|
|
@@ -5062,6 +5105,29 @@ var transitionsItemsList = transitionProperties.map((category) => ({
|
|
|
5062
5105
|
items: category.properties.map((property) => property.label)
|
|
5063
5106
|
}));
|
|
5064
5107
|
|
|
5108
|
+
// src/controls/transition-control/trainsition-events.ts
|
|
5109
|
+
var import_editor_elements3 = require("@elementor/editor-elements");
|
|
5110
|
+
var import_utils5 = require("@elementor/utils");
|
|
5111
|
+
var transitionRepeaterMixpanelEvent = {
|
|
5112
|
+
eventName: "click_added_transition",
|
|
5113
|
+
location: "V4 Style Tab",
|
|
5114
|
+
secondaryLocation: "Transition control",
|
|
5115
|
+
trigger: "click"
|
|
5116
|
+
};
|
|
5117
|
+
function subscribeToTransitionEvent() {
|
|
5118
|
+
eventBus.subscribe("transition-item-added", (data) => {
|
|
5119
|
+
const payload = data;
|
|
5120
|
+
const value = payload?.itemValue?.selection?.value?.value?.value;
|
|
5121
|
+
const selectedElements = (0, import_editor_elements3.getSelectedElements)();
|
|
5122
|
+
const widgetType = selectedElements[0]?.type ?? null;
|
|
5123
|
+
(0, import_utils5.sendMixpanelEvent)({
|
|
5124
|
+
transition_type: value ?? "unknown",
|
|
5125
|
+
...transitionRepeaterMixpanelEvent,
|
|
5126
|
+
widget_type: widgetType
|
|
5127
|
+
});
|
|
5128
|
+
});
|
|
5129
|
+
}
|
|
5130
|
+
|
|
5065
5131
|
// src/controls/transition-control/transition-selector.tsx
|
|
5066
5132
|
var React89 = __toESM(require("react"));
|
|
5067
5133
|
var import_react45 = require("react");
|
|
@@ -5219,6 +5285,7 @@ var disableAddItemTooltipContent = /* @__PURE__ */ React90.createElement(
|
|
|
5219
5285
|
/* @__PURE__ */ React90.createElement(import_ui78.AlertTitle, null, (0, import_i18n47.__)("Transitions", "elementor")),
|
|
5220
5286
|
/* @__PURE__ */ React90.createElement(import_ui78.Box, { component: "span" }, /* @__PURE__ */ React90.createElement(import_ui78.Typography, { variant: "body2" }, (0, import_i18n47.__)("Switch to 'Normal' state to add a transition.", "elementor")))
|
|
5221
5287
|
);
|
|
5288
|
+
subscribeToTransitionEvent();
|
|
5222
5289
|
var TransitionRepeaterControl = createControl(
|
|
5223
5290
|
({
|
|
5224
5291
|
recentlyUsedListGetter,
|
|
@@ -5266,8 +5333,15 @@ var EditorWrapper = (0, import_ui79.styled)(import_ui79.Box)`
|
|
|
5266
5333
|
position: relative;
|
|
5267
5334
|
height: 200px;
|
|
5268
5335
|
|
|
5269
|
-
.monaco-editor .
|
|
5270
|
-
|
|
5336
|
+
.monaco-editor .suggest-widget {
|
|
5337
|
+
width: 220px !important;
|
|
5338
|
+
max-width: 220px !important;
|
|
5339
|
+
}
|
|
5340
|
+
|
|
5341
|
+
.visual-content-dimmed {
|
|
5342
|
+
opacity: 0.6;
|
|
5343
|
+
color: #aaa !important;
|
|
5344
|
+
pointer-events: none;
|
|
5271
5345
|
}
|
|
5272
5346
|
`;
|
|
5273
5347
|
var ResizeHandle = (0, import_ui79.styled)(import_ui79.Button)`
|
|
@@ -5358,6 +5432,16 @@ function validate(editor, monaco) {
|
|
|
5358
5432
|
const allMarkers = monaco.editor.getModelMarkers({ resource: model.uri });
|
|
5359
5433
|
return allMarkers.filter((marker) => marker.severity === monaco.MarkerSeverity.Error).length === 0;
|
|
5360
5434
|
}
|
|
5435
|
+
function clearMarkersFromVisualContent(editor, monaco) {
|
|
5436
|
+
const model = editor.getModel();
|
|
5437
|
+
if (!model) {
|
|
5438
|
+
return;
|
|
5439
|
+
}
|
|
5440
|
+
const allMarkers = monaco.editor.getModelMarkers({ resource: model.uri });
|
|
5441
|
+
const filteredMarkers = allMarkers.filter((marker) => marker.startLineNumber !== 1);
|
|
5442
|
+
const nonCustomMarkers = filteredMarkers.filter((m) => m.source !== "custom-css-rules");
|
|
5443
|
+
monaco.editor.setModelMarkers(model, "css", nonCustomMarkers);
|
|
5444
|
+
}
|
|
5361
5445
|
|
|
5362
5446
|
// src/components/css-code-editor/resize-handle.tsx
|
|
5363
5447
|
var React91 = __toESM(require("react"));
|
|
@@ -5404,6 +5488,60 @@ var ResizeHandleComponent = ({ onResize, containerRef, onHeightChange }) => {
|
|
|
5404
5488
|
);
|
|
5405
5489
|
};
|
|
5406
5490
|
|
|
5491
|
+
// src/components/css-code-editor/visual-content-change-protection.ts
|
|
5492
|
+
var preventChangeOnVisualContent = (editor) => {
|
|
5493
|
+
const model = editor.getModel();
|
|
5494
|
+
if (!model) {
|
|
5495
|
+
return;
|
|
5496
|
+
}
|
|
5497
|
+
const decorationsCollection = editor.createDecorationsCollection();
|
|
5498
|
+
const applyVisualContentStyling = () => {
|
|
5499
|
+
const totalLines = model.getLineCount();
|
|
5500
|
+
const decorations = [];
|
|
5501
|
+
decorations.push({
|
|
5502
|
+
range: {
|
|
5503
|
+
startLineNumber: 1,
|
|
5504
|
+
startColumn: 1,
|
|
5505
|
+
endLineNumber: 1,
|
|
5506
|
+
endColumn: model.getLineContent(1).length + 1
|
|
5507
|
+
},
|
|
5508
|
+
options: {
|
|
5509
|
+
inlineClassName: "visual-content-dimmed",
|
|
5510
|
+
isWholeLine: false
|
|
5511
|
+
}
|
|
5512
|
+
});
|
|
5513
|
+
if (totalLines > 1) {
|
|
5514
|
+
decorations.push({
|
|
5515
|
+
range: {
|
|
5516
|
+
startLineNumber: totalLines,
|
|
5517
|
+
startColumn: 1,
|
|
5518
|
+
endLineNumber: totalLines,
|
|
5519
|
+
endColumn: model.getLineContent(totalLines).length + 1
|
|
5520
|
+
},
|
|
5521
|
+
options: {
|
|
5522
|
+
inlineClassName: "visual-content-dimmed",
|
|
5523
|
+
isWholeLine: false
|
|
5524
|
+
}
|
|
5525
|
+
});
|
|
5526
|
+
}
|
|
5527
|
+
decorationsCollection.set(decorations);
|
|
5528
|
+
};
|
|
5529
|
+
applyVisualContentStyling();
|
|
5530
|
+
model.onDidChangeContent(() => {
|
|
5531
|
+
applyVisualContentStyling();
|
|
5532
|
+
});
|
|
5533
|
+
const originalPushEditOperations = model.pushEditOperations;
|
|
5534
|
+
model.pushEditOperations = function(beforeCursorState, editOperations, cursorStateComputer) {
|
|
5535
|
+
const totalLines = model.getLineCount();
|
|
5536
|
+
const filteredOperations = editOperations.filter((operation) => {
|
|
5537
|
+
const range = operation.range;
|
|
5538
|
+
const affectsProtectedLine = range.startLineNumber === 1 || range.endLineNumber === 1 || range.startLineNumber === totalLines || range.endLineNumber === totalLines;
|
|
5539
|
+
return !affectsProtectedLine;
|
|
5540
|
+
});
|
|
5541
|
+
return originalPushEditOperations.call(this, beforeCursorState, filteredOperations, cursorStateComputer);
|
|
5542
|
+
};
|
|
5543
|
+
};
|
|
5544
|
+
|
|
5407
5545
|
// src/components/css-code-editor/css-editor.tsx
|
|
5408
5546
|
var setVisualContent = (value) => {
|
|
5409
5547
|
const trimmed = value.trim();
|
|
@@ -5417,44 +5555,16 @@ var getActual = (value) => {
|
|
|
5417
5555
|
}
|
|
5418
5556
|
return lines.slice(1, -1).map((line) => line.replace(/^ {2}/, "")).join("\n");
|
|
5419
5557
|
};
|
|
5420
|
-
var preventChangeOnVisualContent = (editor, monaco) => {
|
|
5421
|
-
const model = editor.getModel();
|
|
5422
|
-
if (!model) {
|
|
5423
|
-
return;
|
|
5424
|
-
}
|
|
5425
|
-
editor.onKeyDown((e) => {
|
|
5426
|
-
const position = editor.getPosition();
|
|
5427
|
-
if (!position) {
|
|
5428
|
-
return;
|
|
5429
|
-
}
|
|
5430
|
-
const totalLines = model.getLineCount();
|
|
5431
|
-
const isInProtectedRange = position.lineNumber === 1 || position.lineNumber === totalLines;
|
|
5432
|
-
if (isInProtectedRange) {
|
|
5433
|
-
const allowedKeys = [
|
|
5434
|
-
monaco.KeyCode.UpArrow,
|
|
5435
|
-
monaco.KeyCode.DownArrow,
|
|
5436
|
-
monaco.KeyCode.LeftArrow,
|
|
5437
|
-
monaco.KeyCode.RightArrow,
|
|
5438
|
-
monaco.KeyCode.Home,
|
|
5439
|
-
monaco.KeyCode.End,
|
|
5440
|
-
monaco.KeyCode.PageUp,
|
|
5441
|
-
monaco.KeyCode.PageDown,
|
|
5442
|
-
monaco.KeyCode.Tab,
|
|
5443
|
-
monaco.KeyCode.Escape
|
|
5444
|
-
];
|
|
5445
|
-
if (!allowedKeys.includes(e.keyCode)) {
|
|
5446
|
-
e.preventDefault();
|
|
5447
|
-
e.stopPropagation();
|
|
5448
|
-
}
|
|
5449
|
-
}
|
|
5450
|
-
});
|
|
5451
|
-
};
|
|
5452
5558
|
var createEditorDidMountHandler = (editorRef, monacoRef, debounceTimer, onChange) => {
|
|
5453
5559
|
return (editor, monaco) => {
|
|
5454
5560
|
editorRef.current = editor;
|
|
5455
5561
|
monacoRef.current = monaco;
|
|
5456
|
-
preventChangeOnVisualContent(editor
|
|
5562
|
+
preventChangeOnVisualContent(editor);
|
|
5457
5563
|
setCustomSyntaxRules(editor, monaco);
|
|
5564
|
+
monaco.editor.onDidChangeMarkers(() => {
|
|
5565
|
+
setTimeout(() => clearMarkersFromVisualContent(editor, monaco), 0);
|
|
5566
|
+
});
|
|
5567
|
+
editor.setPosition({ lineNumber: 2, column: (editor.getModel()?.getLineContent(2).length ?? 0) + 1 });
|
|
5458
5568
|
editor.onDidChangeModelContent(() => {
|
|
5459
5569
|
const code = editor.getModel()?.getValue() ?? "";
|
|
5460
5570
|
const userContent = getActual(code);
|
|
@@ -5468,9 +5578,7 @@ var createEditorDidMountHandler = (editorRef, monacoRef, debounceTimer, onChange
|
|
|
5468
5578
|
return;
|
|
5469
5579
|
}
|
|
5470
5580
|
const hasNoErrors = validate(editorRef.current, monacoRef.current);
|
|
5471
|
-
|
|
5472
|
-
onChange(userContent);
|
|
5473
|
-
}
|
|
5581
|
+
onChange(userContent, hasNoErrors);
|
|
5474
5582
|
}, 500);
|
|
5475
5583
|
debounceTimer.current = newTimer;
|
|
5476
5584
|
});
|
|
@@ -5508,18 +5616,23 @@ var CssEditor = ({ value, onChange }) => {
|
|
|
5508
5616
|
height: "100%",
|
|
5509
5617
|
language: "css",
|
|
5510
5618
|
theme: theme.palette.mode === "dark" ? "vs-dark" : "vs",
|
|
5511
|
-
|
|
5619
|
+
value: setVisualContent(value),
|
|
5512
5620
|
onMount: handleEditorDidMount,
|
|
5513
5621
|
options: {
|
|
5514
|
-
lineNumbers: "
|
|
5515
|
-
folding:
|
|
5516
|
-
showFoldingControls: "never",
|
|
5622
|
+
lineNumbers: "on",
|
|
5623
|
+
folding: true,
|
|
5517
5624
|
minimap: { enabled: false },
|
|
5518
5625
|
fontFamily: "Roboto, Arial, Helvetica, Verdana, sans-serif",
|
|
5519
5626
|
fontSize: 12,
|
|
5520
5627
|
renderLineHighlight: "none",
|
|
5521
5628
|
hideCursorInOverviewRuler: true,
|
|
5522
|
-
fixedOverflowWidgets: true
|
|
5629
|
+
fixedOverflowWidgets: true,
|
|
5630
|
+
suggestFontSize: 10,
|
|
5631
|
+
suggestLineHeight: 14,
|
|
5632
|
+
stickyScroll: {
|
|
5633
|
+
enabled: false
|
|
5634
|
+
},
|
|
5635
|
+
lineDecorationsWidth: 2
|
|
5523
5636
|
}
|
|
5524
5637
|
}
|
|
5525
5638
|
), /* @__PURE__ */ React92.createElement(
|