@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,357 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InlineImageNode
|
|
3
|
+
} from "./chunk-WJRHXI2C.mjs";
|
|
4
|
+
import {
|
|
5
|
+
FigmaNode,
|
|
6
|
+
LayoutContainerNode,
|
|
7
|
+
LayoutItemNode,
|
|
8
|
+
TweetNode,
|
|
9
|
+
YouTubeNode
|
|
10
|
+
} from "./chunk-AMMKBSST.mjs";
|
|
11
|
+
import {
|
|
12
|
+
DynamicBlockNode
|
|
13
|
+
} from "./chunk-5BAKY5KN.mjs";
|
|
14
|
+
import {
|
|
15
|
+
StepperNode
|
|
16
|
+
} from "./chunk-6RNZQOH2.mjs";
|
|
17
|
+
import {
|
|
18
|
+
CollapsibleContainerNode,
|
|
19
|
+
CollapsibleContentNode,
|
|
20
|
+
CollapsibleTitleNode
|
|
21
|
+
} from "./chunk-GXYD4VZM.mjs";
|
|
22
|
+
import {
|
|
23
|
+
ImageNode
|
|
24
|
+
} from "./chunk-N3WN46VL.mjs";
|
|
25
|
+
import {
|
|
26
|
+
PollNode
|
|
27
|
+
} from "./chunk-GZPNVR7L.mjs";
|
|
28
|
+
import {
|
|
29
|
+
Hint
|
|
30
|
+
} from "./chunk-G53GLEAY.mjs";
|
|
31
|
+
import {
|
|
32
|
+
ExcalidrawNode
|
|
33
|
+
} from "./chunk-KJV3FAZ7.mjs";
|
|
34
|
+
import {
|
|
35
|
+
EquationNode
|
|
36
|
+
} from "./chunk-3JVFG7ER.mjs";
|
|
37
|
+
import {
|
|
38
|
+
StoryBuilderNode
|
|
39
|
+
} from "./chunk-4MEDW3T6.mjs";
|
|
40
|
+
import {
|
|
41
|
+
__spreadProps,
|
|
42
|
+
__spreadValues,
|
|
43
|
+
init_react_shim
|
|
44
|
+
} from "./chunk-77KXU36M.mjs";
|
|
45
|
+
|
|
46
|
+
// src/components/editor/plugins/LinkWithMetaData/index.tsx
|
|
47
|
+
init_react_shim();
|
|
48
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
49
|
+
import {
|
|
50
|
+
$getSelection,
|
|
51
|
+
$isRangeSelection,
|
|
52
|
+
COMMAND_PRIORITY_LOW,
|
|
53
|
+
createCommand,
|
|
54
|
+
ElementNode
|
|
55
|
+
} from "lexical";
|
|
56
|
+
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
57
|
+
import { useEffect } from "react";
|
|
58
|
+
async function fetchMetadata(url) {
|
|
59
|
+
var _a;
|
|
60
|
+
try {
|
|
61
|
+
const proxyUrl = "https://api.allorigins.win/get?url=";
|
|
62
|
+
const response = await fetch(`${proxyUrl}${encodeURIComponent(url)}`);
|
|
63
|
+
const data = await response.json();
|
|
64
|
+
const html = data.contents;
|
|
65
|
+
const parser = new DOMParser();
|
|
66
|
+
const doc = parser.parseFromString(html, "text/html");
|
|
67
|
+
const getMetaTagContent = (property) => {
|
|
68
|
+
const element = doc.querySelector(`meta[property="${property}"]`) || doc.querySelector(`meta[name="${property}"]`);
|
|
69
|
+
return element ? element.getAttribute("content") : null;
|
|
70
|
+
};
|
|
71
|
+
const metadata = {
|
|
72
|
+
title: ((_a = doc.querySelector("title")) == null ? void 0 : _a.textContent) || getMetaTagContent("og:title") || "No title",
|
|
73
|
+
description: getMetaTagContent("og:description") || getMetaTagContent("description") || "No description",
|
|
74
|
+
image: getMetaTagContent("og:image") || void 0,
|
|
75
|
+
// Use a valid fallback image URL
|
|
76
|
+
website: getMetaTagContent("og:site_name") || new URL(url).hostname
|
|
77
|
+
// Use hostname as fallback
|
|
78
|
+
};
|
|
79
|
+
return metadata;
|
|
80
|
+
} catch (error) {
|
|
81
|
+
return {
|
|
82
|
+
title: "No title",
|
|
83
|
+
description: "No description",
|
|
84
|
+
image: void 0,
|
|
85
|
+
website: new URL(url).hostname
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
var LinkWithMetaDataNode = class _LinkWithMetaDataNode extends ElementNode {
|
|
90
|
+
constructor(url, editor, key) {
|
|
91
|
+
super(key);
|
|
92
|
+
this.__metadata = null;
|
|
93
|
+
this.__url = url;
|
|
94
|
+
this.__editor = editor;
|
|
95
|
+
}
|
|
96
|
+
static clone(node) {
|
|
97
|
+
return new _LinkWithMetaDataNode(node.__url, node.__editor, node.__key);
|
|
98
|
+
}
|
|
99
|
+
static importJSON(serializedNode) {
|
|
100
|
+
const node = $createLinkNode(serializedNode.url, serializedNode.__editor);
|
|
101
|
+
node.__metadata = serializedNode.metadata;
|
|
102
|
+
node.__url = serializedNode.url;
|
|
103
|
+
return node;
|
|
104
|
+
}
|
|
105
|
+
exportJSON() {
|
|
106
|
+
return __spreadProps(__spreadValues({}, super.exportJSON()), {
|
|
107
|
+
url: this.__url,
|
|
108
|
+
metadata: this.__metadata,
|
|
109
|
+
type: "link-with-metadata",
|
|
110
|
+
version: 1
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
static getType() {
|
|
114
|
+
return "link-with-metadata";
|
|
115
|
+
}
|
|
116
|
+
// Method to update metadata
|
|
117
|
+
setMetadata(metadata) {
|
|
118
|
+
const writable = this.getWritable();
|
|
119
|
+
writable.__metadata = metadata;
|
|
120
|
+
}
|
|
121
|
+
createDOM() {
|
|
122
|
+
var _a, _b, _c;
|
|
123
|
+
const elementDIV = document.createElement("div");
|
|
124
|
+
elementDIV.className = "dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-50 border border-zinc-200 bg-white/90 text-zinc-950 shadow-md w-full cursor-pointer p-3 rounded-sm border flex flex-row items-center justify-between";
|
|
125
|
+
elementDIV.setAttribute("contenteditable", "false");
|
|
126
|
+
const container = document.createElement("div");
|
|
127
|
+
container.className = "flex flex-row w-full max-sm:flex-col max-sm:gap-y-2 justify-between items-start gap-x-2";
|
|
128
|
+
if ((_a = this.__metadata) == null ? void 0 : _a.image) {
|
|
129
|
+
const leftContainer = document.createElement("div");
|
|
130
|
+
leftContainer.className = "flex w-full h-full max-w-[250px] max-h-[100px] min-h-[100px] order-6";
|
|
131
|
+
const image = document.createElement("img");
|
|
132
|
+
image.src = this.__metadata.image;
|
|
133
|
+
image.alt = `image for ${this.__metadata.title}`;
|
|
134
|
+
image.className = "w-full h-[100px] rounded-lg object-cover";
|
|
135
|
+
leftContainer.appendChild(image);
|
|
136
|
+
container.appendChild(leftContainer);
|
|
137
|
+
}
|
|
138
|
+
const rightContainer = document.createElement("div");
|
|
139
|
+
rightContainer.className = "flex flex-col flex-1 w-full flex-wrap items-start space-y-4";
|
|
140
|
+
const titleLink = document.createElement("a");
|
|
141
|
+
titleLink.className = "font-bold break-words hover:underline";
|
|
142
|
+
titleLink.href = this.__url || "#";
|
|
143
|
+
titleLink.textContent = this.__url || "No URL provided";
|
|
144
|
+
titleLink.target = "_blank";
|
|
145
|
+
rightContainer.appendChild(titleLink);
|
|
146
|
+
const descriptionSmall = document.createElement("small");
|
|
147
|
+
descriptionSmall.className = "font-[400] dark:text-gray-200 text-gray-500";
|
|
148
|
+
descriptionSmall.textContent = ((_b = this.__metadata) == null ? void 0 : _b.description) || "Loading metadata...";
|
|
149
|
+
rightContainer.appendChild(descriptionSmall);
|
|
150
|
+
const sourceSmall = document.createElement("small");
|
|
151
|
+
sourceSmall.className = "text-sm mt-4 font-[400] dark:text-gray-300 text-gray-500/50";
|
|
152
|
+
sourceSmall.textContent = ((_c = this.__metadata) == null ? void 0 : _c.website) || "";
|
|
153
|
+
rightContainer.appendChild(sourceSmall);
|
|
154
|
+
container.appendChild(rightContainer);
|
|
155
|
+
elementDIV.appendChild(container);
|
|
156
|
+
if (this.__url && !this.__metadata) {
|
|
157
|
+
fetchMetadata(this.__url).then((metadata) => {
|
|
158
|
+
this.__editor.update(() => {
|
|
159
|
+
this.setMetadata(metadata);
|
|
160
|
+
});
|
|
161
|
+
}).catch((error) => {
|
|
162
|
+
console.error("Error fetching metadata:", error);
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
return elementDIV;
|
|
166
|
+
}
|
|
167
|
+
updateDOM(prevNode, dom) {
|
|
168
|
+
var _a, _b, _c, _d;
|
|
169
|
+
if (this.__metadata !== prevNode.__metadata) {
|
|
170
|
+
const container = dom.querySelector("div");
|
|
171
|
+
const image = dom.querySelector("img");
|
|
172
|
+
const titleLink = dom.querySelector("a");
|
|
173
|
+
const descriptionSmall = dom.querySelector("small:nth-of-type(1)");
|
|
174
|
+
const sourceSmall = dom.querySelector("small:nth-of-type(2)");
|
|
175
|
+
if (titleLink && descriptionSmall && sourceSmall) {
|
|
176
|
+
titleLink.href = this.__url || "#";
|
|
177
|
+
titleLink.textContent = ((_a = this.__metadata) == null ? void 0 : _a.title) || this.__url || "No URL provided";
|
|
178
|
+
descriptionSmall.textContent = ((_b = this.__metadata) == null ? void 0 : _b.description) || "Loading metadata...";
|
|
179
|
+
sourceSmall.textContent = ((_c = this.__metadata) == null ? void 0 : _c.website) || "";
|
|
180
|
+
}
|
|
181
|
+
if ((_d = this.__metadata) == null ? void 0 : _d.image) {
|
|
182
|
+
if (!image) {
|
|
183
|
+
const leftContainer = document.createElement("div");
|
|
184
|
+
leftContainer.className = "flex h-full flex-shrink-0 order-6";
|
|
185
|
+
const newImage = document.createElement("img");
|
|
186
|
+
newImage.src = this.__metadata.image;
|
|
187
|
+
newImage.alt = "Custom Image";
|
|
188
|
+
newImage.className = "w-24 min-h-24 max-[250px] h-[200px] rounded-lg object-fill";
|
|
189
|
+
leftContainer.appendChild(newImage);
|
|
190
|
+
container == null ? void 0 : container.insertBefore(leftContainer, container.firstChild);
|
|
191
|
+
} else {
|
|
192
|
+
image.src = this.__metadata.image;
|
|
193
|
+
}
|
|
194
|
+
} else if (image) {
|
|
195
|
+
image.remove();
|
|
196
|
+
}
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
function $createLinkNode(url, editor) {
|
|
203
|
+
return new LinkWithMetaDataNode(url, editor);
|
|
204
|
+
}
|
|
205
|
+
var TOGGLE_LINK_COMMAND_LinkWithMetaDataNode = createCommand("toggleLink");
|
|
206
|
+
function LinkWithMetaDataPlugin() {
|
|
207
|
+
const [editor] = useLexicalComposerContext();
|
|
208
|
+
useEffect(() => {
|
|
209
|
+
if (!editor.hasNodes([LinkWithMetaDataNode])) {
|
|
210
|
+
throw new Error("LinkWithMetaDataPlugin: LinkWithMetaDataNode not registered on editor");
|
|
211
|
+
}
|
|
212
|
+
}, [editor]);
|
|
213
|
+
editor.registerCommand(
|
|
214
|
+
TOGGLE_LINK_COMMAND_LinkWithMetaDataNode,
|
|
215
|
+
(url) => {
|
|
216
|
+
const selection = $getSelection();
|
|
217
|
+
if ($isRangeSelection(selection)) {
|
|
218
|
+
const linkNode = $createLinkNode(url, editor);
|
|
219
|
+
$insertNodeToNearestRoot(linkNode);
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
},
|
|
223
|
+
COMMAND_PRIORITY_LOW
|
|
224
|
+
);
|
|
225
|
+
return null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/components/editor/plugins/AutoLinkPlugin/index.tsx
|
|
229
|
+
init_react_shim();
|
|
230
|
+
import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
|
|
231
|
+
import { useEffect as useEffect2 } from "react";
|
|
232
|
+
import { $getSelection as $getSelection2, $isRangeSelection as $isRangeSelection2 } from "lexical";
|
|
233
|
+
import { $isCodeHighlightNode } from "@lexical/code";
|
|
234
|
+
var URL_REGEX = new RegExp("((https?:\\/\\/(www\\.)?)|(www\\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])");
|
|
235
|
+
function LexicalAutoLinkPlugin() {
|
|
236
|
+
const [editor] = useLexicalComposerContext2();
|
|
237
|
+
useEffect2(() => {
|
|
238
|
+
const handlePaste = (event) => {
|
|
239
|
+
var _a;
|
|
240
|
+
const pastedText = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
|
|
241
|
+
if (pastedText && URL_REGEX.test(pastedText)) {
|
|
242
|
+
event.preventDefault();
|
|
243
|
+
pastedText.split(" ").map((TEXT) => {
|
|
244
|
+
if (URL_REGEX.test(TEXT)) {
|
|
245
|
+
editor.update(() => {
|
|
246
|
+
const selection = $getSelection2();
|
|
247
|
+
if ($isRangeSelection2(selection)) {
|
|
248
|
+
const node = selection.anchor.getNode();
|
|
249
|
+
if (!$isCodeHighlightNode(node)) {
|
|
250
|
+
if (node && node.getTextContent() === TEXT) {
|
|
251
|
+
node.remove();
|
|
252
|
+
}
|
|
253
|
+
editor.dispatchCommand(TOGGLE_LINK_COMMAND_LinkWithMetaDataNode, TEXT);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
const rootElement = editor.getRootElement();
|
|
262
|
+
if (rootElement) {
|
|
263
|
+
rootElement.addEventListener("paste", handlePaste);
|
|
264
|
+
}
|
|
265
|
+
return () => {
|
|
266
|
+
if (rootElement) {
|
|
267
|
+
rootElement.removeEventListener("paste", handlePaste);
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
}, [editor]);
|
|
271
|
+
return null;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// src/components/editor/plugins/CodeHighlightPlugin/index.ts
|
|
275
|
+
init_react_shim();
|
|
276
|
+
import { registerCodeHighlighting } from "@lexical/code";
|
|
277
|
+
import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
|
|
278
|
+
import { useEffect as useEffect3 } from "react";
|
|
279
|
+
function CodeHighlightPlugin() {
|
|
280
|
+
const [editor] = useLexicalComposerContext3();
|
|
281
|
+
useEffect3(() => {
|
|
282
|
+
return registerCodeHighlighting(editor);
|
|
283
|
+
}, [editor]);
|
|
284
|
+
return null;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/components/editor/nodes/index.ts
|
|
288
|
+
init_react_shim();
|
|
289
|
+
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
290
|
+
import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
291
|
+
import { ListItemNode, ListNode } from "@lexical/list";
|
|
292
|
+
import { MarkNode } from "@lexical/mark";
|
|
293
|
+
import { OverflowNode } from "@lexical/overflow";
|
|
294
|
+
import { HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
|
|
295
|
+
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
296
|
+
import { TableCellNode, TableNode, TableRowNode } from "@lexical/table";
|
|
297
|
+
var nodes = [
|
|
298
|
+
HeadingNode,
|
|
299
|
+
ListNode,
|
|
300
|
+
ListItemNode,
|
|
301
|
+
QuoteNode,
|
|
302
|
+
CodeNode,
|
|
303
|
+
TableNode,
|
|
304
|
+
TableCellNode,
|
|
305
|
+
TableRowNode,
|
|
306
|
+
CodeHighlightNode,
|
|
307
|
+
StepperNode,
|
|
308
|
+
AutoLinkNode,
|
|
309
|
+
YouTubeNode,
|
|
310
|
+
Hint,
|
|
311
|
+
TweetNode,
|
|
312
|
+
LinkNode,
|
|
313
|
+
OverflowNode,
|
|
314
|
+
HorizontalRuleNode,
|
|
315
|
+
MarkNode,
|
|
316
|
+
ImageNode,
|
|
317
|
+
PollNode,
|
|
318
|
+
LayoutItemNode,
|
|
319
|
+
LayoutContainerNode,
|
|
320
|
+
CollapsibleContainerNode,
|
|
321
|
+
CollapsibleContentNode,
|
|
322
|
+
CollapsibleTitleNode,
|
|
323
|
+
LinkWithMetaDataNode,
|
|
324
|
+
InlineImageNode,
|
|
325
|
+
ExcalidrawNode,
|
|
326
|
+
FigmaNode,
|
|
327
|
+
EquationNode,
|
|
328
|
+
StoryBuilderNode,
|
|
329
|
+
DynamicBlockNode
|
|
330
|
+
];
|
|
331
|
+
var nestedNodes = [
|
|
332
|
+
HeadingNode,
|
|
333
|
+
ListNode,
|
|
334
|
+
ListItemNode,
|
|
335
|
+
LinkNode,
|
|
336
|
+
CodeHighlightNode,
|
|
337
|
+
QuoteNode,
|
|
338
|
+
CodeNode,
|
|
339
|
+
StepperNode,
|
|
340
|
+
LinkWithMetaDataNode,
|
|
341
|
+
ImageNode,
|
|
342
|
+
InlineImageNode,
|
|
343
|
+
ExcalidrawNode,
|
|
344
|
+
FigmaNode,
|
|
345
|
+
EquationNode,
|
|
346
|
+
StoryBuilderNode,
|
|
347
|
+
DynamicBlockNode
|
|
348
|
+
];
|
|
349
|
+
var nodes_default = nodes;
|
|
350
|
+
|
|
351
|
+
export {
|
|
352
|
+
LinkWithMetaDataPlugin,
|
|
353
|
+
LexicalAutoLinkPlugin,
|
|
354
|
+
CodeHighlightPlugin,
|
|
355
|
+
nestedNodes,
|
|
356
|
+
nodes_default
|
|
357
|
+
};
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Dialog,
|
|
3
|
+
DialogContent,
|
|
4
|
+
DialogDescription,
|
|
5
|
+
DialogFooter,
|
|
6
|
+
DialogHeader,
|
|
7
|
+
DialogTitle
|
|
8
|
+
} from "./chunk-WDG7J2DY.mjs";
|
|
9
|
+
import {
|
|
10
|
+
Button
|
|
11
|
+
} from "./chunk-BIU7WTLX.mjs";
|
|
12
|
+
import {
|
|
13
|
+
init_react_shim
|
|
14
|
+
} from "./chunk-77KXU36M.mjs";
|
|
15
|
+
|
|
16
|
+
// src/components/ui/excalidraw/ExcalidrawModal.tsx
|
|
17
|
+
init_react_shim();
|
|
18
|
+
import { Excalidraw } from "@excalidraw/excalidraw";
|
|
19
|
+
import { isDOMNode } from "lexical";
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
22
|
+
import { createPortal } from "react-dom";
|
|
23
|
+
import { motion, AnimatePresence } from "framer-motion";
|
|
24
|
+
import { Save, X, Trash2, AlertTriangle, Palette } from "lucide-react";
|
|
25
|
+
var modalVariants = {
|
|
26
|
+
initial: {
|
|
27
|
+
opacity: 0,
|
|
28
|
+
scale: 0.95,
|
|
29
|
+
y: 20
|
|
30
|
+
},
|
|
31
|
+
animate: {
|
|
32
|
+
opacity: 1,
|
|
33
|
+
scale: 1,
|
|
34
|
+
y: 0,
|
|
35
|
+
transition: {
|
|
36
|
+
type: "spring",
|
|
37
|
+
stiffness: 300,
|
|
38
|
+
damping: 30
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
exit: {
|
|
42
|
+
opacity: 0,
|
|
43
|
+
scale: 0.95,
|
|
44
|
+
y: 20,
|
|
45
|
+
transition: {
|
|
46
|
+
duration: 0.2
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var backdropVariants = {
|
|
51
|
+
initial: { opacity: 0 },
|
|
52
|
+
animate: {
|
|
53
|
+
opacity: 1,
|
|
54
|
+
transition: { duration: 0.3 }
|
|
55
|
+
},
|
|
56
|
+
exit: {
|
|
57
|
+
opacity: 0,
|
|
58
|
+
transition: { duration: 0.2 }
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var actionsVariants = {
|
|
62
|
+
initial: { opacity: 0, y: 10 },
|
|
63
|
+
animate: {
|
|
64
|
+
opacity: 1,
|
|
65
|
+
y: 0,
|
|
66
|
+
transition: { delay: 0.2, duration: 0.3 }
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function ExcalidrawModal({
|
|
70
|
+
closeOnClickOutside = false,
|
|
71
|
+
onSave,
|
|
72
|
+
initialElements,
|
|
73
|
+
initialAppState,
|
|
74
|
+
initialFiles,
|
|
75
|
+
isShown = false,
|
|
76
|
+
onDelete,
|
|
77
|
+
onClose
|
|
78
|
+
}) {
|
|
79
|
+
const excaliDrawModelRef = useRef(null);
|
|
80
|
+
const [excalidrawAPI, setExcalidrawAPI] = useState(null);
|
|
81
|
+
const [discardModalOpen, setDiscardModalOpen] = useState(false);
|
|
82
|
+
const [elements, setElements] = useState(initialElements);
|
|
83
|
+
const [files, setFiles] = useState(initialFiles);
|
|
84
|
+
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
var _a;
|
|
87
|
+
(_a = excaliDrawModelRef.current) == null ? void 0 : _a.focus();
|
|
88
|
+
}, []);
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
var _a;
|
|
91
|
+
let modalOverlayElement = null;
|
|
92
|
+
const clickOutsideHandler = (event) => {
|
|
93
|
+
const target = event.target;
|
|
94
|
+
if (excaliDrawModelRef.current !== null && isDOMNode(target) && !excaliDrawModelRef.current.contains(target) && closeOnClickOutside) {
|
|
95
|
+
if (hasUnsavedChanges) {
|
|
96
|
+
setDiscardModalOpen(true);
|
|
97
|
+
} else {
|
|
98
|
+
onDelete();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
if (excaliDrawModelRef.current !== null) {
|
|
103
|
+
modalOverlayElement = (_a = excaliDrawModelRef.current) == null ? void 0 : _a.parentElement;
|
|
104
|
+
modalOverlayElement == null ? void 0 : modalOverlayElement.addEventListener("click", clickOutsideHandler);
|
|
105
|
+
}
|
|
106
|
+
return () => {
|
|
107
|
+
modalOverlayElement == null ? void 0 : modalOverlayElement.removeEventListener("click", clickOutsideHandler);
|
|
108
|
+
};
|
|
109
|
+
}, [closeOnClickOutside, onDelete, hasUnsavedChanges]);
|
|
110
|
+
useLayoutEffect(() => {
|
|
111
|
+
const currentModalRef = excaliDrawModelRef.current;
|
|
112
|
+
const onKeyDown = (event) => {
|
|
113
|
+
if (event.key === "Escape") {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
if (hasUnsavedChanges) {
|
|
116
|
+
setDiscardModalOpen(true);
|
|
117
|
+
} else {
|
|
118
|
+
onDelete();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (event.ctrlKey || event.metaKey) {
|
|
122
|
+
if (event.key === "s") {
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
save();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
currentModalRef == null ? void 0 : currentModalRef.addEventListener("keydown", onKeyDown);
|
|
129
|
+
return () => {
|
|
130
|
+
currentModalRef == null ? void 0 : currentModalRef.removeEventListener("keydown", onKeyDown);
|
|
131
|
+
};
|
|
132
|
+
}, [elements, files, onDelete, hasUnsavedChanges]);
|
|
133
|
+
const save = () => {
|
|
134
|
+
if (elements == null ? void 0 : elements.some((el) => !el.isDeleted)) {
|
|
135
|
+
const appState = excalidrawAPI == null ? void 0 : excalidrawAPI.getAppState();
|
|
136
|
+
const partialState = {
|
|
137
|
+
exportBackground: appState == null ? void 0 : appState.exportBackground,
|
|
138
|
+
exportScale: appState == null ? void 0 : appState.exportScale,
|
|
139
|
+
exportWithDarkMode: (appState == null ? void 0 : appState.theme) === "dark",
|
|
140
|
+
isBindingEnabled: appState == null ? void 0 : appState.isBindingEnabled,
|
|
141
|
+
isLoading: appState == null ? void 0 : appState.isLoading,
|
|
142
|
+
name: appState == null ? void 0 : appState.name,
|
|
143
|
+
theme: appState == null ? void 0 : appState.theme,
|
|
144
|
+
viewBackgroundColor: appState == null ? void 0 : appState.viewBackgroundColor,
|
|
145
|
+
viewModeEnabled: appState == null ? void 0 : appState.viewModeEnabled,
|
|
146
|
+
zenModeEnabled: appState == null ? void 0 : appState.zenModeEnabled,
|
|
147
|
+
zoom: appState == null ? void 0 : appState.zoom
|
|
148
|
+
};
|
|
149
|
+
onSave(elements, partialState, files);
|
|
150
|
+
setHasUnsavedChanges(false);
|
|
151
|
+
} else {
|
|
152
|
+
onDelete();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const discard = () => {
|
|
156
|
+
if (hasUnsavedChanges) {
|
|
157
|
+
setDiscardModalOpen(true);
|
|
158
|
+
} else {
|
|
159
|
+
onClose();
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
const handleConfirmDiscard = () => {
|
|
163
|
+
setDiscardModalOpen(false);
|
|
164
|
+
setHasUnsavedChanges(false);
|
|
165
|
+
onClose();
|
|
166
|
+
};
|
|
167
|
+
function DiscardConfirmationDialog() {
|
|
168
|
+
return /* @__PURE__ */ React.createElement(Dialog, { open: discardModalOpen, onOpenChange: setDiscardModalOpen }, /* @__PURE__ */ React.createElement(DialogContent, { className: "sm:max-w-md" }, /* @__PURE__ */ React.createElement(DialogHeader, { className: "text-center sm:text-center" }, /* @__PURE__ */ React.createElement("div", { className: "mx-auto flex h-12 w-12 items-center justify-center rounded-full bg-red-100 dark:bg-red-900/20" }, /* @__PURE__ */ React.createElement(AlertTriangle, { className: "h-6 w-6 text-red-600 dark:text-red-400" })), /* @__PURE__ */ React.createElement(DialogTitle, { className: "text-lg font-semibold text-gray-900 dark:text-gray-100" }, "Discard Changes?"), /* @__PURE__ */ React.createElement(DialogDescription, { className: "text-sm text-gray-500 dark:text-gray-400" }, "You have unsaved changes in your drawing. Are you sure you want to discard them? This action cannot be undone.")), /* @__PURE__ */ React.createElement(DialogFooter, { className: "gap-3 pt-6" }, /* @__PURE__ */ React.createElement(
|
|
169
|
+
Button,
|
|
170
|
+
{
|
|
171
|
+
variant: "outline",
|
|
172
|
+
onClick: () => setDiscardModalOpen(false),
|
|
173
|
+
className: "flex-1 sm:flex-none"
|
|
174
|
+
},
|
|
175
|
+
"Cancel"
|
|
176
|
+
), /* @__PURE__ */ React.createElement(
|
|
177
|
+
Button,
|
|
178
|
+
{
|
|
179
|
+
variant: "destructive",
|
|
180
|
+
onClick: handleConfirmDiscard,
|
|
181
|
+
className: "flex-1 sm:flex-none"
|
|
182
|
+
},
|
|
183
|
+
/* @__PURE__ */ React.createElement(Trash2, { className: "mr-2 h-4 w-4" }),
|
|
184
|
+
"Discard"
|
|
185
|
+
))));
|
|
186
|
+
}
|
|
187
|
+
if (isShown === false) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
const onChange = (els, _, fls) => {
|
|
191
|
+
setElements(els);
|
|
192
|
+
setFiles(fls);
|
|
193
|
+
const hasChanges = els && initialElements ? els.length !== initialElements.length || els.some((el, idx) => JSON.stringify(el) !== JSON.stringify(initialElements[idx])) : els !== initialElements;
|
|
194
|
+
setHasUnsavedChanges(hasChanges);
|
|
195
|
+
};
|
|
196
|
+
const hasContent = elements == null ? void 0 : elements.some((el) => !el.isDeleted);
|
|
197
|
+
return createPortal(
|
|
198
|
+
/* @__PURE__ */ React.createElement(AnimatePresence, { mode: "wait" }, /* @__PURE__ */ React.createElement(
|
|
199
|
+
motion.div,
|
|
200
|
+
{
|
|
201
|
+
className: "fixed inset-0 z-[250] flex items-center justify-center",
|
|
202
|
+
initial: "initial",
|
|
203
|
+
animate: "animate",
|
|
204
|
+
exit: "exit",
|
|
205
|
+
variants: backdropVariants
|
|
206
|
+
},
|
|
207
|
+
/* @__PURE__ */ React.createElement(
|
|
208
|
+
motion.div,
|
|
209
|
+
{
|
|
210
|
+
className: "absolute inset-0 bg-black/60 backdrop-blur-sm",
|
|
211
|
+
onClick: () => {
|
|
212
|
+
if (closeOnClickOutside) {
|
|
213
|
+
if (hasUnsavedChanges) {
|
|
214
|
+
setDiscardModalOpen(true);
|
|
215
|
+
} else {
|
|
216
|
+
onDelete();
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
/* @__PURE__ */ React.createElement(
|
|
223
|
+
motion.div,
|
|
224
|
+
{
|
|
225
|
+
className: "relative z-10 mx-4 flex h-[90vh] w-full max-w-6xl flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-2xl dark:border-gray-800 dark:bg-gray-900",
|
|
226
|
+
ref: excaliDrawModelRef,
|
|
227
|
+
tabIndex: -1,
|
|
228
|
+
variants: modalVariants,
|
|
229
|
+
role: "dialog",
|
|
230
|
+
"aria-modal": "true",
|
|
231
|
+
"aria-labelledby": "excalidraw-title",
|
|
232
|
+
"aria-describedby": "excalidraw-description"
|
|
233
|
+
},
|
|
234
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between border-b border-gray-200 bg-gray-50 px-6 py-4 dark:border-gray-800 dark:bg-gray-800/50" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-3" }, /* @__PURE__ */ React.createElement("div", { className: "flex h-10 w-10 items-center justify-center rounded-lg bg-blue-100 dark:bg-blue-900/20" }, /* @__PURE__ */ React.createElement(Palette, { className: "h-5 w-5 text-blue-600 dark:text-blue-400" })), /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
|
|
235
|
+
"h2",
|
|
236
|
+
{
|
|
237
|
+
id: "excalidraw-title",
|
|
238
|
+
className: "text-lg font-semibold text-gray-900 dark:text-gray-100"
|
|
239
|
+
},
|
|
240
|
+
"Drawing Editor"
|
|
241
|
+
), /* @__PURE__ */ React.createElement(
|
|
242
|
+
"p",
|
|
243
|
+
{
|
|
244
|
+
id: "excalidraw-description",
|
|
245
|
+
className: "text-sm text-gray-500 dark:text-gray-400"
|
|
246
|
+
},
|
|
247
|
+
"Create and edit your drawings with Excalidraw",
|
|
248
|
+
hasUnsavedChanges && /* @__PURE__ */ React.createElement("span", { className: "ml-2 inline-flex items-center rounded-full bg-amber-100 px-2 py-1 text-xs font-medium text-amber-800 dark:bg-amber-900/20 dark:text-amber-400" }, "Unsaved changes")
|
|
249
|
+
))), /* @__PURE__ */ React.createElement(
|
|
250
|
+
Button,
|
|
251
|
+
{
|
|
252
|
+
variant: "ghost",
|
|
253
|
+
size: "icon",
|
|
254
|
+
onClick: () => {
|
|
255
|
+
if (hasUnsavedChanges) {
|
|
256
|
+
setDiscardModalOpen(true);
|
|
257
|
+
} else {
|
|
258
|
+
onDelete();
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
className: "h-8 w-8",
|
|
262
|
+
"aria-label": "Close drawing editor"
|
|
263
|
+
},
|
|
264
|
+
/* @__PURE__ */ React.createElement(X, { className: "h-4 w-4" })
|
|
265
|
+
)),
|
|
266
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex-1 overflow-hidden" }, /* @__PURE__ */ React.createElement("div", { className: "h-full w-full" }, /* @__PURE__ */ React.createElement(
|
|
267
|
+
Excalidraw,
|
|
268
|
+
{
|
|
269
|
+
onChange,
|
|
270
|
+
excalidrawAPI: setExcalidrawAPI,
|
|
271
|
+
initialData: {
|
|
272
|
+
appState: initialAppState || { isLoading: false },
|
|
273
|
+
elements: initialElements,
|
|
274
|
+
files: initialFiles
|
|
275
|
+
},
|
|
276
|
+
theme: "light"
|
|
277
|
+
}
|
|
278
|
+
))),
|
|
279
|
+
/* @__PURE__ */ React.createElement(
|
|
280
|
+
motion.div,
|
|
281
|
+
{
|
|
282
|
+
className: "flex items-center justify-between border-t border-gray-200 bg-gray-50 px-6 py-4 dark:border-gray-800 dark:bg-gray-800/50",
|
|
283
|
+
variants: actionsVariants
|
|
284
|
+
},
|
|
285
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-2 text-sm text-gray-500 dark:text-gray-400" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-1" }, /* @__PURE__ */ React.createElement("kbd", { className: "rounded bg-gray-200 px-2 py-1 text-xs font-mono dark:bg-gray-700" }, "Ctrl"), /* @__PURE__ */ React.createElement("span", null, "+"), /* @__PURE__ */ React.createElement("kbd", { className: "rounded bg-gray-200 px-2 py-1 text-xs font-mono dark:bg-gray-700" }, "S"), /* @__PURE__ */ React.createElement("span", { className: "ml-1" }, "to save")), /* @__PURE__ */ React.createElement("span", { className: "text-gray-300 dark:text-gray-600" }, "\u2022"), /* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-1" }, /* @__PURE__ */ React.createElement("kbd", { className: "rounded bg-gray-200 px-2 py-1 text-xs font-mono dark:bg-gray-700" }, "Esc"), /* @__PURE__ */ React.createElement("span", { className: "ml-1" }, "to close"))),
|
|
286
|
+
/* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-3" }, /* @__PURE__ */ React.createElement(
|
|
287
|
+
Button,
|
|
288
|
+
{
|
|
289
|
+
variant: "outline",
|
|
290
|
+
onClick: discard,
|
|
291
|
+
className: "min-w-[100px]"
|
|
292
|
+
},
|
|
293
|
+
/* @__PURE__ */ React.createElement(X, { className: "mr-2 h-4 w-4" }),
|
|
294
|
+
hasUnsavedChanges ? "Discard" : "Close"
|
|
295
|
+
), /* @__PURE__ */ React.createElement(
|
|
296
|
+
Button,
|
|
297
|
+
{
|
|
298
|
+
onClick: save,
|
|
299
|
+
disabled: !hasContent,
|
|
300
|
+
className: "min-w-[100px]"
|
|
301
|
+
},
|
|
302
|
+
/* @__PURE__ */ React.createElement(Save, { className: "mr-2 h-4 w-4" }),
|
|
303
|
+
"Save Drawing"
|
|
304
|
+
))
|
|
305
|
+
)
|
|
306
|
+
),
|
|
307
|
+
discardModalOpen && /* @__PURE__ */ React.createElement(DiscardConfirmationDialog, null)
|
|
308
|
+
)),
|
|
309
|
+
document.body
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export {
|
|
314
|
+
ExcalidrawModal
|
|
315
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_react_shim
|
|
3
|
+
} from "./chunk-77KXU36M.mjs";
|
|
4
|
+
|
|
5
|
+
// src/lib/utils.ts
|
|
6
|
+
init_react_shim();
|
|
7
|
+
import { clsx } from "clsx";
|
|
8
|
+
import { twMerge } from "tailwind-merge";
|
|
9
|
+
function cn(...inputs) {
|
|
10
|
+
return twMerge(clsx(inputs));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
cn
|
|
15
|
+
};
|