@elementor/editor-styles-repository 0.8.3 → 0.8.5
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +20 -0
- package/dist/index.d.mts +48 -18
- package/dist/index.d.ts +48 -18
- package/dist/index.js +144 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +143 -53
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -5
- package/src/__tests__/{elements-styles-provider.test.ts → document-elements-styles-provider.test.ts} +33 -21
- package/src/__tests__/element-base-styles-provider.test.ts +3 -3
- package/src/errors.ts +5 -0
- package/src/hooks/{use-create-actions-by-provider.ts → use-get-styles-repository-create-action.ts} +10 -3
- package/src/index.ts +11 -12
- package/src/init.ts +3 -3
- package/src/{elements-styles-provider.ts → providers/document-elements-styles-provider.ts} +29 -16
- package/src/{element-base-styles-provider.ts → providers/element-base-styles-provider.ts} +6 -10
- package/src/types.ts +33 -0
- package/src/utils/__tests__/create-styles-repository.test.ts +17 -93
- package/src/utils/__tests__/validate-style-label.test.ts +120 -0
- package/src/utils/create-styles-provider.ts +51 -0
- package/src/utils/create-styles-repository.ts +3 -58
- package/src/utils/is-elements-styles-provider.ts +5 -0
- package/src/utils/validate-style-label.ts +74 -0
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// src/utils/create-styles-repository.ts
|
|
2
|
-
var VALID_SELECTOR_REGEX = /^[a-zA-Z0-9_-]+$/;
|
|
3
2
|
var createStylesRepository = () => {
|
|
4
3
|
const providers = [];
|
|
5
4
|
const getProviders = () => {
|
|
@@ -9,7 +8,7 @@ var createStylesRepository = () => {
|
|
|
9
8
|
providers.push(provider);
|
|
10
9
|
};
|
|
11
10
|
const all = (meta = {}) => {
|
|
12
|
-
return getProviders().flatMap((provider) => provider.actions.
|
|
11
|
+
return getProviders().flatMap((provider) => provider.actions.all(meta));
|
|
13
12
|
};
|
|
14
13
|
const subscribe = (cb) => {
|
|
15
14
|
const unsubscribes = providers.map((provider) => {
|
|
@@ -20,28 +19,14 @@ var createStylesRepository = () => {
|
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
const getProviderByKey = (key) => {
|
|
23
|
-
return providers.find((provider) => provider.
|
|
22
|
+
return providers.find((provider) => provider.getKey() === key);
|
|
24
23
|
};
|
|
25
|
-
const isLabelExist = (newLabel) => {
|
|
26
|
-
const classes = all();
|
|
27
|
-
const reservedLabels = providers.map(({ reservedLabel }) => reservedLabel).filter(Boolean);
|
|
28
|
-
if (reservedLabels.includes(newLabel)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
if (!classes?.length) {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
return classes.some(({ label }) => label.toLowerCase() === newLabel.toLowerCase());
|
|
35
|
-
};
|
|
36
|
-
const isLabelValid = (newLabel) => VALID_SELECTOR_REGEX.test(newLabel);
|
|
37
24
|
return {
|
|
38
25
|
all,
|
|
39
26
|
register,
|
|
40
27
|
subscribe,
|
|
41
28
|
getProviders,
|
|
42
|
-
getProviderByKey
|
|
43
|
-
isLabelExist,
|
|
44
|
-
isLabelValid
|
|
29
|
+
getProviderByKey
|
|
45
30
|
};
|
|
46
31
|
};
|
|
47
32
|
|
|
@@ -56,21 +41,37 @@ function useProviders() {
|
|
|
56
41
|
return stylesRepository.getProviders();
|
|
57
42
|
}
|
|
58
43
|
|
|
59
|
-
// src/hooks/use-
|
|
44
|
+
// src/hooks/use-get-styles-repository-create-action.ts
|
|
60
45
|
import { useMemo } from "react";
|
|
61
|
-
function
|
|
46
|
+
function useGetStylesRepositoryCreateAction() {
|
|
62
47
|
return useMemo(() => {
|
|
63
|
-
|
|
48
|
+
const createActions = stylesRepository.getProviders().map((provider) => {
|
|
64
49
|
if (!provider.actions.create) {
|
|
65
50
|
return null;
|
|
66
51
|
}
|
|
67
52
|
return [provider, provider.actions.create];
|
|
68
53
|
}).filter((item) => !!item);
|
|
54
|
+
if (createActions.length === 1) {
|
|
55
|
+
return createActions[0];
|
|
56
|
+
} else if (createActions.length === 0) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
throw new Error("Multiple providers with create action found in styles repository.");
|
|
69
60
|
}, []);
|
|
70
61
|
}
|
|
71
62
|
|
|
72
|
-
// src/
|
|
73
|
-
import {
|
|
63
|
+
// src/utils/validate-style-label.ts
|
|
64
|
+
import { z } from "@elementor/schema";
|
|
65
|
+
import { __ } from "@wordpress/i18n";
|
|
66
|
+
|
|
67
|
+
// src/providers/document-elements-styles-provider.ts
|
|
68
|
+
import {
|
|
69
|
+
getCurrentDocumentId,
|
|
70
|
+
getElements,
|
|
71
|
+
getElementStyles,
|
|
72
|
+
styleRerenderEvents,
|
|
73
|
+
updateElementStyle
|
|
74
|
+
} from "@elementor/editor-elements";
|
|
74
75
|
import { __privateListenTo as listenTo } from "@elementor/editor-v1-adapters";
|
|
75
76
|
|
|
76
77
|
// src/errors.ts
|
|
@@ -79,22 +80,65 @@ var InvalidElementsStyleProviderMetaError = createError({
|
|
|
79
80
|
code: "invalid_elements_style_provider_meta",
|
|
80
81
|
message: "Invalid elements style provider meta."
|
|
81
82
|
});
|
|
83
|
+
var ActiveDocumentMustExistError = createError({
|
|
84
|
+
code: "active_document_must_exist",
|
|
85
|
+
message: "Active document must exist."
|
|
86
|
+
});
|
|
82
87
|
|
|
83
|
-
// src/
|
|
84
|
-
var
|
|
85
|
-
var
|
|
86
|
-
|
|
87
|
-
key
|
|
88
|
+
// src/utils/create-styles-provider.ts
|
|
89
|
+
var DEFAULT_LIMIT = 1e4;
|
|
90
|
+
var DEFAULT_PRIORITY = 10;
|
|
91
|
+
function createStylesProvider({
|
|
92
|
+
key,
|
|
93
|
+
priority = DEFAULT_PRIORITY,
|
|
94
|
+
limit = DEFAULT_LIMIT,
|
|
95
|
+
subscribe = () => () => {
|
|
96
|
+
},
|
|
97
|
+
labels,
|
|
98
|
+
actions
|
|
99
|
+
}) {
|
|
100
|
+
return {
|
|
101
|
+
getKey: typeof key === "string" ? () => key : key,
|
|
102
|
+
priority,
|
|
103
|
+
limit,
|
|
104
|
+
subscribe,
|
|
105
|
+
labels: {
|
|
106
|
+
singular: labels?.singular ?? null,
|
|
107
|
+
plural: labels?.plural ?? null
|
|
108
|
+
},
|
|
109
|
+
actions: {
|
|
110
|
+
all: actions.all,
|
|
111
|
+
get: actions.get,
|
|
112
|
+
create: actions.create,
|
|
113
|
+
delete: actions.delete,
|
|
114
|
+
update: actions.update,
|
|
115
|
+
updateProps: actions.updateProps
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// src/providers/document-elements-styles-provider.ts
|
|
121
|
+
var ELEMENTS_STYLES_PROVIDER_KEY_PREFIX = "document-elements-";
|
|
122
|
+
var ELEMENTS_STYLES_RESERVED_LABEL = "local";
|
|
123
|
+
var documentElementsStylesProvider = createStylesProvider({
|
|
124
|
+
key: () => {
|
|
125
|
+
const documentId = getCurrentDocumentId();
|
|
126
|
+
if (!documentId) {
|
|
127
|
+
throw new ActiveDocumentMustExistError();
|
|
128
|
+
}
|
|
129
|
+
return `${ELEMENTS_STYLES_PROVIDER_KEY_PREFIX}${documentId}`;
|
|
130
|
+
},
|
|
88
131
|
priority: 50,
|
|
132
|
+
subscribe: (cb) => listenTo(styleRerenderEvents, cb),
|
|
89
133
|
actions: {
|
|
90
|
-
|
|
134
|
+
all: (meta = {}) => {
|
|
91
135
|
let elements = getElements();
|
|
92
136
|
if (isValidElementsMeta(meta)) {
|
|
93
137
|
elements = elements.filter((element) => element.id === meta.elementId);
|
|
94
138
|
}
|
|
95
139
|
return elements.flatMap((element) => Object.values(element.model.get("styles") ?? {}));
|
|
96
140
|
},
|
|
97
|
-
|
|
141
|
+
get: (id, meta = {}) => {
|
|
98
142
|
if (!isValidElementsMeta(meta)) {
|
|
99
143
|
throw new InvalidElementsStyleProviderMetaError({ context: { meta } });
|
|
100
144
|
}
|
|
@@ -112,51 +156,97 @@ var elementsStylesProvider = {
|
|
|
112
156
|
props: args.props
|
|
113
157
|
});
|
|
114
158
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
reservedLabel: LOCAL_STYLES_RESERVED_LABEL
|
|
118
|
-
};
|
|
159
|
+
}
|
|
160
|
+
});
|
|
119
161
|
function isValidElementsMeta(meta) {
|
|
120
162
|
return "elementId" in meta && typeof meta.elementId === "string" && !!meta.elementId;
|
|
121
163
|
}
|
|
122
164
|
|
|
123
|
-
// src/
|
|
165
|
+
// src/utils/validate-style-label.ts
|
|
166
|
+
var NO_START_DIGIT_REGEX = /^(|[^0-9].*)$/;
|
|
167
|
+
var NO_SPACES_REGEX = /^\S*$/;
|
|
168
|
+
var NO_SPECIAL_CHARS_REGEX = /^(|[a-zA-Z0-9_-]+)$/;
|
|
169
|
+
var NO_DOUBLE_HYPHEN_START_REGEX = /^(?!--).*/;
|
|
170
|
+
var NO_HYPHEN_DIGIT_START_REGEX = /^(?!-[0-9])/;
|
|
171
|
+
var NO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX = /^(?!.*(--|__)).*/;
|
|
172
|
+
var NO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX = /^(?![-_]).*(?<![-_])$/;
|
|
173
|
+
var RESERVED_CLASS_NAMES = ["container"];
|
|
174
|
+
var schema = z.string().max(50, __("Class name is too long. Please keep it under 50 characters.", "elementor")).regex(NO_START_DIGIT_REGEX, __("Class names must start with a letter.", "elementor")).regex(NO_SPACES_REGEX, __("Class names can\u2019t contain spaces.", "elementor")).regex(
|
|
175
|
+
NO_SPECIAL_CHARS_REGEX,
|
|
176
|
+
__("Class names can only use letters, numbers, dashes (-), and underscores (_).", "elementor")
|
|
177
|
+
).regex(NO_DOUBLE_HYPHEN_START_REGEX, __("Double hyphens are reserved for custom properties.", "elementor")).regex(
|
|
178
|
+
NO_HYPHEN_DIGIT_START_REGEX,
|
|
179
|
+
__("Class names can\u2019t start with a hyphen followed by a number.", "elementor")
|
|
180
|
+
).regex(
|
|
181
|
+
NO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX,
|
|
182
|
+
__("Avoid using multiple dashes or underscores in a row.", "elementor")
|
|
183
|
+
).regex(
|
|
184
|
+
NO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX,
|
|
185
|
+
__("Class names can\u2019t start or end with a dash or underscore.", "elementor")
|
|
186
|
+
).refine((value) => !RESERVED_CLASS_NAMES.includes(value), {
|
|
187
|
+
message: __("This name is reserved and can\u2019t be used. Try something more specific.", "elementor")
|
|
188
|
+
});
|
|
189
|
+
function validateStyleLabel(label, event) {
|
|
190
|
+
const existingLabels = /* @__PURE__ */ new Set([
|
|
191
|
+
ELEMENTS_STYLES_RESERVED_LABEL,
|
|
192
|
+
...stylesRepository.all().map((styleDef) => styleDef.label.toLowerCase())
|
|
193
|
+
]);
|
|
194
|
+
const fullValidationEvent = ["create", "rename"].includes(event);
|
|
195
|
+
const result = schema.refine((value) => !(fullValidationEvent && value.length < 2), {
|
|
196
|
+
message: __("Class name is too short. Use at least 2 characters.", "elementor")
|
|
197
|
+
}).refine((value) => !(fullValidationEvent && existingLabels.has(value)), {
|
|
198
|
+
message: __("This class name already exists. Please choose a unique name.", "elementor")
|
|
199
|
+
}).safeParse(label.toLowerCase());
|
|
200
|
+
if (result.success) {
|
|
201
|
+
return {
|
|
202
|
+
isValid: true,
|
|
203
|
+
errorMessage: null
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
return {
|
|
207
|
+
isValid: false,
|
|
208
|
+
errorMessage: result.error.format()._errors[0]
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/utils/is-elements-styles-provider.ts
|
|
213
|
+
function isElementsStylesProvider(key) {
|
|
214
|
+
return new RegExp(`^${ELEMENTS_STYLES_PROVIDER_KEY_PREFIX}\\d+$`).test(key);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// src/providers/element-base-styles-provider.ts
|
|
124
218
|
import { getWidgetsCache } from "@elementor/editor-elements";
|
|
125
219
|
var ELEMENTS_BASE_STYLES_PROVIDER_KEY = "element-base-styles";
|
|
126
|
-
var elementBaseStylesProvider = {
|
|
220
|
+
var elementBaseStylesProvider = createStylesProvider({
|
|
127
221
|
key: ELEMENTS_BASE_STYLES_PROVIDER_KEY,
|
|
128
|
-
priority: 10,
|
|
129
222
|
actions: {
|
|
130
|
-
|
|
223
|
+
all() {
|
|
131
224
|
const widgetsCache = getWidgetsCache();
|
|
132
225
|
return Object.values(widgetsCache ?? {}).flatMap(
|
|
133
226
|
(widget) => Object.values(widget.base_styles ?? {})
|
|
134
227
|
);
|
|
135
228
|
},
|
|
136
|
-
|
|
137
|
-
return this.
|
|
229
|
+
get(id) {
|
|
230
|
+
return this.all().find((style) => style.id === id) ?? null;
|
|
138
231
|
}
|
|
139
|
-
},
|
|
140
|
-
subscribe: () => {
|
|
141
|
-
return () => {
|
|
142
|
-
};
|
|
143
232
|
}
|
|
144
|
-
};
|
|
233
|
+
});
|
|
145
234
|
|
|
146
235
|
// src/init.ts
|
|
147
236
|
function init() {
|
|
148
|
-
stylesRepository.register(
|
|
237
|
+
stylesRepository.register(documentElementsStylesProvider);
|
|
149
238
|
stylesRepository.register(elementBaseStylesProvider);
|
|
150
239
|
}
|
|
151
|
-
|
|
152
|
-
// src/index.ts
|
|
153
|
-
init();
|
|
154
240
|
export {
|
|
155
241
|
ELEMENTS_BASE_STYLES_PROVIDER_KEY,
|
|
156
|
-
|
|
157
|
-
|
|
242
|
+
ELEMENTS_STYLES_PROVIDER_KEY_PREFIX,
|
|
243
|
+
ELEMENTS_STYLES_RESERVED_LABEL,
|
|
244
|
+
createStylesProvider,
|
|
245
|
+
init,
|
|
246
|
+
isElementsStylesProvider,
|
|
158
247
|
stylesRepository,
|
|
159
|
-
|
|
160
|
-
useProviders
|
|
248
|
+
useGetStylesRepositoryCreateAction,
|
|
249
|
+
useProviders,
|
|
250
|
+
validateStyleLabel
|
|
161
251
|
};
|
|
162
252
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utils/create-styles-repository.ts","../src/styles-repository.ts","../src/hooks/use-providers.ts","../src/hooks/use-create-actions-by-provider.ts","../src/elements-styles-provider.ts","../src/errors.ts","../src/element-base-styles-provider.ts","../src/init.ts","../src/index.ts"],"sourcesContent":["import { type Props } from '@elementor/editor-props';\nimport { type StyleDefinition, type StyleDefinitionID, type StyleDefinitionVariant } from '@elementor/editor-styles';\n\ntype MakeOptional< T, K extends keyof T > = Omit< T, K > & Partial< T >;\n\nexport type UpdateActionPayload = MakeOptional< StyleDefinition, 'label' | 'variants' | 'type' >;\n\nexport type UpdatePropsActionPayload = {\n\tid: StyleDefinitionID;\n\tmeta: StyleDefinitionVariant[ 'meta' ];\n\tprops: Props;\n};\n\nexport type Meta = Record< string, unknown >;\n\nexport type StylesProvider = {\n\tkey: string;\n\tpriority: number;\n\tactions: {\n\t\tget: ( meta?: Meta ) => StyleDefinition[];\n\t\tgetById: ( id: StyleDefinitionID, meta?: Meta ) => StyleDefinition | null;\n\t\tcreate?: ( label: StyleDefinition[ 'label' ] ) => StyleDefinitionID;\n\t\tdelete?: ( id: StyleDefinitionID ) => void;\n\t\tsetOrder?: ( order: StyleDefinitionID[] ) => void;\n\t\tupdate?: ( data: UpdateActionPayload ) => void;\n\t\tupdateProps?: ( args: UpdatePropsActionPayload, meta?: Meta ) => void;\n\t};\n\tsubscribe: ( callback: () => void ) => () => void;\n\tlabels?: {\n\t\tsingular: string;\n\t\tplural: string;\n\t};\n\treservedLabel?: string;\n\tlimit?: number;\n};\n\nconst VALID_SELECTOR_REGEX = /^[a-zA-Z0-9_-]+$/;\n\nexport const createStylesRepository = () => {\n\tconst providers: StylesProvider[] = [];\n\n\tconst getProviders = () => {\n\t\treturn providers.slice( 0 ).sort( ( a, b ) => ( a.priority > b.priority ? -1 : 1 ) );\n\t};\n\n\tconst register = ( provider: StylesProvider ) => {\n\t\tproviders.push( provider );\n\t};\n\n\tconst all = ( meta: Meta = {} ) => {\n\t\treturn getProviders().flatMap( ( provider ) => provider.actions.get( meta ) );\n\t};\n\n\tconst subscribe = ( cb: () => void ) => {\n\t\tconst unsubscribes = providers.map( ( provider ) => {\n\t\t\treturn provider.subscribe( cb );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribes.forEach( ( unsubscribe ) => unsubscribe() );\n\t\t};\n\t};\n\n\tconst getProviderByKey = ( key: string ) => {\n\t\treturn providers.find( ( provider ) => provider.key === key );\n\t};\n\n\tconst isLabelExist = ( newLabel: string ) => {\n\t\tconst classes = all();\n\t\tconst reservedLabels = providers.map( ( { reservedLabel } ) => reservedLabel ).filter( Boolean );\n\n\t\tif ( reservedLabels.includes( newLabel ) ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! classes?.length ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn classes.some( ( { label } ) => label.toLowerCase() === newLabel.toLowerCase() );\n\t};\n\n\tconst isLabelValid = ( newLabel: string ) => VALID_SELECTOR_REGEX.test( newLabel );\n\n\treturn {\n\t\tall,\n\t\tregister,\n\t\tsubscribe,\n\t\tgetProviders,\n\t\tgetProviderByKey,\n\t\tisLabelExist,\n\t\tisLabelValid,\n\t};\n};\n","import { createStylesRepository } from './utils/create-styles-repository';\n\nexport const stylesRepository = createStylesRepository();\n","import { useEffect, useReducer } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\n\nexport function useProviders() {\n\tconst [ , rerender ] = useReducer( ( prev ) => ! prev, false );\n\n\tuseEffect( () => stylesRepository.subscribe( rerender ), [] );\n\n\treturn stylesRepository.getProviders();\n}\n","import { useMemo } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\nimport { type StylesProvider } from '../utils/create-styles-repository';\n\ntype CreateAction = Required< StylesProvider[ 'actions' ] >[ 'create' ];\ntype CreateTuple = [ StylesProvider, CreateAction ];\n\nexport function useCreateActionsByProvider() {\n\treturn useMemo( () => {\n\t\treturn stylesRepository\n\t\t\t.getProviders()\n\t\t\t.map< CreateTuple | null >( ( provider ) => {\n\t\t\t\tif ( ! provider.actions.create ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn [ provider, provider.actions.create ];\n\t\t\t} )\n\t\t\t.filter( ( item ) => !! item );\n\t}, [] );\n}\n","import { getElements, getElementStyles, styleRerenderEvents, updateElementStyle } from '@elementor/editor-elements';\nimport { __privateListenTo as listenTo } from '@elementor/editor-v1-adapters';\n\nimport { InvalidElementsStyleProviderMetaError } from './errors';\nimport { type StylesProvider } from './utils/create-styles-repository';\n\nexport const ELEMENTS_STYLES_PROVIDER_KEY = 'elements';\nexport const LOCAL_STYLES_RESERVED_LABEL = 'local';\n\nexport const elementsStylesProvider = {\n\tkey: ELEMENTS_STYLES_PROVIDER_KEY,\n\tpriority: 50,\n\tactions: {\n\t\tget: ( meta = {} ) => {\n\t\t\tlet elements = getElements();\n\n\t\t\tif ( isValidElementsMeta( meta ) ) {\n\t\t\t\telements = elements.filter( ( element ) => element.id === meta.elementId );\n\t\t\t}\n\n\t\t\treturn elements.flatMap( ( element ) => Object.values( element.model.get( 'styles' ) ?? {} ) );\n\t\t},\n\n\t\tgetById: ( id, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tconst styles = getElementStyles( meta.elementId ) ?? {};\n\n\t\t\treturn styles[ id ] ?? null;\n\t\t},\n\n\t\tupdateProps: ( args, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tupdateElementStyle( {\n\t\t\t\telementId: meta.elementId,\n\t\t\t\tstyleId: args.id,\n\t\t\t\tmeta: args.meta,\n\t\t\t\tprops: args.props,\n\t\t\t} );\n\t\t},\n\t},\n\tsubscribe: ( cb ) => listenTo( styleRerenderEvents, cb ),\n\treservedLabel: LOCAL_STYLES_RESERVED_LABEL,\n} satisfies StylesProvider;\n\ntype ElementsMeta = {\n\telementId: string;\n};\n\nfunction isValidElementsMeta( meta: Record< string, unknown > ): meta is ElementsMeta {\n\treturn 'elementId' in meta && typeof meta.elementId === 'string' && !! meta.elementId;\n}\n","import { createError } from '@elementor/utils';\n\nexport const InvalidElementsStyleProviderMetaError = createError< { meta: Record< string, unknown > } >( {\n\tcode: 'invalid_elements_style_provider_meta',\n\tmessage: 'Invalid elements style provider meta.',\n} );\n","import { getWidgetsCache } from '@elementor/editor-elements';\n\nimport { type StylesProvider } from './utils/create-styles-repository';\n\nexport const ELEMENTS_BASE_STYLES_PROVIDER_KEY = 'element-base-styles';\n\nexport const elementBaseStylesProvider: StylesProvider = {\n\tkey: ELEMENTS_BASE_STYLES_PROVIDER_KEY,\n\tpriority: 10,\n\tactions: {\n\t\tget() {\n\t\t\tconst widgetsCache = getWidgetsCache();\n\n\t\t\treturn Object.values( widgetsCache ?? {} ).flatMap( ( widget ) =>\n\t\t\t\tObject.values( widget.base_styles ?? {} )\n\t\t\t);\n\t\t},\n\n\t\tgetById( id ) {\n\t\t\treturn this.get().find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n\tsubscribe: () => {\n\t\treturn () => {};\n\t},\n};\n","import { elementBaseStylesProvider } from './element-base-styles-provider';\nimport { elementsStylesProvider } from './elements-styles-provider';\nimport { stylesRepository } from './styles-repository';\n\nexport function init() {\n\tstylesRepository.register( elementsStylesProvider );\n\tstylesRepository.register( elementBaseStylesProvider );\n}\n","export {\n\ttype StylesProvider,\n\ttype UpdateActionPayload,\n\ttype Meta,\n\ttype UpdatePropsActionPayload,\n} from './utils/create-styles-repository';\n\nexport { stylesRepository } from './styles-repository';\nexport { useProviders } from './hooks/use-providers';\nexport { useCreateActionsByProvider } from './hooks/use-create-actions-by-provider';\n\nexport { ELEMENTS_STYLES_PROVIDER_KEY, LOCAL_STYLES_RESERVED_LABEL } from './elements-styles-provider';\nexport { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from './element-base-styles-provider';\n\nimport { init } from './init';\n\ninit();\n"],"mappings":";AAoCA,IAAM,uBAAuB;AAEtB,IAAM,yBAAyB,MAAM;AAC3C,QAAM,YAA8B,CAAC;AAErC,QAAM,eAAe,MAAM;AAC1B,WAAO,UAAU,MAAO,CAAE,EAAE,KAAM,CAAE,GAAG,MAAS,EAAE,WAAW,EAAE,WAAW,KAAK,CAAI;AAAA,EACpF;AAEA,QAAM,WAAW,CAAE,aAA8B;AAChD,cAAU,KAAM,QAAS;AAAA,EAC1B;AAEA,QAAM,MAAM,CAAE,OAAa,CAAC,MAAO;AAClC,WAAO,aAAa,EAAE,QAAS,CAAE,aAAc,SAAS,QAAQ,IAAK,IAAK,CAAE;AAAA,EAC7E;AAEA,QAAM,YAAY,CAAE,OAAoB;AACvC,UAAM,eAAe,UAAU,IAAK,CAAE,aAAc;AACnD,aAAO,SAAS,UAAW,EAAG;AAAA,IAC/B,CAAE;AAEF,WAAO,MAAM;AACZ,mBAAa,QAAS,CAAE,gBAAiB,YAAY,CAAE;AAAA,IACxD;AAAA,EACD;AAEA,QAAM,mBAAmB,CAAE,QAAiB;AAC3C,WAAO,UAAU,KAAM,CAAE,aAAc,SAAS,QAAQ,GAAI;AAAA,EAC7D;AAEA,QAAM,eAAe,CAAE,aAAsB;AAC5C,UAAM,UAAU,IAAI;AACpB,UAAM,iBAAiB,UAAU,IAAK,CAAE,EAAE,cAAc,MAAO,aAAc,EAAE,OAAQ,OAAQ;AAE/F,QAAK,eAAe,SAAU,QAAS,GAAI;AAC1C,aAAO;AAAA,IACR;AAEA,QAAK,CAAE,SAAS,QAAS;AACxB,aAAO;AAAA,IACR;AAEA,WAAO,QAAQ,KAAM,CAAE,EAAE,MAAM,MAAO,MAAM,YAAY,MAAM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AAA,IAC3D;AAAA,EACD;AAAA,EACA,WAAW,MAAM;AAChB,WAAO,MAAM;AAAA,IAAC;AAAA,EACf;AACD;;;ACrBO,SAAS,OAAO;AACtB,mBAAiB,SAAU,sBAAuB;AAClD,mBAAiB,SAAU,yBAA0B;AACtD;;;ACSA,KAAK;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/utils/create-styles-repository.ts","../src/styles-repository.ts","../src/hooks/use-providers.ts","../src/hooks/use-get-styles-repository-create-action.ts","../src/utils/validate-style-label.ts","../src/providers/document-elements-styles-provider.ts","../src/errors.ts","../src/utils/create-styles-provider.ts","../src/utils/is-elements-styles-provider.ts","../src/providers/element-base-styles-provider.ts","../src/init.ts"],"sourcesContent":["import { type Meta, type StylesProvider } from '../types';\n\nexport const createStylesRepository = () => {\n\tconst providers: StylesProvider[] = [];\n\n\tconst getProviders = () => {\n\t\treturn providers.slice( 0 ).sort( ( a, b ) => ( a.priority > b.priority ? -1 : 1 ) );\n\t};\n\n\tconst register = ( provider: StylesProvider ) => {\n\t\tproviders.push( provider );\n\t};\n\n\tconst all = ( meta: Meta = {} ) => {\n\t\treturn getProviders().flatMap( ( provider ) => provider.actions.all( meta ) );\n\t};\n\n\tconst subscribe = ( cb: () => void ) => {\n\t\tconst unsubscribes = providers.map( ( provider ) => {\n\t\t\treturn provider.subscribe( cb );\n\t\t} );\n\n\t\treturn () => {\n\t\t\tunsubscribes.forEach( ( unsubscribe ) => unsubscribe() );\n\t\t};\n\t};\n\n\tconst getProviderByKey = ( key: string ) => {\n\t\treturn providers.find( ( provider ) => provider.getKey() === key );\n\t};\n\n\treturn {\n\t\tall,\n\t\tregister,\n\t\tsubscribe,\n\t\tgetProviders,\n\t\tgetProviderByKey,\n\t};\n};\n","import { createStylesRepository } from './utils/create-styles-repository';\n\nexport const stylesRepository = createStylesRepository();\n","import { useEffect, useReducer } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\n\nexport function useProviders() {\n\tconst [ , rerender ] = useReducer( ( prev ) => ! prev, false );\n\n\tuseEffect( () => stylesRepository.subscribe( rerender ), [] );\n\n\treturn stylesRepository.getProviders();\n}\n","import { useMemo } from 'react';\n\nimport { stylesRepository } from '../styles-repository';\nimport { type StylesProvider } from '../types';\n\ntype CreateAction = Required< StylesProvider[ 'actions' ] >[ 'create' ];\ntype CreateTuple = [ StylesProvider, CreateAction ];\n\nexport function useGetStylesRepositoryCreateAction() {\n\treturn useMemo( () => {\n\t\tconst createActions = stylesRepository\n\t\t\t.getProviders()\n\t\t\t.map< CreateTuple | null >( ( provider ) => {\n\t\t\t\tif ( ! provider.actions.create ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn [ provider, provider.actions.create ];\n\t\t\t} )\n\t\t\t.filter( ( item ) => !! item );\n\n\t\tif ( createActions.length === 1 ) {\n\t\t\treturn createActions[ 0 ];\n\t\t} else if ( createActions.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\t\tthrow new Error( 'Multiple providers with create action found in styles repository.' );\n\t}, [] );\n}\n","import { z } from '@elementor/schema';\nimport { __ } from '@wordpress/i18n';\n\nimport { ELEMENTS_STYLES_RESERVED_LABEL } from '../providers/document-elements-styles-provider';\nimport { stylesRepository } from '../styles-repository';\n\nconst NO_START_DIGIT_REGEX = /^(|[^0-9].*)$/;\nconst NO_SPACES_REGEX = /^\\S*$/;\nconst NO_SPECIAL_CHARS_REGEX = /^(|[a-zA-Z0-9_-]+)$/;\nconst NO_DOUBLE_HYPHEN_START_REGEX = /^(?!--).*/;\nconst NO_HYPHEN_DIGIT_START_REGEX = /^(?!-[0-9])/;\nconst NO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX = /^(?!.*(--|__)).*/;\nconst NO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX = /^(?![-_]).*(?<![-_])$/;\n\nconst RESERVED_CLASS_NAMES = [ 'container' ];\n\nconst schema = z\n\t.string()\n\t.max( 50, __( 'Class name is too long. Please keep it under 50 characters.', 'elementor' ) )\n\t.regex( NO_START_DIGIT_REGEX, __( 'Class names must start with a letter.', 'elementor' ) )\n\t.regex( NO_SPACES_REGEX, __( 'Class names can’t contain spaces.', 'elementor' ) )\n\t.regex(\n\t\tNO_SPECIAL_CHARS_REGEX,\n\t\t__( 'Class names can only use letters, numbers, dashes (-), and underscores (_).', 'elementor' )\n\t)\n\t.regex( NO_DOUBLE_HYPHEN_START_REGEX, __( 'Double hyphens are reserved for custom properties.', 'elementor' ) )\n\t.regex(\n\t\tNO_HYPHEN_DIGIT_START_REGEX,\n\t\t__( 'Class names can’t start with a hyphen followed by a number.', 'elementor' )\n\t)\n\t.regex(\n\t\tNO_CONSECUTIVE_HYPHENS_OR_UNDERSCORES_REGEX,\n\t\t__( 'Avoid using multiple dashes or underscores in a row.', 'elementor' )\n\t)\n\t.regex(\n\t\tNO_LEADING_TRAILING_DASH_UNDERSCORE_REGEX,\n\t\t__( 'Class names can’t start or end with a dash or underscore.', 'elementor' )\n\t)\n\t.refine( ( value ) => ! RESERVED_CLASS_NAMES.includes( value ), {\n\t\tmessage: __( 'This name is reserved and can’t be used. Try something more specific.', 'elementor' ),\n\t} );\n\ntype ValidationEvent = 'inputChange' | 'create' | 'rename';\ntype ValidationResult = { isValid: true; errorMessage: null } | { isValid: false; errorMessage: string };\n\nexport function validateStyleLabel( label: string, event: ValidationEvent | 'rename' ): ValidationResult {\n\tconst existingLabels = new Set( [\n\t\tELEMENTS_STYLES_RESERVED_LABEL,\n\t\t...stylesRepository.all().map( ( styleDef ) => styleDef.label.toLowerCase() ),\n\t] );\n\n\tconst fullValidationEvent = [ 'create', 'rename' ].includes( event );\n\n\tconst result = schema\n\t\t.refine( ( value ) => ! ( fullValidationEvent && value.length < 2 ), {\n\t\t\tmessage: __( 'Class name is too short. Use at least 2 characters.', 'elementor' ),\n\t\t} )\n\t\t.refine( ( value ) => ! ( fullValidationEvent && existingLabels.has( value ) ), {\n\t\t\tmessage: __( 'This class name already exists. Please choose a unique name.', 'elementor' ),\n\t\t} )\n\t\t.safeParse( label.toLowerCase() );\n\n\tif ( result.success ) {\n\t\treturn {\n\t\t\tisValid: true,\n\t\t\terrorMessage: null,\n\t\t};\n\t}\n\n\treturn {\n\t\tisValid: false,\n\t\terrorMessage: result.error.format()._errors[ 0 ],\n\t};\n}\n","import {\n\tgetCurrentDocumentId,\n\tgetElements,\n\tgetElementStyles,\n\tstyleRerenderEvents,\n\tupdateElementStyle,\n} from '@elementor/editor-elements';\nimport { __privateListenTo as listenTo } from '@elementor/editor-v1-adapters';\n\nimport { ActiveDocumentMustExistError, InvalidElementsStyleProviderMetaError } from '../errors';\nimport { createStylesProvider } from '../utils/create-styles-provider';\n\nexport const ELEMENTS_STYLES_PROVIDER_KEY_PREFIX = 'document-elements-';\nexport const ELEMENTS_STYLES_RESERVED_LABEL = 'local';\n\ntype ElementsMeta = {\n\telementId: string;\n};\n\nexport const documentElementsStylesProvider = createStylesProvider( {\n\tkey: () => {\n\t\tconst documentId = getCurrentDocumentId();\n\n\t\tif ( ! documentId ) {\n\t\t\tthrow new ActiveDocumentMustExistError();\n\t\t}\n\n\t\treturn `${ ELEMENTS_STYLES_PROVIDER_KEY_PREFIX }${ documentId }`;\n\t},\n\tpriority: 50,\n\tsubscribe: ( cb ) => listenTo( styleRerenderEvents, cb ),\n\tactions: {\n\t\tall: ( meta = {} ) => {\n\t\t\tlet elements = getElements();\n\n\t\t\tif ( isValidElementsMeta( meta ) ) {\n\t\t\t\telements = elements.filter( ( element ) => element.id === meta.elementId );\n\t\t\t}\n\n\t\t\treturn elements.flatMap( ( element ) => Object.values( element.model.get( 'styles' ) ?? {} ) );\n\t\t},\n\n\t\tget: ( id, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tconst styles = getElementStyles( meta.elementId ) ?? {};\n\n\t\t\treturn styles[ id ] ?? null;\n\t\t},\n\n\t\tupdateProps: ( args, meta = {} ) => {\n\t\t\tif ( ! isValidElementsMeta( meta ) ) {\n\t\t\t\tthrow new InvalidElementsStyleProviderMetaError( { context: { meta } } );\n\t\t\t}\n\n\t\t\tupdateElementStyle( {\n\t\t\t\telementId: meta.elementId,\n\t\t\t\tstyleId: args.id,\n\t\t\t\tmeta: args.meta,\n\t\t\t\tprops: args.props,\n\t\t\t} );\n\t\t},\n\t},\n} );\n\nfunction isValidElementsMeta( meta: Record< string, unknown > ): meta is ElementsMeta {\n\treturn 'elementId' in meta && typeof meta.elementId === 'string' && !! meta.elementId;\n}\n","import { createError } from '@elementor/utils';\n\nexport const InvalidElementsStyleProviderMetaError = createError< { meta: Record< string, unknown > } >( {\n\tcode: 'invalid_elements_style_provider_meta',\n\tmessage: 'Invalid elements style provider meta.',\n} );\n\nexport const ActiveDocumentMustExistError = createError( {\n\tcode: 'active_document_must_exist',\n\tmessage: 'Active document must exist.',\n} );\n","import { type StylesProvider } from '../types';\n\nexport type CreateStylesProviderOptions = {\n\tkey: string | ( () => string );\n\tpriority?: number;\n\tlimit?: number;\n\tsubscribe?: ( callback: () => void ) => () => void;\n\tlabels?: {\n\t\tsingular: string;\n\t\tplural: string;\n\t};\n\tactions: {\n\t\tall: StylesProvider[ 'actions' ][ 'all' ];\n\t\tget: StylesProvider[ 'actions' ][ 'get' ];\n\t\tcreate?: StylesProvider[ 'actions' ][ 'create' ];\n\t\tdelete?: StylesProvider[ 'actions' ][ 'delete' ];\n\t\tupdate?: StylesProvider[ 'actions' ][ 'update' ];\n\t\tupdateProps?: StylesProvider[ 'actions' ][ 'updateProps' ];\n\t};\n};\n\nconst DEFAULT_LIMIT = 10000;\nconst DEFAULT_PRIORITY = 10;\n\nexport function createStylesProvider( {\n\tkey,\n\tpriority = DEFAULT_PRIORITY,\n\tlimit = DEFAULT_LIMIT,\n\tsubscribe = () => () => {},\n\tlabels,\n\tactions,\n}: CreateStylesProviderOptions ): StylesProvider {\n\treturn {\n\t\tgetKey: typeof key === 'string' ? () => key : key,\n\t\tpriority,\n\t\tlimit,\n\t\tsubscribe,\n\t\tlabels: {\n\t\t\tsingular: labels?.singular ?? null,\n\t\t\tplural: labels?.plural ?? null,\n\t\t},\n\t\tactions: {\n\t\t\tall: actions.all,\n\t\t\tget: actions.get,\n\t\t\tcreate: actions.create,\n\t\t\tdelete: actions.delete,\n\t\t\tupdate: actions.update,\n\t\t\tupdateProps: actions.updateProps,\n\t\t},\n\t};\n}\n","import { ELEMENTS_STYLES_PROVIDER_KEY_PREFIX } from '../providers/document-elements-styles-provider';\n\nexport function isElementsStylesProvider( key: string ) {\n\treturn new RegExp( `^${ ELEMENTS_STYLES_PROVIDER_KEY_PREFIX }\\\\d+$` ).test( key );\n}\n","import { getWidgetsCache } from '@elementor/editor-elements';\n\nimport { createStylesProvider } from '../utils/create-styles-provider';\n\nexport const ELEMENTS_BASE_STYLES_PROVIDER_KEY = 'element-base-styles';\n\nexport const elementBaseStylesProvider = createStylesProvider( {\n\tkey: ELEMENTS_BASE_STYLES_PROVIDER_KEY,\n\tactions: {\n\t\tall() {\n\t\t\tconst widgetsCache = getWidgetsCache();\n\n\t\t\treturn Object.values( widgetsCache ?? {} ).flatMap( ( widget ) =>\n\t\t\t\tObject.values( widget.base_styles ?? {} )\n\t\t\t);\n\t\t},\n\n\t\tget( id ) {\n\t\t\treturn this.all().find( ( style ) => style.id === id ) ?? null;\n\t\t},\n\t},\n} );\n","import { documentElementsStylesProvider } from './providers/document-elements-styles-provider';\nimport { elementBaseStylesProvider } from './providers/element-base-styles-provider';\nimport { stylesRepository } from './styles-repository';\n\nexport function init() {\n\tstylesRepository.register( documentElementsStylesProvider );\n\tstylesRepository.register( elementBaseStylesProvider );\n}\n"],"mappings":";AAEO,IAAM,yBAAyB,MAAM;AAC3C,QAAM,YAA8B,CAAC;AAErC,QAAM,eAAe,MAAM;AAC1B,WAAO,UAAU,MAAO,CAAE,EAAE,KAAM,CAAE,GAAG,MAAS,EAAE,WAAW,EAAE,WAA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;AAAA,EAChD;AACD;;;AIvEO,SAAS,yBAA0B,KAAc;AACvD,SAAO,IAAI,OAAQ,IAAK,mCAAoC,OAAQ,EAAE,KAAM,GAAI;AACjF;;;ACJA,SAAS,uBAAuB;AAIzB,IAAM,oCAAoC;AAE1C,IAAM,4BAA4B,qBAAsB;AAAA,EAC9D,KAAK;AAAA,EACL,SAAS;AAAA,IACR,MAAM;AACL,YAAM,eAAe,gBAAgB;AAErC,aAAO,OAAO,OAAQ,gBAAgB,CAAC,CAAE,EAAE;AAAA,QAAS,CAAE,WACrD,OAAO,OAAQ,OAAO,eAAe,CAAC,CAAE;AAAA,MACzC;AAAA,IACD;AAAA,IAEA,IAAK,IAAK;AACT,aAAO,KAAK,IAAI,EAAE,KAAM,CAAE,UAAW,MAAM,OAAO,EAAG,KAAK;AAAA,IAC3D;AAAA,EACD;AACD,CAAE;;;ACjBK,SAAS,OAAO;AACtB,mBAAiB,SAAU,8BAA+B;AAC1D,mBAAiB,SAAU,yBAA0B;AACtD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-styles-repository",
|
|
3
3
|
"description": "Elementor Editor Styles Repository",
|
|
4
|
-
"version": "0.8.
|
|
4
|
+
"version": "0.8.5",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@elementor/editor-elements": "0.8.
|
|
37
|
-
"@elementor/editor-props": "0.
|
|
38
|
-
"@elementor/editor-styles": "0.6.
|
|
36
|
+
"@elementor/editor-elements": "0.8.1",
|
|
37
|
+
"@elementor/editor-props": "0.12.0",
|
|
38
|
+
"@elementor/editor-styles": "0.6.6",
|
|
39
39
|
"@elementor/editor-v1-adapters": "0.11.0",
|
|
40
|
-
"@elementor/
|
|
40
|
+
"@elementor/schema": "0.1.2",
|
|
41
|
+
"@elementor/utils": "0.4.0",
|
|
42
|
+
"@wordpress/i18n": "^5.13.0"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
45
|
"react": "^18.3.1"
|
package/src/__tests__/{elements-styles-provider.test.ts → document-elements-styles-provider.test.ts}
RENAMED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { createMockElement, createMockStyleDefinition } from 'test-utils';
|
|
2
|
-
import { getElements, getElementStyles, updateElementStyle } from '@elementor/editor-elements';
|
|
2
|
+
import { getCurrentDocumentId, getElements, getElementStyles, updateElementStyle } from '@elementor/editor-elements';
|
|
3
3
|
import type { StyleDefinition } from '@elementor/editor-styles';
|
|
4
4
|
|
|
5
|
-
import { elementsStylesProvider } from '../elements-styles-provider';
|
|
6
5
|
import { InvalidElementsStyleProviderMetaError } from '../errors';
|
|
6
|
+
import { documentElementsStylesProvider } from '../providers/document-elements-styles-provider';
|
|
7
7
|
|
|
8
8
|
jest.mock( '@elementor/editor-elements' );
|
|
9
9
|
|
|
10
|
-
describe( '
|
|
10
|
+
describe( 'documentElementsStylesProvider', () => {
|
|
11
11
|
beforeEach( () => {
|
|
12
12
|
jest.mocked( getElements ).mockReturnValue( [
|
|
13
13
|
createMockElement( {
|
|
@@ -30,9 +30,20 @@ describe( 'elementsStylesProvider', () => {
|
|
|
30
30
|
] );
|
|
31
31
|
} );
|
|
32
32
|
|
|
33
|
+
it( 'should generate the key based on current document', () => {
|
|
34
|
+
// Arrange.
|
|
35
|
+
jest.mocked( getCurrentDocumentId ).mockReturnValue( 42 );
|
|
36
|
+
|
|
37
|
+
// Act.
|
|
38
|
+
const key = documentElementsStylesProvider.getKey();
|
|
39
|
+
|
|
40
|
+
// Assert.
|
|
41
|
+
expect( key ).toBe( 'document-elements-42' );
|
|
42
|
+
} );
|
|
43
|
+
|
|
33
44
|
it( 'should return all the styles attached to all the document elements', () => {
|
|
34
45
|
// Act.
|
|
35
|
-
const styles =
|
|
46
|
+
const styles = documentElementsStylesProvider.actions.all();
|
|
36
47
|
|
|
37
48
|
// Assert.
|
|
38
49
|
expect( styles ).toEqual( [
|
|
@@ -44,7 +55,7 @@ describe( 'elementsStylesProvider', () => {
|
|
|
44
55
|
|
|
45
56
|
it( 'should return all styles filtered by element', () => {
|
|
46
57
|
// Act.
|
|
47
|
-
const styles =
|
|
58
|
+
const styles = documentElementsStylesProvider.actions.all( { elementId: '1' } );
|
|
48
59
|
|
|
49
60
|
// Assert.
|
|
50
61
|
expect( styles ).toEqual( [
|
|
@@ -74,7 +85,7 @@ describe( 'elementsStylesProvider', () => {
|
|
|
74
85
|
} );
|
|
75
86
|
|
|
76
87
|
// Act.
|
|
77
|
-
const elementStyle =
|
|
88
|
+
const elementStyle = documentElementsStylesProvider.actions.get( 'style-2', { elementId: 'test-element-id' } );
|
|
78
89
|
|
|
79
90
|
// Assert.
|
|
80
91
|
expect( elementStyle ).toStrictEqual( styles[ 'style-2' ] );
|
|
@@ -82,14 +93,14 @@ describe( 'elementsStylesProvider', () => {
|
|
|
82
93
|
|
|
83
94
|
it( 'should throw when trying to get a style by id without passing an element id', () => {
|
|
84
95
|
// Act & Assert.
|
|
85
|
-
expect( () =>
|
|
96
|
+
expect( () => documentElementsStylesProvider.actions.get( 'style', { notElementId: 'test-value' } ) ).toThrow(
|
|
86
97
|
new InvalidElementsStyleProviderMetaError()
|
|
87
98
|
);
|
|
88
99
|
} );
|
|
89
100
|
|
|
90
101
|
it( 'should update style props', () => {
|
|
91
102
|
// Act.
|
|
92
|
-
|
|
103
|
+
documentElementsStylesProvider.actions?.updateProps?.(
|
|
93
104
|
{
|
|
94
105
|
id: 'test-style',
|
|
95
106
|
meta: {
|
|
@@ -127,20 +138,21 @@ describe( 'elementsStylesProvider', () => {
|
|
|
127
138
|
{ elementsMeta: { elementId: {} } },
|
|
128
139
|
] )( 'should throw when updating props with invalid elements meta', ( { elementsMeta } ) => {
|
|
129
140
|
// Act & Assert.
|
|
130
|
-
expect(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
expect(
|
|
142
|
+
() =>
|
|
143
|
+
documentElementsStylesProvider.actions?.updateProps?.(
|
|
144
|
+
{
|
|
145
|
+
id: 'test-id',
|
|
146
|
+
meta: {
|
|
147
|
+
breakpoint: null,
|
|
148
|
+
state: null,
|
|
149
|
+
},
|
|
150
|
+
props: {
|
|
151
|
+
prop: 'value',
|
|
152
|
+
},
|
|
137
153
|
},
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
elementsMeta
|
|
143
|
-
)
|
|
154
|
+
elementsMeta
|
|
155
|
+
)
|
|
144
156
|
).toThrow( new InvalidElementsStyleProviderMetaError() );
|
|
145
157
|
} );
|
|
146
158
|
} );
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createMockStyleDefinition } from 'test-utils';
|
|
2
2
|
import { getWidgetsCache } from '@elementor/editor-elements';
|
|
3
3
|
|
|
4
|
-
import { elementBaseStylesProvider } from '../element-base-styles-provider';
|
|
4
|
+
import { elementBaseStylesProvider } from '../providers/element-base-styles-provider';
|
|
5
5
|
|
|
6
6
|
jest.mock( '@elementor/editor-elements' );
|
|
7
7
|
|
|
@@ -25,7 +25,7 @@ describe( 'elementBaseStylesProvider', () => {
|
|
|
25
25
|
|
|
26
26
|
it( 'should return all the styles attached to all the document elements', () => {
|
|
27
27
|
// Act.
|
|
28
|
-
const styles = elementBaseStylesProvider.actions.
|
|
28
|
+
const styles = elementBaseStylesProvider.actions.all();
|
|
29
29
|
|
|
30
30
|
// Assert.
|
|
31
31
|
expect( styles ).toEqual( [
|
|
@@ -37,7 +37,7 @@ describe( 'elementBaseStylesProvider', () => {
|
|
|
37
37
|
|
|
38
38
|
it( 'should return base style by id', () => {
|
|
39
39
|
// Act.
|
|
40
|
-
const style = elementBaseStylesProvider.actions.
|
|
40
|
+
const style = elementBaseStylesProvider.actions.get( 's-1' );
|
|
41
41
|
|
|
42
42
|
// Assert.
|
|
43
43
|
expect( style ).toEqual( expect.objectContaining( { id: 's-1' } ) );
|
package/src/errors.ts
CHANGED
|
@@ -4,3 +4,8 @@ export const InvalidElementsStyleProviderMetaError = createError< { meta: Record
|
|
|
4
4
|
code: 'invalid_elements_style_provider_meta',
|
|
5
5
|
message: 'Invalid elements style provider meta.',
|
|
6
6
|
} );
|
|
7
|
+
|
|
8
|
+
export const ActiveDocumentMustExistError = createError( {
|
|
9
|
+
code: 'active_document_must_exist',
|
|
10
|
+
message: 'Active document must exist.',
|
|
11
|
+
} );
|
package/src/hooks/{use-create-actions-by-provider.ts → use-get-styles-repository-create-action.ts}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { stylesRepository } from '../styles-repository';
|
|
4
|
-
import { type StylesProvider } from '../
|
|
4
|
+
import { type StylesProvider } from '../types';
|
|
5
5
|
|
|
6
6
|
type CreateAction = Required< StylesProvider[ 'actions' ] >[ 'create' ];
|
|
7
7
|
type CreateTuple = [ StylesProvider, CreateAction ];
|
|
8
8
|
|
|
9
|
-
export function
|
|
9
|
+
export function useGetStylesRepositoryCreateAction() {
|
|
10
10
|
return useMemo( () => {
|
|
11
|
-
|
|
11
|
+
const createActions = stylesRepository
|
|
12
12
|
.getProviders()
|
|
13
13
|
.map< CreateTuple | null >( ( provider ) => {
|
|
14
14
|
if ( ! provider.actions.create ) {
|
|
@@ -18,5 +18,12 @@ export function useCreateActionsByProvider() {
|
|
|
18
18
|
return [ provider, provider.actions.create ];
|
|
19
19
|
} )
|
|
20
20
|
.filter( ( item ) => !! item );
|
|
21
|
+
|
|
22
|
+
if ( createActions.length === 1 ) {
|
|
23
|
+
return createActions[ 0 ];
|
|
24
|
+
} else if ( createActions.length === 0 ) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
throw new Error( 'Multiple providers with create action found in styles repository.' );
|
|
21
28
|
}, [] );
|
|
22
29
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
export
|
|
2
|
-
type StylesProvider,
|
|
3
|
-
type UpdateActionPayload,
|
|
4
|
-
type Meta,
|
|
5
|
-
type UpdatePropsActionPayload,
|
|
6
|
-
} from './utils/create-styles-repository';
|
|
1
|
+
export * from './types';
|
|
7
2
|
|
|
8
3
|
export { stylesRepository } from './styles-repository';
|
|
9
4
|
export { useProviders } from './hooks/use-providers';
|
|
10
|
-
export {
|
|
11
|
-
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
5
|
+
export { useGetStylesRepositoryCreateAction } from './hooks/use-get-styles-repository-create-action';
|
|
6
|
+
export { validateStyleLabel } from './utils/validate-style-label';
|
|
7
|
+
export { createStylesProvider, type CreateStylesProviderOptions } from './utils/create-styles-provider';
|
|
8
|
+
export { isElementsStylesProvider } from './utils/is-elements-styles-provider';
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
export { ELEMENTS_BASE_STYLES_PROVIDER_KEY } from './providers/element-base-styles-provider';
|
|
11
|
+
export {
|
|
12
|
+
ELEMENTS_STYLES_PROVIDER_KEY_PREFIX,
|
|
13
|
+
ELEMENTS_STYLES_RESERVED_LABEL,
|
|
14
|
+
} from './providers/document-elements-styles-provider';
|
|
16
15
|
|
|
17
|
-
init
|
|
16
|
+
export { init } from './init';
|
package/src/init.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { documentElementsStylesProvider } from './providers/document-elements-styles-provider';
|
|
2
|
+
import { elementBaseStylesProvider } from './providers/element-base-styles-provider';
|
|
3
3
|
import { stylesRepository } from './styles-repository';
|
|
4
4
|
|
|
5
5
|
export function init() {
|
|
6
|
-
stylesRepository.register(
|
|
6
|
+
stylesRepository.register( documentElementsStylesProvider );
|
|
7
7
|
stylesRepository.register( elementBaseStylesProvider );
|
|
8
8
|
}
|