@webiny/lexical-theme 0.0.0-unstable.a4637c5ce6 β 0.0.0-unstable.a4f3e4ea8b
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/README.md +9 -4
- package/Theme.d.ts +28 -0
- package/Theme.js +71 -0
- package/Theme.js.map +1 -0
- package/createLexicalEditorTokens.d.ts +2 -0
- package/createLexicalEditorTokens.js +105 -0
- package/createLexicalEditorTokens.js.map +1 -0
- package/createTheme.d.ts +8 -7
- package/createTheme.js +8 -101
- package/createTheme.js.map +1 -1
- package/index.d.ts +4 -5
- package/index.js +4 -62
- package/package.json +12 -13
- package/toTypographyMap.d.ts +2 -0
- package/toTypographyMap.js +11 -0
- package/toTypographyMap.js.map +1 -0
- package/types.d.ts +16 -12
- package/types.js +0 -7
- package/index.js.map +0 -1
- package/types.js.map +0 -1
- package/utils/findTypographyStyleByHtmlTag.d.ts +0 -8
- package/utils/findTypographyStyleByHtmlTag.js +0 -19
- package/utils/findTypographyStyleByHtmlTag.js.map +0 -1
- package/utils/styleObjectToString.d.ts +0 -2
- package/utils/styleObjectToString.js +0 -24
- package/utils/styleObjectToString.js.map +0 -1
- package/utils/toTypographyEmotionMap.d.ts +0 -4
- package/utils/toTypographyEmotionMap.js +0 -45
- package/utils/toTypographyEmotionMap.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# @webiny/lexical-theme
|
|
2
2
|
|
|
3
|
-
[!
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> Itβs **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
π **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/Theme.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { EditorThemeClasses } from "lexical";
|
|
2
|
+
import type { ColorValue, FontSizes, EditorTheme, TypographyValue } from "./types.js";
|
|
3
|
+
export declare class Theme {
|
|
4
|
+
static cache: Record<string, Theme>;
|
|
5
|
+
static lastUsedTheme: Theme | null;
|
|
6
|
+
readonly tokens: EditorThemeClasses;
|
|
7
|
+
private readonly _colors;
|
|
8
|
+
private readonly _fontSizes;
|
|
9
|
+
private readonly _typography;
|
|
10
|
+
private readonly _typographyMap;
|
|
11
|
+
private readonly _allowCustomColors;
|
|
12
|
+
constructor(params: {
|
|
13
|
+
colors: EditorTheme["colors"];
|
|
14
|
+
typography: EditorTheme["typography"];
|
|
15
|
+
fontSizes: EditorTheme["fontSizes"];
|
|
16
|
+
tokens: EditorThemeClasses;
|
|
17
|
+
allowCustomColors?: boolean;
|
|
18
|
+
});
|
|
19
|
+
static empty(): Theme;
|
|
20
|
+
static from(lexicalTheme: EditorThemeClasses): Theme;
|
|
21
|
+
get colors(): ColorValue[];
|
|
22
|
+
get typography(): Record<string, TypographyValue[]>;
|
|
23
|
+
get fontSizes(): FontSizes;
|
|
24
|
+
get allowCustomColors(): boolean;
|
|
25
|
+
getTypographyById(id: string): TypographyValue;
|
|
26
|
+
getTypographyByTag(tag: string | string[]): TypographyValue | undefined;
|
|
27
|
+
private toTypographyMap;
|
|
28
|
+
}
|
package/Theme.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
class Theme {
|
|
2
|
+
static{
|
|
3
|
+
this.cache = {};
|
|
4
|
+
}
|
|
5
|
+
static{
|
|
6
|
+
this.lastUsedTheme = null;
|
|
7
|
+
}
|
|
8
|
+
constructor(params){
|
|
9
|
+
this._colors = params.colors;
|
|
10
|
+
this._typography = params.typography;
|
|
11
|
+
this._fontSizes = params.fontSizes;
|
|
12
|
+
this._typographyMap = this.toTypographyMap(params.typography);
|
|
13
|
+
this.tokens = params.tokens;
|
|
14
|
+
this._allowCustomColors = params.allowCustomColors ?? false;
|
|
15
|
+
}
|
|
16
|
+
static empty() {
|
|
17
|
+
return new Theme({
|
|
18
|
+
colors: [],
|
|
19
|
+
typography: {},
|
|
20
|
+
fontSizes: [],
|
|
21
|
+
tokens: {},
|
|
22
|
+
allowCustomColors: false
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
static from(lexicalTheme) {
|
|
26
|
+
const { $colors, $typography, $fontSizes, $cacheKey, ...tokens } = lexicalTheme;
|
|
27
|
+
if (!$colors) return Theme.lastUsedTheme ?? Theme.empty();
|
|
28
|
+
if (!Theme.cache[$cacheKey]) Theme.cache[$cacheKey] = new Theme({
|
|
29
|
+
colors: $colors,
|
|
30
|
+
typography: $typography,
|
|
31
|
+
fontSizes: $fontSizes,
|
|
32
|
+
tokens
|
|
33
|
+
});
|
|
34
|
+
Theme.lastUsedTheme = Theme.cache[$cacheKey];
|
|
35
|
+
return Theme.cache[$cacheKey];
|
|
36
|
+
}
|
|
37
|
+
get colors() {
|
|
38
|
+
return this._colors;
|
|
39
|
+
}
|
|
40
|
+
get typography() {
|
|
41
|
+
return this._typography;
|
|
42
|
+
}
|
|
43
|
+
get fontSizes() {
|
|
44
|
+
return this._fontSizes;
|
|
45
|
+
}
|
|
46
|
+
get allowCustomColors() {
|
|
47
|
+
return this._allowCustomColors;
|
|
48
|
+
}
|
|
49
|
+
getTypographyById(id) {
|
|
50
|
+
return this._typographyMap[id];
|
|
51
|
+
}
|
|
52
|
+
getTypographyByTag(tag) {
|
|
53
|
+
const tags = Array.isArray(tag) ? tag : [
|
|
54
|
+
tag
|
|
55
|
+
];
|
|
56
|
+
for(const styleId in this._typographyMap){
|
|
57
|
+
const style = this._typographyMap[styleId];
|
|
58
|
+
if (tags.includes(style.tag)) return style;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
toTypographyMap(typography) {
|
|
62
|
+
return Object.keys(typography).reduce((acc, key)=>{
|
|
63
|
+
const items = typography[key];
|
|
64
|
+
for (const item of items)acc[item.id] = item;
|
|
65
|
+
return acc;
|
|
66
|
+
}, {});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export { Theme };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=Theme.js.map
|
package/Theme.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Theme.js","sources":["../src/Theme.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\nimport type {\n ColorValue,\n FontSizes,\n EditorTheme,\n TypographyMap,\n TypographyValue\n} from \"~/types.js\";\n\ntype InternalProps = {\n $colors: EditorTheme[\"colors\"];\n $fontSizes: EditorTheme[\"fontSizes\"];\n $typography: EditorTheme[\"typography\"];\n $cacheKey: string;\n};\n\ntype InternalTheme = EditorThemeClasses & InternalProps;\n\nexport class Theme {\n static cache: Record<string, Theme> = {};\n static lastUsedTheme: Theme | null = null;\n public readonly tokens: EditorThemeClasses;\n private readonly _colors: ColorValue[];\n private readonly _fontSizes: FontSizes;\n private readonly _typography: Record<string, TypographyValue[]>;\n private readonly _typographyMap: TypographyMap;\n private readonly _allowCustomColors: boolean;\n\n constructor(params: {\n colors: EditorTheme[\"colors\"];\n typography: EditorTheme[\"typography\"];\n fontSizes: EditorTheme[\"fontSizes\"];\n tokens: EditorThemeClasses;\n allowCustomColors?: boolean;\n }) {\n this._colors = params.colors;\n this._typography = params.typography;\n this._fontSizes = params.fontSizes;\n this._typographyMap = this.toTypographyMap(params.typography);\n this.tokens = params.tokens;\n this._allowCustomColors = params.allowCustomColors ?? false;\n }\n\n static empty() {\n return new Theme({\n colors: [],\n typography: {},\n fontSizes: [],\n tokens: {},\n allowCustomColors: false\n });\n }\n\n static from(lexicalTheme: EditorThemeClasses) {\n const { $colors, $typography, $fontSizes, $cacheKey, ...tokens } =\n lexicalTheme as InternalTheme;\n\n if (!$colors) {\n return Theme.lastUsedTheme ?? Theme.empty();\n }\n\n if (!Theme.cache[$cacheKey]) {\n Theme.cache[$cacheKey] = new Theme({\n colors: $colors,\n typography: $typography,\n fontSizes: $fontSizes,\n tokens\n });\n }\n\n Theme.lastUsedTheme = Theme.cache[$cacheKey];\n\n return Theme.cache[$cacheKey];\n }\n\n get colors() {\n return this._colors;\n }\n\n get typography() {\n return this._typography;\n }\n\n get fontSizes() {\n return this._fontSizes;\n }\n\n get allowCustomColors() {\n return this._allowCustomColors;\n }\n\n getTypographyById(id: string) {\n return this._typographyMap[id];\n }\n\n getTypographyByTag(tag: string | string[]) {\n const tags = Array.isArray(tag) ? tag : [tag];\n\n for (const styleId in this._typographyMap) {\n const style = this._typographyMap[styleId];\n if (tags.includes(style.tag)) {\n return style;\n }\n }\n return undefined;\n }\n\n /*\n * Creates a map of style key ID's and typography style objects\n */\n private toTypographyMap(typography: EditorTheme[\"typography\"]): TypographyMap {\n return Object.keys(typography).reduce((acc, key) => {\n const items = typography[key];\n for (const item of items) {\n acc[item.id] = item;\n }\n return acc;\n }, {} as TypographyMap);\n }\n}\n"],"names":["Theme","params","lexicalTheme","$colors","$typography","$fontSizes","$cacheKey","tokens","id","tag","tags","Array","styleId","style","typography","Object","acc","key","items","item"],"mappings":"AAkBO,MAAMA;;aACF,KAAK,GAA0B,CAAC;;;aAChC,aAAa,GAAiB;;IAQrC,YAAYC,MAMX,CAAE;QACC,IAAI,CAAC,OAAO,GAAGA,OAAO,MAAM;QAC5B,IAAI,CAAC,WAAW,GAAGA,OAAO,UAAU;QACpC,IAAI,CAAC,UAAU,GAAGA,OAAO,SAAS;QAClC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,eAAe,CAACA,OAAO,UAAU;QAC5D,IAAI,CAAC,MAAM,GAAGA,OAAO,MAAM;QAC3B,IAAI,CAAC,kBAAkB,GAAGA,OAAO,iBAAiB,IAAI;IAC1D;IAEA,OAAO,QAAQ;QACX,OAAO,IAAID,MAAM;YACb,QAAQ,EAAE;YACV,YAAY,CAAC;YACb,WAAW,EAAE;YACb,QAAQ,CAA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B,OAAOH;QACX,GAAG,CAAC;IACR;AACJ"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
const createLexicalTokens = (classPrefix)=>{
|
|
2
|
+
const withPrefix = (className)=>`${classPrefix}${className}`;
|
|
3
|
+
return {
|
|
4
|
+
characterLimit: withPrefix("characterLimit"),
|
|
5
|
+
code: withPrefix("code"),
|
|
6
|
+
codeHighlight: {
|
|
7
|
+
atrule: withPrefix("tokenAttr"),
|
|
8
|
+
attr: withPrefix("tokenAttr"),
|
|
9
|
+
boolean: withPrefix("tokenProperty"),
|
|
10
|
+
builtin: withPrefix("tokenSelector"),
|
|
11
|
+
cdata: withPrefix("tokenComment"),
|
|
12
|
+
char: withPrefix("tokenSelector"),
|
|
13
|
+
class: withPrefix("tokenFunction"),
|
|
14
|
+
"class-name": withPrefix("tokenFunction"),
|
|
15
|
+
comment: withPrefix("tokenComment"),
|
|
16
|
+
constant: withPrefix("tokenProperty"),
|
|
17
|
+
deleted: withPrefix("tokenProperty"),
|
|
18
|
+
doctype: withPrefix("tokenComment"),
|
|
19
|
+
entity: withPrefix("tokenOperator"),
|
|
20
|
+
function: withPrefix("tokenFunction"),
|
|
21
|
+
important: withPrefix("tokenVariable"),
|
|
22
|
+
inserted: withPrefix("tokenSelector"),
|
|
23
|
+
keyword: withPrefix("tokenAttr"),
|
|
24
|
+
namespace: withPrefix("tokenVariable"),
|
|
25
|
+
number: withPrefix("tokenProperty"),
|
|
26
|
+
operator: withPrefix("tokenOperator"),
|
|
27
|
+
prolog: withPrefix("tokenComment"),
|
|
28
|
+
property: withPrefix("tokenProperty"),
|
|
29
|
+
punctuation: withPrefix("tokenPunctuation"),
|
|
30
|
+
regex: withPrefix("tokenVariable"),
|
|
31
|
+
selector: withPrefix("tokenSelector"),
|
|
32
|
+
string: withPrefix("tokenSelector"),
|
|
33
|
+
symbol: withPrefix("tokenProperty"),
|
|
34
|
+
tag: withPrefix("tokenProperty"),
|
|
35
|
+
url: withPrefix("tokenOperator"),
|
|
36
|
+
variable: withPrefix("tokenVariable")
|
|
37
|
+
},
|
|
38
|
+
embedBlock: {
|
|
39
|
+
base: withPrefix("embedBlock"),
|
|
40
|
+
focus: withPrefix("embedBlockFocus")
|
|
41
|
+
},
|
|
42
|
+
hashtag: withPrefix("hashtag"),
|
|
43
|
+
heading: {
|
|
44
|
+
h1: withPrefix("h1"),
|
|
45
|
+
h2: withPrefix("h2"),
|
|
46
|
+
h3: withPrefix("h3"),
|
|
47
|
+
h4: withPrefix("h4"),
|
|
48
|
+
h5: withPrefix("h5"),
|
|
49
|
+
h6: withPrefix("h6")
|
|
50
|
+
},
|
|
51
|
+
link: withPrefix("link"),
|
|
52
|
+
list: {
|
|
53
|
+
listitem: withPrefix("listItem"),
|
|
54
|
+
listitemChecked: withPrefix("listItemChecked"),
|
|
55
|
+
listitemUnchecked: withPrefix("listItemUnchecked"),
|
|
56
|
+
nested: {
|
|
57
|
+
listitem: withPrefix("nestedListItem")
|
|
58
|
+
},
|
|
59
|
+
olDepth: [
|
|
60
|
+
withPrefix("ol1"),
|
|
61
|
+
withPrefix("ol2"),
|
|
62
|
+
withPrefix("ol3"),
|
|
63
|
+
withPrefix("ol4"),
|
|
64
|
+
withPrefix("ol5")
|
|
65
|
+
],
|
|
66
|
+
ul: withPrefix("ul")
|
|
67
|
+
},
|
|
68
|
+
ltr: withPrefix("ltr"),
|
|
69
|
+
mark: withPrefix("mark"),
|
|
70
|
+
markOverlap: withPrefix("markOverlap"),
|
|
71
|
+
paragraph: withPrefix("paragraph"),
|
|
72
|
+
quote: withPrefix("quote"),
|
|
73
|
+
rtl: withPrefix("rtl"),
|
|
74
|
+
text: {
|
|
75
|
+
bold: withPrefix("textBold"),
|
|
76
|
+
code: withPrefix("textCode"),
|
|
77
|
+
italic: withPrefix("textItalic"),
|
|
78
|
+
strikethrough: withPrefix("textStrikethrough"),
|
|
79
|
+
subscript: withPrefix("textSubscript"),
|
|
80
|
+
superscript: withPrefix("textSuperscript"),
|
|
81
|
+
underline: withPrefix("textUnderline"),
|
|
82
|
+
underlineStrikethrough: withPrefix("textUnderlineStrikethrough")
|
|
83
|
+
},
|
|
84
|
+
fontColorText: withPrefix("fontColorText"),
|
|
85
|
+
image: withPrefix("image"),
|
|
86
|
+
indent: withPrefix("indent"),
|
|
87
|
+
inlineImage: withPrefix("inline-image"),
|
|
88
|
+
table: withPrefix("table"),
|
|
89
|
+
tableAddColumns: withPrefix("tableAddColumns"),
|
|
90
|
+
tableAddRows: withPrefix("tableAddRows"),
|
|
91
|
+
tableCellActionButton: withPrefix("tableCellActionButton"),
|
|
92
|
+
tableCellActionButtonContainer: withPrefix("tableCellActionButtonContainer"),
|
|
93
|
+
tableCellSelected: withPrefix("tableCellSelected"),
|
|
94
|
+
tableCell: withPrefix("tableCell"),
|
|
95
|
+
tableCellHeader: withPrefix("tableCellHeader"),
|
|
96
|
+
tableCellResizer: withPrefix("tableCellResizer"),
|
|
97
|
+
tableRow: withPrefix("tableRow"),
|
|
98
|
+
tableScrollableWrapper: withPrefix("tableScrollableWrapper"),
|
|
99
|
+
tableSelected: withPrefix("tableSelected"),
|
|
100
|
+
tableSelection: withPrefix("tableSelection")
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export { createLexicalTokens };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=createLexicalEditorTokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLexicalEditorTokens.js","sources":["../src/createLexicalEditorTokens.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\n\nexport const createLexicalTokens = (classPrefix: string): EditorThemeClasses => {\n const withPrefix = (className: string) => {\n return `${classPrefix}${className}`;\n };\n\n return {\n characterLimit: withPrefix(\"characterLimit\"),\n code: withPrefix(\"code\"),\n codeHighlight: {\n atrule: withPrefix(\"tokenAttr\"),\n attr: withPrefix(\"tokenAttr\"),\n boolean: withPrefix(\"tokenProperty\"),\n builtin: withPrefix(\"tokenSelector\"),\n cdata: withPrefix(\"tokenComment\"),\n char: withPrefix(\"tokenSelector\"),\n class: withPrefix(\"tokenFunction\"),\n \"class-name\": withPrefix(\"tokenFunction\"),\n comment: withPrefix(\"tokenComment\"),\n constant: withPrefix(\"tokenProperty\"),\n deleted: withPrefix(\"tokenProperty\"),\n doctype: withPrefix(\"tokenComment\"),\n entity: withPrefix(\"tokenOperator\"),\n function: withPrefix(\"tokenFunction\"),\n important: withPrefix(\"tokenVariable\"),\n inserted: withPrefix(\"tokenSelector\"),\n keyword: withPrefix(\"tokenAttr\"),\n namespace: withPrefix(\"tokenVariable\"),\n number: withPrefix(\"tokenProperty\"),\n operator: withPrefix(\"tokenOperator\"),\n prolog: withPrefix(\"tokenComment\"),\n property: withPrefix(\"tokenProperty\"),\n punctuation: withPrefix(\"tokenPunctuation\"),\n regex: withPrefix(\"tokenVariable\"),\n selector: withPrefix(\"tokenSelector\"),\n string: withPrefix(\"tokenSelector\"),\n symbol: withPrefix(\"tokenProperty\"),\n tag: withPrefix(\"tokenProperty\"),\n url: withPrefix(\"tokenOperator\"),\n variable: withPrefix(\"tokenVariable\")\n },\n embedBlock: {\n base: withPrefix(\"embedBlock\"),\n focus: withPrefix(\"embedBlockFocus\")\n },\n hashtag: withPrefix(\"hashtag\"),\n heading: {\n h1: withPrefix(\"h1\"),\n h2: withPrefix(\"h2\"),\n h3: withPrefix(\"h3\"),\n h4: withPrefix(\"h4\"),\n h5: withPrefix(\"h5\"),\n h6: withPrefix(\"h6\")\n },\n link: withPrefix(\"link\"),\n list: {\n listitem: withPrefix(\"listItem\"),\n listitemChecked: withPrefix(\"listItemChecked\"),\n listitemUnchecked: withPrefix(\"listItemUnchecked\"),\n nested: {\n listitem: withPrefix(\"nestedListItem\")\n },\n olDepth: [\n withPrefix(\"ol1\"),\n withPrefix(\"ol2\"),\n withPrefix(\"ol3\"),\n withPrefix(\"ol4\"),\n withPrefix(\"ol5\")\n ],\n ul: withPrefix(\"ul\")\n },\n ltr: withPrefix(\"ltr\"),\n mark: withPrefix(\"mark\"),\n markOverlap: withPrefix(\"markOverlap\"),\n paragraph: withPrefix(\"paragraph\"),\n quote: withPrefix(\"quote\"),\n rtl: withPrefix(\"rtl\"),\n text: {\n bold: withPrefix(\"textBold\"),\n code: withPrefix(\"textCode\"),\n italic: withPrefix(\"textItalic\"),\n strikethrough: withPrefix(\"textStrikethrough\"),\n subscript: withPrefix(\"textSubscript\"),\n superscript: withPrefix(\"textSuperscript\"),\n underline: withPrefix(\"textUnderline\"),\n underlineStrikethrough: withPrefix(\"textUnderlineStrikethrough\")\n },\n fontColorText: withPrefix(\"fontColorText\"),\n image: withPrefix(\"image\"),\n indent: withPrefix(\"indent\"),\n inlineImage: withPrefix(\"inline-image\"),\n table: withPrefix(\"table\"),\n tableAddColumns: withPrefix(\"tableAddColumns\"),\n tableAddRows: withPrefix(\"tableAddRows\"),\n tableCellActionButton: withPrefix(\"tableCellActionButton\"),\n tableCellActionButtonContainer: withPrefix(\"tableCellActionButtonContainer\"),\n tableCellSelected: withPrefix(\"tableCellSelected\"),\n tableCell: withPrefix(\"tableCell\"),\n tableCellHeader: withPrefix(\"tableCellHeader\"),\n tableCellResizer: withPrefix(\"tableCellResizer\"),\n tableRow: withPrefix(\"tableRow\"),\n tableScrollableWrapper: withPrefix(\"tableScrollableWrapper\"),\n tableSelected: withPrefix(\"tableSelected\"),\n tableSelection: withPrefix(\"tableSelection\")\n };\n};\n"],"names":["createLexicalTokens","classPrefix","withPrefix","className"],"mappings":"AAEO,MAAMA,sBAAsB,CAACC;IAChC,MAAMC,aAAa,CAACC,YACT,GAAGF,cAAcE,WAAW;IAGvC,OAAO;QACH,gBAAgBD,WAAW;QAC3B,MAAMA,WAAW;QACjB,eAAe;YACX,QAAQA,WAAW;YACnB,MAAMA,WAAW;YACjB,SAASA,WAAW;YACpB,SAASA,WAAW;YACpB,OAAOA,WAAW;YAClB,MAAMA,WAAW;YACjB,OAAOA,WAAW;YAClB,cAAcA,WAAW;YACzB,SAASA,WAAW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ClB,iBAAiBA,WAAW;QAC5B,cAAcA,WAAW;QACzB,uBAAuBA,WAAW;QAClC,gCAAgCA,WAAW;QAC3C,mBAAmBA,WAAW;QAC9B,WAAWA,WAAW;QACtB,iBAAiBA,WAAW;QAC5B,kBAAkBA,WAAW;QAC7B,UAAUA,WAAW;QACrB,wBAAwBA,WAAW;QACnC,eAAeA,WAAW;QAC1B,gBAAgBA,WAAW;IAC/B;AACJ"}
|
package/createTheme.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import type { ColorValue, EditorTheme, TypographyValue, FontSizes } from "./types.js";
|
|
2
|
+
export interface CreateThemeParams {
|
|
3
|
+
colors: ColorValue[];
|
|
4
|
+
typography: Record<string, TypographyValue[]>;
|
|
5
|
+
lexicalTokenPrefix: string;
|
|
6
|
+
fontSizes: FontSizes | null;
|
|
7
|
+
}
|
|
8
|
+
export declare const createTheme: (params: CreateThemeParams) => EditorTheme;
|
package/createTheme.js
CHANGED
|
@@ -1,103 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
emotionMap: {},
|
|
10
|
-
characterLimit: "WebinyLexical__characterLimit",
|
|
11
|
-
code: "WebinyLexical__code",
|
|
12
|
-
codeHighlight: {
|
|
13
|
-
atrule: "WebinyLexical__tokenAttr",
|
|
14
|
-
attr: "WebinyLexical__tokenAttr",
|
|
15
|
-
boolean: "WebinyLexical__tokenProperty",
|
|
16
|
-
builtin: "WebinyLexical__tokenSelector",
|
|
17
|
-
cdata: "WebinyLexical__tokenComment",
|
|
18
|
-
char: "WebinyLexical__tokenSelector",
|
|
19
|
-
class: "WebinyLexical__tokenFunction",
|
|
20
|
-
"class-name": "WebinyLexical__tokenFunction",
|
|
21
|
-
comment: "WebinyLexical__tokenComment",
|
|
22
|
-
constant: "WebinyLexical__tokenProperty",
|
|
23
|
-
deleted: "WebinyLexical__tokenProperty",
|
|
24
|
-
doctype: "WebinyLexical__tokenComment",
|
|
25
|
-
entity: "WebinyLexical__tokenOperator",
|
|
26
|
-
function: "WebinyLexical__tokenFunction",
|
|
27
|
-
important: "WebinyLexical__tokenVariable",
|
|
28
|
-
inserted: "WebinyLexical__tokenSelector",
|
|
29
|
-
keyword: "WebinyLexical__tokenAttr",
|
|
30
|
-
namespace: "WebinyLexical__tokenVariable",
|
|
31
|
-
number: "WebinyLexical__tokenProperty",
|
|
32
|
-
operator: "WebinyLexical__tokenOperator",
|
|
33
|
-
prolog: "WebinyLexical__tokenComment",
|
|
34
|
-
property: "WebinyLexical__tokenProperty",
|
|
35
|
-
punctuation: "WebinyLexical__tokenPunctuation",
|
|
36
|
-
regex: "WebinyLexical__tokenVariable",
|
|
37
|
-
selector: "WebinyLexical__tokenSelector",
|
|
38
|
-
string: "WebinyLexical__tokenSelector",
|
|
39
|
-
symbol: "WebinyLexical__tokenProperty",
|
|
40
|
-
tag: "WebinyLexical__tokenProperty",
|
|
41
|
-
url: "WebinyLexical__tokenOperator",
|
|
42
|
-
variable: "WebinyLexical__tokenVariable"
|
|
43
|
-
},
|
|
44
|
-
embedBlock: {
|
|
45
|
-
base: "WebinyLexical__embedBlock",
|
|
46
|
-
focus: "WebinyLexical__embedBlockFocus"
|
|
47
|
-
},
|
|
48
|
-
hashtag: "WebinyLexical__hashtag",
|
|
49
|
-
heading: {
|
|
50
|
-
h1: "WebinyLexical__h1",
|
|
51
|
-
h2: "WebinyLexical__h2",
|
|
52
|
-
h3: "WebinyLexical__h3",
|
|
53
|
-
h4: "WebinyLexical__h4",
|
|
54
|
-
h5: "WebinyLexical__h5",
|
|
55
|
-
h6: "WebinyLexical__h6"
|
|
56
|
-
},
|
|
57
|
-
link: "WebinyLexical__link",
|
|
58
|
-
list: {
|
|
59
|
-
listitem: "WebinyLexical__listItem",
|
|
60
|
-
listitemChecked: "WebinyLexical__listItemChecked",
|
|
61
|
-
listitemUnchecked: "WebinyLexical__listItemUnchecked",
|
|
62
|
-
nested: {
|
|
63
|
-
listitem: "WebinyLexical__nestedListItem"
|
|
64
|
-
},
|
|
65
|
-
olDepth: ["WebinyLexical__ol1", "WebinyLexical__ol2", "WebinyLexical__ol3", "WebinyLexical__ol4", "WebinyLexical__ol5"],
|
|
66
|
-
ul: "WebinyLexical__ul"
|
|
67
|
-
},
|
|
68
|
-
ltr: "WebinyLexical__ltr",
|
|
69
|
-
mark: "WebinyLexical__mark",
|
|
70
|
-
markOverlap: "WebinyLexical__markOverlap",
|
|
71
|
-
paragraph: "WebinyLexical__paragraph",
|
|
72
|
-
quote: "WebinyLexical__quote",
|
|
73
|
-
rtl: "WebinyLexical__rtl",
|
|
74
|
-
text: {
|
|
75
|
-
bold: "WebinyLexical__textBold",
|
|
76
|
-
code: "WebinyLexical__textCode",
|
|
77
|
-
italic: "WebinyLexical__textItalic",
|
|
78
|
-
strikethrough: "WebinyLexical__textStrikethrough",
|
|
79
|
-
subscript: "WebinyLexical__textSubscript",
|
|
80
|
-
superscript: "WebinyLexical__textSuperscript",
|
|
81
|
-
underline: "WebinyLexical__textUnderline",
|
|
82
|
-
underlineStrikethrough: "WebinyLexical__textUnderlineStrikethrough"
|
|
83
|
-
},
|
|
84
|
-
fontColorText: "WebinyLexical__fontColorText",
|
|
85
|
-
image: "editor-image",
|
|
86
|
-
indent: "PlaygroundEditorTheme__indent",
|
|
87
|
-
inlineImage: "inline-editor-image"
|
|
88
|
-
};
|
|
89
|
-
const createTheme = ({
|
|
90
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
-
styles,
|
|
92
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
93
|
-
emotionMap,
|
|
94
|
-
...theme
|
|
95
|
-
}) => {
|
|
96
|
-
return {
|
|
97
|
-
...defaultTheme,
|
|
98
|
-
...theme
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
exports.createTheme = createTheme;
|
|
1
|
+
import { createLexicalTokens } from "./createLexicalEditorTokens.js";
|
|
2
|
+
const createTheme = (params)=>({
|
|
3
|
+
colors: params.colors,
|
|
4
|
+
typography: params.typography,
|
|
5
|
+
tokens: createLexicalTokens(params.lexicalTokenPrefix),
|
|
6
|
+
fontSizes: params.fontSizes ?? []
|
|
7
|
+
});
|
|
8
|
+
export { createTheme };
|
|
102
9
|
|
|
103
10
|
//# sourceMappingURL=createTheme.js.map
|
package/createTheme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"createTheme.js","sources":["../src/createTheme.ts"],"sourcesContent":["import type { ColorValue, EditorTheme, TypographyValue, FontSizes } from \"~/types.js\";\nimport { createLexicalTokens } from \"~/createLexicalEditorTokens.js\";\n\nexport interface CreateThemeParams {\n colors: ColorValue[];\n typography: Record<string, TypographyValue[]>;\n lexicalTokenPrefix: string;\n fontSizes: FontSizes | null;\n}\n\nexport const createTheme = (params: CreateThemeParams): EditorTheme => {\n return {\n colors: params.colors,\n typography: params.typography,\n tokens: createLexicalTokens(params.lexicalTokenPrefix),\n fontSizes: params.fontSizes ?? []\n };\n};\n"],"names":["createTheme","params","createLexicalTokens"],"mappings":";AAUO,MAAMA,cAAc,CAACC,SACjB;QACH,QAAQA,OAAO,MAAM;QACrB,YAAYA,OAAO,UAAU;QAC7B,QAAQC,oBAAoBD,OAAO,kBAAkB;QACrD,WAAWA,OAAO,SAAS,IAAI,EAAE;IACrC"}
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export * from "./createTheme";
|
|
2
|
-
export * from "./types";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./utils/styleObjectToString";
|
|
1
|
+
export * from "./createTheme.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./Theme.js";
|
|
4
|
+
export * from "./toTypographyMap.js";
|
package/index.js
CHANGED
|
@@ -1,62 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
var _createTheme = require("./createTheme");
|
|
7
|
-
Object.keys(_createTheme).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _createTheme[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _createTheme[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _types = require("./types");
|
|
18
|
-
Object.keys(_types).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _types[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _types[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _findTypographyStyleByHtmlTag = require("./utils/findTypographyStyleByHtmlTag");
|
|
29
|
-
Object.keys(_findTypographyStyleByHtmlTag).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (key in exports && exports[key] === _findTypographyStyleByHtmlTag[key]) return;
|
|
32
|
-
Object.defineProperty(exports, key, {
|
|
33
|
-
enumerable: true,
|
|
34
|
-
get: function () {
|
|
35
|
-
return _findTypographyStyleByHtmlTag[key];
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
var _toTypographyEmotionMap = require("./utils/toTypographyEmotionMap");
|
|
40
|
-
Object.keys(_toTypographyEmotionMap).forEach(function (key) {
|
|
41
|
-
if (key === "default" || key === "__esModule") return;
|
|
42
|
-
if (key in exports && exports[key] === _toTypographyEmotionMap[key]) return;
|
|
43
|
-
Object.defineProperty(exports, key, {
|
|
44
|
-
enumerable: true,
|
|
45
|
-
get: function () {
|
|
46
|
-
return _toTypographyEmotionMap[key];
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
var _styleObjectToString = require("./utils/styleObjectToString");
|
|
51
|
-
Object.keys(_styleObjectToString).forEach(function (key) {
|
|
52
|
-
if (key === "default" || key === "__esModule") return;
|
|
53
|
-
if (key in exports && exports[key] === _styleObjectToString[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _styleObjectToString[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export * from "./createTheme.js";
|
|
2
|
+
export * from "./types.js";
|
|
3
|
+
export * from "./Theme.js";
|
|
4
|
+
export * from "./toTypographyMap.js";
|
package/package.json
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/lexical-theme",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
3
|
+
"version": "0.0.0-unstable.a4f3e4ea8b",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
4
9
|
"dependencies": {
|
|
5
|
-
"
|
|
6
|
-
"emotion": "10.0.27",
|
|
7
|
-
"lexical": "0.23.1",
|
|
8
|
-
"react-style-object-to-css": "1.1.2"
|
|
10
|
+
"lexical": "0.48.0"
|
|
9
11
|
},
|
|
10
12
|
"devDependencies": {
|
|
11
|
-
"@webiny/
|
|
13
|
+
"@webiny/build-tools": "0.0.0-unstable.a4f3e4ea8b"
|
|
12
14
|
},
|
|
13
15
|
"publishConfig": {
|
|
14
|
-
"access": "public"
|
|
15
|
-
"directory": "dist"
|
|
16
|
-
},
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "node ../cli/bin.js run build",
|
|
19
|
-
"watch": "node ../cli/bin.js run watch"
|
|
16
|
+
"access": "public"
|
|
20
17
|
},
|
|
21
|
-
"
|
|
18
|
+
"webiny": {
|
|
19
|
+
"publishFrom": "dist"
|
|
20
|
+
}
|
|
22
21
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const toTypographyMap = (theme)=>{
|
|
2
|
+
const typographyStyles = theme.typography;
|
|
3
|
+
if (!typographyStyles) return {};
|
|
4
|
+
return Object.keys(typographyStyles).reduce((acc, key)=>{
|
|
5
|
+
for (const style of typographyStyles[key])acc[style.id] = style;
|
|
6
|
+
return acc;
|
|
7
|
+
}, {});
|
|
8
|
+
};
|
|
9
|
+
export { toTypographyMap };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=toTypographyMap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toTypographyMap.js","sources":["../src/toTypographyMap.ts"],"sourcesContent":["import type { EditorTheme, TypographyMap } from \"~/types.js\";\n\nexport const toTypographyMap = (theme: EditorTheme): TypographyMap => {\n const typographyStyles = theme.typography;\n if (!typographyStyles) {\n return {};\n }\n\n return Object.keys(typographyStyles).reduce((acc, key) => {\n for (const style of typographyStyles[key]) {\n acc[style.id] = style;\n }\n return acc;\n }, {} as TypographyMap);\n};\n"],"names":["toTypographyMap","theme","typographyStyles","Object","acc","key","style"],"mappings":"AAEO,MAAMA,kBAAkB,CAACC;IAC5B,MAAMC,mBAAmBD,MAAM,UAAU;IACzC,IAAI,CAACC,kBACD,OAAO,CAAC;IAGZ,OAAOC,OAAO,IAAI,CAACD,kBAAkB,MAAM,CAAC,CAACE,KAAKC;QAC9C,KAAK,MAAMC,SAASJ,gBAAgB,CAACG,IAAI,CACrCD,GAAG,CAACE,MAAM,EAAE,CAAC,GAAGA;QAEpB,OAAOF;IACX,GAAG,CAAC;AACR"}
|
package/types.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorThemeClasses } from "lexical";
|
|
2
|
+
export type ColorValue = {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
};
|
|
7
|
+
export type FontSizes = string[];
|
|
2
8
|
export type TypographyValue = {
|
|
3
9
|
id: string;
|
|
4
10
|
tag: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
className?: string;
|
|
11
|
+
label: string;
|
|
12
|
+
className: string;
|
|
8
13
|
};
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
className: string;
|
|
16
|
-
};
|
|
14
|
+
export type EditorTheme = {
|
|
15
|
+
colors: ColorValue[];
|
|
16
|
+
typography: Record<string, TypographyValue[]>;
|
|
17
|
+
tokens: EditorThemeClasses;
|
|
18
|
+
fontSizes: FontSizes;
|
|
19
|
+
allowCustomColors?: boolean;
|
|
17
20
|
};
|
|
21
|
+
export type TypographyMap = Record<string, TypographyValue>;
|
package/types.js
CHANGED
package/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_createTheme","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_types","_findTypographyStyleByHtmlTag","_toTypographyEmotionMap","_styleObjectToString"],"sources":["index.ts"],"sourcesContent":["export * from \"./createTheme\";\nexport * from \"./types\";\nexport * from \"./utils/findTypographyStyleByHtmlTag\";\nexport * from \"./utils/toTypographyEmotionMap\";\nexport * from \"./utils/styleObjectToString\";\n"],"mappings":";;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,YAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GA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AAA;AACA,IAAAQ,oBAAA,GAAAZ,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAU,oBAAA,EAAAT,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAQ,oBAAA,CAAAR,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAI,oBAAA,CAAAR,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
package/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CSSObject } from \"@emotion/react\";\n\nexport type TypographyValue = {\n id: string;\n tag: string;\n name: string;\n css?: CSSObject;\n className?: string;\n};\n\n/*\n * Contains IDs of the styles and classes generated by Emotion.\n */\nexport type ThemeEmotionMap = {\n [styleId: string]: {\n id: string;\n tag: string;\n name: string;\n styles?: Record<string, any>;\n // emotion generated class or user provided class\n className: string;\n };\n};\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ThemeEmotionMap } from "../types";
|
|
2
|
-
export declare const findTypographyStyleByHtmlTag: (htmlTag: string | string[], themeEmotionMap: ThemeEmotionMap) => {
|
|
3
|
-
id: string;
|
|
4
|
-
tag: string;
|
|
5
|
-
name: string;
|
|
6
|
-
styles?: Record<string, any> | undefined;
|
|
7
|
-
className: string;
|
|
8
|
-
} | undefined;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.findTypographyStyleByHtmlTag = void 0;
|
|
7
|
-
const findTypographyStyleByHtmlTag = (htmlTag, themeEmotionMap) => {
|
|
8
|
-
const tags = Array.isArray(htmlTag) ? htmlTag : [htmlTag];
|
|
9
|
-
for (const styleId in themeEmotionMap) {
|
|
10
|
-
const style = themeEmotionMap[styleId];
|
|
11
|
-
if (tags.includes(style.tag)) {
|
|
12
|
-
return style;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return undefined;
|
|
16
|
-
};
|
|
17
|
-
exports.findTypographyStyleByHtmlTag = findTypographyStyleByHtmlTag;
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=findTypographyStyleByHtmlTag.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["findTypographyStyleByHtmlTag","htmlTag","themeEmotionMap","tags","Array","isArray","styleId","style","includes","tag","undefined","exports"],"sources":["findTypographyStyleByHtmlTag.ts"],"sourcesContent":["import type { ThemeEmotionMap } from \"~/types\";\n\nexport const findTypographyStyleByHtmlTag = (\n htmlTag: string | string[],\n themeEmotionMap: ThemeEmotionMap\n) => {\n const tags = Array.isArray(htmlTag) ? htmlTag : [htmlTag];\n\n for (const styleId in themeEmotionMap) {\n const style = themeEmotionMap[styleId];\n if (tags.includes(style.tag)) {\n return style;\n }\n }\n return undefined;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,4BAA4B,GAAGA,CACxCC,OAA0B,EAC1BC,eAAgC,KAC/B;EACD,MAAMC,IAAI,GAAGC,KAAK,CAACC,OAAO,CAACJ,OAAO,CAAC,GAAGA,OAAO,GAAG,CAACA,OAAO,CAAC;EAEzD,KAAK,MAAMK,OAAO,IAAIJ,eAAe,EAAE;IACnC,MAAMK,KAAK,GAAGL,eAAe,CAACI,OAAO,CAAC;IACtC,IAAIH,IAAI,CAACK,QAAQ,CAACD,KAAK,CAACE,GAAG,CAAC,EAAE;MAC1B,OAAOF,KAAK;IAChB;EACJ;EACA,OAAOG,SAAS;AACpB,CAAC;AAACC,OAAA,CAAAX,4BAAA,GAAAA,4BAAA","ignoreList":[]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.styleObjectToString = void 0;
|
|
8
|
-
var _reactStyleObjectToCss = _interopRequireDefault(require("react-style-object-to-css"));
|
|
9
|
-
// @ts-expect-error - There are no types "@types/react-style-object-to-css" for this lib.
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
* Converts CSS style objects to string
|
|
13
|
-
* Example:
|
|
14
|
-
* { fontSize: '10px' } => "font-size: 10px"
|
|
15
|
-
* */
|
|
16
|
-
const styleObjectToString = styleObject => {
|
|
17
|
-
if (!styleObject) {
|
|
18
|
-
return styleObject;
|
|
19
|
-
}
|
|
20
|
-
return (0, _reactStyleObjectToCss.default)(styleObject);
|
|
21
|
-
};
|
|
22
|
-
exports.styleObjectToString = styleObjectToString;
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=styleObjectToString.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_reactStyleObjectToCss","_interopRequireDefault","require","styleObjectToString","styleObject","reactToCSS","exports"],"sources":["styleObjectToString.ts"],"sourcesContent":["// @ts-expect-error - There are no types \"@types/react-style-object-to-css\" for this lib.\nimport reactToCSS from \"react-style-object-to-css\";\nimport type { CSSObject } from \"@emotion/react\";\n\n/*\n * Converts CSS style objects to string\n * Example:\n * { fontSize: '10px' } => \"font-size: 10px\"\n * */\nexport const styleObjectToString = (styleObject: CSSObject): string => {\n if (!styleObject) {\n return styleObject;\n }\n return reactToCSS(styleObject);\n};\n"],"mappings":";;;;;;;AACA,IAAAA,sBAAA,GAAAC,sBAAA,CAAAC,OAAA;AADA;;AAIA;AACA;AACA;AACA;AACA;AACO,MAAMC,mBAAmB,GAAIC,WAAsB,IAAa;EACnE,IAAI,CAACA,WAAW,EAAE;IACd,OAAOA,WAAW;EACtB;EACA,OAAO,IAAAC,8BAAU,EAACD,WAAW,CAAC;AAClC,CAAC;AAACE,OAAA,CAAAH,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { css as EmotionCSS } from "emotion";
|
|
2
|
-
import type { ThemeEmotionMap } from "../types";
|
|
3
|
-
import type { EditorTheme } from "../createTheme";
|
|
4
|
-
export declare const toTypographyEmotionMap: (css: typeof EmotionCSS, theme: EditorTheme, themeStylesTransformer?: any) => ThemeEmotionMap;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.toTypographyEmotionMap = void 0;
|
|
7
|
-
/*
|
|
8
|
-
* Creates a map of style key ID's and typography style objects that include 'className' property which contains the
|
|
9
|
-
* CSS class name generated by the Emotion from typography styles object.
|
|
10
|
-
*/
|
|
11
|
-
const toTypographyEmotionMap = (css, theme, themeStylesTransformer) => {
|
|
12
|
-
const map = {};
|
|
13
|
-
const typographyStyles = theme.styles?.typography;
|
|
14
|
-
if (!typographyStyles) {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
17
|
-
for (const key in typographyStyles) {
|
|
18
|
-
const typographyTypeData = typographyStyles[key];
|
|
19
|
-
if (typographyTypeData) {
|
|
20
|
-
typographyTypeData.forEach(styleItem => {
|
|
21
|
-
// If `className` is already defined, use the style as is.
|
|
22
|
-
if (styleItem.className !== undefined) {
|
|
23
|
-
map[styleItem.id] = styleItem;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// 'lx' (abbreviation of lexical) variable will lead to generate shorter class names.
|
|
28
|
-
// for example: instead of default 'css-181qz4b-453f345f'
|
|
29
|
-
// the last segment will always end with 'lx' or 'css-181qz4b-lx'
|
|
30
|
-
let transformedStyles = styleItem.styles;
|
|
31
|
-
if (themeStylesTransformer) {
|
|
32
|
-
transformedStyles = themeStylesTransformer(styleItem.styles);
|
|
33
|
-
}
|
|
34
|
-
map[styleItem.id] = {
|
|
35
|
-
...styleItem,
|
|
36
|
-
className: [css(transformedStyles)].filter(Boolean).join(" ")
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return map;
|
|
42
|
-
};
|
|
43
|
-
exports.toTypographyEmotionMap = toTypographyEmotionMap;
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=toTypographyEmotionMap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["toTypographyEmotionMap","css","theme","themeStylesTransformer","map","typographyStyles","styles","typography","key","typographyTypeData","forEach","styleItem","className","undefined","id","transformedStyles","filter","Boolean","join","exports"],"sources":["toTypographyEmotionMap.ts"],"sourcesContent":["import type { css as EmotionCSS } from \"emotion\";\nimport type { ThemeEmotionMap } from \"~/types\";\nimport type { EditorTheme } from \"~/createTheme\";\n\ntype StyleItem = {\n id: string;\n tag: string;\n name: string;\n styles?: Record<string, any>;\n className?: string;\n};\n\n/*\n * Creates a map of style key ID's and typography style objects that include 'className' property which contains the\n * CSS class name generated by the Emotion from typography styles object.\n */\nexport const toTypographyEmotionMap = (\n css: typeof EmotionCSS,\n theme: EditorTheme,\n themeStylesTransformer?: any\n): ThemeEmotionMap => {\n const map: ThemeEmotionMap = {};\n const typographyStyles = theme.styles?.typography;\n if (!typographyStyles) {\n return {};\n }\n\n for (const key in typographyStyles) {\n const typographyTypeData = typographyStyles[key] as StyleItem[];\n if (typographyTypeData) {\n typographyTypeData.forEach(styleItem => {\n // If `className` is already defined, use the style as is.\n if (styleItem.className !== undefined) {\n map[styleItem.id] = styleItem as StyleItem & { className: string };\n return;\n }\n\n // 'lx' (abbreviation of lexical) variable will lead to generate shorter class names.\n // for example: instead of default 'css-181qz4b-453f345f'\n // the last segment will always end with 'lx' or 'css-181qz4b-lx'\n let transformedStyles = styleItem.styles;\n if (themeStylesTransformer) {\n transformedStyles = themeStylesTransformer(styleItem.styles);\n }\n\n map[styleItem.id] = {\n ...styleItem,\n className: [css(transformedStyles)].filter(Boolean).join(\" \")\n };\n });\n }\n }\n\n return map;\n};\n"],"mappings":";;;;;;AAYA;AACA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAGA,CAClCC,GAAsB,EACtBC,KAAkB,EAClBC,sBAA4B,KACV;EAClB,MAAMC,GAAoB,GAAG,CAAC,CAAC;EAC/B,MAAMC,gBAAgB,GAAGH,KAAK,CAACI,MAAM,EAAEC,UAAU;EACjD,IAAI,CAACF,gBAAgB,EAAE;IACnB,OAAO,CAAC,CAAC;EACb;EAEA,KAAK,MAAMG,GAAG,IAAIH,gBAAgB,EAAE;IAChC,MAAMI,kBAAkB,GAAGJ,gBAAgB,CAACG,GAAG,CAAgB;IAC/D,IAAIC,kBAAkB,EAAE;MACpBA,kBAAkB,CAACC,OAAO,CAACC,SAAS,IAAI;QACpC;QACA,IAAIA,SAAS,CAACC,SAAS,KAAKC,SAAS,EAAE;UACnCT,GAAG,CAACO,SAAS,CAACG,EAAE,CAAC,GAAGH,SAA8C;UAClE;QACJ;;QAEA;QACA;QACA;QACA,IAAII,iBAAiB,GAAGJ,SAAS,CAACL,MAAM;QACxC,IAAIH,sBAAsB,EAAE;UACxBY,iBAAiB,GAAGZ,sBAAsB,CAACQ,SAAS,CAACL,MAAM,CAAC;QAChE;QAEAF,GAAG,CAACO,SAAS,CAACG,EAAE,CAAC,GAAG;UAChB,GAAGH,SAAS;UACZC,SAAS,EAAE,CAACX,GAAG,CAACc,iBAAiB,CAAC,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG;QAChE,CAAC;MACL,CAAC,CAAC;IACN;EACJ;EAEA,OAAOd,GAAG;AACd,CAAC;AAACe,OAAA,CAAAnB,sBAAA,GAAAA,sBAAA","ignoreList":[]}
|