@webiny/lexical-theme 5.44.1-beta.1 β†’ 5.45.0-beta.0

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 CHANGED
@@ -1,6 +1,11 @@
1
1
  # @webiny/lexical-theme
2
2
 
3
- [![](https://img.shields.io/npm/dw/@webiny/lexical-theme.svg)](https://www.npmjs.com/package/@webiny/llexical-lexical-theme)
4
- [![](https://img.shields.io/npm/v/@webiny/lexical-theme.svg)](https://www.npmjs.com/package/@webiny/lexical-theme)
5
- [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
6
- [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
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,18 @@
1
+ import type { EditorThemeClasses } from "lexical";
2
+ import type { ColorValue, 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 _colors;
8
+ private _typography;
9
+ private _typographyMap;
10
+ constructor(colors: EditorTheme["colors"], typography: EditorTheme["typography"], tokens: EditorThemeClasses);
11
+ static empty(): Theme;
12
+ static from(lexicalTheme: EditorThemeClasses): Theme;
13
+ get colors(): ColorValue[];
14
+ get typography(): Record<string, TypographyValue[]>;
15
+ getTypographyById(id: string): TypographyValue;
16
+ getTypographyByTag(tag: string | string[]): TypographyValue | undefined;
17
+ private toTypographyMap;
18
+ }
package/Theme.js ADDED
@@ -0,0 +1,64 @@
1
+ export class Theme {
2
+ static cache = {};
3
+ static lastUsedTheme = null;
4
+ constructor(colors, typography, tokens) {
5
+ this._colors = colors;
6
+ this._typography = typography;
7
+ this._typographyMap = this.toTypographyMap(typography);
8
+ this.tokens = tokens;
9
+ }
10
+ static empty() {
11
+ return new Theme([], {}, {});
12
+ }
13
+ static from(lexicalTheme) {
14
+ const {
15
+ $colors,
16
+ $typography,
17
+ $cacheKey,
18
+ ...tokens
19
+ } = lexicalTheme;
20
+ if (!$colors) {
21
+ return Theme.lastUsedTheme ?? Theme.empty();
22
+ }
23
+ if (!Theme.cache[$cacheKey]) {
24
+ Theme.cache[$cacheKey] = new Theme($colors, $typography, tokens);
25
+ }
26
+ Theme.lastUsedTheme = Theme.cache[$cacheKey];
27
+ return Theme.cache[$cacheKey];
28
+ }
29
+ get colors() {
30
+ return this._colors;
31
+ }
32
+ get typography() {
33
+ return this._typography;
34
+ }
35
+ getTypographyById(id) {
36
+ return this._typographyMap[id];
37
+ }
38
+ getTypographyByTag(tag) {
39
+ const tags = Array.isArray(tag) ? tag : [tag];
40
+ for (const styleId in this._typographyMap) {
41
+ const style = this._typographyMap[styleId];
42
+ if (tags.includes(style.tag)) {
43
+ return style;
44
+ }
45
+ }
46
+ return undefined;
47
+ }
48
+
49
+ /*
50
+ * Creates a map of style key ID's and typography style objects
51
+ */
52
+
53
+ toTypographyMap(typography) {
54
+ return Object.keys(typography).reduce((acc, key) => {
55
+ const items = typography[key];
56
+ for (const item of items) {
57
+ acc[item.id] = item;
58
+ }
59
+ return acc;
60
+ }, {});
61
+ }
62
+ }
63
+
64
+ //# sourceMappingURL=Theme.js.map
package/Theme.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Theme","cache","lastUsedTheme","constructor","colors","typography","tokens","_colors","_typography","_typographyMap","toTypographyMap","empty","from","lexicalTheme","$colors","$typography","$cacheKey","getTypographyById","id","getTypographyByTag","tag","tags","Array","isArray","styleId","style","includes","undefined","Object","keys","reduce","acc","key","items","item"],"sources":["Theme.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\nimport type { ColorValue, EditorTheme, TypographyMap, TypographyValue } from \"~/types.js\";\n\ntype InternalProps = {\n $colors: EditorTheme[\"colors\"];\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 _colors: ColorValue[];\n private _typography: Record<string, TypographyValue[]>;\n private _typographyMap: TypographyMap;\n\n constructor(\n colors: EditorTheme[\"colors\"],\n typography: EditorTheme[\"typography\"],\n tokens: EditorThemeClasses\n ) {\n this._colors = colors;\n this._typography = typography;\n this._typographyMap = this.toTypographyMap(typography);\n this.tokens = tokens;\n }\n\n static empty() {\n return new Theme([], {}, {});\n }\n\n static from(lexicalTheme: EditorThemeClasses) {\n const { $colors, $typography, $cacheKey, ...tokens } = 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($colors, $typography, tokens);\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 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\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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CAAC;EAClC;EAEAC,kBAAkBA,CAACC,GAAsB,EAAE;IACvC,MAAMC,IAAI,GAAGC,KAAK,CAACC,OAAO,CAACH,GAAG,CAAC,GAAGA,GAAG,GAAG,CAACA,GAAG,CAAC;IAE7C,KAAK,MAAMI,OAAO,IAAI,IAAI,CAACf,cAAc,EAAE;MACvC,MAAMgB,KAAK,GAAG,IAAI,CAAChB,cAAc,CAACe,OAAO,CAAC;MAC1C,IAAIH,IAAI,CAACK,QAAQ,CAACD,KAAK,CAACL,GAAG,CAAC,EAAE;QAC1B,OAAOK,KAAK;MAChB;IACJ;IACA,OAAOE,SAAS;EACpB;;EAEA;AACJ;AACA;;EAEYjB,eAAeA,CAACL,UAAqC,EAAiB;IAC1E,OAAOuB,MAAM,CAACC,IAAI,CAACxB,UAAU,CAAC,CAACyB,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;MAChD,MAAMC,KAAK,GAAG5B,UAAU,CAAC2B,GAAG,CAAC;MAC7B,KAAK,MAAME,IAAI,IAAID,KAAK,EAAE;QACtBF,GAAG,CAACG,IAAI,CAAChB,EAAE,CAAC,GAAGgB,IAAI;MACvB;MACA,OAAOH,GAAG;IACd,CAAC,EAAE,CAAC,CAAkB,CAAC;EAC3B;AACJ","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { EditorThemeClasses } from "lexical";
2
+ export declare const createLexicalTokens: (classPrefix: string) => EditorThemeClasses;
@@ -0,0 +1,100 @@
1
+ export const createLexicalTokens = classPrefix => {
2
+ const withPrefix = className => {
3
+ return `${classPrefix}${className}`;
4
+ };
5
+ return {
6
+ characterLimit: withPrefix("characterLimit"),
7
+ code: withPrefix("code"),
8
+ codeHighlight: {
9
+ atrule: withPrefix("tokenAttr"),
10
+ attr: withPrefix("tokenAttr"),
11
+ boolean: withPrefix("tokenProperty"),
12
+ builtin: withPrefix("tokenSelector"),
13
+ cdata: withPrefix("tokenComment"),
14
+ char: withPrefix("tokenSelector"),
15
+ class: withPrefix("tokenFunction"),
16
+ "class-name": withPrefix("tokenFunction"),
17
+ comment: withPrefix("tokenComment"),
18
+ constant: withPrefix("tokenProperty"),
19
+ deleted: withPrefix("tokenProperty"),
20
+ doctype: withPrefix("tokenComment"),
21
+ entity: withPrefix("tokenOperator"),
22
+ function: withPrefix("tokenFunction"),
23
+ important: withPrefix("tokenVariable"),
24
+ inserted: withPrefix("tokenSelector"),
25
+ keyword: withPrefix("tokenAttr"),
26
+ namespace: withPrefix("tokenVariable"),
27
+ number: withPrefix("tokenProperty"),
28
+ operator: withPrefix("tokenOperator"),
29
+ prolog: withPrefix("tokenComment"),
30
+ property: withPrefix("tokenProperty"),
31
+ punctuation: withPrefix("tokenPunctuation"),
32
+ regex: withPrefix("tokenVariable"),
33
+ selector: withPrefix("tokenSelector"),
34
+ string: withPrefix("tokenSelector"),
35
+ symbol: withPrefix("tokenProperty"),
36
+ tag: withPrefix("tokenProperty"),
37
+ url: withPrefix("tokenOperator"),
38
+ variable: withPrefix("tokenVariable")
39
+ },
40
+ embedBlock: {
41
+ base: withPrefix("embedBlock"),
42
+ focus: withPrefix("embedBlockFocus")
43
+ },
44
+ hashtag: withPrefix("hashtag"),
45
+ heading: {
46
+ h1: withPrefix("h1"),
47
+ h2: withPrefix("h2"),
48
+ h3: withPrefix("h3"),
49
+ h4: withPrefix("h4"),
50
+ h5: withPrefix("h5"),
51
+ h6: withPrefix("h6")
52
+ },
53
+ link: withPrefix("link"),
54
+ list: {
55
+ listitem: withPrefix("listItem"),
56
+ listitemChecked: withPrefix("listItemChecked"),
57
+ listitemUnchecked: withPrefix("listItemUnchecked"),
58
+ nested: {
59
+ listitem: withPrefix("nestedListItem")
60
+ },
61
+ olDepth: [withPrefix("ol1"), withPrefix("ol2"), withPrefix("ol3"), withPrefix("ol4"), withPrefix("ol5")],
62
+ ul: withPrefix("ul")
63
+ },
64
+ ltr: withPrefix("ltr"),
65
+ mark: withPrefix("mark"),
66
+ markOverlap: withPrefix("markOverlap"),
67
+ paragraph: withPrefix("paragraph"),
68
+ quote: withPrefix("quote"),
69
+ rtl: withPrefix("rtl"),
70
+ text: {
71
+ bold: withPrefix("textBold"),
72
+ code: withPrefix("textCode"),
73
+ italic: withPrefix("textItalic"),
74
+ strikethrough: withPrefix("textStrikethrough"),
75
+ subscript: withPrefix("textSubscript"),
76
+ superscript: withPrefix("textSuperscript"),
77
+ underline: withPrefix("textUnderline"),
78
+ underlineStrikethrough: withPrefix("textUnderlineStrikethrough")
79
+ },
80
+ fontColorText: withPrefix("fontColorText"),
81
+ image: withPrefix("image"),
82
+ indent: withPrefix("indent"),
83
+ inlineImage: withPrefix("inline-image"),
84
+ table: withPrefix("table"),
85
+ tableAddColumns: withPrefix("tableAddColumns"),
86
+ tableAddRows: withPrefix("tableAddRows"),
87
+ tableCellActionButton: withPrefix("tableCellActionButton"),
88
+ tableCellActionButtonContainer: withPrefix("tableCellActionButtonContainer"),
89
+ tableCellSelected: withPrefix("tableCellSelected"),
90
+ tableCell: withPrefix("tableCell"),
91
+ tableCellHeader: withPrefix("tableCellHeader"),
92
+ tableCellResizer: withPrefix("tableCellResizer"),
93
+ tableRow: withPrefix("tableRow"),
94
+ tableScrollableWrapper: withPrefix("tableScrollableWrapper"),
95
+ tableSelected: withPrefix("tableSelected"),
96
+ tableSelection: withPrefix("tableSelection")
97
+ };
98
+ };
99
+
100
+ //# sourceMappingURL=createLexicalEditorTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createLexicalTokens","classPrefix","withPrefix","className","characterLimit","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","hashtag","heading","h1","h2","h3","h4","h5","h6","link","list","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ul","ltr","mark","markOverlap","paragraph","quote","rtl","text","bold","italic","strikethrough","subscript","superscript","underline","underlineStrikethrough","fontColorText","image","indent","inlineImage","table","tableAddColumns","tableAddRows","tableCellActionButton","tableCellActionButtonContainer","tableCellSelected","tableCell","tableCellHeader","tableCellResizer","tableRow","tableScrollableWrapper","tableSelected","tableSelection"],"sources":["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"],"mappings":"AAEA,OAAO,MAAMA,mBAAmB,GAAIC,WAAmB,IAAyB;EAC5E,MAAMC,UAAU,GAAIC,SAAiB,IAAK;IACtC,OAAO,GAAGF,WAAW,GAAGE,SAAS,EAAE;EACvC,CAAC;EAED,OAAO;IACHC,cAAc,EAAEF,UAAU,CAAC,gBAAgB,CAAC;IAC5CG,IAAI,EAAEH,UAAU,CAAC,MAAM,CAAC;IACxBI,aAAa,EAAE;MACXC,MAAM,EAAEL,UAAU,CAAC,WAAW,CAAC;MAC/BM,IAAI,EAAEN,UAAU,CAAC,WAAW,CAAC;MAC7BO,OAAO,EAAEP,UAAU,CAAC,eAAe,CAAC;MACpCQ,OAAO,EAAER,UAAU,CAAC,eAAe,CAAC;MACpCS,KAAK,EAAET,UAAU,CAAC,cAAc,CAAC;MACjCU,IAAI,EAAEV,UAAU,CAAC,eAAe,CAAC;MACjCW,KAAK,EAAEX,UAAU,CAAC,eAAe,CAAC;MAClC,YAAY,EAAEA,UAAU,CAAC,eAAe,CAAC;MACzCY,OAAO,EAAEZ,UAAU,CAAC,cAAc,CAAC;MACnCa,QAAQ,EAAEb,UAAU,CAAC,eAAe,CAAC;MACrCc,OAAO,EAAEd,UAAU,CAAC,eAAe,CAAC;MACpCe,OAAO,EAAEf,UAAU,CAAC,cAAc,CAAC;MACnCgB,MAAM,EAAEhB,UAAU,CAAC,eAAe,CAAC;MACnCiB,QAAQ,EAAEjB,UAAU,CAAC,eAAe,CAAC;MACrCkB,SAAS,EAAElB,UAAU,CAAC,eAAe,CAAC;MACtCmB,QAAQ,EAAEnB,UAAU,CAAC,eAAe,CAAC;MACrCoB,OAAO,EAAEpB,UAAU,CAAC,WAAW,CAAC;MAChCqB,SAAS,EAAErB,UAAU,CAAC,eAAe,CAAC;MACtCsB,MAAM,EAAEtB,UAAU,CAAC,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BwE,eAAe,EAAExE,UAAU,CAAC,iBAAiB,CAAC;IAC9CyE,YAAY,EAAEzE,UAAU,CAAC,cAAc,CAAC;IACxC0E,qBAAqB,EAAE1E,UAAU,CAAC,uBAAuB,CAAC;IAC1D2E,8BAA8B,EAAE3E,UAAU,CAAC,gCAAgC,CAAC;IAC5E4E,iBAAiB,EAAE5E,UAAU,CAAC,mBAAmB,CAAC;IAClD6E,SAAS,EAAE7E,UAAU,CAAC,WAAW,CAAC;IAClC8E,eAAe,EAAE9E,UAAU,CAAC,iBAAiB,CAAC;IAC9C+E,gBAAgB,EAAE/E,UAAU,CAAC,kBAAkB,CAAC;IAChDgF,QAAQ,EAAEhF,UAAU,CAAC,UAAU,CAAC;IAChCiF,sBAAsB,EAAEjF,UAAU,CAAC,wBAAwB,CAAC;IAC5DkF,aAAa,EAAElF,UAAU,CAAC,eAAe,CAAC;IAC1CmF,cAAc,EAAEnF,UAAU,CAAC,gBAAgB;EAC/C,CAAC;AACL,CAAC","ignoreList":[]}
package/createTheme.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { EditorThemeClasses } from "lexical";
2
- import { ThemeEmotionMap } from "./types";
3
- export type EditorTheme = {
4
- styles: Record<string, any>;
5
- emotionMap: ThemeEmotionMap;
6
- } & EditorThemeClasses;
7
- export declare const createTheme: ({ styles, emotionMap, ...theme }: Partial<EditorTheme>) => EditorTheme;
1
+ import type { ColorValue, EditorTheme, TypographyValue } from "./types.js";
2
+ export interface CreateThemeParams {
3
+ colors: ColorValue[];
4
+ typography: Record<string, TypographyValue[]>;
5
+ lexicalTokenPrefix: string;
6
+ }
7
+ export declare const createTheme: (params: CreateThemeParams) => EditorTheme;
package/createTheme.js CHANGED
@@ -1,103 +1,10 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createTheme = void 0;
7
- const defaultTheme = {
8
- styles: {},
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
- }) => {
1
+ import { createLexicalTokens } from "./createLexicalEditorTokens.js";
2
+ export const createTheme = params => {
96
3
  return {
97
- ...defaultTheme,
98
- ...theme
4
+ colors: params.colors,
5
+ typography: params.typography,
6
+ tokens: createLexicalTokens(params.lexicalTokenPrefix)
99
7
  };
100
8
  };
101
- exports.createTheme = createTheme;
102
9
 
103
10
  //# sourceMappingURL=createTheme.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["defaultTheme","styles","emotionMap","characterLimit","code","codeHighlight","atrule","attr","boolean","builtin","cdata","char","class","comment","constant","deleted","doctype","entity","function","important","inserted","keyword","namespace","number","operator","prolog","property","punctuation","regex","selector","string","symbol","tag","url","variable","embedBlock","base","focus","hashtag","heading","h1","h2","h3","h4","h5","h6","link","list","listitem","listitemChecked","listitemUnchecked","nested","olDepth","ul","ltr","mark","markOverlap","paragraph","quote","rtl","text","bold","italic","strikethrough","subscript","superscript","underline","underlineStrikethrough","fontColorText","image","indent","inlineImage","createTheme","theme","exports"],"sources":["createTheme.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\nimport { ThemeEmotionMap } from \"~/types\";\n\nexport type EditorTheme = {\n styles: Record<string, any>;\n emotionMap: ThemeEmotionMap;\n} & EditorThemeClasses;\n\nconst defaultTheme: EditorTheme = {\n styles: {},\n emotionMap: {},\n characterLimit: \"WebinyLexical__characterLimit\",\n code: \"WebinyLexical__code\",\n codeHighlight: {\n atrule: \"WebinyLexical__tokenAttr\",\n attr: \"WebinyLexical__tokenAttr\",\n boolean: \"WebinyLexical__tokenProperty\",\n builtin: \"WebinyLexical__tokenSelector\",\n cdata: \"WebinyLexical__tokenComment\",\n char: \"WebinyLexical__tokenSelector\",\n class: \"WebinyLexical__tokenFunction\",\n \"class-name\": \"WebinyLexical__tokenFunction\",\n comment: \"WebinyLexical__tokenComment\",\n constant: \"WebinyLexical__tokenProperty\",\n deleted: \"WebinyLexical__tokenProperty\",\n doctype: \"WebinyLexical__tokenComment\",\n entity: \"WebinyLexical__tokenOperator\",\n function: \"WebinyLexical__tokenFunction\",\n important: \"WebinyLexical__tokenVariable\",\n inserted: \"WebinyLexical__tokenSelector\",\n keyword: \"WebinyLexical__tokenAttr\",\n namespace: \"WebinyLexical__tokenVariable\",\n number: \"WebinyLexical__tokenProperty\",\n operator: \"WebinyLexical__tokenOperator\",\n prolog: \"WebinyLexical__tokenComment\",\n property: \"WebinyLexical__tokenProperty\",\n punctuation: \"WebinyLexical__tokenPunctuation\",\n regex: \"WebinyLexical__tokenVariable\",\n selector: \"WebinyLexical__tokenSelector\",\n string: \"WebinyLexical__tokenSelector\",\n symbol: \"WebinyLexical__tokenProperty\",\n tag: \"WebinyLexical__tokenProperty\",\n url: \"WebinyLexical__tokenOperator\",\n variable: \"WebinyLexical__tokenVariable\"\n },\n embedBlock: {\n base: \"WebinyLexical__embedBlock\",\n focus: \"WebinyLexical__embedBlockFocus\"\n },\n hashtag: \"WebinyLexical__hashtag\",\n heading: {\n h1: \"WebinyLexical__h1\",\n h2: \"WebinyLexical__h2\",\n h3: \"WebinyLexical__h3\",\n h4: \"WebinyLexical__h4\",\n h5: \"WebinyLexical__h5\",\n h6: \"WebinyLexical__h6\"\n },\n link: \"WebinyLexical__link\",\n list: {\n listitem: \"WebinyLexical__listItem\",\n listitemChecked: \"WebinyLexical__listItemChecked\",\n listitemUnchecked: \"WebinyLexical__listItemUnchecked\",\n nested: {\n listitem: \"WebinyLexical__nestedListItem\"\n },\n olDepth: [\n \"WebinyLexical__ol1\",\n \"WebinyLexical__ol2\",\n \"WebinyLexical__ol3\",\n \"WebinyLexical__ol4\",\n \"WebinyLexical__ol5\"\n ],\n ul: \"WebinyLexical__ul\"\n },\n ltr: \"WebinyLexical__ltr\",\n mark: \"WebinyLexical__mark\",\n markOverlap: \"WebinyLexical__markOverlap\",\n paragraph: \"WebinyLexical__paragraph\",\n quote: \"WebinyLexical__quote\",\n rtl: \"WebinyLexical__rtl\",\n text: {\n bold: \"WebinyLexical__textBold\",\n code: \"WebinyLexical__textCode\",\n italic: \"WebinyLexical__textItalic\",\n strikethrough: \"WebinyLexical__textStrikethrough\",\n subscript: \"WebinyLexical__textSubscript\",\n superscript: \"WebinyLexical__textSuperscript\",\n underline: \"WebinyLexical__textUnderline\",\n underlineStrikethrough: \"WebinyLexical__textUnderlineStrikethrough\"\n },\n fontColorText: \"WebinyLexical__fontColorText\",\n image: \"editor-image\",\n indent: \"PlaygroundEditorTheme__indent\",\n inlineImage: \"inline-editor-image\"\n};\n\nexport const createTheme = ({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n styles,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n emotionMap,\n ...theme\n}: Partial<EditorThe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AmB;IACvBC,EAAE,EAAE,mBAAmB;IACvBC,EAAE,EAAE,mBAAmB;IACvBC,EAAE,EAAE,mBAAmB;IACvBC,EAAE,EAAE;EACR,CAAC;EACDC,IAAI,EAAE,qBAAqB;EAC3BC,IAAI,EAAE;IACFC,QAAQ,EAAE,yBAAyB;IACnCC,eAAe,EAAE,gCAAgC;IACjDC,iBAAiB,EAAE,kCAAkC;IACrDC,MAAM,EAAE;MACJH,QAAQ,EAAE;IACd,CAAC;IACDI,OAAO,EAAE,CACL,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,CACvB;IACDC,EAAE,EAAE;EACR,CAAC;EACDC,GAAG,EAAE,oBAAoB;EACzBC,IAAI,EAAE,qBAAqB;EAC3BC,WAAW,EAAE,4BAA4B;EACzCC,SAAS,EAAE,0BAA0B;EACrCC,KAAK,EAAE,sBAAsB;EAC7BC,GAAG,EAAE,oBAAoB;EACzBC,IAAI,EAAE;IACFC,IAAI,EAAE,yBAAyB;IAC/BzD,IAAI,EAAE,yBAAyB;IAC/B0D,MAAM,EAAE,2BAA2B;IACnCC,aAAa,EAAE,kCAAkC;IACjDC,SAAS,EAAE,8BAA8B;IACzCC,WAAW,EAAE,gCAAgC;IAC7CC,SAAS,EAAE,8BAA8B;IACzCC,sBAAsB,EAAE;EAC5B,CAAC;EACDC,aAAa,EAAE,8BAA8B;EAC7CC,KAAK,EAAE,cAAc;EACrBC,MAAM,EAAE,+BAA+B;EACvCC,WAAW,EAAE;AACjB,CAAC;AAEM,MAAMC,WAAW,GAAGA,CAAC;EACxB;EACAvE,MAAM;EACN;EACAC,UAAU;EACV,GAAGuE;AACe,CAAC,KAAkB;EACrC,OAAO;IAAE,GAAGzE,YAAY;IAAE,GAAGyE;EAAM,CAAC;AACxC,CAAC;AAACC,OAAA,CAAAF,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"names":["createLexicalTokens","createTheme","params","colors","typography","tokens","lexicalTokenPrefix"],"sources":["createTheme.ts"],"sourcesContent":["import type { ColorValue, EditorTheme, TypographyValue } from \"~/types.js\";\nimport { createLexicalTokens } from \"~/createLexicalEditorTokens.js\";\n\nexport interface CreateThemeParams {\n colors: ColorValue[];\n typography: Record<string, TypographyValue[]>;\n lexicalTokenPrefix: string;\n}\n\nexport const createTheme = (params: CreateThemeParams): EditorTheme => {\n return {\n colors: params.colors,\n typography: params.typography,\n tokens: createLexicalTokens(params.lexicalTokenPrefix)\n };\n};\n"],"mappings":"AACA,SAASA,mBAAmB;AAQ5B,OAAO,MAAMC,WAAW,GAAIC,MAAyB,IAAkB;EACnE,OAAO;IACHC,MAAM,EAAED,MAAM,CAACC,MAAM;IACrBC,UAAU,EAAEF,MAAM,CAACE,UAAU;IAC7BC,MAAM,EAAEL,mBAAmB,CAACE,MAAM,CAACI,kBAAkB;EACzD,CAAC;AACL,CAAC","ignoreList":[]}
package/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export * from "./createTheme";
2
- export * from "./types";
3
- export * from "./utils/findTypographyStyleByHtmlTag";
4
- export * from "./utils/toTypographyEmotionMap";
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,6 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
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
- });
1
+ export * from "./createTheme.js";
2
+ export * from "./types.js";
3
+ export * from "./Theme.js";
4
+ export * from "./toTypographyMap.js";
61
5
 
62
6
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
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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AA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAG,uBAAA,CAAAP,GAAA;IAAA;EAAA;AAAA;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":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./createTheme.js\";\nexport * from \"./types.js\";\nexport * from \"./Theme.js\";\nexport * from \"./toTypographyMap.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA","ignoreList":[]}
package/package.json CHANGED
@@ -1,22 +1,16 @@
1
1
  {
2
2
  "name": "@webiny/lexical-theme",
3
- "version": "5.44.1-beta.1",
3
+ "version": "5.45.0-beta.0",
4
+ "type": "module",
4
5
  "dependencies": {
5
- "@emotion/react": "11.10.8",
6
- "emotion": "10.0.27",
7
- "lexical": "0.23.1",
8
- "react-style-object-to-css": "1.1.2"
6
+ "lexical": "0.40.0"
9
7
  },
10
8
  "devDependencies": {
11
- "@webiny/project-utils": "5.44.1-beta.1"
9
+ "@webiny/build-tools": "5.45.0-beta.0"
12
10
  },
13
11
  "publishConfig": {
14
12
  "access": "public",
15
13
  "directory": "dist"
16
14
  },
17
- "scripts": {
18
- "build": "node ../cli/bin.js run build",
19
- "watch": "node ../cli/bin.js run watch"
20
- },
21
- "gitHead": "ff5f085c417040291d39fdbe5153067f3a23ed86"
15
+ "gitHead": "b85c33cfbe7c02c130445c918d913ef4b2c09cb2"
22
16
  }
@@ -0,0 +1,2 @@
1
+ import type { EditorTheme, TypographyMap } from "./types.js";
2
+ export declare const toTypographyMap: (theme: EditorTheme) => TypographyMap;
@@ -0,0 +1,14 @@
1
+ export const toTypographyMap = theme => {
2
+ const typographyStyles = theme.typography;
3
+ if (!typographyStyles) {
4
+ return {};
5
+ }
6
+ return Object.keys(typographyStyles).reduce((acc, key) => {
7
+ for (const style of typographyStyles[key]) {
8
+ acc[style.id] = style;
9
+ }
10
+ return acc;
11
+ }, {});
12
+ };
13
+
14
+ //# sourceMappingURL=toTypographyMap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["toTypographyMap","theme","typographyStyles","typography","Object","keys","reduce","acc","key","style","id"],"sources":["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"],"mappings":"AAEA,OAAO,MAAMA,eAAe,GAAIC,KAAkB,IAAoB;EAClE,MAAMC,gBAAgB,GAAGD,KAAK,CAACE,UAAU;EACzC,IAAI,CAACD,gBAAgB,EAAE;IACnB,OAAO,CAAC,CAAC;EACb;EAEA,OAAOE,MAAM,CAACC,IAAI,CAACH,gBAAgB,CAAC,CAACI,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;IACtD,KAAK,MAAMC,KAAK,IAAIP,gBAAgB,CAACM,GAAG,CAAC,EAAE;MACvCD,GAAG,CAACE,KAAK,CAACC,EAAE,CAAC,GAAGD,KAAK;IACzB;IACA,OAAOF,GAAG;EACd,CAAC,EAAE,CAAC,CAAkB,CAAC;AAC3B,CAAC","ignoreList":[]}
package/types.d.ts CHANGED
@@ -1,21 +1,18 @@
1
- import type { CSSObject } from "@emotion/react";
2
- export type ListHtmlTag = "ol" | "ul";
3
- export type HeadingHtmlTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
4
- export type ParagraphHtmlTag = "p";
5
- export type QuoteBlockHtmlTag = "quoteblock";
6
- export type TypographyHTMLTag = HeadingHtmlTag | ParagraphHtmlTag | ListHtmlTag | QuoteBlockHtmlTag;
1
+ import type { EditorThemeClasses } from "lexical";
2
+ export type ColorValue = {
3
+ id: string;
4
+ label: string;
5
+ value: string;
6
+ };
7
7
  export type TypographyValue = {
8
- css: CSSObject;
9
8
  id: string;
10
- tag: TypographyHTMLTag;
11
- name: string;
9
+ tag: string;
10
+ label: string;
11
+ className: string;
12
12
  };
13
- export type ThemeEmotionMap = {
14
- [styleId: string]: {
15
- id: string;
16
- tag: TypographyHTMLTag;
17
- name: string;
18
- styles: Record<string, any>;
19
- className: string;
20
- };
13
+ export type EditorTheme = {
14
+ colors: ColorValue[];
15
+ typography: Record<string, TypographyValue[]>;
16
+ tokens: EditorThemeClasses;
21
17
  };
18
+ export type TypographyMap = Record<string, TypographyValue>;
package/types.js CHANGED
@@ -1,7 +1,3 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
1
+ export {};
6
2
 
7
3
  //# sourceMappingURL=types.js.map
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { CSSObject } from \"@emotion/react\";\n\n// Supported HTML tags.\nexport type ListHtmlTag = \"ol\" | \"ul\";\nexport type HeadingHtmlTag = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\nexport type ParagraphHtmlTag = \"p\";\nexport type QuoteBlockHtmlTag = \"quoteblock\";\n\nexport type TypographyHTMLTag = HeadingHtmlTag | ParagraphHtmlTag | ListHtmlTag | QuoteBlockHtmlTag;\n\nexport type TypographyValue = {\n css: CSSObject;\n id: string;\n tag: TypographyHTMLTag;\n name: 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: TypographyHTMLTag;\n name: string;\n styles: Record<string, any>;\n // emotion generated class\n className: string;\n };\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\n\nexport type ColorValue = {\n id: string;\n label: string;\n value: string;\n};\n\nexport type TypographyValue = {\n id: string;\n tag: string;\n label: string;\n className: string;\n};\n\nexport type EditorTheme = {\n colors: ColorValue[];\n typography: Record<string, TypographyValue[]>;\n tokens: EditorThemeClasses;\n};\n\nexport type TypographyMap = Record<string, TypographyValue>;\n"],"mappings":"","ignoreList":[]}
@@ -1,8 +0,0 @@
1
- import { ThemeEmotionMap } from "../types";
2
- export declare const findTypographyStyleByHtmlTag: (htmlTag: string, themeEmotionMap: ThemeEmotionMap) => {
3
- id: string;
4
- tag: import("../types").TypographyHTMLTag;
5
- name: string;
6
- styles: Record<string, any>;
7
- className: string;
8
- } | undefined;
@@ -1,18 +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
- for (const styleId in themeEmotionMap) {
9
- const style = themeEmotionMap[styleId];
10
- if (style.tag === htmlTag) {
11
- return style;
12
- }
13
- }
14
- return undefined;
15
- };
16
- exports.findTypographyStyleByHtmlTag = findTypographyStyleByHtmlTag;
17
-
18
- //# sourceMappingURL=findTypographyStyleByHtmlTag.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["findTypographyStyleByHtmlTag","htmlTag","themeEmotionMap","styleId","style","tag","undefined","exports"],"sources":["findTypographyStyleByHtmlTag.ts"],"sourcesContent":["import { ThemeEmotionMap } from \"~/types\";\n\nexport const findTypographyStyleByHtmlTag = (htmlTag: string, themeEmotionMap: ThemeEmotionMap) => {\n for (const styleId in themeEmotionMap) {\n const style = themeEmotionMap[styleId];\n if (style.tag === htmlTag) {\n return style;\n }\n }\n return undefined;\n};\n"],"mappings":";;;;;;AAEO,MAAMA,4BAA4B,GAAGA,CAACC,OAAe,EAAEC,eAAgC,KAAK;EAC/F,KAAK,MAAMC,OAAO,IAAID,eAAe,EAAE;IACnC,MAAME,KAAK,GAAGF,eAAe,CAACC,OAAO,CAAC;IACtC,IAAIC,KAAK,CAACC,GAAG,KAAKJ,OAAO,EAAE;MACvB,OAAOG,KAAK;IAChB;EACJ;EACA,OAAOE,SAAS;AACpB,CAAC;AAACC,OAAA,CAAAP,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- import type { CSSObject } from "@emotion/react";
2
- export declare const styleObjectToString: (styleObject: CSSObject) => string;
@@ -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 { ThemeEmotionMap } from "../types";
2
- import { EditorTheme } from "../createTheme";
3
- import { css as EmotionCSS } from "emotion";
4
- export declare const toTypographyEmotionMap: (css: typeof EmotionCSS, theme: EditorTheme, themeStylesTransformer?: any) => ThemeEmotionMap;
@@ -1,41 +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
- // 'lx' (abbreviation of lexical) variable will lead to generate shorter class names.
22
- // for example: instead of default 'css-181qz4b-453f345f'
23
- // the last segment will always end with 'lx' or 'css-181qz4b-lx'
24
-
25
- let transformedStyles = styleItem.styles;
26
- if (themeStylesTransformer) {
27
- transformedStyles = themeStylesTransformer(styleItem.styles);
28
- }
29
- const lx = {
30
- ...styleItem,
31
- className: [css(transformedStyles)].filter(Boolean).join(" ")
32
- };
33
- map[styleItem.id] = lx;
34
- });
35
- }
36
- }
37
- return map;
38
- };
39
- exports.toTypographyEmotionMap = toTypographyEmotionMap;
40
-
41
- //# sourceMappingURL=toTypographyEmotionMap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["toTypographyEmotionMap","css","theme","themeStylesTransformer","map","typographyStyles","styles","typography","key","typographyTypeData","forEach","styleItem","transformedStyles","lx","className","filter","Boolean","join","id","exports"],"sources":["toTypographyEmotionMap.ts"],"sourcesContent":["import { ThemeEmotionMap, TypographyHTMLTag } from \"~/types\";\nimport { EditorTheme } from \"~/createTheme\";\nimport { css as EmotionCSS } from \"emotion\";\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 {\n id: string;\n tag: TypographyHTMLTag;\n name: string;\n styles: Record<string, any>;\n }[];\n if (typographyTypeData) {\n typographyTypeData.forEach(styleItem => {\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\n let transformedStyles = styleItem.styles;\n if (themeStylesTransformer) {\n transformedStyles = themeStylesTransformer(styleItem.styles);\n }\n\n const lx = {\n ...styleItem,\n className: [css(transformedStyles)].filter(Boolean).join(\" \")\n };\n map[styleItem.id] = lx;\n });\n }\n }\n\n return map;\n};\n"],"mappings":";;;;;;AAIA;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,CAK5C;IACH,IAAIC,kBAAkB,EAAE;MACpBA,kBAAkB,CAACC,OAAO,CAACC,SAAS,IAAI;QACpC;QACA;QACA;;QAEA,IAAIC,iBAAiB,GAAGD,SAAS,CAACL,MAAM;QACxC,IAAIH,sBAAsB,EAAE;UACxBS,iBAAiB,GAAGT,sBAAsB,CAACQ,SAAS,CAACL,MAAM,CAAC;QAChE;QAEA,MAAMO,EAAE,GAAG;UACP,GAAGF,SAAS;UACZG,SAAS,EAAE,CAACb,GAAG,CAACW,iBAAiB,CAAC,CAAC,CAACG,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,GAAG;QAChE,CAAC;QACDb,GAAG,CAACO,SAAS,CAACO,EAAE,CAAC,GAAGL,EAAE;MAC1B,CAAC,CAAC;IACN;EACJ;EAEA,OAAOT,GAAG;AACd,CAAC;AAACe,OAAA,CAAAnB,sBAAA,GAAAA,sBAAA","ignoreList":[]}