@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/ui/DropDown.js ADDED
@@ -0,0 +1,168 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.DropDown = DropDown;
9
+ exports.DropDownItem = DropDownItem;
10
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
12
+ var React = _interopRequireWildcard(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
+ var DropDownContext = /*#__PURE__*/React.createContext(null);
22
+ function DropDownItem(_ref) {
23
+ var children = _ref.children,
24
+ className = _ref.className,
25
+ onClick = _ref.onClick,
26
+ title = _ref.title;
27
+ var ref = (0, React.useRef)(null);
28
+ var dropDownContext = React.useContext(DropDownContext);
29
+ if (dropDownContext === null) {
30
+ throw new Error("DropDownItem must be used within a DropDown");
31
+ }
32
+ var registerItem = dropDownContext.registerItem;
33
+ (0, React.useEffect)(function () {
34
+ if (ref && ref.current) {
35
+ registerItem(ref);
36
+ }
37
+ }, [ref, registerItem]);
38
+ return /*#__PURE__*/React.createElement("button", {
39
+ className: className,
40
+ onClick: onClick,
41
+ ref: ref,
42
+ title: title
43
+ }, children);
44
+ }
45
+ function DropDownItems(_ref2) {
46
+ var children = _ref2.children,
47
+ dropDownRef = _ref2.dropDownRef,
48
+ onClose = _ref2.onClose;
49
+ var _useState = (0, React.useState)(),
50
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
51
+ items = _useState2[0],
52
+ setItems = _useState2[1];
53
+ var _useState3 = (0, React.useState)(),
54
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
55
+ highlightedItem = _useState4[0],
56
+ setHighlightedItem = _useState4[1];
57
+ var registerItem = (0, React.useCallback)(function (itemRef) {
58
+ setItems(function (prev) {
59
+ return prev ? [].concat((0, _toConsumableArray2.default)(prev), [itemRef]) : [itemRef];
60
+ });
61
+ }, [setItems]);
62
+ var handleKeyDown = function handleKeyDown(event) {
63
+ if (!items) {
64
+ return;
65
+ }
66
+ var key = event.key;
67
+ if (["Escape", "ArrowUp", "ArrowDown", "Tab"].includes(key)) {
68
+ event.preventDefault();
69
+ }
70
+ if (key === "Escape" || key === "Tab") {
71
+ onClose();
72
+ } else if (key === "ArrowUp") {
73
+ setHighlightedItem(function (prev) {
74
+ if (!prev) {
75
+ return items[0];
76
+ }
77
+ var index = items.indexOf(prev) - 1;
78
+ return items[index === -1 ? items.length - 1 : index];
79
+ });
80
+ } else if (key === "ArrowDown") {
81
+ setHighlightedItem(function (prev) {
82
+ if (!prev) {
83
+ return items[0];
84
+ }
85
+ return items[items.indexOf(prev) + 1];
86
+ });
87
+ }
88
+ };
89
+ var contextValue = (0, React.useMemo)(function () {
90
+ return {
91
+ registerItem: registerItem
92
+ };
93
+ }, [registerItem]);
94
+ (0, React.useEffect)(function () {
95
+ if (items && !highlightedItem) {
96
+ setHighlightedItem(items[0]);
97
+ }
98
+ if (highlightedItem && highlightedItem.current) {
99
+ highlightedItem.current.focus();
100
+ }
101
+ }, [items, highlightedItem]);
102
+ return /*#__PURE__*/React.createElement(DropDownContext.Provider, {
103
+ value: contextValue
104
+ }, /*#__PURE__*/React.createElement("div", {
105
+ className: "lexical-dropdown",
106
+ ref: dropDownRef !== null && dropDownRef !== void 0 ? dropDownRef : null,
107
+ onKeyDown: handleKeyDown
108
+ }, children));
109
+ }
110
+ function DropDown(_ref3) {
111
+ var _ref3$disabled = _ref3.disabled,
112
+ disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
113
+ buttonLabel = _ref3.buttonLabel,
114
+ buttonAriaLabel = _ref3.buttonAriaLabel,
115
+ buttonClassName = _ref3.buttonClassName,
116
+ buttonIconClassName = _ref3.buttonIconClassName,
117
+ children = _ref3.children,
118
+ stopCloseOnClickSelf = _ref3.stopCloseOnClickSelf;
119
+ var buttonRef = (0, React.useRef)(null);
120
+ var _useState5 = (0, React.useState)(false),
121
+ _useState6 = (0, _slicedToArray2.default)(_useState5, 2),
122
+ showDropDown = _useState6[0],
123
+ setShowDropDown = _useState6[1];
124
+ var handleClose = function handleClose() {
125
+ setShowDropDown(false);
126
+ if (buttonRef && buttonRef.current) {
127
+ buttonRef.current.focus();
128
+ }
129
+ };
130
+ (0, React.useEffect)(function () {
131
+ var button = buttonRef.current;
132
+ if (button === null || !showDropDown) {
133
+ return;
134
+ }
135
+ var handle = function handle(event) {
136
+ var target = event.target;
137
+ if (!button.contains(target)) {
138
+ setShowDropDown(false);
139
+ }
140
+ };
141
+ document.addEventListener("click", handle);
142
+ return function () {
143
+ document.removeEventListener("click", handle);
144
+ };
145
+ }, [buttonRef, showDropDown, stopCloseOnClickSelf]);
146
+ return /*#__PURE__*/React.createElement("button", {
147
+ style: {
148
+ position: "relative"
149
+ },
150
+ disabled: disabled,
151
+ "aria-label": buttonAriaLabel || buttonLabel,
152
+ className: buttonClassName,
153
+ onClick: function onClick() {
154
+ return setShowDropDown(!showDropDown);
155
+ },
156
+ ref: buttonRef
157
+ }, buttonIconClassName && /*#__PURE__*/React.createElement("span", {
158
+ className: buttonIconClassName
159
+ }), buttonLabel && /*#__PURE__*/React.createElement("span", {
160
+ className: "text dropdown-button-text"
161
+ }, buttonLabel), /*#__PURE__*/React.createElement("i", {
162
+ className: "chevron-down"
163
+ }), showDropDown && /*#__PURE__*/React.createElement("div", {
164
+ className: "lexical-dropdown-container"
165
+ }, /*#__PURE__*/React.createElement(DropDownItems, {
166
+ onClose: handleClose
167
+ }, children)));
168
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","_interopRequireWildcard","require","DropDownContext","createContext","DropDownItem","_ref","children","className","onClick","title","ref","useRef","dropDownContext","useContext","Error","registerItem","useEffect","current","createElement","DropDownItems","_ref2","dropDownRef","onClose","_useState","useState","_useState2","_slicedToArray2","default","items","setItems","_useState3","_useState4","highlightedItem","setHighlightedItem","useCallback","itemRef","prev","concat","_toConsumableArray2","handleKeyDown","event","key","includes","preventDefault","index","indexOf","length","contextValue","useMemo","focus","Provider","value","onKeyDown","DropDown","_ref3","_ref3$disabled","disabled","buttonLabel","buttonAriaLabel","buttonClassName","buttonIconClassName","stopCloseOnClickSelf","buttonRef","_useState5","_useState6","showDropDown","setShowDropDown","handleClose","button","handle","target","contains","document","addEventListener","removeEventListener","style","position"],"sources":["DropDown.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 { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport * as React from \"react\";\n\ntype DropDownContextType = {\n registerItem: (ref: React.RefObject<HTMLButtonElement>) => void;\n};\n\nconst DropDownContext = React.createContext<DropDownContextType | null>(null);\n\nexport function DropDownItem({\n children,\n className,\n onClick,\n title\n}: {\n children: React.ReactNode;\n className: string;\n onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;\n title?: string;\n}) {\n const ref = useRef<HTMLButtonElement>(null);\n\n const dropDownContext = React.useContext(DropDownContext);\n\n if (dropDownContext === null) {\n throw new Error(\"DropDownItem must be used within a DropDown\");\n }\n\n const { registerItem } = dropDownContext;\n\n useEffect(() => {\n if (ref && ref.current) {\n registerItem(ref);\n }\n }, [ref, registerItem]);\n\n return (\n <button className={className} onClick={onClick} ref={ref} title={title}>\n {children}\n </button>\n );\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n onClose\n}: {\n children: React.ReactNode;\n dropDownRef?: React.Ref<HTMLDivElement>;\n onClose: () => void;\n}) {\n const [items, setItems] = useState<React.RefObject<HTMLButtonElement>[]>();\n const [highlightedItem, setHighlightedItem] = useState<React.RefObject<HTMLButtonElement>>();\n\n const registerItem = useCallback(\n (itemRef: React.RefObject<HTMLButtonElement>) => {\n setItems(prev => (prev ? [...prev, itemRef] : [itemRef]));\n },\n [setItems]\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (!items) {\n return;\n }\n\n const key = event.key;\n\n if ([\"Escape\", \"ArrowUp\", \"ArrowDown\", \"Tab\"].includes(key)) {\n event.preventDefault();\n }\n\n if (key === \"Escape\" || key === \"Tab\") {\n onClose();\n } else if (key === \"ArrowUp\") {\n setHighlightedItem(prev => {\n if (!prev) {\n return items[0];\n }\n const index = items.indexOf(prev) - 1;\n return items[index === -1 ? items.length - 1 : index];\n });\n } else if (key === \"ArrowDown\") {\n setHighlightedItem(prev => {\n if (!prev) {\n return items[0];\n }\n return items[items.indexOf(prev) + 1];\n });\n }\n };\n\n const contextValue = useMemo(\n () => ({\n registerItem\n }),\n [registerItem]\n );\n\n useEffect(() => {\n if (items && !highlightedItem) {\n setHighlightedItem(items[0]);\n }\n\n if (highlightedItem && highlightedItem.current) {\n highlightedItem.current.focus();\n }\n }, [items, highlightedItem]);\n\n return (\n <DropDownContext.Provider value={contextValue}>\n <div className=\"lexical-dropdown\" ref={dropDownRef ?? null} onKeyDown={handleKeyDown}>\n {children}\n </div>\n </DropDownContext.Provider>\n );\n}\n\nexport function DropDown({\n disabled = false,\n buttonLabel,\n buttonAriaLabel,\n buttonClassName,\n buttonIconClassName,\n children,\n stopCloseOnClickSelf\n}: {\n disabled?: boolean;\n buttonAriaLabel?: string;\n buttonClassName: string;\n buttonIconClassName?: string;\n buttonLabel?: string;\n children: ReactNode;\n stopCloseOnClickSelf?: boolean;\n}): JSX.Element {\n const buttonRef = useRef<HTMLButtonElement>(null);\n const [showDropDown, setShowDropDown] = useState(false);\n\n const handleClose = () => {\n setShowDropDown(false);\n if (buttonRef && buttonRef.current) {\n buttonRef.current.focus();\n }\n };\n\n useEffect(() => {\n const button = buttonRef.current;\n if (button === null || !showDropDown) {\n return;\n }\n\n const handle = (event: MouseEvent) => {\n const target = event.target;\n if (!button.contains(target as Node)) {\n setShowDropDown(false);\n }\n };\n document.addEventListener(\"click\", handle);\n\n return () => {\n document.removeEventListener(\"click\", handle);\n };\n }, [buttonRef, showDropDown, stopCloseOnClickSelf]);\n\n return (\n <button\n style={{ position: \"relative\" }}\n disabled={disabled}\n aria-label={buttonAriaLabel || buttonLabel}\n className={buttonClassName}\n onClick={() => setShowDropDown(!showDropDown)}\n ref={buttonRef}\n >\n {buttonIconClassName && <span className={buttonIconClassName} />}\n {buttonLabel && <span className=\"text dropdown-button-text\">{buttonLabel}</span>}\n <i className=\"chevron-down\" />\n {showDropDown && (\n <div className={\"lexical-dropdown-container\"}>\n <DropDownItems onClose={handleClose}>{children}</DropDownItems>\n </div>\n )}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;;;AAQA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,IAAMC,eAAe,gBAAGH,KAAK,CAACI,aAAa,CAA6B,IAAI,CAAC;AAEtE,SAASC,YAAYA,CAAAC,IAAA,EAUzB;EAAA,IATCC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,SAAS,GAAAF,IAAA,CAATE,SAAS;IACTC,OAAO,GAAAH,IAAA,CAAPG,OAAO;I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I1D,KAAA,CAAAmB,aAAA;IAAMX,SAAS,EAAC;EAA2B,GAAEkD,WAAW,CAAQ,eAChF1D,KAAA,CAAAmB,aAAA;IAAGX,SAAS,EAAC;EAAc,EAAG,EAC7B0D,YAAY,iBACTlE,KAAA,CAAAmB,aAAA;IAAKX,SAAS,EAAE;EAA6B,gBACzCR,KAAA,CAAAmB,aAAA,CAACC,aAAa;IAACG,OAAO,EAAE6C;EAAY,GAAE7D,QAAQ,CAAiB,CAEtE,CACI;AAEjB"}
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,101 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.LinkPreview = LinkPreview;
9
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
10
+ require("./LinkPreview.css");
11
+ var React = _interopRequireWildcard(require("react"));
12
+ /**
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ *
18
+ */
19
+
20
+ // Cached responses or running request promises
21
+ var PREVIEW_CACHE = {};
22
+ var URL_MATCHER = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;
23
+ function useSuspenseRequest(url) {
24
+ var cached = PREVIEW_CACHE[url];
25
+ if (!url.match(URL_MATCHER)) {
26
+ return {
27
+ preview: null
28
+ };
29
+ }
30
+ if (!cached) {
31
+ cached = PREVIEW_CACHE[url] = fetch("/api/link-preview?url=".concat(encodeURI(url))).then(function (response) {
32
+ return response.json();
33
+ }).then(function (preview) {
34
+ PREVIEW_CACHE[url] = preview;
35
+ return preview;
36
+ }).catch(function () {
37
+ PREVIEW_CACHE[url] = {
38
+ preview: null
39
+ };
40
+ });
41
+ }
42
+ if (cached instanceof Promise) {
43
+ throw cached;
44
+ }
45
+ return cached;
46
+ }
47
+ function LinkPreviewContent(_ref) {
48
+ var url = _ref.url;
49
+ var _useSuspenseRequest = useSuspenseRequest(url),
50
+ preview = _useSuspenseRequest.preview;
51
+ if (preview === null) {
52
+ return null;
53
+ }
54
+ return /*#__PURE__*/React.createElement("div", {
55
+ className: "LinkPreview__container"
56
+ }, preview.img && /*#__PURE__*/React.createElement("div", {
57
+ className: "LinkPreview__imageWrapper"
58
+ }, /*#__PURE__*/React.createElement("img", {
59
+ src: preview.img,
60
+ alt: preview.title,
61
+ className: "LinkPreview__image"
62
+ })), preview.domain && /*#__PURE__*/React.createElement("div", {
63
+ className: "LinkPreview__domain"
64
+ }, preview.domain), preview.title && /*#__PURE__*/React.createElement("div", {
65
+ className: "LinkPreview__title"
66
+ }, preview.title), preview.description && /*#__PURE__*/React.createElement("div", {
67
+ className: "LinkPreview__description"
68
+ }, preview.description));
69
+ }
70
+ function Glimmer(props) {
71
+ return /*#__PURE__*/React.createElement("div", Object.assign({
72
+ className: "LinkPreview__glimmer"
73
+ }, props, {
74
+ style: (0, _objectSpread2.default)({
75
+ animationDelay: String((props.index || 0) * 300)
76
+ }, props.style || {})
77
+ }));
78
+ }
79
+ function LinkPreview(_ref2) {
80
+ var url = _ref2.url;
81
+ return /*#__PURE__*/React.createElement(React.Suspense, {
82
+ fallback: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Glimmer, {
83
+ style: {
84
+ height: "80px"
85
+ },
86
+ index: 0
87
+ }), /*#__PURE__*/React.createElement(Glimmer, {
88
+ style: {
89
+ width: "60%"
90
+ },
91
+ index: 1
92
+ }), /*#__PURE__*/React.createElement(Glimmer, {
93
+ style: {
94
+ width: "80%"
95
+ },
96
+ index: 2
97
+ }))
98
+ }, /*#__PURE__*/React.createElement(LinkPreviewContent, {
99
+ url: url
100
+ }));
101
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["require","React","_interopRequireWildcard","PREVIEW_CACHE","URL_MATCHER","useSuspenseRequest","url","cached","match","preview","fetch","concat","encodeURI","then","response","json","catch","Promise","LinkPreviewContent","_ref","_useSuspenseRequest","createElement","className","img","src","alt","title","domain","description","Glimmer","props","Object","assign","style","_objectSpread2","default","animationDelay","String","index","LinkPreview","_ref2","Suspense","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 { CSSProperties, 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=\"LinkPreview__container\">\n {preview.img && (\n <div className=\"LinkPreview__imageWrapper\">\n <img src={preview.img} alt={preview.title} className=\"LinkPreview__image\" />\n </div>\n )}\n {preview.domain && <div className=\"LinkPreview__domain\">{preview.domain}</div>}\n {preview.title && <div className=\"LinkPreview__title\">{preview.title}</div>}\n {preview.description && (\n <div className=\"LinkPreview__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=\"LinkPreview__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":";;;;;;;;;AAQAA,OAAA;AAEA,IAAAC,KAAA,GAAAC,uBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA,IAAMG,aAAsE,GAAG,CAAC,CAAC;AAEjF,IAAMC,WAAW,GACb,iHAAiH;AAErH,SAAS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Q,OAAO;MAACI,KAAK,EAAE;QAAEY,KAAK,EAAE;MAAM,CAAE;MAACP,KAAK,EAAE;IAAE,EAAG;EAErD,gBAEDrC,KAAA,CAAAoB,aAAA,CAACH,kBAAkB;IAACZ,GAAG,EAAEA;EAAI,EAAG,CACzB;AAEnB"}
@@ -0,0 +1,23 @@
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
+ color: #999;
13
+ overflow: hidden;
14
+ position: absolute;
15
+ text-overflow: ellipsis;
16
+ top: 0px;
17
+ left: 15px;
18
+ right: 28px;
19
+ user-select: none;
20
+ white-space: nowrap;
21
+ display: inline-block;
22
+ pointer-events: none;
23
+ }
@@ -0,0 +1,13 @@
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 { ReactNode } from "react";
10
+ export declare function Placeholder({ children, className }: {
11
+ children: ReactNode;
12
+ className?: string;
13
+ }): JSX.Element;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.Placeholder = Placeholder;
8
+ require("./Placeholder.css");
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
+ function Placeholder(_ref) {
19
+ var children = _ref.children,
20
+ className = _ref.className;
21
+ return /*#__PURE__*/React.createElement("div", {
22
+ className: className || "Placeholder__root"
23
+ }, children);
24
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["require","React","_interopRequireWildcard","Placeholder","_ref","children","className","createElement"],"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 { ReactNode } from \"react\";\n\nexport function Placeholder({\n children,\n className\n}: {\n children: ReactNode;\n className?: string;\n}): JSX.Element {\n return <div className={className || \"Placeholder__root\"}>{children}</div>;\n}\n"],"mappings":";;;;;;;AAQAA,OAAA;AAEA,IAAAC,KAAA,GAAAC,uBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOO,SAASG,WAAWA,CAAAC,IAAA,EAMX;EAAA,IALZC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IACRC,SAAS,GAAAF,IAAA,CAATE,SAAS;EAKT,oBAAOL,KAAA,CAAAM,aAAA;IAAKD,SAAS,EAAEA,SAAS,IAAI;EAAoB,GAAED,QAAQ,CAAO;AAC7E"}
@@ -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
+ declare 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,39 @@
1
+ "use strict";
2
+
3
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = TextInput;
8
+ require("./Input.css");
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
+ function TextInput(_ref) {
19
+ var label = _ref.label,
20
+ value = _ref.value,
21
+ _onChange = _ref.onChange,
22
+ _ref$placeholder = _ref.placeholder,
23
+ placeholder = _ref$placeholder === void 0 ? "" : _ref$placeholder,
24
+ dataTestId = _ref["data-test-id"];
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ className: "Input__wrapper"
27
+ }, /*#__PURE__*/React.createElement("label", {
28
+ className: "Input__label"
29
+ }, label), /*#__PURE__*/React.createElement("input", {
30
+ type: "text",
31
+ className: "Input__input",
32
+ placeholder: placeholder,
33
+ value: value,
34
+ onChange: function onChange(e) {
35
+ _onChange(e.target.value);
36
+ },
37
+ "data-test-id": dataTestId
38
+ }));
39
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["require","React","_interopRequireWildcard","TextInput","_ref","label","value","onChange","_ref$placeholder","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":";;;;;;;AAQAA,OAAA;AAEA,IAAAC,KAAA,GAAAC,uBAAA,CAAAF,OAAA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAce,SAASG,SAASA,CAAAC,IAAA,EAMV;EAAA,IALnBC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,KAAK,GAAAF,IAAA,CAALE,KAAK;IACLC,SAAQ,GAAAH,IAAA,CAARG,QAAQ;IAAAC,gBAAA,GAAAJ,IAAA,CACRK,WAAW;IAAXA,WAAW,GAAAD,gBAAA,cAAG,EAAE,GAAAA,gBAAA;IACAE,UAAU,GAAAN,IAAA,CAA1B,cAAc;EAEd,oBACIH,KAAA,CAAAU,aAAA;IAAKC,SAAS,EAAC;EAAgB,gBAC3BX,KAAA,CAAAU,aAAA;IAAOC,SAAS,EAAC;EAAc,GAAEP,KAAK,CAAS,eAC/CJ,KAAA,CAAAU,aAAA;IACIE,IAAI,EAAC,MAAM;IACXD,SAAS,EAAC,cAAc;IACxBH,WAAW,EAAEA,WAAY;IACzBH,KAAK,EAAEA,KAAM;IACbC,QAAQ,EAAE,SAAAA,SAAAO,CAAC,EAAI;MACXP,SAAQ,CAACO,CAAC,CAACC,MAAM,CAACT,KAAK,CAAC;IAC5B,CAAE;IACF,gBAAcI;EAAW,EAC3B,CACA;AAEd"}
@@ -0,0 +1,5 @@
1
+ import { LexicalValue } from "../types";
2
+ /**
3
+ * @description Basic JSON data string that will initialize the editor.
4
+ */
5
+ export declare const generateInitialLexicalValue: () => LexicalValue;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.generateInitialLexicalValue = void 0;
7
+ /**
8
+ * @description Basic JSON data string that will initialize the editor.
9
+ */
10
+ var generateInitialLexicalValue = function generateInitialLexicalValue() {
11
+ return JSON.stringify({
12
+ root: {
13
+ children: [{
14
+ children: [],
15
+ direction: null,
16
+ format: "",
17
+ indent: 0,
18
+ type: "paragraph",
19
+ version: 1
20
+ }],
21
+ direction: null,
22
+ format: "",
23
+ indent: 0,
24
+ type: "root",
25
+ version: 1
26
+ }
27
+ });
28
+ };
29
+ exports.generateInitialLexicalValue = generateInitialLexicalValue;
@@ -0,0 +1 @@
1
+ {"version":3,"names":["generateInitialLexicalValue","JSON","stringify","root","children","direction","format","indent","type","version","exports"],"sources":["generateInitialLexicalValue.ts"],"sourcesContent":["import { LexicalValue } from \"~/types\";\n\n/**\n * @description Basic JSON data string that will initialize the editor.\n */\nexport const generateInitialLexicalValue = (): LexicalValue => {\n return JSON.stringify({\n root: {\n children: [\n {\n children: [],\n direction: null,\n format: \"\",\n indent: 0,\n type: \"paragraph\",\n version: 1\n }\n ],\n direction: null,\n format: \"\",\n indent: 0,\n type: \"root\",\n version: 1\n }\n });\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA2BA,CAAA,EAAuB;EAC3D,OAAOC,IAAI,CAACC,SAAS,CAAC;IAClBC,IAAI,EAAE;MACFC,QAAQ,EAAE,CACN;QACIA,QAAQ,EAAE,EAAE;QACZC,SAAS,EAAE,IAAI;QACfC,MAAM,EAAE,EAAE;QACVC,MAAM,EAAE,CAAC;QACTC,IAAI,EAAE,WAAW;QACjBC,OAAO,EAAE;MACb,CAAC,CACJ;MACDJ,SAAS,EAAE,IAAI;MACfC,MAAM,EAAE,EAAE;MACVC,MAAM,EAAE,CAAC;MACTC,IAAI,EAAE,MAAM;MACZC,OAAO,EAAE;IACb;EACJ,CAAC,CAAC;AACN,CAAC;AAACC,OAAA,CAAAV,2BAAA,GAAAA,2BAAA"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="web" />
2
+ /// <reference types="react" />
3
+ /**
4
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ *
9
+ */
10
+ export declare function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getDOMRangeRect = getDOMRangeRect;
7
+ /**
8
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
9
+ *
10
+ * This source code is licensed under the MIT license found in the
11
+ * LICENSE file in the root directory of this source tree.
12
+ *
13
+ */
14
+ function getDOMRangeRect(nativeSelection, rootElement) {
15
+ var domRange = nativeSelection.getRangeAt(0);
16
+ var rect;
17
+ if (nativeSelection.anchorNode === rootElement) {
18
+ var inner = rootElement;
19
+ while (inner.firstElementChild != null) {
20
+ inner = inner.firstElementChild;
21
+ }
22
+ rect = inner.getBoundingClientRect();
23
+ } else {
24
+ rect = domRange.getBoundingClientRect();
25
+ }
26
+ return rect;
27
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getDOMRangeRect","nativeSelection","rootElement","domRange","getRangeAt","rect","anchorNode","inner","firstElementChild","getBoundingClientRect"],"sources":["getDOMRangeRect.ts"],"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 */\nexport function getDOMRangeRect(nativeSelection: Selection, rootElement: HTMLElement): DOMRect {\n const domRange = nativeSelection.getRangeAt(0);\n\n let rect;\n\n if (nativeSelection.anchorNode === rootElement) {\n let inner = rootElement;\n while (inner.firstElementChild != null) {\n inner = inner.firstElementChild as HTMLElement;\n }\n rect = inner.getBoundingClientRect();\n } else {\n rect = domRange.getBoundingClientRect();\n }\n\n return rect;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,eAAeA,CAACC,eAA0B,EAAEC,WAAwB,EAAW;EAC3F,IAAMC,QAAQ,GAAGF,eAAe,CAACG,UAAU,CAAC,CAAC,CAAC;EAE9C,IAAIC,IAAI;EAER,IAAIJ,eAAe,CAACK,UAAU,KAAKJ,WAAW,EAAE;IAC5C,IAAIK,KAAK,GAAGL,WAAW;IACvB,OAAOK,KAAK,CAACC,iBAAiB,IAAI,IAAI,EAAE;MACpCD,KAAK,GAAGA,KAAK,CAACC,iBAAgC;IAClD;IACAH,IAAI,GAAGE,KAAK,CAACE,qBAAqB,EAAE;EACxC,CAAC,MAAM;IACHJ,IAAI,GAAGF,QAAQ,CAACM,qBAAqB,EAAE;EAC3C;EAEA,OAAOJ,IAAI;AACf"}
@@ -0,0 +1,2 @@
1
+ import { ElementNode, RangeSelection, TextNode } from "lexical";
2
+ export declare function getSelectedNode(selection: RangeSelection): TextNode | ElementNode;