5htp-core 0.4.8-3 → 0.4.9-1

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 (186) hide show
  1. package/package.json +5 -1
  2. package/src/client/components/Form.ts +2 -6
  3. package/src/client/components/button.tsx +2 -1
  4. package/src/client/components/containers/Popover/index.tsx +2 -2
  5. package/src/client/components/dropdown/index.tsx +16 -6
  6. package/src/client/components/input/Slider/index.tsx +0 -2
  7. package/src/client/components/inputv3/Rte/Editor.tsx +271 -0
  8. package/src/client/components/inputv3/Rte/ToolbarPlugin/BlockFormat.tsx +220 -0
  9. package/src/client/components/inputv3/Rte/ToolbarPlugin/ElementFormat.tsx +107 -0
  10. package/src/client/components/inputv3/Rte/ToolbarPlugin/index.tsx +768 -0
  11. package/src/client/components/inputv3/Rte/appSettings.ts +36 -0
  12. package/src/client/components/inputv3/Rte/context/FlashMessageContext.tsx +68 -0
  13. package/src/client/components/inputv3/Rte/context/SettingsContext.tsx +71 -0
  14. package/src/client/components/inputv3/Rte/context/SharedAutocompleteContext.tsx +71 -0
  15. package/src/client/components/inputv3/Rte/context/SharedHistoryContext.tsx +35 -0
  16. package/src/client/components/inputv3/Rte/currentEditor.ts +3 -1
  17. package/src/client/components/inputv3/Rte/hooks/useFlashMessage.tsx +16 -0
  18. package/src/client/components/inputv3/Rte/hooks/useReport.ts +67 -0
  19. package/src/client/components/inputv3/Rte/images/emoji/1F600.png +0 -0
  20. package/src/client/components/inputv3/Rte/images/emoji/1F641.png +0 -0
  21. package/src/client/components/inputv3/Rte/images/emoji/1F642.png +0 -0
  22. package/src/client/components/inputv3/Rte/images/emoji/2764.png +0 -0
  23. package/src/client/components/inputv3/Rte/images/emoji/LICENSE.md +5 -0
  24. package/src/client/components/inputv3/Rte/images/icons/draggable-block-menu.svg +1 -0
  25. package/src/client/components/inputv3/Rte/images/icons/prettier-error.svg +1 -0
  26. package/src/client/components/inputv3/Rte/images/icons/prettier.svg +1 -0
  27. package/src/client/components/inputv3/Rte/images/image/LICENSE.md +5 -0
  28. package/src/client/components/inputv3/Rte/images/image-broken.svg +4 -0
  29. package/src/client/components/inputv3/Rte/images/logo.svg +1 -0
  30. package/src/client/components/inputv3/Rte/index.tsx +25 -94
  31. package/src/client/components/inputv3/Rte/nodes/AutocompleteNode.tsx +119 -0
  32. package/src/client/components/inputv3/Rte/nodes/EmojiNode.tsx +102 -0
  33. package/src/client/components/inputv3/Rte/nodes/EquationComponent.tsx +141 -0
  34. package/src/client/components/inputv3/Rte/nodes/EquationNode.tsx +174 -0
  35. package/src/client/components/inputv3/Rte/nodes/FigmaNode.tsx +135 -0
  36. package/src/client/components/inputv3/Rte/nodes/ImageComponent.tsx +468 -0
  37. package/src/client/components/inputv3/Rte/nodes/ImageNode.css +43 -0
  38. package/src/client/components/inputv3/Rte/nodes/ImageNode.tsx +266 -0
  39. package/src/client/components/inputv3/Rte/nodes/InlineImageNode/InlineImageComponent.tsx +402 -0
  40. package/src/client/components/inputv3/Rte/nodes/InlineImageNode/InlineImageNode.css +94 -0
  41. package/src/client/components/inputv3/Rte/nodes/InlineImageNode/InlineImageNode.tsx +294 -0
  42. package/src/client/components/inputv3/Rte/nodes/KeywordNode.ts +67 -0
  43. package/src/client/components/inputv3/Rte/nodes/LayoutContainerNode.ts +137 -0
  44. package/src/client/components/inputv3/Rte/nodes/LayoutItemNode.ts +71 -0
  45. package/src/client/components/inputv3/Rte/nodes/MentionNode.ts +130 -0
  46. package/src/client/components/inputv3/Rte/nodes/PageBreakNode/index.css +62 -0
  47. package/src/client/components/inputv3/Rte/nodes/PageBreakNode/index.tsx +170 -0
  48. package/src/client/components/inputv3/Rte/nodes/PlaygroundNodes.ts +76 -0
  49. package/src/client/components/inputv3/Rte/nodes/PollComponent.tsx +249 -0
  50. package/src/client/components/inputv3/Rte/nodes/PollNode.css +187 -0
  51. package/src/client/components/inputv3/Rte/nodes/PollNode.tsx +209 -0
  52. package/src/client/components/inputv3/Rte/nodes/StickyComponent.tsx +261 -0
  53. package/src/client/components/inputv3/Rte/nodes/StickyNode.css +37 -0
  54. package/src/client/components/inputv3/Rte/nodes/StickyNode.tsx +150 -0
  55. package/src/client/components/inputv3/Rte/nodes/TweetNode.tsx +223 -0
  56. package/src/client/components/inputv3/Rte/nodes/YouTubeNode.tsx +184 -0
  57. package/src/client/components/inputv3/Rte/plugins/ActionsPlugin/index.tsx +334 -0
  58. package/src/client/components/inputv3/Rte/plugins/AutoEmbedPlugin/index.tsx +352 -0
  59. package/src/client/components/inputv3/Rte/plugins/AutoLinkPlugin/index.tsx +32 -0
  60. package/src/client/components/inputv3/Rte/plugins/AutocompletePlugin/index.tsx +2529 -0
  61. package/src/client/components/inputv3/Rte/plugins/CodeActionMenuPlugin/components/CopyButton/index.tsx +70 -0
  62. package/src/client/components/inputv3/Rte/plugins/CodeActionMenuPlugin/components/PrettierButton/index.css +14 -0
  63. package/src/client/components/inputv3/Rte/plugins/CodeActionMenuPlugin/components/PrettierButton/index.tsx +156 -0
  64. package/src/client/components/inputv3/Rte/plugins/CodeActionMenuPlugin/index.css +54 -0
  65. package/src/client/components/inputv3/Rte/plugins/CodeActionMenuPlugin/index.tsx +190 -0
  66. package/src/client/components/inputv3/Rte/plugins/CodeActionMenuPlugin/utils.ts +33 -0
  67. package/src/client/components/inputv3/Rte/plugins/CodeHighlightPlugin/index.ts +21 -0
  68. package/src/client/components/inputv3/Rte/plugins/CollapsiblePlugin/Collapsible.css +57 -0
  69. package/src/client/components/inputv3/Rte/plugins/CollapsiblePlugin/CollapsibleContainerNode.ts +168 -0
  70. package/src/client/components/inputv3/Rte/plugins/CollapsiblePlugin/CollapsibleContentNode.ts +127 -0
  71. package/src/client/components/inputv3/Rte/plugins/CollapsiblePlugin/CollapsibleTitleNode.ts +152 -0
  72. package/src/client/components/inputv3/Rte/plugins/CollapsiblePlugin/CollapsibleUtils.ts +17 -0
  73. package/src/client/components/inputv3/Rte/plugins/CollapsiblePlugin/index.ts +284 -0
  74. package/src/client/components/inputv3/Rte/plugins/ComponentPickerPlugin/index.tsx +370 -0
  75. package/src/client/components/inputv3/Rte/plugins/ContextMenuPlugin/index.tsx +270 -0
  76. package/src/client/components/inputv3/Rte/plugins/DocsPlugin/index.tsx +20 -0
  77. package/src/client/components/inputv3/Rte/plugins/DragDropPastePlugin/index.ts +51 -0
  78. package/src/client/components/inputv3/Rte/plugins/DraggableBlockPlugin/index.css +36 -0
  79. package/src/client/components/inputv3/Rte/plugins/DraggableBlockPlugin/index.tsx +43 -0
  80. package/src/client/components/inputv3/Rte/plugins/EmojiPickerPlugin/index.tsx +198 -0
  81. package/src/client/components/inputv3/Rte/plugins/EmojisPlugin/index.ts +75 -0
  82. package/src/client/components/inputv3/Rte/plugins/EquationsPlugin/index.tsx +82 -0
  83. package/src/client/components/inputv3/Rte/plugins/FigmaPlugin/index.tsx +40 -0
  84. package/src/client/components/inputv3/Rte/plugins/FloatingLinkEditorPlugin/index.css +41 -0
  85. package/src/client/components/inputv3/Rte/plugins/FloatingLinkEditorPlugin/index.tsx +393 -0
  86. package/src/client/components/inputv3/Rte/plugins/FloatingTextFormatToolbarPlugin/index.css +141 -0
  87. package/src/client/components/inputv3/Rte/plugins/FloatingTextFormatToolbarPlugin/index.tsx +388 -0
  88. package/src/client/components/inputv3/Rte/plugins/ImagesPlugin/index.tsx +350 -0
  89. package/src/client/components/inputv3/Rte/plugins/InlineImagePlugin/index.tsx +336 -0
  90. package/src/client/components/inputv3/Rte/plugins/KeywordsPlugin/index.ts +56 -0
  91. package/src/client/components/inputv3/Rte/plugins/LayoutPlugin/InsertLayoutDialog.tsx +58 -0
  92. package/src/client/components/inputv3/Rte/plugins/LayoutPlugin/LayoutPlugin.tsx +219 -0
  93. package/src/client/components/inputv3/Rte/plugins/LinkPlugin/index.tsx +34 -0
  94. package/src/client/components/inputv3/Rte/plugins/ListMaxIndentLevelPlugin/index.ts +85 -0
  95. package/src/client/components/inputv3/Rte/plugins/MarkdownShortcutPlugin/index.tsx +16 -0
  96. package/src/client/components/inputv3/Rte/plugins/MarkdownTransformers/index.ts +324 -0
  97. package/src/client/components/inputv3/Rte/plugins/MaxLengthPlugin/index.tsx +53 -0
  98. package/src/client/components/inputv3/Rte/plugins/MentionsPlugin/index.tsx +696 -0
  99. package/src/client/components/inputv3/Rte/plugins/PageBreakPlugin/index.tsx +57 -0
  100. package/src/client/components/inputv3/Rte/plugins/PasteLogPlugin/index.tsx +54 -0
  101. package/src/client/components/inputv3/Rte/plugins/PollPlugin/index.tsx +86 -0
  102. package/src/client/components/inputv3/Rte/plugins/SpeechToTextPlugin/index.ts +125 -0
  103. package/src/client/components/inputv3/Rte/plugins/StickyPlugin/index.ts +22 -0
  104. package/src/client/components/inputv3/Rte/plugins/TabFocusPlugin/index.tsx +65 -0
  105. package/src/client/components/inputv3/Rte/plugins/TableActionMenuPlugin/index.tsx +773 -0
  106. package/src/client/components/inputv3/Rte/plugins/TableCellResizer/index.css +12 -0
  107. package/src/client/components/inputv3/Rte/plugins/TableCellResizer/index.tsx +436 -0
  108. package/src/client/components/inputv3/Rte/plugins/TableHoverActionsPlugin/index.tsx +287 -0
  109. package/src/client/components/inputv3/Rte/plugins/TableOfContentsPlugin/index.css +95 -0
  110. package/src/client/components/inputv3/Rte/plugins/TableOfContentsPlugin/index.tsx +197 -0
  111. package/src/client/components/inputv3/Rte/plugins/TablePlugin.tsx +178 -0
  112. package/src/client/components/inputv3/Rte/plugins/TestRecorderPlugin/index.tsx +468 -0
  113. package/src/client/components/inputv3/Rte/plugins/TreeViewPlugin/index.tsx +26 -0
  114. package/src/client/components/inputv3/Rte/plugins/TwitterPlugin/index.ts +41 -0
  115. package/src/client/components/inputv3/Rte/plugins/TypingPerfPlugin/index.ts +117 -0
  116. package/src/client/components/inputv3/Rte/plugins/YouTubePlugin/index.ts +41 -0
  117. package/src/client/components/inputv3/Rte/shared/canUseDOM.ts +4 -0
  118. package/src/client/components/inputv3/Rte/shared/caretFromPoint.ts +40 -0
  119. package/src/client/components/inputv3/Rte/shared/environment.ts +56 -0
  120. package/src/client/components/inputv3/Rte/shared/invariant.ts +26 -0
  121. package/src/client/components/inputv3/Rte/shared/normalizeClassNames.ts +21 -0
  122. package/src/client/components/inputv3/Rte/shared/react-test-utils.ts +18 -0
  123. package/src/client/components/inputv3/Rte/shared/reactPatches.ts +22 -0
  124. package/src/client/components/inputv3/Rte/shared/simpleDiffWithCursor.ts +49 -0
  125. package/src/client/components/inputv3/Rte/shared/useLayoutEffect.ts +19 -0
  126. package/src/client/components/inputv3/Rte/shared/warnOnlyOnce.ts +20 -0
  127. package/src/client/components/inputv3/Rte/style.less +30 -60
  128. package/src/client/components/inputv3/Rte/themes/CommentEditorTheme.css +13 -0
  129. package/src/client/components/inputv3/Rte/themes/CommentEditorTheme.ts +20 -0
  130. package/src/client/components/inputv3/Rte/themes/PlaygroundEditorTheme.css +447 -0
  131. package/src/client/components/inputv3/Rte/themes/PlaygroundEditorTheme.ts +120 -0
  132. package/src/client/components/inputv3/Rte/themes/StickyEditorTheme.css +13 -0
  133. package/src/client/components/inputv3/Rte/themes/StickyEditorTheme.ts +20 -0
  134. package/src/client/components/inputv3/Rte/ui/ColorPicker.css +88 -0
  135. package/src/client/components/inputv3/Rte/ui/ColorPicker.tsx +365 -0
  136. package/src/client/components/inputv3/Rte/ui/ContentEditable.css +44 -0
  137. package/src/client/components/inputv3/Rte/ui/ContentEditable.tsx +36 -0
  138. package/src/client/components/inputv3/Rte/ui/DropDown.tsx +259 -0
  139. package/src/client/components/inputv3/Rte/ui/DropdownColorPicker.tsx +41 -0
  140. package/src/client/components/inputv3/Rte/ui/EquationEditor.css +38 -0
  141. package/src/client/components/inputv3/Rte/ui/EquationEditor.tsx +56 -0
  142. package/src/client/components/inputv3/Rte/ui/FileInput.tsx +38 -0
  143. package/src/client/components/inputv3/Rte/ui/FlashMessage.css +28 -0
  144. package/src/client/components/inputv3/Rte/ui/FlashMessage.tsx +29 -0
  145. package/src/client/components/inputv3/Rte/ui/ImageResizer.tsx +316 -0
  146. package/src/client/components/inputv3/Rte/ui/Input.css +32 -0
  147. package/src/client/components/inputv3/Rte/ui/KatexRenderer.tsx +54 -0
  148. package/src/client/components/inputv3/Rte/ui/Switch.tsx +36 -0
  149. package/src/client/components/inputv3/Rte/utils/docSerialization.ts +77 -0
  150. package/src/client/components/inputv3/Rte/utils/emoji-list.ts +16615 -0
  151. package/src/client/components/inputv3/Rte/utils/getDOMRangeRect.ts +27 -0
  152. package/src/client/components/inputv3/Rte/utils/getSelectedNode.ts +27 -0
  153. package/src/client/components/inputv3/Rte/utils/guard.ts +10 -0
  154. package/src/client/components/inputv3/Rte/utils/isMobileWidth.ts +7 -0
  155. package/src/client/components/inputv3/Rte/utils/joinClasses.ts +13 -0
  156. package/src/client/components/inputv3/Rte/utils/setFloatingElemPosition.ts +51 -0
  157. package/src/client/components/inputv3/Rte/utils/setFloatingElemPositionForLinkEditor.ts +46 -0
  158. package/src/client/components/inputv3/Rte/utils/swipe.ts +127 -0
  159. package/src/client/components/inputv3/Rte/utils/url.ts +38 -0
  160. package/src/client/components/inputv3/base.tsx +8 -5
  161. package/src/client/components/inputv3/index.tsx +1 -1
  162. package/src/common/data/rte/nodes.ts +60 -9
  163. package/src/common/validation/index.ts +21 -2
  164. package/src/common/validation/schema.ts +27 -10
  165. package/src/common/validation/validator.ts +12 -4
  166. package/src/common/validation/validators.ts +108 -66
  167. package/src/server/services/router/http/multipart.ts +0 -1
  168. package/src/server/services/schema/index.ts +26 -4
  169. package/src/server/services/schema/request.ts +3 -2
  170. package/src/server/services/schema/rte.ts +110 -0
  171. package/src/server/utils/rte.ts +7 -4
  172. package/src/client/components/inputv3/Rte/ExampleTheme.tsx +0 -42
  173. package/src/client/components/inputv3/Rte/ToolbarPlugin.tsx +0 -167
  174. package/src/client/components/inputv3/Rte/icons/LICENSE.md +0 -5
  175. package/src/client/components/inputv3/Rte/icons/arrow-clockwise.svg +0 -4
  176. package/src/client/components/inputv3/Rte/icons/arrow-counterclockwise.svg +0 -4
  177. package/src/client/components/inputv3/Rte/icons/journal-text.svg +0 -5
  178. package/src/client/components/inputv3/Rte/icons/justify.svg +0 -3
  179. package/src/client/components/inputv3/Rte/icons/text-center.svg +0 -3
  180. package/src/client/components/inputv3/Rte/icons/text-left.svg +0 -3
  181. package/src/client/components/inputv3/Rte/icons/text-paragraph.svg +0 -3
  182. package/src/client/components/inputv3/Rte/icons/text-right.svg +0 -3
  183. package/src/client/components/inputv3/Rte/icons/type-bold.svg +0 -3
  184. package/src/client/components/inputv3/Rte/icons/type-italic.svg +0 -3
  185. package/src/client/components/inputv3/Rte/icons/type-strikethrough.svg +0 -3
  186. package/src/client/components/inputv3/Rte/icons/type-underline.svg +0 -3
@@ -0,0 +1,36 @@
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
+ export const DEFAULT_SETTINGS = {
10
+ disableBeforeInput: false,
11
+ emptyEditor: false,
12
+ hasLinkAttributes: false,
13
+ isAutocomplete: false,
14
+ isCharLimit: false,
15
+ isCharLimitUtf8: false,
16
+ isCollab: false,
17
+ isMaxLength: false,
18
+ isRichText: true,
19
+ measureTypingPerf: false,
20
+ shouldPreserveNewLinesInMarkdown: false,
21
+ shouldUseLexicalContextMenu: false,
22
+ showNestedEditorTreeView: false,
23
+ showTableOfContents: false,
24
+ showTreeView: true,
25
+ tableCellBackgroundColor: true,
26
+ tableCellMerge: true,
27
+ } as const;
28
+
29
+ // These are mutated in setupEnv
30
+ export const INITIAL_SETTINGS: Record<SettingName, boolean> = {
31
+ ...DEFAULT_SETTINGS,
32
+ };
33
+
34
+ export type SettingName = keyof typeof DEFAULT_SETTINGS;
35
+
36
+ export type Settings = typeof INITIAL_SETTINGS;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import {
10
+ createContext,
11
+ ReactNode,
12
+ useCallback,
13
+ useContext,
14
+ useEffect,
15
+ useState,
16
+ } from 'react';
17
+
18
+ import FlashMessage from '../ui/FlashMessage';
19
+
20
+ export type ShowFlashMessage = (
21
+ message?: React.ReactNode,
22
+ duration?: number,
23
+ ) => void;
24
+
25
+ interface FlashMessageProps {
26
+ message?: React.ReactNode;
27
+ duration?: number;
28
+ }
29
+
30
+ const Context = createContext<ShowFlashMessage | undefined>(undefined);
31
+ const INITIAL_STATE: FlashMessageProps = {};
32
+ const DEFAULT_DURATION = 1000;
33
+
34
+ export const FlashMessageContext = ({
35
+ children,
36
+ }: {
37
+ children: ReactNode;
38
+ }): JSX.Element => {
39
+ const [props, setProps] = useState(INITIAL_STATE);
40
+ const showFlashMessage = useCallback<ShowFlashMessage>(
41
+ (message, duration) =>
42
+ setProps(message ? {duration, message} : INITIAL_STATE),
43
+ [],
44
+ );
45
+ useEffect(() => {
46
+ if (props.message) {
47
+ const timeoutId = setTimeout(
48
+ () => setProps(INITIAL_STATE),
49
+ props.duration ?? DEFAULT_DURATION,
50
+ );
51
+ return () => clearTimeout(timeoutId);
52
+ }
53
+ }, [props]);
54
+ return (
55
+ <Context.Provider value={showFlashMessage}>
56
+ {children}
57
+ {props.message && <FlashMessage>{props.message}</FlashMessage>}
58
+ </Context.Provider>
59
+ );
60
+ };
61
+
62
+ export const useFlashMessageContext = (): ShowFlashMessage => {
63
+ const ctx = useContext(Context);
64
+ if (!ctx) {
65
+ throw new Error('Missing FlashMessageContext');
66
+ }
67
+ return ctx;
68
+ };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import type {SettingName} from '../appSettings';
10
+
11
+ import * as React from 'react';
12
+ import {
13
+ createContext,
14
+ ReactNode,
15
+ useCallback,
16
+ useContext,
17
+ useMemo,
18
+ useState,
19
+ } from 'react';
20
+
21
+ import {DEFAULT_SETTINGS, INITIAL_SETTINGS} from '../appSettings';
22
+
23
+ type SettingsContextShape = {
24
+ setOption: (name: SettingName, value: boolean) => void;
25
+ settings: Record<SettingName, boolean>;
26
+ };
27
+
28
+ const Context: React.Context<SettingsContextShape> = createContext({
29
+ setOption: (name: SettingName, value: boolean) => {
30
+ return;
31
+ },
32
+ settings: INITIAL_SETTINGS,
33
+ });
34
+
35
+ export const SettingsContext = ({
36
+ children,
37
+ }: {
38
+ children: ReactNode;
39
+ }): JSX.Element => {
40
+ const [settings, setSettings] = useState(INITIAL_SETTINGS);
41
+
42
+ const setOption = useCallback((setting: SettingName, value: boolean) => {
43
+ setSettings((options) => ({
44
+ ...options,
45
+ [setting]: value,
46
+ }));
47
+ setURLParam(setting, value);
48
+ }, []);
49
+
50
+ const contextValue = useMemo(() => {
51
+ return {setOption, settings};
52
+ }, [setOption, settings]);
53
+
54
+ return <Context.Provider value={contextValue}>{children}</Context.Provider>;
55
+ };
56
+
57
+ export const useSettings = (): SettingsContextShape => {
58
+ return useContext(Context);
59
+ };
60
+
61
+ function setURLParam(param: SettingName, value: null | boolean) {
62
+ const url = new URL(window.location.href);
63
+ const params = new URLSearchParams(url.search);
64
+ if (value !== DEFAULT_SETTINGS[param]) {
65
+ params.set(param, String(value));
66
+ } else {
67
+ params.delete(param);
68
+ }
69
+ url.search = params.toString();
70
+ window.history.pushState(null, '', url.toString());
71
+ }
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import * as React from 'react';
10
+ import {
11
+ createContext,
12
+ ReactNode,
13
+ useContext,
14
+ useEffect,
15
+ useMemo,
16
+ useState,
17
+ } from 'react';
18
+
19
+ type Suggestion = null | string;
20
+ type CallbackFn = (newSuggestion: Suggestion) => void;
21
+ type SubscribeFn = (callbackFn: CallbackFn) => () => void;
22
+ type PublishFn = (newSuggestion: Suggestion) => void;
23
+ type ContextShape = [SubscribeFn, PublishFn];
24
+ type HookShape = [suggestion: Suggestion, setSuggestion: PublishFn];
25
+
26
+ const Context: React.Context<ContextShape> = createContext([
27
+ (_cb) => () => {
28
+ return;
29
+ },
30
+ (_newSuggestion: Suggestion) => {
31
+ return;
32
+ },
33
+ ]);
34
+
35
+ export const SharedAutocompleteContext = ({
36
+ children,
37
+ }: {
38
+ children: ReactNode;
39
+ }): JSX.Element => {
40
+ const context: ContextShape = useMemo(() => {
41
+ let suggestion: Suggestion | null = null;
42
+ const listeners: Set<CallbackFn> = new Set();
43
+ return [
44
+ (cb: (newSuggestion: Suggestion) => void) => {
45
+ cb(suggestion);
46
+ listeners.add(cb);
47
+ return () => {
48
+ listeners.delete(cb);
49
+ };
50
+ },
51
+ (newSuggestion: Suggestion) => {
52
+ suggestion = newSuggestion;
53
+ for (const listener of listeners) {
54
+ listener(newSuggestion);
55
+ }
56
+ },
57
+ ];
58
+ }, []);
59
+ return <Context.Provider value={context}>{children}</Context.Provider>;
60
+ };
61
+
62
+ export const useSharedAutocompleteContext = (): HookShape => {
63
+ const [subscribe, publish]: ContextShape = useContext(Context);
64
+ const [suggestion, setSuggestion] = useState<Suggestion>(null);
65
+ useEffect(() => {
66
+ return subscribe((newSuggestion: Suggestion) => {
67
+ setSuggestion(newSuggestion);
68
+ });
69
+ }, [subscribe]);
70
+ return [suggestion, publish];
71
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import type {HistoryState} from '@lexical/react/LexicalHistoryPlugin';
10
+
11
+ import {createEmptyHistoryState} from '@lexical/react/LexicalHistoryPlugin';
12
+ import * as React from 'react';
13
+ import {createContext, ReactNode, useContext, useMemo} from 'react';
14
+
15
+ type ContextShape = {
16
+ historyState?: HistoryState;
17
+ };
18
+
19
+ const Context: React.Context<ContextShape> = createContext({});
20
+
21
+ export const SharedHistoryContext = ({
22
+ children,
23
+ }: {
24
+ children: ReactNode;
25
+ }): JSX.Element => {
26
+ const historyContext = useMemo(
27
+ () => ({historyState: createEmptyHistoryState()}),
28
+ [],
29
+ );
30
+ return <Context.Provider value={historyContext}>{children}</Context.Provider>;
31
+ };
32
+
33
+ export const useSharedHistoryContext = (): ContextShape => {
34
+ return useContext(Context);
35
+ };
@@ -1,6 +1,7 @@
1
1
  import { createEditor, LexicalEditor } from 'lexical';
2
2
  import { $generateHtmlFromNodes } from '@lexical/html';
3
3
  import editorNodes from '@common/data/rte/nodes';
4
+ import ExampleTheme from '@client/components/inputv3/Rte/themes/PlaygroundEditorTheme';
4
5
 
5
6
  class RichEditorUtils {
6
7
 
@@ -16,7 +17,8 @@ class RichEditorUtils {
16
17
  if (!this.virtualEditor) {
17
18
  // Create a headless Lexical editor instance
18
19
  this.virtualEditor = createEditor({
19
- nodes: editorNodes
20
+ nodes: editorNodes,
21
+ theme: ExampleTheme,
20
22
  });
21
23
  }
22
24
 
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import {
10
+ type ShowFlashMessage,
11
+ useFlashMessageContext,
12
+ } from '../context/FlashMessageContext';
13
+
14
+ export default function useFlashMessage(): ShowFlashMessage {
15
+ return useFlashMessageContext();
16
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import {useCallback, useEffect, useRef} from 'react';
10
+
11
+ const getElement = (): HTMLElement => {
12
+ let element = document.getElementById('report-container');
13
+
14
+ if (element === null) {
15
+ element = document.createElement('div');
16
+ element.id = 'report-container';
17
+ element.style.position = 'fixed';
18
+ element.style.top = '50%';
19
+ element.style.left = '50%';
20
+ element.style.fontSize = '32px';
21
+ element.style.transform = 'translate(-50%, -50px)';
22
+ element.style.padding = '20px';
23
+ element.style.background = 'rgba(240, 240, 240, 0.4)';
24
+ element.style.borderRadius = '20px';
25
+
26
+ if (document.body) {
27
+ document.body.appendChild(element);
28
+ }
29
+ }
30
+
31
+ return element;
32
+ };
33
+
34
+ export default function useReport(): (
35
+ arg0: string,
36
+ ) => ReturnType<typeof setTimeout> {
37
+ const timer = useRef<ReturnType<typeof setTimeout> | null>(null);
38
+ const cleanup = useCallback(() => {
39
+ if (timer.current !== null) {
40
+ clearTimeout(timer.current);
41
+ timer.current = null;
42
+ }
43
+
44
+ if (document.body) {
45
+ document.body.removeChild(getElement());
46
+ }
47
+ }, []);
48
+
49
+ useEffect(() => {
50
+ return cleanup;
51
+ }, [cleanup]);
52
+
53
+ return useCallback(
54
+ (content) => {
55
+ // eslint-disable-next-line no-console
56
+ console.log(content);
57
+ const element = getElement();
58
+ if (timer.current !== null) {
59
+ clearTimeout(timer.current);
60
+ }
61
+ element.innerHTML = content;
62
+ timer.current = setTimeout(cleanup, 1000);
63
+ return timer.current;
64
+ },
65
+ [cleanup],
66
+ );
67
+ }
@@ -0,0 +1,5 @@
1
+ OpenMoji
2
+ https://openmoji.org
3
+
4
+ Licensed under Attribution-ShareAlike 4.0 International
5
+ https://creativecommons.org/licenses/by-sa/4.0/
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 24 24" fill="currentColor"><path stroke="currentColor" d="M8.5 10a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm0 7a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm7-10a2 2 0 1 0-2-2 2 2 0 0 0 2 2Zm-7-4a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm7 14a2 2 0 1 0 2 2 2 2 0 0 0-2-2Zm0-7a2 2 0 1 0 2 2 2 2 0 0 0-2-2Z"/></svg>
@@ -0,0 +1 @@
1
+ <svg style="color:red" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M8.571 23.429A.571.571 0 0 1 8 24H2.286a.571.571 0 0 1 0-1.143H8c.316 0 .571.256.571.572zM8 20.57H6.857a.571.571 0 0 0 0 1.143H8a.571.571 0 0 0 0-1.143zm-5.714 1.143H4.57a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zM8 18.286H2.286a.571.571 0 0 0 0 1.143H8a.571.571 0 0 0 0-1.143zM16 16H5.714a.571.571 0 0 0 0 1.143H16A.571.571 0 0 0 16 16zM2.286 17.143h1.143a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm17.143-3.429H16a.571.571 0 0 0 0 1.143h3.429a.571.571 0 0 0 0-1.143zM9.143 14.857h4.571a.571.571 0 0 0 0-1.143H9.143a.571.571 0 0 0 0 1.143zm-6.857 0h4.571a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zM20.57 11.43h-9.14a.571.571 0 0 0 0 1.142h9.142a.571.571 0 0 0 0-1.142zM9.714 12a.571.571 0 0 0-.571-.571H5.714a.571.571 0 0 0 0 1.142h3.429A.571.571 0 0 0 9.714 12zm-7.428.571h1.143a.571.571 0 0 0 0-1.142H2.286a.571.571 0 0 0 0 1.142zm19.428-3.428H16a.571.571 0 0 0 0 1.143h5.714a.571.571 0 0 0 0-1.143zM2.286 10.286H8a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm13.143-2.857A.57.57 0 0 0 16 8h5.714a.571.571 0 0 0 0-1.143H16a.571.571 0 0 0-.571.572zm-8.572-.572a.571.571 0 0 0 0 1.143H8a.571.571 0 0 0 0-1.143H6.857zM2.286 8H4.57a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm16.571-2.857c0 .315.256.571.572.571h1.142a.571.571 0 0 0 0-1.143H19.43a.571.571 0 0 0-.572.572zm-1.143 0a.571.571 0 0 0-.571-.572H12.57a.571.571 0 0 0 0 1.143h4.572a.571.571 0 0 0 .571-.571zm-15.428.571h8a.571.571 0 0 0 0-1.143h-8a.571.571 0 0 0 0 1.143zm5.143-2.857c0 .316.255.572.571.572h11.429a.571.571 0 0 0 0-1.143H8a.571.571 0 0 0-.571.571zm-5.143.572h3.428a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm0-2.286H16A.571.571 0 0 0 16 0H2.286a.571.571 0 0 0 0 1.143z" fill="red"/></svg>
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M8.571 23.429A.571.571 0 0 1 8 24H2.286a.571.571 0 0 1 0-1.143H8c.316 0 .571.256.571.572zM8 20.57H6.857a.571.571 0 0 0 0 1.143H8a.571.571 0 0 0 0-1.143zm-5.714 1.143H4.57a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zM8 18.286H2.286a.571.571 0 0 0 0 1.143H8a.571.571 0 0 0 0-1.143zM16 16H5.714a.571.571 0 0 0 0 1.143H16A.571.571 0 0 0 16 16zM2.286 17.143h1.143a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm17.143-3.429H16a.571.571 0 0 0 0 1.143h3.429a.571.571 0 0 0 0-1.143zM9.143 14.857h4.571a.571.571 0 0 0 0-1.143H9.143a.571.571 0 0 0 0 1.143zm-6.857 0h4.571a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zM20.57 11.43h-9.14a.571.571 0 0 0 0 1.142h9.142a.571.571 0 0 0 0-1.142zM9.714 12a.571.571 0 0 0-.571-.571H5.714a.571.571 0 0 0 0 1.142h3.429A.571.571 0 0 0 9.714 12zm-7.428.571h1.143a.571.571 0 0 0 0-1.142H2.286a.571.571 0 0 0 0 1.142zm19.428-3.428H16a.571.571 0 0 0 0 1.143h5.714a.571.571 0 0 0 0-1.143zM2.286 10.286H8a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm13.143-2.857A.57.57 0 0 0 16 8h5.714a.571.571 0 0 0 0-1.143H16a.571.571 0 0 0-.571.572zm-8.572-.572a.571.571 0 0 0 0 1.143H8a.571.571 0 0 0 0-1.143H6.857zM2.286 8H4.57a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm16.571-2.857c0 .315.256.571.572.571h1.142a.571.571 0 0 0 0-1.143H19.43a.571.571 0 0 0-.572.572zm-1.143 0a.571.571 0 0 0-.571-.572H12.57a.571.571 0 0 0 0 1.143h4.572a.571.571 0 0 0 .571-.571zm-15.428.571h8a.571.571 0 0 0 0-1.143h-8a.571.571 0 0 0 0 1.143zm5.143-2.857c0 .316.255.572.571.572h11.429a.571.571 0 0 0 0-1.143H8a.571.571 0 0 0-.571.571zm-5.143.572h3.428a.571.571 0 0 0 0-1.143H2.286a.571.571 0 0 0 0 1.143zm0-2.286H16A.571.571 0 0 0 16 0H2.286a.571.571 0 0 0 0 1.143z"/></svg>
@@ -0,0 +1,5 @@
1
+ yellow-flower.jpg by Andrew Haimerl
2
+ https://unsplash.com/photos/oxQHb8Yqt14
3
+
4
+ Licensed under Unsplash License
5
+ https://unsplash.com/license
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
+ <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M22 3H2v18h20v-2h-2v-2h2v-2h-2v-2h2v-2h-2V9h2V7h-2V5h2V3zm-2 4v2h-2v2h2v2h-2v2h2v2h-2v2H4V5h14v2h2zm-6 2h-2v2h-2v2H8v2H6v2h2v-2h2v-2h2v-2h2v2h2v-2h-2V9zM6 7h2v2H6V7z" fill="#000000"/>
4
+ </svg>
@@ -0,0 +1 @@
1
+ <svg width="597" height="131" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M189.512 115.984h-40.32v-13.776h11.256V14.176H148.52V.4h29.736v101.808h11.256v13.776ZM265.334 92.968c-.672 6.608-3.92 12.376-9.744 17.304-5.824 4.928-13.832 7.392-24.024 7.392-10.976 0-19.992-3.192-27.048-9.576-7.056-6.496-10.584-16.016-10.584-28.56 0-11.536 3.192-21.168 9.576-28.896 6.496-7.728 15.512-11.592 27.048-11.592 10.416 0 18.648 3.136 24.696 9.408 6.16 6.16 9.296 14 9.408 23.52 0 3.136-.336 6.496-1.008 10.08H212.75c1.008 14.112 7.728 21.168 20.16 21.168 5.824 0 9.968-1.4 12.432-4.2 2.576-2.8 4.256-5.768 5.04-8.904l14.952 2.856ZM246.182 70.96c.448-4.48-.616-8.68-3.192-12.6-2.464-4.032-6.664-6.048-12.6-6.048-5.376 0-9.464 1.792-12.264 5.376-2.8 3.584-4.536 8.008-5.208 13.272h33.264ZM352.448 115.984h-36.12v-13.776h7.224l-13.608-15.456-13.44 15.456h6.384v13.776H269.12v-13.776h10.416l21.84-23.52-23.184-24.36h-8.568V40.552h36.792v13.776h-7.056l12.6 15.12 13.44-15.12h-6.552V40.552H350.6v13.776h-7.896l-21.672 22.68 23.352 25.2h8.064v13.776ZM397.526 115.984h-40.32v-13.776h11.256V54.496h-11.928V40.552h29.736v61.656h11.256v13.776ZM472.117 88.936c-.784 6.72-3.752 13.216-8.904 19.488-5.152 6.16-13.44 9.24-24.864 9.24-10.752 0-19.544-3.248-26.376-9.744-6.72-6.496-10.08-15.96-10.08-28.392 0-12.208 3.472-22.008 10.416-29.4 7.056-7.392 16.24-11.088 27.552-11.088 4.48 0 8.96.56 13.44 1.68 4.48 1.12 8.904 2.968 13.272 5.544l3.024 21.168-14.448 1.512-2.52-12.432a29.58 29.58 0 0 0-13.104-3.024c-12.544 0-18.816 8.4-18.816 25.2 0 16.352 6.44 24.528 19.32 24.528 9.408 0 15.064-5.712 16.968-17.136l15.12 2.856ZM484.683 46.096c5.6-2.688 10.584-4.536 14.952-5.544s9.408-1.512 15.12-1.512c8.4 0 15.288 2.128 20.664 6.384 5.488 4.256 8.232 10.64 8.232 19.152v33.936c0 4.48 1.848 6.72 5.544 6.72 1.008 0 2.296-.224 3.864-.672l.168 9.912c-3.696 2.128-7.728 3.192-12.096 3.192-9.52 0-14.672-4.984-15.456-14.952v-.336c-2.24 3.92-5.432 7.448-9.576 10.584-4.032 3.136-9.072 4.704-15.12 4.704-5.264 0-10.472-1.568-15.624-4.704-5.04-3.248-7.56-8.848-7.56-16.8 0-9.296 3.696-15.4 11.088-18.312 7.392-3.024 15.4-4.536 24.024-4.536 2.128 0 4.312.056 6.552.168 2.24.112 4.312.28 6.216.504v-4.2c0-4.48-.784-8.512-2.352-12.096-1.568-3.584-5.488-5.376-11.76-5.376-2.352 0-4.592.168-6.72.504-2.016.336-3.976 1.008-5.88 2.016l-3.024 11.592-14.448-1.512 3.192-18.816Zm40.992 39.984v-2.688a917.892 917.892 0 0 0-5.88-.672 56.265 56.265 0 0 0-6.216-.336c-4.48 0-8.512.784-12.096 2.352-3.472 1.568-5.208 4.704-5.208 9.408 0 6.832 3.64 10.248 10.92 10.248 4.256 0 8.288-1.512 12.096-4.536 3.808-3.136 5.936-7.728 6.384-13.776ZM596.079 115.984h-40.32v-13.776h11.256V14.176h-11.928V.4h29.736v101.808h11.256v13.776Z" fill="#050505"/><path fill="#76B6FF" d="M367 2h19v20h-19zM20 54h22v10H20V54Z"/><path d="M47 54h22v10H47V54Z" fill="#050505"/><path d="M74 54h9v10h-9V54ZM20 70h36v10H20V70ZM61 70h22v10H61V70Z" fill="#76B6FF"/><path d="M20 86h22v10H20V86Z" fill="#050505"/><path d="M47 86h22v10H47V86Z" fill="#76B6FF"/><path d="M74 86h9v10h-9V86Z" fill="#050505"/><path d="M0 34h83v10H10v62h73v10H0V34ZM118 34h-15v10h5v62h-5v10h15V34Z" fill="#050505"/><path d="M78 29V19h31v10H98v92h11v10H78v-10h10V29H78Z" fill="#050505"/></svg>
@@ -5,29 +5,16 @@
5
5
  // Npm
6
6
  import React from 'react';
7
7
 
8
- import { EditorState, createEditor } from 'lexical';
9
- import { $generateHtmlFromNodes } from '@lexical/html';
10
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
11
- import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
12
- import { LexicalComposer } from '@lexical/react/LexicalComposer';
13
- import { ContentEditable } from '@lexical/react/LexicalContentEditable';
14
- import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
15
- import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
16
- import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
17
- import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
8
+ // Lexical
18
9
  import RichEditorUtils from './currentEditor';
19
10
 
20
11
  // Core libs
21
12
  import { useInput, InputBaseProps, InputWrapper } from '../base';
22
- import editorNodes from '@common/data/rte/nodes';
23
13
 
24
14
  // Special componets
25
- import ExampleTheme from './ExampleTheme';
26
- import ToolbarPlugin from './ToolbarPlugin';
15
+ import type TEditor from './Editor';
27
16
  import './style.less';
28
17
 
29
- const EMPTY_STATE = '{"root":{"children":[{"children":[],"direction":null,"format":"","indent":0,"type":"paragraph","version":1}],"direction":null,"format":"","indent":0,"type":"root","version":1}}';
30
-
31
18
  /*----------------------------------
32
19
  - TYPES
33
20
  ----------------------------------*/
@@ -36,21 +23,6 @@ export type Props = {
36
23
  preview?: boolean,
37
24
  }
38
25
 
39
- const ValueControlPlugin = ({ props, value }) => {
40
-
41
- const [editor] = useLexicalComposerContext();
42
-
43
- React.useEffect(() => {
44
- if (props.value && props.value !== value) {
45
-
46
- const initialEditorState = editor.parseEditorState(props.value)
47
- editor.setEditorState(initialEditorState);
48
- }
49
- }, [props.value]);
50
-
51
- return null;
52
- }
53
-
54
26
  /*----------------------------------
55
27
  - COMPOSANT
56
28
  ----------------------------------*/
@@ -69,14 +41,10 @@ export default (props: Props & InputBaseProps<string>) => {
69
41
  - INIT
70
42
  ----------------------------------*/
71
43
 
44
+ const [Editor, setEditor] = React.useState<{ default: typeof TEditor }>(null);
72
45
  const [isPreview, setIsPreview] = React.useState(preview);
73
-
74
- const [html, setHTML] = React.useState();
75
-
76
- const [{ value }, setValue] = useInput(props, EMPTY_STATE, true);
77
-
78
- // Trigger onchange oly when finished typing
79
- const refCommit = React.useRef<NodeJS.Timeout | null>(null);
46
+ const [html, setHTML] = React.useState(null);
47
+ const [{ value }, setValue] = useInput(props, undefined, true);
80
48
 
81
49
  className += ' input rte';
82
50
 
@@ -84,11 +52,10 @@ export default (props: Props & InputBaseProps<string>) => {
84
52
  - ACTIONS
85
53
  ----------------------------------*/
86
54
 
87
- React.useEffect(async () => {
88
-
89
- if (isPreview)
90
- renderPreview(value);
91
-
55
+ React.useEffect(() => {
56
+ if (isPreview) {
57
+ renderPreview(value).then(setHTML);
58
+ }
92
59
  }, [value, isPreview]);
93
60
 
94
61
  // When isPreview changes, close the active editor
@@ -105,35 +72,28 @@ export default (props: Props & InputBaseProps<string>) => {
105
72
  close: () => setIsPreview(true)
106
73
  }
107
74
 
75
+ // Load editor component if not alreayd done
76
+ // We lazy load since it's heavy and needs to be loade donly on client side
77
+ if (!Editor) {
78
+ import('./Editor').then(setEditor);
79
+ }
80
+
108
81
  }
109
82
  }, [isPreview]);
110
83
 
111
- const renderPreview = async (value: {}) => {
84
+ const renderPreview = async (value: {} | undefined) => {
85
+
86
+ if (!value)
87
+ return '';
112
88
 
113
89
  if (typeof document === 'undefined')
114
90
  throw new Error("HTML preview disabled in server side.");
115
91
 
116
92
  const html = await RichEditorUtils.jsonToHtml(value);
117
93
 
118
- setHTML(html);
94
+ return html;
119
95
  }
120
96
 
121
- const onChange = (editorState: EditorState) => {
122
- editorState.read(() => {
123
-
124
- if (refCommit.current !== null)
125
- clearTimeout(refCommit.current);
126
-
127
- refCommit.current = setTimeout(() => {
128
-
129
- const stateJson = JSON.stringify(editorState.toJSON());
130
-
131
- setValue(stateJson);
132
-
133
- }, 100);
134
- });
135
- };
136
-
137
97
  /*----------------------------------
138
98
  - RENDER
139
99
  ----------------------------------*/
@@ -143,47 +103,18 @@ export default (props: Props & InputBaseProps<string>) => {
143
103
 
144
104
  {isPreview ? (
145
105
 
146
- !html ? (
147
- <div class="col al-center h-4">
106
+ html === null ? (
107
+ <div class="col al-center h-2">
148
108
  <i src="spin" />
149
109
  </div>
150
110
  ) : (
151
- <div class="h-4 scrollable col clickable"
111
+ <div class="preview reading h-1-4 scrollable col clickable"
152
112
  onClick={() => setIsPreview(false)}
153
113
  dangerouslySetInnerHTML={{ __html: html }} />
154
114
  )
155
115
 
156
- ) : typeof window !== 'undefined' && (
157
- <LexicalComposer initialConfig={{
158
- editorState: value || EMPTY_STATE,
159
- nodes: editorNodes,
160
- // Handling of errors during update
161
- onError(error: Error) { throw error; },
162
- // The editor theme
163
- theme: ExampleTheme,
164
- }}>
165
- <div className="editor-container">
166
- <ToolbarPlugin />
167
- <div className="editor-inner">
168
- <RichTextPlugin
169
- contentEditable={
170
- <ContentEditable
171
- className="editor-input"
172
- aria-placeholder={"Type text here ..."}
173
- placeholder={
174
- <div className="editor-placeholder">Type text here ...</div>
175
- }
176
- />
177
- }
178
- ErrorBoundary={LexicalErrorBoundary}
179
- />
180
- <HistoryPlugin />
181
- <AutoFocusPlugin />
182
- <OnChangePlugin onChange={onChange} />
183
- <ValueControlPlugin props={props} value={value} />
184
- </div>
185
- </div>
186
- </LexicalComposer>
116
+ ) : Editor !== null && (
117
+ <Editor.default value={value} setValue={setValue} props={props} />
187
118
  )}
188
119
 
189
120
  {/* <Tag {...fieldProps}