@webiny/lexical-editor 0.0.0-unstable.085ff6572f

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 (306) 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 +11 -0
  28. package/components/LexicalEditorConfig/LexicalEditorConfig.js +19 -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 +435 -0
  40. package/components/Toolbar/Toolbar.d.ts +13 -0
  41. package/components/Toolbar/Toolbar.js +215 -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 +56 -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 +58 -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 +52 -0
  69. package/components/ToolbarActions/QuoteAction.js.map +1 -0
  70. package/components/ToolbarActions/TextAlignmentAction.d.ts +11 -0
  71. package/components/ToolbarActions/TextAlignmentAction.js +70 -0
  72. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
  73. package/components/ToolbarActions/TypographyAction.d.ts +11 -0
  74. package/components/ToolbarActions/TypographyAction.js +145 -0
  75. package/components/ToolbarActions/TypographyAction.js.map +1 -0
  76. package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
  77. package/components/ToolbarActions/UnderlineAction.js +43 -0
  78. package/components/ToolbarActions/UnderlineAction.js.map +1 -0
  79. package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +2 -0
  80. package/components/ToolbarPresets/HeadingToolbarPreset.js +56 -0
  81. package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -0
  82. package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +2 -0
  83. package/components/ToolbarPresets/ParagraphToolbarPreset.js +71 -0
  84. package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -0
  85. package/context/FontColorActionContext.d.ts +6 -0
  86. package/context/FontColorActionContext.js +10 -0
  87. package/context/FontColorActionContext.js.map +1 -0
  88. package/context/RichTextEditorContext.d.ts +26 -0
  89. package/context/RichTextEditorContext.js +68 -0
  90. package/context/RichTextEditorContext.js.map +1 -0
  91. package/context/SharedHistoryContext.d.ts +11 -0
  92. package/context/SharedHistoryContext.js +26 -0
  93. package/context/SharedHistoryContext.js.map +1 -0
  94. package/context/TextAlignmentActionContextProps.d.ts +9 -0
  95. package/context/TextAlignmentActionContextProps.js +10 -0
  96. package/context/TextAlignmentActionContextProps.js.map +1 -0
  97. package/context/TypographyActionContext.d.ts +7 -0
  98. package/context/TypographyActionContext.js +10 -0
  99. package/context/TypographyActionContext.js.map +1 -0
  100. package/hooks/useFontColorPicker.d.ts +2 -0
  101. package/hooks/useFontColorPicker.js +15 -0
  102. package/hooks/useFontColorPicker.js.map +1 -0
  103. package/hooks/useList.d.ts +2 -0
  104. package/hooks/useList.js +39 -0
  105. package/hooks/useList.js.map +1 -0
  106. package/hooks/useQuote.d.ts +2 -0
  107. package/hooks/useQuote.js +20 -0
  108. package/hooks/useQuote.js.map +1 -0
  109. package/hooks/useRichTextEditor.d.ts +2 -0
  110. package/hooks/useRichTextEditor.js +15 -0
  111. package/hooks/useRichTextEditor.js.map +1 -0
  112. package/hooks/useTextAlignmentAction.d.ts +1 -0
  113. package/hooks/useTextAlignmentAction.js +15 -0
  114. package/hooks/useTextAlignmentAction.js.map +1 -0
  115. package/hooks/useTypographyAction.d.ts +1 -0
  116. package/hooks/useTypographyAction.js +15 -0
  117. package/hooks/useTypographyAction.js.map +1 -0
  118. package/images/icons/LICENSE.md +5 -0
  119. package/images/icons/chat-square-quote.svg +1 -0
  120. package/images/icons/chevron-down.svg +1 -0
  121. package/images/icons/code.svg +1 -0
  122. package/images/icons/font-color.svg +1 -0
  123. package/images/icons/indent.svg +3 -0
  124. package/images/icons/justify.svg +3 -0
  125. package/images/icons/link.svg +1 -0
  126. package/images/icons/list-ol.svg +1 -0
  127. package/images/icons/list-ul.svg +1 -0
  128. package/images/icons/outdent.svg +3 -0
  129. package/images/icons/pencil-fill.svg +1 -0
  130. package/images/icons/text-center.svg +1 -0
  131. package/images/icons/text-left.svg +1 -0
  132. package/images/icons/text-paragraph.svg +1 -0
  133. package/images/icons/text-right.svg +1 -0
  134. package/images/icons/type-bold.svg +1 -0
  135. package/images/icons/type-h1.svg +1 -0
  136. package/images/icons/type-h2.svg +1 -0
  137. package/images/icons/type-h3.svg +1 -0
  138. package/images/icons/type-h4.svg +1 -0
  139. package/images/icons/type-h5.svg +1 -0
  140. package/images/icons/type-h6.svg +1 -0
  141. package/images/icons/type-italic.svg +1 -0
  142. package/images/icons/type-strikethrough.svg +1 -0
  143. package/images/icons/type-underline.svg +1 -0
  144. package/images/icons/unlink_icon.svg +1 -0
  145. package/index.d.ts +42 -0
  146. package/index.js +295 -0
  147. package/index.js.map +1 -0
  148. package/nodes/FontColorNode.d.ts +43 -0
  149. package/nodes/FontColorNode.js +127 -0
  150. package/nodes/FontColorNode.js.map +1 -0
  151. package/nodes/HeadingNode.d.ts +34 -0
  152. package/nodes/HeadingNode.js +192 -0
  153. package/nodes/HeadingNode.js.map +1 -0
  154. package/nodes/ListItemNode.d.ts +46 -0
  155. package/nodes/ListItemNode.js +441 -0
  156. package/nodes/ListItemNode.js.map +1 -0
  157. package/nodes/ListNode/formatList.d.ts +12 -0
  158. package/nodes/ListNode/formatList.js +424 -0
  159. package/nodes/ListNode/formatList.js.map +1 -0
  160. package/nodes/ListNode.d.ts +42 -0
  161. package/nodes/ListNode.js +294 -0
  162. package/nodes/ListNode.js.map +1 -0
  163. package/nodes/ParagraphNode.d.ts +32 -0
  164. package/nodes/ParagraphNode.js +218 -0
  165. package/nodes/ParagraphNode.js.map +1 -0
  166. package/nodes/QuoteNode.d.ts +34 -0
  167. package/nodes/QuoteNode.js +225 -0
  168. package/nodes/QuoteNode.js.map +1 -0
  169. package/nodes/TypographyElementNode.d.ts +42 -0
  170. package/nodes/TypographyElementNode.js +155 -0
  171. package/nodes/TypographyElementNode.js.map +1 -0
  172. package/nodes/types.d.ts +15 -0
  173. package/nodes/types.js +5 -0
  174. package/nodes/types.js.map +1 -0
  175. package/nodes/webinyNodes.d.ts +7 -0
  176. package/nodes/webinyNodes.js +45 -0
  177. package/nodes/webinyNodes.js.map +1 -0
  178. package/package.json +41 -0
  179. package/plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts +11 -0
  180. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +46 -0
  181. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +1 -0
  182. package/plugins/AutoLinkPlugin/index.d.ts +1 -0
  183. package/plugins/AutoLinkPlugin/index.js +16 -0
  184. package/plugins/AutoLinkPlugin/index.js.map +1 -0
  185. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
  186. package/plugins/BlurEventPlugin/BlurEventPlugin.js +28 -0
  187. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
  188. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +17 -0
  189. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +88 -0
  190. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +1 -0
  191. package/plugins/ClickableLinkPlugin/index.d.ts +1 -0
  192. package/plugins/ClickableLinkPlugin/index.js +16 -0
  193. package/plugins/ClickableLinkPlugin/index.js.map +1 -0
  194. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
  195. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +20 -0
  196. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
  197. package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
  198. package/plugins/CodeHighlightPlugin/index.js +16 -0
  199. package/plugins/CodeHighlightPlugin/index.js.map +1 -0
  200. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +118 -0
  201. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
  202. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +222 -0
  203. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
  204. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
  205. package/plugins/FloatingLinkEditorPlugin/index.js +16 -0
  206. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
  207. package/plugins/FontColorPlugin/FontColorPlugin.d.ts +2 -0
  208. package/plugins/FontColorPlugin/FontColorPlugin.js +39 -0
  209. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
  210. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +8 -0
  211. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +34 -0
  212. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -0
  213. package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -0
  214. package/plugins/LexicalUpdateStatePlugin/index.js +16 -0
  215. package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -0
  216. package/plugins/TypographyPlugin/TypographyPlugin.d.ts +2 -0
  217. package/plugins/TypographyPlugin/TypographyPlugin.js +35 -0
  218. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
  219. package/plugins/WebinyListPLugin/WebinyListPlugin.d.ts +1 -0
  220. package/plugins/WebinyListPLugin/WebinyListPlugin.js +25 -0
  221. package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +1 -0
  222. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts +1 -0
  223. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +24 -0
  224. package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -0
  225. package/themes/webinyLexicalTheme.css +429 -0
  226. package/themes/webinyLexicalTheme.d.ts +9 -0
  227. package/themes/webinyLexicalTheme.js +87 -0
  228. package/themes/webinyLexicalTheme.js.map +1 -0
  229. package/types.d.ts +63 -0
  230. package/types.js +25 -0
  231. package/types.js.map +1 -0
  232. package/ui/Divider.d.ts +2 -0
  233. package/ui/Divider.js +13 -0
  234. package/ui/Divider.js.map +1 -0
  235. package/ui/DropDown.d.ts +26 -0
  236. package/ui/DropDown.js +206 -0
  237. package/ui/DropDown.js.map +1 -0
  238. package/ui/Input.css +32 -0
  239. package/ui/LinkPreview.css +69 -0
  240. package/ui/LinkPreview.d.ts +12 -0
  241. package/ui/LinkPreview.js +101 -0
  242. package/ui/LinkPreview.js.map +1 -0
  243. package/ui/Placeholder.css +23 -0
  244. package/ui/Placeholder.d.ts +13 -0
  245. package/ui/Placeholder.js +24 -0
  246. package/ui/Placeholder.js.map +1 -0
  247. package/ui/TextInput.d.ts +18 -0
  248. package/ui/TextInput.js +39 -0
  249. package/ui/TextInput.js.map +1 -0
  250. package/ui/ToolbarActionDialog.d.ts +12 -0
  251. package/ui/ToolbarActionDialog.js +106 -0
  252. package/ui/ToolbarActionDialog.js.map +1 -0
  253. package/utils/findTypographyStyleByHtmlTag.d.ts +8 -0
  254. package/utils/findTypographyStyleByHtmlTag.js +16 -0
  255. package/utils/findTypographyStyleByHtmlTag.js.map +1 -0
  256. package/utils/generateInitialLexicalValue.d.ts +5 -0
  257. package/utils/generateInitialLexicalValue.js +30 -0
  258. package/utils/generateInitialLexicalValue.js.map +1 -0
  259. package/utils/getDOMRangeRect.d.ts +10 -0
  260. package/utils/getDOMRangeRect.js +27 -0
  261. package/utils/getDOMRangeRect.js.map +1 -0
  262. package/utils/getLexicalTextSelectionState.d.ts +5 -0
  263. package/utils/getLexicalTextSelectionState.js +163 -0
  264. package/utils/getLexicalTextSelectionState.js.map +1 -0
  265. package/utils/getSelectedNode.d.ts +2 -0
  266. package/utils/getSelectedNode.js +30 -0
  267. package/utils/getSelectedNode.js.map +1 -0
  268. package/utils/isValidJSON.d.ts +1 -0
  269. package/utils/isValidJSON.js +18 -0
  270. package/utils/isValidJSON.js.map +1 -0
  271. package/utils/isValidLexicalData.d.ts +2 -0
  272. package/utils/isValidLexicalData.js +24 -0
  273. package/utils/isValidLexicalData.js.map +1 -0
  274. package/utils/nodes/clearNodeFormating.d.ts +2 -0
  275. package/utils/nodes/clearNodeFormating.js +28 -0
  276. package/utils/nodes/clearNodeFormating.js.map +1 -0
  277. package/utils/nodes/formatToHeading.d.ts +3 -0
  278. package/utils/nodes/formatToHeading.js +25 -0
  279. package/utils/nodes/formatToHeading.js.map +1 -0
  280. package/utils/nodes/formatToParagraph.d.ts +2 -0
  281. package/utils/nodes/formatToParagraph.js +20 -0
  282. package/utils/nodes/formatToParagraph.js.map +1 -0
  283. package/utils/nodes/formatToQuote.d.ts +2 -0
  284. package/utils/nodes/formatToQuote.js +25 -0
  285. package/utils/nodes/formatToQuote.js.map +1 -0
  286. package/utils/nodes/listNode.d.ts +11 -0
  287. package/utils/nodes/listNode.js +107 -0
  288. package/utils/nodes/listNode.js.map +1 -0
  289. package/utils/point.d.ts +21 -0
  290. package/utils/point.js +77 -0
  291. package/utils/point.js.map +1 -0
  292. package/utils/rect.d.ts +47 -0
  293. package/utils/rect.js +169 -0
  294. package/utils/rect.js.map +1 -0
  295. package/utils/sanitizeUrl.d.ts +8 -0
  296. package/utils/sanitizeUrl.js +27 -0
  297. package/utils/sanitizeUrl.js.map +1 -0
  298. package/utils/setFloatingElemPosition.d.ts +3 -0
  299. package/utils/setFloatingElemPosition.js +40 -0
  300. package/utils/setFloatingElemPosition.js.map +1 -0
  301. package/utils/styleObjectToString.d.ts +2 -0
  302. package/utils/styleObjectToString.js +22 -0
  303. package/utils/styleObjectToString.js.map +1 -0
  304. package/utils/toTypographyEmotionMap.d.ts +3 -0
  305. package/utils/toTypographyEmotionMap.js +36 -0
  306. package/utils/toTypographyEmotionMap.js.map +1 -0
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.$createHeadingNode = $createHeadingNode;
8
+ exports.$isHeadingNode = $isHeadingNode;
9
+ exports.HeadingNode = void 0;
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
12
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
14
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
15
+ var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
16
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
17
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
18
+ var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
19
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
20
+ var _lexical = require("lexical");
21
+ var _utils = require("@lexical/utils");
22
+ var _findTypographyStyleByHtmlTag = require("../utils/findTypographyStyleByHtmlTag");
23
+ var _richText = require("@lexical/rich-text");
24
+ var _ParagraphNode = require("./ParagraphNode");
25
+ var HeadingNode = /*#__PURE__*/function (_BaseHeadingNode) {
26
+ (0, _inherits2.default)(HeadingNode, _BaseHeadingNode);
27
+ var _super = (0, _createSuper2.default)(HeadingNode);
28
+ function HeadingNode(tag, typographyStyleId, key) {
29
+ var _this;
30
+ (0, _classCallCheck2.default)(this, HeadingNode);
31
+ _this = _super.call(this, tag, key);
32
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "__styles", []);
33
+ if (typographyStyleId) {
34
+ _this.__styles.push({
35
+ styleId: typographyStyleId,
36
+ type: "typography"
37
+ });
38
+ }
39
+ return _this;
40
+ }
41
+ (0, _createClass2.default)(HeadingNode, [{
42
+ key: "setDefaultTypography",
43
+ value: function setDefaultTypography(themeEmotionMap) {
44
+ var typographyStyle = (0, _findTypographyStyleByHtmlTag.findTypographyStyleByHtmlTag)(this.__tag, themeEmotionMap);
45
+ if (typographyStyle) {
46
+ this.__styles.push({
47
+ styleId: typographyStyle.id,
48
+ type: "typography"
49
+ });
50
+ }
51
+ }
52
+ }, {
53
+ key: "setTypography",
54
+ value: function setTypography(typographyStyleId) {
55
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "getWritable", this).call(this);
56
+ if (!this.hasTypographyStyle()) {
57
+ var themeStyle = {
58
+ styleId: typographyStyleId,
59
+ type: "typography"
60
+ };
61
+ self.__styles.push(themeStyle);
62
+ }
63
+ return self;
64
+ }
65
+ }, {
66
+ key: "getTypographyStyleId",
67
+ value: function getTypographyStyleId() {
68
+ var style = this.__styles.find(function (x) {
69
+ return x.type === "typography";
70
+ });
71
+ return (style === null || style === void 0 ? void 0 : style.styleId) || undefined;
72
+ }
73
+ }, {
74
+ key: "clearTypographyStyle",
75
+ value: function clearTypographyStyle() {
76
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "getWritable", this).call(this);
77
+ self.__styles = self.__styles.filter(function (s) {
78
+ return s.type !== "typography";
79
+ });
80
+ return self;
81
+ }
82
+ }, {
83
+ key: "hasTypographyStyle",
84
+ value: function hasTypographyStyle() {
85
+ return !!this.getTypographyStyleId();
86
+ }
87
+ }, {
88
+ key: "getThemeStyles",
89
+ value: function getThemeStyles() {
90
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "getLatest", this).call(this);
91
+ return self.__styles;
92
+ }
93
+ }, {
94
+ key: "setThemeStyles",
95
+ value: function setThemeStyles(styles) {
96
+ var self = (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "getWritable", this).call(this);
97
+ self.__styles = (0, _toConsumableArray2.default)(styles);
98
+ return self;
99
+ }
100
+ }, {
101
+ key: "updateElementWithThemeClasses",
102
+ value: function updateElementWithThemeClasses(element, theme) {
103
+ if (!(theme !== null && theme !== void 0 && theme.emotionMap)) {
104
+ return element;
105
+ }
106
+ if (!this.hasTypographyStyle()) {
107
+ this.setDefaultTypography(theme.emotionMap);
108
+ }
109
+ var typoStyleId = this.getTypographyStyleId();
110
+ var themeClasses;
111
+
112
+ // Typography css class
113
+ if (typoStyleId) {
114
+ var typographyStyle = theme.emotionMap[typoStyleId];
115
+ if (typographyStyle) {
116
+ themeClasses = typographyStyle.className;
117
+ }
118
+ }
119
+ if (themeClasses) {
120
+ (0, _utils.addClassNamesToElement)(element, themeClasses);
121
+ }
122
+ return element;
123
+ }
124
+ }, {
125
+ key: "createDOM",
126
+ value: function createDOM(config) {
127
+ var element = (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "createDOM", this).call(this, config);
128
+ return this.updateElementWithThemeClasses(element, config.theme);
129
+ }
130
+ }, {
131
+ key: "exportJSON",
132
+ value: function exportJSON() {
133
+ return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, (0, _get2.default)((0, _getPrototypeOf2.default)(HeadingNode.prototype), "exportJSON", this).call(this)), {}, {
134
+ styles: this.__styles,
135
+ type: "heading-element",
136
+ version: 1
137
+ });
138
+ }
139
+
140
+ // Mutation
141
+ }, {
142
+ key: "insertNewAfter",
143
+ value: function insertNewAfter(selection) {
144
+ var restoreSelection = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
145
+ // Next line for headings are always headings with the same tag
146
+ var newElement = $createHeadingNode(this.getTag());
147
+ var direction = this.getDirection();
148
+ newElement.setDirection(direction);
149
+ this.insertAfter(newElement, restoreSelection);
150
+ return newElement;
151
+ }
152
+ }, {
153
+ key: "collapseAtStart",
154
+ value: function collapseAtStart() {
155
+ var newElement = !this.isEmpty() ? $createHeadingNode(this.getTag()) : (0, _ParagraphNode.$createParagraphNode)();
156
+ var children = this.getChildren();
157
+ children.forEach(function (child) {
158
+ return newElement.append(child);
159
+ });
160
+ this.replace(newElement);
161
+ return true;
162
+ }
163
+ }], [{
164
+ key: "getType",
165
+ value: function getType() {
166
+ return "heading-element";
167
+ }
168
+ }, {
169
+ key: "clone",
170
+ value: function clone(node) {
171
+ return new HeadingNode(node.getTag(), node.getTypographyStyleId(), node.__key);
172
+ }
173
+ }, {
174
+ key: "importJSON",
175
+ value: function importJSON(serializedNode) {
176
+ var node = $createHeadingNode(serializedNode.tag);
177
+ node.setFormat(serializedNode.format);
178
+ node.setIndent(serializedNode.indent);
179
+ node.setDirection(serializedNode.direction);
180
+ node.setThemeStyles(serializedNode.styles);
181
+ return node;
182
+ }
183
+ }]);
184
+ return HeadingNode;
185
+ }(_richText.HeadingNode);
186
+ exports.HeadingNode = HeadingNode;
187
+ function $createHeadingNode(tag, typographyStyleId) {
188
+ return (0, _lexical.$applyNodeReplacement)(new HeadingNode(tag, typographyStyleId));
189
+ }
190
+ function $isHeadingNode(node) {
191
+ return node instanceof HeadingNode;
192
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["HeadingNode","tag","typographyStyleId","key","__styles","push","styleId","type","themeEmotionMap","typographyStyle","findTypographyStyleByHtmlTag","__tag","id","self","hasTypographyStyle","themeStyle","style","find","x","undefined","filter","s","getTypographyStyleId","styles","element","theme","emotionMap","setDefaultTypography","typoStyleId","themeClasses","className","addClassNamesToElement","config","updateElementWithThemeClasses","version","selection","restoreSelection","newElement","$createHeadingNode","getTag","direction","getDirection","setDirection","insertAfter","isEmpty","$createParagraphNode","children","getChildren","forEach","child","append","replace","node","__key","serializedNode","setFormat","format","setIndent","indent","setThemeStyles","BaseHeadingNode","$applyNodeReplacement","$isHeadingNode"],"sources":["HeadingNode.ts"],"sourcesContent":["import { $applyNodeReplacement, LexicalNode, NodeKey, RangeSelection, Spread } from \"lexical\";\nimport { EditorConfig } from \"lexical\";\nimport { TypographyStylesNode, ThemeStyleValue, TextNodeThemeStyles } from \"~/nodes/types\";\nimport { WebinyTheme } from \"~/themes/webinyLexicalTheme\";\nimport { addClassNamesToElement } from \"@lexical/utils\";\nimport { findTypographyStyleByHtmlTag } from \"~/utils/findTypographyStyleByHtmlTag\";\nimport { ThemeEmotionMap } from \"~/types\";\nimport {\n HeadingNode as BaseHeadingNode,\n HeadingTagType,\n SerializedHeadingNode as BaseSerializedHeadingNode\n} from \"@lexical/rich-text\";\nimport { $createParagraphNode, ParagraphNode } from \"~/nodes/ParagraphNode\";\n\nexport type SerializeHeadingNode = Spread<\n {\n styles: ThemeStyleValue[];\n type: \"heading-element\";\n },\n BaseSerializedHeadingNode\n>;\n\nexport class HeadingNode\n extends BaseHeadingNode\n implements TextNodeThemeStyles, TypographyStylesNode\n{\n __styles: ThemeStyleValue[] = [];\n\n constructor(tag: HeadingTagType, typographyStyleId?: string, key?: NodeKey) {\n super(tag, key);\n\n if (typographyStyleId) {\n this.__styles.push({ styleId: typographyStyleId, type: \"typography\" });\n }\n }\n\n protected setDefaultTypography(themeEmotionMap: ThemeEmotionMap) {\n const typographyStyle = findTypographyStyleByHtmlTag(this.__tag, themeEmotionMap);\n if (typographyStyle) {\n this.__styles.push({ styleId: typographyStyle.id, type: \"typography\" });\n }\n }\n\n setTypography(typographyStyleId: string): this {\n const self = super.getWritable();\n if (!this.hasTypographyStyle()) {\n const themeStyle = {\n styleId: typographyStyleId,\n type: \"typography\"\n } as ThemeStyleValue;\n self.__styles.push(themeStyle);\n }\n return self;\n }\n\n getTypographyStyleId(): string | undefined {\n const style = this.__styles.find(x => x.type === \"typography\");\n return style?.styleId || undefined;\n }\n\n clearTypographyStyle(): this {\n const self = super.getWritable();\n self.__styles = self.__styles.filter(s => s.type !== \"typography\");\n return self;\n }\n\n hasTypographyStyle(): boolean {\n return !!this.getTypographyStyleId();\n }\n\n getThemeStyles(): ThemeStyleValue[] {\n const self = super.getLatest();\n return self.__styles;\n }\n\n setThemeStyles(styles: ThemeStyleValue[]) {\n const self = super.getWritable();\n self.__styles = [...styles];\n return self;\n }\n\n static override getType(): string {\n return \"heading-element\";\n }\n\n static override clone(node: HeadingNode): HeadingNode {\n return new HeadingNode(node.getTag(), node.getTypographyStyleId(), node.__key);\n }\n\n protected updateElementWithThemeClasses(element: HTMLElement, theme: WebinyTheme): HTMLElement {\n if (!theme?.emotionMap) {\n return element;\n }\n\n if (!this.hasTypographyStyle()) {\n this.setDefaultTypography(theme.emotionMap);\n }\n\n const typoStyleId = this.getTypographyStyleId();\n\n let themeClasses;\n\n // Typography css class\n if (typoStyleId) {\n const typographyStyle = theme.emotionMap[typoStyleId];\n if (typographyStyle) {\n themeClasses = typographyStyle.className;\n }\n }\n\n if (themeClasses) {\n addClassNamesToElement(element, themeClasses);\n }\n\n return element;\n }\n\n override createDOM(config: EditorConfig): HTMLElement {\n const element = super.createDOM(config);\n return this.updateElementWithThemeClasses(element, config.theme as WebinyTheme);\n }\n\n static override importJSON(serializedNode: SerializeHeadingNode): BaseHeadingNode {\n const node = $createHeadingNode(serializedNode.tag);\n node.setFormat(serializedNode.format);\n node.setIndent(serializedNode.indent);\n node.setDirection(serializedNode.direction);\n node.setThemeStyles(serializedNode.styles);\n return node;\n }\n\n override exportJSON(): SerializeHeadingNode {\n return {\n ...super.exportJSON(),\n styles: this.__styles,\n type: \"heading-element\",\n version: 1\n };\n }\n\n // Mutation\n override insertNewAfter(\n selection?: RangeSelection,\n restoreSelection = true\n ): ParagraphNode | HeadingNode {\n // Next line for headings are always headings with the same tag\n const newElement = $createHeadingNode(this.getTag());\n const direction = this.getDirection();\n newElement.setDirection(direction);\n this.insertAfter(newElement, restoreSelection);\n return newElement;\n }\n\n override collapseAtStart(): true {\n const newElement = !this.isEmpty()\n ? $createHeadingNode(this.getTag())\n : $createParagraphNode();\n const children = this.getChildren();\n children.forEach(child => newElement.append(child));\n this.replace(newElement);\n return true;\n }\n}\n\nexport function $createHeadingNode(tag: HeadingTagType, typographyStyleId?: string): HeadingNode {\n return $applyNodeReplacement(new HeadingNode(tag, typographyStyleId));\n}\n\nexport function $isHeadingNode(node: LexicalNode | null | undefined): node is HeadingNode {\n return node instanceof HeadingNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAIA;AACA;AAEA;AAKA;AAA4E,IAU/DA,WAAW;EAAA;EAAA;EAMpB,qBAAYC,GAAmB,EAAEC,iBAA0B,EAAEC,GAAa,EAAE;IAAA;IAAA;IACxE,0BAAMF,GAAG,EAAEE,GAAG;IAAE,uFAHU,EAAE;IAK5B,IAAID,iBAAiB,EAAE;MACnB,MAAKE,QAAQ,CAACC,IAAI,CAAC;QAAEC,OAAO,EAAEJ,iBAAiB;QAAEK,IAAI,EAAE;MAAa,CAAC,CAAC;IAC1E;IAAC;EACL;EAAC;IAAA;IAAA,OAED,8BAA+BC,eAAgC,EAAE;MAC7D,IAAMC,eAAe,GAAG,IAAAC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;EAC7F,OAAO,IAAA2D,8BAAqB,EAAC,IAAI7D,WAAW,CAACC,GAAG,EAAEC,iBAAiB,CAAC,CAAC;AACzE;AAEO,SAAS4D,cAAc,CAACV,IAAoC,EAAuB;EACtF,OAAOA,IAAI,YAAYpD,WAAW;AACtC"}
@@ -0,0 +1,46 @@
1
+ /// <reference types="react" />
2
+ /// <reference types="web" />
3
+ import { DOMConversionMap, EditorConfig, ElementNode, GridSelection, LexicalNode, NodeKey, NodeSelection, ParagraphNode, RangeSelection, SerializedElementNode } from "lexical";
4
+ import { Spread } from "lexical";
5
+ export declare type SerializedWebinyListItemNode = Spread<{
6
+ checked: boolean | undefined;
7
+ type: "webiny-listitem";
8
+ value: number;
9
+ version: 1;
10
+ }, SerializedElementNode>;
11
+ /** @noInheritDoc */
12
+ export declare class ListItemNode extends ElementNode {
13
+ /** @internal */
14
+ __value: number;
15
+ /** @internal */
16
+ __checked?: boolean;
17
+ static getType(): string;
18
+ static clone(node: ListItemNode): ListItemNode;
19
+ constructor(value?: number, checked?: boolean, key?: NodeKey);
20
+ createDOM(config: EditorConfig): HTMLElement;
21
+ updateDOM(prevNode: ListItemNode, dom: HTMLElement, config: EditorConfig): boolean;
22
+ static importDOM(): DOMConversionMap | null;
23
+ static importJSON(serializedNode: SerializedWebinyListItemNode): ListItemNode;
24
+ exportJSON(): SerializedWebinyListItemNode;
25
+ append(...nodes: LexicalNode[]): this;
26
+ replace<N extends LexicalNode>(replaceWithNode: N): N;
27
+ insertAfter(node: LexicalNode): LexicalNode;
28
+ remove(preserveEmptyParent?: boolean): void;
29
+ insertNewAfter(): ListItemNode | ParagraphNode;
30
+ collapseAtStart(selection: RangeSelection): true;
31
+ getValue(): number;
32
+ setValue(value: number): void;
33
+ getChecked(): boolean | undefined;
34
+ setChecked(checked?: boolean): void;
35
+ toggleChecked(): void;
36
+ getIndent(): number;
37
+ setIndent(indent: number): this;
38
+ canIndent(): false;
39
+ insertBefore(nodeToInsert: LexicalNode): LexicalNode;
40
+ canInsertAfter(node: LexicalNode): boolean;
41
+ canReplaceWith(replacement: LexicalNode): boolean;
42
+ canMergeWith(node: LexicalNode): boolean;
43
+ extractWithChild(child: LexicalNode, selection: RangeSelection | NodeSelection | GridSelection): boolean;
44
+ }
45
+ export declare function $createListItemNode(checked?: boolean): ListItemNode;
46
+ export declare function $isListItemNode(node: LexicalNode | null | undefined): node is ListItemNode;