@emailmaker/extensions-app 0.9.0-dev.1

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/types.d.ts ADDED
@@ -0,0 +1,542 @@
1
+ import { IPluginConstructor, Instance, PluginRegistry } from '@emailmaker/emailmaker';
2
+
3
+ interface IDisposable {
4
+ dispose(): void;
5
+ }
6
+ /**
7
+ * Unique identifier for a UI component.
8
+ * @template P The type of the component's props
9
+ */
10
+ type ComponentId$1<P = void> = string & {
11
+ propsType?: P;
12
+ };
13
+ /**
14
+ * Represents a component type with its props.
15
+ */
16
+ type ComponentType$1<Props> = {
17
+ type: ComponentId$1<Props>;
18
+ props: Props;
19
+ };
20
+ /**
21
+ * Extensible registry of component inputs accepted by core extension APIs.
22
+ * React-specific variants are added by the React adapter package.
23
+ */
24
+ interface ComponentInputRegistry$1<Props = unknown> {
25
+ componentType: ComponentType$1<Props>;
26
+ componentId: ComponentId$1<Props>;
27
+ }
28
+ /**
29
+ * Supported component input accepted by core extension APIs.
30
+ * Registered React component values live in the React adapter package.
31
+ */
32
+ type ComponentInput$1<Props = unknown> = ComponentInputRegistry$1<Props>[keyof ComponentInputRegistry$1<Props>];
33
+ /**
34
+ * UI element that can be a primitive or a registered component descriptor.
35
+ */
36
+ type UIElement = string | number | boolean | null | undefined | ComponentInput$1<any>;
37
+ /**
38
+ * Identifier type for message service.
39
+ */
40
+ type Identifier$1<Type0 = any, Type1 = any, Type2 = any> = {
41
+ type0?: Type0;
42
+ type1: Type1;
43
+ type2: Type2;
44
+ } & string;
45
+ /**
46
+ * Type that can be a Promise or a value.
47
+ */
48
+ type MayBePromise$1<Value> = Promise<Value> | Value;
49
+ /**
50
+ * Information about an element.
51
+ */
52
+ interface ElementInfo {
53
+ html: string;
54
+ name: string;
55
+ }
56
+ /**
57
+ * Represents an element that can be used for building UI.
58
+ */
59
+ interface Element {
60
+ title?: UIElement;
61
+ fallbackTooltip?: UIElement;
62
+ icon?: UIElement;
63
+ html: string;
64
+ className?: string;
65
+ name: string;
66
+ }
67
+ /**
68
+ * API for managing elements in the editor.
69
+ */
70
+ interface IElementsApi {
71
+ /**
72
+ * Retrieves a list of all elements.
73
+ */
74
+ getNames(): Promise<ElementInfo[]>;
75
+ /**
76
+ * Updates an existing element.
77
+ */
78
+ update(name: string, element: Element): IDisposable;
79
+ /**
80
+ * Deletes an element by its name.
81
+ */
82
+ delete(name: string): void;
83
+ /**
84
+ * Inserts a new element at a specified position.
85
+ */
86
+ insert(element: Element, position?: number): IDisposable;
87
+ /**
88
+ * Fires when elements are injected to HTML.
89
+ */
90
+ handleInject(listener: (elementInfo: {
91
+ name: string;
92
+ className: string;
93
+ html: string;
94
+ }) => void, priority?: number, thisArg?: any): IDisposable;
95
+ }
96
+ /**
97
+ * API for interacting with the MessageService.
98
+ * Provides methods to send and receive messages, as well as manage event listeners.
99
+ */
100
+ interface IMessageServiceApi {
101
+ /**
102
+ * Sends a message through MessageService.
103
+ */
104
+ send<Type>(messageTypeId: Identifier$1<Type>, data: Type, queued?: boolean): void;
105
+ send(data: any, queued?: boolean): void;
106
+ /**
107
+ * Sends an asynchronous message and waits for a response.
108
+ */
109
+ sendAsync<Type, Result>(messageTypeId: Identifier$1<Type, Result>, data: Type, queued?: boolean): Promise<Result | void>;
110
+ /**
111
+ * Adds a global event listener for message events.
112
+ */
113
+ addListener(listener: (e: MessageEvent) => void): IDisposable;
114
+ /**
115
+ * Adds a listener for a specific message type.
116
+ */
117
+ addListener<Type = any>(messageTypeId: Identifier$1<Type>, listener: (value: Type) => void, priority?: number): IDisposable;
118
+ /**
119
+ * Adds an asynchronous listener for a specific message type.
120
+ */
121
+ addListenerAsync<Type = any, Result = any>(messageTypeId: Identifier$1<Type, Result>, listener: (value: Type) => MayBePromise$1<Result>, priority?: number): IDisposable;
122
+ /**
123
+ * Adds a listener for the initialization event.
124
+ */
125
+ onInit(listener: (target: Window) => void, immediately?: boolean, priority?: number): IDisposable;
126
+ /**
127
+ * Checks whether initialization has been completed.
128
+ */
129
+ isInited(): boolean;
130
+ }
131
+ /**
132
+ * Mouse position type.
133
+ */
134
+ type MousePosition = {
135
+ x: number;
136
+ y: number;
137
+ } | null;
138
+ /**
139
+ * Modal props interface.
140
+ */
141
+ interface ModalProps {
142
+ open?: boolean;
143
+ confirmLoading?: boolean;
144
+ closable?: boolean;
145
+ onOk?: (e: MouseEvent) => void;
146
+ onCancel?: (e: MouseEvent) => void;
147
+ afterClose?: () => void;
148
+ afterOpenChange?: (open: boolean) => void;
149
+ centered?: boolean;
150
+ width?: string | number;
151
+ footer?: UIElement;
152
+ okText?: UIElement;
153
+ okType?: 'default' | 'primary' | 'dashed' | 'link' | 'text' | 'danger';
154
+ cancelText?: UIElement;
155
+ maskClosable?: boolean;
156
+ forceRender?: boolean;
157
+ destroyOnClose?: boolean;
158
+ style?: any;
159
+ wrapClassName?: string;
160
+ maskTransitionName?: string;
161
+ transitionName?: string;
162
+ className?: string;
163
+ rootClassName?: string;
164
+ getContainer?: string | HTMLElement | (() => HTMLElement) | false;
165
+ zIndex?: number;
166
+ mask?: boolean;
167
+ keyboard?: boolean;
168
+ wrapProps?: any;
169
+ prefixCls?: string;
170
+ closeIcon?: UIElement;
171
+ focusTriggerAfterClose?: boolean;
172
+ mousePosition?: MousePosition;
173
+ }
174
+ /**
175
+ * Configuration interface for modal windows.
176
+ */
177
+ interface ModalConfig<Props = unknown> {
178
+ type?: 'confirm' | 'info' | 'success' | 'error' | 'warning';
179
+ title?: UIElement;
180
+ content: ComponentInput$1<Props>;
181
+ width?: number | string;
182
+ closable?: boolean;
183
+ onOk?: () => void | Promise<void>;
184
+ onClose?: () => void;
185
+ modalProps?: ModalProps;
186
+ }
187
+ /**
188
+ * ModalApi interface for managing modal windows in plugins.
189
+ */
190
+ interface IModalApi {
191
+ /**
192
+ * Opens a modal window.
193
+ * @returns A unique identifier for the modal window.
194
+ */
195
+ show<P>(config: ModalConfig<P>): string;
196
+ /**
197
+ * Closes a modal window by its identifier.
198
+ */
199
+ close(id: string): void;
200
+ /**
201
+ * Closes all open modal windows.
202
+ */
203
+ closeAll(): void;
204
+ /**
205
+ * Updates the parameters of an already open modal window.
206
+ */
207
+ update<P>(id: string, config: Partial<ModalConfig<P>>): void;
208
+ }
209
+ /**
210
+ * API for managing styles and scripts in a sandboxed environment (e.g., an iframe).
211
+ */
212
+ interface ISandboxScriptApi {
213
+ /**
214
+ * Registers an external CSS file inside the sandboxed environment.
215
+ */
216
+ registerSandboxCSS(url: string): IDisposable;
217
+ /**
218
+ * Registers a block of CSS code inside the sandboxed environment.
219
+ */
220
+ registerSandboxCSSCode(key: string, code: string): IDisposable;
221
+ /**
222
+ * Registers an external JavaScript file inside the sandboxed environment.
223
+ */
224
+ registerSandboxScript(url: string): IDisposable;
225
+ /**
226
+ * Registers a block of JavaScript code inside the sandboxed environment.
227
+ */
228
+ registerSandboxScriptCode(key: string, code: string): IDisposable;
229
+ }
230
+ /**
231
+ * Options for adding extra tabs in the interface.
232
+ */
233
+ interface ExtraTabOptions<Props = unknown> {
234
+ content: ComponentInput$1<Props>;
235
+ label?: string;
236
+ key: string;
237
+ className?: string;
238
+ }
239
+ /**
240
+ * Options for the settings panel.
241
+ */
242
+ interface SettingsPanelOptions<Props = unknown> {
243
+ content: ComponentInput$1<Props>;
244
+ caption?: string;
245
+ deletable?: boolean;
246
+ parent?: boolean;
247
+ advancedTabs?: ExtraTabOptions[];
248
+ }
249
+ /**
250
+ * API for managing the settings panel.
251
+ */
252
+ interface ISettingsPanelApi {
253
+ /**
254
+ * Opens the settings panel and displays the provided component.
255
+ */
256
+ showSettingsPanel<Props = unknown>(options: SettingsPanelOptions<Props>): void;
257
+ /**
258
+ * Closes the settings panel.
259
+ */
260
+ closeSettingsPanel(): void;
261
+ }
262
+ /**
263
+ * Unique identifier for a UI component.
264
+ * @template P The component's props type.
265
+ */
266
+ type ComponentId<P = void> = string & {
267
+ propsType?: P;
268
+ };
269
+ /**
270
+ * Represents a component type with its props.
271
+ */
272
+ type ComponentType<Props> = {
273
+ type: ComponentId<Props>;
274
+ props: Props;
275
+ };
276
+ /**
277
+ * Creates a unique identifier for a UI component.
278
+ * @template Props The component's props type.
279
+ * @param {string} [name] Optional identifier name.
280
+ * @returns {ComponentId<Props>} A unique component identifier.
281
+ */
282
+ declare function createComponentIdentifier<Props>(name?: string): ComponentId<Props>;
283
+ /**
284
+ * Extensible registry of component inputs accepted by core extension APIs.
285
+ * React-specific variants are added by @emailmaker/extensions-react.
286
+ */
287
+ interface ComponentInputRegistry<Props = unknown> {
288
+ componentType: ComponentType<Props>;
289
+ componentId: ComponentId<Props>;
290
+ }
291
+ /**
292
+ * Supported component input accepted by core extension APIs.
293
+ * React-specific component values are provided by @emailmaker/extensions-react.
294
+ */
295
+ type ComponentInput<Props = unknown> = ComponentInputRegistry<Props>[keyof ComponentInputRegistry<Props>];
296
+ /**
297
+ * Identifier type for message service.
298
+ */
299
+ type Identifier<Type0 = any, Type1 = any, Type2 = any> = {
300
+ type0?: Type0;
301
+ type1: Type1;
302
+ type2: Type2;
303
+ } & string;
304
+ /**
305
+ * Type that can be a Promise or a value.
306
+ */
307
+ type MayBePromise<Value> = Promise<Value> | Value;
308
+ /**
309
+ * This interface defines a "DOM component" which represents a component that directly manipulates the DOM.
310
+ */
311
+ interface IDomComponent<P> {
312
+ node: Node;
313
+ update?(props: P, children?: Node[]): IDomComponent<P> | void;
314
+ dispose?(): void;
315
+ }
316
+ /**
317
+ * Factory function for creating DOM components.
318
+ */
319
+ interface IDomComponentFactory<P> {
320
+ (props: P, children?: Node[]): IDomComponent<P>;
321
+ }
322
+ /**
323
+ * This interface defines a registry for DOM components.
324
+ */
325
+ interface IDomComponentRegistry {
326
+ add<Props>(componentId: ComponentId<Props>, domComponentFactory: IDomComponentFactory<Props>): IDisposable;
327
+ }
328
+ /**
329
+ * Global DomComponentRegistry singleton.
330
+ */
331
+ declare const DomComponentRegistry: IDomComponentRegistry;
332
+ // ============================================
333
+ // EmailSettingsApi
334
+ // ============================================
335
+ /**
336
+ * API for working with email settings.
337
+ */
338
+ interface EmailSettingsApi {
339
+ getEmailLayoutSettings(): Promise<EmailLayoutSettings>;
340
+ setEmailLayoutSettings(settings: Partial<EmailLayoutSettings>): Promise<void>;
341
+ getEmailContentStyles(): Promise<EmailContentStyles>;
342
+ setEmailContentStyles(contentStyles: Partial<EmailContentStyles>): Promise<void>;
343
+ }
344
+ /**
345
+ * Email layout settings.
346
+ */
347
+ interface EmailLayoutSettings {
348
+ backgroundColor: string;
349
+ backgroundImage: Array<{
350
+ type: 'url';
351
+ value: string;
352
+ }>;
353
+ backgroundPositionX: string;
354
+ backgroundPositionY: string;
355
+ backgroundRepeat: string;
356
+ backgroundSize?: string;
357
+ backgroundColorContent?: string;
358
+ textStrong: boolean;
359
+ textItalic: boolean;
360
+ textUnderline: boolean;
361
+ width?: {
362
+ value?: number;
363
+ dim?: string;
364
+ };
365
+ responsive?: {
366
+ shutdown?: boolean;
367
+ styles?: boolean;
368
+ };
369
+ }
370
+ /**
371
+ * Email content styles.
372
+ */
373
+ interface EmailContentStyles {
374
+ text?: {
375
+ fontFamily?: string[] | string;
376
+ fontSize?: number;
377
+ fontSizeDim?: string;
378
+ lineHeight?: number;
379
+ lineHeightDim?: string;
380
+ color?: string;
381
+ contrastColor?: string;
382
+ textAlign?: string;
383
+ paddingBottom?: number;
384
+ paddingBottomDim?: string;
385
+ };
386
+ headings?: {
387
+ fontFamily?: string[] | string;
388
+ fontSize?: number;
389
+ fontSizeDim?: string;
390
+ lineHeight?: number;
391
+ lineHeightDim?: string;
392
+ color?: string;
393
+ contrastColor?: string;
394
+ textAlign?: string;
395
+ paddingTop?: number;
396
+ paddingTopDim?: string;
397
+ paddingBottom?: number;
398
+ paddingBottomDim?: string;
399
+ letterSpacing?: number;
400
+ letterSpacingDim?: string;
401
+ bold?: boolean;
402
+ italic?: boolean;
403
+ };
404
+ links?: {
405
+ color?: string;
406
+ contrastColor?: string;
407
+ underline?: boolean;
408
+ };
409
+ buttons?: {
410
+ fontFamily?: string[] | string;
411
+ fontSize?: number;
412
+ fontSizeDim?: string;
413
+ letterSpacing?: number;
414
+ letterSpacingDim?: string;
415
+ color?: string;
416
+ contrastColor?: string;
417
+ bold?: boolean;
418
+ italic?: boolean;
419
+ backgroundColor?: string;
420
+ contrastBackgroundColor?: string;
421
+ marginTop?: number;
422
+ marginTopDim?: string;
423
+ marginBottom?: number;
424
+ marginBottomDim?: string;
425
+ border?: {
426
+ all?: number | null;
427
+ top?: number | null;
428
+ right?: number | null;
429
+ bottom?: number | null;
430
+ left?: number | null;
431
+ };
432
+ borderRadius?: {
433
+ all?: number | null;
434
+ topLeft?: number | null;
435
+ topRight?: number | null;
436
+ bottomRight?: number | null;
437
+ bottomLeft?: number | null;
438
+ };
439
+ textAlign?: string;
440
+ padding?: {
441
+ all?: number | null;
442
+ top?: number | null;
443
+ right?: number | null;
444
+ bottom?: number | null;
445
+ left?: number | null;
446
+ };
447
+ };
448
+ block?: {
449
+ backgroundColor?: string;
450
+ contrastBackgroundColor?: string;
451
+ padding?: {
452
+ all?: number | null;
453
+ top?: number | null;
454
+ right?: number | null;
455
+ bottom?: number | null;
456
+ left?: number | null;
457
+ };
458
+ };
459
+ cards?: {
460
+ contrastBackgroundColor?: string;
461
+ contrastTextColor?: string;
462
+ baseBackgroundColor?: string;
463
+ baseTextColor?: string;
464
+ border?: {
465
+ all?: number | null;
466
+ top?: number | null;
467
+ right?: number | null;
468
+ bottom?: number | null;
469
+ left?: number | null;
470
+ };
471
+ borderRadius?: {
472
+ all?: number | null;
473
+ topLeft?: number | null;
474
+ topRight?: number | null;
475
+ bottomRight?: number | null;
476
+ bottomLeft?: number | null;
477
+ };
478
+ };
479
+ }
480
+ // ============================================
481
+ // Deprecated facade classes
482
+ // ============================================
483
+ /**
484
+ * @deprecated Use `editor.use('SandboxScriptApi')` to access built-in platform APIs.
485
+ * This compatibility facade will be removed in a future plugin-system package release.
486
+ */
487
+ declare class SandboxScriptApi {
488
+ constructor(editor: Instance);
489
+ }
490
+ interface SandboxScriptApi extends ISandboxScriptApi {}
491
+ /**
492
+ * @deprecated Use `editor.use('ElementsApi')` to access built-in platform APIs.
493
+ * This compatibility facade will be removed in a future plugin-system package release.
494
+ */
495
+ declare class ElementsApi {
496
+ constructor(editor: Instance);
497
+ }
498
+ interface ElementsApi extends IElementsApi {}
499
+ /**
500
+ * @deprecated Use `editor.use('MessageService')` to access built-in platform APIs.
501
+ * This compatibility facade will be removed in a future plugin-system package release.
502
+ */
503
+ declare class MessageService {
504
+ constructor(editor: Instance);
505
+ }
506
+ interface MessageService extends IMessageServiceApi {}
507
+ /**
508
+ * @deprecated Use `editor.use('SettingsPanelApi')` to access built-in platform APIs.
509
+ * This compatibility facade will be removed in a future plugin-system package release.
510
+ */
511
+ declare class SettingsPanelApi {
512
+ constructor(editor: Instance);
513
+ }
514
+ interface SettingsPanelApi extends ISettingsPanelApi {}
515
+ /**
516
+ * @deprecated Use `editor.use('ModalApi')` to access built-in platform APIs.
517
+ * This compatibility facade will be removed in a future plugin-system package release.
518
+ */
519
+ declare class ModalApi {
520
+ constructor(editor: Instance);
521
+ }
522
+ interface ModalApi extends IModalApi {}
523
+ /**
524
+ * @deprecated Use `editor.use('EmailSettingsApi')` to access built-in platform APIs.
525
+ * This compatibility facade will be removed in a future plugin-system package release.
526
+ */
527
+ declare class EmailSettingsApi {
528
+ constructor(editor: Instance);
529
+ }
530
+ declare module '@emailmaker/emailmaker' {
531
+ interface PluginTypeMap {
532
+ SandboxScriptApi: IPluginConstructor<ISandboxScriptApi>;
533
+ ElementsApi: IPluginConstructor<IElementsApi>;
534
+ MessageService: IPluginConstructor<IMessageServiceApi>;
535
+ SettingsPanelApi: IPluginConstructor<ISettingsPanelApi>;
536
+ ModalApi: IPluginConstructor<IModalApi>;
537
+ EmailSettingsApi: IPluginConstructor<EmailSettingsApi>;
538
+ }
539
+ }
540
+ declare const pluginRegistry: PluginRegistry;
541
+ declare const version: string;
542
+ export { ComponentId, ComponentInput, ComponentInputRegistry, ComponentType, DomComponentRegistry, ElementsApi, EmailContentStyles, EmailLayoutSettings, EmailSettingsApi, type IDisposable, IDomComponent, IDomComponentFactory, IDomComponentRegistry, Identifier, MayBePromise, MessageService, ModalApi, SandboxScriptApi, SettingsPanelApi, createComponentIdentifier, pluginRegistry, version };