@elementor/editor-editing-panel 4.4.0-1067 → 4.4.0-1069

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-editing-panel",
3
- "version": "4.4.0-1067",
3
+ "version": "4.4.0-1069",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -39,31 +39,31 @@
39
39
  "dev": "tsup --config=../../tsup.dev.ts"
40
40
  },
41
41
  "dependencies": {
42
- "@elementor/editor": "4.4.0-1067",
43
- "@elementor/editor-canvas": "4.4.0-1067",
44
- "@elementor/editor-controls": "4.4.0-1067",
45
- "@elementor/editor-documents": "4.4.0-1067",
46
- "@elementor/editor-elements": "4.4.0-1067",
47
- "@elementor/editor-interactions": "4.4.0-1067",
48
- "@elementor/editor-notifications": "4.4.0-1067",
49
- "@elementor/editor-panels": "4.4.0-1067",
50
- "@elementor/editor-props": "4.4.0-1067",
51
- "@elementor/editor-responsive": "4.4.0-1067",
52
- "@elementor/editor-styles": "4.4.0-1067",
53
- "@elementor/editor-styles-repository": "4.4.0-1067",
54
- "@elementor/editor-ui": "4.4.0-1067",
55
- "@elementor/editor-v1-adapters": "4.4.0-1067",
56
- "@elementor/http-client": "4.4.0-1067",
42
+ "@elementor/editor": "4.4.0-1069",
43
+ "@elementor/editor-canvas": "4.4.0-1069",
44
+ "@elementor/editor-controls": "4.4.0-1069",
45
+ "@elementor/editor-documents": "4.4.0-1069",
46
+ "@elementor/editor-elements": "4.4.0-1069",
47
+ "@elementor/editor-interactions": "4.4.0-1069",
48
+ "@elementor/editor-notifications": "4.4.0-1069",
49
+ "@elementor/editor-panels": "4.4.0-1069",
50
+ "@elementor/editor-props": "4.4.0-1069",
51
+ "@elementor/editor-responsive": "4.4.0-1069",
52
+ "@elementor/editor-styles": "4.4.0-1069",
53
+ "@elementor/editor-styles-repository": "4.4.0-1069",
54
+ "@elementor/editor-ui": "4.4.0-1069",
55
+ "@elementor/editor-v1-adapters": "4.4.0-1069",
56
+ "@elementor/http-client": "4.4.0-1069",
57
57
  "@elementor/icons": "~1.75.1",
58
- "@elementor/editor-variables": "4.4.0-1067",
59
- "@elementor/locations": "4.4.0-1067",
60
- "@elementor/menus": "4.4.0-1067",
61
- "@elementor/query": "4.4.0-1067",
62
- "@elementor/schema": "4.4.0-1067",
63
- "@elementor/session": "4.4.0-1067",
58
+ "@elementor/editor-variables": "4.4.0-1069",
59
+ "@elementor/locations": "4.4.0-1069",
60
+ "@elementor/menus": "4.4.0-1069",
61
+ "@elementor/query": "4.4.0-1069",
62
+ "@elementor/schema": "4.4.0-1069",
63
+ "@elementor/session": "4.4.0-1069",
64
64
  "@elementor/ui": "1.37.5",
65
- "@elementor/utils": "4.4.0-1067",
66
- "@elementor/wp-media": "4.4.0-1067",
65
+ "@elementor/utils": "4.4.0-1069",
66
+ "@elementor/wp-media": "4.4.0-1069",
67
67
  "@wordpress/i18n": "^5.13.0"
68
68
  },
69
69
  "peerDependencies": {
@@ -1,12 +1,15 @@
1
1
  import { type ItemsActionPayload } from '@elementor/editor-controls';
2
2
  import {
3
+ type CreateElementParams,
3
4
  createElements,
4
5
  duplicateElements,
6
+ generateElementId,
5
7
  getContainer,
6
8
  moveElements,
7
9
  removeElements,
10
+ type V1ElementData,
8
11
  } from '@elementor/editor-elements';
9
- import { booleanPropTypeUtil } from '@elementor/editor-props';
12
+ import { booleanPropTypeUtil, escapedHtmlPropTypeUtil } from '@elementor/editor-props';
10
13
  import { __ } from '@wordpress/i18n';
11
14
 
12
15
  export type ListItem = {
@@ -15,10 +18,14 @@ export type ListItem = {
15
18
  };
16
19
 
17
20
  export const LIST_ITEM_ELEMENT_TYPE = 'e-list-item';
21
+ const LIST_ITEM_MARKER_ELEMENT_TYPE = 'e-list-item-marker';
22
+ const LIST_ITEM_CONTENT_ELEMENT_TYPE = 'e-list-item-content';
23
+ const PARAGRAPH_WIDGET_TYPE = 'e-paragraph';
24
+ const SVG_WIDGET_TYPE = 'e-svg';
18
25
 
19
26
  const TRAILING_NUMBER = /(\d+)\s*$/;
20
27
 
21
- const getItemTitle = ( position: number ) => `Item ${ position }`;
28
+ const getItemTitle = ( position: number ) => `List item ${ position }`;
22
29
 
23
30
  const getNextItemNumber = ( existingTitles: ( string | undefined )[] ) => {
24
31
  const taken = new Set( existingTitles.filter( ( title ): title is string => Boolean( title ) ) );
@@ -39,6 +46,57 @@ const getNextItemNumber = ( existingTitles: ( string | undefined )[] ) => {
39
46
  return next;
40
47
  };
41
48
 
49
+ const buildItemModel = ( position: number, showMarkers: boolean ): V1ElementData => {
50
+ const itemTitle = getItemTitle( position );
51
+
52
+ return {
53
+ elType: LIST_ITEM_ELEMENT_TYPE,
54
+ id: generateElementId(),
55
+ settings: {
56
+ show_markers: booleanPropTypeUtil.create( showMarkers ),
57
+ },
58
+ editor_settings: {
59
+ title: itemTitle,
60
+ initial_position: position,
61
+ },
62
+ elements: [
63
+ {
64
+ elType: LIST_ITEM_MARKER_ELEMENT_TYPE,
65
+ id: generateElementId(),
66
+ editor_settings: {
67
+ title: __( 'Marker', 'elementor' ),
68
+ },
69
+ elements: [
70
+ {
71
+ elType: 'widget',
72
+ widgetType: SVG_WIDGET_TYPE,
73
+ id: generateElementId(),
74
+ elements: [],
75
+ },
76
+ ],
77
+ },
78
+ {
79
+ elType: LIST_ITEM_CONTENT_ELEMENT_TYPE,
80
+ id: generateElementId(),
81
+ editor_settings: {
82
+ title: __( 'Content', 'elementor' ),
83
+ },
84
+ elements: [
85
+ {
86
+ elType: 'widget',
87
+ widgetType: PARAGRAPH_WIDGET_TYPE,
88
+ id: generateElementId(),
89
+ elements: [],
90
+ settings: {
91
+ paragraph: escapedHtmlPropTypeUtil.create( itemTitle ),
92
+ },
93
+ },
94
+ ],
95
+ },
96
+ ],
97
+ };
98
+ };
99
+
42
100
  export const duplicateItem = ( { items }: { items: ItemsActionPayload< ListItem > } ) => {
43
101
  duplicateElements( {
44
102
  elementIds: items.map( ( { item } ) => item.id ),
@@ -108,17 +166,7 @@ export const addItem = ( {
108
166
  elements: [
109
167
  {
110
168
  container: listContainer,
111
- model: {
112
- elType: LIST_ITEM_ELEMENT_TYPE,
113
- settings: {
114
- show_markers: booleanPropTypeUtil.create( showMarkers ),
115
- },
116
- hydrateDefaultChildren: true,
117
- editor_settings: {
118
- title: getItemTitle( position ),
119
- initial_position: position,
120
- },
121
- },
169
+ model: buildItemModel( position, showMarkers ) as CreateElementParams[ 'model' ],
122
170
  options: { at: index },
123
171
  },
124
172
  ],
@@ -16,7 +16,7 @@ const getEffectiveListItemLabel = ( label: string | undefined, fallbackLabel: st
16
16
  };
17
17
 
18
18
  const getDefaultListItemLabel = ( index: number ) => {
19
- return `Item ${ index + 1 }`;
19
+ return `List item ${ index + 1 }`;
20
20
  };
21
21
 
22
22
  export const ListItemsControl = ( { label }: { label: string } ) => {
@@ -88,7 +88,7 @@ const ListItemsControlContent = ( { label }: { label: string } ) => {
88
88
  adornment={ () => null }
89
89
  itemSettings={ {
90
90
  getId: ( { item } ) => item.id,
91
- initialValues: { id: '', title: 'Item' },
91
+ initialValues: { id: '', title: 'List item' },
92
92
  Label: ItemLabel,
93
93
  Content: ItemContent,
94
94
  Icon: () => null,