@webiny/lexical-editor 0.0.0-unstable.085ff6572f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +17 -0
- package/commands/webiny-list.d.ts +7 -0
- package/commands/webiny-list.js +13 -0
- package/commands/webiny-list.js.map +1 -0
- package/commands/webiny-quote.d.ts +5 -0
- package/commands/webiny-quote.js +9 -0
- package/commands/webiny-quote.js.map +1 -0
- package/components/AddRichTextEditorNodeType.d.ts +6 -0
- package/components/AddRichTextEditorNodeType.js +28 -0
- package/components/AddRichTextEditorNodeType.js.map +1 -0
- package/components/AddRichTextEditorPlugin.d.ts +12 -0
- package/components/AddRichTextEditorPlugin.js +33 -0
- package/components/AddRichTextEditorPlugin.js.map +1 -0
- package/components/AddToolbarAction.d.ts +7 -0
- package/components/AddToolbarAction.js +33 -0
- package/components/AddToolbarAction.js.map +1 -0
- package/components/Editor/HeadingEditor.d.ts +7 -0
- package/components/Editor/HeadingEditor.js +29 -0
- package/components/Editor/HeadingEditor.js.map +1 -0
- package/components/Editor/ParagraphEditor.d.ts +7 -0
- package/components/Editor/ParagraphEditor.js +30 -0
- package/components/Editor/ParagraphEditor.js.map +1 -0
- package/components/Editor/RichTextEditor.d.ts +26 -0
- package/components/Editor/RichTextEditor.js +138 -0
- package/components/Editor/RichTextEditor.js.map +1 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.d.ts +11 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js +19 -0
- package/components/LexicalEditorConfig/LexicalEditorConfig.js.map +1 -0
- package/components/LexicalHtmlRenderer.d.ts +16 -0
- package/components/LexicalHtmlRenderer.js +67 -0
- package/components/LexicalHtmlRenderer.js.map +1 -0
- package/components/Toolbar/HeadingToolbar.d.ts +12 -0
- package/components/Toolbar/HeadingToolbar.js +23 -0
- package/components/Toolbar/HeadingToolbar.js.map +1 -0
- package/components/Toolbar/ParagraphToolbar.d.ts +12 -0
- package/components/Toolbar/ParagraphToolbar.js +23 -0
- package/components/Toolbar/ParagraphToolbar.js.map +1 -0
- package/components/Toolbar/Toolbar.css +435 -0
- package/components/Toolbar/Toolbar.d.ts +13 -0
- package/components/Toolbar/Toolbar.js +215 -0
- package/components/Toolbar/Toolbar.js.map +1 -0
- package/components/ToolbarActions/BoldAction.d.ts +2 -0
- package/components/ToolbarActions/BoldAction.js +43 -0
- package/components/ToolbarActions/BoldAction.js.map +1 -0
- package/components/ToolbarActions/BulletListAction.d.ts +2 -0
- package/components/ToolbarActions/BulletListAction.js +56 -0
- package/components/ToolbarActions/BulletListAction.js.map +1 -0
- package/components/ToolbarActions/CodeHighlightAction.d.ts +2 -0
- package/components/ToolbarActions/CodeHighlightAction.js +43 -0
- package/components/ToolbarActions/CodeHighlightAction.js.map +1 -0
- package/components/ToolbarActions/FontColorAction.d.ts +11 -0
- package/components/ToolbarActions/FontColorAction.js +83 -0
- package/components/ToolbarActions/FontColorAction.js.map +1 -0
- package/components/ToolbarActions/FontSizeAction.d.ts +2 -0
- package/components/ToolbarActions/FontSizeAction.js +101 -0
- package/components/ToolbarActions/FontSizeAction.js.map +1 -0
- package/components/ToolbarActions/ItalicAction.d.ts +2 -0
- package/components/ToolbarActions/ItalicAction.js +43 -0
- package/components/ToolbarActions/ItalicAction.js.map +1 -0
- package/components/ToolbarActions/LinkAction.d.ts +2 -0
- package/components/ToolbarActions/LinkAction.js +64 -0
- package/components/ToolbarActions/LinkAction.js.map +1 -0
- package/components/ToolbarActions/NumberedListAction.d.ts +2 -0
- package/components/ToolbarActions/NumberedListAction.js +58 -0
- package/components/ToolbarActions/NumberedListAction.js.map +1 -0
- package/components/ToolbarActions/QuoteAction.d.ts +2 -0
- package/components/ToolbarActions/QuoteAction.js +52 -0
- package/components/ToolbarActions/QuoteAction.js.map +1 -0
- package/components/ToolbarActions/TextAlignmentAction.d.ts +11 -0
- package/components/ToolbarActions/TextAlignmentAction.js +70 -0
- package/components/ToolbarActions/TextAlignmentAction.js.map +1 -0
- package/components/ToolbarActions/TypographyAction.d.ts +11 -0
- package/components/ToolbarActions/TypographyAction.js +145 -0
- package/components/ToolbarActions/TypographyAction.js.map +1 -0
- package/components/ToolbarActions/UnderlineAction.d.ts +2 -0
- package/components/ToolbarActions/UnderlineAction.js +43 -0
- package/components/ToolbarActions/UnderlineAction.js.map +1 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.d.ts +2 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js +56 -0
- package/components/ToolbarPresets/HeadingToolbarPreset.js.map +1 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.d.ts +2 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.js +71 -0
- package/components/ToolbarPresets/ParagraphToolbarPreset.js.map +1 -0
- package/context/FontColorActionContext.d.ts +6 -0
- package/context/FontColorActionContext.js +10 -0
- package/context/FontColorActionContext.js.map +1 -0
- package/context/RichTextEditorContext.d.ts +26 -0
- package/context/RichTextEditorContext.js +68 -0
- package/context/RichTextEditorContext.js.map +1 -0
- package/context/SharedHistoryContext.d.ts +11 -0
- package/context/SharedHistoryContext.js +26 -0
- package/context/SharedHistoryContext.js.map +1 -0
- package/context/TextAlignmentActionContextProps.d.ts +9 -0
- package/context/TextAlignmentActionContextProps.js +10 -0
- package/context/TextAlignmentActionContextProps.js.map +1 -0
- package/context/TypographyActionContext.d.ts +7 -0
- package/context/TypographyActionContext.js +10 -0
- package/context/TypographyActionContext.js.map +1 -0
- package/hooks/useFontColorPicker.d.ts +2 -0
- package/hooks/useFontColorPicker.js +15 -0
- package/hooks/useFontColorPicker.js.map +1 -0
- package/hooks/useList.d.ts +2 -0
- package/hooks/useList.js +39 -0
- package/hooks/useList.js.map +1 -0
- package/hooks/useQuote.d.ts +2 -0
- package/hooks/useQuote.js +20 -0
- package/hooks/useQuote.js.map +1 -0
- package/hooks/useRichTextEditor.d.ts +2 -0
- package/hooks/useRichTextEditor.js +15 -0
- package/hooks/useRichTextEditor.js.map +1 -0
- package/hooks/useTextAlignmentAction.d.ts +1 -0
- package/hooks/useTextAlignmentAction.js +15 -0
- package/hooks/useTextAlignmentAction.js.map +1 -0
- package/hooks/useTypographyAction.d.ts +1 -0
- package/hooks/useTypographyAction.js +15 -0
- package/hooks/useTypographyAction.js.map +1 -0
- package/images/icons/LICENSE.md +5 -0
- package/images/icons/chat-square-quote.svg +1 -0
- package/images/icons/chevron-down.svg +1 -0
- package/images/icons/code.svg +1 -0
- package/images/icons/font-color.svg +1 -0
- package/images/icons/indent.svg +3 -0
- package/images/icons/justify.svg +3 -0
- package/images/icons/link.svg +1 -0
- package/images/icons/list-ol.svg +1 -0
- package/images/icons/list-ul.svg +1 -0
- package/images/icons/outdent.svg +3 -0
- package/images/icons/pencil-fill.svg +1 -0
- package/images/icons/text-center.svg +1 -0
- package/images/icons/text-left.svg +1 -0
- package/images/icons/text-paragraph.svg +1 -0
- package/images/icons/text-right.svg +1 -0
- package/images/icons/type-bold.svg +1 -0
- package/images/icons/type-h1.svg +1 -0
- package/images/icons/type-h2.svg +1 -0
- package/images/icons/type-h3.svg +1 -0
- package/images/icons/type-h4.svg +1 -0
- package/images/icons/type-h5.svg +1 -0
- package/images/icons/type-h6.svg +1 -0
- package/images/icons/type-italic.svg +1 -0
- package/images/icons/type-strikethrough.svg +1 -0
- package/images/icons/type-underline.svg +1 -0
- package/images/icons/unlink_icon.svg +1 -0
- package/index.d.ts +42 -0
- package/index.js +295 -0
- package/index.js.map +1 -0
- package/nodes/FontColorNode.d.ts +43 -0
- package/nodes/FontColorNode.js +127 -0
- package/nodes/FontColorNode.js.map +1 -0
- package/nodes/HeadingNode.d.ts +34 -0
- package/nodes/HeadingNode.js +192 -0
- package/nodes/HeadingNode.js.map +1 -0
- package/nodes/ListItemNode.d.ts +46 -0
- package/nodes/ListItemNode.js +441 -0
- package/nodes/ListItemNode.js.map +1 -0
- package/nodes/ListNode/formatList.d.ts +12 -0
- package/nodes/ListNode/formatList.js +424 -0
- package/nodes/ListNode/formatList.js.map +1 -0
- package/nodes/ListNode.d.ts +42 -0
- package/nodes/ListNode.js +294 -0
- package/nodes/ListNode.js.map +1 -0
- package/nodes/ParagraphNode.d.ts +32 -0
- package/nodes/ParagraphNode.js +218 -0
- package/nodes/ParagraphNode.js.map +1 -0
- package/nodes/QuoteNode.d.ts +34 -0
- package/nodes/QuoteNode.js +225 -0
- package/nodes/QuoteNode.js.map +1 -0
- package/nodes/TypographyElementNode.d.ts +42 -0
- package/nodes/TypographyElementNode.js +155 -0
- package/nodes/TypographyElementNode.js.map +1 -0
- package/nodes/types.d.ts +15 -0
- package/nodes/types.js +5 -0
- package/nodes/types.js.map +1 -0
- package/nodes/webinyNodes.d.ts +7 -0
- package/nodes/webinyNodes.js +45 -0
- package/nodes/webinyNodes.js.map +1 -0
- package/package.json +41 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.d.ts +11 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js +46 -0
- package/plugins/AutoLinkPlugin/AutoLinkPlugin.js.map +1 -0
- package/plugins/AutoLinkPlugin/index.d.ts +1 -0
- package/plugins/AutoLinkPlugin/index.js +16 -0
- package/plugins/AutoLinkPlugin/index.js.map +1 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.d.ts +7 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js +28 -0
- package/plugins/BlurEventPlugin/BlurEventPlugin.js.map +1 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.d.ts +17 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js +88 -0
- package/plugins/ClickableLinkPlugin/ClickableLinkPlugin.js.map +1 -0
- package/plugins/ClickableLinkPlugin/index.d.ts +1 -0
- package/plugins/ClickableLinkPlugin/index.js +16 -0
- package/plugins/ClickableLinkPlugin/index.js.map +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js +20 -0
- package/plugins/CodeHighlightPlugin/CodeHighlightPlugin.js.map +1 -0
- package/plugins/CodeHighlightPlugin/index.d.ts +1 -0
- package/plugins/CodeHighlightPlugin/index.js +16 -0
- package/plugins/CodeHighlightPlugin/index.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.css +118 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.d.ts +7 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js +222 -0
- package/plugins/FloatingLinkEditorPlugin/FloatingLinkEditorPlugin.js.map +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.d.ts +1 -0
- package/plugins/FloatingLinkEditorPlugin/index.js +16 -0
- package/plugins/FloatingLinkEditorPlugin/index.js.map +1 -0
- package/plugins/FontColorPlugin/FontColorPlugin.d.ts +2 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js +39 -0
- package/plugins/FontColorPlugin/FontColorPlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.d.ts +8 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js +34 -0
- package/plugins/LexicalUpdateStatePlugin/LexicalUpdateStatePlugin.js.map +1 -0
- package/plugins/LexicalUpdateStatePlugin/index.d.ts +1 -0
- package/plugins/LexicalUpdateStatePlugin/index.js +16 -0
- package/plugins/LexicalUpdateStatePlugin/index.js.map +1 -0
- package/plugins/TypographyPlugin/TypographyPlugin.d.ts +2 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js +35 -0
- package/plugins/TypographyPlugin/TypographyPlugin.js.map +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.d.ts +1 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js +25 -0
- package/plugins/WebinyListPLugin/WebinyListPlugin.js.map +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.d.ts +1 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js +24 -0
- package/plugins/WebinyQuoteNodePlugin/WebinyQuoteNodePlugin.js.map +1 -0
- package/themes/webinyLexicalTheme.css +429 -0
- package/themes/webinyLexicalTheme.d.ts +9 -0
- package/themes/webinyLexicalTheme.js +87 -0
- package/themes/webinyLexicalTheme.js.map +1 -0
- package/types.d.ts +63 -0
- package/types.js +25 -0
- package/types.js.map +1 -0
- package/ui/Divider.d.ts +2 -0
- package/ui/Divider.js +13 -0
- package/ui/Divider.js.map +1 -0
- package/ui/DropDown.d.ts +26 -0
- package/ui/DropDown.js +206 -0
- package/ui/DropDown.js.map +1 -0
- package/ui/Input.css +32 -0
- package/ui/LinkPreview.css +69 -0
- package/ui/LinkPreview.d.ts +12 -0
- package/ui/LinkPreview.js +101 -0
- package/ui/LinkPreview.js.map +1 -0
- package/ui/Placeholder.css +23 -0
- package/ui/Placeholder.d.ts +13 -0
- package/ui/Placeholder.js +24 -0
- package/ui/Placeholder.js.map +1 -0
- package/ui/TextInput.d.ts +18 -0
- package/ui/TextInput.js +39 -0
- package/ui/TextInput.js.map +1 -0
- package/ui/ToolbarActionDialog.d.ts +12 -0
- package/ui/ToolbarActionDialog.js +106 -0
- package/ui/ToolbarActionDialog.js.map +1 -0
- package/utils/findTypographyStyleByHtmlTag.d.ts +8 -0
- package/utils/findTypographyStyleByHtmlTag.js +16 -0
- package/utils/findTypographyStyleByHtmlTag.js.map +1 -0
- package/utils/generateInitialLexicalValue.d.ts +5 -0
- package/utils/generateInitialLexicalValue.js +30 -0
- package/utils/generateInitialLexicalValue.js.map +1 -0
- package/utils/getDOMRangeRect.d.ts +10 -0
- package/utils/getDOMRangeRect.js +27 -0
- package/utils/getDOMRangeRect.js.map +1 -0
- package/utils/getLexicalTextSelectionState.d.ts +5 -0
- package/utils/getLexicalTextSelectionState.js +163 -0
- package/utils/getLexicalTextSelectionState.js.map +1 -0
- package/utils/getSelectedNode.d.ts +2 -0
- package/utils/getSelectedNode.js +30 -0
- package/utils/getSelectedNode.js.map +1 -0
- package/utils/isValidJSON.d.ts +1 -0
- package/utils/isValidJSON.js +18 -0
- package/utils/isValidJSON.js.map +1 -0
- package/utils/isValidLexicalData.d.ts +2 -0
- package/utils/isValidLexicalData.js +24 -0
- package/utils/isValidLexicalData.js.map +1 -0
- package/utils/nodes/clearNodeFormating.d.ts +2 -0
- package/utils/nodes/clearNodeFormating.js +28 -0
- package/utils/nodes/clearNodeFormating.js.map +1 -0
- package/utils/nodes/formatToHeading.d.ts +3 -0
- package/utils/nodes/formatToHeading.js +25 -0
- package/utils/nodes/formatToHeading.js.map +1 -0
- package/utils/nodes/formatToParagraph.d.ts +2 -0
- package/utils/nodes/formatToParagraph.js +20 -0
- package/utils/nodes/formatToParagraph.js.map +1 -0
- package/utils/nodes/formatToQuote.d.ts +2 -0
- package/utils/nodes/formatToQuote.js +25 -0
- package/utils/nodes/formatToQuote.js.map +1 -0
- package/utils/nodes/listNode.d.ts +11 -0
- package/utils/nodes/listNode.js +107 -0
- package/utils/nodes/listNode.js.map +1 -0
- package/utils/point.d.ts +21 -0
- package/utils/point.js +77 -0
- package/utils/point.js.map +1 -0
- package/utils/rect.d.ts +47 -0
- package/utils/rect.js +169 -0
- package/utils/rect.js.map +1 -0
- package/utils/sanitizeUrl.d.ts +8 -0
- package/utils/sanitizeUrl.js +27 -0
- package/utils/sanitizeUrl.js.map +1 -0
- package/utils/setFloatingElemPosition.d.ts +3 -0
- package/utils/setFloatingElemPosition.js +40 -0
- package/utils/setFloatingElemPosition.js.map +1 -0
- package/utils/styleObjectToString.d.ts +2 -0
- package/utils/styleObjectToString.js +22 -0
- package/utils/styleObjectToString.js.map +1 -0
- package/utils/toTypographyEmotionMap.d.ts +3 -0
- package/utils/toTypographyEmotionMap.js +36 -0
- package/utils/toTypographyEmotionMap.js.map +1 -0
package/ui/DropDown.js
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
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
|
+
type: "button"
|
|
44
|
+
}, children);
|
|
45
|
+
}
|
|
46
|
+
function DropDownItems(_ref2) {
|
|
47
|
+
var children = _ref2.children,
|
|
48
|
+
dropDownRef = _ref2.dropDownRef,
|
|
49
|
+
_ref2$showScroll = _ref2.showScroll,
|
|
50
|
+
showScroll = _ref2$showScroll === void 0 ? true : _ref2$showScroll,
|
|
51
|
+
onClose = _ref2.onClose;
|
|
52
|
+
var _useState = (0, React.useState)(),
|
|
53
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
54
|
+
items = _useState2[0],
|
|
55
|
+
setItems = _useState2[1];
|
|
56
|
+
var _useState3 = (0, React.useState)(),
|
|
57
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
58
|
+
highlightedItem = _useState4[0],
|
|
59
|
+
setHighlightedItem = _useState4[1];
|
|
60
|
+
var registerItem = (0, React.useCallback)(function (itemRef) {
|
|
61
|
+
setItems(function (prev) {
|
|
62
|
+
return prev ? [].concat((0, _toConsumableArray2.default)(prev), [itemRef]) : [itemRef];
|
|
63
|
+
});
|
|
64
|
+
}, [setItems]);
|
|
65
|
+
var handleKeyDown = function handleKeyDown(event) {
|
|
66
|
+
if (!items) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
var key = event.key;
|
|
70
|
+
if (["Escape", "ArrowUp", "ArrowDown", "Tab"].includes(key)) {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
}
|
|
73
|
+
if (key === "Escape" || key === "Tab") {
|
|
74
|
+
onClose();
|
|
75
|
+
} else if (key === "ArrowUp") {
|
|
76
|
+
setHighlightedItem(function (prev) {
|
|
77
|
+
if (!prev) {
|
|
78
|
+
return items[0];
|
|
79
|
+
}
|
|
80
|
+
var index = items.indexOf(prev) - 1;
|
|
81
|
+
return items[index === -1 ? items.length - 1 : index];
|
|
82
|
+
});
|
|
83
|
+
} else if (key === "ArrowDown") {
|
|
84
|
+
setHighlightedItem(function (prev) {
|
|
85
|
+
if (!prev) {
|
|
86
|
+
return items[0];
|
|
87
|
+
}
|
|
88
|
+
return items[items.indexOf(prev) + 1];
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
var contextValue = (0, React.useMemo)(function () {
|
|
93
|
+
return {
|
|
94
|
+
registerItem: registerItem
|
|
95
|
+
};
|
|
96
|
+
}, [registerItem]);
|
|
97
|
+
(0, React.useEffect)(function () {
|
|
98
|
+
if (items && !highlightedItem) {
|
|
99
|
+
setHighlightedItem(items[0]);
|
|
100
|
+
}
|
|
101
|
+
if (highlightedItem && highlightedItem.current) {
|
|
102
|
+
highlightedItem.current.focus();
|
|
103
|
+
}
|
|
104
|
+
}, [items, highlightedItem]);
|
|
105
|
+
return /*#__PURE__*/React.createElement(DropDownContext.Provider, {
|
|
106
|
+
value: contextValue
|
|
107
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
108
|
+
className: "lexical-dropdown ".concat(showScroll ? "" : "no-scroll"),
|
|
109
|
+
ref: dropDownRef,
|
|
110
|
+
onKeyDown: handleKeyDown
|
|
111
|
+
}, children));
|
|
112
|
+
}
|
|
113
|
+
function DropDown(_ref3) {
|
|
114
|
+
var _ref3$disabled = _ref3.disabled,
|
|
115
|
+
disabled = _ref3$disabled === void 0 ? false : _ref3$disabled,
|
|
116
|
+
buttonLabel = _ref3.buttonLabel,
|
|
117
|
+
buttonAriaLabel = _ref3.buttonAriaLabel,
|
|
118
|
+
buttonClassName = _ref3.buttonClassName,
|
|
119
|
+
buttonIconClassName = _ref3.buttonIconClassName,
|
|
120
|
+
children = _ref3.children,
|
|
121
|
+
stopCloseOnClickSelf = _ref3.stopCloseOnClickSelf,
|
|
122
|
+
_ref3$showScroll = _ref3.showScroll,
|
|
123
|
+
showScroll = _ref3$showScroll === void 0 ? true : _ref3$showScroll;
|
|
124
|
+
var dropDownRef = (0, React.useRef)(null);
|
|
125
|
+
var buttonRef = (0, React.useRef)(null);
|
|
126
|
+
// Used to prevent flickering of the dropdown while calculating the dropdown position.
|
|
127
|
+
var _useState5 = (0, React.useState)(false),
|
|
128
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
129
|
+
positionIsCalculated = _useState6[0],
|
|
130
|
+
setPositionIsCalculated = _useState6[1];
|
|
131
|
+
var _useState7 = (0, React.useState)(false),
|
|
132
|
+
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
133
|
+
showDropDown = _useState8[0],
|
|
134
|
+
setShowDropDown = _useState8[1];
|
|
135
|
+
var handleClose = function handleClose() {
|
|
136
|
+
setPositionIsCalculated(false);
|
|
137
|
+
setShowDropDown(false);
|
|
138
|
+
if (buttonRef && buttonRef.current) {
|
|
139
|
+
buttonRef.current.focus();
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
(0, React.useEffect)(function () {
|
|
143
|
+
var button = buttonRef.current;
|
|
144
|
+
var dropDown = dropDownRef.current;
|
|
145
|
+
if (showDropDown && button && dropDown) {
|
|
146
|
+
dropDown.style.top = "44px";
|
|
147
|
+
dropDown.style.left = "".concat(button.offsetLeft, "px");
|
|
148
|
+
setPositionIsCalculated(true);
|
|
149
|
+
}
|
|
150
|
+
}, [dropDownRef, buttonRef, showDropDown]);
|
|
151
|
+
(0, React.useEffect)(function () {
|
|
152
|
+
var button = buttonRef.current;
|
|
153
|
+
if (button && showDropDown) {
|
|
154
|
+
var handle = function handle(event) {
|
|
155
|
+
var target = event.target;
|
|
156
|
+
if (stopCloseOnClickSelf) {
|
|
157
|
+
if (dropDownRef.current && dropDownRef.current.contains(target)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (!button.contains(target)) {
|
|
162
|
+
setShowDropDown(false);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
document.addEventListener("click", handle);
|
|
166
|
+
return function () {
|
|
167
|
+
document.removeEventListener("click", handle);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
return;
|
|
171
|
+
}, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf]);
|
|
172
|
+
var displayContainer = (0, React.useMemo)(function () {
|
|
173
|
+
// To prevent blinking, we show the container only when the dropdown position is calculated.
|
|
174
|
+
// Without this, window would be visible first on left (0px), and after a millisecond on the right side.
|
|
175
|
+
return positionIsCalculated ? {
|
|
176
|
+
display: "block"
|
|
177
|
+
} : {
|
|
178
|
+
display: "none"
|
|
179
|
+
};
|
|
180
|
+
}, [positionIsCalculated]);
|
|
181
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
|
|
182
|
+
style: {
|
|
183
|
+
position: "relative"
|
|
184
|
+
},
|
|
185
|
+
disabled: disabled,
|
|
186
|
+
"aria-label": buttonAriaLabel || buttonLabel,
|
|
187
|
+
className: buttonClassName,
|
|
188
|
+
onClick: function onClick() {
|
|
189
|
+
return setShowDropDown(!showDropDown);
|
|
190
|
+
},
|
|
191
|
+
ref: buttonRef
|
|
192
|
+
}, buttonIconClassName && /*#__PURE__*/React.createElement("span", {
|
|
193
|
+
className: buttonIconClassName
|
|
194
|
+
}), buttonLabel && /*#__PURE__*/React.createElement("span", {
|
|
195
|
+
className: "text dropdown-button-text"
|
|
196
|
+
}, buttonLabel), /*#__PURE__*/React.createElement("i", {
|
|
197
|
+
className: "chevron-down"
|
|
198
|
+
})), showDropDown && /*#__PURE__*/React.createElement("div", {
|
|
199
|
+
className: "lexical-dropdown-container",
|
|
200
|
+
style: displayContainer
|
|
201
|
+
}, /*#__PURE__*/React.createElement(DropDownItems, {
|
|
202
|
+
showScroll: showScroll,
|
|
203
|
+
dropDownRef: dropDownRef,
|
|
204
|
+
onClose: handleClose
|
|
205
|
+
}, children)));
|
|
206
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DropDownContext","React","createContext","DropDownItem","children","className","onClick","title","ref","useRef","dropDownContext","useContext","Error","registerItem","useEffect","current","DropDownItems","dropDownRef","showScroll","onClose","useState","items","setItems","highlightedItem","setHighlightedItem","useCallback","itemRef","prev","handleKeyDown","event","key","includes","preventDefault","index","indexOf","length","contextValue","useMemo","focus","DropDown","disabled","buttonLabel","buttonAriaLabel","buttonClassName","buttonIconClassName","stopCloseOnClickSelf","buttonRef","positionIsCalculated","setPositionIsCalculated","showDropDown","setShowDropDown","handleClose","button","dropDown","style","top","left","offsetLeft","handle","target","contains","document","addEventListener","removeEventListener","displayContainer","display","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} type=\"button\">\n {children}\n </button>\n );\n}\n\nfunction DropDownItems({\n children,\n dropDownRef,\n showScroll = true,\n onClose\n}: {\n children: React.ReactNode;\n dropDownRef?: React.Ref<HTMLDivElement>;\n showScroll?: boolean;\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\n className={`lexical-dropdown ${showScroll ? \"\" : \"no-scroll\"}`}\n ref={dropDownRef}\n onKeyDown={handleKeyDown}\n >\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 showScroll = true\n}: {\n disabled?: boolean;\n buttonAriaLabel?: string;\n buttonClassName: string;\n buttonIconClassName?: string;\n buttonLabel?: string;\n children: ReactNode;\n stopCloseOnClickSelf?: boolean;\n showScroll?: boolean;\n}): JSX.Element {\n const dropDownRef = useRef<HTMLDivElement>(null);\n const buttonRef = useRef<HTMLButtonElement>(null);\n // Used to prevent flickering of the dropdown while calculating the dropdown position.\n const [positionIsCalculated, setPositionIsCalculated] = useState(false);\n const [showDropDown, setShowDropDown] = useState(false);\n\n const handleClose = () => {\n setPositionIsCalculated(false);\n setShowDropDown(false);\n if (buttonRef && buttonRef.current) {\n buttonRef.current.focus();\n }\n };\n\n useEffect(() => {\n const button = buttonRef.current;\n const dropDown = dropDownRef.current;\n\n if (showDropDown && button && dropDown) {\n dropDown.style.top = \"44px\";\n dropDown.style.left = `${button.offsetLeft}px`;\n setPositionIsCalculated(true);\n }\n }, [dropDownRef, buttonRef, showDropDown]);\n\n useEffect(() => {\n const button = buttonRef.current;\n if (button && showDropDown) {\n const handle = (event: MouseEvent) => {\n const target = event.target;\n if (stopCloseOnClickSelf) {\n if (dropDownRef.current && dropDownRef.current.contains(target as Node)) {\n return;\n }\n }\n\n if (!button.contains(target as Node)) {\n setShowDropDown(false);\n }\n };\n document.addEventListener(\"click\", handle);\n return () => {\n document.removeEventListener(\"click\", handle);\n };\n }\n return;\n }, [dropDownRef, buttonRef, showDropDown, stopCloseOnClickSelf]);\n\n const displayContainer = useMemo(() => {\n // To prevent blinking, we show the container only when the dropdown position is calculated.\n // Without this, window would be visible first on left (0px), and after a millisecond on the right side.\n return positionIsCalculated ? { display: \"block\" } : { display: \"none\" };\n }, [positionIsCalculated]);\n\n return (\n <>\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 </button>\n {showDropDown && (\n <div className={\"lexical-dropdown-container\"} style={displayContainer}>\n <DropDownItems\n showScroll={showScroll}\n dropDownRef={dropDownRef}\n onClose={handleClose}\n >\n {children}\n </DropDownItems>\n </div>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;AAQA;AARA;AACA;AACA;AACA;AACA;AACA;AACA;;AASA,IAAMA,eAAe,gBAAGC,KAAK,CAACC,aAAa,CAA6B,IAAI,CAAC;AAEtE,SAASC,YAAY,OAUzB;EAAA,IATCC,QAAQ,QAARA,QAAQ;IACRC,SAAS,QAATA,SAAS;IACTC,OAAO,Q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AO,EAAE;IAAO,CAAC;EAC5E,CAAC,EAAE,CAAClB,oBAAoB,CAAC,CAAC;EAE1B,oBACI,uDACI;IACI,KAAK,EAAE;MAAEmB,QAAQ,EAAE;IAAW,CAAE;IAChC,QAAQ,EAAE1B,QAAS;IACnB,cAAYE,eAAe,IAAID,WAAY;IAC3C,SAAS,EAAEE,eAAgB;IAC3B,OAAO,EAAE;MAAA,OAAMO,eAAe,CAAC,CAACD,YAAY,CAAC;IAAA,CAAC;IAC9C,GAAG,EAAEH;EAAU,GAEdF,mBAAmB,iBAAI;IAAM,SAAS,EAAEA;EAAoB,EAAG,EAC/DH,WAAW,iBAAI;IAAM,SAAS,EAAC;EAA2B,GAAEA,WAAW,CAAQ,eAChF;IAAG,SAAS,EAAC;EAAc,EAAG,CACzB,EACRQ,YAAY,iBACT;IAAK,SAAS,EAAE,4BAA6B;IAAC,KAAK,EAAEe;EAAiB,gBAClE,oBAAC,aAAa;IACV,UAAU,EAAE9C,UAAW;IACvB,WAAW,EAAED,WAAY;IACzB,OAAO,EAAEkC;EAAY,GAEpB/C,QAAQ,CACG,CAEvB,CACF;AAEX"}
|
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":["PREVIEW_CACHE","URL_MATCHER","useSuspenseRequest","url","cached","match","preview","fetch","encodeURI","then","response","json","catch","Promise","LinkPreviewContent","img","title","domain","description","Glimmer","props","animationDelay","String","index","style","LinkPreview","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":";;;;;;;;;AAQA;AAEA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAcA;AACA,IAAMA,aAAsE,GAAG,CAAC,CAAC;AAEjF,IAAMC,WAAW,GACb,iHAAiH;AAErH,SAASC,kBAAkB,CAACC,GAAW,EAAE;EACrC,IAAIC,MAAM,GAAGJ,aAAa,CAACG,GAAG,CAAC;EAE/B,IAAI,CAACA,GAAG,CAACE,KAAK,CAACJ,WAAW,CAAC,EAAE;IACzB,OAAO;MAAEK,OAAO,EAAE;IAAK,CAAC;EAC5B;EAEA,IAAI,CAACF,MAAM,EAAE;IACTA,MAAM,GAAGJ,aAAa,CAACG,GAAG,CAAC,GAAGI,KAAK,iCAA0BC,SAAS,CAACL,GAAG,CAAC,EAAG,CACzEM,IAAI,CAAC,UAAAC,QAAQ;MAAA,OAAIA,QAAQ,CAACC,IAAI,EAAE;IAAA,EAAC,CACjCF,IAAI,CAAC,UAAAH,OAAO,EAAI;MACbN,aAAa,CAACG,GAAG,CAAC,GAAGG,OAAO;MAC5B,OAAOA,OAAO;IAClB,CAAC,CAAC,CACDM,KAAK,CAAC,YAAM;MACTZ,aAAa,CAACG,GAAG,CAAC,GAAG;QAAEG,OAAO,EAAE;MAAK,CAAC;IAC1C,CAA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G,eAChD,oBAAC,OAAO;MAAC,KAAK,EAAE;QAAEC,KAAK,EAAE;MAAM,CAAE;MAAC,KAAK,EAAE;IAAE,EAAG,eAC9C,oBAAC,OAAO;MAAC,KAAK,EAAE;QAAEA,KAAK,EAAE;MAAM,CAAE;MAAC,KAAK,EAAE;IAAE,EAAG;EAErD,gBAED,oBAAC,kBAAkB;IAAC,GAAG,EAAExB;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":["Placeholder","children","className"],"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":";;;;;;;AAQA;AAEA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAOO,SAASA,WAAW,OAMX;EAAA,IALZC,QAAQ,QAARA,QAAQ;IACRC,SAAS,QAATA,SAAS;EAKT,oBAAO;IAAK,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 {};
|
package/ui/TextInput.js
ADDED
|
@@ -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":["TextInput","label","value","onChange","placeholder","dataTestId","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":";;;;;;;AAQA;AAEA;AAVA;AACA;AACA;AACA;AACA;AACA;AACA;;AAce,SAASA,SAAS,OAMV;EAAA,IALnBC,KAAK,QAALA,KAAK;IACLC,KAAK,QAALA,KAAK;IACLC,SAAQ,QAARA,QAAQ;IAAA,wBACRC,WAAW;IAAXA,WAAW,iCAAG,EAAE;IACAC,UAAU,QAA1B,cAAc;EAEd,oBACI;IAAK,SAAS,EAAC;EAAgB,gBAC3B;IAAO,SAAS,EAAC;EAAc,GAAEJ,KAAK,CAAS,eAC/C;IACI,IAAI,EAAC,MAAM;IACX,SAAS,EAAC,cAAc;IACxB,WAAW,EAAEG,WAAY;IACzB,KAAK,EAAEF,KAAM;IACb,QAAQ,EAAE,kBAAAI,CAAC,EAAI;MACXH,SAAQ,CAACG,CAAC,CAACC,MAAM,CAACL,KAAK,CAAC;IAC5B,CAAE;IACF,gBAAcG;EAAW,EAC3B,CACA;AAEd"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as 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
|
+
stopCloseOnClickSelf?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const ToolbarActionDialog: React.FC<ToolbarActionDialogProps>;
|
|
12
|
+
export {};
|