@groovymedia/easy-email-core 4.12.2-2
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/lib/blocks/advanced/blocks/index.d.ts +15 -0
- package/lib/blocks/advanced/generateAdvancedBlock.d.ts +60 -0
- package/lib/blocks/advanced/generateAdvancedContentBlock.d.ts +6 -0
- package/lib/blocks/advanced/generateAdvancedLayoutBlock.d.ts +7 -0
- package/lib/blocks/advanced/index.d.ts +19 -0
- package/lib/blocks/index.d.ts +2 -0
- package/lib/blocks/standard/Accordion/index.d.ts +17 -0
- package/lib/blocks/standard/AccordionElement/index.d.ts +16 -0
- package/lib/blocks/standard/AccordionText/index.d.ts +12 -0
- package/lib/blocks/standard/AccordionTitle/index.d.ts +9 -0
- package/lib/blocks/standard/Button/index.d.ts +30 -0
- package/lib/blocks/standard/Carousel/index.d.ts +26 -0
- package/lib/blocks/standard/Column/index.d.ts +13 -0
- package/lib/blocks/standard/Divider/index.d.ts +11 -0
- package/lib/blocks/standard/Group/index.d.ts +8 -0
- package/lib/blocks/standard/Hero/index.d.ts +15 -0
- package/lib/blocks/standard/Image/index.d.ts +18 -0
- package/lib/blocks/standard/Navbar/index.d.ts +27 -0
- package/lib/blocks/standard/Page/index.d.ts +29 -0
- package/lib/blocks/standard/Raw/index.d.ts +5 -0
- package/lib/blocks/standard/Section/index.d.ts +19 -0
- package/lib/blocks/standard/Social/index.d.ts +47 -0
- package/lib/blocks/standard/Spacer/index.d.ts +7 -0
- package/lib/blocks/standard/Table/index.d.ts +5 -0
- package/lib/blocks/standard/Template/index.d.ts +5 -0
- package/lib/blocks/standard/Text/index.d.ts +20 -0
- package/lib/blocks/standard/Wrapper/index.d.ts +12 -0
- package/lib/blocks/standard/index.d.ts +45 -0
- package/lib/components/Accordion.d.ts +7 -0
- package/lib/components/AccordionElement.d.ts +7 -0
- package/lib/components/AccordionText.d.ts +7 -0
- package/lib/components/AccordionTitle.d.ts +7 -0
- package/lib/components/BasicBlock.d.ts +7 -0
- package/lib/components/BlockRenderer.d.ts +4 -0
- package/lib/components/Button.d.ts +7 -0
- package/lib/components/Carousel.d.ts +7 -0
- package/lib/components/Column.d.ts +7 -0
- package/lib/components/Divider.d.ts +7 -0
- package/lib/components/Group.d.ts +7 -0
- package/lib/components/Hero.d.ts +7 -0
- package/lib/components/Image.d.ts +7 -0
- package/lib/components/MjmlBlock.d.ts +10 -0
- package/lib/components/Navbar.d.ts +7 -0
- package/lib/components/Page.d.ts +7 -0
- package/lib/components/Raw.d.ts +7 -0
- package/lib/components/Section.d.ts +7 -0
- package/lib/components/Social.d.ts +7 -0
- package/lib/components/Spacer.d.ts +7 -0
- package/lib/components/Table.d.ts +7 -0
- package/lib/components/Template.d.ts +8 -0
- package/lib/components/Text.d.ts +7 -0
- package/lib/components/Wrapper.d.ts +7 -0
- package/lib/components/index.d.ts +23 -0
- package/lib/constants.d.ts +42 -0
- package/lib/index.cjs.js +111 -0
- package/lib/index.cjs.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.es.js +5997 -0
- package/lib/index.es.js.map +1 -0
- package/lib/typings/index.d.ts +41 -0
- package/lib/utils/BlockManager.d.ts +16 -0
- package/lib/utils/I18nManager.d.ts +7 -0
- package/lib/utils/ImageManager.d.ts +13 -0
- package/lib/utils/JsonToMjml.d.ts +12 -0
- package/lib/utils/TemplateEngineManager.d.ts +18 -0
- package/lib/utils/ancestorOf.d.ts +1 -0
- package/lib/utils/block.d.ts +34 -0
- package/lib/utils/classnames.d.ts +1 -0
- package/lib/utils/createBlock.d.ts +2 -0
- package/lib/utils/createBlockDataByType.d.ts +2 -0
- package/lib/utils/createCustomBlock.d.ts +2 -0
- package/lib/utils/generaMjmlMetaData.d.ts +2 -0
- package/lib/utils/getAdapterAttributesString.d.ts +2 -0
- package/lib/utils/getImg.d.ts +15 -0
- package/lib/utils/getPlaceholder.d.ts +2 -0
- package/lib/utils/getPreviewClassName.d.ts +1 -0
- package/lib/utils/index.d.ts +16 -0
- package/lib/utils/isAdvancedBlock.d.ts +1 -0
- package/lib/utils/isProductionMode.d.ts +24 -0
- package/lib/utils/isValidBlockData.d.ts +2 -0
- package/lib/utils/mergeBlock.d.ts +2 -0
- package/lib/utils/parseReactBlockToBlockData.d.ts +2 -0
- package/package.json +91 -0
- package/readme.md +581 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { IPage } from '../blocks';
|
|
2
|
+
export interface IBlock<T extends IBlockData = IBlockData> {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
create: (payload?: RecursivePartial<T>) => T;
|
|
6
|
+
validParentType: string[];
|
|
7
|
+
render: (params: {
|
|
8
|
+
data: T;
|
|
9
|
+
idx?: string | null;
|
|
10
|
+
mode: 'testing' | 'production';
|
|
11
|
+
context?: IPage;
|
|
12
|
+
dataSource?: {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
keepClassName?: boolean;
|
|
17
|
+
renderPortal?: (props: Omit<Parameters<IBlock<T>['render']>[0], 'renderPortal'> & {
|
|
18
|
+
refEle: HTMLElement;
|
|
19
|
+
}) => React.ReactNode;
|
|
20
|
+
}) => React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
export interface IBlockData<Attr extends Record<string, string> = any, Data extends {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
} = any> {
|
|
25
|
+
title?: string;
|
|
26
|
+
type: string;
|
|
27
|
+
data: {
|
|
28
|
+
value: Data;
|
|
29
|
+
hidden?: boolean | string;
|
|
30
|
+
};
|
|
31
|
+
attributes: Attr & {
|
|
32
|
+
'css-class'?: string;
|
|
33
|
+
};
|
|
34
|
+
children: IBlockData[];
|
|
35
|
+
}
|
|
36
|
+
export interface create<T extends any = any> {
|
|
37
|
+
(payload?: RecursivePartial<T>): T;
|
|
38
|
+
}
|
|
39
|
+
export declare type RecursivePartial<T> = {
|
|
40
|
+
[P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object ? RecursivePartial<T[P]> : T[P];
|
|
41
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IBlock, IBlockData } from '../typings';
|
|
2
|
+
export declare class BlockManager {
|
|
3
|
+
private static blocksMap;
|
|
4
|
+
private static autoCompletePath;
|
|
5
|
+
private static setAutoCompletePath;
|
|
6
|
+
static getBlocks(): Array<IBlock>;
|
|
7
|
+
static registerBlocks(blocksMap: {
|
|
8
|
+
[key: string]: IBlock;
|
|
9
|
+
}): void;
|
|
10
|
+
static getBlockByType<T extends IBlockData>(type: string): IBlock<T> | undefined;
|
|
11
|
+
static getBlocksByType(types: Array<string>): Array<IBlock | undefined>;
|
|
12
|
+
static getAutoCompleteFullPath(): {
|
|
13
|
+
[key: string]: string[][];
|
|
14
|
+
};
|
|
15
|
+
static getAutoCompletePath(type: string, targetType: string): Array<string> | null;
|
|
16
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare class I18nManager {
|
|
3
|
+
static localeData: Record<string, string>;
|
|
4
|
+
static setLocaleData(localeData: Record<string, string>): void;
|
|
5
|
+
static translate(key: string, placeholder?: React.ReactNode): string;
|
|
6
|
+
}
|
|
7
|
+
export declare const t: typeof I18nManager.translate;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare type ObjectString = {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
};
|
|
4
|
+
export declare class ImageManager {
|
|
5
|
+
private static map;
|
|
6
|
+
private static overrideMap;
|
|
7
|
+
static add(imgMap: ObjectString): void;
|
|
8
|
+
static get<T extends ObjectString>(name: keyof T): string;
|
|
9
|
+
static getOverrideMap(): {
|
|
10
|
+
[key: string]: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JsonToMjmlOption } from './isProductionMode';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { IBlockData } from '../typings';
|
|
4
|
+
declare type EmailRenderProps = {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
context?: IBlockData;
|
|
7
|
+
dataSource?: Record<string, any>;
|
|
8
|
+
mode: 'production' | 'testing';
|
|
9
|
+
};
|
|
10
|
+
export declare function JsonToMjml(options: JsonToMjmlOption): string;
|
|
11
|
+
export declare const useEmailRenderContext: () => EmailRenderProps;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AdvancedBlock } from '../blocks/advanced/generateAdvancedBlock';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
declare function generateIterationTemplate(option: NonNullable<AdvancedBlock['data']['value']['iteration']>, content: React.ReactElement): JSX.Element;
|
|
4
|
+
declare function generateConditionTemplate(option: NonNullable<AdvancedBlock['data']['value']['condition']>, content: React.ReactElement): JSX.Element;
|
|
5
|
+
interface IterationTemplate {
|
|
6
|
+
name: 'iteration';
|
|
7
|
+
templateGenerateFn: typeof generateIterationTemplate;
|
|
8
|
+
}
|
|
9
|
+
interface ConditionTemplate {
|
|
10
|
+
name: 'condition';
|
|
11
|
+
templateGenerateFn: typeof generateConditionTemplate;
|
|
12
|
+
}
|
|
13
|
+
export declare class TemplateEngineManager {
|
|
14
|
+
private static tags;
|
|
15
|
+
static setTag(option: IterationTemplate | ConditionTemplate): void;
|
|
16
|
+
static generateTagTemplate<T extends keyof typeof TemplateEngineManager['tags']>(name: T): typeof TemplateEngineManager['tags'][T];
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ancestorOf(type: string, targetType: string): number;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BlockType } from './../constants';
|
|
2
|
+
import { IBlock, IBlockData } from '../typings';
|
|
3
|
+
export declare function getPageIdx(): string;
|
|
4
|
+
export declare function getChildIdx(idx: string, index: number): string;
|
|
5
|
+
export declare function getNodeIdxClassName(idx: string): string;
|
|
6
|
+
export declare function getNodeTypeClassName(type: string): string;
|
|
7
|
+
export declare function getNodeIdxFromClassName(classList: DOMTokenList): string | undefined;
|
|
8
|
+
export declare function getNodeTypeFromClassName(classList: DOMTokenList | string): BlockType | null;
|
|
9
|
+
export declare const getIndexByIdx: (idx: string) => number;
|
|
10
|
+
export declare const getParentIdx: (idx: string) => string | undefined;
|
|
11
|
+
export declare const getValueByIdx: <T extends IBlockData<any, any>>(values: {
|
|
12
|
+
content: IBlockData;
|
|
13
|
+
}, idx: string) => T | null;
|
|
14
|
+
export declare const getParentByIdx: <T extends IBlockData<any, any> = IBlockData<any, any>>(values: {
|
|
15
|
+
content: IBlockData;
|
|
16
|
+
}, idx: string) => T | null;
|
|
17
|
+
export declare const getSiblingIdx: (sourceIndex: string, num: number) => string;
|
|
18
|
+
export declare const getParentByType: <T extends IBlockData<any, any>>(context: {
|
|
19
|
+
content: IBlockData;
|
|
20
|
+
}, idx: string, type: BlockType) => T | null;
|
|
21
|
+
export declare const getSameParent: (values: {
|
|
22
|
+
content: IBlockData;
|
|
23
|
+
}, idx: string, dragType: string) => {
|
|
24
|
+
parent: IBlockData;
|
|
25
|
+
parentIdx: string;
|
|
26
|
+
} | null;
|
|
27
|
+
export declare const getParenRelativeByType: <T extends IBlockData<any, any>>(context: {
|
|
28
|
+
content: IBlockData;
|
|
29
|
+
}, idx: string, type: BlockType) => {
|
|
30
|
+
parentIdx: string;
|
|
31
|
+
insertIndex: number;
|
|
32
|
+
parent: IBlockData;
|
|
33
|
+
} | null;
|
|
34
|
+
export declare const getValidChildBlocks: (type: BlockType) => IBlock[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function classnames(...rest: any[]): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const defaultImagesMap: {
|
|
2
|
+
IMAGE_01: string;
|
|
3
|
+
IMAGE_02: string;
|
|
4
|
+
IMAGE_03: string;
|
|
5
|
+
IMAGE_04: string;
|
|
6
|
+
IMAGE_59: string;
|
|
7
|
+
IMAGE_09: string;
|
|
8
|
+
IMAGE_10: string;
|
|
9
|
+
IMAGE_15: string;
|
|
10
|
+
IMAGE_16: string;
|
|
11
|
+
IMAGE_17: string;
|
|
12
|
+
IMAGE_31: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function getImg(name: keyof typeof defaultImagesMap): string;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPreviewClassName(idx: string | null, type: string): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { isValidBlockData } from './isValidBlockData';
|
|
2
|
+
export { JsonToMjml } from './JsonToMjml';
|
|
3
|
+
export { parseReactBlockToBlockData } from './parseReactBlockToBlockData';
|
|
4
|
+
export { createCustomBlock } from './createCustomBlock';
|
|
5
|
+
export { createBlock } from './createBlock';
|
|
6
|
+
export { createBlockDataByType } from './createBlockDataByType';
|
|
7
|
+
export { mergeBlock } from './mergeBlock';
|
|
8
|
+
export { getPreviewClassName } from './getPreviewClassName';
|
|
9
|
+
export { ancestorOf } from './ancestorOf';
|
|
10
|
+
export { BlockManager } from './BlockManager';
|
|
11
|
+
export { ImageManager } from './ImageManager';
|
|
12
|
+
export { TemplateEngineManager } from './TemplateEngineManager';
|
|
13
|
+
export { isAdvancedBlock } from './isAdvancedBlock';
|
|
14
|
+
export { I18nManager, t } from './I18nManager';
|
|
15
|
+
export { getAdapterAttributesString } from './getAdapterAttributesString';
|
|
16
|
+
export * from './block';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isAdvancedBlock(type: any): boolean;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { IBlockData } from '../typings';
|
|
2
|
+
export interface JsonToMjmlOptionProduction {
|
|
3
|
+
idx?: string | null;
|
|
4
|
+
data: IBlockData;
|
|
5
|
+
context?: IBlockData;
|
|
6
|
+
mode: 'production';
|
|
7
|
+
keepClassName?: boolean;
|
|
8
|
+
dataSource?: {
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
beautify?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface JsonToMjmlOptionDev {
|
|
14
|
+
data: IBlockData;
|
|
15
|
+
idx: string | null;
|
|
16
|
+
context?: IBlockData;
|
|
17
|
+
dataSource?: {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
mode: 'testing';
|
|
21
|
+
beautify?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare type JsonToMjmlOption = JsonToMjmlOptionDev | JsonToMjmlOptionProduction;
|
|
24
|
+
export declare const isProductionMode: (option: JsonToMjmlOption) => option is JsonToMjmlOptionProduction;
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@groovymedia/easy-email-core",
|
|
3
|
+
"license": "MIT",
|
|
4
|
+
"description": "Email editor",
|
|
5
|
+
"version": "4.12.2-2",
|
|
6
|
+
"author": "m-Ryan",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+ssh://git@github.com/m-Ryan/easy-email.git"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"email editor core"
|
|
13
|
+
],
|
|
14
|
+
"files": [
|
|
15
|
+
"lib"
|
|
16
|
+
],
|
|
17
|
+
"main": "lib/index.cjs.js",
|
|
18
|
+
"module": "lib/index.es.js",
|
|
19
|
+
"types": "lib/index.d.ts",
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "yarn build --watch",
|
|
22
|
+
"typings": "tsc --declaration --emitDeclarationOnly --project tsconfig.lib.json",
|
|
23
|
+
"build": "rimraf lib && npm run typings && tsc-alias && vite build --config vite.config.ts",
|
|
24
|
+
"block": "ts-node -r tsconfig-paths/register scripts/generateBlockJSX.ts",
|
|
25
|
+
"format": "eslint --fix --ext .tsx,.ts,.tsx src/",
|
|
26
|
+
"test": "jest --coverage"
|
|
27
|
+
},
|
|
28
|
+
"husky": {
|
|
29
|
+
"hooks": {
|
|
30
|
+
"pre-commit": "yarn test && yarn lint-staged"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"lint-staged": {
|
|
34
|
+
"src/*.{js,jsx,ts,tsx}, example/*.{js,jsx,ts,tsx}": [
|
|
35
|
+
"yarn lint"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@babel/core": "^7.15.0",
|
|
40
|
+
"@babel/preset-env": "^7.15.0",
|
|
41
|
+
"@babel/preset-react": "^7.14.5",
|
|
42
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
43
|
+
"@types/he": "^1.2.0",
|
|
44
|
+
"@types/jest": "^26.0.24",
|
|
45
|
+
"@types/js-beautify": "^1.13.3",
|
|
46
|
+
"@types/jsdom": "^16.2.13",
|
|
47
|
+
"@types/lodash": "^4.14.178",
|
|
48
|
+
"@types/node": "^16.11.7",
|
|
49
|
+
"@types/react": "^18.2.2",
|
|
50
|
+
"@types/react-dom": "^18.2.3",
|
|
51
|
+
"@types/uuid": "^8.3.4",
|
|
52
|
+
"@typescript-eslint/eslint-plugin": "^4.28.3",
|
|
53
|
+
"@typescript-eslint/parser": "^4.28.3",
|
|
54
|
+
"babel-jest": "^27.0.6",
|
|
55
|
+
"eslint": "^7.31.0",
|
|
56
|
+
"eslint-config-prettier": "^8.3.0",
|
|
57
|
+
"eslint-loader": "^4.0.2",
|
|
58
|
+
"eslint-plugin-import": "^2.23.4",
|
|
59
|
+
"eslint-plugin-prettier": "^3.4.0",
|
|
60
|
+
"eslint-plugin-react": "^7.24.0",
|
|
61
|
+
"eslint-plugin-react-hooks": "^4.2.0",
|
|
62
|
+
"jest": "^27.0.6",
|
|
63
|
+
"jsdom": "^17.0.0",
|
|
64
|
+
"liquidjs": "^9.40.0",
|
|
65
|
+
"react": "^18.2.0",
|
|
66
|
+
"react-dom": "^18.2.0",
|
|
67
|
+
"rimraf": "^3.0.2",
|
|
68
|
+
"ts-node": "^10.4.0",
|
|
69
|
+
"tsc-alias": "^1.4.1",
|
|
70
|
+
"tsconfig-paths": "^3.11.0",
|
|
71
|
+
"typescript": "^4.4.4",
|
|
72
|
+
"vite": "^2.5.6"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"he": "^1.2.0",
|
|
76
|
+
"js-beautify": "^1.14.4",
|
|
77
|
+
"lodash": "^4.17.21",
|
|
78
|
+
"uuid": "^8.3.2"
|
|
79
|
+
},
|
|
80
|
+
"peerDependencies": {
|
|
81
|
+
"react": "^18.2.0",
|
|
82
|
+
"react-dom": "^18.2.0"
|
|
83
|
+
},
|
|
84
|
+
"bugs": {
|
|
85
|
+
"url": "https://github.com/m-Ryan/easy-email/issues"
|
|
86
|
+
},
|
|
87
|
+
"homepage": "https://github.com/m-Ryan/easy-email#readme",
|
|
88
|
+
"directories": {
|
|
89
|
+
"lib": "lib"
|
|
90
|
+
}
|
|
91
|
+
}
|