@webiny/lexical-editor 0.0.0-unstable.d65ec29d44

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 (188) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/components/AddRichTextEditorNodeType.d.ts +6 -0
  4. package/components/AddRichTextEditorNodeType.js +28 -0
  5. package/components/AddRichTextEditorNodeType.js.map +1 -0
  6. package/components/AddRichTextEditorPlugin.d.ts +10 -0
  7. package/components/AddRichTextEditorPlugin.js +31 -0
  8. package/components/AddRichTextEditorPlugin.js.map +1 -0
  9. package/components/AddToolbarAction.d.ts +7 -0
  10. package/components/AddToolbarAction.js +33 -0
  11. package/components/AddToolbarAction.js.map +1 -0
  12. package/components/Editor/HeadingEditor.d.ts +7 -0
  13. package/components/Editor/HeadingEditor.js +28 -0
  14. package/components/Editor/HeadingEditor.js.map +1 -0
  15. package/components/Editor/ParagraphEditor.d.ts +7 -0
  16. package/components/Editor/ParagraphEditor.js +30 -0
  17. package/components/Editor/ParagraphEditor.js.map +1 -0
  18. package/components/Editor/RichTextEditor.d.ts +23 -0
  19. package/components/Editor/RichTextEditor.js +107 -0
  20. package/components/Editor/RichTextEditor.js.map +1 -0
  21. package/components/LexicalHtmlRenderer.d.ts +9 -0
  22. package/components/LexicalHtmlRenderer.js +44 -0
  23. package/components/LexicalHtmlRenderer.js.map +1 -0
  24. package/components/Toolbar/HeadingToolbar.d.ts +12 -0
  25. package/components/Toolbar/HeadingToolbar.js +23 -0
  26. package/components/Toolbar/HeadingToolbar.js.map +1 -0
  27. package/components/Toolbar/ParagraphToolbar.d.ts +12 -0
  28. package/components/Toolbar/ParagraphToolbar.js +23 -0
  29. package/components/Toolbar/ParagraphToolbar.js.map +1 -0
  30. package/components/Toolbar/Toolbar.css +414 -0
  31. package/components/Toolbar/Toolbar.d.ts +13 -0
  32. package/components/Toolbar/Toolbar.js +161 -0
  33. package/components/Toolbar/Toolbar.js.map +1 -0
  34. package/components/ToolbarActions/BoldAction.d.ts +5 -0
  35. package/components/ToolbarActions/BoldAction.js +38 -0
  36. package/components/ToolbarActions/BoldAction.js.map +1 -0
  37. package/components/ToolbarActions/BulletListAction.d.ts +5 -0
  38. package/components/ToolbarActions/BulletListAction.js +89 -0
  39. package/components/ToolbarActions/BulletListAction.js.map +1 -0
  40. package/components/ToolbarActions/CodeHighlightAction.d.ts +6 -0
  41. package/components/ToolbarActions/CodeHighlightAction.js +39 -0
  42. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
  43. package/components/ToolbarActions/FontSizeAction.d.ts +2 -0
  44. package/components/ToolbarActions/FontSizeAction.js +104 -0
  45. package/components/ToolbarActions/FontSizeAction.js.map +1 -0
  46. package/components/ToolbarActions/ItalicAction.d.ts +5 -0
  47. package/components/ToolbarActions/ItalicAction.js +38 -0
  48. package/components/ToolbarActions/ItalicAction.js.map +1 -0
  49. package/components/ToolbarActions/LinkAction.d.ts +7 -0
  50. package/components/ToolbarActions/LinkAction.js +69 -0
  51. package/components/ToolbarActions/LinkAction.js.map +1 -0
  52. package/components/ToolbarActions/NumberedListAction.d.ts +5 -0
  53. package/components/ToolbarActions/NumberedListAction.js +89 -0
  54. package/components/ToolbarActions/NumberedListAction.js.map +1 -0
  55. package/components/ToolbarActions/QuoteAction.d.ts +4 -0
  56. package/components/ToolbarActions/QuoteAction.js +66 -0
  57. package/components/ToolbarActions/QuoteAction.js.map +1 -0
  58. package/components/ToolbarActions/UnderlineAction.d.ts +5 -0
  59. package/components/ToolbarActions/UnderlineAction.js +38 -0
  60. package/components/ToolbarActions/UnderlineAction.js.map +1 -0
  61. package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +2 -0
  62. package/components/ToolbarPresets/HeadingToolbarPreset.js +44 -0
  63. package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -0
  64. package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +2 -0
  65. package/components/ToolbarPresets/ParagraphToolbarPreset.js +59 -0
  66. package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -0
  67. package/context/RichTextEditorContext.d.ts +11 -0
  68. package/context/RichTextEditorContext.js +29 -0
  69. package/context/RichTextEditorContext.js.map +1 -0
  70. package/hooks/useRichTextEditor.d.ts +2 -0
  71. package/hooks/useRichTextEditor.js +15 -0
  72. package/hooks/useRichTextEditor.js.map +1 -0
  73. package/images/icons/LICENSE.md +5 -0
  74. package/images/icons/chat-square-quote.svg +1 -0
  75. package/images/icons/chevron-down.svg +1 -0
  76. package/images/icons/code.svg +1 -0
  77. package/images/icons/link.svg +1 -0
  78. package/images/icons/list-ol.svg +1 -0
  79. package/images/icons/list-ul.svg +1 -0
  80. package/images/icons/pencil-fill.svg +1 -0
  81. package/images/icons/text-center.svg +1 -0
  82. package/images/icons/text-left.svg +1 -0
  83. package/images/icons/text-paragraph.svg +1 -0
  84. package/images/icons/text-right.svg +1 -0
  85. package/images/icons/type-bold.svg +1 -0
  86. package/images/icons/type-h1.svg +1 -0
  87. package/images/icons/type-h2.svg +1 -0
  88. package/images/icons/type-h3.svg +1 -0
  89. package/images/icons/type-h4.svg +1 -0
  90. package/images/icons/type-h5.svg +1 -0
  91. package/images/icons/type-h6.svg +1 -0
  92. package/images/icons/type-italic.svg +1 -0
  93. package/images/icons/type-strikethrough.svg +1 -0
  94. package/images/icons/type-underline.svg +1 -0
  95. package/images/icons/unlink_icon.svg +1 -0
  96. package/index.d.ts +34 -0
  97. package/index.js +239 -0
  98. package/index.js.map +1 -0
  99. package/nodes/webinyNodes.d.ts +2 -0
  100. package/nodes/webinyNodes.js +15 -0
  101. package/nodes/webinyNodes.js.map +1 -0
  102. package/package.json +38 -0
  103. package/plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts +11 -0
  104. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +46 -0
  105. package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +1 -0
  106. package/plugins/AutoLinkPlugin/index.d.ts +1 -0
  107. package/plugins/AutoLinkPlugin/index.js +16 -0
  108. package/plugins/AutoLinkPlugin/index.js.map +1 -0
  109. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
  110. package/plugins/BlurEventPlugin/BlurEventPlugin.js +28 -0
  111. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
  112. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +17 -0
  113. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +88 -0
  114. package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +1 -0
  115. package/plugins/ClickableLinkPlugin/index.d.ts +1 -0
  116. package/plugins/ClickableLinkPlugin/index.js +16 -0
  117. package/plugins/ClickableLinkPlugin/index.js.map +1 -0
  118. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
  119. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +20 -0
  120. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
  121. package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
  122. package/plugins/CodeHighlightPlugin/index.js +16 -0
  123. package/plugins/CodeHighlightPlugin/index.js.map +1 -0
  124. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +118 -0
  125. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
  126. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +222 -0
  127. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
  128. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
  129. package/plugins/FloatingLinkEditorPlugin/index.js +16 -0
  130. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
  131. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +8 -0
  132. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +34 -0
  133. package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -0
  134. package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -0
  135. package/plugins/LexicalUpdateStatePlugin/index.js +16 -0
  136. package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -0
  137. package/themes/webinyLexicalTheme.css +422 -0
  138. package/themes/webinyLexicalTheme.d.ts +10 -0
  139. package/themes/webinyLexicalTheme.js +107 -0
  140. package/themes/webinyLexicalTheme.js.map +1 -0
  141. package/types.d.ts +2 -0
  142. package/types.js +5 -0
  143. package/types.js.map +1 -0
  144. package/ui/Divider.d.ts +2 -0
  145. package/ui/Divider.js +13 -0
  146. package/ui/Divider.js.map +1 -0
  147. package/ui/DropDown.d.ts +25 -0
  148. package/ui/DropDown.js +168 -0
  149. package/ui/DropDown.js.map +1 -0
  150. package/ui/Input.css +32 -0
  151. package/ui/LinkPreview.css +69 -0
  152. package/ui/LinkPreview.d.ts +12 -0
  153. package/ui/LinkPreview.js +101 -0
  154. package/ui/LinkPreview.js.map +1 -0
  155. package/ui/Placeholder.css +23 -0
  156. package/ui/Placeholder.d.ts +13 -0
  157. package/ui/Placeholder.js +24 -0
  158. package/ui/Placeholder.js.map +1 -0
  159. package/ui/TextInput.d.ts +18 -0
  160. package/ui/TextInput.js +39 -0
  161. package/ui/TextInput.js.map +1 -0
  162. package/utils/generateInitialLexicalValue.d.ts +5 -0
  163. package/utils/generateInitialLexicalValue.js +29 -0
  164. package/utils/generateInitialLexicalValue.js.map +1 -0
  165. package/utils/getDOMRangeRect.d.ts +10 -0
  166. package/utils/getDOMRangeRect.js +27 -0
  167. package/utils/getDOMRangeRect.js.map +1 -0
  168. package/utils/getSelectedNode.d.ts +2 -0
  169. package/utils/getSelectedNode.js +30 -0
  170. package/utils/getSelectedNode.js.map +1 -0
  171. package/utils/isValidJSON.d.ts +1 -0
  172. package/utils/isValidJSON.js +18 -0
  173. package/utils/isValidJSON.js.map +1 -0
  174. package/utils/isValidLexicalData.d.ts +2 -0
  175. package/utils/isValidLexicalData.js +24 -0
  176. package/utils/isValidLexicalData.js.map +1 -0
  177. package/utils/point.d.ts +21 -0
  178. package/utils/point.js +77 -0
  179. package/utils/point.js.map +1 -0
  180. package/utils/rect.d.ts +47 -0
  181. package/utils/rect.js +169 -0
  182. package/utils/rect.js.map +1 -0
  183. package/utils/sanitizeUrl.d.ts +8 -0
  184. package/utils/sanitizeUrl.js +27 -0
  185. package/utils/sanitizeUrl.js.map +1 -0
  186. package/utils/setFloatingElemPosition.d.ts +3 -0
  187. package/utils/setFloatingElemPosition.js +40 -0
  188. package/utils/setFloatingElemPosition.js.map +1 -0
package/index.js ADDED
@@ -0,0 +1,239 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ Object.defineProperty(exports, "AddRichTextEditorNodeType", {
8
+ enumerable: true,
9
+ get: function get() {
10
+ return _AddRichTextEditorNodeType.AddRichTextEditorNodeType;
11
+ }
12
+ });
13
+ Object.defineProperty(exports, "AddRichTextEditorPlugin", {
14
+ enumerable: true,
15
+ get: function get() {
16
+ return _AddRichTextEditorPlugin.AddRichTextEditorPlugin;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "AddToolbarAction", {
20
+ enumerable: true,
21
+ get: function get() {
22
+ return _AddToolbarAction.AddToolbarAction;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "BlurEventPlugin", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _BlurEventPlugin.BlurEventPlugin;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "BoldAction", {
32
+ enumerable: true,
33
+ get: function get() {
34
+ return _BoldAction.BoldAction;
35
+ }
36
+ });
37
+ Object.defineProperty(exports, "BulletListAction", {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _BulletListAction.BulletListAction;
41
+ }
42
+ });
43
+ Object.defineProperty(exports, "ClickableLinkPlugin", {
44
+ enumerable: true,
45
+ get: function get() {
46
+ return _ClickableLinkPlugin.ClickableLinkPlugin;
47
+ }
48
+ });
49
+ Object.defineProperty(exports, "CodeHighlightAction", {
50
+ enumerable: true,
51
+ get: function get() {
52
+ return _CodeHighlightAction.CodeHighlightAction;
53
+ }
54
+ });
55
+ Object.defineProperty(exports, "CodeHighlightPlugin", {
56
+ enumerable: true,
57
+ get: function get() {
58
+ return _CodeHighlightPlugin.CodeHighlightPlugin;
59
+ }
60
+ });
61
+ Object.defineProperty(exports, "Divider", {
62
+ enumerable: true,
63
+ get: function get() {
64
+ return _Divider.Divider;
65
+ }
66
+ });
67
+ Object.defineProperty(exports, "DropDown", {
68
+ enumerable: true,
69
+ get: function get() {
70
+ return _DropDown.DropDown;
71
+ }
72
+ });
73
+ Object.defineProperty(exports, "DropDownItem", {
74
+ enumerable: true,
75
+ get: function get() {
76
+ return _DropDown.DropDownItem;
77
+ }
78
+ });
79
+ Object.defineProperty(exports, "FloatingLinkEditorPlugin", {
80
+ enumerable: true,
81
+ get: function get() {
82
+ return _FloatingLinkEditorPlugin.FloatingLinkEditorPlugin;
83
+ }
84
+ });
85
+ Object.defineProperty(exports, "FontSizeAction", {
86
+ enumerable: true,
87
+ get: function get() {
88
+ return _FontSizeAction.FontSizeAction;
89
+ }
90
+ });
91
+ Object.defineProperty(exports, "HeadingEditor", {
92
+ enumerable: true,
93
+ get: function get() {
94
+ return _HeadingEditor.HeadingEditor;
95
+ }
96
+ });
97
+ Object.defineProperty(exports, "HeadingToolbar", {
98
+ enumerable: true,
99
+ get: function get() {
100
+ return _HeadingToolbar.HeadingToolbar;
101
+ }
102
+ });
103
+ Object.defineProperty(exports, "HeadingToolbarPreset", {
104
+ enumerable: true,
105
+ get: function get() {
106
+ return _HeadingToolbarPreset.HeadingToolbarPreset;
107
+ }
108
+ });
109
+ Object.defineProperty(exports, "ItalicAction", {
110
+ enumerable: true,
111
+ get: function get() {
112
+ return _ItalicAction.ItalicAction;
113
+ }
114
+ });
115
+ Object.defineProperty(exports, "LexicalHtmlRenderer", {
116
+ enumerable: true,
117
+ get: function get() {
118
+ return _LexicalHtmlRenderer.LexicalHtmlRenderer;
119
+ }
120
+ });
121
+ Object.defineProperty(exports, "LexicalUpdateStatePlugin", {
122
+ enumerable: true,
123
+ get: function get() {
124
+ return _LexicalUpdateStatePlugin.LexicalUpdateStatePlugin;
125
+ }
126
+ });
127
+ Object.defineProperty(exports, "LinkAction", {
128
+ enumerable: true,
129
+ get: function get() {
130
+ return _LinkAction.LinkAction;
131
+ }
132
+ });
133
+ Object.defineProperty(exports, "LinkPlugin", {
134
+ enumerable: true,
135
+ get: function get() {
136
+ return _LexicalLinkPlugin.LinkPlugin;
137
+ }
138
+ });
139
+ Object.defineProperty(exports, "NumberedListAction", {
140
+ enumerable: true,
141
+ get: function get() {
142
+ return _NumberedListAction.NumberedListAction;
143
+ }
144
+ });
145
+ Object.defineProperty(exports, "ParagraphEditor", {
146
+ enumerable: true,
147
+ get: function get() {
148
+ return _ParagraphEditor.ParagraphEditor;
149
+ }
150
+ });
151
+ Object.defineProperty(exports, "ParagraphToolbar", {
152
+ enumerable: true,
153
+ get: function get() {
154
+ return _ParagraphToolbar.ParagraphToolbar;
155
+ }
156
+ });
157
+ Object.defineProperty(exports, "ParagraphToolbarPreset", {
158
+ enumerable: true,
159
+ get: function get() {
160
+ return _ParagraphToolbarPreset.ParagraphToolbarPreset;
161
+ }
162
+ });
163
+ Object.defineProperty(exports, "QuoteAction", {
164
+ enumerable: true,
165
+ get: function get() {
166
+ return _QuoteAction.QuoteAction;
167
+ }
168
+ });
169
+ Object.defineProperty(exports, "RichTextEditor", {
170
+ enumerable: true,
171
+ get: function get() {
172
+ return _RichTextEditor.RichTextEditor;
173
+ }
174
+ });
175
+ Object.defineProperty(exports, "Toolbar", {
176
+ enumerable: true,
177
+ get: function get() {
178
+ return _Toolbar.Toolbar;
179
+ }
180
+ });
181
+ Object.defineProperty(exports, "UnderlineAction", {
182
+ enumerable: true,
183
+ get: function get() {
184
+ return _UnderlineAction.UnderlineAction;
185
+ }
186
+ });
187
+ Object.defineProperty(exports, "generateInitialLexicalValue", {
188
+ enumerable: true,
189
+ get: function get() {
190
+ return _generateInitialLexicalValue.generateInitialLexicalValue;
191
+ }
192
+ });
193
+ Object.defineProperty(exports, "isValidLexicalData", {
194
+ enumerable: true,
195
+ get: function get() {
196
+ return _isValidLexicalData.isValidLexicalData;
197
+ }
198
+ });
199
+ exports.types = void 0;
200
+ Object.defineProperty(exports, "useRichTextEditor", {
201
+ enumerable: true,
202
+ get: function get() {
203
+ return _useRichTextEditor.useRichTextEditor;
204
+ }
205
+ });
206
+ var _LexicalHtmlRenderer = require("./components/LexicalHtmlRenderer");
207
+ var _useRichTextEditor = require("./hooks/useRichTextEditor");
208
+ var _Divider = require("./ui/Divider");
209
+ var _DropDown = require("./ui/DropDown");
210
+ var _BoldAction = require("./components/ToolbarActions/BoldAction");
211
+ var _BulletListAction = require("./components/ToolbarActions/BulletListAction");
212
+ var _CodeHighlightAction = require("./components/ToolbarActions/CodeHighlightAction");
213
+ var _FontSizeAction = require("./components/ToolbarActions/FontSizeAction");
214
+ var _ItalicAction = require("./components/ToolbarActions/ItalicAction");
215
+ var _LinkAction = require("./components/ToolbarActions/LinkAction");
216
+ var _NumberedListAction = require("./components/ToolbarActions/NumberedListAction");
217
+ var _QuoteAction = require("./components/ToolbarActions/QuoteAction");
218
+ var _UnderlineAction = require("./components/ToolbarActions/UnderlineAction");
219
+ var _HeadingToolbar = require("./components/Toolbar/HeadingToolbar");
220
+ var _ParagraphToolbar = require("./components/Toolbar/ParagraphToolbar");
221
+ var _Toolbar = require("./components/Toolbar/Toolbar");
222
+ var _ParagraphToolbarPreset = require("./components/ToolbarPresets/ParagraphToolbarPreset");
223
+ var _HeadingToolbarPreset = require("./components/ToolbarPresets/HeadingToolbarPreset");
224
+ var _RichTextEditor = require("./components/Editor/RichTextEditor");
225
+ var _HeadingEditor = require("./components/Editor/HeadingEditor");
226
+ var _ParagraphEditor = require("./components/Editor/ParagraphEditor");
227
+ var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
228
+ var _FloatingLinkEditorPlugin = require("./plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin");
229
+ var _CodeHighlightPlugin = require("./plugins/CodeHighlightPlugin/CodeHighlightPlugin");
230
+ var _ClickableLinkPlugin = require("./plugins/ClickableLinkPlugin/ClickableLinkPlugin");
231
+ var _BlurEventPlugin = require("./plugins/BlurEventPlugin/BlurEventPlugin");
232
+ var _LexicalUpdateStatePlugin = require("./plugins/LexicalUpdateStatePlugin");
233
+ var _AddToolbarAction = require("./components/AddToolbarAction");
234
+ var _AddRichTextEditorPlugin = require("./components/AddRichTextEditorPlugin");
235
+ var _AddRichTextEditorNodeType = require("./components/AddRichTextEditorNodeType");
236
+ var _generateInitialLexicalValue = require("./utils/generateInitialLexicalValue");
237
+ var _isValidLexicalData = require("./utils/isValidLexicalData");
238
+ var _types = _interopRequireWildcard(require("./types"));
239
+ exports.types = _types;
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_LexicalHtmlRenderer","require","_useRichTextEditor","_Divider","_DropDown","_BoldAction","_BulletListAction","_CodeHighlightAction","_FontSizeAction","_ItalicAction","_LinkAction","_NumberedListAction","_QuoteAction","_UnderlineAction","_HeadingToolbar","_ParagraphToolbar","_Toolbar","_ParagraphToolbarPreset","_HeadingToolbarPreset","_RichTextEditor","_HeadingEditor","_ParagraphEditor","_LexicalLinkPlugin","_FloatingLinkEditorPlugin","_CodeHighlightPlugin","_ClickableLinkPlugin","_BlurEventPlugin","_LexicalUpdateStatePlugin","_AddToolbarAction","_AddRichTextEditorPlugin","_AddRichTextEditorNodeType","_generateInitialLexicalValue","_isValidLexicalData","_types","_interopRequireWildcard","exports","types"],"sources":["index.tsx"],"sourcesContent":["// render\nexport { LexicalHtmlRenderer } from \"~/components/LexicalHtmlRenderer\";\n// hooks\nexport { useRichTextEditor } from \"~/hooks/useRichTextEditor\";\n// UI elements\nexport { Divider } from \"~/ui/Divider\";\nexport { DropDownItem } from \"~/ui/DropDown\";\nexport { DropDown } from \"~/ui/DropDown\";\n// actions\nexport { BoldAction } from \"~/components/ToolbarActions/BoldAction\";\nexport { BulletListAction } from \"~/components/ToolbarActions/BulletListAction\";\nexport { CodeHighlightAction } from \"~/components/ToolbarActions/CodeHighlightAction\";\nexport { FontSizeAction } from \"~/components/ToolbarActions/FontSizeAction\";\nexport { ItalicAction } from \"~/components/ToolbarActions/ItalicAction\";\nexport { LinkAction } from \"~/components/ToolbarActions/LinkAction\";\nexport { NumberedListAction } from \"~/components/ToolbarActions/NumberedListAction\";\nexport { QuoteAction } from \"~/components/ToolbarActions/QuoteAction\";\nexport { UnderlineAction } from \"~/components/ToolbarActions/UnderlineAction\";\n// toolbars\nexport { HeadingToolbar } from \"~/components/Toolbar/HeadingToolbar\";\nexport { ParagraphToolbar } from \"~/components/Toolbar/ParagraphToolbar\";\nexport { Toolbar } from \"~/components/Toolbar/Toolbar\";\n// presets\nexport { ParagraphToolbarPreset } from \"~/components/ToolbarPresets/ParagraphToolbarPreset\";\nexport { HeadingToolbarPreset } from \"./components/ToolbarPresets/HeadingToolbarPreset\";\n// editor\nexport { RichTextEditor } from \"~/components/Editor/RichTextEditor\";\nexport { HeadingEditor } from \"~/components/Editor/HeadingEditor\";\nexport { ParagraphEditor } from \"~/components/Editor/ParagraphEditor\";\n// plugins\nexport { LinkPlugin } from \"@lexical/react/LexicalLinkPlugin\";\nexport { FloatingLinkEditorPlugin } from \"~/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin\";\nexport { CodeHighlightPlugin } from \"~/plugins/CodeHighlightPlugin/CodeHighlightPlugin\";\nexport { ClickableLinkPlugin } from \"~/plugins/ClickableLinkPlugin/ClickableLinkPlugin\";\nexport { BlurEventPlugin } from \"~/plugins/BlurEventPlugin/BlurEventPlugin\";\nexport { LexicalUpdateStatePlugin } from \"~/plugins/LexicalUpdateStatePlugin\";\n// composition\nexport { AddToolbarAction } from \"~/components/AddToolbarAction\";\nexport { AddRichTextEditorPlugin } from \"~/components/AddRichTextEditorPlugin\";\nexport { AddRichTextEditorNodeType } from \"~/components/AddRichTextEditorNodeType\";\n// utils\nexport { generateInitialLexicalValue } from \"~/utils/generateInitialLexicalValue\";\nexport { isValidLexicalData } from \"~/utils/isValidLexicalData\";\n// types\nexport * as types from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,IAAAA,oBAAA,GAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAGA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAN,OAAA;AACA,IAAAO,eAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,mBAAA,GAAAV,OAAA;AACA,IAAAW,YAAA,GAAAX,OAAA;AACA,IAAAY,gBAAA,GAAAZ,OAAA;AAEA,IAAAa,eAAA,GAAAb,OAAA;AACA,IAAAc,iBAAA,GAAAd,OAAA;AACA,IAAAe,QAAA,GAAAf,OAAA;AAEA,IAAAgB,uBAAA,GAAAhB,OAAA;AACA,IAAAiB,qBAAA,GAAAjB,OAAA;AAEA,IAAAkB,eAAA,GAAAlB,OAAA;AACA,IAAAmB,cAAA,GAAAnB,OAAA;AACA,IAAAoB,gBAAA,GAAApB,OAAA;AAEA,IAAAqB,kBAAA,GAAArB,OAAA;AACA,IAAAsB,yBAAA,GAAAtB,OAAA;AACA,IAAAuB,oBAAA,GAAAvB,OAAA;AACA,IAAAwB,oBAAA,GAAAxB,OAAA;AACA,IAAAyB,gBAAA,GAAAzB,OAAA;AACA,IAAA0B,yBAAA,GAAA1B,OAAA;AAEA,IAAA2B,iBAAA,GAAA3B,OAAA;AACA,IAAA4B,wBAAA,GAAA5B,OAAA;AACA,IAAA6B,0BAAA,GAAA7B,OAAA;AAEA,IAAA8B,4BAAA,GAAA9B,OAAA;AACA,IAAA+B,mBAAA,GAAA/B,OAAA;AAAgE,IAAAgC,MAAA,GAAAC,uBAAA,CAAAjC,OAAA;AAAAkC,OAAA,CAAAC,KAAA,GAAAH,MAAA"}
@@ -0,0 +1,2 @@
1
+ import type { Klass, LexicalNode } from "lexical";
2
+ export declare const WebinyNodes: Array<Klass<LexicalNode>>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.WebinyNodes = void 0;
7
+ var _code = require("@lexical/code");
8
+ var _hashtag = require("@lexical/hashtag");
9
+ var _link = require("@lexical/link");
10
+ var _list = require("@lexical/list");
11
+ var _mark = require("@lexical/mark");
12
+ var _overflow = require("@lexical/overflow");
13
+ var _richText = require("@lexical/rich-text");
14
+ var WebinyNodes = [_richText.HeadingNode, _list.ListNode, _list.ListItemNode, _richText.QuoteNode, _code.CodeNode, _hashtag.HashtagNode, _code.CodeHighlightNode, _link.AutoLinkNode, _link.LinkNode, _overflow.OverflowNode, _mark.MarkNode];
15
+ exports.WebinyNodes = WebinyNodes;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_code","require","_hashtag","_link","_list","_mark","_overflow","_richText","WebinyNodes","HeadingNode","ListNode","ListItemNode","QuoteNode","CodeNode","HashtagNode","CodeHighlightNode","AutoLinkNode","LinkNode","OverflowNode","MarkNode","exports"],"sources":["webinyNodes.ts"],"sourcesContent":["import type { Klass, LexicalNode } from \"lexical\";\n\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { AutoLinkNode, LinkNode } from \"@lexical/link\";\nimport { ListItemNode, ListNode } from \"@lexical/list\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { OverflowNode } from \"@lexical/overflow\";\nimport { HeadingNode, QuoteNode } from \"@lexical/rich-text\";\n\nexport const WebinyNodes: Array<Klass<LexicalNode>> = [\n HeadingNode,\n ListNode,\n ListItemNode,\n QuoteNode,\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n LinkNode,\n OverflowNode,\n MarkNode\n];\n"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAEO,IAAMO,WAAsC,GAAG,CAClDC,qBAAW,EACXC,cAAQ,EACRC,kBAAY,EACZC,mBAAS,EACTC,cAAQ,EACRC,oBAAW,EACXC,uBAAiB,EACjBC,kBAAY,EACZC,cAAQ,EACRC,sBAAY,EACZC,cAAQ,CACX;AAACC,OAAA,CAAAZ,WAAA,GAAAA,WAAA"}
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@webiny/lexical-editor",
3
+ "version": "0.0.0-unstable.d65ec29d44",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/webiny/webiny-js.git"
7
+ },
8
+ "license": "MIT",
9
+ "dependencies": {
10
+ "@lexical/code": "0.8.0",
11
+ "@lexical/hashtag": "0.8.0",
12
+ "@lexical/link": "0.8.1",
13
+ "@lexical/list": "0.8.0",
14
+ "@lexical/mark": "0.8.0",
15
+ "@lexical/overflow": "0.8.0",
16
+ "@lexical/react": "0.8.1",
17
+ "@lexical/rich-text": "0.8.0",
18
+ "@lexical/selection": "0.8.0",
19
+ "@lexical/utils": "0.8.0",
20
+ "@webiny/react-composition": "0.0.0-unstable.d65ec29d44",
21
+ "lexical": "0.8.1",
22
+ "react": "17.0.2",
23
+ "react-dom": "17.0.2"
24
+ },
25
+ "devDependencies": {
26
+ "@webiny/cli": "^5.33.1",
27
+ "@webiny/project-utils": "^5.33.1"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public",
31
+ "directory": "dist"
32
+ },
33
+ "scripts": {
34
+ "build": "yarn webiny run build",
35
+ "watch": "yarn webiny run watch"
36
+ },
37
+ "gitHead": "d65ec29d4408dff33cb4e30a943bf7d2dabceb4d"
38
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ /// <reference types="react" />
10
+ /// <reference types="web" />
11
+ export declare const LexicalAutoLinkPlugin: () => JSX.Element;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.LexicalAutoLinkPlugin = void 0;
8
+ var _LexicalAutoLinkPlugin = require("@lexical/react/LexicalAutoLinkPlugin");
9
+ var React = _interopRequireWildcard(require("react"));
10
+ /**
11
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ *
16
+ */
17
+
18
+ var URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
19
+ var EMAIL_MATCHER = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
20
+ var MATCHERS = [function (text) {
21
+ var match = URL_MATCHER.exec(text);
22
+ if (match === null) {
23
+ return null;
24
+ }
25
+ var fullMatch = match[0];
26
+ return {
27
+ index: match.index,
28
+ length: fullMatch.length,
29
+ text: fullMatch,
30
+ url: fullMatch.startsWith("http") ? fullMatch : "https://".concat(fullMatch)
31
+ };
32
+ }, function (text) {
33
+ var match = EMAIL_MATCHER.exec(text);
34
+ return match && {
35
+ index: match.index,
36
+ length: match[0].length,
37
+ text: match[0],
38
+ url: "mailto:".concat(match[0])
39
+ };
40
+ }];
41
+ var LexicalAutoLinkPlugin = function LexicalAutoLinkPlugin() {
42
+ return /*#__PURE__*/React.createElement(_LexicalAutoLinkPlugin.AutoLinkPlugin, {
43
+ matchers: MATCHERS
44
+ });
45
+ };
46
+ exports.LexicalAutoLinkPlugin = LexicalAutoLinkPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_LexicalAutoLinkPlugin","require","React","_interopRequireWildcard","URL_MATCHER","EMAIL_MATCHER","MATCHERS","text","match","exec","fullMatch","index","length","url","startsWith","concat","LexicalAutoLinkPlugin","createElement","AutoLinkPlugin","matchers","exports"],"sources":["AutoLinkPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport { AutoLinkPlugin } from \"@lexical/react/LexicalAutoLinkPlugin\";\nimport * as React from \"react\";\n\nconst URL_MATCHER =\n /((https?:\\/\\/(www\\.)?)|(www\\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;\n\nconst EMAIL_MATCHER =\n /(([^<>()[\\]\\\\.,;:\\s@\"]+(\\.[^<>()[\\]\\\\.,;:\\s@\"]+)*)|(\".+\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))/;\n\nconst MATCHERS = [\n (text: string) => {\n const match = URL_MATCHER.exec(text);\n if (match === null) {\n return null;\n }\n const fullMatch = match[0];\n return {\n index: match.index,\n length: fullMatch.length,\n text: fullMatch,\n url: fullMatch.startsWith(\"http\") ? fullMatch : `https://${fullMatch}`\n };\n },\n (text: string) => {\n const match = EMAIL_MATCHER.exec(text);\n return (\n match && {\n index: match.index,\n length: match[0].length,\n text: match[0],\n url: `mailto:${match[0]}`\n }\n );\n }\n];\n\nexport const LexicalAutoLinkPlugin = (): JSX.Element => {\n return <AutoLinkPlugin matchers={MATCHERS} />;\n};\n"],"mappings":";;;;;;;AAQA,IAAAA,sBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAC,uBAAA,CAAAF,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA,IAAMG,WAAW,GACb,iHAAiH;AAErH,IAAMC,aAAa,GACf,qJAAqJ;AAEzJ,IAAMC,QAAQ,GAAG,CACb,UAACC,IAAY,EAAK;EACd,IAAMC,KAAK,GAAGJ,WAAW,CAACK,IAAI,CAACF,IAAI,CAAC;EACpC,IAAIC,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,IAAI;EACf;EACA,IAAME,SAAS,GAAGF,KAAK,CAAC,CAAC,CAAC;EAC1B,OAAO;IACHG,KAAK,EAAEH,KAAK,CAACG,KAAK;IAClBC,MAAM,EAAEF,SAAS,CAACE,MAAM;IACxBL,IAAI,EAAEG,SAAS;IACfG,GAAG,EAAEH,SAAS,CAACI,UAAU,CAAC,MAAM,CAAC,GAAGJ,SAAS,cAAAK,MAAA,CAAcL,SAAS;EACxE,CAAC;AACL,CAAC,EACD,UAACH,IAAY,EAAK;EACd,IAAMC,KAAK,GAAGH,aAAa,CAACI,IAAI,CAACF,IAAI,CAAC;EACtC,OACIC,KAAK,IAAI;IACLG,KAAK,EAAEH,KAAK,CAACG,KAAK;IAClBC,MAAM,EAAEJ,KAAK,CAAC,CAAC,CAAC,CAACI,MAAM;IACvBL,IAAI,EAAEC,KAAK,CAAC,CAAC,CAAC;IACdK,GAAG,YAAAE,MAAA,CAAYP,KAAK,CAAC,CAAC,CAAC;EAC3B,CAAC;AAET,CAAC,CACJ;AAEM,IAAMQ,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAA,EAAsB;EACpD,oBAAOd,KAAA,CAAAe,aAAA,CAACjB,sBAAA,CAAAkB,cAAc;IAACC,QAAQ,EAAEb;EAAS,EAAG;AACjD,CAAC;AAACc,OAAA,CAAAJ,qBAAA,GAAAA,qBAAA"}
@@ -0,0 +1 @@
1
+ export * from "./AutoLinkPlugin";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _AutoLinkPlugin = require("./AutoLinkPlugin");
7
+ Object.keys(_AutoLinkPlugin).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _AutoLinkPlugin[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _AutoLinkPlugin[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_AutoLinkPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./AutoLinkPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,eAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,eAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,eAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,7 @@
1
+ import { FC } from "react";
2
+ import { LexicalValue } from "../../types";
3
+ interface BlurEventPlugin {
4
+ onBlur?: (editorState: LexicalValue) => void;
5
+ }
6
+ export declare const BlurEventPlugin: FC<BlurEventPlugin>;
7
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.BlurEventPlugin = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _react = require("react");
10
+ var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
11
+ var _lexical = require("lexical");
12
+ var BlurEventPlugin = function BlurEventPlugin(_ref) {
13
+ var onBlur = _ref.onBlur;
14
+ var _useLexicalComposerCo = (0, _LexicalComposerContext.useLexicalComposerContext)(),
15
+ _useLexicalComposerCo2 = (0, _slicedToArray2.default)(_useLexicalComposerCo, 1),
16
+ editor = _useLexicalComposerCo2[0];
17
+ (0, _react.useEffect)(function () {
18
+ return editor.registerCommand(_lexical.BLUR_COMMAND, function () {
19
+ if (typeof onBlur === "function") {
20
+ var _editorState = editor.getEditorState();
21
+ onBlur(JSON.stringify(_editorState.toJSON()));
22
+ }
23
+ return false;
24
+ }, _lexical.COMMAND_PRIORITY_LOW);
25
+ }, []);
26
+ return null;
27
+ };
28
+ exports.BlurEventPlugin = BlurEventPlugin;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_LexicalComposerContext","_lexical","BlurEventPlugin","_ref","onBlur","_useLexicalComposerCo","useLexicalComposerContext","_useLexicalComposerCo2","_slicedToArray2","default","editor","useEffect","registerCommand","BLUR_COMMAND","editorState","getEditorState","JSON","stringify","toJSON","COMMAND_PRIORITY_LOW","exports"],"sources":["BlurEventPlugin.tsx"],"sourcesContent":["import { FC, useEffect } from \"react\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW } from \"lexical\";\nimport { LexicalValue } from \"~/types\";\n\ninterface BlurEventPlugin {\n onBlur?: (editorState: LexicalValue) => void;\n}\n\nexport const BlurEventPlugin: FC<BlurEventPlugin> = ({ onBlur }) => {\n const [editor] = useLexicalComposerContext();\n\n useEffect(\n () =>\n editor.registerCommand(\n BLUR_COMMAND,\n () => {\n if (typeof onBlur === \"function\") {\n const editorState = editor.getEditorState();\n onBlur(JSON.stringify(editorState.toJSON()));\n }\n return false;\n },\n COMMAND_PRIORITY_LOW\n ),\n []\n );\n return null;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAOO,IAAMG,eAAoC,GAAG,SAAvCA,eAAoCA,CAAAC,IAAA,EAAmB;EAAA,IAAbC,MAAM,GAAAD,IAAA,CAANC,MAAM;EACzD,IAAAC,qBAAA,GAAiB,IAAAC,iDAAyB,GAAE;IAAAC,sBAAA,OAAAC,eAAA,CAAAC,OAAA,EAAAJ,qBAAA;IAArCK,MAAM,GAAAH,sBAAA;EAEb,IAAAI,gBAAS,EACL;IAAA,OACID,MAAM,CAACE,eAAe,CAClBC,qBAAY,EACZ,YAAM;MACF,IAAI,OAAOT,MAAM,KAAK,UAAU,EAAE;QAC9B,IAAMU,YAAW,GAAGJ,MAAM,CAACK,cAAc,EAAE;QAC3CX,MAAM,CAACY,IAAI,CAACC,SAAS,CAACH,YAAW,CAACI,MAAM,EAAE,CAAC,CAAC;MAChD;MACA,OAAO,KAAK;IAChB,CAAC,EACDC,6BAAoB,CACvB;EAAA,GACL,EAAE,CACL;EACD,OAAO,IAAI;AACf,CAAC;AAACC,OAAA,CAAAlB,eAAA,GAAAA,eAAA"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ /// <reference types="react" />
10
+ /// <reference types="web" />
11
+ import type { LinkNode } from "@lexical/link";
12
+ declare type LinkFilter = (event: MouseEvent, linkNode: LinkNode) => boolean;
13
+ export declare function ClickableLinkPlugin({ filter, newTab }: {
14
+ filter?: LinkFilter;
15
+ newTab?: boolean;
16
+ }): JSX.Element | null;
17
+ export {};
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ClickableLinkPlugin = ClickableLinkPlugin;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _link = require("@lexical/link");
10
+ var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
11
+ var _lexical = require("lexical");
12
+ var _react = require("react");
13
+ /**
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ *
19
+ */
20
+
21
+ function ClickableLinkPlugin(_ref) {
22
+ var filter = _ref.filter,
23
+ _ref$newTab = _ref.newTab,
24
+ newTab = _ref$newTab === void 0 ? true : _ref$newTab;
25
+ var _useLexicalComposerCo = (0, _LexicalComposerContext.useLexicalComposerContext)(),
26
+ _useLexicalComposerCo2 = (0, _slicedToArray2.default)(_useLexicalComposerCo, 1),
27
+ editor = _useLexicalComposerCo2[0];
28
+ (0, _react.useEffect)(function () {
29
+ function onClick(e) {
30
+ var event = e;
31
+ var linkDomNode = getLinkDomNode(event, editor);
32
+ if (linkDomNode === null) {
33
+ return;
34
+ }
35
+ var href = linkDomNode.getAttribute("href");
36
+ if (linkDomNode.getAttribute("contenteditable") === "false" || href === undefined) {
37
+ return;
38
+ }
39
+
40
+ // Allow user to select link text without following url
41
+ var selection = editor.getEditorState().read(_lexical.$getSelection);
42
+ if ((0, _lexical.$isRangeSelection)(selection) && !selection.isCollapsed()) {
43
+ return;
44
+ }
45
+ var linkNode = null;
46
+ editor.update(function () {
47
+ var maybeLinkNode = (0, _lexical.$getNearestNodeFromDOMNode)(linkDomNode);
48
+ if ((0, _link.$isLinkNode)(maybeLinkNode)) {
49
+ linkNode = maybeLinkNode;
50
+ }
51
+ });
52
+ if (linkNode === null || filter !== undefined && !filter(event, linkNode)) {
53
+ return;
54
+ }
55
+ try {
56
+ if (href !== null) {
57
+ window.open(href, newTab || event.metaKey || event.ctrlKey ? "_blank" : "_self");
58
+ }
59
+ } catch (_unused) {
60
+ // It didn't work, which is better than throwing an exception!
61
+ }
62
+ }
63
+ return editor.registerRootListener(function (rootElement, prevRootElement) {
64
+ if (prevRootElement !== null) {
65
+ prevRootElement.removeEventListener("click", onClick);
66
+ }
67
+ if (rootElement !== null) {
68
+ rootElement.addEventListener("click", onClick);
69
+ }
70
+ });
71
+ }, [editor, filter, newTab]);
72
+ return null;
73
+ }
74
+ function isLinkDomNode(domNode) {
75
+ return domNode.nodeName.toLowerCase() === "a";
76
+ }
77
+ function getLinkDomNode(event, editor) {
78
+ return editor.getEditorState().read(function () {
79
+ var domNode = event.target;
80
+ if (isLinkDomNode(domNode)) {
81
+ return domNode;
82
+ }
83
+ if (domNode.parentNode && isLinkDomNode(domNode.parentNode)) {
84
+ return domNode.parentNode;
85
+ }
86
+ return null;
87
+ });
88
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_link","require","_LexicalComposerContext","_lexical","_react","ClickableLinkPlugin","_ref","filter","_ref$newTab","newTab","_useLexicalComposerCo","useLexicalComposerContext","_useLexicalComposerCo2","_slicedToArray2","default","editor","useEffect","onClick","e","event","linkDomNode","getLinkDomNode","href","getAttribute","undefined","selection","getEditorState","read","$getSelection","$isRangeSelection","isCollapsed","linkNode","update","maybeLinkNode","$getNearestNodeFromDOMNode","$isLinkNode","window","open","metaKey","ctrlKey","_unused","registerRootListener","rootElement","prevRootElement","removeEventListener","addEventListener","isLinkDomNode","domNode","nodeName","toLowerCase","target","parentNode"],"sources":["ClickableLinkPlugin.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { LinkNode } from \"@lexical/link\";\nimport type { LexicalEditor } from \"lexical\";\n\nimport { $isLinkNode } from \"@lexical/link\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\nimport { $getNearestNodeFromDOMNode, $getSelection, $isRangeSelection } from \"lexical\";\nimport { useEffect } from \"react\";\n\ntype LinkFilter = (event: MouseEvent, linkNode: LinkNode) => boolean;\n\nexport function ClickableLinkPlugin({\n filter,\n newTab = true\n}: {\n filter?: LinkFilter;\n newTab?: boolean;\n}): JSX.Element | null {\n const [editor] = useLexicalComposerContext();\n useEffect(() => {\n function onClick(e: Event) {\n const event = e as MouseEvent;\n const linkDomNode = getLinkDomNode(event, editor);\n\n if (linkDomNode === null) {\n return;\n }\n\n const href = linkDomNode.getAttribute(\"href\");\n\n if (linkDomNode.getAttribute(\"contenteditable\") === \"false\" || href === undefined) {\n return;\n }\n\n // Allow user to select link text without following url\n const selection = editor.getEditorState().read($getSelection);\n if ($isRangeSelection(selection) && !selection.isCollapsed()) {\n return;\n }\n\n let linkNode = null;\n editor.update(() => {\n const maybeLinkNode = $getNearestNodeFromDOMNode(linkDomNode);\n\n if ($isLinkNode(maybeLinkNode)) {\n linkNode = maybeLinkNode;\n }\n });\n\n if (linkNode === null || (filter !== undefined && !filter(event, linkNode))) {\n return;\n }\n\n try {\n if (href !== null) {\n window.open(\n href,\n newTab || event.metaKey || event.ctrlKey ? \"_blank\" : \"_self\"\n );\n }\n } catch {\n // It didn't work, which is better than throwing an exception!\n }\n }\n\n return editor.registerRootListener(\n (rootElement: null | HTMLElement, prevRootElement: null | HTMLElement) => {\n if (prevRootElement !== null) {\n prevRootElement.removeEventListener(\"click\", onClick);\n }\n\n if (rootElement !== null) {\n rootElement.addEventListener(\"click\", onClick);\n }\n }\n );\n }, [editor, filter, newTab]);\n return null;\n}\n\nfunction isLinkDomNode(domNode: Node): boolean {\n return domNode.nodeName.toLowerCase() === \"a\";\n}\n\nfunction getLinkDomNode(event: MouseEvent, editor: LexicalEditor): HTMLAnchorElement | null {\n return editor.getEditorState().read(() => {\n const domNode = event.target as Node;\n\n if (isLinkDomNode(domNode)) {\n return domNode as HTMLAnchorElement;\n }\n\n if (domNode.parentNode && isLinkDomNode(domNode.parentNode)) {\n return domNode.parentNode as HTMLAnchorElement;\n }\n\n return null;\n });\n}\n"],"mappings":"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"}
@@ -0,0 +1 @@
1
+ export * from "./ClickableLinkPlugin";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _ClickableLinkPlugin = require("./ClickableLinkPlugin");
7
+ Object.keys(_ClickableLinkPlugin).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _ClickableLinkPlugin[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _ClickableLinkPlugin[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_ClickableLinkPlugin","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export * from \"./ClickableLinkPlugin\";\n"],"mappings":";;;;;AAAA,IAAAA,oBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,oBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,oBAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,oBAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1 @@
1
+ export declare function CodeHighlightPlugin(): null;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.CodeHighlightPlugin = CodeHighlightPlugin;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _react = require("react");
10
+ var _code = require("@lexical/code");
11
+ var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
12
+ function CodeHighlightPlugin() {
13
+ var _useLexicalComposerCo = (0, _LexicalComposerContext.useLexicalComposerContext)(),
14
+ _useLexicalComposerCo2 = (0, _slicedToArray2.default)(_useLexicalComposerCo, 1),
15
+ editor = _useLexicalComposerCo2[0];
16
+ (0, _react.useEffect)(function () {
17
+ return (0, _code.registerCodeHighlighting)(editor);
18
+ }, [editor]);
19
+ return null;
20
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_code","_LexicalComposerContext","CodeHighlightPlugin","_useLexicalComposerCo","useLexicalComposerContext","_useLexicalComposerCo2","_slicedToArray2","default","editor","useEffect","registerCodeHighlighting"],"sources":["CodeHighlightPlugin.tsx"],"sourcesContent":["import { useEffect } from \"react\";\nimport { registerCodeHighlighting } from \"@lexical/code\";\nimport { useLexicalComposerContext } from \"@lexical/react/LexicalComposerContext\";\n\nexport function CodeHighlightPlugin() {\n const [editor] = useLexicalComposerContext();\n useEffect(() => {\n return registerCodeHighlighting(editor);\n }, [editor]);\n return null;\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,uBAAA,GAAAF,OAAA;AAEO,SAASG,mBAAmBA,CAAA,EAAG;EAClC,IAAAC,qBAAA,GAAiB,IAAAC,iDAAyB,GAAE;IAAAC,sBAAA,OAAAC,eAAA,CAAAC,OAAA,EAAAJ,qBAAA;IAArCK,MAAM,GAAAH,sBAAA;EACb,IAAAI,gBAAS,EAAC,YAAM;IACZ,OAAO,IAAAC,8BAAwB,EAACF,MAAM,CAAC;EAC3C,CAAC,EAAE,CAACA,MAAM,CAAC,CAAC;EACZ,OAAO,IAAI;AACf"}
@@ -0,0 +1 @@
1
+ export * from "./CodeHighlightPlugin";
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _CodeHighlightPlugin = require("./CodeHighlightPlugin");
7
+ Object.keys(_CodeHighlightPlugin).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _CodeHighlightPlugin[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _CodeHighlightPlugin[key];
14
+ }
15
+ });
16
+ });