@datalayer/jupyter-lexical 0.0.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 (233) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/lib/components/InsertEquationDialog.d.ts +6 -0
  4. package/lib/components/InsertEquationDialog.js +17 -0
  5. package/lib/components/InsertEquationDialog.js.map +1 -0
  6. package/lib/components/InsertImageDialog.d.ts +13 -0
  7. package/lib/components/InsertImageDialog.js +48 -0
  8. package/lib/components/InsertImageDialog.js.map +1 -0
  9. package/lib/components/JupyterCellComponent.d.ts +2 -0
  10. package/lib/components/JupyterCellComponent.js +12 -0
  11. package/lib/components/JupyterCellComponent.js.map +1 -0
  12. package/lib/components/JupyterOutputComponent.d.ts +13 -0
  13. package/lib/components/JupyterOutputComponent.js +8 -0
  14. package/lib/components/JupyterOutputComponent.js.map +1 -0
  15. package/lib/convert/LexicalToNbFormat.d.ts +4 -0
  16. package/lib/convert/LexicalToNbFormat.js +100 -0
  17. package/lib/convert/LexicalToNbFormat.js.map +1 -0
  18. package/lib/convert/NbFormatToLexical.d.ts +4 -0
  19. package/lib/convert/NbFormatToLexical.js +31 -0
  20. package/lib/convert/NbFormatToLexical.js.map +1 -0
  21. package/lib/convert/markdown/MarkdownExport.d.ts +11 -0
  22. package/lib/convert/markdown/MarkdownExport.js +129 -0
  23. package/lib/convert/markdown/MarkdownExport.js.map +1 -0
  24. package/lib/convert/markdown/MarkdownImport.d.ts +2 -0
  25. package/lib/convert/markdown/MarkdownImport.js +246 -0
  26. package/lib/convert/markdown/MarkdownImport.js.map +1 -0
  27. package/lib/convert/markdown/MarkdownShortcuts.d.ts +10 -0
  28. package/lib/convert/markdown/MarkdownShortcuts.js +254 -0
  29. package/lib/convert/markdown/MarkdownShortcuts.js.map +1 -0
  30. package/lib/convert/markdown/MarkdownTransformers.d.ts +39 -0
  31. package/lib/convert/markdown/MarkdownTransformers.js +242 -0
  32. package/lib/convert/markdown/MarkdownTransformers.js.map +1 -0
  33. package/lib/convert/markdown/convertToMarkdown.d.ts +1 -0
  34. package/lib/convert/markdown/convertToMarkdown.js +126 -0
  35. package/lib/convert/markdown/convertToMarkdown.js.map +1 -0
  36. package/lib/convert/markdown/index.d.ts +17 -0
  37. package/lib/convert/markdown/index.js +46 -0
  38. package/lib/convert/markdown/index.js.map +1 -0
  39. package/lib/convert/markdown/utils.d.ts +24 -0
  40. package/lib/convert/markdown/utils.js +303 -0
  41. package/lib/convert/markdown/utils.js.map +1 -0
  42. package/lib/convert/transformers/MarkdownTransformers.d.ts +13 -0
  43. package/lib/convert/transformers/MarkdownTransformers.js +178 -0
  44. package/lib/convert/transformers/MarkdownTransformers.js.map +1 -0
  45. package/lib/examples/App.d.ts +1 -0
  46. package/lib/examples/App.js +22 -0
  47. package/lib/examples/App.js.map +1 -0
  48. package/lib/examples/Editor.d.ts +9 -0
  49. package/lib/examples/Editor.js +81 -0
  50. package/lib/examples/Editor.js.map +1 -0
  51. package/lib/examples/Example.d.ts +1 -0
  52. package/lib/examples/Example.js +11 -0
  53. package/lib/examples/Example.js.map +1 -0
  54. package/lib/examples/content/Example.ipynb.json +98 -0
  55. package/lib/examples/content/Example.lexical.json +259 -0
  56. package/lib/examples/context/LexicalContext.d.ts +13 -0
  57. package/lib/examples/context/LexicalContext.js +22 -0
  58. package/lib/examples/context/LexicalContext.js.map +1 -0
  59. package/lib/examples/plugins/ToolbarPlugin.d.ts +2 -0
  60. package/lib/examples/plugins/ToolbarPlugin.js +448 -0
  61. package/lib/examples/plugins/ToolbarPlugin.js.map +1 -0
  62. package/lib/examples/plugins/TreeViewPlugin.d.ts +2 -0
  63. package/lib/examples/plugins/TreeViewPlugin.js +13 -0
  64. package/lib/examples/plugins/TreeViewPlugin.js.map +1 -0
  65. package/lib/examples/themes/Theme.d.ts +10 -0
  66. package/lib/examples/themes/Theme.js +94 -0
  67. package/lib/examples/themes/Theme.js.map +1 -0
  68. package/lib/hooks/useModal.d.ts +2 -0
  69. package/lib/hooks/useModal.js +39 -0
  70. package/lib/hooks/useModal.js.map +1 -0
  71. package/lib/images/yellow-flower-small.jpg +0 -0
  72. package/lib/index.d.ts +40 -0
  73. package/lib/index.js +55 -0
  74. package/lib/index.js.map +1 -0
  75. package/lib/jupyter/index.d.ts +0 -0
  76. package/lib/jupyter/index.js +6 -0
  77. package/lib/jupyter/index.js.map +1 -0
  78. package/lib/jupyter/lab/Example.d.ts +1 -0
  79. package/lib/jupyter/lab/Example.js +11 -0
  80. package/lib/jupyter/lab/Example.js.map +1 -0
  81. package/lib/jupyter/lab/__tests__/datalayer.spec.d.ts +0 -0
  82. package/lib/jupyter/lab/__tests__/datalayer.spec.js +11 -0
  83. package/lib/jupyter/lab/__tests__/datalayer.spec.js.map +1 -0
  84. package/lib/jupyter/lab/component/MockComponent.d.ts +2 -0
  85. package/lib/jupyter/lab/component/MockComponent.js +17 -0
  86. package/lib/jupyter/lab/component/MockComponent.js.map +1 -0
  87. package/lib/jupyter/lab/component/MockTab1.d.ts +2 -0
  88. package/lib/jupyter/lab/component/MockTab1.js +14 -0
  89. package/lib/jupyter/lab/component/MockTab1.js.map +1 -0
  90. package/lib/jupyter/lab/handler.d.ts +8 -0
  91. package/lib/jupyter/lab/handler.js +41 -0
  92. package/lib/jupyter/lab/handler.js.map +1 -0
  93. package/lib/jupyter/lab/index.d.ts +7 -0
  94. package/lib/jupyter/lab/index.js +73 -0
  95. package/lib/jupyter/lab/index.js.map +1 -0
  96. package/lib/jupyter/lab/widget.d.ts +6 -0
  97. package/lib/jupyter/lab/widget.js +18 -0
  98. package/lib/jupyter/lab/widget.js.map +1 -0
  99. package/lib/nodes/EquationNode.d.ts +31 -0
  100. package/lib/nodes/EquationNode.js +118 -0
  101. package/lib/nodes/EquationNode.js.map +1 -0
  102. package/lib/nodes/ImageNode.css +50 -0
  103. package/lib/nodes/ImageNode.d.ts +58 -0
  104. package/lib/nodes/ImageNode.js +275 -0
  105. package/lib/nodes/ImageNode.js.map +1 -0
  106. package/lib/nodes/JupyterCodeHighlightNode.d.ts +49 -0
  107. package/lib/nodes/JupyterCodeHighlightNode.js +165 -0
  108. package/lib/nodes/JupyterCodeHighlightNode.js.map +1 -0
  109. package/lib/nodes/JupyterCodeHighlighter.d.ts +28 -0
  110. package/lib/nodes/JupyterCodeHighlighter.js +522 -0
  111. package/lib/nodes/JupyterCodeHighlighter.js.map +1 -0
  112. package/lib/nodes/JupyterCodeNode.d.ts +50 -0
  113. package/lib/nodes/JupyterCodeNode.js +277 -0
  114. package/lib/nodes/JupyterCodeNode.js.map +1 -0
  115. package/lib/nodes/JupyterOutputNode.d.ts +58 -0
  116. package/lib/nodes/JupyterOutputNode.js +144 -0
  117. package/lib/nodes/JupyterOutputNode.js.map +1 -0
  118. package/lib/nodes/YouTubeNode.d.ts +28 -0
  119. package/lib/nodes/YouTubeNode.js +56 -0
  120. package/lib/nodes/YouTubeNode.js.map +1 -0
  121. package/lib/plugins/AutoEmbedPlugin.d.ts +17 -0
  122. package/lib/plugins/AutoEmbedPlugin.js +110 -0
  123. package/lib/plugins/AutoEmbedPlugin.js.map +1 -0
  124. package/lib/plugins/AutoLinkPlugin.d.ts +2 -0
  125. package/lib/plugins/AutoLinkPlugin.js +34 -0
  126. package/lib/plugins/AutoLinkPlugin.js.map +1 -0
  127. package/lib/plugins/CodeActionMenuPlugin.css +52 -0
  128. package/lib/plugins/CodeActionMenuPlugin.d.ts +12 -0
  129. package/lib/plugins/CodeActionMenuPlugin.js +108 -0
  130. package/lib/plugins/CodeActionMenuPlugin.js.map +1 -0
  131. package/lib/plugins/ComponentPickerMenuPlugin.d.ts +2 -0
  132. package/lib/plugins/ComponentPickerMenuPlugin.js +244 -0
  133. package/lib/plugins/ComponentPickerMenuPlugin.js.map +1 -0
  134. package/lib/plugins/EquationsPlugin.d.ts +21 -0
  135. package/lib/plugins/EquationsPlugin.js +48 -0
  136. package/lib/plugins/EquationsPlugin.js.map +1 -0
  137. package/lib/plugins/HorizontalRulePlugin.d.ts +2 -0
  138. package/lib/plugins/HorizontalRulePlugin.js +40 -0
  139. package/lib/plugins/HorizontalRulePlugin.js.map +1 -0
  140. package/lib/plugins/ImagesPlugin.d.ts +25 -0
  141. package/lib/plugins/ImagesPlugin.js +212 -0
  142. package/lib/plugins/ImagesPlugin.js.map +1 -0
  143. package/lib/plugins/JupyterPlugin.css +13 -0
  144. package/lib/plugins/JupyterPlugin.d.ts +16 -0
  145. package/lib/plugins/JupyterPlugin.js +169 -0
  146. package/lib/plugins/JupyterPlugin.js.map +1 -0
  147. package/lib/plugins/ListMaxIndentLevelPlugin.d.ts +4 -0
  148. package/lib/plugins/ListMaxIndentLevelPlugin.js +49 -0
  149. package/lib/plugins/ListMaxIndentLevelPlugin.js.map +1 -0
  150. package/lib/plugins/MardownPlugin.d.ts +2 -0
  151. package/lib/plugins/MardownPlugin.js +20 -0
  152. package/lib/plugins/MardownPlugin.js.map +1 -0
  153. package/lib/plugins/NbformatContentPlugin.d.ts +6 -0
  154. package/lib/plugins/NbformatContentPlugin.js +20 -0
  155. package/lib/plugins/NbformatContentPlugin.js.map +1 -0
  156. package/lib/plugins/TableOfContentsPlugin.css +87 -0
  157. package/lib/plugins/TableOfContentsPlugin.d.ts +3 -0
  158. package/lib/plugins/TableOfContentsPlugin.js +115 -0
  159. package/lib/plugins/TableOfContentsPlugin.js.map +1 -0
  160. package/lib/plugins/YouTubePlugin.d.ts +4 -0
  161. package/lib/plugins/YouTubePlugin.js +34 -0
  162. package/lib/plugins/YouTubePlugin.js.map +1 -0
  163. package/lib/ui/Button.css +40 -0
  164. package/lib/ui/Button.d.ts +18 -0
  165. package/lib/ui/Button.js +8 -0
  166. package/lib/ui/Button.js.map +1 -0
  167. package/lib/ui/ContentEditable.css +24 -0
  168. package/lib/ui/ContentEditable.d.ts +5 -0
  169. package/lib/ui/ContentEditable.js +20 -0
  170. package/lib/ui/ContentEditable.js.map +1 -0
  171. package/lib/ui/CopyButton.d.ts +7 -0
  172. package/lib/ui/CopyButton.js +47 -0
  173. package/lib/ui/CopyButton.js.map +1 -0
  174. package/lib/ui/Dialog.css +23 -0
  175. package/lib/ui/Dialog.d.ts +16 -0
  176. package/lib/ui/Dialog.js +21 -0
  177. package/lib/ui/Dialog.js.map +1 -0
  178. package/lib/ui/DropDown.d.ts +23 -0
  179. package/lib/ui/DropDown.js +119 -0
  180. package/lib/ui/DropDown.js.map +1 -0
  181. package/lib/ui/EquationEditor.css +42 -0
  182. package/lib/ui/EquationEditor.d.ts +18 -0
  183. package/lib/ui/EquationEditor.js +31 -0
  184. package/lib/ui/EquationEditor.js.map +1 -0
  185. package/lib/ui/FileInput.d.ts +15 -0
  186. package/lib/ui/FileInput.js +18 -0
  187. package/lib/ui/FileInput.js.map +1 -0
  188. package/lib/ui/ImageResizer.d.ts +16 -0
  189. package/lib/ui/ImageResizer.js +166 -0
  190. package/lib/ui/ImageResizer.js.map +1 -0
  191. package/lib/ui/Input.css +37 -0
  192. package/lib/ui/KatexEquationAlterer.css +45 -0
  193. package/lib/ui/KatexEquationAlterer.d.ts +7 -0
  194. package/lib/ui/KatexEquationAlterer.js +33 -0
  195. package/lib/ui/KatexEquationAlterer.js.map +1 -0
  196. package/lib/ui/KatexRenderer.d.ts +6 -0
  197. package/lib/ui/KatexRenderer.js +36 -0
  198. package/lib/ui/KatexRenderer.js.map +1 -0
  199. package/lib/ui/Modal.css +67 -0
  200. package/lib/ui/Modal.d.ts +15 -0
  201. package/lib/ui/Modal.js +58 -0
  202. package/lib/ui/Modal.js.map +1 -0
  203. package/lib/ui/Placeholder.css +29 -0
  204. package/lib/ui/Placeholder.d.ts +14 -0
  205. package/lib/ui/Placeholder.js +7 -0
  206. package/lib/ui/Placeholder.js.map +1 -0
  207. package/lib/ui/PrettierButton.css +20 -0
  208. package/lib/ui/PrettierButton.tsx_tmp +133 -0
  209. package/lib/ui/TextInput.d.ts +16 -0
  210. package/lib/ui/TextInput.js +20 -0
  211. package/lib/ui/TextInput.js.map +1 -0
  212. package/lib/utils/canUseDOM.d.ts +8 -0
  213. package/lib/utils/canUseDOM.js +16 -0
  214. package/lib/utils/canUseDOM.js.map +1 -0
  215. package/lib/utils/debouncer.d.ts +1 -0
  216. package/lib/utils/debouncer.js +24 -0
  217. package/lib/utils/debouncer.js.map +1 -0
  218. package/lib/utils/invariant.d.ts +8 -0
  219. package/lib/utils/invariant.js +23 -0
  220. package/lib/utils/invariant.js.map +1 -0
  221. package/lib/utils/join.d.ts +8 -0
  222. package/lib/utils/join.js +16 -0
  223. package/lib/utils/join.js.map +1 -0
  224. package/lib/utils/selection.d.ts +8 -0
  225. package/lib/utils/selection.js +14 -0
  226. package/lib/utils/selection.js.map +1 -0
  227. package/lib/utils/useLayoutEffect.d.ts +10 -0
  228. package/lib/utils/useLayoutEffect.js +19 -0
  229. package/lib/utils/useLayoutEffect.js.map +1 -0
  230. package/package.json +166 -0
  231. package/style/base.css +16 -0
  232. package/style/index.css +7 -0
  233. package/style/index.js +7 -0
@@ -0,0 +1,67 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+
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
+
15
+ .Modal__overlay {
16
+ display: flex;
17
+ justify-content: center;
18
+ align-items: center;
19
+ position: fixed;
20
+ flex-direction: column;
21
+ top: 0px;
22
+ bottom: 0px;
23
+ left: 0px;
24
+ right: 0px;
25
+ background-color: rgba(40, 40, 40, 0.6);
26
+ flex-grow: 0px;
27
+ flex-shrink: 1px;
28
+ z-index: 100;
29
+ }
30
+ .Modal__modal {
31
+ padding: 20px;
32
+ min-height: 100px;
33
+ min-width: 300px;
34
+ display: flex;
35
+ flex-grow: 0px;
36
+ background-color: #fff;
37
+ flex-direction: column;
38
+ position: relative;
39
+ box-shadow: 0 0 20px 0 #444;
40
+ border-radius: 10px;
41
+ }
42
+ .Modal__title {
43
+ color: #444;
44
+ margin: 0px;
45
+ padding-bottom: 10px;
46
+ border-bottom: 1px solid #ccc;
47
+ }
48
+ .Modal__closeButton {
49
+ border: 0px;
50
+ position: absolute;
51
+ right: 20px;
52
+ border-radius: 20px;
53
+ justify-content: center;
54
+ align-items: center;
55
+ display: flex;
56
+ width: 30px;
57
+ height: 30px;
58
+ text-align: center;
59
+ cursor: pointer;
60
+ background-color: #eee;
61
+ }
62
+ .Modal__closeButton:hover {
63
+ background-color: #ddd;
64
+ }
65
+ .Modal__content {
66
+ padding-top: 20px;
67
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import { ReactNode } from 'react';
8
+ import './Modal.css';
9
+ export declare const Modal: ({ onClose, children, title, closeOnClickOutside, }: {
10
+ children: ReactNode;
11
+ closeOnClickOutside?: boolean | undefined;
12
+ onClose: () => void;
13
+ title: string;
14
+ }) => JSX.Element;
15
+ export default Modal;
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2023 Datalayer, Inc.
4
+ *
5
+ * MIT License
6
+ */
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
+ import { useEffect, useRef } from 'react';
14
+ import { createPortal } from 'react-dom';
15
+ import './Modal.css';
16
+ function PortalImpl({ onClose, children, title, closeOnClickOutside, }) {
17
+ const modalRef = useRef(null);
18
+ useEffect(() => {
19
+ if (modalRef.current !== null) {
20
+ modalRef.current.focus();
21
+ }
22
+ }, []);
23
+ useEffect(() => {
24
+ let modalOverlayElement = null;
25
+ const handler = (event) => {
26
+ if (event.keyCode === 27) {
27
+ onClose();
28
+ }
29
+ };
30
+ const clickOutsideHandler = (event) => {
31
+ const target = event.target;
32
+ if (modalRef.current !== null &&
33
+ !modalRef.current.contains(target) &&
34
+ closeOnClickOutside) {
35
+ onClose();
36
+ }
37
+ };
38
+ if (modalRef.current !== null) {
39
+ modalOverlayElement = modalRef.current?.parentElement;
40
+ if (modalOverlayElement !== null) {
41
+ modalOverlayElement?.addEventListener('click', clickOutsideHandler);
42
+ }
43
+ }
44
+ window.addEventListener('keydown', handler);
45
+ return () => {
46
+ window.removeEventListener('keydown', handler);
47
+ if (modalOverlayElement !== null) {
48
+ modalOverlayElement?.removeEventListener('click', clickOutsideHandler);
49
+ }
50
+ };
51
+ }, [closeOnClickOutside, onClose]);
52
+ return (_jsx("div", { className: "Modal__overlay", role: "dialog", children: _jsxs("div", { className: "Modal__modal", tabIndex: -1, ref: modalRef, children: [_jsx("h2", { className: "Modal__title", children: title }), _jsx("button", { className: "Modal__closeButton", "aria-label": "Close modal", type: "button", onClick: onClose, children: "X" }), _jsx("div", { className: "Modal__content", children: children })] }) }));
53
+ }
54
+ export const Modal = ({ onClose, children, title, closeOnClickOutside = false, }) => {
55
+ return createPortal(_jsx(PortalImpl, { onClose: onClose, title: title, closeOnClickOutside: closeOnClickOutside, children: children }), document.body);
56
+ };
57
+ export default Modal;
58
+ //# sourceMappingURL=Modal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/ui/Modal.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,OAAO,EAAY,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACnD,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AAEvC,OAAO,aAAa,CAAC;AAErB,SAAS,UAAU,CAAC,EAClB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,mBAAmB,GAMpB;IACC,MAAM,QAAQ,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;IAC9C,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE;YAC7B,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;SAC1B;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,mBAAmB,GAAuB,IAAI,CAAC;QACnD,MAAM,OAAO,GAAG,CAAC,KAAoB,EAAE,EAAE;YACvC,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE,EAAE;gBACxB,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;QACF,MAAM,mBAAmB,GAAG,CAAC,KAAiB,EAAE,EAAE;YAChD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;YAC5B,IACE,QAAQ,CAAC,OAAO,KAAK,IAAI;gBACzB,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAc,CAAC;gBAC1C,mBAAmB,EACnB;gBACA,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC;QACF,IAAI,QAAQ,CAAC,OAAO,KAAK,IAAI,EAAE;YAC7B,mBAAmB,GAAG,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;YACtD,IAAI,mBAAmB,KAAK,IAAI,EAAE;gBAChC,mBAAmB,EAAE,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;aACrE;SACF;QACD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QAC5C,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC/C,IAAI,mBAAmB,KAAK,IAAI,EAAE;gBAChC,mBAAmB,EAAE,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;aACxE;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC,CAAC;IACnC,OAAO,CACL,cAAK,SAAS,EAAC,gBAAgB,EAAC,IAAI,EAAC,QAAQ,YAC3C,eAAK,SAAS,EAAC,cAAc,EAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,aACvD,aAAI,SAAS,EAAC,cAAc,YAAE,KAAK,GAAM,EACzC,iBACE,SAAS,EAAC,oBAAoB,gBACnB,aAAa,EACxB,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,kBAET,EACT,cAAK,SAAS,EAAC,gBAAgB,YAAE,QAAQ,GAAO,IAC5C,GACF,CACP,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,EACpB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,mBAAmB,GAAG,KAAK,GAM5B,EAAe,EAAE;IAChB,OAAO,YAAY,CACjB,KAAC,UAAU,IACT,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,KAAK,EACZ,mBAAmB,EAAE,mBAAmB,YACvC,QAAQ,GACE,EACb,QAAQ,CAAC,IAAI,CACd,CAAC;AACJ,CAAC,CAAA;AAED,eAAe,KAAK,CAAC"}
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+
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
+ */
15
+
16
+ .Placeholder__root {
17
+ font-size: 15px;
18
+ color: #999;
19
+ overflow: hidden;
20
+ position: absolute;
21
+ text-overflow: ellipsis;
22
+ top: 10px;
23
+ left: 10px;
24
+ right: 10px;
25
+ user-select: none;
26
+ white-space: nowrap;
27
+ display: inline-block;
28
+ pointer-events: none;
29
+ }
@@ -0,0 +1,14 @@
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 { ReactNode } from 'react';
9
+ import './Placeholder.css';
10
+ export declare const Placeholder: ({ children, className, }: {
11
+ children: ReactNode;
12
+ className?: string | undefined;
13
+ }) => JSX.Element;
14
+ export default Placeholder;
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import './Placeholder.css';
3
+ export const Placeholder = ({ children, className, }) => {
4
+ return _jsx("div", { className: className || 'Placeholder__root', children: children });
5
+ };
6
+ export default Placeholder;
7
+ //# sourceMappingURL=Placeholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Placeholder.js","sourceRoot":"","sources":["../../src/ui/Placeholder.tsx"],"names":[],"mappings":";AAgBA,OAAO,mBAAmB,CAAC;AAE3B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,QAAQ,EACR,SAAS,GAIV,EAAe,EAAE;IAChB,OAAO,cAAK,SAAS,EAAE,SAAS,IAAI,mBAAmB,YAAG,QAAQ,GAAO,CAAC;AAC5E,CAAC,CAAA;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+
7
+ .code-action-menu-container .prettier-wrapper {
8
+ position: relative;
9
+ }
10
+
11
+ .code-action-menu-container .prettier-wrapper .code-error-tips {
12
+ padding: 5px;
13
+ border-radius: 4px;
14
+ color: #fff;
15
+ background: #222;
16
+ margin-top: 4px;
17
+ position: absolute;
18
+ top: 26px;
19
+ right: 0;
20
+ }
@@ -0,0 +1,133 @@
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 {$isJupyterCodeNode} from '../nodes/JupyterCodeNode';
9
+ import {$getNearestNodeFromDOMNode, LexicalEditor} from 'lexical';
10
+ import {Options} from 'prettier';
11
+ import * as babelParser from 'prettier/parser-babel';
12
+ import * as htmlParser from 'prettier/parser-html';
13
+ import * as markdownParser from 'prettier/parser-markdown';
14
+ import * as cssParser from 'prettier/parser-postcss';
15
+ import {format} from 'prettier/standalone';
16
+ import {useState} from 'react';
17
+
18
+ import './PrettierButton.css';
19
+
20
+ interface Props {
21
+ lang: string;
22
+ editor: LexicalEditor;
23
+ getCodeDOMNode: () => HTMLElement | null;
24
+ }
25
+
26
+ const PRETTIER_OPTIONS_BY_LANG: Record<string, Options> = {
27
+ css: {
28
+ parser: 'css',
29
+ plugins: [cssParser],
30
+ },
31
+ html: {
32
+ parser: 'html',
33
+ plugins: [htmlParser],
34
+ },
35
+ js: {
36
+ parser: 'babel',
37
+ plugins: [babelParser],
38
+ },
39
+ markdown: {
40
+ parser: 'markdown',
41
+ plugins: [markdownParser],
42
+ },
43
+ };
44
+
45
+ const LANG_CAN_BE_PRETTIER = Object.keys(PRETTIER_OPTIONS_BY_LANG);
46
+
47
+ export function canBePrettier(lang: string): boolean {
48
+ return LANG_CAN_BE_PRETTIER.includes(lang);
49
+ }
50
+
51
+ function getPrettierOptions(lang: string): Options {
52
+ const options = PRETTIER_OPTIONS_BY_LANG[lang];
53
+ if (!options) {
54
+ throw new Error(
55
+ `CodeActionMenuPlugin: Prettier does not support this language: ${lang}`,
56
+ );
57
+ }
58
+
59
+ return options;
60
+ }
61
+
62
+ export function PrettierButton({lang, editor, getCodeDOMNode}: Props) {
63
+ const [syntaxError, setSyntaxError] = useState<string>('');
64
+ const [tipsVisible, setTipsVisible] = useState<boolean>(false);
65
+
66
+ async function handleClick(): Promise<void> {
67
+ const codeDOMNode = getCodeDOMNode();
68
+
69
+ if (!codeDOMNode) {
70
+ return;
71
+ }
72
+
73
+ editor.update(() => {
74
+ const codeNode = $getNearestNodeFromDOMNode(codeDOMNode);
75
+
76
+ if ($isJupyterCodeNode(codeNode)) {
77
+ const content = codeNode.getTextContent();
78
+ const options = getPrettierOptions(lang);
79
+
80
+ let parsed = '';
81
+
82
+ try {
83
+ parsed = format(content, options);
84
+ } catch (error: unknown) {
85
+ if (error instanceof Error) {
86
+ setSyntaxError(error.message);
87
+ setTipsVisible(true);
88
+ } else {
89
+ console.error('Unexpected error: ', error);
90
+ }
91
+ }
92
+ if (parsed !== '') {
93
+ const selection = codeNode.select(0);
94
+ selection.insertText(parsed);
95
+ setSyntaxError('');
96
+ setTipsVisible(false);
97
+ }
98
+ }
99
+ });
100
+ }
101
+
102
+ function handleMouseEnter() {
103
+ if (syntaxError !== '') {
104
+ setTipsVisible(true);
105
+ }
106
+ }
107
+
108
+ function handleMouseLeave() {
109
+ if (syntaxError !== '') {
110
+ setTipsVisible(false);
111
+ }
112
+ }
113
+
114
+ return (
115
+ <div className="prettier-wrapper">
116
+ <button
117
+ className="menu-item"
118
+ onClick={handleClick}
119
+ onMouseEnter={handleMouseEnter}
120
+ onMouseLeave={handleMouseLeave}
121
+ aria-label="prettier">
122
+ {syntaxError ? (
123
+ <i className="format prettier-error" />
124
+ ) : (
125
+ <i className="format prettier" />
126
+ )}
127
+ </button>
128
+ {tipsVisible ? (
129
+ <pre className="code-error-tips">{syntaxError}</pre>
130
+ ) : null}
131
+ </div>
132
+ );
133
+ }
@@ -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
+ import './Input.css';
8
+ type Props = Readonly<{
9
+ 'data-test-id'?: string;
10
+ label: string;
11
+ onChange: (val: string) => void;
12
+ placeholder?: string;
13
+ value: string;
14
+ }>;
15
+ export declare const TextInput: ({ label, value, onChange, placeholder, "data-test-id": dataTestId, }: Props) => JSX.Element;
16
+ export default TextInput;
@@ -0,0 +1,20 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2021-2023 Datalayer, Inc.
4
+ *
5
+ * MIT License
6
+ */
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
+ import './Input.css';
14
+ export const TextInput = ({ label, value, onChange, placeholder = '', 'data-test-id': dataTestId, }) => {
15
+ return (_jsxs("div", { className: "Input__wrapper", children: [_jsx("label", { className: "Input__label", children: label }), _jsx("input", { type: "text", className: "Input__input", placeholder: placeholder, value: value, onChange: (e) => {
16
+ onChange(e.target.value);
17
+ }, "data-test-id": dataTestId })] }));
18
+ };
19
+ export default TextInput;
20
+ //# sourceMappingURL=TextInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextInput.js","sourceRoot":"","sources":["../../src/ui/TextInput.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,OAAO,aAAa,CAAC;AAUrB,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EACxB,KAAK,EACL,KAAK,EACL,QAAQ,EACR,WAAW,GAAG,EAAE,EAChB,cAAc,EAAE,UAAU,GACpB,EAAe,EAAE;IACvB,OAAO,CACL,eAAK,SAAS,EAAC,gBAAgB,aAC7B,gBAAO,SAAS,EAAC,cAAc,YAAE,KAAK,GAAS,EAC/C,gBACE,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,cAAc,EACxB,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;oBACd,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC3B,CAAC,kBACa,UAAU,GACxB,IACE,CACP,CAAC;AACJ,CAAC,CAAA;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,8 @@
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
+ export declare const CAN_USE_DOM: boolean;
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ *
12
+ */
13
+ export const CAN_USE_DOM = typeof window !== 'undefined' &&
14
+ typeof window.document !== 'undefined' &&
15
+ typeof window.document.createElement !== 'undefined';
16
+ //# sourceMappingURL=canUseDOM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canUseDOM.js","sourceRoot":"","sources":["../../src/utils/canUseDOM.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,MAAM,CAAC,MAAM,WAAW,GACtB,OAAO,MAAM,KAAK,WAAW;IAC7B,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;IACtC,OAAO,MAAM,CAAC,QAAQ,CAAC,aAAa,KAAK,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function useDebounce<T extends (...args: never[]) => void>(fn: T, ms: number, maxWait?: number): import("lodash").DebouncedFunc<(...args: Parameters<T>) => void>;
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ *
12
+ */
13
+ import { debounce } from 'lodash-es';
14
+ import { useMemo, useRef } from 'react';
15
+ export function useDebounce(fn, ms, maxWait) {
16
+ const funcRef = useRef(null);
17
+ funcRef.current = fn;
18
+ return useMemo(() => debounce((...args) => {
19
+ if (funcRef.current) {
20
+ funcRef.current(...args);
21
+ }
22
+ }, ms, { maxWait }), [ms, maxWait]);
23
+ }
24
+ //# sourceMappingURL=debouncer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debouncer.js","sourceRoot":"","sources":["../../src/utils/debouncer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AACH,OAAO,EAAC,QAAQ,EAAC,MAAM,WAAW,CAAC;AACnC,OAAO,EAAC,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAEtC,MAAM,UAAU,WAAW,CACzB,EAAK,EACL,EAAU,EACV,OAAgB;IAEhB,MAAM,OAAO,GAAG,MAAM,CAAW,IAAI,CAAC,CAAC;IACvC,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;IACrB,OAAO,OAAO,CACZ,GAAG,EAAE,CACH,QAAQ,CACN,CAAC,GAAG,IAAmB,EAAE,EAAE;QACzB,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;SAC1B;IACH,CAAC,EACD,EAAE,EACF,EAAC,OAAO,EAAC,CACV,EACH,CAAC,EAAE,EAAE,OAAO,CAAC,CACd,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
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
+ export default function invariant(cond?: boolean, message?: string, ...args: string[]): asserts cond;
@@ -0,0 +1,23 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ *
12
+ */
13
+ // invariant(condition, message) will refine types based on "condition", and
14
+ // if "condition" is false will throw an error. This function is special-cased
15
+ // in flow itself, so we can't name it anything else.
16
+ export default function invariant(cond, message, ...args) {
17
+ if (cond) {
18
+ return;
19
+ }
20
+ throw new Error('Internal Lexical error: invariant() is meant to be replaced at compile ' +
21
+ 'time. There is no runtime version.');
22
+ }
23
+ //# sourceMappingURL=invariant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.js","sourceRoot":"","sources":["../../src/utils/invariant.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,4EAA4E;AAC5E,8EAA8E;AAC9E,qDAAqD;AACrD,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,IAAc,EACd,OAAgB,EAChB,GAAG,IAAc;IAEjB,IAAI,IAAI,EAAE;QACR,OAAO;KACR;IAED,MAAM,IAAI,KAAK,CACb,yEAAyE;QACvE,oCAAoC,CACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
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
+ export declare const joinClasses: (...args: Array<string | boolean | null | undefined>) => string;
8
+ export default joinClasses;
@@ -0,0 +1,16 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ export const joinClasses = (...args) => {
13
+ return args.filter(Boolean).join(' ');
14
+ };
15
+ export default joinClasses;
16
+ //# sourceMappingURL=join.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"join.js","sourceRoot":"","sources":["../../src/utils/join.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAG,IAAgD,EACnD,EAAE;IACF,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACxC,CAAC,CAAA;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,8 @@
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
+ export declare const getSelection: () => Selection | null;
8
+ export default getSelection;
@@ -0,0 +1,14 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ */
12
+ export const getSelection = () => window.getSelection();
13
+ export default getSelection;
14
+ //# sourceMappingURL=selection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/utils/selection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAqB,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;AAE1E,eAAe,YAAY,CAAC"}
@@ -0,0 +1,10 @@
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 { useLayoutEffect } from 'react';
9
+ export declare const useLayoutEffectImpl: typeof useLayoutEffect;
10
+ export default useLayoutEffectImpl;
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Copyright (c) 2021-2023 Datalayer, Inc.
3
+ *
4
+ * MIT License
5
+ */
6
+ /**
7
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
8
+ *
9
+ * This source code is licensed under the MIT license found in the
10
+ * LICENSE file in the root directory of this source tree.
11
+ *
12
+ */
13
+ import { useEffect, useLayoutEffect } from 'react';
14
+ import { CAN_USE_DOM } from './canUseDOM';
15
+ export const useLayoutEffectImpl = CAN_USE_DOM
16
+ ? useLayoutEffect
17
+ : useEffect;
18
+ export default useLayoutEffectImpl;
19
+ //# sourceMappingURL=useLayoutEffect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLayoutEffect.js","sourceRoot":"","sources":["../../src/utils/useLayoutEffect.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;GAMG;AAEH,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,OAAO,CAAC;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,mBAAmB,GAA2B,WAAW;IACpE,CAAC,CAAC,eAAe;IACjB,CAAC,CAAC,SAAS,CAAC;AAEd,eAAe,mBAAmB,CAAC"}