@webiny/lexical-editor 6.0.0-beta.0 → 6.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/README.md +6 -12
  2. package/commands/image.d.ts +2 -2
  3. package/commands/image.js +2 -8
  4. package/commands/image.js.map +1 -1
  5. package/commands/index.d.ts +5 -3
  6. package/commands/index.js +5 -38
  7. package/commands/index.js.map +1 -1
  8. package/commands/list.d.ts +2 -2
  9. package/commands/list.js +4 -10
  10. package/commands/list.js.map +1 -1
  11. package/commands/quote.d.ts +2 -2
  12. package/commands/quote.js +2 -8
  13. package/commands/quote.js.map +1 -1
  14. package/commands/toolbar.d.ts +1 -0
  15. package/commands/toolbar.js +4 -0
  16. package/commands/toolbar.js.map +1 -0
  17. package/commands/typography.d.ts +8 -0
  18. package/commands/typography.js +4 -0
  19. package/commands/typography.js.map +1 -0
  20. package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
  21. package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
  22. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
  23. package/components/Editor/RichTextEditor.d.ts +29 -12
  24. package/components/Editor/RichTextEditor.js +89 -110
  25. package/components/Editor/RichTextEditor.js.map +1 -1
  26. package/components/Editor/normalizeInputValue.d.ts +6 -0
  27. package/components/Editor/normalizeInputValue.js +16 -0
  28. package/components/Editor/normalizeInputValue.js.map +1 -0
  29. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +14 -16
  30. package/components/LexicalEditorConfig/LexicalEditorConfig.js +21 -69
  31. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -1
  32. package/components/LexicalEditorConfig/components/Node.d.ts +1 -1
  33. package/components/LexicalEditorConfig/components/Node.js +17 -26
  34. package/components/LexicalEditorConfig/components/Node.js.map +1 -1
  35. package/components/LexicalEditorConfig/components/Plugin.js +17 -26
  36. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -1
  37. package/components/LexicalEditorConfig/components/ToolbarElement.js +17 -26
  38. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -1
  39. package/components/LexicalHtmlRenderer.d.ts +5 -8
  40. package/components/LexicalHtmlRenderer.js +35 -50
  41. package/components/LexicalHtmlRenderer.js.map +1 -1
  42. package/components/Toolbar/StaticToolbar.css +416 -0
  43. package/components/Toolbar/StaticToolbar.d.ts +3 -1
  44. package/components/Toolbar/StaticToolbar.js +19 -23
  45. package/components/Toolbar/StaticToolbar.js.map +1 -1
  46. package/components/ToolbarActions/BoldAction.js +16 -21
  47. package/components/ToolbarActions/BoldAction.js.map +1 -1
  48. package/components/ToolbarActions/BulletListAction.js +25 -31
  49. package/components/ToolbarActions/BulletListAction.js.map +1 -1
  50. package/components/ToolbarActions/CodeHighlightAction.js +16 -21
  51. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -1
  52. package/components/ToolbarActions/FontColorAction.d.ts +16 -4
  53. package/components/ToolbarActions/FontColorAction.js +32 -43
  54. package/components/ToolbarActions/FontColorAction.js.map +1 -1
  55. package/components/ToolbarActions/ImageAction.js +19 -34
  56. package/components/ToolbarActions/ImageAction.js.map +1 -1
  57. package/components/ToolbarActions/ItalicAction.js +16 -21
  58. package/components/ToolbarActions/ItalicAction.js.map +1 -1
  59. package/components/ToolbarActions/LinkAction.js +19 -24
  60. package/components/ToolbarActions/LinkAction.js.map +1 -1
  61. package/components/ToolbarActions/NumberedListAction.js +25 -36
  62. package/components/ToolbarActions/NumberedListAction.js.map +1 -1
  63. package/components/ToolbarActions/QuoteAction.js +20 -25
  64. package/components/ToolbarActions/QuoteAction.js.map +1 -1
  65. package/components/ToolbarActions/TextAlignmentAction.d.ts +16 -4
  66. package/components/ToolbarActions/TextAlignmentAction.js +36 -45
  67. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -1
  68. package/components/ToolbarActions/TypographyAction.d.ts +16 -4
  69. package/components/ToolbarActions/TypographyAction.js +57 -79
  70. package/components/ToolbarActions/TypographyAction.js.map +1 -1
  71. package/components/ToolbarActions/UnderlineAction.js +16 -21
  72. package/components/ToolbarActions/UnderlineAction.js.map +1 -1
  73. package/context/FontColorActionContext.js +2 -9
  74. package/context/FontColorActionContext.js.map +1 -1
  75. package/context/RichTextEditorContext.d.ts +7 -8
  76. package/context/RichTextEditorContext.js +28 -26
  77. package/context/RichTextEditorContext.js.map +1 -1
  78. package/context/SharedHistoryContext.d.ts +3 -3
  79. package/context/SharedHistoryContext.js +12 -20
  80. package/context/SharedHistoryContext.js.map +1 -1
  81. package/context/TextAlignmentActionContextProps.d.ts +1 -1
  82. package/context/TextAlignmentActionContextProps.js +2 -9
  83. package/context/TextAlignmentActionContextProps.js.map +1 -1
  84. package/context/TypographyActionContext.d.ts +3 -2
  85. package/context/TypographyActionContext.js +2 -9
  86. package/context/TypographyActionContext.js.map +1 -1
  87. package/exports/admin/lexical.d.ts +15 -0
  88. package/exports/admin/lexical.js +23 -0
  89. package/exports/admin/lexical.js.map +1 -0
  90. package/hooks/index.d.ts +7 -8
  91. package/hooks/index.js +7 -93
  92. package/hooks/index.js.map +1 -1
  93. package/hooks/useCurrentElement.d.ts +3 -3
  94. package/hooks/useCurrentElement.js +11 -18
  95. package/hooks/useCurrentElement.js.map +1 -1
  96. package/hooks/useCurrentSelection.d.ts +2 -1
  97. package/hooks/useCurrentSelection.js +27 -40
  98. package/hooks/useCurrentSelection.js.map +1 -1
  99. package/hooks/useFontColorPicker.d.ts +1 -1
  100. package/hooks/useFontColorPicker.js +5 -11
  101. package/hooks/useFontColorPicker.js.map +1 -1
  102. package/hooks/useIsMounted.js +6 -14
  103. package/hooks/useIsMounted.js.map +1 -1
  104. package/hooks/useRichTextEditor.d.ts +1 -1
  105. package/hooks/useRichTextEditor.js +5 -11
  106. package/hooks/useRichTextEditor.js.map +1 -1
  107. package/hooks/useTextAlignmentAction.d.ts +1 -1
  108. package/hooks/useTextAlignmentAction.js +5 -11
  109. package/hooks/useTextAlignmentAction.js.map +1 -1
  110. package/hooks/useTypographyAction.d.ts +1 -1
  111. package/hooks/useTypographyAction.js +5 -11
  112. package/hooks/useTypographyAction.js.map +1 -1
  113. package/index.d.ts +33 -38
  114. package/index.js +44 -322
  115. package/index.js.map +1 -1
  116. package/package.json +18 -22
  117. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +2 -2
  118. package/plugins/BlurEventPlugin/BlurEventPlugin.js +16 -22
  119. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -1
  120. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +9 -14
  121. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -1
  122. package/plugins/CodeHighlightPlugin/index.d.ts +1 -1
  123. package/plugins/CodeHighlightPlugin/index.js +1 -16
  124. package/plugins/CodeHighlightPlugin/index.js.map +1 -1
  125. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +10 -0
  126. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +28 -0
  127. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  128. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +7 -0
  129. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +61 -0
  130. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  131. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +2 -136
  132. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +4 -16
  133. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +7 -180
  134. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -1
  135. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -1
  136. package/plugins/FloatingLinkEditorPlugin/index.js +1 -16
  137. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -1
  138. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +2 -8
  139. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -1
  140. package/plugins/FloatingLinkEditorPlugin/types.d.ts +10 -0
  141. package/plugins/FloatingLinkEditorPlugin/types.js +3 -0
  142. package/plugins/FloatingLinkEditorPlugin/types.js.map +1 -0
  143. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.d.ts +8 -2
  144. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js +119 -63
  145. package/plugins/FloatingLinkEditorPlugin/useFloatingLinkEditor.js.map +1 -1
  146. package/plugins/FontColorPlugin/FontColorPlugin.js +19 -28
  147. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -1
  148. package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
  149. package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
  150. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
  151. package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
  152. package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
  153. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
  154. package/plugins/ImagesPlugin/ImagesPlugin.d.ts +2 -3
  155. package/plugins/ImagesPlugin/ImagesPlugin.js +58 -60
  156. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -1
  157. package/plugins/LinkPlugin/LinkPlugin.d.ts +1 -1
  158. package/plugins/LinkPlugin/LinkPlugin.js +29 -37
  159. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -1
  160. package/plugins/ListPLugin/ListPlugin.js +52 -15
  161. package/plugins/ListPLugin/ListPlugin.js.map +1 -1
  162. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +19 -16
  163. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -1
  164. package/plugins/StateHandlingPlugin.d.ts +8 -0
  165. package/plugins/StateHandlingPlugin.js +75 -0
  166. package/plugins/StateHandlingPlugin.js.map +1 -0
  167. package/plugins/TypographyPlugin/TypographyPlugin.js +17 -21
  168. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -1
  169. package/types.d.ts +8 -8
  170. package/types.js +6 -38
  171. package/types.js.map +1 -1
  172. package/ui/ContentEditable.d.ts +0 -1
  173. package/ui/ContentEditable.js +7 -14
  174. package/ui/ContentEditable.js.map +1 -1
  175. package/ui/Divider.d.ts +0 -1
  176. package/ui/Divider.js +3 -10
  177. package/ui/Divider.js.map +1 -1
  178. package/ui/DropDown.d.ts +1 -1
  179. package/ui/DropDown.js +64 -90
  180. package/ui/DropDown.js.map +1 -1
  181. package/ui/ImageResizer.d.ts +0 -1
  182. package/ui/ImageResizer.js +84 -89
  183. package/ui/ImageResizer.js.map +1 -1
  184. package/ui/LinkPreview.d.ts +0 -1
  185. package/ui/LinkPreview.js +22 -29
  186. package/ui/LinkPreview.js.map +1 -1
  187. package/ui/Placeholder.d.ts +1 -1
  188. package/ui/Placeholder.js +10 -16
  189. package/ui/Placeholder.js.map +1 -1
  190. package/ui/TextInput.d.ts +1 -2
  191. package/ui/TextInput.js +11 -18
  192. package/ui/TextInput.js.map +1 -1
  193. package/ui/ToolbarActionDialog.js +30 -42
  194. package/ui/ToolbarActionDialog.js.map +1 -1
  195. package/utils/canUseDOM.js +1 -7
  196. package/utils/canUseDOM.js.map +1 -1
  197. package/utils/files.d.ts +6 -7
  198. package/utils/files.js +5 -56
  199. package/utils/files.js.map +1 -1
  200. package/utils/getDOMRangeRect.js +4 -10
  201. package/utils/getDOMRangeRect.js.map +1 -1
  202. package/utils/getSelectedNode.d.ts +1 -1
  203. package/utils/getSelectedNode.js +9 -16
  204. package/utils/getSelectedNode.js.map +1 -1
  205. package/utils/getTransparentImage.js +1 -7
  206. package/utils/getTransparentImage.js.map +1 -1
  207. package/utils/insertImage.d.ts +1 -1
  208. package/utils/insertImage.js +8 -14
  209. package/utils/insertImage.js.map +1 -1
  210. package/utils/isAnchorLink.js +1 -7
  211. package/utils/isAnchorLink.js.map +1 -1
  212. package/utils/isChildOfFloatingToolbar.js +2 -8
  213. package/utils/isChildOfFloatingToolbar.js.map +1 -1
  214. package/utils/isHTMLElement.js +1 -7
  215. package/utils/isHTMLElement.js.map +1 -1
  216. package/utils/isValidJSON.js +3 -9
  217. package/utils/isValidJSON.js.map +1 -1
  218. package/utils/isValidLexicalData.d.ts +3 -3
  219. package/utils/isValidLexicalData.js +6 -12
  220. package/utils/isValidLexicalData.js.map +1 -1
  221. package/utils/point.js +35 -60
  222. package/utils/point.js.map +1 -1
  223. package/utils/rect.d.ts +2 -2
  224. package/utils/rect.js +115 -149
  225. package/utils/rect.js.map +1 -1
  226. package/utils/sanitizeUrl.js +6 -13
  227. package/utils/sanitizeUrl.js.map +1 -1
  228. package/utils/setFloatingElemPosition.d.ts +1 -1
  229. package/utils/setFloatingElemPosition.js +29 -39
  230. package/utils/setFloatingElemPosition.js.map +1 -1
  231. package/components/Editor/HeadingEditor.d.ts +0 -7
  232. package/components/Editor/HeadingEditor.js +0 -29
  233. package/components/Editor/HeadingEditor.js.map +0 -1
  234. package/components/Editor/ParagraphEditor.d.ts +0 -7
  235. package/components/Editor/ParagraphEditor.js +0 -29
  236. package/components/Editor/ParagraphEditor.js.map +0 -1
  237. package/components/Toolbar/Toolbar.css +0 -647
  238. package/components/Toolbar/Toolbar.d.ts +0 -6
  239. package/components/Toolbar/Toolbar.js +0 -162
  240. package/components/Toolbar/Toolbar.js.map +0 -1
  241. package/components/ToolbarActions/FontSizeAction.d.ts +0 -2
  242. package/components/ToolbarActions/FontSizeAction.js +0 -88
  243. package/components/ToolbarActions/FontSizeAction.js.map +0 -1
  244. package/hooks/useList.d.ts +0 -2
  245. package/hooks/useList.js +0 -54
  246. package/hooks/useList.js.map +0 -1
  247. package/hooks/useQuote.d.ts +0 -2
  248. package/hooks/useQuote.js +0 -22
  249. package/hooks/useQuote.js.map +0 -1
  250. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +0 -9
  251. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +0 -118
  252. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +0 -1
  253. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +0 -9
  254. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +0 -44
  255. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +0 -1
  256. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.d.ts +0 -9
  257. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js +0 -45
  258. package/plugins/LexicalUpdateStatePlugin/UpdateStatePlugin.js.map +0 -1
  259. package/plugins/LexicalUpdateStatePlugin/index.d.ts +0 -1
  260. package/plugins/LexicalUpdateStatePlugin/index.js +0 -18
  261. package/plugins/LexicalUpdateStatePlugin/index.js.map +0 -1
  262. package/utils/generateInitialLexicalValue.d.ts +0 -5
  263. package/utils/generateInitialLexicalValue.js +0 -33
  264. package/utils/generateInitialLexicalValue.js.map +0 -1
@@ -1,64 +1,49 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.LexicalHtmlRenderer = void 0;
9
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
- var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
- var _react = _interopRequireWildcard(require("react"));
13
- var _emotion = require("emotion");
14
- var _LexicalComposer = require("@lexical/react/LexicalComposer");
15
- var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
16
- var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
17
- var _LexicalErrorBoundary = _interopRequireDefault(require("@lexical/react/LexicalErrorBoundary"));
18
- var _lexicalNodes = require("@webiny/lexical-nodes");
19
- var _lexicalTheme = require("@webiny/lexical-theme");
20
- var _isValidLexicalData = require("../utils/isValidLexicalData");
21
- var _generateInitialLexicalValue = require("../utils/generateInitialLexicalValue");
22
- var _LexicalUpdateStatePlugin = require("../plugins/LexicalUpdateStatePlugin");
23
- var _RichTextEditorContext = require("../context/RichTextEditorContext");
24
- var _excluded = ["nodes", "value", "theme"];
25
- var LexicalHtmlRenderer = exports.LexicalHtmlRenderer = function LexicalHtmlRenderer(_ref) {
26
- var nodes = _ref.nodes,
27
- value = _ref.value,
28
- theme = _ref.theme,
29
- props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
30
- var themeEmotionMap = props?.themeEmotionMap ?? (0, _lexicalTheme.toTypographyEmotionMap)(_emotion.css, theme, props.themeStylesTransformer);
31
- var editorTheme = (0, _react.useRef)((0, _lexicalTheme.createTheme)());
32
- var editorValue = (0, _isValidLexicalData.isValidLexicalData)(value) ? value : (0, _generateInitialLexicalValue.generateInitialLexicalValue)();
33
- var initialConfig = {
34
- // We update the state via the `<LexicalUpdateStatePlugin/>`.
1
+ import React, { useRef } from "react";
2
+ import { LexicalComposer } from "@lexical/react/LexicalComposer";
3
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
4
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
5
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary.js";
6
+ import { allNodes } from "@webiny/lexical-nodes";
7
+ import { RichTextEditorProvider } from "../context/RichTextEditorContext.js";
8
+ import { StateHandlingPlugin } from "../plugins/StateHandlingPlugin.js";
9
+ export const LexicalHtmlRenderer = ({
10
+ nodes,
11
+ value,
12
+ ...props
13
+ }) => {
14
+ const theme = props.theme;
15
+ const editorTheme = useRef(theme);
16
+ const initialConfig = {
35
17
  editorState: null,
36
18
  namespace: "webiny",
37
- onError: function onError() {
19
+ onError: () => {
38
20
  // Ignore errors. We don't want to break the app because of errors caused by config/value updates.
39
21
  // These are usually resolved in the next component render cycle.
40
22
  },
41
23
  editable: false,
42
- nodes: [].concat((0, _toConsumableArray2.default)(_lexicalNodes.allNodes), (0, _toConsumableArray2.default)(nodes || [])),
43
- theme: (0, _objectSpread2.default)((0, _objectSpread2.default)({}, editorTheme.current), {}, {
44
- emotionMap: themeEmotionMap,
45
- styles: theme.styles
46
- })
24
+ nodes: [...allNodes, ...(nodes || [])],
25
+ theme: {
26
+ ...editorTheme.current.tokens,
27
+ // I'm not aware of a better way to pass custom data to nodes.
28
+ // For now, we're using Lexical's theme to pass colors and typography.
29
+ $colors: editorTheme.current.colors,
30
+ $typography: editorTheme.current.typography,
31
+ $cacheKey: JSON.stringify(editorTheme.current)
32
+ }
47
33
  };
48
- return /*#__PURE__*/_react.default.createElement(_LexicalComposer.LexicalComposer, {
34
+ return /*#__PURE__*/React.createElement(LexicalComposer, {
49
35
  initialConfig: initialConfig,
50
36
  key: initialConfig.nodes.length
51
- }, /*#__PURE__*/_react.default.createElement(_RichTextEditorContext.RichTextEditorProvider, {
52
- theme: theme,
53
- themeEmotionMap: themeEmotionMap
54
- }, /*#__PURE__*/_react.default.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
55
- contentEditable: /*#__PURE__*/_react.default.createElement("div", {
37
+ }, /*#__PURE__*/React.createElement(RichTextEditorProvider, {
38
+ theme: theme
39
+ }, /*#__PURE__*/React.createElement(RichTextPlugin, {
40
+ contentEditable: /*#__PURE__*/React.createElement("div", {
56
41
  className: "editor"
57
- }, /*#__PURE__*/_react.default.createElement(_LexicalContentEditable.ContentEditable, null)),
58
- ErrorBoundary: _LexicalErrorBoundary.default,
42
+ }, /*#__PURE__*/React.createElement(ContentEditable, null)),
43
+ ErrorBoundary: LexicalErrorBoundary,
59
44
  placeholder: null
60
- }), /*#__PURE__*/_react.default.createElement(_LexicalUpdateStatePlugin.UpdateStatePlugin, {
61
- value: editorValue
45
+ }), /*#__PURE__*/React.createElement(StateHandlingPlugin, {
46
+ value: value
62
47
  })));
63
48
  };
64
49
 
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_emotion","_LexicalComposer","_LexicalRichTextPlugin","_LexicalContentEditable","_LexicalErrorBoundary","_interopRequireDefault","_lexicalNodes","_lexicalTheme","_isValidLexicalData","_generateInitialLexicalValue","_LexicalUpdateStatePlugin","_RichTextEditorContext","_excluded","LexicalHtmlRenderer","exports","_ref","nodes","value","theme","props","_objectWithoutProperties2","default","themeEmotionMap","toTypographyEmotionMap","css","themeStylesTransformer","editorTheme","useRef","createTheme","editorValue","isValidLexicalData","generateInitialLexicalValue","initialConfig","editorState","namespace","onError","editable","concat","_toConsumableArray2","allNodes","_objectSpread2","current","emotionMap","styles","createElement","LexicalComposer","key","length","RichTextEditorProvider","RichTextPlugin","contentEditable","className","ContentEditable","ErrorBoundary","LexicalErrorBoundary","placeholder","UpdateStatePlugin"],"sources":["LexicalHtmlRenderer.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport { Klass, LexicalNode } from \"lexical\";\nimport { css } from \"emotion\";\nimport { CSSObject } from \"@emotion/react\";\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 { allNodes } from \"@webiny/lexical-nodes\";\nimport {\n createTheme,\n WebinyTheme,\n ThemeEmotionMap,\n toTypographyEmotionMap\n} from \"@webiny/lexical-theme\";\nimport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\nimport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nimport { LexicalValue } from \"~/types\";\nimport { UpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext\";\n\ninterface LexicalHtmlRendererProps {\n nodes?: Klass<LexicalNode>[];\n value: LexicalValue | null;\n theme: WebinyTheme;\n themeEmotionMap?: ThemeEmotionMap;\n themeStylesTransformer?: (cssObject: Record<string, any>) => CSSObject;\n}\n\nexport const LexicalHtmlRenderer = ({\n nodes,\n value,\n theme,\n ...props\n}: LexicalHtmlRendererProps) => {\n const themeEmotionMap =\n props?.themeEmotionMap ?? toTypographyEmotionMap(css, theme, props.themeStylesTransformer);\n const editorTheme = useRef(createTheme());\n const editorValue = isValidLexicalData(value) ? value : generateInitialLexicalValue();\n\n const initialConfig = {\n // We update the state via the `<LexicalUpdateStatePlugin/>`.\n editorState: null,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n editable: false,\n nodes: [...allNodes, ...(nodes || [])],\n theme: { ...editorTheme.current, emotionMap: themeEmotionMap, styles: theme.styles }\n };\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider theme={theme} themeEmotionMap={themeEmotionMap}>\n <RichTextPlugin\n contentEditable={\n <div className=\"editor\">\n <ContentEditable />\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <UpdateStatePlugin value={editorValue} />\n </RichTextEditorProvider>\n </LexicalComposer>\n );\n};\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AACA,IAAAI,uBAAA,GAAAJ,OAAA;AACA,IAAAK,qBAAA,GAAAC,sBAAA,CAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AAMA,IAAAS,mBAAA,GAAAT,OAAA;AACA,IAAAU,4BAAA,GAAAV,OAAA;AAEA,IAAAW,yBAAA,GAAAX,OAAA;AACA,IAAAY,sBAAA,GAAAZ,OAAA;AAAyE,IAAAa,SAAA;AAUlE,IAAMC,mBAAmB,GAAAC,OAAA,CAAAD,mBAAA,GAAG,SAAtBA,mBAAmBA,CAAAE,IAAA,EAKA;EAAA,IAJ5BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,KAAK,GAAAH,IAAA,CAALG,KAAK;IACFC,KAAK,OAAAC,yBAAA,CAAAC,OAAA,EAAAN,IAAA,EAAAH,SAAA;EAER,IAAMU,eAAe,GACjBH,KAAK,EAAEG,eAAe,IAAI,IAAAC,oCAAsB,EAACC,YAAG,EAAEN,KAAK,EAAEC,KAAK,CAACM,sBAAsB,CAAC;EAC9F,IAAMC,WAAW,GAAG,IAAAC,aAAM,EAAC,IAAAC,yBAAW,EAAC,CAAC,CAAC;EACzC,IAAMC,WAAW,GAAG,IAAAC,sCAAkB,EAACb,KAAK,CAAC,GAAGA,KAAK,GAAG,IAAAc,wDAA2B,EAAC,CAAC;EAErF,IAAMC,aAAa,GAAG;IAClB;IACAC,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAE,SAAAA,QAAA,EAAM;MACX;MACA;IAAA,CACH;IACDC,QAAQ,EAAE,KAAK;IACfpB,KAAK,KAAAqB,MAAA,KAAAC,mBAAA,CAAAjB,OAAA,EAAMkB,sBAAQ,OAAAD,mBAAA,CAAAjB,OAAA,EAAML,KAAK,IAAI,EAAE,EAAE;IACtCE,KAAK,MAAAsB,cAAA,CAAAnB,OAAA,MAAAmB,cAAA,CAAAnB,OAAA,MAAOK,WAAW,CAACe,OAAO;MAAEC,UAAU,EAAEpB,eAAe;MAAEqB,MAAM,EAAEzB,KAAK,CAACyB;IAAM;EACtF,CAAC;EAED,oBACI9C,MAAA,CAAAwB,OAAA,CAAAuB,aAAA,CAAC3C,gBAAA,CAAA4C,eAAe;IAACb,aAAa,EAAEA,aAAc;IAACc,GAAG,EAAEd,aAAa,CAAChB,KAAK,CAAC+B;EAAO,gBAC3ElD,MAAA,CAAAwB,OAAA,CAAAuB,aAAA,CAACjC,sBAAA,CAAAqC,sBAAsB;IAAC9B,KAAK,EAAEA,KAAM;IAACI,eAAe,EAAEA;EAAgB,gBACnEzB,MAAA,CAAAwB,OAAA,CAAAuB,aAAA,CAAC1C,sBAAA,CAAA+C,cAAc;IACXC,eAAe,eACXrD,MAAA,CAAAwB,OAAA,CAAAuB,aAAA;MAAKO,SAAS,EAAC;IAAQ,gBACnBtD,MAAA,CAAAwB,OAAA,CAAAuB,aAAA,CAACzC,uBAAA,CAAAiD,eAAe,MAAE,CACjB,CACR;IACDC,aAAa,EAAEC,6BAAqB;IACpCC,WAAW,EAAE;EAAK,CACrB,CAAC,eACF1D,MAAA,CAAAwB,OAAA,CAAAuB,aAAA,CAAClC,yBAAA,CAAA8C,iBAAiB;IAACvC,KAAK,EAAEY;EAAY,CAAE,CACpB,CACX,CAAC;AAE1B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","useRef","LexicalComposer","RichTextPlugin","ContentEditable","LexicalErrorBoundary","allNodes","RichTextEditorProvider","StateHandlingPlugin","LexicalHtmlRenderer","nodes","value","props","theme","editorTheme","initialConfig","editorState","namespace","onError","editable","current","tokens","$colors","colors","$typography","typography","$cacheKey","JSON","stringify","createElement","key","length","contentEditable","className","ErrorBoundary","placeholder"],"sources":["LexicalHtmlRenderer.tsx"],"sourcesContent":["import React, { useRef } from \"react\";\nimport type { Klass, LexicalNode } from \"lexical\";\nimport { LexicalComposer } from \"@lexical/react/LexicalComposer\";\nimport { RichTextPlugin } from \"@lexical/react/LexicalRichTextPlugin\";\nimport { ContentEditable } from \"@lexical/react/LexicalContentEditable\";\nimport { LexicalErrorBoundary } from \"@lexical/react/LexicalErrorBoundary.js\";\nimport { allNodes } from \"@webiny/lexical-nodes\";\nimport type { EditorTheme } from \"@webiny/lexical-theme\";\nimport type { LexicalValue } from \"~/types.js\";\nimport { RichTextEditorProvider } from \"~/context/RichTextEditorContext.js\";\nimport { StateHandlingPlugin } from \"~/plugins/StateHandlingPlugin.js\";\n\ninterface LexicalHtmlRendererProps {\n nodes?: Klass<LexicalNode>[];\n value: LexicalValue | null;\n theme: EditorTheme;\n}\n\nexport const LexicalHtmlRenderer = ({ nodes, value, ...props }: LexicalHtmlRendererProps) => {\n const theme: EditorTheme = props.theme;\n const editorTheme = useRef(theme);\n\n const initialConfig = {\n editorState: null,\n namespace: \"webiny\",\n onError: () => {\n // Ignore errors. We don't want to break the app because of errors caused by config/value updates.\n // These are usually resolved in the next component render cycle.\n },\n editable: false,\n nodes: [...allNodes, ...(nodes || [])],\n theme: {\n ...editorTheme.current.tokens,\n // I'm not aware of a better way to pass custom data to nodes.\n // For now, we're using Lexical's theme to pass colors and typography.\n $colors: editorTheme.current.colors,\n $typography: editorTheme.current.typography,\n $cacheKey: JSON.stringify(editorTheme.current)\n }\n };\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={initialConfig.nodes.length}>\n <RichTextEditorProvider theme={theme}>\n <RichTextPlugin\n contentEditable={\n <div className=\"editor\">\n <ContentEditable />\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n placeholder={null}\n />\n <StateHandlingPlugin value={value} />\n </RichTextEditorProvider>\n </LexicalComposer>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,QAAQ,OAAO;AAErC,SAASC,eAAe,QAAQ,gCAAgC;AAChE,SAASC,cAAc,QAAQ,sCAAsC;AACrE,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,oBAAoB,QAAQ,wCAAwC;AAC7E,SAASC,QAAQ,QAAQ,uBAAuB;AAGhD,SAASC,sBAAsB;AAC/B,SAASC,mBAAmB;AAQ5B,OAAO,MAAMC,mBAAmB,GAAGA,CAAC;EAAEC,KAAK;EAAEC,KAAK;EAAE,GAAGC;AAAgC,CAAC,KAAK;EACzF,MAAMC,KAAkB,GAAGD,KAAK,CAACC,KAAK;EACtC,MAAMC,WAAW,GAAGb,MAAM,CAACY,KAAK,CAAC;EAEjC,MAAME,aAAa,GAAG;IAClBC,WAAW,EAAE,IAAI;IACjBC,SAAS,EAAE,QAAQ;IACnBC,OAAO,EAAEA,CAAA,KAAM;MACX;MACA;IAAA,CACH;IACDC,QAAQ,EAAE,KAAK;IACfT,KAAK,EAAE,CAAC,GAAGJ,QAAQ,EAAE,IAAII,KAAK,IAAI,EAAE,CAAC,CAAC;IACtCG,KAAK,EAAE;MACH,GAAGC,WAAW,CAACM,OAAO,CAACC,MAAM;MAC7B;MACA;MACAC,OAAO,EAAER,WAAW,CAACM,OAAO,CAACG,MAAM;MACnCC,WAAW,EAAEV,WAAW,CAACM,OAAO,CAACK,UAAU;MAC3CC,SAAS,EAAEC,IAAI,CAACC,SAAS,CAACd,WAAW,CAACM,OAAO;IACjD;EACJ,CAAC;EAED,oBACIpB,KAAA,CAAA6B,aAAA,CAAC3B,eAAe;IAACa,aAAa,EAAEA,aAAc;IAACe,GAAG,EAAEf,aAAa,CAACL,KAAK,CAACqB;EAAO,gBAC3E/B,KAAA,CAAA6B,aAAA,CAACtB,sBAAsB;IAACM,KAAK,EAAEA;EAAM,gBACjCb,KAAA,CAAA6B,aAAA,CAAC1B,cAAc;IACX6B,eAAe,eACXhC,KAAA,CAAA6B,aAAA;MAAKI,SAAS,EAAC;IAAQ,gBACnBjC,KAAA,CAAA6B,aAAA,CAACzB,eAAe,MAAE,CACjB,CACR;IACD8B,aAAa,EAAE7B,oBAAqB;IACpC8B,WAAW,EAAE;EAAK,CACrB,CAAC,eACFnC,KAAA,CAAA6B,aAAA,CAACrB,mBAAmB;IAACG,KAAK,EAAEA;EAAM,CAAE,CAChB,CACX,CAAC;AAE1B,CAAC","ignoreList":[]}
@@ -258,3 +258,419 @@
258
258
  .static-toolbar button.item.dropdown-item-active i {
259
259
  opacity: 1;
260
260
  }
261
+
262
+ i.bold {
263
+ background-image: url("../../images/icons/type-bold.svg");
264
+ }
265
+
266
+ i.italic {
267
+ background-image: url("../../images/icons/type-italic.svg");
268
+ }
269
+
270
+ i.code {
271
+ background-image: url("../../images/icons/code.svg");
272
+ }
273
+
274
+ i.underline {
275
+ background-image: url("../../images/icons/type-underline.svg");
276
+ }
277
+
278
+ i.strikethrough {
279
+ background-image: url("../../images/icons/type-strikethrough.svg");
280
+ }
281
+
282
+ i.link {
283
+ background-image: url("../../images/icons/link.svg");
284
+ }
285
+
286
+ i.quote {
287
+ background-image: url("../../images/icons/chat-square-quote.svg");
288
+ }
289
+
290
+ .icon.left-align,
291
+ i.left-align {
292
+ background-image: url("../../images/icons/text-left.svg");
293
+ }
294
+
295
+ i.center-align {
296
+ background-image: url("../../images/icons/text-center.svg");
297
+ }
298
+
299
+ i.right-align {
300
+ background-image: url("../../images/icons/text-right.svg");
301
+ }
302
+
303
+ i.indent {
304
+ background-image: url("../../images/icons/indent.svg");
305
+ }
306
+
307
+ i.outdent {
308
+ background-image: url("../../images/icons/outdent.svg");
309
+ }
310
+
311
+ i.justify-align {
312
+ background-image: url("../../images/icons/justify.svg");
313
+ }
314
+
315
+ i.chevron-down {
316
+ background-color: transparent;
317
+ background-size: contain;
318
+ display: inline-block;
319
+ height: 8px;
320
+ width: 8px;
321
+ background-image: url("../../images/icons/chevron-down.svg");
322
+ }
323
+
324
+ i.insert-image,
325
+ .icon.insert-image {
326
+ background-color: transparent;
327
+ background-size: contain;
328
+ display: inline-block;
329
+ height: 8px;
330
+ width: 8px;
331
+ background-image: url("../../images/icons/insert-image.svg");
332
+ }
333
+
334
+ .icon.bullet-list,
335
+ .icon.bullet {
336
+ background-image: url("../../images/icons/list-ul.svg");
337
+ }
338
+
339
+ .icon.numbered-list,
340
+ .icon.number {
341
+ background-image: url("../../images/icons/list-ol.svg");
342
+ }
343
+
344
+ i.font-color,
345
+ .icon.font-color {
346
+ background-image: url("../../images/icons/font-color.svg");
347
+ }
348
+
349
+ .link-editor .button.active,
350
+ .toolbar .button.active {
351
+ background-color: rgb(223, 232, 250);
352
+ }
353
+
354
+ .toolbar .divider {
355
+ width: 1px;
356
+ background-color: #eee;
357
+ margin: 0 4px;
358
+ }
359
+
360
+ .lexical-dropdown-container {
361
+ position: absolute;
362
+ bottom: -5px;
363
+ left: 0;
364
+ }
365
+
366
+ .lexical-dropdown {
367
+ z-index: 10;
368
+ display: block;
369
+ position: fixed;
370
+ box-shadow:
371
+ 0 12px 28px 0 rgba(0, 0, 0, 0.2),
372
+ 0 2px 4px 0 rgba(0, 0, 0, 0.1),
373
+ inset 0 0 0 1px rgba(255, 255, 255, 0.5);
374
+ border-radius: 8px;
375
+ min-height: 40px;
376
+ background-color: #fff;
377
+ max-height: 250px;
378
+ overflow: hidden;
379
+ overflow-y: auto;
380
+ }
381
+
382
+ .lexical-dropdown.no-scroll {
383
+ max-height: inherit;
384
+ overflow: auto;
385
+ overflow-y: auto;
386
+ }
387
+
388
+ .lexical-dropdown .item {
389
+ margin: 0 8px 0 8px;
390
+ padding: 8px;
391
+ color: #050505;
392
+ cursor: pointer;
393
+ line-height: 16px;
394
+ font-size: 15px;
395
+ display: flex;
396
+ align-content: center;
397
+ flex-direction: row;
398
+ flex-shrink: 0;
399
+ justify-content: space-between;
400
+ background-color: #fff;
401
+ border-radius: 8px;
402
+ border: 0;
403
+ max-width: 250px;
404
+ min-width: 100px;
405
+ }
406
+
407
+ .lexical-dropdown .item.fontsize-item,
408
+ .lexical-dropdown .item.fontsize-item .text {
409
+ min-width: unset;
410
+ }
411
+
412
+ .lexical-dropdown .item .active {
413
+ display: flex;
414
+ width: 20px;
415
+ height: 20px;
416
+ background-size: contain;
417
+ }
418
+
419
+ .lexical-dropdown .item:first-child {
420
+ margin-top: 8px;
421
+ }
422
+
423
+ .lexical-dropdown .item:last-child {
424
+ margin-bottom: 8px;
425
+ }
426
+
427
+ .lexical-dropdown .item:hover {
428
+ background-color: #eee;
429
+ }
430
+
431
+ .lexical-dropdown .item .text {
432
+ display: flex;
433
+ line-height: 20px;
434
+ flex-grow: 1;
435
+ min-width: 150px;
436
+ }
437
+
438
+ .lexical-dropdown .item .icon {
439
+ display: flex;
440
+ width: 20px;
441
+ height: 20px;
442
+ user-select: none;
443
+ margin-right: 12px;
444
+ line-height: 16px;
445
+ background-size: contain;
446
+ background-position: center;
447
+ background-repeat: no-repeat;
448
+ }
449
+
450
+ .lexical-dropdown .divider {
451
+ width: auto;
452
+ background-color: #eee;
453
+ margin: 4px 8px;
454
+ height: 1px;
455
+ }
456
+
457
+ @media screen and (max-width: 1100px) {
458
+ .dropdown-button-text {
459
+ display: none !important;
460
+ }
461
+ .font-size .dropdown-button-text {
462
+ display: flex !important;
463
+ }
464
+ .code-language .dropdown-button-text {
465
+ display: flex !important;
466
+ }
467
+ }
468
+
469
+ button.item i {
470
+ opacity: 0.6;
471
+ }
472
+
473
+ button.item.dropdown-item-active {
474
+ background-color: rgba(223, 232, 250, 0.3);
475
+ }
476
+
477
+ button.item.dropdown-item-active i {
478
+ opacity: 1;
479
+ }
480
+
481
+ .editor-shell span.editor-image {
482
+ cursor: default;
483
+ display: inline-block;
484
+ position: relative;
485
+ user-select: none;
486
+ }
487
+
488
+ .editor-shell .editor-image img {
489
+ max-width: 100%;
490
+ cursor: default;
491
+ }
492
+
493
+ .editor-shell .editor-image img.focused {
494
+ outline: 2px solid rgb(60, 132, 244);
495
+ user-select: none;
496
+ }
497
+
498
+ .editor-shell .editor-image img.focused.draggable {
499
+ cursor: grab;
500
+ }
501
+
502
+ .editor-shell .editor-image img.focused.draggable:active {
503
+ cursor: grabbing;
504
+ }
505
+
506
+ .editor-shell .editor-image .image-caption-container .tree-view-output {
507
+ margin: 0;
508
+ border-radius: 0;
509
+ }
510
+
511
+ .editor-shell .editor-image .image-caption-container {
512
+ display: block;
513
+ position: absolute;
514
+ bottom: 4px;
515
+ left: 0;
516
+ right: 0;
517
+ padding: 0;
518
+ margin: 0;
519
+ border-top: 1px solid #fff;
520
+ background-color: #ffffffe6;
521
+ min-width: 100px;
522
+ color: #000;
523
+ overflow: hidden;
524
+ }
525
+
526
+ .editor-shell .editor-image .image-caption-button {
527
+ display: block;
528
+ position: absolute;
529
+ bottom: 20px;
530
+ left: 0;
531
+ right: 0;
532
+ width: 30%;
533
+ padding: 10px;
534
+ margin: 0 auto;
535
+ border: 1px solid rgba(255, 255, 255, 0.3);
536
+ border-radius: 5px;
537
+ background-color: #00000080;
538
+ min-width: 100px;
539
+ color: #fff;
540
+ cursor: pointer;
541
+ user-select: none;
542
+ }
543
+
544
+ .editor-shell .editor-image .image-caption-button:hover {
545
+ background-color: #3c84f480;
546
+ }
547
+
548
+ .editor-shell .editor-image .image-resizer {
549
+ display: block;
550
+ width: 7px;
551
+ height: 7px;
552
+ position: absolute;
553
+ background-color: #3c84f4;
554
+ border: 1px solid #fff;
555
+ }
556
+
557
+ .editor-shell .editor-image .image-resizer.image-resizer-n {
558
+ top: -6px;
559
+ left: 48%;
560
+ cursor: n-resize;
561
+ }
562
+
563
+ .editor-shell .editor-image .image-resizer.image-resizer-ne {
564
+ top: -6px;
565
+ right: -6px;
566
+ cursor: ne-resize;
567
+ }
568
+
569
+ .editor-shell .editor-image .image-resizer.image-resizer-e {
570
+ bottom: 48%;
571
+ right: -6px;
572
+ cursor: e-resize;
573
+ }
574
+
575
+ .editor-shell .editor-image .image-resizer.image-resizer-se {
576
+ bottom: -2px;
577
+ right: -6px;
578
+ cursor: nwse-resize;
579
+ }
580
+
581
+ .editor-shell .editor-image .image-resizer.image-resizer-s {
582
+ bottom: -2px;
583
+ left: 48%;
584
+ cursor: s-resize;
585
+ }
586
+
587
+ .editor-shell .editor-image .image-resizer.image-resizer-sw {
588
+ bottom: -2px;
589
+ left: -6px;
590
+ cursor: sw-resize;
591
+ }
592
+
593
+ .editor-shell .editor-image .image-resizer.image-resizer-w {
594
+ bottom: 48%;
595
+ left: -6px;
596
+ cursor: w-resize;
597
+ }
598
+
599
+ .editor-shell .editor-image .image-resizer.image-resizer-nw {
600
+ top: -6px;
601
+ left: -6px;
602
+ cursor: nw-resize;
603
+ }
604
+
605
+ .editor-shell span.inline-editor-image {
606
+ cursor: default;
607
+ display: inline-block;
608
+ position: relative;
609
+ z-index: 1;
610
+ }
611
+
612
+ .editor-shell .inline-editor-image img {
613
+ max-width: 100%;
614
+ cursor: default;
615
+ }
616
+
617
+ .editor-shell .inline-editor-image img.focused {
618
+ outline: 2px solid rgb(60, 132, 244);
619
+ }
620
+
621
+ .editor-shell .inline-editor-image img.focused.draggable {
622
+ cursor: grab;
623
+ }
624
+
625
+ .editor-shell .inline-editor-image img.focused.draggable:active {
626
+ cursor: grabbing;
627
+ }
628
+
629
+ .editor-shell .inline-editor-image .image-caption-container .tree-view-output {
630
+ margin: 0;
631
+ border-radius: 0;
632
+ }
633
+
634
+ .editor-shell .inline-editor-image.position-full {
635
+ margin: 1em 0;
636
+ }
637
+
638
+ .editor-shell .inline-editor-image.position-left {
639
+ float: left;
640
+ width: 50%;
641
+ margin: 1em 1em 0 0;
642
+ }
643
+
644
+ .editor-shell .inline-editor-image.position-right {
645
+ float: right;
646
+ width: 50%;
647
+ margin: 1em 0 0 1em;
648
+ }
649
+
650
+ .editor-shell .inline-editor-image .image-edit-button {
651
+ display: block;
652
+ position: absolute;
653
+ top: 12px;
654
+ right: 12px;
655
+ padding: 6px 8px;
656
+ margin: 0 auto;
657
+ border: 1px solid rgba(255, 255, 255, 0.3);
658
+ border-radius: 5px;
659
+ background-color: #00000080;
660
+ min-width: 60px;
661
+ color: #fff;
662
+ cursor: pointer;
663
+ user-select: none;
664
+ }
665
+
666
+ .editor-shell .inline-editor-image .image-edit-button:hover {
667
+ background-color: #3c84f480;
668
+ }
669
+
670
+ .editor-shell .inline-editor-image .image-caption-container {
671
+ display: block;
672
+ background-color: #f4f4f4;
673
+ min-width: 100%;
674
+ color: #000;
675
+ overflow: hidden;
676
+ }
@@ -1,3 +1,5 @@
1
1
  import React from "react";
2
2
  import "./StaticToolbar.css";
3
- export declare const StaticToolbar: () => React.JSX.Element;
3
+ export declare const StaticToolbar: ({ className }: {
4
+ className?: string;
5
+ }) => React.JSX.Element;
@@ -1,26 +1,22 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.StaticToolbar = void 0;
8
- var _react = _interopRequireWildcard(require("react"));
9
- require("./StaticToolbar.css");
10
- var _LexicalEditorConfig = require("../LexicalEditorConfig/LexicalEditorConfig");
11
- var _hooks = require("../../hooks");
12
- var StaticToolbar = exports.StaticToolbar = function StaticToolbar() {
13
- var _useLexicalEditorConf = (0, _LexicalEditorConfig.useLexicalEditorConfig)(),
14
- toolbarElements = _useLexicalEditorConf.toolbarElements;
15
- var _useRichTextEditor = (0, _hooks.useRichTextEditor)(),
16
- editor = _useRichTextEditor.editor;
17
- return /*#__PURE__*/_react.default.createElement("div", {
18
- className: "static-toolbar"
19
- }, editor.isEditable() && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, toolbarElements.map(function (action) {
20
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
21
- key: action.name
22
- }, action.element);
23
- })));
1
+ import React, { Fragment } from "react";
2
+ import "./StaticToolbar.css";
3
+ import { useLexicalEditorConfig } from "../LexicalEditorConfig/LexicalEditorConfig.js";
4
+ import { useRichTextEditor } from "../../hooks/index.js";
5
+ export const StaticToolbar = ({
6
+ className
7
+ }) => {
8
+ const {
9
+ toolbarElements
10
+ } = useLexicalEditorConfig();
11
+ const {
12
+ editor
13
+ } = useRichTextEditor();
14
+ return /*#__PURE__*/React.createElement("div", {
15
+ className: className ?? "static-toolbar",
16
+ "data-role": "toolbar"
17
+ }, editor.isEditable() && /*#__PURE__*/React.createElement(React.Fragment, null, toolbarElements.map(action => /*#__PURE__*/React.createElement(Fragment, {
18
+ key: action.name
19
+ }, action.element))));
24
20
  };
25
21
 
26
22
  //# sourceMappingURL=StaticToolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_LexicalEditorConfig","_hooks","StaticToolbar","exports","_useLexicalEditorConf","useLexicalEditorConfig","toolbarElements","_useRichTextEditor","useRichTextEditor","editor","default","createElement","className","isEditable","Fragment","map","action","key","name","element"],"sources":["StaticToolbar.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport \"./StaticToolbar.css\";\nimport { useLexicalEditorConfig } from \"~/components/LexicalEditorConfig/LexicalEditorConfig\";\nimport { useRichTextEditor } from \"~/hooks\";\n\nexport const StaticToolbar = () => {\n const { toolbarElements } = useLexicalEditorConfig();\n const { editor } = useRichTextEditor();\n\n return (\n <div className=\"static-toolbar\">\n {editor.isEditable() && (\n <>\n {toolbarElements.map(action => (\n <Fragment key={action.name}>{action.element}</Fragment>\n ))}\n </>\n )}\n </div>\n );\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACAA,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,IAAMG,aAAa,GAAAC,OAAA,CAAAD,aAAA,GAAG,SAAhBA,aAAaA,CAAA,EAAS;EAC/B,IAAAE,qBAAA,GAA4B,IAAAC,2CAAsB,EAAC,CAAC;IAA5CC,eAAe,GAAAF,qBAAA,CAAfE,eAAe;EACvB,IAAAC,kBAAA,GAAmB,IAAAC,wBAAiB,EAAC,CAAC;IAA9BC,MAAM,GAAAF,kBAAA,CAANE,MAAM;EAEd,oBACIZ,MAAA,CAAAa,OAAA,CAAAC,aAAA;IAAKC,SAAS,EAAC;EAAgB,GAC1BH,MAAM,CAACI,UAAU,CAAC,CAAC,iBAChBhB,MAAA,CAAAa,OAAA,CAAAC,aAAA,CAAAd,MAAA,CAAAa,OAAA,CAAAI,QAAA,QACKR,eAAe,CAACS,GAAG,CAAC,UAAAC,MAAM;IAAA,oBACvBnB,MAAA,CAAAa,OAAA,CAAAC,aAAA,CAACd,MAAA,CAAAiB,QAAQ;MAACG,GAAG,EAAED,MAAM,CAACE;IAAK,GAAEF,MAAM,CAACG,OAAkB,CAAC;EAAA,CAC1D,CACH,CAEL,CAAC;AAEd,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","Fragment","useLexicalEditorConfig","useRichTextEditor","StaticToolbar","className","toolbarElements","editor","createElement","isEditable","map","action","key","name","element"],"sources":["StaticToolbar.tsx"],"sourcesContent":["import React, { Fragment } from \"react\";\nimport \"./StaticToolbar.css\";\nimport { useLexicalEditorConfig } from \"~/components/LexicalEditorConfig/LexicalEditorConfig.js\";\nimport { useRichTextEditor } from \"~/hooks/index.js\";\n\nexport const StaticToolbar = ({ className }: { className?: string }) => {\n const { toolbarElements } = useLexicalEditorConfig();\n const { editor } = useRichTextEditor();\n\n return (\n <div className={className ?? \"static-toolbar\"} data-role={\"toolbar\"}>\n {editor.isEditable() && (\n <>\n {toolbarElements.map(action => (\n <Fragment key={action.name}>{action.element}</Fragment>\n ))}\n </>\n )}\n </div>\n );\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC;AACA,SAASC,sBAAsB;AAC/B,SAASC,iBAAiB;AAE1B,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC;AAAkC,CAAC,KAAK;EACpE,MAAM;IAAEC;EAAgB,CAAC,GAAGJ,sBAAsB,CAAC,CAAC;EACpD,MAAM;IAAEK;EAAO,CAAC,GAAGJ,iBAAiB,CAAC,CAAC;EAEtC,oBACIH,KAAA,CAAAQ,aAAA;IAAKH,SAAS,EAAEA,SAAS,IAAI,gBAAiB;IAAC,aAAW;EAAU,GAC/DE,MAAM,CAACE,UAAU,CAAC,CAAC,iBAChBT,KAAA,CAAAQ,aAAA,CAAAR,KAAA,CAAAC,QAAA,QACKK,eAAe,CAACI,GAAG,CAACC,MAAM,iBACvBX,KAAA,CAAAQ,aAAA,CAACP,QAAQ;IAACW,GAAG,EAAED,MAAM,CAACE;EAAK,GAAEF,MAAM,CAACG,OAAkB,CACzD,CACH,CAEL,CAAC;AAEd,CAAC","ignoreList":[]}
@@ -1,28 +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.BoldAction = void 0;
8
- var _react = _interopRequireDefault(require("react"));
9
- var _lexical = require("lexical");
10
- var _useCurrentSelection2 = require("../../hooks/useCurrentSelection");
11
- var _hooks = require("../../hooks");
12
- var BoldAction = exports.BoldAction = function BoldAction() {
13
- var _useRichTextEditor = (0, _hooks.useRichTextEditor)(),
14
- editor = _useRichTextEditor.editor;
15
- var _useCurrentSelection = (0, _useCurrentSelection2.useCurrentSelection)(),
16
- rangeSelection = _useCurrentSelection.rangeSelection;
17
- var isBoldSelected = rangeSelection ? rangeSelection.hasFormat("bold") : false;
18
- var handleClick = function handleClick() {
19
- editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, "bold");
1
+ import React from "react";
2
+ import { FORMAT_TEXT_COMMAND } from "lexical";
3
+ import { useCurrentSelection } from "../../hooks/useCurrentSelection.js";
4
+ import { useRichTextEditor } from "../../hooks/index.js";
5
+ export const BoldAction = () => {
6
+ const {
7
+ editor
8
+ } = useRichTextEditor();
9
+ const {
10
+ rangeSelection
11
+ } = useCurrentSelection();
12
+ const isBoldSelected = rangeSelection ? rangeSelection.hasFormat("bold") : false;
13
+ const handleClick = () => {
14
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, "bold");
20
15
  };
21
- return /*#__PURE__*/_react.default.createElement("button", {
16
+ return /*#__PURE__*/React.createElement("button", {
22
17
  onClick: handleClick,
23
18
  className: "popup-item spaced " + (isBoldSelected ? "active" : ""),
24
19
  "aria-label": "Format text as bold"
25
- }, /*#__PURE__*/_react.default.createElement("i", {
20
+ }, /*#__PURE__*/React.createElement("i", {
26
21
  className: "format bold"
27
22
  }));
28
23
  };