@webiny/lexical-editor 0.0.0-unstable.06b2ede40f

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 (308) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +17 -0
  3. package/commands/image.d.ts +6 -0
  4. package/commands/image.js +4 -0
  5. package/commands/image.js.map +1 -0
  6. package/commands/index.d.ts +5 -0
  7. package/commands/index.js +7 -0
  8. package/commands/index.js.map +1 -0
  9. package/commands/list.d.ts +7 -0
  10. package/commands/list.js +6 -0
  11. package/commands/list.js.map +1 -0
  12. package/commands/quote.d.ts +5 -0
  13. package/commands/quote.js +4 -0
  14. package/commands/quote.js.map +1 -0
  15. package/commands/toolbar.d.ts +1 -0
  16. package/commands/toolbar.js +4 -0
  17. package/commands/toolbar.js.map +1 -0
  18. package/commands/typography.d.ts +8 -0
  19. package/commands/typography.js +4 -0
  20. package/commands/typography.js.map +1 -0
  21. package/components/Editor/EnsureHeadingTagPlugin.d.ts +6 -0
  22. package/components/Editor/EnsureHeadingTagPlugin.js +20 -0
  23. package/components/Editor/EnsureHeadingTagPlugin.js.map +1 -0
  24. package/components/Editor/HeadingEditor.d.ts +7 -0
  25. package/components/Editor/HeadingEditor.js +22 -0
  26. package/components/Editor/HeadingEditor.js.map +1 -0
  27. package/components/Editor/ParagraphEditor.d.ts +7 -0
  28. package/components/Editor/ParagraphEditor.js +22 -0
  29. package/components/Editor/ParagraphEditor.js.map +1 -0
  30. package/components/Editor/RichTextEditor.d.ts +49 -0
  31. package/components/Editor/RichTextEditor.js +133 -0
  32. package/components/Editor/RichTextEditor.js.map +1 -0
  33. package/components/Editor/normalizeInputValue.d.ts +6 -0
  34. package/components/Editor/normalizeInputValue.js +16 -0
  35. package/components/Editor/normalizeInputValue.js.map +1 -0
  36. package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +20 -0
  37. package/components/LexicalEditorConfig/LexicalEditorConfig.js +63 -0
  38. package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
  39. package/components/LexicalEditorConfig/components/Node.d.ts +14 -0
  40. package/components/LexicalEditorConfig/components/Node.js +30 -0
  41. package/components/LexicalEditorConfig/components/Node.js.map +1 -0
  42. package/components/LexicalEditorConfig/components/Plugin.d.ts +13 -0
  43. package/components/LexicalEditorConfig/components/Plugin.js +30 -0
  44. package/components/LexicalEditorConfig/components/Plugin.js.map +1 -0
  45. package/components/LexicalEditorConfig/components/ToolbarElement.d.ts +13 -0
  46. package/components/LexicalEditorConfig/components/ToolbarElement.js +30 -0
  47. package/components/LexicalEditorConfig/components/ToolbarElement.js.map +1 -0
  48. package/components/LexicalHtmlRenderer.d.ts +14 -0
  49. package/components/LexicalHtmlRenderer.js +55 -0
  50. package/components/LexicalHtmlRenderer.js.map +1 -0
  51. package/components/Toolbar/StaticToolbar.css +260 -0
  52. package/components/Toolbar/StaticToolbar.d.ts +5 -0
  53. package/components/Toolbar/StaticToolbar.js +22 -0
  54. package/components/Toolbar/StaticToolbar.js.map +1 -0
  55. package/components/Toolbar/Toolbar.css +643 -0
  56. package/components/Toolbar/Toolbar.d.ts +6 -0
  57. package/components/Toolbar/Toolbar.js +148 -0
  58. package/components/Toolbar/Toolbar.js.map +1 -0
  59. package/components/ToolbarActions/BoldAction.d.ts +2 -0
  60. package/components/ToolbarActions/BoldAction.js +25 -0
  61. package/components/ToolbarActions/BoldAction.js.map +1 -0
  62. package/components/ToolbarActions/BulletListAction.d.ts +2 -0
  63. package/components/ToolbarActions/BulletListAction.js +40 -0
  64. package/components/ToolbarActions/BulletListAction.js.map +1 -0
  65. package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
  66. package/components/ToolbarActions/CodeHighlightAction.js +25 -0
  67. package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
  68. package/components/ToolbarActions/FontColorAction.d.ts +29 -0
  69. package/components/ToolbarActions/FontColorAction.js +50 -0
  70. package/components/ToolbarActions/FontColorAction.js.map +1 -0
  71. package/components/ToolbarActions/FontSizeAction.d.ts +14 -0
  72. package/components/ToolbarActions/FontSizeAction.js +91 -0
  73. package/components/ToolbarActions/FontSizeAction.js.map +1 -0
  74. package/components/ToolbarActions/ImageAction.d.ts +2 -0
  75. package/components/ToolbarActions/ImageAction.js +37 -0
  76. package/components/ToolbarActions/ImageAction.js.map +1 -0
  77. package/components/ToolbarActions/ItalicAction.d.ts +2 -0
  78. package/components/ToolbarActions/ItalicAction.js +25 -0
  79. package/components/ToolbarActions/ItalicAction.js.map +1 -0
  80. package/components/ToolbarActions/LinkAction.d.ts +2 -0
  81. package/components/ToolbarActions/LinkAction.js +37 -0
  82. package/components/ToolbarActions/LinkAction.js.map +1 -0
  83. package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
  84. package/components/ToolbarActions/NumberedListAction.js +48 -0
  85. package/components/ToolbarActions/NumberedListAction.js.map +1 -0
  86. package/components/ToolbarActions/QuoteAction.d.ts +2 -0
  87. package/components/ToolbarActions/QuoteAction.js +33 -0
  88. package/components/ToolbarActions/QuoteAction.js.map +1 -0
  89. package/components/ToolbarActions/TextAlignmentAction.d.ts +29 -0
  90. package/components/ToolbarActions/TextAlignmentAction.js +61 -0
  91. package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
  92. package/components/ToolbarActions/TypographyAction.d.ts +29 -0
  93. package/components/ToolbarActions/TypographyAction.js +108 -0
  94. package/components/ToolbarActions/TypographyAction.js.map +1 -0
  95. package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
  96. package/components/ToolbarActions/UnderlineAction.js +24 -0
  97. package/components/ToolbarActions/UnderlineAction.js.map +1 -0
  98. package/context/FontColorActionContext.d.ts +6 -0
  99. package/context/FontColorActionContext.js +4 -0
  100. package/context/FontColorActionContext.js.map +1 -0
  101. package/context/RichTextEditorContext.d.ts +19 -0
  102. package/context/RichTextEditorContext.js +21 -0
  103. package/context/RichTextEditorContext.js.map +1 -0
  104. package/context/SharedHistoryContext.d.ts +10 -0
  105. package/context/SharedHistoryContext.js +19 -0
  106. package/context/SharedHistoryContext.js.map +1 -0
  107. package/context/TextAlignmentActionContextProps.d.ts +9 -0
  108. package/context/TextAlignmentActionContextProps.js +4 -0
  109. package/context/TextAlignmentActionContextProps.js.map +1 -0
  110. package/context/TypographyActionContext.d.ts +8 -0
  111. package/context/TypographyActionContext.js +4 -0
  112. package/context/TypographyActionContext.js.map +1 -0
  113. package/hooks/index.d.ts +8 -0
  114. package/hooks/index.js +10 -0
  115. package/hooks/index.js.map +1 -0
  116. package/hooks/useCurrentElement.d.ts +7 -0
  117. package/hooks/useCurrentElement.js +27 -0
  118. package/hooks/useCurrentElement.js.map +1 -0
  119. package/hooks/useCurrentSelection.d.ts +13 -0
  120. package/hooks/useCurrentSelection.js +57 -0
  121. package/hooks/useCurrentSelection.js.map +1 -0
  122. package/hooks/useFontColorPicker.d.ts +2 -0
  123. package/hooks/useFontColorPicker.js +11 -0
  124. package/hooks/useFontColorPicker.js.map +1 -0
  125. package/hooks/useIsMounted.d.ts +1 -0
  126. package/hooks/useIsMounted.js +12 -0
  127. package/hooks/useIsMounted.js.map +1 -0
  128. package/hooks/useList.d.ts +2 -0
  129. package/hooks/useList.js +50 -0
  130. package/hooks/useList.js.map +1 -0
  131. package/hooks/useQuote.d.ts +2 -0
  132. package/hooks/useQuote.js +17 -0
  133. package/hooks/useQuote.js.map +1 -0
  134. package/hooks/useRichTextEditor.d.ts +2 -0
  135. package/hooks/useRichTextEditor.js +11 -0
  136. package/hooks/useRichTextEditor.js.map +1 -0
  137. package/hooks/useTextAlignmentAction.d.ts +1 -0
  138. package/hooks/useTextAlignmentAction.js +11 -0
  139. package/hooks/useTextAlignmentAction.js.map +1 -0
  140. package/hooks/useTypographyAction.d.ts +1 -0
  141. package/hooks/useTypographyAction.js +11 -0
  142. package/hooks/useTypographyAction.js.map +1 -0
  143. package/images/icons/LICENSE.md +5 -0
  144. package/images/icons/chat-square-quote.svg +1 -0
  145. package/images/icons/chevron-down.svg +1 -0
  146. package/images/icons/code.svg +1 -0
  147. package/images/icons/font-color.svg +1 -0
  148. package/images/icons/indent.svg +3 -0
  149. package/images/icons/insert-image.svg +4 -0
  150. package/images/icons/justify.svg +3 -0
  151. package/images/icons/link.svg +1 -0
  152. package/images/icons/list-ol.svg +1 -0
  153. package/images/icons/list-ul.svg +1 -0
  154. package/images/icons/outdent.svg +3 -0
  155. package/images/icons/pencil-fill.svg +1 -0
  156. package/images/icons/text-center.svg +1 -0
  157. package/images/icons/text-left.svg +1 -0
  158. package/images/icons/text-paragraph.svg +1 -0
  159. package/images/icons/text-right.svg +1 -0
  160. package/images/icons/type-bold.svg +1 -0
  161. package/images/icons/type-h1.svg +1 -0
  162. package/images/icons/type-h2.svg +1 -0
  163. package/images/icons/type-h3.svg +1 -0
  164. package/images/icons/type-h4.svg +1 -0
  165. package/images/icons/type-h5.svg +1 -0
  166. package/images/icons/type-h6.svg +1 -0
  167. package/images/icons/type-italic.svg +1 -0
  168. package/images/icons/type-strikethrough.svg +1 -0
  169. package/images/icons/type-underline.svg +1 -0
  170. package/images/icons/unlink_icon.svg +1 -0
  171. package/index.d.ts +37 -0
  172. package/index.js +50 -0
  173. package/index.js.map +1 -0
  174. package/package.json +40 -0
  175. package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
  176. package/plugins/BlurEventPlugin/BlurEventPlugin.js +20 -0
  177. package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
  178. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
  179. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +14 -0
  180. package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
  181. package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
  182. package/plugins/CodeHighlightPlugin/index.js +3 -0
  183. package/plugins/CodeHighlightPlugin/index.js.map +1 -0
  184. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.d.ts +16 -0
  185. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js +158 -0
  186. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditor.js.map +1 -0
  187. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.d.ts +8 -0
  188. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js +62 -0
  189. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorController.js.map +1 -0
  190. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +176 -0
  191. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
  192. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +14 -0
  193. package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
  194. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.d.ts +8 -0
  195. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js +104 -0
  196. package/plugins/FloatingLinkEditorPlugin/LinkEditForm.js.map +1 -0
  197. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.d.ts +9 -0
  198. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js +34 -0
  199. package/plugins/FloatingLinkEditorPlugin/LinkPreviewForm.js.map +1 -0
  200. package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
  201. package/plugins/FloatingLinkEditorPlugin/index.js +3 -0
  202. package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
  203. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.d.ts +1 -0
  204. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js +12 -0
  205. package/plugins/FloatingLinkEditorPlugin/isChildOfLinkEditor.js.map +1 -0
  206. package/plugins/FontColorPlugin/FontColorPlugin.d.ts +1 -0
  207. package/plugins/FontColorPlugin/FontColorPlugin.js +27 -0
  208. package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
  209. package/plugins/FontColorPlugin/applyColorToNode.d.ts +3 -0
  210. package/plugins/FontColorPlugin/applyColorToNode.js +8 -0
  211. package/plugins/FontColorPlugin/applyColorToNode.js.map +1 -0
  212. package/plugins/FontColorPlugin/applyColorToSelection.d.ts +3 -0
  213. package/plugins/FontColorPlugin/applyColorToSelection.js +66 -0
  214. package/plugins/FontColorPlugin/applyColorToSelection.js.map +1 -0
  215. package/plugins/ImagesPlugin/ImagesPlugin.d.ts +12 -0
  216. package/plugins/ImagesPlugin/ImagesPlugin.js +151 -0
  217. package/plugins/ImagesPlugin/ImagesPlugin.js.map +1 -0
  218. package/plugins/LinkPlugin/LinkPlugin.d.ts +5 -0
  219. package/plugins/LinkPlugin/LinkPlugin.js +59 -0
  220. package/plugins/LinkPlugin/LinkPlugin.js.map +1 -0
  221. package/plugins/ListPLugin/ListPlugin.d.ts +1 -0
  222. package/plugins/ListPLugin/ListPlugin.js +17 -0
  223. package/plugins/ListPLugin/ListPlugin.js.map +1 -0
  224. package/plugins/QuoteNodePlugin/QuoteNodePlugin.d.ts +1 -0
  225. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js +18 -0
  226. package/plugins/QuoteNodePlugin/QuoteNodePlugin.js.map +1 -0
  227. package/plugins/StateHandlingPlugin.d.ts +8 -0
  228. package/plugins/StateHandlingPlugin.js +75 -0
  229. package/plugins/StateHandlingPlugin.js.map +1 -0
  230. package/plugins/TypographyPlugin/TypographyPlugin.d.ts +1 -0
  231. package/plugins/TypographyPlugin/TypographyPlugin.js +27 -0
  232. package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
  233. package/types.d.ts +12 -0
  234. package/types.js +9 -0
  235. package/types.js.map +1 -0
  236. package/ui/ContentEditable.css +22 -0
  237. package/ui/ContentEditable.d.ts +12 -0
  238. package/ui/ContentEditable.js +19 -0
  239. package/ui/ContentEditable.js.map +1 -0
  240. package/ui/Divider.d.ts +2 -0
  241. package/ui/Divider.js +8 -0
  242. package/ui/Divider.js.map +1 -0
  243. package/ui/DropDown.d.ts +25 -0
  244. package/ui/DropDown.js +182 -0
  245. package/ui/DropDown.js.map +1 -0
  246. package/ui/ImageResizer.d.ts +24 -0
  247. package/ui/ImageResizer.js +211 -0
  248. package/ui/ImageResizer.js.map +1 -0
  249. package/ui/Input.css +32 -0
  250. package/ui/LinkPreview.css +69 -0
  251. package/ui/LinkPreview.d.ts +12 -0
  252. package/ui/LinkPreview.js +97 -0
  253. package/ui/LinkPreview.js.map +1 -0
  254. package/ui/Placeholder.css +20 -0
  255. package/ui/Placeholder.d.ts +15 -0
  256. package/ui/Placeholder.js +24 -0
  257. package/ui/Placeholder.js.map +1 -0
  258. package/ui/TextInput.d.ts +18 -0
  259. package/ui/TextInput.js +34 -0
  260. package/ui/TextInput.js.map +1 -0
  261. package/ui/ToolbarActionDialog.d.ts +11 -0
  262. package/ui/ToolbarActionDialog.js +77 -0
  263. package/ui/ToolbarActionDialog.js.map +1 -0
  264. package/utils/canUseDOM.d.ts +1 -0
  265. package/utils/canUseDOM.js +3 -0
  266. package/utils/canUseDOM.js.map +1 -0
  267. package/utils/files.d.ts +11 -0
  268. package/utils/files.js +21 -0
  269. package/utils/files.js.map +1 -0
  270. package/utils/getDOMRangeRect.d.ts +8 -0
  271. package/utils/getDOMRangeRect.js +23 -0
  272. package/utils/getDOMRangeRect.js.map +1 -0
  273. package/utils/getSelectedNode.d.ts +2 -0
  274. package/utils/getSelectedNode.js +25 -0
  275. package/utils/getSelectedNode.js.map +1 -0
  276. package/utils/getTransparentImage.d.ts +1 -0
  277. package/utils/getTransparentImage.js +5 -0
  278. package/utils/getTransparentImage.js.map +1 -0
  279. package/utils/insertImage.d.ts +2 -0
  280. package/utils/insertImage.js +16 -0
  281. package/utils/insertImage.js.map +1 -0
  282. package/utils/isAnchorLink.d.ts +1 -0
  283. package/utils/isAnchorLink.js +5 -0
  284. package/utils/isAnchorLink.js.map +1 -0
  285. package/utils/isChildOfFloatingToolbar.d.ts +1 -0
  286. package/utils/isChildOfFloatingToolbar.js +12 -0
  287. package/utils/isChildOfFloatingToolbar.js.map +1 -0
  288. package/utils/isHTMLElement.d.ts +8 -0
  289. package/utils/isHTMLElement.js +12 -0
  290. package/utils/isHTMLElement.js.map +1 -0
  291. package/utils/isValidJSON.d.ts +1 -0
  292. package/utils/isValidJSON.js +13 -0
  293. package/utils/isValidJSON.js.map +1 -0
  294. package/utils/isValidLexicalData.d.ts +4 -0
  295. package/utils/isValidLexicalData.js +24 -0
  296. package/utils/isValidLexicalData.js.map +1 -0
  297. package/utils/point.d.ts +21 -0
  298. package/utils/point.js +49 -0
  299. package/utils/point.js.map +1 -0
  300. package/utils/rect.d.ts +45 -0
  301. package/utils/rect.js +130 -0
  302. package/utils/rect.js.map +1 -0
  303. package/utils/sanitizeUrl.d.ts +1 -0
  304. package/utils/sanitizeUrl.js +25 -0
  305. package/utils/sanitizeUrl.js.map +1 -0
  306. package/utils/setFloatingElemPosition.d.ts +1 -0
  307. package/utils/setFloatingElemPosition.js +30 -0
  308. package/utils/setFloatingElemPosition.js.map +1 -0
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import * as React from "react";
10
+ import { useRef } from "react";
11
+ function clamp(value, min, max) {
12
+ return Math.min(Math.max(value, min), max);
13
+ }
14
+ const Direction = {
15
+ east: 1 << 0,
16
+ north: 1 << 3,
17
+ south: 1 << 1,
18
+ west: 1 << 2
19
+ };
20
+ export function ImageResizer({
21
+ onResizeStart,
22
+ onResizeEnd,
23
+ buttonRef,
24
+ imageRef,
25
+ maxWidth,
26
+ editor,
27
+ showCaption,
28
+ setShowCaption,
29
+ captionsEnabled
30
+ }) {
31
+ const controlWrapperRef = useRef(null);
32
+ const userSelect = useRef({
33
+ priority: "",
34
+ value: "default"
35
+ });
36
+ const positioningRef = useRef({
37
+ currentHeight: 0,
38
+ currentWidth: 0,
39
+ direction: 0,
40
+ isResizing: false,
41
+ ratio: 0,
42
+ startHeight: 0,
43
+ startWidth: 0,
44
+ startX: 0,
45
+ startY: 0
46
+ });
47
+ const editorRootElement = editor.getRootElement();
48
+ // Find max width, accounting for editor padding.
49
+ const maxWidthContainer = maxWidth ? maxWidth : editorRootElement !== null ? editorRootElement.getBoundingClientRect().width - 20 : 100;
50
+ const maxHeightContainer = editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;
51
+ const minWidth = 100;
52
+ const minHeight = 100;
53
+ const setStartCursor = direction => {
54
+ const ew = direction === Direction.east || direction === Direction.west;
55
+ const ns = direction === Direction.north || direction === Direction.south;
56
+ const nwse = direction & Direction.north && direction & Direction.west || direction & Direction.south && direction & Direction.east;
57
+ const cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
58
+ if (editorRootElement !== null) {
59
+ editorRootElement.style.setProperty("cursor", `${cursorDir}-resize`, "important");
60
+ }
61
+ if (document.body !== null) {
62
+ document.body.style.setProperty("cursor", `${cursorDir}-resize`, "important");
63
+ userSelect.current.value = document.body.style.getPropertyValue("-webkit-user-select");
64
+ userSelect.current.priority = document.body.style.getPropertyPriority("-webkit-user-select");
65
+ document.body.style.setProperty("-webkit-user-select", `none`, "important");
66
+ }
67
+ };
68
+ const setEndCursor = () => {
69
+ if (editorRootElement !== null) {
70
+ editorRootElement.style.setProperty("cursor", "text");
71
+ }
72
+ if (document.body !== null) {
73
+ document.body.style.setProperty("cursor", "default");
74
+ document.body.style.setProperty("-webkit-user-select", userSelect.current.value, userSelect.current.priority);
75
+ }
76
+ };
77
+ const handlePointerDown = (event, direction) => {
78
+ if (!editor.isEditable()) {
79
+ return;
80
+ }
81
+ const image = imageRef.current;
82
+ const controlWrapper = controlWrapperRef.current;
83
+ if (image !== null && controlWrapper !== null) {
84
+ const {
85
+ width,
86
+ height
87
+ } = image.getBoundingClientRect();
88
+ const positioning = positioningRef.current;
89
+ positioning.startWidth = width;
90
+ positioning.startHeight = height;
91
+ positioning.ratio = width / height;
92
+ positioning.currentWidth = width;
93
+ positioning.currentHeight = height;
94
+ positioning.startX = event.clientX;
95
+ positioning.startY = event.clientY;
96
+ positioning.isResizing = true;
97
+ positioning.direction = direction;
98
+ setStartCursor(direction);
99
+ onResizeStart();
100
+ controlWrapper.classList.add("image-control-wrapper--resizing");
101
+ image.style.height = `${height}px`;
102
+ image.style.width = `${width}px`;
103
+ document.addEventListener("pointermove", handlePointerMove);
104
+ document.addEventListener("pointerup", handlePointerUp);
105
+ }
106
+ };
107
+ const handlePointerMove = event => {
108
+ const image = imageRef.current;
109
+ const positioning = positioningRef.current;
110
+ const isHorizontal = positioning.direction & (Direction.east | Direction.west);
111
+ const isVertical = positioning.direction & (Direction.south | Direction.north);
112
+ if (image !== null && positioning.isResizing) {
113
+ // Corner cursor
114
+ if (isHorizontal && isVertical) {
115
+ let diff = Math.floor(positioning.startX - event.clientX);
116
+ diff = positioning.direction & Direction.east ? -diff : diff;
117
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
118
+ const height = width / positioning.ratio;
119
+ image.style.width = `${width}px`;
120
+ image.style.height = `${height}px`;
121
+ positioning.currentHeight = height;
122
+ positioning.currentWidth = width;
123
+ } else if (isVertical) {
124
+ let diff = Math.floor(positioning.startY - event.clientY);
125
+ diff = positioning.direction & Direction.south ? -diff : diff;
126
+ const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);
127
+ image.style.height = `${height}px`;
128
+ positioning.currentHeight = height;
129
+ } else {
130
+ let diff = Math.floor(positioning.startX - event.clientX);
131
+ diff = positioning.direction & Direction.east ? -diff : diff;
132
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
133
+ image.style.width = `${width}px`;
134
+ positioning.currentWidth = width;
135
+ }
136
+ }
137
+ };
138
+ const handlePointerUp = () => {
139
+ const image = imageRef.current;
140
+ const positioning = positioningRef.current;
141
+ const controlWrapper = controlWrapperRef.current;
142
+ if (image !== null && controlWrapper !== null && positioning.isResizing) {
143
+ const width = positioning.currentWidth;
144
+ const height = positioning.currentHeight;
145
+ positioning.startWidth = 0;
146
+ positioning.startHeight = 0;
147
+ positioning.ratio = 0;
148
+ positioning.startX = 0;
149
+ positioning.startY = 0;
150
+ positioning.currentWidth = 0;
151
+ positioning.currentHeight = 0;
152
+ positioning.isResizing = false;
153
+ controlWrapper.classList.remove("image-control-wrapper--resizing");
154
+ setEndCursor();
155
+ onResizeEnd(width, height);
156
+ document.removeEventListener("pointermove", handlePointerMove);
157
+ document.removeEventListener("pointerup", handlePointerUp);
158
+ }
159
+ };
160
+ return /*#__PURE__*/React.createElement("div", {
161
+ ref: controlWrapperRef
162
+ }, !showCaption && captionsEnabled && /*#__PURE__*/React.createElement("button", {
163
+ className: "image-caption-button",
164
+ ref: buttonRef,
165
+ onClick: () => {
166
+ setShowCaption(!showCaption);
167
+ }
168
+ }, "Add Caption"), /*#__PURE__*/React.createElement("div", {
169
+ className: "image-resizer image-resizer-n",
170
+ onPointerDown: event => {
171
+ handlePointerDown(event, Direction.north);
172
+ }
173
+ }), /*#__PURE__*/React.createElement("div", {
174
+ className: "image-resizer image-resizer-ne",
175
+ onPointerDown: event => {
176
+ handlePointerDown(event, Direction.north | Direction.east);
177
+ }
178
+ }), /*#__PURE__*/React.createElement("div", {
179
+ className: "image-resizer image-resizer-e",
180
+ onPointerDown: event => {
181
+ handlePointerDown(event, Direction.east);
182
+ }
183
+ }), /*#__PURE__*/React.createElement("div", {
184
+ className: "image-resizer image-resizer-se",
185
+ onPointerDown: event => {
186
+ handlePointerDown(event, Direction.south | Direction.east);
187
+ }
188
+ }), /*#__PURE__*/React.createElement("div", {
189
+ className: "image-resizer image-resizer-s",
190
+ onPointerDown: event => {
191
+ handlePointerDown(event, Direction.south);
192
+ }
193
+ }), /*#__PURE__*/React.createElement("div", {
194
+ className: "image-resizer image-resizer-sw",
195
+ onPointerDown: event => {
196
+ handlePointerDown(event, Direction.south | Direction.west);
197
+ }
198
+ }), /*#__PURE__*/React.createElement("div", {
199
+ className: "image-resizer image-resizer-w",
200
+ onPointerDown: event => {
201
+ handlePointerDown(event, Direction.west);
202
+ }
203
+ }), /*#__PURE__*/React.createElement("div", {
204
+ className: "image-resizer image-resizer-nw",
205
+ onPointerDown: event => {
206
+ handlePointerDown(event, Direction.north | Direction.west);
207
+ }
208
+ }));
209
+ }
210
+
211
+ //# sourceMappingURL=ImageResizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useRef","clamp","value","min","max","Math","Direction","east","north","south","west","ImageResizer","onResizeStart","onResizeEnd","buttonRef","imageRef","maxWidth","editor","showCaption","setShowCaption","captionsEnabled","controlWrapperRef","userSelect","priority","positioningRef","currentHeight","currentWidth","direction","isResizing","ratio","startHeight","startWidth","startX","startY","editorRootElement","getRootElement","maxWidthContainer","getBoundingClientRect","width","maxHeightContainer","height","minWidth","minHeight","setStartCursor","ew","ns","nwse","cursorDir","style","setProperty","document","body","current","getPropertyValue","getPropertyPriority","setEndCursor","handlePointerDown","event","isEditable","image","controlWrapper","positioning","clientX","clientY","classList","add","addEventListener","handlePointerMove","handlePointerUp","isHorizontal","isVertical","diff","floor","remove","removeEventListener","createElement","ref","className","onClick","onPointerDown"],"sources":["ImageResizer.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 { LexicalEditor } from \"lexical\";\n\nimport * as React from \"react\";\nimport { useRef } from \"react\";\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nconst Direction = {\n east: 1 << 0,\n north: 1 << 3,\n south: 1 << 1,\n west: 1 << 2\n};\n\nexport function ImageResizer({\n onResizeStart,\n onResizeEnd,\n buttonRef,\n imageRef,\n maxWidth,\n editor,\n showCaption,\n setShowCaption,\n captionsEnabled\n}: {\n editor: LexicalEditor;\n buttonRef: { current: null | HTMLButtonElement };\n imageRef: { current: null | HTMLElement };\n maxWidth?: number;\n onResizeEnd: (width: \"inherit\" | number, height: \"inherit\" | number) => void;\n onResizeStart: () => void;\n setShowCaption: (show: boolean) => void;\n showCaption: boolean;\n captionsEnabled: boolean;\n}): JSX.Element {\n const controlWrapperRef = useRef<HTMLDivElement>(null);\n const userSelect = useRef({\n priority: \"\",\n value: \"default\"\n });\n const positioningRef = useRef<{\n currentHeight: \"inherit\" | number;\n currentWidth: \"inherit\" | number;\n direction: number;\n isResizing: boolean;\n ratio: number;\n startHeight: number;\n startWidth: number;\n startX: number;\n startY: number;\n }>({\n currentHeight: 0,\n currentWidth: 0,\n direction: 0,\n isResizing: false,\n ratio: 0,\n startHeight: 0,\n startWidth: 0,\n startX: 0,\n startY: 0\n });\n const editorRootElement = editor.getRootElement();\n // Find max width, accounting for editor padding.\n const maxWidthContainer = maxWidth\n ? maxWidth\n : editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().width - 20\n : 100;\n const maxHeightContainer =\n editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;\n\n const minWidth = 100;\n const minHeight = 100;\n\n const setStartCursor = (direction: number) => {\n const ew = direction === Direction.east || direction === Direction.west;\n const ns = direction === Direction.north || direction === Direction.south;\n const nwse =\n (direction & Direction.north && direction & Direction.west) ||\n (direction & Direction.south && direction & Direction.east);\n\n const cursorDir = ew ? \"ew\" : ns ? \"ns\" : nwse ? \"nwse\" : \"nesw\";\n\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n userSelect.current.value = document.body.style.getPropertyValue(\"-webkit-user-select\");\n userSelect.current.priority =\n document.body.style.getPropertyPriority(\"-webkit-user-select\");\n document.body.style.setProperty(\"-webkit-user-select\", `none`, \"important\");\n }\n };\n\n const setEndCursor = () => {\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", \"text\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", \"default\");\n document.body.style.setProperty(\n \"-webkit-user-select\",\n userSelect.current.value,\n userSelect.current.priority\n );\n }\n };\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>, direction: number) => {\n if (!editor.isEditable()) {\n return;\n }\n\n const image = imageRef.current;\n const controlWrapper = controlWrapperRef.current;\n\n if (image !== null && controlWrapper !== null) {\n const { width, height } = image.getBoundingClientRect();\n const positioning = positioningRef.current;\n positioning.startWidth = width;\n positioning.startHeight = height;\n positioning.ratio = width / height;\n positioning.currentWidth = width;\n positioning.currentHeight = height;\n positioning.startX = event.clientX;\n positioning.startY = event.clientY;\n positioning.isResizing = true;\n positioning.direction = direction;\n\n setStartCursor(direction);\n onResizeStart();\n\n controlWrapper.classList.add(\"image-control-wrapper--resizing\");\n image.style.height = `${height}px`;\n image.style.width = `${width}px`;\n\n document.addEventListener(\"pointermove\", handlePointerMove);\n document.addEventListener(\"pointerup\", handlePointerUp);\n }\n };\n const handlePointerMove = (event: PointerEvent) => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n\n const isHorizontal = positioning.direction & (Direction.east | Direction.west);\n const isVertical = positioning.direction & (Direction.south | Direction.north);\n\n if (image !== null && positioning.isResizing) {\n // Corner cursor\n if (isHorizontal && isVertical) {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n const height = width / positioning.ratio;\n image.style.width = `${width}px`;\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n positioning.currentWidth = width;\n } else if (isVertical) {\n let diff = Math.floor(positioning.startY - event.clientY);\n diff = positioning.direction & Direction.south ? -diff : diff;\n\n const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);\n\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n } else {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n image.style.width = `${width}px`;\n positioning.currentWidth = width;\n }\n }\n };\n const handlePointerUp = () => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n const controlWrapper = controlWrapperRef.current;\n if (image !== null && controlWrapper !== null && positioning.isResizing) {\n const width = positioning.currentWidth;\n const height = positioning.currentHeight;\n positioning.startWidth = 0;\n positioning.startHeight = 0;\n positioning.ratio = 0;\n positioning.startX = 0;\n positioning.startY = 0;\n positioning.currentWidth = 0;\n positioning.currentHeight = 0;\n positioning.isResizing = false;\n\n controlWrapper.classList.remove(\"image-control-wrapper--resizing\");\n\n setEndCursor();\n onResizeEnd(width, height);\n\n document.removeEventListener(\"pointermove\", handlePointerMove);\n document.removeEventListener(\"pointerup\", handlePointerUp);\n }\n };\n return (\n <div ref={controlWrapperRef}>\n {!showCaption && captionsEnabled && (\n <button\n className=\"image-caption-button\"\n ref={buttonRef}\n onClick={() => {\n setShowCaption(!showCaption);\n }}\n >\n Add Caption\n </button>\n )}\n <div\n className=\"image-resizer image-resizer-n\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north);\n }}\n />\n <div\n className=\"image-resizer image-resizer-ne\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-e\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-se\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-s\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south);\n }}\n />\n <div\n className=\"image-resizer image-resizer-sw\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-w\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-nw\"\n onPointerDown={event => {\n handlePointerDown(event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a,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACG,KAAK,GAAGH,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CAAC,eACFX,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,+BAA+B;IACzCE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACI,IAAI,CAAC;IAC5C;EAAE,CACL,CAAC,eACFX,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,gCAAgC;IAC1CE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACE,KAAK,GAAGF,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CACA,CAAC;AAEd","ignoreList":[]}
package/ui/Input.css ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ .Input__wrapper {
11
+ display: flex;
12
+ flex-direction: row;
13
+ align-items: center;
14
+ margin-bottom: 10px;
15
+ }
16
+ .Input__label {
17
+ display: flex;
18
+ flex: 1;
19
+ color: #666;
20
+ }
21
+ .Input__input {
22
+ display: flex;
23
+ flex: 2;
24
+ border: 1px solid #999;
25
+ padding-top: 7px;
26
+ padding-bottom: 7px;
27
+ padding-left: 10px;
28
+ padding-right: 10px;
29
+ font-size: 16px;
30
+ border-radius: 5px;
31
+ min-width: 0;
32
+ }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ @keyframes glimmer-animation {
11
+ 0% {
12
+ background: #f9f9f9;
13
+ }
14
+ .50% {
15
+ background: #eeeeee;
16
+ }
17
+ .100% {
18
+ background: #f9f9f9;
19
+ }
20
+ }
21
+
22
+ .LinkPreview__container {
23
+ padding-bottom: 12px;
24
+ }
25
+
26
+ .LinkPreview__imageWrapper {
27
+ text-align: center;
28
+ }
29
+
30
+ .LinkPreview__image {
31
+ max-width: 100%;
32
+ max-height: 250px;
33
+ margin: auto;
34
+ }
35
+
36
+ .LinkPreview__title {
37
+ margin-left: 12px;
38
+ margin-right: 12px;
39
+ margin-top: 4px;
40
+ }
41
+
42
+ .LinkPreview__description {
43
+ color: #999;
44
+ font-size: 90%;
45
+ margin-left: 12px;
46
+ margin-right: 12px;
47
+ margin-top: 4px;
48
+ }
49
+
50
+ .LinkPreview__domain {
51
+ color: #999;
52
+ font-size: 90%;
53
+ margin-left: 12px;
54
+ margin-right: 12px;
55
+ margin-top: 4px;
56
+ }
57
+
58
+ .LinkPreview__glimmer {
59
+ background: #f9f9f9;
60
+ border-radius: 8px;
61
+ height: 18px;
62
+ margin-bottom: 8px;
63
+ margin-left: 12px;
64
+ margin-right: 12px;
65
+ animation-duration: 3s;
66
+ animation-iteration-count: infinite;
67
+ animation-timing-function: linear;
68
+ animation-name: glimmer-animation;
69
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ import "./LinkPreview.css";
10
+ export declare function LinkPreview({ url }: Readonly<{
11
+ url: string;
12
+ }>): JSX.Element;
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import "./LinkPreview.css";
10
+ import * as React from "react";
11
+ import { Suspense } from "react";
12
+ // Cached responses or running request promises
13
+ const PREVIEW_CACHE = {};
14
+ const URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
15
+ function useSuspenseRequest(url) {
16
+ let cached = PREVIEW_CACHE[url];
17
+ if (!url.match(URL_MATCHER)) {
18
+ return {
19
+ preview: null
20
+ };
21
+ }
22
+ if (!cached) {
23
+ cached = PREVIEW_CACHE[url] = fetch(`/api/link-preview?url=${encodeURI(url)}`).then(response => response.json()).then(preview => {
24
+ PREVIEW_CACHE[url] = preview;
25
+ return preview;
26
+ }).catch(() => {
27
+ PREVIEW_CACHE[url] = {
28
+ preview: null
29
+ };
30
+ });
31
+ }
32
+ if (cached instanceof Promise) {
33
+ throw cached;
34
+ }
35
+ return cached;
36
+ }
37
+ function LinkPreviewContent({
38
+ url
39
+ }) {
40
+ const {
41
+ preview
42
+ } = useSuspenseRequest(url);
43
+ if (preview === null) {
44
+ return null;
45
+ }
46
+ return /*#__PURE__*/React.createElement("div", {
47
+ className: "CustomLinkPreview__container"
48
+ }, preview.img && /*#__PURE__*/React.createElement("div", {
49
+ className: "CustomLinkPreview__imageWrapper"
50
+ }, /*#__PURE__*/React.createElement("img", {
51
+ src: preview.img,
52
+ alt: preview.title,
53
+ className: "CustomLinkPreview__image"
54
+ })), preview.domain && /*#__PURE__*/React.createElement("div", {
55
+ className: "CustomLinkPreview__domain"
56
+ }, preview.domain), preview.title && /*#__PURE__*/React.createElement("div", {
57
+ className: "CustomLinkPreview__title"
58
+ }, preview.title), preview.description && /*#__PURE__*/React.createElement("div", {
59
+ className: "CustomLinkPreview__description"
60
+ }, preview.description));
61
+ }
62
+ function Glimmer(props) {
63
+ return /*#__PURE__*/React.createElement("div", Object.assign({
64
+ className: "CustomLinkPreview__glimmer"
65
+ }, props, {
66
+ style: {
67
+ animationDelay: String((props.index || 0) * 300),
68
+ ...(props.style || {})
69
+ }
70
+ }));
71
+ }
72
+ export function LinkPreview({
73
+ url
74
+ }) {
75
+ return /*#__PURE__*/React.createElement(Suspense, {
76
+ fallback: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Glimmer, {
77
+ style: {
78
+ height: "80px"
79
+ },
80
+ index: 0
81
+ }), /*#__PURE__*/React.createElement(Glimmer, {
82
+ style: {
83
+ width: "60%"
84
+ },
85
+ index: 1
86
+ }), /*#__PURE__*/React.createElement(Glimmer, {
87
+ style: {
88
+ width: "80%"
89
+ },
90
+ index: 2
91
+ }))
92
+ }, /*#__PURE__*/React.createElement(LinkPreviewContent, {
93
+ url: url
94
+ }));
95
+ }
96
+
97
+ //# sourceMappingURL=LinkPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Suspense","PREVIEW_CACHE","URL_MATCHER","useSuspenseRequest","url","cached","match","preview","fetch","encodeURI","then","response","json","catch","Promise","LinkPreviewContent","createElement","className","img","src","alt","title","domain","description","Glimmer","props","Object","assign","style","animationDelay","String","index","LinkPreview","fallback","Fragment","height","width"],"sources":["LinkPreview.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 \"./LinkPreview.css\";\n\nimport * as React from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { Suspense } from \"react\";\n\ntype Preview = {\n title: string;\n description: string;\n img: string;\n domain: string;\n} | null;\n\n// Cached responses or running request promises\nconst PREVIEW_CACHE: Record<string, Promise<Preview> | { preview: Preview }> = {};\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\nfunction useSuspenseRequest(url: string) {\n let cached = PREVIEW_CACHE[url];\n\n if (!url.match(URL_MATCHER)) {\n return { preview: null };\n }\n\n if (!cached) {\n cached = PREVIEW_CACHE[url] = fetch(`/api/link-preview?url=${encodeURI(url)}`)\n .then(response => response.json())\n .then(preview => {\n PREVIEW_CACHE[url] = preview;\n return preview;\n })\n .catch(() => {\n PREVIEW_CACHE[url] = { preview: null };\n });\n }\n\n if (cached instanceof Promise) {\n throw cached;\n }\n\n return cached;\n}\n\nfunction LinkPreviewContent({\n url\n}: Readonly<{\n url: string;\n}>): JSX.Element | null {\n const { preview } = useSuspenseRequest(url);\n if (preview === null) {\n return null;\n }\n return (\n <div className=\"CustomLinkPreview__container\">\n {preview.img && (\n <div className=\"CustomLinkPreview__imageWrapper\">\n <img\n src={preview.img}\n alt={preview.title}\n className=\"CustomLinkPreview__image\"\n />\n </div>\n )}\n {preview.domain && <div className=\"CustomLinkPreview__domain\">{preview.domain}</div>}\n {preview.title && <div className=\"CustomLinkPreview__title\">{preview.title}</div>}\n {preview.description && (\n <div className=\"CustomLinkPreview__description\">{preview.description}</div>\n )}\n </div>\n );\n}\n\nfunction Glimmer(props: { style: CSSProperties; index: number }): JSX.Element {\n return (\n <div\n className=\"CustomLinkPreview__glimmer\"\n {...props}\n style={{\n animationDelay: String((props.index || 0) * 300),\n ...(props.style || {})\n }}\n />\n );\n}\n\nexport function LinkPreview({\n url\n}: Readonly<{\n url: string;\n}>): JSX.Element {\n return (\n <Suspense\n fallback={\n <>\n <Glimmer style={{ height: \"80px\" }} index={0} />\n <Glimmer style={{ width: \"60%\" }} index={1} />\n <Glimmer style={{ width: \"80%\" }} index={2} />\n </>\n }\n >\n <LinkPreviewContent url={url} />\n </Suspense>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,QAAQ,QAAQ,OAAO;AAShC;AACA,MAAMC,aAAsE,GAAG,CAAC,CAAC;AAEjF,MAAMC,WAAW,GACb,iHAAiH;AAErH,SAASC,kBAAkBA,CAACC,GAAW,EAAE;EACrC,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EAAEA;EAAI,CAAE,CACzB,CAAC;AAEnB","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ .Placeholder__root {
11
+ font-size: 15px;
12
+ margin-top: -20px;
13
+ color: #999;
14
+ overflow: hidden;
15
+ position: relative;
16
+ text-overflow: ellipsis;
17
+ user-select: none;
18
+ white-space: nowrap;
19
+ pointer-events: none;
20
+ }
@@ -0,0 +1,15 @@
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
+ import "./Placeholder.css";
9
+ import * as React from "react";
10
+ import type { ReactNode } from "react";
11
+ export declare function Placeholder({ children, className, styles }: {
12
+ children: ReactNode;
13
+ className?: string;
14
+ styles?: React.CSSProperties;
15
+ }): JSX.Element;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import "./Placeholder.css";
10
+ import * as React from "react";
11
+ export function Placeholder({
12
+ children,
13
+ className,
14
+ styles
15
+ }) {
16
+ return /*#__PURE__*/React.createElement("div", {
17
+ style: {
18
+ ...styles
19
+ },
20
+ className: className || "Placeholder__root"
21
+ }, children);
22
+ }
23
+
24
+ //# sourceMappingURL=Placeholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Placeholder","children","className","styles","createElement","style"],"sources":["Placeholder.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 \"./Placeholder.css\";\n\nimport * as React from \"react\";\nimport type { ReactNode } from \"react\";\n\nexport function Placeholder({\n children,\n className,\n styles\n}: {\n children: ReactNode;\n className?: string;\n styles?: React.CSSProperties;\n}): JSX.Element {\n return (\n <div style={{ ...styles }} className={className || \"Placeholder__root\"}>\n {children}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAO,SAASC,WAAWA,CAAC;EACxBC,QAAQ;EACRC,SAAS;EACTC;AAKJ,CAAC,EAAe;EACZ,oBACIJ,KAAA,CAAAK,aAAA;IAAKC,KAAK,EAAE;MAAE,GAAGF;IAAO,CAAE;IAACD,SAAS,EAAEA,SAAS,IAAI;EAAoB,GAClED,QACA,CAAC;AAEd","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ /// <reference types="react" />
9
+ import "./Input.css";
10
+ type Props = Readonly<{
11
+ "data-test-id"?: string;
12
+ label: string;
13
+ onChange: (val: string) => void;
14
+ placeholder?: string;
15
+ value: string;
16
+ }>;
17
+ export default function TextInput({ label, value, onChange, placeholder, "data-test-id": dataTestId }: Props): JSX.Element;
18
+ export {};
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import "./Input.css";
10
+ import * as React from "react";
11
+ export default function TextInput({
12
+ label,
13
+ value,
14
+ onChange,
15
+ placeholder = "",
16
+ "data-test-id": dataTestId
17
+ }) {
18
+ return /*#__PURE__*/React.createElement("div", {
19
+ className: "Input__wrapper"
20
+ }, /*#__PURE__*/React.createElement("label", {
21
+ className: "Input__label"
22
+ }, label), /*#__PURE__*/React.createElement("input", {
23
+ type: "text",
24
+ className: "Input__input",
25
+ placeholder: placeholder,
26
+ value: value,
27
+ onChange: e => {
28
+ onChange(e.target.value);
29
+ },
30
+ "data-test-id": dataTestId
31
+ }));
32
+ }
33
+
34
+ //# sourceMappingURL=TextInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","TextInput","label","value","onChange","placeholder","dataTestId","createElement","className","type","e","target"],"sources":["TextInput.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 \"./Input.css\";\n\nimport * as React from \"react\";\n\ntype Props = Readonly<{\n \"data-test-id\"?: string;\n label: string;\n onChange: (val: string) => void;\n placeholder?: string;\n value: string;\n}>;\n\nexport default function TextInput({\n label,\n value,\n onChange,\n placeholder = \"\",\n \"data-test-id\": dataTestId\n}: Props): JSX.Element {\n return (\n <div className=\"Input__wrapper\">\n <label className=\"Input__label\">{label}</label>\n <input\n type=\"text\"\n className=\"Input__input\"\n placeholder={placeholder}\n value={value}\n onChange={e => {\n onChange(e.target.value);\n }}\n data-test-id={dataTestId}\n />\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAU9B,eAAe,SAASC,SAASA,CAAC;EAC9BC,KAAK;EACLC,KAAK;EACLC,QAAQ;EACRC,WAAW,GAAG,EAAE;EAChB,cAAc,EAAEC;AACb,CAAC,EAAe;EACnB,oBACIN,KAAA,CAAAO,aAAA;IAAKC,SAAS,EAAC;EAAgB,gBAC3BR,KAAA,CAAAO,aAAA;IAAOC,SAAS,EAAC;EAAc,GAAEN,KAAa,CAAC,eAC/CF,KAAA,CAAAO,aAAA;IACIE,IAAI,EAAC,MAAM;IACXD,SAAS,EAAC,cAAc;IACxBH,WAAW,EAAEA,WAAY;IACzBF,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAEM,CAAC,IAAI;MACXN,QAAQ,CAACM,CAAC,CAACC,MAAM,CAACR,KAAK,CAAC;IAC5B,CAAE;IACF,gBAAcG;EAAW,CAC5B,CACA,CAAC;AAEd","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ interface ToolbarActionDialogProps {
3
+ disabled: boolean;
4
+ buttonLabel?: string;
5
+ buttonAriaLabel: string;
6
+ buttonClassName: string;
7
+ buttonIconClassName: string;
8
+ children: React.ReactNode | React.ReactNode[];
9
+ }
10
+ export declare const ToolbarActionDialog: ({ disabled, buttonAriaLabel, buttonClassName, buttonIconClassName, buttonLabel, children }: ToolbarActionDialogProps) => JSX.Element;
11
+ export {};