@webiny/lexical-theme 0.0.0-unstable.de38392959 → 0.0.0-unstable.e0bfc55d5a

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/createTheme.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import type { EditorThemeClasses } from "lexical";
2
- import "./theme.css";
3
- import { ThemeEmotionMap } from "./types";
4
- export declare type WebinyTheme = {
5
- styles?: Record<string, any>;
6
- emotionMap?: ThemeEmotionMap;
7
- };
8
- export declare type EditorTheme = WebinyTheme & EditorThemeClasses;
9
- export declare const createTheme: () => EditorTheme;
2
+ import type { 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;
package/createTheme.js CHANGED
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createTheme = void 0;
7
- require("./theme.css");
8
7
  const defaultTheme = {
9
- styles: undefined,
10
- emotionMap: undefined,
8
+ styles: {},
9
+ emotionMap: {},
11
10
  characterLimit: "WebinyLexical__characterLimit",
12
11
  code: "WebinyLexical__code",
13
12
  codeHighlight: {
@@ -87,8 +86,17 @@ const defaultTheme = {
87
86
  indent: "PlaygroundEditorTheme__indent",
88
87
  inlineImage: "inline-editor-image"
89
88
  };
90
- const createTheme = () => {
91
- return defaultTheme;
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
+ };
92
100
  };
93
101
  exports.createTheme = createTheme;
94
102
 
@@ -1 +1 @@
1
- {"version":3,"names":["require","defaultTheme","styles","undefined","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","exports"],"sources":["createTheme.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\n\nimport \"./theme.css\";\nimport { ThemeEmotionMap } from \"~/types\";\n\nexport type WebinyTheme = {\n styles?: Record<string, any>;\n emotionMap?: ThemeEmotionMap;\n};\n\nexport type EditorTheme = WebinyTheme & EditorThemeClasses;\n\nconst defaultTheme: EditorTheme = {\n styles: undefined,\n emotionMap: undefined,\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 = (): EditorTheme => {\n return defaultTheme;\n};\n"],"mappings":";;;;;;AAEAA,OAAA;AAUA,MAAMC,YAAyB,GAAG;EAC9BC,MAAM,EAAEC,SAAS;EACjBC,UAAU,EAAED,SAAS;EACrBE,cAAc,EAAE,+BAA+B;EAC/CC,IAAI,EAAE,qBAAqB;EAC3BC,aAAa,EAAE;IACXC,MAAM,EAAE,0BAA0B;IAClCC,IAAI,EAAE,0BAA0B;IAChCC,OAAO,EAAE,8BAA8B;IACvCC,OAAO,EAAE,8BAA8B;IACvCC,KAAK,EAAE,6BAA6B;IACpCC,IAAI,EAAE,8BAA8B;IACpCC,KAAK,EAAE,8BAA8B;IACrC,YAAY,EAAE,8BAA8B;IAC5CC,OAAO,EAAE,6BAA6B;IACtCC,QAAQ,EAAE,8BAA8B;IACxCC,OAAO,EAAE,8BAA8B;IACvCC,OAAO,EAAE,6BAA6B;IACtCC,MAAM,EAAE,8BAA8B;IACtCC,QAAQ,EAAE,8BAA8B;IACxCC,SAAS,EAAE,8BAA8B;IACzCC,QAAQ,EAAE,8BAA8B;IACxCC,OAAO,EAAE,0BAA0B;IACnCC,SAAS,EAAE,8BAA8B;IACzCC,MAAM,EAAE,8BAA8B;IACtCC,QAAQ,EAAE,8BAA8B;IACxCC,MAAM,EAAE,6BAA6B;IACrCC,QAAQ,EAAE,8BAA8B;IACxCC,WAAW,EAAE,iCAAiC;IAC9CC,KAAK,EAAE,8BAA8B;IACrCC,QAAQ,EAAE,8BAA8B;IACxCC,MAAM,EAAE,8BAA8B;IACtCC,MAAM,EAAE,8BAA8B;IACtCC,GAAG,EAAE,8BAA8B;IACnCC,GAAG,EAAE,8BAA8B;IACnCC,QAAQ,EAAE;EACd,CAAC;EACDC,UAAU,EAAE;IACRC,IAAI,EAAE,2BAA2B;IACjCC,KAAK,EAAE;EACX,CAAC;EACDC,OAAO,EAAE,wBAAwB;EACjCC,OAAO,EAAE;IACLC,EAAE,EAAE,mBAAmB;IACvBC,EAAE,EAAE,mBAAmB;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,CAAA,KAAmB;EAC1C,OAAOzE,YAAY;AACvB,CAAC;AAAC0E,OAAA,CAAAD,WAAA,GAAAA,WAAA"}
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 type { 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<EditorTheme>): EditorTheme => {\n return { ...defaultTheme, ...theme };\n};\n"],"mappings":"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","ignoreList":[]}
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,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,YAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,6BAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,6BAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,6BAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,6BAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,uBAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,uBAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,uBAAA,CAAAP,GAAA;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"}
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,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,YAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,6BAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,6BAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,6BAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAE,6BAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,uBAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,uBAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,uBAAA,CAAAP,GAAA;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":[]}
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@webiny/lexical-theme",
3
- "version": "0.0.0-unstable.de38392959",
3
+ "version": "0.0.0-unstable.e0bfc55d5a",
4
4
  "dependencies": {
5
5
  "@emotion/react": "11.10.8",
6
- "lexical": "0.12.2",
6
+ "emotion": "10.0.27",
7
+ "lexical": "0.23.1",
7
8
  "react-style-object-to-css": "1.1.2"
8
9
  },
9
10
  "devDependencies": {
10
- "@webiny/cli": "0.0.0-unstable.de38392959",
11
- "@webiny/project-utils": "0.0.0-unstable.de38392959"
11
+ "@webiny/project-utils": "0.0.0-unstable.e0bfc55d5a"
12
12
  },
13
13
  "publishConfig": {
14
14
  "access": "public",
15
15
  "directory": "dist"
16
16
  },
17
17
  "scripts": {
18
- "build": "yarn webiny run build",
19
- "watch": "yarn webiny run watch"
18
+ "build": "node ../cli/bin.js run build",
19
+ "watch": "node ../cli/bin.js run watch"
20
20
  },
21
- "gitHead": "de38392959f2692d1feb08945a3588cd80e4924c"
21
+ "gitHead": "e0bfc55d5a4d6a42b32e6558d9fb2eb6753e331b"
22
22
  }
package/theme.css CHANGED
@@ -87,8 +87,11 @@
87
87
  border-bottom: 1px solid rgba(88, 144, 255, 0.3);
88
88
  }
89
89
  .WebinyLexical__link {
90
- color: rgb(33, 111, 219);
90
+ color: #fa5723;
91
91
  text-decoration: none;
92
+ > * {
93
+ color: inherit !important;
94
+ }
92
95
  }
93
96
  .WebinyLexical__link:hover {
94
97
  text-decoration: underline;
@@ -319,7 +322,7 @@
319
322
  }
320
323
  .WebinyLexical__listItemUnchecked:before,
321
324
  .WebinyLexical__listItemChecked:before {
322
- content: '';
325
+ content: "";
323
326
  width: 16px;
324
327
  height: 16px;
325
328
  top: 2px;
@@ -329,8 +332,8 @@
329
332
  background-size: cover;
330
333
  position: absolute;
331
334
  }
332
- .WebinyLexical__listItemUnchecked[dir='rtl']:before,
333
- .WebinyLexical__listItemChecked[dir='rtl']:before {
335
+ .WebinyLexical__listItemUnchecked[dir="rtl"]:before,
336
+ .WebinyLexical__listItemChecked[dir="rtl"]:before {
334
337
  left: auto;
335
338
  right: 0;
336
339
  }
@@ -350,7 +353,7 @@
350
353
  background-repeat: no-repeat;
351
354
  }
352
355
  .WebinyLexical__listItemChecked:after {
353
- content: '';
356
+ content: "";
354
357
  cursor: pointer;
355
358
  border-color: #fff;
356
359
  border-style: solid;
package/types.d.ts CHANGED
@@ -1,21 +1,17 @@
1
1
  import type { CSSObject } from "@emotion/react";
2
- export declare type ListHtmlTag = "ol" | "ul";
3
- export declare type HeadingHtmlTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
4
- export declare type ParagraphHtmlTag = "p";
5
- export declare type QuoteBlockHtmlTag = "quoteblock";
6
- export declare type TypographyHTMLTag = HeadingHtmlTag | ParagraphHtmlTag | ListHtmlTag | QuoteBlockHtmlTag;
7
- export declare type TypographyValue = {
8
- css: CSSObject;
2
+ export type TypographyValue = {
9
3
  id: string;
10
- tag: TypographyHTMLTag;
4
+ tag: string;
11
5
  name: string;
6
+ css?: CSSObject;
7
+ className?: string;
12
8
  };
13
- export declare type ThemeEmotionMap = {
9
+ export type ThemeEmotionMap = {
14
10
  [styleId: string]: {
15
11
  id: string;
16
- tag: TypographyHTMLTag;
12
+ tag: string;
17
13
  name: string;
18
- styles: Record<string, any>;
14
+ styles?: Record<string, any>;
19
15
  className: string;
20
16
  };
21
17
  };
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":""}
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 +1,8 @@
1
- import { ThemeEmotionMap } from "../types";
2
- export declare const findTypographyStyleByHtmlTag: (htmlTag: string, themeEmotionMap: ThemeEmotionMap) => {
1
+ import type { ThemeEmotionMap } from "../types";
2
+ export declare const findTypographyStyleByHtmlTag: (htmlTag: string | string[], themeEmotionMap: ThemeEmotionMap) => {
3
3
  id: string;
4
- tag: import("../types").TypographyHTMLTag;
4
+ tag: string;
5
5
  name: string;
6
- styles: Record<string, any>;
6
+ styles?: Record<string, any> | undefined;
7
7
  className: string;
8
8
  } | undefined;
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.findTypographyStyleByHtmlTag = void 0;
7
7
  const findTypographyStyleByHtmlTag = (htmlTag, themeEmotionMap) => {
8
+ const tags = Array.isArray(htmlTag) ? htmlTag : [htmlTag];
8
9
  for (const styleId in themeEmotionMap) {
9
10
  const style = themeEmotionMap[styleId];
10
- if (style.tag === htmlTag) {
11
+ if (tags.includes(style.tag)) {
11
12
  return style;
12
13
  }
13
14
  }
@@ -1 +1 @@
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"}
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 +1 @@
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"}
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,3 +1,4 @@
1
- import { ThemeEmotionMap } from "../types";
2
- import { WebinyTheme } from "../createTheme";
3
- export declare const toTypographyEmotionMap: (css: (cssStyle: Record<string, any>) => string, theme: WebinyTheme, themeStylesTransformer?: any) => ThemeEmotionMap;
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;
@@ -18,19 +18,23 @@ const toTypographyEmotionMap = (css, theme, themeStylesTransformer) => {
18
18
  const typographyTypeData = typographyStyles[key];
19
19
  if (typographyTypeData) {
20
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
+
21
27
  // 'lx' (abbreviation of lexical) variable will lead to generate shorter class names.
22
28
  // for example: instead of default 'css-181qz4b-453f345f'
23
29
  // the last segment will always end with 'lx' or 'css-181qz4b-lx'
24
-
25
30
  let transformedStyles = styleItem.styles;
26
31
  if (themeStylesTransformer) {
27
32
  transformedStyles = themeStylesTransformer(styleItem.styles);
28
33
  }
29
- const lx = {
34
+ map[styleItem.id] = {
30
35
  ...styleItem,
31
36
  className: [css(transformedStyles)].filter(Boolean).join(" ")
32
37
  };
33
- map[styleItem.id] = lx;
34
38
  });
35
39
  }
36
40
  }
@@ -1 +1 @@
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 { WebinyTheme } from \"~/createTheme\";\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: (cssStyle: Record<string, any>) => string,\n theme: WebinyTheme,\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":";;;;;;AAGA;AACA;AACA;AACA;AACO,MAAMA,sBAAsB,GAAGA,CAClCC,GAA8C,EAC9CC,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"}
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":[]}