@webiny/lexical-editor 0.0.0-unstable.1145e7667f

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.
Files changed (279) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/commands/webiny-list.d.ts +7 -0
  4. package/commands/webiny-list.js +13 -0
  5. package/commands/webiny-list.js.map +1 -0
  6. package/commands/webiny-quote.d.ts +5 -0
  7. package/commands/webiny-quote.js +9 -0
  8. package/commands/webiny-quote.js.map +1 -0
  9. package/components/AddRichTextEditorNodeType.d.ts +6 -0
  10. package/components/AddRichTextEditorNodeType.js +28 -0
  11. package/components/AddRichTextEditorNodeType.js.map +1 -0
  12. package/components/AddRichTextEditorPlugin.d.ts +12 -0
  13. package/components/AddRichTextEditorPlugin.js +33 -0
  14. package/components/AddRichTextEditorPlugin.js.map +1 -0
  15. package/components/AddToolbarAction.d.ts +7 -0
  16. package/components/AddToolbarAction.js +33 -0
  17. package/components/AddToolbarAction.js.map +1 -0
  18. package/components/Editor/HeadingEditor.d.ts +7 -0
  19. package/components/Editor/HeadingEditor.js +29 -0
  20. package/components/Editor/HeadingEditor.js.map +1 -0
  21. package/components/Editor/ParagraphEditor.d.ts +7 -0
  22. package/components/Editor/ParagraphEditor.js +30 -0
  23. package/components/Editor/ParagraphEditor.js.map +1 -0
  24. package/components/Editor/RichTextEditor.d.ts +26 -0
  25. package/components/Editor/RichTextEditor.js +138 -0
  26. package/components/Editor/RichTextEditor.js.map +1 -0
  27. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +9 -0
  28. package/components/LexicalEditorConfig/LexicalEditorConfig.js +17 -0
  29. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
  30. package/components/LexicalHtmlRenderer.d.ts +16 -0
  31. package/components/LexicalHtmlRenderer.js +67 -0
  32. package/components/LexicalHtmlRenderer.js.map +1 -0
  33. package/components/Toolbar/HeadingToolbar.d.ts +12 -0
  34. package/components/Toolbar/HeadingToolbar.js +23 -0
  35. package/components/Toolbar/HeadingToolbar.js.map +1 -0
  36. package/components/Toolbar/ParagraphToolbar.d.ts +12 -0
  37. package/components/Toolbar/ParagraphToolbar.js +23 -0
  38. package/components/Toolbar/ParagraphToolbar.js.map +1 -0
  39. package/components/Toolbar/Toolbar.css +423 -0
  40. package/components/Toolbar/Toolbar.d.ts +13 -0
  41. package/components/Toolbar/Toolbar.js +181 -0
  42. package/components/Toolbar/Toolbar.js.map +1 -0
  43. package/components/ToolbarActions/BoldAction.d.ts +2 -0
  44. package/components/ToolbarActions/BoldAction.js +43 -0
  45. package/components/ToolbarActions/BoldAction.js.map +1 -0
  46. package/components/ToolbarActions/BulletListAction.d.ts +2 -0
  47. package/components/ToolbarActions/BulletListAction.js +51 -0
  48. package/components/ToolbarActions/BulletListAction.js.map +1 -0
  49. package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
  50. package/components/ToolbarActions/CodeHighlightAction.js +43 -0
  51. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
  52. package/components/ToolbarActions/FontColorAction.d.ts +11 -0
  53. package/components/ToolbarActions/FontColorAction.js +83 -0
  54. package/components/ToolbarActions/FontColorAction.js.map +1 -0
  55. package/components/ToolbarActions/FontSizeAction.d.ts +2 -0
  56. package/components/ToolbarActions/FontSizeAction.js +101 -0
  57. package/components/ToolbarActions/FontSizeAction.js.map +1 -0
  58. package/components/ToolbarActions/ItalicAction.d.ts +2 -0
  59. package/components/ToolbarActions/ItalicAction.js +43 -0
  60. package/components/ToolbarActions/ItalicAction.js.map +1 -0
  61. package/components/ToolbarActions/LinkAction.d.ts +2 -0
  62. package/components/ToolbarActions/LinkAction.js +64 -0
  63. package/components/ToolbarActions/LinkAction.js.map +1 -0
  64. package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
  65. package/components/ToolbarActions/NumberedListAction.js +53 -0
  66. package/components/ToolbarActions/NumberedListAction.js.map +1 -0
  67. package/components/ToolbarActions/QuoteAction.d.ts +2 -0
  68. package/components/ToolbarActions/QuoteAction.js +53 -0
  69. package/components/ToolbarActions/QuoteAction.js.map +1 -0
  70. package/components/ToolbarActions/TypographyAction.d.ts +11 -0
  71. package/components/ToolbarActions/TypographyAction.js +118 -0
  72. package/components/ToolbarActions/TypographyAction.js.map +1 -0
  73. package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
  74. package/components/ToolbarActions/UnderlineAction.js +43 -0
  75. package/components/ToolbarActions/UnderlineAction.js.map +1 -0
  76. package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +2 -0
  77. package/components/ToolbarPresets/HeadingToolbarPreset.js +52 -0
  78. package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -0
  79. package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +2 -0
  80. package/components/ToolbarPresets/ParagraphToolbarPreset.js +67 -0
  81. package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -0
  82. package/context/FontColorActionContext.d.ts +6 -0
  83. package/context/FontColorActionContext.js +10 -0
  84. package/context/FontColorActionContext.js.map +1 -0
  85. package/context/RichTextEditorContext.d.ts +21 -0
  86. package/context/RichTextEditorContext.js +56 -0
  87. package/context/RichTextEditorContext.js.map +1 -0
  88. package/context/SharedHistoryContext.d.ts +11 -0
  89. package/context/SharedHistoryContext.js +26 -0
  90. package/context/SharedHistoryContext.js.map +1 -0
  91. package/context/TypographyActionContext.d.ts +7 -0
  92. package/context/TypographyActionContext.js +10 -0
  93. package/context/TypographyActionContext.js.map +1 -0
  94. package/hooks/useFontColorPicker.d.ts +2 -0
  95. package/hooks/useFontColorPicker.js +15 -0
  96. package/hooks/useFontColorPicker.js.map +1 -0
  97. package/hooks/useRichTextEditor.d.ts +2 -0
  98. package/hooks/useRichTextEditor.js +15 -0
  99. package/hooks/useRichTextEditor.js.map +1 -0
  100. package/hooks/useTypographyAction.d.ts +1 -0
  101. package/hooks/useTypographyAction.js +15 -0
  102. package/hooks/useTypographyAction.js.map +1 -0
  103. package/hooks/useWebinyList.d.ts +2 -0
  104. package/hooks/useWebinyList.js +39 -0
  105. package/hooks/useWebinyList.js.map +1 -0
  106. package/hooks/useWebinyQuote.d.ts +2 -0
  107. package/hooks/useWebinyQuote.js +20 -0
  108. package/hooks/useWebinyQuote.js.map +1 -0
  109. package/images/icons/LICENSE.md +5 -0
  110. package/images/icons/chat-square-quote.svg +1 -0
  111. package/images/icons/chevron-down.svg +1 -0
  112. package/images/icons/code.svg +1 -0
  113. package/images/icons/font-color.svg +1 -0
  114. package/images/icons/link.svg +1 -0
  115. package/images/icons/list-ol.svg +1 -0
  116. package/images/icons/list-ul.svg +1 -0
  117. package/images/icons/pencil-fill.svg +1 -0
  118. package/images/icons/text-center.svg +1 -0
  119. package/images/icons/text-left.svg +1 -0
  120. package/images/icons/text-paragraph.svg +1 -0
  121. package/images/icons/text-right.svg +1 -0
  122. package/images/icons/type-bold.svg +1 -0
  123. package/images/icons/type-h1.svg +1 -0
  124. package/images/icons/type-h2.svg +1 -0
  125. package/images/icons/type-h3.svg +1 -0
  126. package/images/icons/type-h4.svg +1 -0
  127. package/images/icons/type-h5.svg +1 -0
  128. package/images/icons/type-h6.svg +1 -0
  129. package/images/icons/type-italic.svg +1 -0
  130. package/images/icons/type-strikethrough.svg +1 -0
  131. package/images/icons/type-underline.svg +1 -0
  132. package/images/icons/unlink_icon.svg +1 -0
  133. package/index.d.ts +40 -0
  134. package/index.js +281 -0
  135. package/index.js.map +1 -0
  136. package/nodes/FontColorNode.d.ts +43 -0
  137. package/nodes/FontColorNode.js +127 -0
  138. package/nodes/FontColorNode.js.map +1 -0
  139. package/nodes/TypographyElementNode.d.ts +42 -0
  140. package/nodes/TypographyElementNode.js +154 -0
  141. package/nodes/TypographyElementNode.js.map +1 -0
  142. package/nodes/WebinyQuoteNode.d.ts +29 -0
  143. package/nodes/WebinyQuoteNode.js +148 -0
  144. package/nodes/WebinyQuoteNode.js.map +1 -0
  145. package/nodes/list-node/WebinyListItemNode.d.ts +46 -0
  146. package/nodes/list-node/WebinyListItemNode.js +441 -0
  147. package/nodes/list-node/WebinyListItemNode.js.map +1 -0
  148. package/nodes/list-node/WebinyListNode.d.ts +38 -0
  149. package/nodes/list-node/WebinyListNode.js +253 -0
  150. package/nodes/list-node/WebinyListNode.js.map +1 -0
  151. package/nodes/list-node/formatList.d.ts +12 -0
  152. package/nodes/list-node/formatList.js +423 -0
  153. package/nodes/list-node/formatList.js.map +1 -0
  154. package/nodes/webinyNodes.d.ts +7 -0
  155. package/nodes/webinyNodes.js +21 -0
  156. package/nodes/webinyNodes.js.map +1 -0
  157. package/package.json +41 -0
  158. package/plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts +11 -0
  159. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +46 -0
  160. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +1 -0
  161. package/plugins/AutoLinkPlugin/index.d.ts +1 -0
  162. package/plugins/AutoLinkPlugin/index.js +16 -0
  163. package/plugins/AutoLinkPlugin/index.js.map +1 -0
  164. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
  165. package/plugins/BlurEventPlugin/BlurEventPlugin.js +28 -0
  166. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
  167. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +17 -0
  168. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +88 -0
  169. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +1 -0
  170. package/plugins/ClickableLinkPlugin/index.d.ts +1 -0
  171. package/plugins/ClickableLinkPlugin/index.js +16 -0
  172. package/plugins/ClickableLinkPlugin/index.js.map +1 -0
  173. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
  174. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +20 -0
  175. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
  176. package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
  177. package/plugins/CodeHighlightPlugin/index.js +16 -0
  178. package/plugins/CodeHighlightPlugin/index.js.map +1 -0
  179. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +118 -0
  180. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
  181. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +222 -0
  182. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
  183. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
  184. package/plugins/FloatingLinkEditorPlugin/index.js +16 -0
  185. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
  186. package/plugins/FontColorPlugin/FontColorPlugin.d.ts +2 -0
  187. package/plugins/FontColorPlugin/FontColorPlugin.js +38 -0
  188. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
  189. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +8 -0
  190. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +34 -0
  191. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -0
  192. package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -0
  193. package/plugins/LexicalUpdateStatePlugin/index.js +16 -0
  194. package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -0
  195. package/plugins/TypographyPlugin/TypographyPlugin.d.ts +2 -0
  196. package/plugins/TypographyPlugin/TypographyPlugin.js +31 -0
  197. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
  198. package/plugins/WebinyListPLugin/WebinyListPlugin.d.ts +1 -0
  199. package/plugins/WebinyListPLugin/WebinyListPlugin.js +25 -0
  200. package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +1 -0
  201. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts +1 -0
  202. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +24 -0
  203. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -0
  204. package/themes/webinyLexicalTheme.css +420 -0
  205. package/themes/webinyLexicalTheme.d.ts +9 -0
  206. package/themes/webinyLexicalTheme.js +87 -0
  207. package/themes/webinyLexicalTheme.js.map +1 -0
  208. package/types.d.ts +61 -0
  209. package/types.js +12 -0
  210. package/types.js.map +1 -0
  211. package/ui/Divider.d.ts +2 -0
  212. package/ui/Divider.js +13 -0
  213. package/ui/Divider.js.map +1 -0
  214. package/ui/DropDown.d.ts +26 -0
  215. package/ui/DropDown.js +173 -0
  216. package/ui/DropDown.js.map +1 -0
  217. package/ui/Input.css +32 -0
  218. package/ui/LinkPreview.css +69 -0
  219. package/ui/LinkPreview.d.ts +12 -0
  220. package/ui/LinkPreview.js +101 -0
  221. package/ui/LinkPreview.js.map +1 -0
  222. package/ui/Placeholder.css +23 -0
  223. package/ui/Placeholder.d.ts +13 -0
  224. package/ui/Placeholder.js +24 -0
  225. package/ui/Placeholder.js.map +1 -0
  226. package/ui/TextInput.d.ts +18 -0
  227. package/ui/TextInput.js +39 -0
  228. package/ui/TextInput.js.map +1 -0
  229. package/ui/ToolbarActionDialog.d.ts +12 -0
  230. package/ui/ToolbarActionDialog.js +106 -0
  231. package/ui/ToolbarActionDialog.js.map +1 -0
  232. package/utils/generateInitialLexicalValue.d.ts +5 -0
  233. package/utils/generateInitialLexicalValue.js +29 -0
  234. package/utils/generateInitialLexicalValue.js.map +1 -0
  235. package/utils/getDOMRangeRect.d.ts +10 -0
  236. package/utils/getDOMRangeRect.js +27 -0
  237. package/utils/getDOMRangeRect.js.map +1 -0
  238. package/utils/getLexicalTextSelectionState.d.ts +5 -0
  239. package/utils/getLexicalTextSelectionState.js +141 -0
  240. package/utils/getLexicalTextSelectionState.js.map +1 -0
  241. package/utils/getSelectedNode.d.ts +2 -0
  242. package/utils/getSelectedNode.js +30 -0
  243. package/utils/getSelectedNode.js.map +1 -0
  244. package/utils/isValidJSON.d.ts +1 -0
  245. package/utils/isValidJSON.js +18 -0
  246. package/utils/isValidJSON.js.map +1 -0
  247. package/utils/isValidLexicalData.d.ts +2 -0
  248. package/utils/isValidLexicalData.js +24 -0
  249. package/utils/isValidLexicalData.js.map +1 -0
  250. package/utils/nodes/clearNodeFormating.d.ts +2 -0
  251. package/utils/nodes/clearNodeFormating.js +28 -0
  252. package/utils/nodes/clearNodeFormating.js.map +1 -0
  253. package/utils/nodes/formatToParagraph.d.ts +2 -0
  254. package/utils/nodes/formatToParagraph.js +19 -0
  255. package/utils/nodes/formatToParagraph.js.map +1 -0
  256. package/utils/nodes/formatToQuote.d.ts +2 -0
  257. package/utils/nodes/formatToQuote.js +20 -0
  258. package/utils/nodes/formatToQuote.js.map +1 -0
  259. package/utils/nodes/list-node.d.ts +11 -0
  260. package/utils/nodes/list-node.js +107 -0
  261. package/utils/nodes/list-node.js.map +1 -0
  262. package/utils/point.d.ts +21 -0
  263. package/utils/point.js +77 -0
  264. package/utils/point.js.map +1 -0
  265. package/utils/rect.d.ts +47 -0
  266. package/utils/rect.js +169 -0
  267. package/utils/rect.js.map +1 -0
  268. package/utils/sanitizeUrl.d.ts +8 -0
  269. package/utils/sanitizeUrl.js +27 -0
  270. package/utils/sanitizeUrl.js.map +1 -0
  271. package/utils/setFloatingElemPosition.d.ts +3 -0
  272. package/utils/setFloatingElemPosition.js +40 -0
  273. package/utils/setFloatingElemPosition.js.map +1 -0
  274. package/utils/styleObjectToString.d.ts +2 -0
  275. package/utils/styleObjectToString.js +22 -0
  276. package/utils/styleObjectToString.js.map +1 -0
  277. package/utils/toTypographyEmotionMap.d.ts +3 -0
  278. package/utils/toTypographyEmotionMap.js +36 -0
  279. package/utils/toTypographyEmotionMap.js.map +1 -0
@@ -0,0 +1,9 @@
1
+ import type { EditorThemeClasses } from "lexical";
2
+ import "./webinyLexicalTheme.css";
3
+ import { ThemeEmotionMap } from "../types";
4
+ export declare type WebinyTheme = {
5
+ styles?: Record<string, any>;
6
+ emotionMap?: ThemeEmotionMap;
7
+ };
8
+ export declare type WebinyEditorTheme = WebinyTheme & EditorThemeClasses;
9
+ export declare const webinyEditorTheme: WebinyEditorTheme;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.webinyEditorTheme = void 0;
7
+ require("./webinyLexicalTheme.css");
8
+ var webinyEditorTheme = {
9
+ styles: undefined,
10
+ emotionMap: undefined,
11
+ characterLimit: "WebinyLexical__characterLimit",
12
+ code: "WebinyLexical__code",
13
+ codeHighlight: {
14
+ atrule: "WebinyLexical__tokenAttr",
15
+ attr: "WebinyLexical__tokenAttr",
16
+ boolean: "WebinyLexical__tokenProperty",
17
+ builtin: "WebinyLexical__tokenSelector",
18
+ cdata: "WebinyLexical__tokenComment",
19
+ char: "WebinyLexical__tokenSelector",
20
+ class: "WebinyLexical__tokenFunction",
21
+ "class-name": "WebinyLexical__tokenFunction",
22
+ comment: "WebinyLexical__tokenComment",
23
+ constant: "WebinyLexical__tokenProperty",
24
+ deleted: "WebinyLexical__tokenProperty",
25
+ doctype: "WebinyLexical__tokenComment",
26
+ entity: "WebinyLexical__tokenOperator",
27
+ function: "WebinyLexical__tokenFunction",
28
+ important: "WebinyLexical__tokenVariable",
29
+ inserted: "WebinyLexical__tokenSelector",
30
+ keyword: "WebinyLexical__tokenAttr",
31
+ namespace: "WebinyLexical__tokenVariable",
32
+ number: "WebinyLexical__tokenProperty",
33
+ operator: "WebinyLexical__tokenOperator",
34
+ prolog: "WebinyLexical__tokenComment",
35
+ property: "WebinyLexical__tokenProperty",
36
+ punctuation: "WebinyLexical__tokenPunctuation",
37
+ regex: "WebinyLexical__tokenVariable",
38
+ selector: "WebinyLexical__tokenSelector",
39
+ string: "WebinyLexical__tokenSelector",
40
+ symbol: "WebinyLexical__tokenProperty",
41
+ tag: "WebinyLexical__tokenProperty",
42
+ url: "WebinyLexical__tokenOperator",
43
+ variable: "WebinyLexical__tokenVariable"
44
+ },
45
+ embedBlock: {
46
+ base: "WebinyLexical__embedBlock",
47
+ focus: "WebinyLexical__embedBlockFocus"
48
+ },
49
+ hashtag: "WebinyLexical__hashtag",
50
+ heading: {
51
+ h1: "WebinyLexical__h1",
52
+ h2: "WebinyLexical__h2",
53
+ h3: "WebinyLexical__h3",
54
+ h4: "WebinyLexical__h4",
55
+ h5: "WebinyLexical__h5",
56
+ h6: "WebinyLexical__h6"
57
+ },
58
+ link: "WebinyLexical__link",
59
+ list: {
60
+ listitem: "WebinyLexical__listItem",
61
+ listitemChecked: "WebinyLexical__listItemChecked",
62
+ listitemUnchecked: "WebinyLexical__listItemUnchecked",
63
+ nested: {
64
+ listitem: "WebinyLexical__nestedListItem"
65
+ },
66
+ olDepth: ["WebinyLexical__ol1", "WebinyLexical__ol2", "WebinyLexical__ol3", "WebinyLexical__ol4", "WebinyLexical__ol5"],
67
+ ul: "WebinyLexical__ul"
68
+ },
69
+ ltr: "WebinyLexical__ltr",
70
+ mark: "WebinyLexical__mark",
71
+ markOverlap: "WebinyLexical__markOverlap",
72
+ paragraph: "WebinyLexical__paragraph",
73
+ quote: "WebinyLexical__quote",
74
+ rtl: "WebinyLexical__rtl",
75
+ text: {
76
+ bold: "WebinyLexical__textBold",
77
+ code: "WebinyLexical__textCode",
78
+ italic: "WebinyLexical__textItalic",
79
+ strikethrough: "WebinyLexical__textStrikethrough",
80
+ subscript: "WebinyLexical__textSubscript",
81
+ superscript: "WebinyLexical__textSuperscript",
82
+ underline: "WebinyLexical__textUnderline",
83
+ underlineStrikethrough: "WebinyLexical__textUnderlineStrikethrough"
84
+ },
85
+ fontColorText: "WebinyLexical__fontColorText"
86
+ };
87
+ exports.webinyEditorTheme = webinyEditorTheme;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["webinyEditorTheme","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"],"sources":["webinyLexicalTheme.ts"],"sourcesContent":["import type { EditorThemeClasses } from \"lexical\";\n\nimport \"./webinyLexicalTheme.css\";\nimport { ThemeEmotionMap } from \"~/types\";\n\nexport type WebinyTheme = {\n styles?: Record<string, any>;\n emotionMap?: ThemeEmotionMap;\n};\n\nexport type WebinyEditorTheme = WebinyTheme & EditorThemeClasses;\n\nexport const webinyEditorTheme: WebinyEditorTheme = {\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};\n"],"mappings":";;;;;;AAEA;AAUO,IAAMA,iBAAoC,GAAG;EAChDC,MAAM,EAAEC,SAAS;EACjBC,UAAU,EAAED,SAAS;EACrB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BC,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;AACnB,CAAC;AAAC"}
package/types.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import { ElementNode, LexicalNode, NodeSelection, RangeSelection, TextNode } from "lexical";
2
+ import { ListType } from "@lexical/list";
3
+ import { CSSObject } from "@emotion/react";
4
+ export declare type ToolbarType = "heading" | "paragraph" | string;
5
+ export declare type LexicalValue = string;
6
+ export { FontColorPicker } from "./components/ToolbarActions/FontColorAction";
7
+ export declare type LexicalTextType = ListType | "paragraph" | "heading" | "quoteblock" | "bullet" | "number" | "link" | undefined;
8
+ export declare type TextFormatting = {
9
+ bold: boolean;
10
+ underline: boolean;
11
+ italic: boolean;
12
+ code: boolean;
13
+ };
14
+ export declare type NodeState = {
15
+ isSelected: boolean;
16
+ };
17
+ export declare type ToolbarState = {
18
+ bold: boolean;
19
+ underline: boolean;
20
+ italic: boolean;
21
+ code: boolean;
22
+ link: NodeState;
23
+ typography: NodeState;
24
+ fontColor: NodeState;
25
+ list: NodeState;
26
+ quote: NodeState;
27
+ textType: LexicalTextType;
28
+ };
29
+ export declare type TextBlockSelection = {
30
+ elementKey?: string;
31
+ selection: RangeSelection | NodeSelection | null;
32
+ element: LexicalNode;
33
+ parent: ElementNode | null;
34
+ node: ElementNode | TextNode;
35
+ anchorNode: ElementNode | TextNode;
36
+ isElementDom: boolean;
37
+ state: ToolbarState | undefined;
38
+ };
39
+ export declare type ListHtmlTag = "ol" | "ul";
40
+ export declare type HeadingHtmlTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
41
+ export declare type ParagraphHtmlTag = "p";
42
+ export declare type QuoteBlockHtmlTag = "quoteblock";
43
+ export declare type TypographyHTMLTag = HeadingHtmlTag | ParagraphHtmlTag | ListHtmlTag | QuoteBlockHtmlTag;
44
+ export declare type TypographyValue = {
45
+ css: CSSObject;
46
+ id: string;
47
+ tag: TypographyHTMLTag;
48
+ name: string;
49
+ };
50
+ export interface WebinyThemeNode {
51
+ getStyleId: () => string;
52
+ }
53
+ export declare type ThemeEmotionMap = {
54
+ [styleId: string]: {
55
+ id: string;
56
+ tag: TypographyHTMLTag;
57
+ name: string;
58
+ styles: Record<string, any>;
59
+ className: string;
60
+ };
61
+ };
package/types.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "FontColorPicker", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _FontColorAction.FontColorPicker;
10
+ }
11
+ });
12
+ var _FontColorAction = require("./components/ToolbarActions/FontColorAction");
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import { ElementNode, LexicalNode, NodeSelection, RangeSelection, TextNode } from \"lexical\";\nimport { ListType } from \"@lexical/list\";\nimport { CSSObject } from \"@emotion/react\";\nexport type ToolbarType = \"heading\" | \"paragraph\" | string;\nexport type LexicalValue = string;\nexport { FontColorPicker } from \"~/components/ToolbarActions/FontColorAction\";\n\nexport type LexicalTextType =\n | ListType\n | \"paragraph\"\n | \"heading\"\n | \"quoteblock\"\n | \"bullet\"\n | \"number\"\n | \"link\"\n | undefined;\n\nexport type TextFormatting = {\n bold: boolean;\n underline: boolean;\n italic: boolean;\n // highlight: boolean #TODO implement with highlight action\n code: boolean;\n};\n\nexport type NodeState = {\n isSelected: boolean;\n};\n\nexport type ToolbarState = {\n // text format\n bold: boolean;\n underline: boolean;\n italic: boolean;\n code: boolean;\n // nodes selection state\n link: NodeState;\n typography: NodeState;\n fontColor: NodeState;\n list: NodeState;\n quote: NodeState;\n textType: LexicalTextType;\n};\n\n/*\n * Represent set of data from the current selection of the text and nodes selected by the user.\n * You can access this object through the @see useRichTextEditor context.\n */\nexport type TextBlockSelection = {\n elementKey?: string;\n selection: RangeSelection | NodeSelection | null;\n element: LexicalNode;\n parent: ElementNode | null;\n node: ElementNode | TextNode;\n anchorNode: ElementNode | TextNode;\n isElementDom: boolean;\n state: ToolbarState | undefined;\n};\n\n// Supported HTML tags by webiny lexical implementation\nexport type ListHtmlTag = \"ol\" | \"ul\";\nexport type HeadingHtmlTag = \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\";\nexport type ParagraphHtmlTag = \"p\";\nexport type QuoteBlockHtmlTag = \"quoteblock\";\n\n// Typography\nexport type TypographyHTMLTag = HeadingHtmlTag | ParagraphHtmlTag | ListHtmlTag | QuoteBlockHtmlTag;\n\nexport type TypographyValue = {\n // CSSObject type\n css: CSSObject;\n id: string;\n tag: TypographyHTMLTag;\n // Display name\n name: string;\n};\n\n/* Nodes */\nexport interface WebinyThemeNode {\n /*\n * Get theme style id\n */\n getStyleId: () => string;\n}\n\n/*\n * Contains IDs of the styles and Emotion generated classes.\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":";;;;;;;;;;;AAKA"}
@@ -0,0 +1,2 @@
1
+ /// <reference types="react" />
2
+ export declare function Divider(): JSX.Element;
package/ui/Divider.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Divider = Divider;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ function Divider() {
10
+ return /*#__PURE__*/_react.default.createElement("div", {
11
+ className: "divider"
12
+ });
13
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Divider"],"sources":["Divider.tsx"],"sourcesContent":["import React from \"react\";\n\nexport function Divider(): JSX.Element {\n return <div className=\"divider\"></div>;\n}\n"],"mappings":";;;;;;;AAAA;AAEO,SAASA,OAAO,GAAgB;EACnC,oBAAO;IAAK,SAAS,EAAC;EAAS,EAAO;AAC1C"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="web" />
9
+ import { ReactNode } from "react";
10
+ import * as React from "react";
11
+ export declare function DropDownItem({ children, className, onClick, title }: {
12
+ children: React.ReactNode;
13
+ className: string;
14
+ onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
15
+ title?: string;
16
+ }): JSX.Element;
17
+ export declare function DropDown({ disabled, buttonLabel, buttonAriaLabel, buttonClassName, buttonIconClassName, children, stopCloseOnClickSelf, showScroll }: {
18
+ disabled?: boolean;
19
+ buttonAriaLabel?: string;
20
+ buttonClassName: string;
21
+ buttonIconClassName?: string;
22
+ buttonLabel?: string;
23
+ children: ReactNode;
24
+ stopCloseOnClickSelf?: boolean;
25
+ showScroll?: boolean;
26
+ }): JSX.Element;
package/ui/DropDown.js ADDED
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.DropDown = DropDown;
9
+ exports.DropDownItem = DropDownItem;
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var React = _interopRequireWildcard(require("react"));
13
+ /**
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ *
19
+ */
20
+
21
+ var DropDownContext = /*#__PURE__*/React.createContext(null);
22
+ function DropDownItem(_ref) {
23
+ var children = _ref.children,
24
+ className = _ref.className,
25
+ onClick = _ref.onClick,
26
+ title = _ref.title;
27
+ var ref = (0, React.useRef)(null);
28
+ var dropDownContext = React.useContext(DropDownContext);
29
+ if (dropDownContext === null) {
30
+ throw new Error("DropDownItem must be used within a DropDown");
31
+ }
32
+ var registerItem = dropDownContext.registerItem;
33
+ (0, React.useEffect)(function () {
34
+ if (ref && ref.current) {
35
+ registerItem(ref);
36
+ }
37
+ }, [ref, registerItem]);
38
+ return /*#__PURE__*/React.createElement("button", {
39
+ className: className,
40
+ onClick: onClick,
41
+ ref: ref,
42
+ title: title
43
+ }, children);
44
+ }
45
+ function DropDownItems(_ref2) {
46
+ var children = _ref2.children,
47
+ dropDownRef = _ref2.dropDownRef,
48
+ _ref2$showScroll = _ref2.showScroll,
49
+ showScroll = _ref2$showScroll === void 0 ? true : _ref2$showScroll,
50
+ onClose = _ref2.onClose;
51
+ var _useState = (0, React.useState)(),
52
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
53
+ items = _useState2[0],
54
+ setItems = _useState2[1];
55
+ var _useState3 = (0, React.useState)(),
56
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
57
+ highlightedItem = _useState4[0],
58
+ setHighlightedItem = _useState4[1];
59
+ var registerItem = (0, React.useCallback)(function (itemRef) {
60
+ setItems(function (prev) {
61
+ return prev ? [].concat((0, _toConsumableArray2.default)(prev), [itemRef]) : [itemRef];
62
+ });
63
+ }, [setItems]);
64
+ var handleKeyDown = function handleKeyDown(event) {
65
+ if (!items) {
66
+ return;
67
+ }
68
+ var key = event.key;
69
+ if (["Escape", "ArrowUp", "ArrowDown", "Tab"].includes(key)) {
70
+ event.preventDefault();
71
+ }
72
+ if (key === "Escape" || key === "Tab") {
73
+ onClose();
74
+ } else if (key === "ArrowUp") {
75
+ setHighlightedItem(function (prev) {
76
+ if (!prev) {
77
+ return items[0];
78
+ }
79
+ var index = items.indexOf(prev) - 1;
80
+ return items[index === -1 ? items.length - 1 : index];
81
+ });
82
+ } else if (key === "ArrowDown") {
83
+ setHighlightedItem(function (prev) {
84
+ if (!prev) {
85
+ return items[0];
86
+ }
87
+ return items[items.indexOf(prev) + 1];
88
+ });
89
+ }
90
+ };
91
+ var contextValue = (0, React.useMemo)(function () {
92
+ return {
93
+ registerItem: registerItem
94
+ };
95
+ }, [registerItem]);
96
+ (0, React.useEffect)(function () {
97
+ if (items && !highlightedItem) {
98
+ setHighlightedItem(items[0]);
99
+ }
100
+ if (highlightedItem && highlightedItem.current) {
101
+ highlightedItem.current.focus();
102
+ }
103
+ }, [items, highlightedItem]);
104
+ return /*#__PURE__*/React.createElement(DropDownContext.Provider, {
105
+ value: contextValue
106
+ }, /*#__PURE__*/React.createElement("div", {
107
+ className: "lexical-dropdown ".concat(showScroll ? "" : "no-scroll"),
108
+ ref: dropDownRef !== null && dropDownRef !== void 0 ? dropDownRef : null,
109
+ onKeyDown: handleKeyDown
110
+ }, children));
111
+ }
112
+ function DropDown(_ref3) {
113
+ var _ref3$disabled = _ref3.disabled,
114
+ disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
115
+ buttonLabel = _ref3.buttonLabel,
116
+ buttonAriaLabel = _ref3.buttonAriaLabel,
117
+ buttonClassName = _ref3.buttonClassName,
118
+ buttonIconClassName = _ref3.buttonIconClassName,
119
+ children = _ref3.children,
120
+ stopCloseOnClickSelf = _ref3.stopCloseOnClickSelf,
121
+ _ref3$showScroll = _ref3.showScroll,
122
+ showScroll = _ref3$showScroll === void 0 ? true : _ref3$showScroll;
123
+ var buttonRef = (0, React.useRef)(null);
124
+ var _useState5 = (0, React.useState)(false),
125
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
126
+ showDropDown = _useState6[0],
127
+ setShowDropDown = _useState6[1];
128
+ var handleClose = function handleClose() {
129
+ setShowDropDown(false);
130
+ if (buttonRef && buttonRef.current) {
131
+ buttonRef.current.focus();
132
+ }
133
+ };
134
+ (0, React.useEffect)(function () {
135
+ var button = buttonRef.current;
136
+ if (button === null || !showDropDown) {
137
+ return;
138
+ }
139
+ var handle = function handle(event) {
140
+ var target = event.target;
141
+ if (!button.contains(target)) {
142
+ setShowDropDown(false);
143
+ }
144
+ };
145
+ document.addEventListener("click", handle);
146
+ return function () {
147
+ document.removeEventListener("click", handle);
148
+ };
149
+ }, [buttonRef, showDropDown, stopCloseOnClickSelf]);
150
+ return /*#__PURE__*/React.createElement("button", {
151
+ style: {
152
+ position: "relative"
153
+ },
154
+ disabled: disabled,
155
+ "aria-label": buttonAriaLabel || buttonLabel,
156
+ className: buttonClassName,
157
+ onClick: function onClick() {
158
+ return setShowDropDown(!showDropDown);
159
+ },
160
+ ref: buttonRef
161
+ }, buttonIconClassName && /*#__PURE__*/React.createElement("span", {
162
+ className: buttonIconClassName
163
+ }), buttonLabel && /*#__PURE__*/React.createElement("span", {
164
+ className: "text dropdown-button-text"
165
+ }, buttonLabel), /*#__PURE__*/React.createElement("i", {
166
+ className: "chevron-down"
167
+ }), showDropDown && /*#__PURE__*/React.createElement("div", {
168
+ className: "lexical-dropdown-container"
169
+ }, /*#__PURE__*/React.createElement(DropDownItems, {
170
+ showScroll: showScroll,
171
+ onClose: handleClose
172
+ }, children)));
173
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DropDownContext","React","createContext","DropDownItem","children","className","onClick","title","ref","useRef","dropDownContext","useContext","Error","registerItem","useEffect","current","DropDownItems","dropDownRef","showScroll","onClose","useState","items","setItems","highlightedItem","setHighlightedItem","useCallback","itemRef","prev","handleKeyDown","event","key","includes","preventDefault","index","indexOf","length","contextValue","useMemo","focus","DropDown","disabled","buttonLabel","buttonAriaLabel","buttonClassName","buttonIconClassName","stopCloseOnClickSelf","buttonRef","showDropDown","setShowDropDown","handleClose","button","handle","target","contains","document","addEventListener","removeEventListener","position"],"sources":["DropDown.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport * as React from \"react\";\n\ntype DropDownContextType = {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void;\n};\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null);\n\nexport function DropDownItem({\n children,\n className,\n onClick,\n title\n}: {\n children: React.ReactNode;\n className: string;\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;\n title?: string;\n}) {\n const ref = useRef<HTMLButtonElement>(null);\n\n const dropDownContext = React.useContext(DropDownContext);\n\n if (dropDownContext === null) {\n throw new Error(\"DropDownItem must be used within a DropDown\");\n }\n\n const { registerItem } = dropDownContext;\n\n useEffect(() => {\n if (ref && ref.current) {\n registerItem(ref);\n }\n }, [ref, registerItem]);\n\n return (\n <button className={className} onClick={onClick} ref={ref} title={title}>\n {children}\n </button>\n );\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n showScroll = true,\n onClose\n}: {\n children: React.ReactNode;\n dropDownRef?: React.Ref<HTMLDivElement>;\n showScroll?: boolean;\n onClose: () => void;\n}) {\n const [items, setItems] = useState<React.RefObject<HTMLButtonElement>[]>();\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>();\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems(prev => (prev ? [...prev, itemRef] : [itemRef]));\n },\n [setItems]\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!items) {\n return;\n }\n\n const key = event.key;\n\n if ([\"Escape\", \"ArrowUp\", \"ArrowDown\", \"Tab\"].includes(key)) {\n event.preventDefault();\n }\n\n if (key === \"Escape\" || key === \"Tab\") {\n onClose();\n } else if (key === \"ArrowUp\") {\n setHighlightedItem(prev => {\n if (!prev) {\n return items[0];\n }\n const index = items.indexOf(prev) - 1;\n return items[index === -1 ? items.length - 1 : index];\n });\n } else if (key === \"ArrowDown\") {\n setHighlightedItem(prev => {\n if (!prev) {\n return items[0];\n }\n return items[items.indexOf(prev) + 1];\n });\n }\n };\n\n const contextValue = useMemo(\n () => ({\n registerItem\n }),\n [registerItem]\n );\n\n useEffect(() => {\n if (items && !highlightedItem) {\n setHighlightedItem(items[0]);\n }\n\n if (highlightedItem && highlightedItem.current) {\n highlightedItem.current.focus();\n }\n }, [items, highlightedItem]);\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div\n className={`lexical-dropdown ${showScroll ? \"\" : \"no-scroll\"}`}\n ref={dropDownRef ?? null}\n onKeyDown={handleKeyDown}\n >\n {children}\n </div>\n </DropDownContext.Provider>\n );\n}\n\nexport function DropDown({\n disabled = false,\n buttonLabel,\n buttonAriaLabel,\n buttonClassName,\n buttonIconClassName,\n children,\n stopCloseOnClickSelf,\n showScroll = true\n}: {\n disabled?: boolean;\n buttonAriaLabel?: string;\n buttonClassName: string;\n buttonIconClassName?: string;\n buttonLabel?: string;\n children: ReactNode;\n stopCloseOnClickSelf?: boolean;\n showScroll?: boolean;\n}): JSX.Element {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [showDropDown, setShowDropDown] = useState(false);\n\n const handleClose = () => {\n setShowDropDown(false);\n if (buttonRef && buttonRef.current) {\n buttonRef.current.focus();\n }\n };\n\n useEffect(() => {\n const button = buttonRef.current;\n if (button === null || !showDropDown) {\n return;\n }\n\n const handle = (event: MouseEvent) => {\n const target = event.target;\n if (!button.contains(target as Node)) {\n setShowDropDown(false);\n }\n };\n document.addEventListener(\"click\", handle);\n\n return () => {\n document.removeEventListener(\"click\", handle);\n };\n }, [buttonRef, showDropDown, stopCloseOnClickSelf]);\n\n return (\n <button\n style={{ position: \"relative\" }}\n disabled={disabled}\n aria-label={buttonAriaLabel || buttonLabel}\n className={buttonClassName}\n onClick={() => setShowDropDown(!showDropDown)}\n ref={buttonRef}\n >\n {buttonIconClassName && <span className={buttonIconClassName} />}\n {buttonLabel && <span className=\"text dropdown-button-text\">{buttonLabel}</span>}\n <i className=\"chevron-down\" />\n {showDropDown && (\n <div className={\"lexical-dropdown-container\"}>\n <DropDownItems showScroll={showScroll} onClose={handleClose}>\n {children}\n </DropDownItems>\n </div>\n )}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;;;AAQA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,IAAMA,eAAe,gBAAGC,KAAK,CAACC,aAAa,CAA6B,IAAI,CAAC;AAEtE,SAASC,YAAY,OAUzB;EAAA,IATCC,QAAQ,QAARA,QAAQ;IACRC,SAAS,QAATA,SAAS;IACTC,OAAO,QAAPA,OAAO;IACPC,KAAK,QAALA,KAAK;EAOL,IAAMC,GAAG,GAAG,IAAAC,YAAM,EAAoB,IAAI,CAAC;EAE3C,IAAMC,eAAe,GAAGT,KAAK,CAACU,UAAU,CAACX,eAAe,CAAC;EAEzD,IAAIU,eAAe,KAAK,IAAI,EAAE;IAC1B,MAAM,IAAIE,KAAK,CAAC,6CAA6C,CAAC;EAClE;EAEA,IAAQC,YAAY,GAAKH,eAAe,CAAhCG,YAAY;EAEpB,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,SAAS,EAAEC,YAAY,EAAEF,oBAAoB,CAAC,CAAC;EAEnD,oBACI;IACI,KAAK,EAAE;MAAEY,QAAQ,EAAE;IAAW,CAAE;IAChC,QAAQ,EAAEjB,QAAS;IACnB,cAAYE,eAAe,IAAID,WAAY;IAC3C,SAAS,EAAEE,eAAgB;IAC3B,OAAO,EAAE;MAAA,OAAMK,eAAe,CAAC,CAACD,YAAY,CAAC;IAAA,CAAC;IAC9C,GAAG,EAAED;EAAU,GAEdF,mBAAmB,iBAAI;IAAM,SAAS,EAAEA;EAAoB,EAAG,EAC/DH,WAAW,iBAAI;IAAM,SAAS,EAAC;EAA2B,GAAEA,WAAW,CAAQ,eAChF;IAAG,SAAS,EAAC;EAAc,EAAG,EAC7BM,YAAY,iBACT;IAAK,SAAS,EAAE;EAA6B,gBACzC,oBAAC,aAAa;IAAC,UAAU,EAAE7B,UAAW;IAAC,OAAO,EAAE+B;EAAY,GACvD7C,QAAQ,CACG,CAEvB,CACI;AAEjB"}
package/ui/Input.css ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ .Input__wrapper {
11
+ display: flex;
12
+ flex-direction: row;
13
+ align-items: center;
14
+ margin-bottom: 10px;
15
+ }
16
+ .Input__label {
17
+ display: flex;
18
+ flex: 1;
19
+ color: #666;
20
+ }
21
+ .Input__input {
22
+ display: flex;
23
+ flex: 2;
24
+ border: 1px solid #999;
25
+ padding-top: 7px;
26
+ padding-bottom: 7px;
27
+ padding-left: 10px;
28
+ padding-right: 10px;
29
+ font-size: 16px;
30
+ border-radius: 5px;
31
+ min-width: 0;
32
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ @keyframes glimmer-animation {
11
+ 0% {
12
+ background: #f9f9f9;
13
+ }
14
+ .50% {
15
+ background: #eeeeee;
16
+ }
17
+ .100% {
18
+ background: #f9f9f9;
19
+ }
20
+ }
21
+
22
+ .LinkPreview__container {
23
+ padding-bottom: 12px;
24
+ }
25
+
26
+ .LinkPreview__imageWrapper {
27
+ text-align: center;
28
+ }
29
+
30
+ .LinkPreview__image {
31
+ max-width: 100%;
32
+ max-height: 250px;
33
+ margin: auto;
34
+ }
35
+
36
+ .LinkPreview__title {
37
+ margin-left: 12px;
38
+ margin-right: 12px;
39
+ margin-top: 4px;
40
+ }
41
+
42
+ .LinkPreview__description {
43
+ color: #999;
44
+ font-size: 90%;
45
+ margin-left: 12px;
46
+ margin-right: 12px;
47
+ margin-top: 4px;
48
+ }
49
+
50
+ .LinkPreview__domain {
51
+ color: #999;
52
+ font-size: 90%;
53
+ margin-left: 12px;
54
+ margin-right: 12px;
55
+ margin-top: 4px;
56
+ }
57
+
58
+ .LinkPreview__glimmer {
59
+ background: #f9f9f9;
60
+ border-radius: 8px;
61
+ height: 18px;
62
+ margin-bottom: 8px;
63
+ margin-left: 12px;
64
+ margin-right: 12px;
65
+ animation-duration: 3s;
66
+ animation-iteration-count: infinite;
67
+ animation-timing-function: linear;
68
+ animation-name: glimmer-animation;
69
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ import "./LinkPreview.css";
10
+ export declare function LinkPreview({ url }: Readonly<{
11
+ url: string;
12
+ }>): JSX.Element;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.LinkPreview = LinkPreview;
9
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ require("./LinkPreview.css");
11
+ var React = _interopRequireWildcard(require("react"));
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ */
19
+
20
+ // Cached responses or running request promises
21
+ var PREVIEW_CACHE = {};
22
+ var URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
23
+ function useSuspenseRequest(url) {
24
+ var cached = PREVIEW_CACHE[url];
25
+ if (!url.match(URL_MATCHER)) {
26
+ return {
27
+ preview: null
28
+ };
29
+ }
30
+ if (!cached) {
31
+ cached = PREVIEW_CACHE[url] = fetch("/api/link-preview?url=".concat(encodeURI(url))).then(function (response) {
32
+ return response.json();
33
+ }).then(function (preview) {
34
+ PREVIEW_CACHE[url] = preview;
35
+ return preview;
36
+ }).catch(function () {
37
+ PREVIEW_CACHE[url] = {
38
+ preview: null
39
+ };
40
+ });
41
+ }
42
+ if (cached instanceof Promise) {
43
+ throw cached;
44
+ }
45
+ return cached;
46
+ }
47
+ function LinkPreviewContent(_ref) {
48
+ var url = _ref.url;
49
+ var _useSuspenseRequest = useSuspenseRequest(url),
50
+ preview = _useSuspenseRequest.preview;
51
+ if (preview === null) {
52
+ return null;
53
+ }
54
+ return /*#__PURE__*/React.createElement("div", {
55
+ className: "LinkPreview__container"
56
+ }, preview.img && /*#__PURE__*/React.createElement("div", {
57
+ className: "LinkPreview__imageWrapper"
58
+ }, /*#__PURE__*/React.createElement("img", {
59
+ src: preview.img,
60
+ alt: preview.title,
61
+ className: "LinkPreview__image"
62
+ })), preview.domain && /*#__PURE__*/React.createElement("div", {
63
+ className: "LinkPreview__domain"
64
+ }, preview.domain), preview.title && /*#__PURE__*/React.createElement("div", {
65
+ className: "LinkPreview__title"
66
+ }, preview.title), preview.description && /*#__PURE__*/React.createElement("div", {
67
+ className: "LinkPreview__description"
68
+ }, preview.description));
69
+ }
70
+ function Glimmer(props) {
71
+ return /*#__PURE__*/React.createElement("div", Object.assign({
72
+ className: "LinkPreview__glimmer"
73
+ }, props, {
74
+ style: (0, _objectSpread2.default)({
75
+ animationDelay: String((props.index || 0) * 300)
76
+ }, props.style || {})
77
+ }));
78
+ }
79
+ function LinkPreview(_ref2) {
80
+ var url = _ref2.url;
81
+ return /*#__PURE__*/React.createElement(React.Suspense, {
82
+ fallback: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Glimmer, {
83
+ style: {
84
+ height: "80px"
85
+ },
86
+ index: 0
87
+ }), /*#__PURE__*/React.createElement(Glimmer, {
88
+ style: {
89
+ width: "60%"
90
+ },
91
+ index: 1
92
+ }), /*#__PURE__*/React.createElement(Glimmer, {
93
+ style: {
94
+ width: "80%"
95
+ },
96
+ index: 2
97
+ }))
98
+ }, /*#__PURE__*/React.createElement(LinkPreviewContent, {
99
+ url: url
100
+ }));
101
+ }