@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
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getSelectedNode
|
|
3
|
+
} from "./chunk-4HBCVSE6.mjs";
|
|
4
|
+
import {
|
|
5
|
+
sanitizeUrl
|
|
6
|
+
} from "./chunk-4VWFVWYP.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Input
|
|
9
|
+
} from "./chunk-POGRR73N.mjs";
|
|
10
|
+
import {
|
|
11
|
+
Button
|
|
12
|
+
} from "./chunk-BIU7WTLX.mjs";
|
|
13
|
+
import {
|
|
14
|
+
cn
|
|
15
|
+
} from "./chunk-YHPNOWFH.mjs";
|
|
16
|
+
import {
|
|
17
|
+
React,
|
|
18
|
+
init_react_shim
|
|
19
|
+
} from "./chunk-77KXU36M.mjs";
|
|
20
|
+
|
|
21
|
+
// src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx
|
|
22
|
+
init_react_shim();
|
|
23
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
24
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
25
|
+
import { createPortal } from "react-dom";
|
|
26
|
+
import {
|
|
27
|
+
$createLinkNode,
|
|
28
|
+
$isAutoLinkNode,
|
|
29
|
+
$isLinkNode,
|
|
30
|
+
TOGGLE_LINK_COMMAND
|
|
31
|
+
} from "@lexical/link";
|
|
32
|
+
import { $findMatchingParent, mergeRegister } from "@lexical/utils";
|
|
33
|
+
import {
|
|
34
|
+
$getSelection,
|
|
35
|
+
$isLineBreakNode,
|
|
36
|
+
$isRangeSelection,
|
|
37
|
+
CLICK_COMMAND,
|
|
38
|
+
COMMAND_PRIORITY_CRITICAL,
|
|
39
|
+
COMMAND_PRIORITY_HIGH,
|
|
40
|
+
COMMAND_PRIORITY_LOW,
|
|
41
|
+
getDOMSelection,
|
|
42
|
+
KEY_ESCAPE_COMMAND,
|
|
43
|
+
SELECTION_CHANGE_COMMAND
|
|
44
|
+
} from "lexical";
|
|
45
|
+
|
|
46
|
+
// src/components/editor/utils/setFloatingElemPositionForLinkEditor.ts
|
|
47
|
+
init_react_shim();
|
|
48
|
+
var VERTICAL_GAP = 10;
|
|
49
|
+
var HORIZONTAL_OFFSET = 5;
|
|
50
|
+
function setFloatingElemPositionForLinkEditor(targetRect, floatingElem, anchorElem, verticalGap = VERTICAL_GAP, horizontalOffset = HORIZONTAL_OFFSET) {
|
|
51
|
+
const scrollerElem = anchorElem.parentElement;
|
|
52
|
+
if (targetRect === null || !scrollerElem) {
|
|
53
|
+
floatingElem.style.opacity = "0";
|
|
54
|
+
floatingElem.style.transform = "translate(-10000px, -10000px)";
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const floatingElemRect = floatingElem.getBoundingClientRect();
|
|
58
|
+
const anchorElementRect = anchorElem.getBoundingClientRect();
|
|
59
|
+
const editorScrollerRect = scrollerElem.getBoundingClientRect();
|
|
60
|
+
let top = targetRect.top - verticalGap;
|
|
61
|
+
let left = targetRect.left - horizontalOffset;
|
|
62
|
+
if (top < editorScrollerRect.top) {
|
|
63
|
+
top += floatingElemRect.height + targetRect.height + verticalGap * 2;
|
|
64
|
+
}
|
|
65
|
+
if (left + floatingElemRect.width > editorScrollerRect.right) {
|
|
66
|
+
left = editorScrollerRect.right - floatingElemRect.width - horizontalOffset;
|
|
67
|
+
}
|
|
68
|
+
top -= anchorElementRect.top;
|
|
69
|
+
left -= anchorElementRect.left;
|
|
70
|
+
floatingElem.style.opacity = "1";
|
|
71
|
+
floatingElem.style.transform = `translate(${left}px, ${top}px)`;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// src/components/editor/plugins/FloatingLinkEditorPlugin/index.tsx
|
|
75
|
+
import { Check, Edit2Icon, Link, X } from "lucide-react";
|
|
76
|
+
function preventDefault(event) {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
}
|
|
79
|
+
function FloatingLinkEditor({
|
|
80
|
+
editor,
|
|
81
|
+
isLink,
|
|
82
|
+
setIsLink,
|
|
83
|
+
anchorElem,
|
|
84
|
+
isLinkEditMode,
|
|
85
|
+
setIsLinkEditMode
|
|
86
|
+
}) {
|
|
87
|
+
const editorRef = useRef(null);
|
|
88
|
+
const inputRef = useRef(null);
|
|
89
|
+
const [linkUrl, setLinkUrl] = useState("");
|
|
90
|
+
const [editedLinkUrl, setEditedLinkUrl] = useState("https://");
|
|
91
|
+
const [lastSelection, setLastSelection] = useState(
|
|
92
|
+
null
|
|
93
|
+
);
|
|
94
|
+
const [urlLogo, setUrlLogo] = useState(null);
|
|
95
|
+
const $updateLinkEditor = useCallback(() => {
|
|
96
|
+
var _a, _b;
|
|
97
|
+
const selection = $getSelection();
|
|
98
|
+
if ($isRangeSelection(selection)) {
|
|
99
|
+
const node = getSelectedNode(selection);
|
|
100
|
+
const linkParent = $findMatchingParent(node, $isLinkNode);
|
|
101
|
+
if (linkParent) {
|
|
102
|
+
setLinkUrl(linkParent.getURL());
|
|
103
|
+
} else if ($isLinkNode(node)) {
|
|
104
|
+
setLinkUrl(node.getURL());
|
|
105
|
+
} else {
|
|
106
|
+
setLinkUrl("");
|
|
107
|
+
}
|
|
108
|
+
if (isLinkEditMode) {
|
|
109
|
+
setEditedLinkUrl(linkUrl);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const editorElem = editorRef.current;
|
|
113
|
+
const nativeSelection = getDOMSelection(editor._window);
|
|
114
|
+
const activeElement = document.activeElement;
|
|
115
|
+
if (editorElem === null) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const rootElement = editor.getRootElement();
|
|
119
|
+
if (selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
|
|
120
|
+
const domRect = (_b = (_a = nativeSelection.focusNode) == null ? void 0 : _a.parentElement) == null ? void 0 : _b.getBoundingClientRect();
|
|
121
|
+
if (domRect) {
|
|
122
|
+
domRect.y += 40;
|
|
123
|
+
setFloatingElemPositionForLinkEditor(domRect, editorElem, anchorElem);
|
|
124
|
+
}
|
|
125
|
+
setLastSelection(selection);
|
|
126
|
+
} else if (!activeElement || activeElement.className !== "link-input") {
|
|
127
|
+
if (rootElement !== null) {
|
|
128
|
+
setFloatingElemPositionForLinkEditor(null, editorElem, anchorElem);
|
|
129
|
+
}
|
|
130
|
+
setLastSelection(null);
|
|
131
|
+
setIsLinkEditMode(false);
|
|
132
|
+
setLinkUrl("");
|
|
133
|
+
}
|
|
134
|
+
return true;
|
|
135
|
+
}, [anchorElem, editor, setIsLinkEditMode, isLinkEditMode, linkUrl]);
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
const scrollerElem = anchorElem.parentElement;
|
|
138
|
+
const update = () => {
|
|
139
|
+
editor.getEditorState().read(() => {
|
|
140
|
+
$updateLinkEditor();
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
window.addEventListener("resize", update);
|
|
144
|
+
if (scrollerElem) {
|
|
145
|
+
scrollerElem.addEventListener("scroll", update);
|
|
146
|
+
}
|
|
147
|
+
return () => {
|
|
148
|
+
window.removeEventListener("resize", update);
|
|
149
|
+
if (scrollerElem) {
|
|
150
|
+
scrollerElem.removeEventListener("scroll", update);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}, [anchorElem.parentElement, editor, $updateLinkEditor]);
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
return mergeRegister(
|
|
156
|
+
editor.registerUpdateListener(({ editorState }) => {
|
|
157
|
+
editorState.read(() => {
|
|
158
|
+
$updateLinkEditor();
|
|
159
|
+
});
|
|
160
|
+
}),
|
|
161
|
+
editor.registerCommand(
|
|
162
|
+
SELECTION_CHANGE_COMMAND,
|
|
163
|
+
() => {
|
|
164
|
+
$updateLinkEditor();
|
|
165
|
+
return true;
|
|
166
|
+
},
|
|
167
|
+
COMMAND_PRIORITY_LOW
|
|
168
|
+
),
|
|
169
|
+
editor.registerCommand(
|
|
170
|
+
KEY_ESCAPE_COMMAND,
|
|
171
|
+
() => {
|
|
172
|
+
if (isLink) {
|
|
173
|
+
setIsLink(false);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
return false;
|
|
177
|
+
},
|
|
178
|
+
COMMAND_PRIORITY_HIGH
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
}, [editor, $updateLinkEditor, setIsLink, isLink]);
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
editor.getEditorState().read(() => {
|
|
184
|
+
$updateLinkEditor();
|
|
185
|
+
});
|
|
186
|
+
}, [editor, $updateLinkEditor]);
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (isLinkEditMode && inputRef.current) {
|
|
189
|
+
inputRef.current.focus();
|
|
190
|
+
}
|
|
191
|
+
}, [isLinkEditMode, isLink]);
|
|
192
|
+
const monitorInputInteraction = (event) => {
|
|
193
|
+
if (event.key === "Enter") {
|
|
194
|
+
handleLinkSubmission(event);
|
|
195
|
+
} else if (event.key === "Escape") {
|
|
196
|
+
event.preventDefault();
|
|
197
|
+
setIsLinkEditMode(false);
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const handleLinkSubmission = (event) => {
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
if (lastSelection !== null) {
|
|
203
|
+
if (linkUrl !== "") {
|
|
204
|
+
editor.update(() => {
|
|
205
|
+
editor.dispatchCommand(
|
|
206
|
+
TOGGLE_LINK_COMMAND,
|
|
207
|
+
sanitizeUrl(editedLinkUrl)
|
|
208
|
+
);
|
|
209
|
+
const selection = $getSelection();
|
|
210
|
+
if ($isRangeSelection(selection)) {
|
|
211
|
+
const parent = getSelectedNode(selection).getParent();
|
|
212
|
+
if ($isAutoLinkNode(parent)) {
|
|
213
|
+
const linkNode = $createLinkNode(parent.getURL(), {
|
|
214
|
+
rel: parent.__rel,
|
|
215
|
+
target: parent.__target,
|
|
216
|
+
title: parent.__title
|
|
217
|
+
});
|
|
218
|
+
parent.replace(linkNode, true);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
setEditedLinkUrl("https://");
|
|
224
|
+
setIsLinkEditMode(false);
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
return /* @__PURE__ */ React.createElement(
|
|
228
|
+
"div",
|
|
229
|
+
{
|
|
230
|
+
ref: editorRef,
|
|
231
|
+
className: " absolute max-w-96 bg-background max-sm:mx-1 w-full border-0 top-0 left-0"
|
|
232
|
+
},
|
|
233
|
+
isLinkEditMode ? /* @__PURE__ */ React.createElement("div", { className: " relative w-full" }, /* @__PURE__ */ React.createElement(
|
|
234
|
+
Link,
|
|
235
|
+
{
|
|
236
|
+
className: cn(
|
|
237
|
+
"size-[14px] text-muted-foreground absolute transition-colors duration-500 transform -translate-x-1/2 -translate-y-1/2 left-4 top-1/2",
|
|
238
|
+
!!editedLinkUrl && "text-black dark:text-white"
|
|
239
|
+
)
|
|
240
|
+
}
|
|
241
|
+
), /* @__PURE__ */ React.createElement(
|
|
242
|
+
Input,
|
|
243
|
+
{
|
|
244
|
+
placeholder: "https://",
|
|
245
|
+
value: editedLinkUrl,
|
|
246
|
+
onChange: (event) => {
|
|
247
|
+
setEditedLinkUrl(event.target.value);
|
|
248
|
+
},
|
|
249
|
+
onKeyDown: (event) => {
|
|
250
|
+
monitorInputInteraction(event);
|
|
251
|
+
},
|
|
252
|
+
ref: inputRef,
|
|
253
|
+
className: "text-gray-900 pl-7 dark:text-gray-100 rounded-xl placeholder-gray-400 dark:placeholder-gray-500"
|
|
254
|
+
}
|
|
255
|
+
), /* @__PURE__ */ React.createElement("div", { className: " absolute bg-background rounded-xl flex flex-row gap-x-1 items-center transition-colors duration-500 transform -translate-y-1/2 right-2 top-1/2" }, /* @__PURE__ */ React.createElement(
|
|
256
|
+
Button,
|
|
257
|
+
{
|
|
258
|
+
className: " rounded-xl h-6 w-6 flex items-center",
|
|
259
|
+
role: "button",
|
|
260
|
+
variant: "destructive",
|
|
261
|
+
size: "Toolbar",
|
|
262
|
+
tip: "delete link",
|
|
263
|
+
tabIndex: 0,
|
|
264
|
+
onMouseDown: preventDefault,
|
|
265
|
+
onClick: () => {
|
|
266
|
+
setIsLinkEditMode(false);
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
/* @__PURE__ */ React.createElement(X, null)
|
|
270
|
+
), /* @__PURE__ */ React.createElement(
|
|
271
|
+
Button,
|
|
272
|
+
{
|
|
273
|
+
className: " rounded-xl h-6 w-6 flex items-center",
|
|
274
|
+
role: "button",
|
|
275
|
+
tabIndex: 0,
|
|
276
|
+
tip: "confirm link",
|
|
277
|
+
onMouseDown: preventDefault,
|
|
278
|
+
onClick: handleLinkSubmission,
|
|
279
|
+
size: "Toolbar"
|
|
280
|
+
},
|
|
281
|
+
/* @__PURE__ */ React.createElement(Check, null)
|
|
282
|
+
))) : /* @__PURE__ */ React.createElement("div", { className: "w-full border-input border rounded-xl h-9 flex items-center justify-between px-3 py-1 text-base shadow-sm " }, /* @__PURE__ */ React.createElement(
|
|
283
|
+
Link,
|
|
284
|
+
{
|
|
285
|
+
className: cn(
|
|
286
|
+
"size-[14px] text-muted-foreground absolute transition-colors duration-500 transform -translate-x-1/2 -translate-y-1/2 left-4 top-1/2",
|
|
287
|
+
!!editedLinkUrl && "text-black dark:text-white"
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
), /* @__PURE__ */ React.createElement(
|
|
291
|
+
"a",
|
|
292
|
+
{
|
|
293
|
+
href: sanitizeUrl(linkUrl),
|
|
294
|
+
target: "_blank",
|
|
295
|
+
rel: "noopener noreferrer",
|
|
296
|
+
className: "pl-4 mb-[1px]"
|
|
297
|
+
},
|
|
298
|
+
linkUrl
|
|
299
|
+
), /* @__PURE__ */ React.createElement("div", { className: " absolute bg-background rounded-xl flex flex-row gap-x-1 items-center transition-colors duration-500 transform -translate-y-1/2 right-2 top-1/2" }, /* @__PURE__ */ React.createElement(
|
|
300
|
+
Button,
|
|
301
|
+
{
|
|
302
|
+
className: " rounded-xl z-50 h-6 w-6 flex items-center",
|
|
303
|
+
role: "button",
|
|
304
|
+
size: "Toolbar",
|
|
305
|
+
tip: "edit link",
|
|
306
|
+
tabIndex: 0,
|
|
307
|
+
onMouseDown: preventDefault,
|
|
308
|
+
onClick: (event) => {
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
setEditedLinkUrl(linkUrl);
|
|
311
|
+
setIsLinkEditMode(true);
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
/* @__PURE__ */ React.createElement(Edit2Icon, { className: "size-4" })
|
|
315
|
+
), /* @__PURE__ */ React.createElement(
|
|
316
|
+
Button,
|
|
317
|
+
{
|
|
318
|
+
className: " rounded-xl h-6 w-6 flex items-center",
|
|
319
|
+
role: "button",
|
|
320
|
+
tabIndex: 0,
|
|
321
|
+
variant: "secondary",
|
|
322
|
+
tip: "delet link",
|
|
323
|
+
size: "Toolbar",
|
|
324
|
+
onMouseDown: preventDefault,
|
|
325
|
+
onClick: () => {
|
|
326
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
327
|
+
}
|
|
328
|
+
},
|
|
329
|
+
/* @__PURE__ */ React.createElement(X, null)
|
|
330
|
+
)))
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
function useFloatingLinkEditorToolbar(editor, anchorElem, isLinkEditMode, setIsLinkEditMode) {
|
|
334
|
+
const [activeEditor, setActiveEditor] = useState(editor);
|
|
335
|
+
const [isLink, setIsLink] = useState(false);
|
|
336
|
+
useEffect(() => {
|
|
337
|
+
function $updateToolbar() {
|
|
338
|
+
const selection = $getSelection();
|
|
339
|
+
if ($isRangeSelection(selection)) {
|
|
340
|
+
const focusNode = getSelectedNode(selection);
|
|
341
|
+
const focusLinkNode = $findMatchingParent(focusNode, $isLinkNode);
|
|
342
|
+
const focusAutoLinkNode = $findMatchingParent(
|
|
343
|
+
focusNode,
|
|
344
|
+
$isAutoLinkNode
|
|
345
|
+
);
|
|
346
|
+
if (!(focusLinkNode || focusAutoLinkNode)) {
|
|
347
|
+
setIsLink(false);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
const badNode = selection.getNodes().filter((node) => !$isLineBreakNode(node)).find((node) => {
|
|
351
|
+
const linkNode = $findMatchingParent(node, $isLinkNode);
|
|
352
|
+
const autoLinkNode = $findMatchingParent(node, $isAutoLinkNode);
|
|
353
|
+
return focusLinkNode && !focusLinkNode.is(linkNode) || linkNode && !linkNode.is(focusLinkNode) || focusAutoLinkNode && !focusAutoLinkNode.is(autoLinkNode) || autoLinkNode && (!autoLinkNode.is(focusAutoLinkNode) || autoLinkNode.getIsUnlinked());
|
|
354
|
+
});
|
|
355
|
+
if (!badNode) {
|
|
356
|
+
setIsLink(true);
|
|
357
|
+
} else {
|
|
358
|
+
setIsLink(false);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return mergeRegister(
|
|
363
|
+
editor.registerUpdateListener(({ editorState }) => {
|
|
364
|
+
editorState.read(() => {
|
|
365
|
+
$updateToolbar();
|
|
366
|
+
});
|
|
367
|
+
}),
|
|
368
|
+
editor.registerCommand(
|
|
369
|
+
SELECTION_CHANGE_COMMAND,
|
|
370
|
+
(_payload, newEditor) => {
|
|
371
|
+
$updateToolbar();
|
|
372
|
+
setActiveEditor(newEditor);
|
|
373
|
+
return false;
|
|
374
|
+
},
|
|
375
|
+
COMMAND_PRIORITY_CRITICAL
|
|
376
|
+
),
|
|
377
|
+
editor.registerCommand(
|
|
378
|
+
CLICK_COMMAND,
|
|
379
|
+
(payload) => {
|
|
380
|
+
const selection = $getSelection();
|
|
381
|
+
if ($isRangeSelection(selection)) {
|
|
382
|
+
const node = getSelectedNode(selection);
|
|
383
|
+
const linkNode = $findMatchingParent(node, $isLinkNode);
|
|
384
|
+
if ($isLinkNode(linkNode) && (payload.metaKey || payload.ctrlKey)) {
|
|
385
|
+
window.open(linkNode.getURL(), "_blank");
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return false;
|
|
390
|
+
},
|
|
391
|
+
COMMAND_PRIORITY_LOW
|
|
392
|
+
)
|
|
393
|
+
);
|
|
394
|
+
}, [editor]);
|
|
395
|
+
if (!isLink) return null;
|
|
396
|
+
return createPortal(
|
|
397
|
+
/* @__PURE__ */ React.createElement(
|
|
398
|
+
FloatingLinkEditor,
|
|
399
|
+
{
|
|
400
|
+
editor: activeEditor,
|
|
401
|
+
isLink,
|
|
402
|
+
anchorElem,
|
|
403
|
+
setIsLink,
|
|
404
|
+
isLinkEditMode,
|
|
405
|
+
setIsLinkEditMode
|
|
406
|
+
}
|
|
407
|
+
),
|
|
408
|
+
anchorElem
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
function FloatingLinkEditorPlugin({
|
|
412
|
+
anchorElem = document.body,
|
|
413
|
+
isLinkEditMode,
|
|
414
|
+
setIsLinkEditMode
|
|
415
|
+
}) {
|
|
416
|
+
const [editor] = useLexicalComposerContext();
|
|
417
|
+
return useFloatingLinkEditorToolbar(
|
|
418
|
+
editor,
|
|
419
|
+
anchorElem,
|
|
420
|
+
isLinkEditMode,
|
|
421
|
+
setIsLinkEditMode
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export {
|
|
426
|
+
FloatingLinkEditorPlugin
|
|
427
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-YHPNOWFH.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadValues,
|
|
7
|
+
init_react_shim
|
|
8
|
+
} from "./chunk-77KXU36M.mjs";
|
|
9
|
+
|
|
10
|
+
// src/components/ui/separator.tsx
|
|
11
|
+
init_react_shim();
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
14
|
+
var Separator = React.forwardRef(
|
|
15
|
+
(_a, ref) => {
|
|
16
|
+
var _b = _a, { className, orientation = "horizontal", decorative = true } = _b, props = __objRest(_b, ["className", "orientation", "decorative"]);
|
|
17
|
+
return /* @__PURE__ */ React.createElement(
|
|
18
|
+
SeparatorPrimitive.Root,
|
|
19
|
+
__spreadValues({
|
|
20
|
+
ref,
|
|
21
|
+
decorative,
|
|
22
|
+
orientation,
|
|
23
|
+
className: cn(
|
|
24
|
+
"shrink-0 bg-border",
|
|
25
|
+
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
|
26
|
+
className
|
|
27
|
+
)
|
|
28
|
+
}, props)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
Separator
|
|
36
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DropDown
|
|
3
|
+
} from "./chunk-EGMI62PP.mjs";
|
|
4
|
+
import {
|
|
5
|
+
init_react_shim
|
|
6
|
+
} from "./chunk-77KXU36M.mjs";
|
|
7
|
+
|
|
8
|
+
// src/components/ui/drop-downs/code.tsx
|
|
9
|
+
init_react_shim();
|
|
10
|
+
import React from "react";
|
|
11
|
+
import {
|
|
12
|
+
CODE_LANGUAGE_FRIENDLY_NAME_MAP,
|
|
13
|
+
getLanguageFriendlyName
|
|
14
|
+
} from "@lexical/code";
|
|
15
|
+
function getCodeLanguageOptions() {
|
|
16
|
+
const options = [];
|
|
17
|
+
for (const [lang, friendlyName] of Object.entries(
|
|
18
|
+
CODE_LANGUAGE_FRIENDLY_NAME_MAP
|
|
19
|
+
)) {
|
|
20
|
+
options.push([lang, friendlyName]);
|
|
21
|
+
}
|
|
22
|
+
return options;
|
|
23
|
+
}
|
|
24
|
+
function CodeList({
|
|
25
|
+
onCodeLanguageSelect,
|
|
26
|
+
disabled = false,
|
|
27
|
+
codeLanguage
|
|
28
|
+
}) {
|
|
29
|
+
const CODE_LANGUAGE_OPTIONS = getCodeLanguageOptions();
|
|
30
|
+
const languageButtons = CODE_LANGUAGE_OPTIONS.map(([lang]) => ({
|
|
31
|
+
label: lang,
|
|
32
|
+
func: () => onCodeLanguageSelect(lang)
|
|
33
|
+
}));
|
|
34
|
+
return /* @__PURE__ */ React.createElement(
|
|
35
|
+
DropDown,
|
|
36
|
+
{
|
|
37
|
+
values: languageButtons,
|
|
38
|
+
disabled,
|
|
39
|
+
TriggerClassName: { maxWidth: "200px", minWidth: "60px", width: "130px" },
|
|
40
|
+
TriggerLabel: getLanguageFriendlyName(codeLanguage)
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
CodeList
|
|
47
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$createPollNode,
|
|
3
|
+
PollNode,
|
|
4
|
+
createPollOption
|
|
5
|
+
} from "./chunk-GZPNVR7L.mjs";
|
|
6
|
+
import {
|
|
7
|
+
init_react_shim
|
|
8
|
+
} from "./chunk-77KXU36M.mjs";
|
|
9
|
+
|
|
10
|
+
// src/components/editor/plugins/PollPlugin/index.tsx
|
|
11
|
+
init_react_shim();
|
|
12
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
13
|
+
import { $wrapNodeInElement } from "@lexical/utils";
|
|
14
|
+
import {
|
|
15
|
+
$createParagraphNode,
|
|
16
|
+
$insertNodes,
|
|
17
|
+
$isRootOrShadowRoot,
|
|
18
|
+
COMMAND_PRIORITY_EDITOR,
|
|
19
|
+
createCommand
|
|
20
|
+
} from "lexical";
|
|
21
|
+
import { useEffect } from "react";
|
|
22
|
+
var INSERT_POLL_COMMAND = createCommand(
|
|
23
|
+
"INSERT_POLL_COMMAND"
|
|
24
|
+
);
|
|
25
|
+
function PollPlugin() {
|
|
26
|
+
const [editor] = useLexicalComposerContext();
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!editor.hasNodes([PollNode])) {
|
|
29
|
+
throw new Error("PollPlugin: PollNode not registered on editor");
|
|
30
|
+
}
|
|
31
|
+
return editor.registerCommand(
|
|
32
|
+
INSERT_POLL_COMMAND,
|
|
33
|
+
(payload) => {
|
|
34
|
+
const pollNode = $createPollNode(payload, [
|
|
35
|
+
createPollOption(),
|
|
36
|
+
createPollOption()
|
|
37
|
+
]);
|
|
38
|
+
$insertNodes([pollNode]);
|
|
39
|
+
if ($isRootOrShadowRoot(pollNode.getParentOrThrow())) {
|
|
40
|
+
$wrapNodeInElement(pollNode, $createParagraphNode).selectEnd();
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
},
|
|
44
|
+
COMMAND_PRIORITY_EDITOR
|
|
45
|
+
);
|
|
46
|
+
}, [editor]);
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
INSERT_POLL_COMMAND,
|
|
52
|
+
PollPlugin
|
|
53
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-YHPNOWFH.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadValues,
|
|
7
|
+
init_react_shim
|
|
8
|
+
} from "./chunk-77KXU36M.mjs";
|
|
9
|
+
|
|
10
|
+
// src/components/ui/dialog.tsx
|
|
11
|
+
init_react_shim();
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
14
|
+
import { X } from "lucide-react";
|
|
15
|
+
var Dialog = DialogPrimitive.Root;
|
|
16
|
+
var DialogTrigger = DialogPrimitive.Trigger;
|
|
17
|
+
var DialogPortal = DialogPrimitive.Portal;
|
|
18
|
+
var DialogOverlay = React.forwardRef((_a, ref) => {
|
|
19
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
20
|
+
return /* @__PURE__ */ React.createElement(
|
|
21
|
+
DialogPrimitive.Overlay,
|
|
22
|
+
__spreadValues({
|
|
23
|
+
ref,
|
|
24
|
+
className: cn(
|
|
25
|
+
"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
26
|
+
className
|
|
27
|
+
)
|
|
28
|
+
}, props)
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
32
|
+
var DialogContent = React.forwardRef((_a, ref) => {
|
|
33
|
+
var _b = _a, { className, children } = _b, props = __objRest(_b, ["className", "children"]);
|
|
34
|
+
return /* @__PURE__ */ React.createElement(DialogPortal, null, /* @__PURE__ */ React.createElement(DialogOverlay, null), /* @__PURE__ */ React.createElement(
|
|
35
|
+
DialogPrimitive.Content,
|
|
36
|
+
__spreadValues({
|
|
37
|
+
ref,
|
|
38
|
+
className: cn(
|
|
39
|
+
"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
|
|
40
|
+
className
|
|
41
|
+
)
|
|
42
|
+
}, props),
|
|
43
|
+
children,
|
|
44
|
+
/* @__PURE__ */ React.createElement(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground" }, /* @__PURE__ */ React.createElement(X, { className: "h-4 w-4" }), /* @__PURE__ */ React.createElement("span", { className: "sr-only" }, "Close"))
|
|
45
|
+
));
|
|
46
|
+
});
|
|
47
|
+
DialogContent.displayName = DialogPrimitive.Content.displayName;
|
|
48
|
+
var DialogHeader = (_a) => {
|
|
49
|
+
var _b = _a, {
|
|
50
|
+
className
|
|
51
|
+
} = _b, props = __objRest(_b, [
|
|
52
|
+
"className"
|
|
53
|
+
]);
|
|
54
|
+
return /* @__PURE__ */ React.createElement(
|
|
55
|
+
"div",
|
|
56
|
+
__spreadValues({
|
|
57
|
+
className: cn(
|
|
58
|
+
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
59
|
+
className
|
|
60
|
+
)
|
|
61
|
+
}, props)
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
DialogHeader.displayName = "DialogHeader";
|
|
65
|
+
var DialogFooter = (_a) => {
|
|
66
|
+
var _b = _a, {
|
|
67
|
+
className
|
|
68
|
+
} = _b, props = __objRest(_b, [
|
|
69
|
+
"className"
|
|
70
|
+
]);
|
|
71
|
+
return /* @__PURE__ */ React.createElement(
|
|
72
|
+
"div",
|
|
73
|
+
__spreadValues({
|
|
74
|
+
className: cn(
|
|
75
|
+
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
76
|
+
className
|
|
77
|
+
)
|
|
78
|
+
}, props)
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
DialogFooter.displayName = "DialogFooter";
|
|
82
|
+
var DialogTitle = React.forwardRef((_a, ref) => {
|
|
83
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
84
|
+
return /* @__PURE__ */ React.createElement(
|
|
85
|
+
DialogPrimitive.Title,
|
|
86
|
+
__spreadValues({
|
|
87
|
+
ref,
|
|
88
|
+
className: cn(
|
|
89
|
+
"text-lg font-semibold leading-none tracking-tight",
|
|
90
|
+
className
|
|
91
|
+
)
|
|
92
|
+
}, props)
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
DialogTitle.displayName = DialogPrimitive.Title.displayName;
|
|
96
|
+
var DialogDescription = React.forwardRef((_a, ref) => {
|
|
97
|
+
var _b = _a, { className } = _b, props = __objRest(_b, ["className"]);
|
|
98
|
+
return /* @__PURE__ */ React.createElement(
|
|
99
|
+
DialogPrimitive.Description,
|
|
100
|
+
__spreadValues({
|
|
101
|
+
ref,
|
|
102
|
+
className: cn("text-sm text-muted-foreground", className)
|
|
103
|
+
}, props)
|
|
104
|
+
);
|
|
105
|
+
});
|
|
106
|
+
DialogDescription.displayName = DialogPrimitive.Description.displayName;
|
|
107
|
+
|
|
108
|
+
export {
|
|
109
|
+
Dialog,
|
|
110
|
+
DialogTrigger,
|
|
111
|
+
DialogContent,
|
|
112
|
+
DialogHeader,
|
|
113
|
+
DialogFooter,
|
|
114
|
+
DialogTitle,
|
|
115
|
+
DialogDescription
|
|
116
|
+
};
|