@collabchron/notiq 0.2.0 → 1.0.0
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 +230 -39
- package/dist/CodeActionMenuPlugin-EINOY4U4.mjs +15 -0
- package/dist/DynamicBlockComponent-NRQJ4WW4.mjs +161 -0
- package/dist/EquationComponent-CB6DFIHV.mjs +154 -0
- package/dist/ExcalidrawComponent-XW6646OH.mjs +528 -0
- package/dist/ExcalidrawPlugin-ZFHT62IF.mjs +14 -0
- package/dist/ExportPlugin-V2RLM63S.mjs +11 -0
- package/dist/FloatingLinkEditorPlugin-TRTCMSP4.mjs +12 -0
- package/dist/FloatingTextFormatToolbarPlugin-F2GY6LMI.mjs +30 -0
- package/dist/HintComponet-BRL6EAMS.mjs +217 -0
- package/dist/InlineImageComponent-UWIUWBHI.mjs +453 -0
- package/dist/MobileToolbar-BOOZAMQE.mjs +268 -0
- package/dist/SlashCommand-GMT5JI33.mjs +28 -0
- package/dist/StoryBuilderComponent-JGDBM5JU.mjs +562 -0
- package/{src/components/editor/plugins/TableCellActionMenuPlugin/index.tsx → dist/TableCellActionMenuPlugin-PGK2K3VG.mjs} +667 -759
- package/{src/components/editor/plugins/TableHoverActionsPlugin/index.tsx → dist/TableHoverActionsPlugin-GJVE6VRW.mjs} +258 -314
- package/dist/TemplatePlugin-ZD3QEVTI.mjs +9 -0
- package/dist/ToolbarPlugin-7TOZRD2R.mjs +1547 -0
- package/dist/babel-JZ2EV6AX.mjs +7233 -0
- package/dist/background-color-XZTYLGO2.mjs +362 -0
- package/dist/block-format-YJCV2DIY.mjs +15 -0
- package/dist/chunk-2FNEAMSP.mjs +127 -0
- package/dist/chunk-3CPBODXA.mjs +84 -0
- package/dist/chunk-3G37YKTV.mjs +83 -0
- package/dist/chunk-3JVFG7ER.mjs +184 -0
- package/dist/chunk-456TN7IM.mjs +110 -0
- package/dist/chunk-4EXYCTGJ.mjs +27 -0
- package/{src/utils/getSelectedNode.ts → dist/chunk-4HBCVSE6.mjs} +26 -27
- package/dist/chunk-4MEDW3T6.mjs +125 -0
- package/dist/chunk-4VWFVWYP.mjs +36 -0
- package/dist/chunk-5BAKY5KN.mjs +84 -0
- package/dist/chunk-5QSNIVIG.mjs +333 -0
- package/dist/chunk-64Z3FI7T.mjs +37 -0
- package/{src/components/editor/nodes/Stepper/index.tsx → dist/chunk-6RNZQOH2.mjs} +214 -260
- package/dist/chunk-77KXU36M.mjs +64 -0
- package/dist/chunk-77UA6HYR.mjs +165 -0
- package/dist/chunk-7NZAPJ4G.mjs +102 -0
- package/dist/chunk-7VUMHWWL.mjs +152 -0
- package/dist/chunk-AMMKBSST.mjs +1256 -0
- package/dist/chunk-BIU7WTLX.mjs +95 -0
- package/dist/chunk-EGMI62PP.mjs +83 -0
- package/dist/chunk-EHNQD5KO.mjs +88 -0
- package/dist/chunk-FSM26655.mjs +37 -0
- package/{src/components/editor/nodes/Hint/index.tsx → dist/chunk-G53GLEAY.mjs} +158 -190
- package/dist/chunk-GK35L7UY.mjs +28 -0
- package/dist/chunk-GXYD4VZM.mjs +193 -0
- package/dist/chunk-GYIOYVCN.mjs +538 -0
- package/dist/chunk-GZPNVR7L.mjs +157 -0
- package/dist/chunk-JXDPPUJI.mjs +52 -0
- package/dist/chunk-K36V4SIW.mjs +141 -0
- package/dist/chunk-KJ6AJ44Q.mjs +128 -0
- package/dist/chunk-KJV3FAZ7.mjs +142 -0
- package/{src/components/editor/plugins/ImagesPlugin/index.tsx → dist/chunk-LGG4IUIA.mjs} +189 -222
- package/dist/chunk-LQN3CMKV.mjs +1906 -0
- package/dist/chunk-N3WN46VL.mjs +236 -0
- package/dist/chunk-PBD6LMLC.mjs +366 -0
- package/dist/chunk-POGRR73N.mjs +33 -0
- package/{src/components/editor/utils/editorFormatting.ts → dist/chunk-PZSUSXQG.mjs} +238 -282
- package/dist/chunk-QEIFVK5M.mjs +29 -0
- package/dist/chunk-QHIQKMVN.mjs +427 -0
- package/dist/chunk-TCYK7DM7.mjs +36 -0
- package/dist/chunk-TTHQCW5F.mjs +47 -0
- package/dist/chunk-U47ABU5Z.mjs +53 -0
- package/dist/chunk-WDG7J2DY.mjs +116 -0
- package/dist/chunk-WJRHXI2C.mjs +733 -0
- package/dist/chunk-XLER2DHM.mjs +357 -0
- package/dist/chunk-XWC4TK2N.mjs +315 -0
- package/dist/chunk-YHPNOWFH.mjs +15 -0
- package/dist/chunk-YKC3SO4Z.mjs +32 -0
- package/dist/chunk-YMBXLRW5.mjs +374 -0
- package/dist/chunk-YPHOEJ46.mjs +64 -0
- package/dist/chunk-YUDCJRJM.mjs +25 -0
- package/dist/chunk-Z4EWP7BI.mjs +65 -0
- package/dist/chunk-ZB5LZQKC.mjs +191 -0
- package/dist/chunk-ZJRKATOJ.mjs +65 -0
- package/dist/color-BPKOPQKN.mjs +12 -0
- package/dist/estree-XC56IUFX.mjs +4414 -0
- package/dist/font-FEZ3GKSF.mjs +13 -0
- package/dist/font-size-EK775WRH.mjs +15 -0
- package/dist/html-S3ACX7NI.mjs +2738 -0
- package/dist/image-2PJIAYAT.mjs +993 -0
- package/dist/index.d.mts +145 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.js +57855 -0
- package/dist/index.mjs +1790 -0
- package/dist/insert-gif-SAIDYURE.mjs +100 -0
- package/dist/insert-image-U3RJN3OW.mjs +259 -0
- package/dist/insert-node-5P2CRJ7S.mjs +201 -0
- package/dist/insert-poll-HCPM7MO6.mjs +33 -0
- package/dist/insert-table-24XYUS2W.mjs +66 -0
- package/dist/markdown-SNVBOSRA.mjs +3487 -0
- package/dist/poll-component-2R4MDLHS.mjs +303 -0
- package/dist/postcss-ONF3VDIM.mjs +5051 -0
- package/dist/standalone-EOIALU3M.mjs +2373 -0
- package/dist/stepper-FSARL6X6.mjs +304 -0
- package/dist/styles/notiq.css +1149 -0
- package/dist/text-align-VLECWO4H.mjs +118 -0
- package/dist/text-format-BG5WOOPZ.mjs +16 -0
- package/dist/typescript-AMPI6OVS.mjs +13135 -0
- package/package.json +94 -10
- package/src/styles/notiq.css +1149 -0
- package/src/styles/tailwind-plugin.ts +134 -0
- package/components.json +0 -21
- package/eslint.config.mjs +0 -16
- package/next.config.ts +0 -12
- package/postcss.config.mjs +0 -5
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/images/icons/plus.svg +0 -10
- package/public/next.svg +0 -1
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/src/app/actions.ts +0 -2
- package/src/app/api/ai/route.ts +0 -175
- package/src/app/api/edgestore/[...edgestore]/route.ts +0 -28
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +0 -205
- package/src/app/layout.tsx +0 -38
- package/src/app/page.tsx +0 -12
- package/src/components/editor/Core.tsx +0 -220
- package/src/components/editor/hooks/instructions-messages.ts +0 -300
- package/src/components/editor/hooks/use-mobile.ts +0 -19
- package/src/components/editor/hooks/useReport.ts +0 -67
- package/src/components/editor/hooks/useResizeObservert.ts +0 -22
- package/src/components/editor/index.tsx +0 -39
- package/src/components/editor/lexical-on-change.tsx +0 -28
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContainerNode.ts +0 -92
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleContentNode.ts +0 -65
- package/src/components/editor/nodes/CollapsibleNode/CollapsibleTitleNode.ts +0 -105
- package/src/components/editor/nodes/EquationNode/EquationComponent.tsx +0 -143
- package/src/components/editor/nodes/EquationNode/EquationNode.tsx +0 -170
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawComponent.tsx +0 -228
- package/src/components/editor/nodes/ExcalidrawNode/ExcalidrawImage.tsx +0 -137
- package/src/components/editor/nodes/ExcalidrawNode/ImageResizer.tsx +0 -317
- package/src/components/editor/nodes/ExcalidrawNode/index.tsx +0 -204
- package/src/components/editor/nodes/FigmaNode/FigmaNode.tsx +0 -134
- package/src/components/editor/nodes/Hint/HintComponet.tsx +0 -221
- package/src/components/editor/nodes/ImageNode/index.tsx +0 -328
- package/src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx +0 -383
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.css +0 -94
- package/src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx +0 -309
- package/src/components/editor/nodes/LayoutNode/LayoutContainerNode.ts +0 -146
- package/src/components/editor/nodes/LayoutNode/LayoutItemNode.ts +0 -79
- package/src/components/editor/nodes/PollNode/index.tsx +0 -204
- package/src/components/editor/nodes/TweetNode/index.tsx +0 -214
- package/src/components/editor/nodes/index.ts +0 -81
- package/src/components/editor/plugins/AutoEmbedPlugin/index.tsx +0 -350
- package/src/components/editor/plugins/AutoLinkPlugin/index.tsx +0 -56
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx +0 -70
- package/src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx +0 -192
- package/src/components/editor/plugins/CodeActionMenuPlugin/index.tsx +0 -217
- package/src/components/editor/plugins/CodeActionMenuPlugin/utils.ts +0 -26
- package/src/components/editor/plugins/CodeHighlightPlugin/index.ts +0 -21
- package/src/components/editor/plugins/CollapsiblePlugin/Collapsible.css +0 -76
- package/src/components/editor/plugins/CollapsiblePlugin/index.ts +0 -228
- package/src/components/editor/plugins/DragDropPastePlugin/index.tsx +0 -44
- package/src/components/editor/plugins/DraggableBlockPlugin/index.tsx +0 -52
- package/src/components/editor/plugins/EquationsPlugin/index.tsx +0 -85
- package/src/components/editor/plugins/ExcalidrawPlugin/index.tsx +0 -98
- package/src/components/editor/plugins/FigmaPlugin/index.tsx +0 -42
- package/src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx +0 -445
- package/src/components/editor/plugins/FloatingTextFormatToolbarPlugin/index.tsx +0 -275
- package/src/components/editor/plugins/InlineImagePlugin/index.tsx +0 -351
- package/src/components/editor/plugins/LayoutPlugin/index.tsx +0 -238
- package/src/components/editor/plugins/LinkPlugin/index.tsx +0 -36
- package/src/components/editor/plugins/LinkWithMetaData/index.tsx +0 -271
- package/src/components/editor/plugins/MarkdownShortcutPlugin/index.tsx +0 -11
- package/src/components/editor/plugins/MarkdownTransformers/index.tsx +0 -304
- package/src/components/editor/plugins/PollPlugin/index.tsx +0 -49
- package/src/components/editor/plugins/ShortcutsPlugin/index.tsx +0 -180
- package/src/components/editor/plugins/ShortcutsPlugin/shortcuts.ts +0 -253
- package/src/components/editor/plugins/SlashCommand/index.tsx +0 -621
- package/src/components/editor/plugins/SpeechToTextPlugin/index.ts +0 -127
- package/src/components/editor/plugins/TabFocusPlugin/index.ts +0 -58
- package/src/components/editor/plugins/TableCellResizer/index.tsx +0 -438
- package/src/components/editor/plugins/TablePlugin/index.tsx +0 -99
- package/src/components/editor/plugins/ToolbarPlugin/index.tsx +0 -522
- package/src/components/editor/plugins/TwitterPlugin/index.ts +0 -35
- package/src/components/editor/plugins/YouTubeNode/index.tsx +0 -179
- package/src/components/editor/plugins/YouTubePlugin/index.ts +0 -41
- package/src/components/editor/themes/editor-theme.ts +0 -113
- package/src/components/editor/themes/theme.css +0 -377
- package/src/components/editor/utils/ai.ts +0 -291
- package/src/components/editor/utils/canUseDOM.ts +0 -12
- package/src/components/editor/utils/environment.ts +0 -50
- package/src/components/editor/utils/extract-data.ts +0 -166
- package/src/components/editor/utils/getAllLexicalChildren.ts +0 -13
- package/src/components/editor/utils/getDOMRangeRect.ts +0 -27
- package/src/components/editor/utils/getSelectedNode.ts +0 -27
- package/src/components/editor/utils/gif.ts +0 -29
- package/src/components/editor/utils/invariant.ts +0 -15
- package/src/components/editor/utils/setFloatingElemPosition.ts +0 -51
- package/src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts +0 -40
- package/src/components/editor/utils/setNodePlaceholderFromSelection/getNodePlaceholder.ts +0 -51
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setNodePlaceholderFromSelection.ts +0 -15
- package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts +0 -114
- package/src/components/editor/utils/setNodePlaceholderFromSelection/styles.css +0 -6
- package/src/components/editor/utils/url.ts +0 -109
- package/src/components/editor/utils/useLayoutEffect.ts +0 -13
- package/src/components/providers/QueryProvider.tsx +0 -15
- package/src/components/providers/SharedHistoryContext.tsx +0 -28
- package/src/components/providers/ToolbarContext.tsx +0 -123
- package/src/components/providers/theme-provider.tsx +0 -11
- package/src/components/theme/ModeToggle.tsx +0 -40
- package/src/components/ui/FileInput.tsx +0 -40
- package/src/components/ui/Input.css +0 -32
- package/src/components/ui/Select.css +0 -42
- package/src/components/ui/Select.tsx +0 -36
- package/src/components/ui/TextInput.tsx +0 -48
- package/src/components/ui/ai/ai-button.tsx +0 -574
- package/src/components/ui/ai/border.tsx +0 -99
- package/src/components/ui/ai/placeholder-input-vanish.tsx +0 -282
- package/src/components/ui/button.tsx +0 -89
- package/src/components/ui/card.tsx +0 -76
- package/src/components/ui/checkbox.tsx +0 -30
- package/src/components/ui/command.tsx +0 -153
- package/src/components/ui/dialog/Dialog.css +0 -25
- package/src/components/ui/dialog/Dialog.tsx +0 -34
- package/src/components/ui/dialog.tsx +0 -122
- package/src/components/ui/drop-downs/background-color.tsx +0 -183
- package/src/components/ui/drop-downs/block-format.tsx +0 -159
- package/src/components/ui/drop-downs/code.tsx +0 -42
- package/src/components/ui/drop-downs/color.tsx +0 -177
- package/src/components/ui/drop-downs/font-size.tsx +0 -138
- package/src/components/ui/drop-downs/font.tsx +0 -155
- package/src/components/ui/drop-downs/index.tsx +0 -122
- package/src/components/ui/drop-downs/insert-node.tsx +0 -213
- package/src/components/ui/drop-downs/text-align.tsx +0 -123
- package/src/components/ui/drop-downs/text-format.tsx +0 -104
- package/src/components/ui/dropdown-menu.tsx +0 -201
- package/src/components/ui/equation/EquationEditor.css +0 -38
- package/src/components/ui/equation/EquationEditor.tsx +0 -56
- package/src/components/ui/equation/KatexEquationAlterer.css +0 -41
- package/src/components/ui/equation/KatexEquationAlterer.tsx +0 -83
- package/src/components/ui/equation/KatexRenderer.tsx +0 -66
- package/src/components/ui/excalidraw/ExcalidrawModal.css +0 -64
- package/src/components/ui/excalidraw/ExcalidrawModal.tsx +0 -234
- package/src/components/ui/excalidraw/Modal.css +0 -62
- package/src/components/ui/excalidraw/Modal.tsx +0 -110
- package/src/components/ui/hover-card.tsx +0 -29
- package/src/components/ui/image/error-image.tsx +0 -17
- package/src/components/ui/image/file-upload.tsx +0 -240
- package/src/components/ui/image/image-resizer.tsx +0 -297
- package/src/components/ui/image/image-toolbar.tsx +0 -264
- package/src/components/ui/image/index.tsx +0 -408
- package/src/components/ui/image/lazy-image.tsx +0 -68
- package/src/components/ui/image/lazy-video.tsx +0 -71
- package/src/components/ui/input.tsx +0 -22
- package/src/components/ui/models/custom-dialog.tsx +0 -320
- package/src/components/ui/models/insert-gif.tsx +0 -90
- package/src/components/ui/models/insert-image.tsx +0 -52
- package/src/components/ui/models/insert-poll.tsx +0 -29
- package/src/components/ui/models/insert-table.tsx +0 -62
- package/src/components/ui/models/use-model.tsx +0 -91
- package/src/components/ui/poll/poll-component.tsx +0 -304
- package/src/components/ui/popover.tsx +0 -33
- package/src/components/ui/progress.tsx +0 -28
- package/src/components/ui/scroll-area.tsx +0 -48
- package/src/components/ui/separator.tsx +0 -31
- package/src/components/ui/skeleton.tsx +0 -15
- package/src/components/ui/sonner.tsx +0 -31
- package/src/components/ui/stepper/step.tsx +0 -179
- package/src/components/ui/stepper/stepper.tsx +0 -89
- package/src/components/ui/textarea.tsx +0 -22
- package/src/components/ui/toggle.tsx +0 -71
- package/src/components/ui/tooltip.tsx +0 -32
- package/src/components/ui/write/text-format-floting-toolbar.tsx +0 -346
- package/src/lib/edgestore.ts +0 -9
- package/src/lib/pinecone-client.ts +0 -0
- package/src/lib/utils.ts +0 -6
- package/src/utils/docSerialization.ts +0 -77
- package/src/utils/emoji-list.ts +0 -16615
- package/src/utils/getDOMRangeRect.ts +0 -27
- package/src/utils/getThemeSelector.ts +0 -25
- package/src/utils/isMobileWidth.ts +0 -7
- package/src/utils/joinClasses.ts +0 -13
- package/src/utils/setFloatingElemPosition.ts +0 -74
- package/src/utils/setFloatingElemPositionForLinkEditor.ts +0 -46
- package/src/utils/swipe.ts +0 -127
- package/src/utils/url.ts +0 -38
- package/tsconfig.json +0 -27
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const VERTICAL_GAP = 10;
|
|
3
|
-
const HORIZONTAL_OFFSET = 5;
|
|
4
|
-
|
|
5
|
-
export function setFloatingElemPositionForLinkEditor(
|
|
6
|
-
targetRect: DOMRect | null,
|
|
7
|
-
floatingElem: HTMLElement,
|
|
8
|
-
anchorElem: HTMLElement,
|
|
9
|
-
verticalGap: number = VERTICAL_GAP,
|
|
10
|
-
horizontalOffset: number = HORIZONTAL_OFFSET,
|
|
11
|
-
): void {
|
|
12
|
-
const scrollerElem = anchorElem.parentElement;
|
|
13
|
-
|
|
14
|
-
if (targetRect === null || !scrollerElem) {
|
|
15
|
-
floatingElem.style.opacity = '0';
|
|
16
|
-
floatingElem.style.transform = 'translate(-10000px, -10000px)';
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const floatingElemRect = floatingElem.getBoundingClientRect();
|
|
21
|
-
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
22
|
-
const editorScrollerRect = scrollerElem.getBoundingClientRect();
|
|
23
|
-
|
|
24
|
-
let top = targetRect.top - verticalGap;
|
|
25
|
-
let left = targetRect.left - horizontalOffset;
|
|
26
|
-
|
|
27
|
-
if (top < editorScrollerRect.top) {
|
|
28
|
-
top += floatingElemRect.height + targetRect.height + verticalGap * 2;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (left + floatingElemRect.width > editorScrollerRect.right) {
|
|
32
|
-
left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
top -= anchorElementRect.top;
|
|
36
|
-
left -= anchorElementRect.left;
|
|
37
|
-
|
|
38
|
-
floatingElem.style.opacity = '1';
|
|
39
|
-
floatingElem.style.transform = `translate(${left}px, ${top}px)`;
|
|
40
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { $isParagraphNode, LexicalNode } from 'lexical';
|
|
2
|
-
import { $isHeadingNode, $isQuoteNode } from '@lexical/rich-text';
|
|
3
|
-
import {$isListItemNode} from "@lexical/list"
|
|
4
|
-
export const getNodePlaceholder = (lexicalNode: LexicalNode) => {
|
|
5
|
-
let placeholder;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if ($isHeadingNode(lexicalNode)) {
|
|
9
|
-
const tag = lexicalNode.getTag();
|
|
10
|
-
placeholder = 'Heading'
|
|
11
|
-
switch (tag) {
|
|
12
|
-
case 'h1': {
|
|
13
|
-
placeholder += ' 1';
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
case 'h2': {
|
|
17
|
-
placeholder += ' 2';
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
case 'h3': {
|
|
21
|
-
placeholder += ' 3';
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
case 'h4': {
|
|
25
|
-
placeholder += ' 4';
|
|
26
|
-
break;
|
|
27
|
-
}
|
|
28
|
-
case 'h5': {
|
|
29
|
-
placeholder += '5';
|
|
30
|
-
break;
|
|
31
|
-
}
|
|
32
|
-
case 'h6': {
|
|
33
|
-
placeholder += '6';
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
if($isListItemNode(lexicalNode)){
|
|
39
|
-
placeholder = "list"
|
|
40
|
-
}
|
|
41
|
-
if($isQuoteNode(lexicalNode)){
|
|
42
|
-
placeholder = "Quote"
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if ($isParagraphNode(lexicalNode)) {
|
|
46
|
-
|
|
47
|
-
placeholder = "Press '/' for command";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return placeholder;
|
|
51
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { $getSelection, $isRangeSelection, LexicalEditor } from 'lexical';
|
|
3
|
-
import { setPlaceholderOnSelection } from './setPlaceholderOnSelection';
|
|
4
|
-
|
|
5
|
-
export const setNodePlaceholderFromSelection = (
|
|
6
|
-
editor: LexicalEditor,
|
|
7
|
-
): void => {
|
|
8
|
-
editor.getEditorState().read(() => {
|
|
9
|
-
const selection = $getSelection();
|
|
10
|
-
if (!$isRangeSelection(selection)) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
setPlaceholderOnSelection({ selection, editor });
|
|
14
|
-
});
|
|
15
|
-
};
|
package/src/components/editor/utils/setNodePlaceholderFromSelection/setPlaceholderOnSelection.ts
DELETED
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { LexicalEditor, PointType, RangeSelection } from 'lexical';
|
|
2
|
-
import { getAllLexicalChildren } from '../getAllLexicalChildren';
|
|
3
|
-
import { getNodePlaceholder } from './getNodePlaceholder';
|
|
4
|
-
|
|
5
|
-
import './styles.css';
|
|
6
|
-
import { $isCollapsibleContainerNode } from '../../nodes/CollapsibleNode/CollapsibleContainerNode';
|
|
7
|
-
import { $isCollapsibleContentNode } from '../../nodes/CollapsibleNode/CollapsibleContentNode';
|
|
8
|
-
|
|
9
|
-
const PLACEHOLDER_CLASS_NAME = 'node-placeholder';
|
|
10
|
-
|
|
11
|
-
const isHtmlHeadingElement = (el: HTMLElement): el is HTMLHeadingElement => {
|
|
12
|
-
return el instanceof HTMLHeadingElement;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const setPlaceholderOnSelection = ({
|
|
16
|
-
selection,
|
|
17
|
-
editor,
|
|
18
|
-
}: {
|
|
19
|
-
selection: RangeSelection;
|
|
20
|
-
editor: LexicalEditor;
|
|
21
|
-
}): void => {
|
|
22
|
-
/**
|
|
23
|
-
* 1. Get all lexical nodes as HTML elements
|
|
24
|
-
*/
|
|
25
|
-
const children = getAllLexicalChildren(editor);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* 2. Remove "placeholder" class if it was added before
|
|
30
|
-
*/
|
|
31
|
-
const removePlaceholderClass = (element: HTMLElement) => {
|
|
32
|
-
if (!element) return;
|
|
33
|
-
|
|
34
|
-
// Remove the placeholder class from the current element
|
|
35
|
-
if (element.classList.contains(PLACEHOLDER_CLASS_NAME)) {
|
|
36
|
-
element.classList.remove(PLACEHOLDER_CLASS_NAME);
|
|
37
|
-
element.removeAttribute('data-placeholder');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Recursively process child elements
|
|
41
|
-
Array.from(element.children).forEach(child => {
|
|
42
|
-
if (child instanceof HTMLElement) {
|
|
43
|
-
removePlaceholderClass(child);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
children.forEach(({ htmlElement,node }:any) => {
|
|
49
|
-
if (!htmlElement) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (isHtmlHeadingElement(htmlElement)) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const classList = htmlElement.classList;
|
|
60
|
-
if (node.__type === 'collapsible-container') {
|
|
61
|
-
removePlaceholderClass(htmlElement);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (node.__type === 'table') {
|
|
65
|
-
removePlaceholderClass(htmlElement);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if(node.__type==="layout-container"){
|
|
69
|
-
removePlaceholderClass(htmlElement);
|
|
70
|
-
}
|
|
71
|
-
if (classList.length && classList.contains(PLACEHOLDER_CLASS_NAME)) {
|
|
72
|
-
classList.remove(PLACEHOLDER_CLASS_NAME);
|
|
73
|
-
htmlElement.removeAttribute('data-placeholder');
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* 3. Do nothing if there is only one lexical child,
|
|
80
|
-
* because we already have a placeholder
|
|
81
|
-
* in <RichTextPlugin/> component
|
|
82
|
-
* With on exception: If we converted default node to the "Heading"
|
|
83
|
-
*/
|
|
84
|
-
if (
|
|
85
|
-
children.length === 1 &&
|
|
86
|
-
children[0].htmlElement &&
|
|
87
|
-
!isHtmlHeadingElement(children[0].htmlElement)
|
|
88
|
-
) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* 4. Get "PointType" object, that contain Nodes data
|
|
94
|
-
* (that is selected)
|
|
95
|
-
* {
|
|
96
|
-
* key: "5", <- Node's key
|
|
97
|
-
* offset: 7,
|
|
98
|
-
* type: "text"
|
|
99
|
-
* }
|
|
100
|
-
*/
|
|
101
|
-
const anchor: PointType = selection.anchor;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* 5. Get placeholder for type ('heading'/'paragraph'/etc...)
|
|
105
|
-
*/
|
|
106
|
-
const placeholder = getNodePlaceholder(anchor.getNode());
|
|
107
|
-
|
|
108
|
-
if (placeholder) {
|
|
109
|
-
const selectedHtmlElement = editor.getElementByKey(anchor.key);
|
|
110
|
-
|
|
111
|
-
selectedHtmlElement?.classList.add(PLACEHOLDER_CLASS_NAME);
|
|
112
|
-
selectedHtmlElement?.setAttribute('data-placeholder', placeholder);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const SUPPORTED_URL_PROTOCOLS = new Set([
|
|
4
|
-
'http:',
|
|
5
|
-
'https:',
|
|
6
|
-
'mailto:',
|
|
7
|
-
'sms:',
|
|
8
|
-
'tel:',
|
|
9
|
-
'ftp:',
|
|
10
|
-
]);
|
|
11
|
-
|
|
12
|
-
export function sanitizeUrl(url: string): string {
|
|
13
|
-
try {
|
|
14
|
-
const parsedUrl = new URL(url);
|
|
15
|
-
// eslint-disable-next-line no-script-url
|
|
16
|
-
if (!SUPPORTED_URL_PROTOCOLS.has(parsedUrl.protocol)) {
|
|
17
|
-
return 'about:blank';
|
|
18
|
-
}
|
|
19
|
-
} catch {
|
|
20
|
-
return url;
|
|
21
|
-
}
|
|
22
|
-
return url;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Source: https://stackoverflow.com/a/8234912/2013580
|
|
26
|
-
const urlRegExp = new RegExp(
|
|
27
|
-
/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/,
|
|
28
|
-
);
|
|
29
|
-
export function validateUrl(url: string): boolean {
|
|
30
|
-
// TODO Fix UI for link insertion; it should never default to an invalid URL such as https://.
|
|
31
|
-
// Maybe show a dialog where they user can type the URL before inserting it.
|
|
32
|
-
return url === 'https://' || urlRegExp.test(url);
|
|
33
|
-
}
|
|
34
|
-
interface Metadata{
|
|
35
|
-
title:string,
|
|
36
|
-
description:string,
|
|
37
|
-
image:string | undefined
|
|
38
|
-
website:string,
|
|
39
|
-
logo:string
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export async function fetchMetadata(url: string): Promise<Metadata> {
|
|
44
|
-
try {
|
|
45
|
-
const proxyUrl = "https://api.allorigins.win/get?url=";
|
|
46
|
-
const response = await fetch(`${proxyUrl}${encodeURIComponent(url)}`);
|
|
47
|
-
const data = await response.json();
|
|
48
|
-
|
|
49
|
-
// Extract the HTML content from the proxy response
|
|
50
|
-
const html = data.contents;
|
|
51
|
-
|
|
52
|
-
// Parse the HTML using DOMParser
|
|
53
|
-
const parser = new DOMParser();
|
|
54
|
-
const doc = parser.parseFromString(html, "text/html");
|
|
55
|
-
|
|
56
|
-
// Helper function to extract meta tag content
|
|
57
|
-
const getMetaTagContent = (property: string) => {
|
|
58
|
-
const element =
|
|
59
|
-
doc.querySelector(`meta[property="${property}"]`) ||
|
|
60
|
-
doc.querySelector(`meta[name="${property}"]`);
|
|
61
|
-
return element ? element.getAttribute("content") : null;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// Helper function to extract favicon or logo
|
|
65
|
-
const getFavicon = () => {
|
|
66
|
-
// Check for common favicon locations
|
|
67
|
-
const favicon =
|
|
68
|
-
doc.querySelector('link[rel="icon"]') ||
|
|
69
|
-
doc.querySelector('link[rel="shortcut icon"]') ||
|
|
70
|
-
doc.querySelector('link[rel="apple-touch-icon"]');
|
|
71
|
-
|
|
72
|
-
if (favicon) {
|
|
73
|
-
const href = favicon.getAttribute("href");
|
|
74
|
-
if (href) {
|
|
75
|
-
// Resolve relative URLs to absolute URLs
|
|
76
|
-
return new URL(href, url).toString();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Fallback to default favicon location
|
|
81
|
-
return new URL("/favicon.ico", url).toString();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// Extract metadata
|
|
85
|
-
const metadata = {
|
|
86
|
-
title:
|
|
87
|
-
doc.querySelector("title")?.textContent ||
|
|
88
|
-
getMetaTagContent("og:title") ||
|
|
89
|
-
"No title",
|
|
90
|
-
description:
|
|
91
|
-
getMetaTagContent("og:description") ||
|
|
92
|
-
getMetaTagContent("description") ||
|
|
93
|
-
"No description",
|
|
94
|
-
image: getMetaTagContent("og:image") || undefined, // Use a valid fallback image URL
|
|
95
|
-
website: getMetaTagContent("og:site_name") || new URL(url).hostname, // Use hostname as fallback
|
|
96
|
-
logo: getFavicon(), // Extract favicon or logo
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
return metadata;
|
|
100
|
-
} catch (error) {
|
|
101
|
-
return {
|
|
102
|
-
title: "No title",
|
|
103
|
-
description: "No description",
|
|
104
|
-
image: undefined,
|
|
105
|
-
website: new URL(url).hostname,
|
|
106
|
-
logo: new URL("/favicon.ico", url).toString(), // Fallback to default favicon
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import {useEffect, useLayoutEffect} from 'react';
|
|
4
|
-
import { CAN_USE_DOM } from './canUseDOM';
|
|
5
|
-
|
|
6
|
-
// This workaround is no longer necessary in React 19,
|
|
7
|
-
// but we currently support React >=17.x
|
|
8
|
-
// https://github.com/facebook/react/pull/26395
|
|
9
|
-
const useLayoutEffectImpl: typeof useLayoutEffect = CAN_USE_DOM
|
|
10
|
-
? useLayoutEffect
|
|
11
|
-
: useEffect;
|
|
12
|
-
|
|
13
|
-
export default useLayoutEffectImpl;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
|
|
4
|
-
import { useState } from "react";
|
|
5
|
-
|
|
6
|
-
interface Props {
|
|
7
|
-
children: React.ReactNode;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default function QueryProvider({ children }: Props) {
|
|
11
|
-
const [queryClient] = useState(() => new QueryClient());
|
|
12
|
-
return (
|
|
13
|
-
<QueryClientProvider client={queryClient}> {children} </QueryClientProvider>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
import type {HistoryState} from '@lexical/react/LexicalHistoryPlugin';
|
|
3
|
-
import {createEmptyHistoryState} from '@lexical/react/LexicalHistoryPlugin';
|
|
4
|
-
|
|
5
|
-
import * as React from 'react';
|
|
6
|
-
import {createContext, ReactNode, useContext, useMemo} from 'react';
|
|
7
|
-
|
|
8
|
-
type ContextShape = {
|
|
9
|
-
historyState?: HistoryState;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const Context: React.Context<ContextShape> = createContext({});
|
|
13
|
-
|
|
14
|
-
export const SharedHistoryContext = ({
|
|
15
|
-
children,
|
|
16
|
-
}: {
|
|
17
|
-
children: ReactNode;
|
|
18
|
-
}) => {
|
|
19
|
-
const historyContext = useMemo(
|
|
20
|
-
() => ({historyState: createEmptyHistoryState()}),
|
|
21
|
-
[],
|
|
22
|
-
);
|
|
23
|
-
return <Context.Provider value={historyContext}>{children}</Context.Provider>;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const useSharedHistoryContext = (): ContextShape => {
|
|
27
|
-
return useContext(Context);
|
|
28
|
-
};
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
import {ElementFormatType} from 'lexical';
|
|
3
|
-
import React, {
|
|
4
|
-
createContext,
|
|
5
|
-
ReactNode,
|
|
6
|
-
useCallback,
|
|
7
|
-
useContext,
|
|
8
|
-
useEffect,
|
|
9
|
-
useMemo,
|
|
10
|
-
useState,
|
|
11
|
-
} from 'react';
|
|
12
|
-
|
|
13
|
-
export const MIN_ALLOWED_FONT_SIZE = 8;
|
|
14
|
-
export const MAX_ALLOWED_FONT_SIZE = 72;
|
|
15
|
-
export const DEFAULT_FONT_SIZE = 15;
|
|
16
|
-
|
|
17
|
-
const rootTypeToRootName = {
|
|
18
|
-
root: 'Root',
|
|
19
|
-
table: 'Table',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const blockTypeToBlockName = {
|
|
23
|
-
bullet: 'Bulleted List',
|
|
24
|
-
check: 'Check List',
|
|
25
|
-
code: 'Code Block',
|
|
26
|
-
h1: 'Heading 1',
|
|
27
|
-
h2: 'Heading 2',
|
|
28
|
-
h3: 'Heading 3',
|
|
29
|
-
h4: 'Heading 4',
|
|
30
|
-
h5: 'Heading 5',
|
|
31
|
-
h6: 'Heading 6',
|
|
32
|
-
number: 'Numbered List',
|
|
33
|
-
paragraph: 'Normal',
|
|
34
|
-
quote: 'Quote',
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const INITIAL_TOOLBAR_STATE = {
|
|
38
|
-
bgColor: '#fff',
|
|
39
|
-
blockType: 'paragraph' as keyof typeof blockTypeToBlockName,
|
|
40
|
-
canRedo: false,
|
|
41
|
-
canUndo: false,
|
|
42
|
-
codeLanguage: '',
|
|
43
|
-
elementFormat: 'left' as ElementFormatType,
|
|
44
|
-
fontColor: '#000',
|
|
45
|
-
fontFamily: 'Arial',
|
|
46
|
-
// Current font size in px
|
|
47
|
-
fontSize: `${DEFAULT_FONT_SIZE}px`,
|
|
48
|
-
// Font size input value - for controlled input
|
|
49
|
-
fontSizeInputValue: `${DEFAULT_FONT_SIZE}`,
|
|
50
|
-
isBold: false,
|
|
51
|
-
isCode: false,
|
|
52
|
-
isImageCaption: false,
|
|
53
|
-
isItalic: false,
|
|
54
|
-
isLink: false,
|
|
55
|
-
isRTL: false,
|
|
56
|
-
isStrikethrough: false,
|
|
57
|
-
isSubscript: false,
|
|
58
|
-
isSuperscript: false,
|
|
59
|
-
isUnderline: false,
|
|
60
|
-
isLowercase: false,
|
|
61
|
-
isUppercase: false,
|
|
62
|
-
isCapitalize: false,
|
|
63
|
-
rootType: 'root' as keyof typeof rootTypeToRootName,
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
type ToolbarState = typeof INITIAL_TOOLBAR_STATE;
|
|
67
|
-
|
|
68
|
-
// Utility type to get keys and infer value types
|
|
69
|
-
type ToolbarStateKey = keyof ToolbarState;
|
|
70
|
-
type ToolbarStateValue<Key extends ToolbarStateKey> = ToolbarState[Key];
|
|
71
|
-
|
|
72
|
-
export type ContextShape = {
|
|
73
|
-
toolbarState: ToolbarState;
|
|
74
|
-
updateToolbarState<Key extends ToolbarStateKey>(
|
|
75
|
-
key: Key,
|
|
76
|
-
value: ToolbarStateValue<Key>,
|
|
77
|
-
): void;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
const Context = createContext<ContextShape | undefined>(undefined);
|
|
82
|
-
|
|
83
|
-
export const ToolbarContext = ({
|
|
84
|
-
children,
|
|
85
|
-
}: {
|
|
86
|
-
children: ReactNode;
|
|
87
|
-
}) => {
|
|
88
|
-
const [toolbarState, setToolbarState] = useState(INITIAL_TOOLBAR_STATE);
|
|
89
|
-
const selectionFontSize = toolbarState.fontSize;
|
|
90
|
-
|
|
91
|
-
const updateToolbarState = useCallback(
|
|
92
|
-
<Key extends ToolbarStateKey>(key: Key, value: ToolbarStateValue<Key>) => {
|
|
93
|
-
setToolbarState((prev) => ({
|
|
94
|
-
...prev,
|
|
95
|
-
[key]: value,
|
|
96
|
-
}));
|
|
97
|
-
},
|
|
98
|
-
[],
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
useEffect(() => {
|
|
102
|
-
updateToolbarState('fontSizeInputValue', selectionFontSize.slice(0, -2));
|
|
103
|
-
}, [selectionFontSize, updateToolbarState]);
|
|
104
|
-
|
|
105
|
-
const contextValue = useMemo(() => {
|
|
106
|
-
return {
|
|
107
|
-
toolbarState,
|
|
108
|
-
updateToolbarState,
|
|
109
|
-
};
|
|
110
|
-
}, [toolbarState, updateToolbarState]);
|
|
111
|
-
|
|
112
|
-
return <Context.Provider value={contextValue}>{children}</Context.Provider>;
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const useToolbarState = () => {
|
|
116
|
-
const context = useContext(Context);
|
|
117
|
-
|
|
118
|
-
if (context === undefined) {
|
|
119
|
-
throw new Error('useToolbarState must be used within a ToolbarProvider');
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return context;
|
|
123
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import { ThemeProvider as NextThemesProvider } from "next-themes"
|
|
5
|
-
|
|
6
|
-
export function ThemeProvider({
|
|
7
|
-
children,
|
|
8
|
-
...props
|
|
9
|
-
}: React.ComponentProps<typeof NextThemesProvider>) {
|
|
10
|
-
return <NextThemesProvider {...props}>{children}</NextThemesProvider>
|
|
11
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import { Moon, Sun } from "lucide-react"
|
|
5
|
-
import { useTheme } from "next-themes"
|
|
6
|
-
|
|
7
|
-
import { Button } from "@/components/ui/button"
|
|
8
|
-
import {
|
|
9
|
-
DropdownMenu,
|
|
10
|
-
DropdownMenuContent,
|
|
11
|
-
DropdownMenuItem,
|
|
12
|
-
DropdownMenuTrigger,
|
|
13
|
-
} from "@/components/ui/dropdown-menu"
|
|
14
|
-
|
|
15
|
-
export function ModeToggle() {
|
|
16
|
-
const { setTheme } = useTheme()
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<DropdownMenu>
|
|
20
|
-
<DropdownMenuTrigger asChild>
|
|
21
|
-
<Button variant={"outline"} size={"Toolbar"} type="button" className="border-none">
|
|
22
|
-
<Sun className="h-[1.2rem] w-[1.2rem] scale-100 rotate-0 transition-all dark:scale-0 dark:-rotate-90" />
|
|
23
|
-
<Moon className="absolute h-[1.2rem] w-[1.2rem] scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0" />
|
|
24
|
-
<span className="sr-only">Toggle theme</span>
|
|
25
|
-
</Button>
|
|
26
|
-
</DropdownMenuTrigger>
|
|
27
|
-
<DropdownMenuContent align="end">
|
|
28
|
-
<DropdownMenuItem onClick={() => setTheme("light")}>
|
|
29
|
-
Light
|
|
30
|
-
</DropdownMenuItem>
|
|
31
|
-
<DropdownMenuItem onClick={() => setTheme("dark")}>
|
|
32
|
-
Dark
|
|
33
|
-
</DropdownMenuItem>
|
|
34
|
-
<DropdownMenuItem onClick={() => setTheme("system")}>
|
|
35
|
-
System
|
|
36
|
-
</DropdownMenuItem>
|
|
37
|
-
</DropdownMenuContent>
|
|
38
|
-
</DropdownMenu>
|
|
39
|
-
)
|
|
40
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
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 {JSX} from 'react';
|
|
10
|
-
|
|
11
|
-
import './Input.css';
|
|
12
|
-
|
|
13
|
-
import * as React from 'react';
|
|
14
|
-
|
|
15
|
-
type Props = Readonly<{
|
|
16
|
-
'data-test-id'?: string;
|
|
17
|
-
accept?: string;
|
|
18
|
-
label: string;
|
|
19
|
-
onChange: (files: FileList | null) => void;
|
|
20
|
-
}>;
|
|
21
|
-
|
|
22
|
-
export default function FileInput({
|
|
23
|
-
accept,
|
|
24
|
-
label,
|
|
25
|
-
onChange,
|
|
26
|
-
'data-test-id': dataTestId,
|
|
27
|
-
}: Props): JSX.Element {
|
|
28
|
-
return (
|
|
29
|
-
<div className="Input__wrapper">
|
|
30
|
-
<label className="Input__label">{label}</label>
|
|
31
|
-
<input
|
|
32
|
-
type="file"
|
|
33
|
-
accept={accept}
|
|
34
|
-
className="Input__input"
|
|
35
|
-
onChange={(e) => onChange(e.target.files)}
|
|
36
|
-
data-test-id={dataTestId}
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
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
|
-
select {
|
|
10
|
-
appearance: none;
|
|
11
|
-
-webkit-appearance: none;
|
|
12
|
-
-moz-appearance: none;
|
|
13
|
-
background-color: transparent;
|
|
14
|
-
border: none;
|
|
15
|
-
padding: 0 1em 0 0;
|
|
16
|
-
margin: 0;
|
|
17
|
-
font-family: inherit;
|
|
18
|
-
font-size: inherit;
|
|
19
|
-
cursor: inherit;
|
|
20
|
-
line-height: inherit;
|
|
21
|
-
|
|
22
|
-
z-index: 1;
|
|
23
|
-
outline: none;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
:root {
|
|
27
|
-
--select-border: #393939;
|
|
28
|
-
--select-focus: #101484;
|
|
29
|
-
--select-arrow: var(--select-border);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.select {
|
|
33
|
-
min-width: 160px;
|
|
34
|
-
max-width: 290px;
|
|
35
|
-
border: 1px solid var(--select-border);
|
|
36
|
-
border-radius: 0.25em;
|
|
37
|
-
padding: 0.25em 0.5em;
|
|
38
|
-
font-size: 1rem;
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
line-height: 1.4;
|
|
41
|
-
background: linear-gradient(to bottom, #ffffff 0%, #e5e5e5 100%);
|
|
42
|
-
}
|