@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,67 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.LexicalHtmlRenderer = exports.BaseLexicalHtmlRenderer = void 0;
8
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
+ var _react = _interopRequireDefault(require("react"));
11
+ var _isValidLexicalData = require("../utils/isValidLexicalData");
12
+ var _generateInitialLexicalValue = require("../utils/generateInitialLexicalValue");
13
+ var _LexicalComposer = require("@lexical/react/LexicalComposer");
14
+ var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
15
+ var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
16
+ var _LexicalErrorBoundary = _interopRequireDefault(require("@lexical/react/LexicalErrorBoundary"));
17
+ var _LexicalUpdateStatePlugin = require("../plugins/LexicalUpdateStatePlugin");
18
+ var _webinyNodes = require("../nodes/webinyNodes");
19
+ var _webinyLexicalTheme = require("../themes/webinyLexicalTheme");
20
+ var _react2 = require("@emotion/react");
21
+ var _toTypographyEmotionMap = require("../utils/toTypographyEmotionMap");
22
+ var BaseLexicalHtmlRenderer = function BaseLexicalHtmlRenderer(_ref) {
23
+ var nodes = _ref.nodes,
24
+ value = _ref.value,
25
+ theme = _ref.theme,
26
+ themeEmotionMap = _ref.themeEmotionMap;
27
+ var initialConfig = {
28
+ editorState: (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)(),
29
+ namespace: "webiny",
30
+ onError: function onError(error) {
31
+ throw error;
32
+ },
33
+ editable: false,
34
+ nodes: [].concat((0, _toConsumableArray2.default)(_webinyNodes.WebinyNodes), (0, _toConsumableArray2.default)(nodes || [])),
35
+ theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _webinyLexicalTheme.webinyEditorTheme), {}, {
36
+ emotionMap: themeEmotionMap,
37
+ styles: theme.styles
38
+ })
39
+ };
40
+ return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
41
+ initialConfig: initialConfig
42
+ }, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
43
+ contentEditable: /*#__PURE__*/_react.default.createElement("div", {
44
+ className: "editor"
45
+ }, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, null)),
46
+ ErrorBoundary: _LexicalErrorBoundary.default,
47
+ placeholder: null
48
+ }), /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.LexicalUpdateStatePlugin, {
49
+ value: value
50
+ }));
51
+ };
52
+
53
+ /**
54
+ * @description Main editor container
55
+ */
56
+ exports.BaseLexicalHtmlRenderer = BaseLexicalHtmlRenderer;
57
+ var LexicalHtmlRenderer = function LexicalHtmlRenderer(props) {
58
+ return /*#__PURE__*/_react.default.createElement(_react2.ClassNames, null, function (_ref2) {
59
+ var _props$themeEmotionMa;
60
+ var css = _ref2.css;
61
+ var themeEmotionMap = (_props$themeEmotionMa = props === null || props === void 0 ? void 0 : props.themeEmotionMap) !== null && _props$themeEmotionMa !== void 0 ? _props$themeEmotionMa : (0, _toTypographyEmotionMap.toTypographyEmotionMap)(css, props.theme);
62
+ return /*#__PURE__*/_react.default.createElement(BaseLexicalHtmlRenderer, Object.assign({}, props, {
63
+ themeEmotionMap: themeEmotionMap
64
+ }));
65
+ });
66
+ };
67
+ exports.LexicalHtmlRenderer = LexicalHtmlRenderer;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["BaseLexicalHtmlRenderer","nodes","value","theme","themeEmotionMap","initialConfig","editorState","isValidLexicalData","generateInitialLexicalValue","namespace","onError","error","editable","WebinyNodes","webinyEditorTheme","emotionMap","styles","LexicalErrorBoundary","LexicalHtmlRenderer","props","css","toTypographyEmotionMap"],"sources":["LexicalHtmlRenderer.tsx"],"sourcesContent":["import React from \"react\";\nimport { LexicalValue, ThemeEmotionMap } from \"~/types\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport LexicalErrorBoundary from \"@lexical/react/LexicalErrorBoundary\";\nimport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { Klass, LexicalNode } from \"lexical\";\nimport { WebinyNodes } from \"~/nodes/webinyNodes\";\nimport { webinyEditorTheme, WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { ClassNames } from \"@emotion/react\";\nimport { toTypographyEmotionMap } from \"~/utils/toTypographyEmotionMap\";\n\ninterface LexicalHtmlRendererProps {\n nodes?: Klass<LexicalNode>[];\n value: LexicalValue | null;\n /*\n * @description Theme to be injected into lexical editor\n */\n theme: WebinyTheme;\n themeEmotionMap?: ThemeEmotionMap;\n}\n\nexport const BaseLexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = ({\n nodes,\n value,\n theme,\n themeEmotionMap\n}) => {\n const initialConfig = {\n editorState: isValidLexicalData(value) ? value : generateInitialLexicalValue(),\n namespace: \"webiny\",\n onError: (error: Error) => {\n throw error;\n },\n editable: false,\n nodes: [...WebinyNodes, ...(nodes || [])],\n theme: { ...webinyEditorTheme, emotionMap: themeEmotionMap, styles: theme.styles }\n };\n\n return (\n <LexicalComposer initialConfig={initialConfig}>\n <RichTextPlugin\n contentEditable={\n <div className=\"editor\">\n <ContentEditable />\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <LexicalUpdateStatePlugin value={value} />\n </LexicalComposer>\n );\n};\n\n/**\n * @description Main editor container\n */\nexport const LexicalHtmlRenderer: React.FC<LexicalHtmlRendererProps> = props => {\n return (\n <ClassNames>\n {({ css }) => {\n const themeEmotionMap =\n props?.themeEmotionMap ?? toTypographyEmotionMap(css, props.theme);\n return <BaseLexicalHtmlRenderer {...props} themeEmotionMap={themeEmotionMap} />;\n }}\n </ClassNames>\n );\n};\n"],"mappings":";;;;;;;;;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAYO,IAAMA,uBAA2D,GAAG,SAA9DA,uBAA2D,OAKlE;EAAA,IAJFC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,eAAe,QAAfA,eAAe;EAEf,IAAMC,aAAa,GAAG;IAClBC,WAAW,EAAE,IAAAC,sCAAkB,EAACL,KAAK,CAAC,GAAGA,KAAK,GAAG,IAAAM,wDAA2B,GAAE;IAC9EC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,iBAACC,KAAY,EAAK;MACvB,MAAMA,KAAK;IACf,CAAC;IACDC,QAAQ,EAAE,KAAK;IACfX,KAAK,6CAAMY,wBAAW,oCAAMZ,KAAK,IAAI,EAAE,EAAE;IACzCE,KAAK,8DAAOW,qCAAiB;MAAEC,UAAU,EAAEX,eAAe;MAAEY,MAAM,EAAEb,KAAK,CAACa;IAAM;EACpF,CAAC;EAED,oBACI,6BAAC,gCAAe;IAAC,aAAa,EAAEX;EAAc,gBAC1C,6BAAC,qCAAc;IACX,eAAe,eACX;MAAK,SAAS,EAAC;IAAQ,gBACnB,6BAAC,uCAAe,OAAG,CAE1B;IACD,aAAa,EAAEY,6BAAqB;IACpC,WAAW,EAAE;EAAK,EACpB,eACF,6BAAC,kDAAwB;IAAC,KAAK,EAAEf;EAAM,EAAG,CAC5B;AAE1B,CAAC;;AAED;AACA;AACA;AAFA;AAGO,IAAMgB,mBAAuD,GAAG,SAA1DA,mBAAuD,CAAGC,KAAK,EAAI;EAC5E,oBACI,6BAAC,kBAAU,QACN,iBAAa;IAAA;IAAA,IAAVC,GAAG,SAAHA,GAAG;IACH,IAAMhB,eAAe,4BACjBe,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEf,eAAe,yEAAI,IAAAiB,8CAAsB,EAACD,GAAG,EAAED,KAAK,CAAChB,KAAK,CAAC;IACtE,oBAAO,6BAAC,uBAAuB,oBAAKgB,KAAK;MAAE,eAAe,EAAEf;IAAgB,GAAG;EACnF,CAAC,CACQ;AAErB,CAAC;AAAC"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="web" />
2
+ import { FC } from "react";
3
+ interface HeadingToolbarProps {
4
+ anchorElem?: HTMLElement;
5
+ }
6
+ /**
7
+ * Toolbar with actions specific for the heading elements from H1-H6.
8
+ * @param anchorElem
9
+ * @constructor
10
+ */
11
+ export declare const HeadingToolbar: FC<HeadingToolbarProps>;
12
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.HeadingToolbar = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _Toolbar = require("./Toolbar");
10
+ /**
11
+ * Toolbar with actions specific for the heading elements from H1-H6.
12
+ * @param anchorElem
13
+ * @constructor
14
+ */
15
+ var HeadingToolbar = function HeadingToolbar(_ref) {
16
+ var _ref$anchorElem = _ref.anchorElem,
17
+ anchorElem = _ref$anchorElem === void 0 ? document.body : _ref$anchorElem;
18
+ return /*#__PURE__*/_react.default.createElement(_Toolbar.Toolbar, {
19
+ type: "heading",
20
+ anchorElem: anchorElem
21
+ });
22
+ };
23
+ exports.HeadingToolbar = HeadingToolbar;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HeadingToolbar","anchorElem","document","body"],"sources":["HeadingToolbar.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface HeadingToolbarProps {\n anchorElem?: HTMLElement;\n}\n\n/**\n * Toolbar with actions specific for the heading elements from H1-H6.\n * @param anchorElem\n * @constructor\n */\nexport const HeadingToolbar: FC<HeadingToolbarProps> = ({ anchorElem = document.body }) => {\n return <Toolbar type={\"heading\"} anchorElem={anchorElem} />;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACO,IAAMA,cAAuC,GAAG,SAA1CA,cAAuC,OAAuC;EAAA,2BAAjCC,UAAU;IAAVA,UAAU,gCAAGC,QAAQ,CAACC,IAAI;EAChF,oBAAO,6BAAC,gBAAO;IAAC,IAAI,EAAE,SAAU;IAAC,UAAU,EAAEF;EAAW,EAAG;AAC/D,CAAC;AAAC"}
@@ -0,0 +1,12 @@
1
+ /// <reference types="web" />
2
+ import { FC } from "react";
3
+ interface ParagraphToolbarProps {
4
+ anchorElem?: HTMLElement;
5
+ }
6
+ /**
7
+ * Toolbar with actions for rich text editing specific for the paragraph element <p>.
8
+ * @param anchorElem
9
+ * @constructor
10
+ */
11
+ export declare const ParagraphToolbar: FC<ParagraphToolbarProps>;
12
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ParagraphToolbar = void 0;
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _Toolbar = require("./Toolbar");
10
+ /**
11
+ * Toolbar with actions for rich text editing specific for the paragraph element <p>.
12
+ * @param anchorElem
13
+ * @constructor
14
+ */
15
+ var ParagraphToolbar = function ParagraphToolbar(_ref) {
16
+ var _ref$anchorElem = _ref.anchorElem,
17
+ anchorElem = _ref$anchorElem === void 0 ? document.body : _ref$anchorElem;
18
+ return /*#__PURE__*/_react.default.createElement(_Toolbar.Toolbar, {
19
+ type: "paragraph",
20
+ anchorElem: anchorElem
21
+ });
22
+ };
23
+ exports.ParagraphToolbar = ParagraphToolbar;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ParagraphToolbar","anchorElem","document","body"],"sources":["ParagraphToolbar.tsx"],"sourcesContent":["import React, { FC } from \"react\";\nimport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n\ninterface ParagraphToolbarProps {\n anchorElem?: HTMLElement;\n}\n\n/**\n * Toolbar with actions for rich text editing specific for the paragraph element <p>.\n * @param anchorElem\n * @constructor\n */\nexport const ParagraphToolbar: FC<ParagraphToolbarProps> = ({ anchorElem = document.body }) => {\n return <Toolbar type={\"paragraph\"} anchorElem={anchorElem} />;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAMA;AACA;AACA;AACA;AACA;AACO,IAAMA,gBAA2C,GAAG,SAA9CA,gBAA2C,OAAuC;EAAA,2BAAjCC,UAAU;IAAVA,UAAU,gCAAGC,QAAQ,CAACC,IAAI;EACpF,oBAAO,6BAAC,gBAAO;IAAC,IAAI,EAAE,WAAY;IAAC,UAAU,EAAEF;EAAW,EAAG;AACjE,CAAC;AAAC"}
@@ -0,0 +1,423 @@
1
+ .floating-text-format-popup {
2
+ display: flex;
3
+ padding: 4px;
4
+ vertical-align: middle;
5
+ position: absolute;
6
+ top: 0;
7
+ left: 0;
8
+ z-index: 30;
9
+ opacity: 0;
10
+ background-color: #fff;
11
+ box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
12
+ border-radius: 8px;
13
+ transition: opacity 0.5s;
14
+ height: 35px;
15
+ will-change: transform;
16
+ }
17
+
18
+ .floating-text-format-popup button.popup-item {
19
+ border: 0;
20
+ display: flex;
21
+ background: none;
22
+ border-radius: 10px;
23
+ padding: 8px;
24
+ cursor: pointer;
25
+ vertical-align: middle;
26
+ }
27
+
28
+ .floating-text-format-popup button.popup-item:disabled {
29
+ cursor: not-allowed;
30
+ }
31
+
32
+ .floating-text-format-popup button.popup-item.spaced {
33
+ margin-right: 2px;
34
+ }
35
+
36
+ .floating-text-format-popup button.popup-item i.format {
37
+ background-size: contain;
38
+ display: inline-block;
39
+ height: 18px;
40
+ width: 18px;
41
+ margin-top: 2px;
42
+ vertical-align: -0.25em;
43
+ display: flex;
44
+ opacity: 0.6;
45
+ }
46
+
47
+ .floating-text-format-popup button.popup-item:disabled i.format {
48
+ opacity: 0.2;
49
+ }
50
+
51
+ .floating-text-format-popup button.popup-item.active {
52
+ background-color: rgba(223, 232, 250, 0.3);
53
+ }
54
+
55
+ .floating-text-format-popup button.popup-item.active i {
56
+ opacity: 1;
57
+ }
58
+
59
+ .floating-text-format-popup .popup-item:hover:not([disabled]) {
60
+ background-color: #eee;
61
+ }
62
+
63
+ .floating-text-format-popup select.popup-item {
64
+ border: 0;
65
+ display: flex;
66
+ background: none;
67
+ border-radius: 10px;
68
+ padding: 8px;
69
+ vertical-align: middle;
70
+ -webkit-appearance: none;
71
+ -moz-appearance: none;
72
+ width: 70px;
73
+ font-size: 14px;
74
+ color: #777;
75
+ text-overflow: ellipsis;
76
+ }
77
+
78
+ .floating-text-format-popup select.code-language {
79
+ text-transform: capitalize;
80
+ width: 130px;
81
+ }
82
+
83
+ .floating-text-format-popup .popup-item .text {
84
+ display: flex;
85
+ line-height: 20px;
86
+ width: 200px;
87
+ vertical-align: middle;
88
+ font-size: 14px;
89
+ color: #777;
90
+ text-overflow: ellipsis;
91
+ width: 70px;
92
+ overflow: hidden;
93
+ height: 20px;
94
+ text-align: left;
95
+ }
96
+
97
+ .floating-text-format-popup .popup-item .icon {
98
+ display: flex;
99
+ width: 20px;
100
+ height: 20px;
101
+ user-select: none;
102
+ margin-right: 8px;
103
+ line-height: 16px;
104
+ background-size: contain;
105
+ }
106
+
107
+ .floating-text-format-popup i.chevron-down {
108
+ margin-top: 3px;
109
+ width: 16px;
110
+ height: 16px;
111
+ display: flex;
112
+ user-select: none;
113
+ }
114
+
115
+ .floating-text-format-popup i.chevron-down.inside {
116
+ width: 16px;
117
+ height: 16px;
118
+ display: flex;
119
+ margin-left: -25px;
120
+ margin-top: 11px;
121
+ margin-right: 10px;
122
+ pointer-events: none;
123
+ }
124
+
125
+ .floating-text-format-popup .divider {
126
+ width: 1px;
127
+ background-color: #eee;
128
+ margin: 0 4px;
129
+ }
130
+
131
+ i.bold {
132
+ background-image: url("../../images/icons/type-bold.svg");
133
+ }
134
+
135
+ i.italic {
136
+ background-image: url("../../images/icons/type-italic.svg");
137
+ }
138
+
139
+ i.code {
140
+ background-image: url("../../images/icons/code.svg");
141
+ }
142
+
143
+ i.underline {
144
+ background-image: url("../../images/icons/type-underline.svg");
145
+ }
146
+
147
+ i.strikethrough {
148
+ background-image: url("../../images/icons/type-strikethrough.svg");
149
+ }
150
+
151
+ i.link {
152
+ background-image: url("../../images/icons/link.svg");
153
+ }
154
+
155
+ i.quote {
156
+ background-image: url("../../images/icons/chat-square-quote.svg");
157
+ }
158
+
159
+ .icon.left-align,
160
+ i.left-align {
161
+ background-image: url("../../images/icons/text-left.svg");
162
+ }
163
+
164
+ i.center-align {
165
+ background-image: url("../../images/icons/text-center.svg");
166
+ }
167
+
168
+ i.right-align {
169
+ background-image: url("../../images/icons/text-right.svg");
170
+ }
171
+
172
+ i.chevron-down {
173
+ background-color: transparent;
174
+ background-size: contain;
175
+ display: inline-block;
176
+ height: 8px;
177
+ width: 8px;
178
+ background-image: url("../../images/icons/chevron-down.svg");
179
+ }
180
+
181
+
182
+ .icon.bullet-list,
183
+ .icon.bullet {
184
+ background-image: url("../../images/icons/list-ul.svg");
185
+ }
186
+
187
+ .icon.numbered-list,
188
+ .icon.number {
189
+ background-image: url("../../images/icons/list-ol.svg");
190
+ }
191
+
192
+ .link-editor .button.active,
193
+ .toolbar .button.active {
194
+ background-color: rgb(223, 232, 250);
195
+ }
196
+
197
+ i.font-color, .icon.font-color {
198
+ background-image: url("../../images/icons/font-color.svg");
199
+ }
200
+
201
+ .floating-text-format-popup button.toolbar-item {
202
+ border: 0;
203
+ display: flex;
204
+ background: none;
205
+ border-radius: 10px;
206
+ padding: 8px;
207
+ cursor: pointer;
208
+ vertical-align: middle;
209
+ flex-shrink: 0;
210
+ align-items: center;
211
+ justify-content: space-between;
212
+ }
213
+
214
+ .floating-text-format-popup button.toolbar-item:disabled {
215
+ cursor: not-allowed;
216
+ }
217
+
218
+ .floating-text-format-popup button.toolbar-item.spaced {
219
+ margin-right: 2px;
220
+ }
221
+
222
+ .floating-text-format-popup button.toolbar-item i.format {
223
+ background-size: contain;
224
+ display: inline-block;
225
+ height: 18px;
226
+ width: 18px;
227
+ vertical-align: -0.25em;
228
+ display: flex;
229
+ opacity: 0.6;
230
+ }
231
+
232
+ .floating-text-format-popup button.toolbar-item:disabled .icon,
233
+ .floating-text-format-popup button.toolbar-item:disabled .text,
234
+ .floating-text-format-popup button.toolbar-item:disabled i.format,
235
+ .floating-text-format-popup button.toolbar-item:disabled .chevron-down {
236
+ opacity: 0.2;
237
+ }
238
+
239
+ .floating-text-format-popup button.toolbar-item.active {
240
+ background-color: rgba(223, 232, 250, 0.3);
241
+ }
242
+
243
+ .floating-text-format-popup button.toolbar-item.active i {
244
+ opacity: 1;
245
+ }
246
+
247
+ .floating-text-format-popup .toolbar-item:hover:not([disabled]) {
248
+ background-color: #eee;
249
+ }
250
+
251
+ .floating-text-format-popup .toolbar-item.font-family .text {
252
+ display: block;
253
+ max-width: 40px;
254
+ }
255
+
256
+ .floating-text-format-popup .code-language {
257
+ width: 150px;
258
+ }
259
+
260
+ .floating-text-format-popup .toolbar-item .text {
261
+ display: flex;
262
+ line-height: 20px;
263
+ vertical-align: middle;
264
+ font-size: 14px;
265
+ color: #777;
266
+ text-overflow: ellipsis;
267
+ overflow: hidden;
268
+ height: 20px;
269
+ text-align: left;
270
+ padding-right: 10px;
271
+ }
272
+
273
+ .floating-text-format-popup .toolbar-item .icon {
274
+ display: flex;
275
+ width: 20px;
276
+ height: 20px;
277
+ user-select: none;
278
+ margin-right: 8px;
279
+ line-height: 16px;
280
+ background-size: contain;
281
+ }
282
+
283
+ .floating-text-format-popup i.chevron-down {
284
+ margin-top: 3px;
285
+ width: 16px;
286
+ height: 16px;
287
+ display: flex;
288
+ user-select: none;
289
+ }
290
+
291
+ .floating-text-format-popup i.chevron-down.inside {
292
+ width: 16px;
293
+ height: 16px;
294
+ display: flex;
295
+ margin-left: -25px;
296
+ margin-top: 11px;
297
+ margin-right: 10px;
298
+ pointer-events: none;
299
+ }
300
+
301
+ .toolbar .divider {
302
+ width: 1px;
303
+ background-color: #eee;
304
+ margin: 0 4px;
305
+ }
306
+ .lexical-dropdown-container {
307
+ position: absolute;
308
+ bottom: -5px;
309
+ left: 0;
310
+ }
311
+
312
+ .lexical-dropdown {
313
+ z-index: 10;
314
+ display: block;
315
+ position: fixed;
316
+ box-shadow: 0 12px 28px 0 rgba(0, 0, 0, 0.2), 0 2px 4px 0 rgba(0, 0, 0, 0.1),
317
+ inset 0 0 0 1px rgba(255, 255, 255, 0.5);
318
+ border-radius: 8px;
319
+ min-height: 40px;
320
+ background-color: #fff;
321
+ max-height: 250px;
322
+ overflow: hidden;
323
+ overflow-y: auto;
324
+ }
325
+
326
+ .lexical-dropdown.no-scroll {
327
+ max-height: inherit;
328
+ overflow: auto;
329
+ overflow-y: auto;
330
+ }
331
+
332
+ .lexical-dropdown .item {
333
+ margin: 0 8px 0 8px;
334
+ padding: 8px;
335
+ color: #050505;
336
+ cursor: pointer;
337
+ line-height: 16px;
338
+ font-size: 15px;
339
+ display: flex;
340
+ align-content: center;
341
+ flex-direction: row;
342
+ flex-shrink: 0;
343
+ justify-content: space-between;
344
+ background-color: #fff;
345
+ border-radius: 8px;
346
+ border: 0;
347
+ max-width: 250px;
348
+ min-width: 100px;
349
+ }
350
+
351
+ .lexical-dropdown .item.fontsize-item,
352
+ .lexical-dropdown .item.fontsize-item .text {
353
+ min-width: unset;
354
+ }
355
+
356
+ .lexical-dropdown .item .active {
357
+ display: flex;
358
+ width: 20px;
359
+ height: 20px;
360
+ background-size: contain;
361
+ }
362
+
363
+ .lexical-dropdown .item:first-child {
364
+ margin-top: 8px;
365
+ }
366
+
367
+ .lexical-dropdown .item:last-child {
368
+ margin-bottom: 8px;
369
+ }
370
+
371
+ .lexical-dropdown .item:hover {
372
+ background-color: #eee;
373
+ }
374
+
375
+ .lexical-dropdown .item .text {
376
+ display: flex;
377
+ line-height: 20px;
378
+ flex-grow: 1;
379
+ min-width: 150px;
380
+ }
381
+
382
+ .lexical-dropdown .item .icon {
383
+ display: flex;
384
+ width: 20px;
385
+ height: 20px;
386
+ user-select: none;
387
+ margin-right: 12px;
388
+ line-height: 16px;
389
+ background-size: contain;
390
+ background-position: center;
391
+ background-repeat: no-repeat;
392
+ }
393
+
394
+ .lexical-dropdown .divider {
395
+ width: auto;
396
+ background-color: #eee;
397
+ margin: 4px 8px;
398
+ height: 1px;
399
+ }
400
+
401
+ @media screen and (max-width: 1100px) {
402
+ .dropdown-button-text {
403
+ display: none !important;
404
+ }
405
+ .font-size .dropdown-button-text {
406
+ display: flex !important;
407
+ }
408
+ .code-language .dropdown-button-text {
409
+ display: flex !important;
410
+ }
411
+ }
412
+
413
+ button.item i {
414
+ opacity: 0.6;
415
+ }
416
+
417
+ button.item.dropdown-item-active {
418
+ background-color: rgba(223, 232, 250, 0.3);
419
+ }
420
+
421
+ button.item.dropdown-item-active i {
422
+ opacity: 1;
423
+ }
@@ -0,0 +1,13 @@
1
+ /// <reference types="web" />
2
+ import React from "react";
3
+ import "./Toolbar.css";
4
+ import { ToolbarType } from "../../types";
5
+ export interface ToolbarProps {
6
+ type: ToolbarType;
7
+ anchorElem: HTMLElement;
8
+ children?: React.ReactNode;
9
+ }
10
+ /**
11
+ * @description Main toolbar container
12
+ */
13
+ export declare const Toolbar: import("@webiny/react-composition").ComposableFC<ToolbarProps>;