@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,217 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
$isHintNode
|
|
4
|
+
} from "./chunk-G53GLEAY.mjs";
|
|
5
|
+
import {
|
|
6
|
+
init_react_shim
|
|
7
|
+
} from "./chunk-77KXU36M.mjs";
|
|
8
|
+
|
|
9
|
+
// src/components/editor/nodes/Hint/HintComponet.tsx
|
|
10
|
+
init_react_shim();
|
|
11
|
+
import { $getNodeByKey } from "lexical";
|
|
12
|
+
import React from "react";
|
|
13
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
14
|
+
import { cva } from "class-variance-authority";
|
|
15
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
16
|
+
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
17
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
18
|
+
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
19
|
+
import { PlainTextPlugin } from "@lexical/react/LexicalPlainTextPlugin";
|
|
20
|
+
var hintVariants = cva(
|
|
21
|
+
"hint p-4 max-sm:p-2 transition-colors my-2 flex flex-row max-sm:flex-col items-start relative justify-between rounded-md straight-corners:rounded-none w-full text-destructive-foreground shadow-xl mx-auto max-w-3xl",
|
|
22
|
+
{
|
|
23
|
+
variants: {
|
|
24
|
+
variant: {
|
|
25
|
+
default: "border border-border/20 dark:bg-black bg-white text-foreground",
|
|
26
|
+
success: "dark:bg-green-500/20 bg-green-500/70 dark:shadow-green-800/10 shadow-green-500/30 border-green-500/40 decoration-primary/60",
|
|
27
|
+
error: "destructive border-destructive dark:shadow-red-800/20 shadow-red-500/30 bg-destructive ",
|
|
28
|
+
warning: "bg-yellow-500/50 dark:shadow-yellow-500/10 shadow-yellow-500/20 border-yellow-500/40",
|
|
29
|
+
info: "bg-blue-500/50 shadow-blue-500/10 bg-blue-700/70 shadow-blue-700/20 border-blue-500/40"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultVariants: {
|
|
33
|
+
variant: "default"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
function HintComponent({
|
|
38
|
+
type,
|
|
39
|
+
captionEditor,
|
|
40
|
+
nodeKey
|
|
41
|
+
}) {
|
|
42
|
+
const [editor] = useLexicalComposerContext();
|
|
43
|
+
const variantMap = {
|
|
44
|
+
hint: "success",
|
|
45
|
+
warning: "warning",
|
|
46
|
+
info: "info",
|
|
47
|
+
error: "error",
|
|
48
|
+
success: "success"
|
|
49
|
+
};
|
|
50
|
+
const variant = variantMap[type] || "default";
|
|
51
|
+
const variantOrder = [
|
|
52
|
+
"success",
|
|
53
|
+
"warning",
|
|
54
|
+
"info",
|
|
55
|
+
"error",
|
|
56
|
+
"hint"
|
|
57
|
+
];
|
|
58
|
+
function handleIcon(type2) {
|
|
59
|
+
switch (type2) {
|
|
60
|
+
case "hint":
|
|
61
|
+
return /* @__PURE__ */ React.createElement(
|
|
62
|
+
"svg",
|
|
63
|
+
{
|
|
64
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
65
|
+
width: "1.5em",
|
|
66
|
+
height: "1.5em",
|
|
67
|
+
viewBox: "0 0 36 36"
|
|
68
|
+
},
|
|
69
|
+
/* @__PURE__ */ React.createElement(
|
|
70
|
+
"path",
|
|
71
|
+
{
|
|
72
|
+
fill: "currentColor",
|
|
73
|
+
d: "M18 2a16 16 0 1 0 16 16A16 16 0 0 0 18 2m0 30a14 14 0 1 1 14-14a14 14 0 0 1-14 14",
|
|
74
|
+
className: "clr-i-outline clr-i-outline-path-1"
|
|
75
|
+
}
|
|
76
|
+
),
|
|
77
|
+
/* @__PURE__ */ React.createElement(
|
|
78
|
+
"path",
|
|
79
|
+
{
|
|
80
|
+
fill: "currentColor",
|
|
81
|
+
d: "M28 12.1a1 1 0 0 0-1.41 0l-11.1 11.05l-6-6A1 1 0 0 0 8 18.53L15.49 26L28 13.52a1 1 0 0 0 0-1.42",
|
|
82
|
+
className: "clr-i-outline clr-i-outline-path-2"
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
/* @__PURE__ */ React.createElement("path", { fill: "none", d: "M0 0h36v36H0z" })
|
|
86
|
+
);
|
|
87
|
+
case "warning":
|
|
88
|
+
return /* @__PURE__ */ React.createElement(
|
|
89
|
+
"svg",
|
|
90
|
+
{
|
|
91
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
92
|
+
width: "1.5em",
|
|
93
|
+
height: "1.5em",
|
|
94
|
+
viewBox: "0 0 24 24"
|
|
95
|
+
},
|
|
96
|
+
/* @__PURE__ */ React.createElement(
|
|
97
|
+
"path",
|
|
98
|
+
{
|
|
99
|
+
fill: "currentColor",
|
|
100
|
+
d: "M4.126 20q-.234 0-.414-.111t-.28-.293q-.108-.179-.12-.387q-.01-.209.118-.421L11.3 5.212q.128-.212.308-.308T12 4.808t.391.096t.308.308l7.871 13.576q.128.212.117.42q-.01.21-.12.388q-.1.182-.28.293t-.413.111zm.324-1h15.1L12 6zM12 17.616q.262 0 .439-.177t.176-.439t-.177-.438t-.438-.178t-.438.177t-.177.439t.177.439t.438.177m0-2.231q.214 0 .357-.144t.143-.356v-4q0-.213-.144-.357t-.357-.143t-.356.143t-.143.357v4q0 .212.144.356t.357.144M12 12.5"
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
);
|
|
104
|
+
case "info":
|
|
105
|
+
return /* @__PURE__ */ React.createElement(
|
|
106
|
+
"svg",
|
|
107
|
+
{
|
|
108
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
109
|
+
width: "1.5em",
|
|
110
|
+
height: "1.5em",
|
|
111
|
+
viewBox: "0 0 24 24"
|
|
112
|
+
},
|
|
113
|
+
/* @__PURE__ */ React.createElement("g", { fill: "none", stroke: "currentColor", strokeLinejoin: "round" }, /* @__PURE__ */ React.createElement(
|
|
114
|
+
"circle",
|
|
115
|
+
{
|
|
116
|
+
cx: "12",
|
|
117
|
+
cy: "12",
|
|
118
|
+
r: "9",
|
|
119
|
+
strokeLinecap: "round",
|
|
120
|
+
strokeWidth: "1.5"
|
|
121
|
+
}
|
|
122
|
+
), /* @__PURE__ */ React.createElement("path", { strokeWidth: "2.25", d: "M12 8h.01v.01H12z" }), /* @__PURE__ */ React.createElement("path", { strokeLinecap: "round", strokeWidth: "1.5", d: "M12 12v4" }))
|
|
123
|
+
);
|
|
124
|
+
case "error":
|
|
125
|
+
return /* @__PURE__ */ React.createElement(
|
|
126
|
+
"svg",
|
|
127
|
+
{
|
|
128
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
129
|
+
width: "1.5em",
|
|
130
|
+
height: "1.5em",
|
|
131
|
+
viewBox: "0 0 512 512"
|
|
132
|
+
},
|
|
133
|
+
/* @__PURE__ */ React.createElement(
|
|
134
|
+
"path",
|
|
135
|
+
{
|
|
136
|
+
fill: "currentColor",
|
|
137
|
+
fillRule: "evenodd",
|
|
138
|
+
d: "M256 42.667c117.803 0 213.334 95.53 213.334 213.333S373.803 469.334 256 469.334S42.667 373.803 42.667 256S138.197 42.667 256 42.667m0 42.667c-94.1 0-170.666 76.565-170.666 170.666c0 94.102 76.565 170.667 170.666 170.667c94.102 0 170.667-76.565 170.667-170.667c0-94.101-76.565-170.666-170.667-170.666m48.918 91.584l30.165 30.165L286.166 256l48.917 48.918l-30.165 30.165L256 286.166l-48.917 48.917l-30.165-30.165L225.835 256l-48.917-48.917l30.165-30.165L256 225.835z"
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
);
|
|
142
|
+
case "success":
|
|
143
|
+
return /* @__PURE__ */ React.createElement(
|
|
144
|
+
"svg",
|
|
145
|
+
{
|
|
146
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
147
|
+
width: "1.5em",
|
|
148
|
+
height: "1.5em",
|
|
149
|
+
viewBox: "0 0 36 36"
|
|
150
|
+
},
|
|
151
|
+
/* @__PURE__ */ React.createElement(
|
|
152
|
+
"path",
|
|
153
|
+
{
|
|
154
|
+
fill: "currentColor",
|
|
155
|
+
d: "M18 2a16 16 0 1 0 16 16A16 16 0 0 0 18 2m0 30a14 14 0 1 1 14-14a14 14 0 0 1-14 14",
|
|
156
|
+
className: "clr-i-outline clr-i-outline-path-1"
|
|
157
|
+
}
|
|
158
|
+
),
|
|
159
|
+
/* @__PURE__ */ React.createElement(
|
|
160
|
+
"path",
|
|
161
|
+
{
|
|
162
|
+
fill: "currentColor",
|
|
163
|
+
d: "M28 12.1a1 1 0 0 0-1.41 0l-11.1 11.05l-6-6A1 1 0 0 0 8 18.53L15.49 26L28 13.52a1 1 0 0 0 0-1.42",
|
|
164
|
+
className: "clr-i-outline clr-i-outline-path-2"
|
|
165
|
+
}
|
|
166
|
+
),
|
|
167
|
+
/* @__PURE__ */ React.createElement("path", { fill: "none", d: "M0 0h36v36H0z" })
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
function handleVariantChange() {
|
|
172
|
+
editor.update(() => {
|
|
173
|
+
const node = $getNodeByKey(nodeKey);
|
|
174
|
+
if ($isHintNode(node)) {
|
|
175
|
+
const currentVariant = node.__variant;
|
|
176
|
+
const currentIndex = variantOrder.indexOf(currentVariant);
|
|
177
|
+
const nextIndex = (currentIndex + 1) % variantOrder.length;
|
|
178
|
+
const nextVariant = variantOrder[nextIndex];
|
|
179
|
+
node.setVariant(nextVariant);
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
return /* @__PURE__ */ React.createElement("div", { className: hintVariants({ variant }) }, /* @__PURE__ */ React.createElement(
|
|
184
|
+
"button",
|
|
185
|
+
{
|
|
186
|
+
type: "button",
|
|
187
|
+
disabled: !editor.isEditable(),
|
|
188
|
+
onClick: handleVariantChange,
|
|
189
|
+
className: "cursor-pointer max-sm:mb-1 ml-2"
|
|
190
|
+
},
|
|
191
|
+
handleIcon(variant)
|
|
192
|
+
), /* @__PURE__ */ React.createElement(LexicalNestedComposer, { initialEditor: captionEditor }, /* @__PURE__ */ React.createElement(HistoryPlugin, null), /* @__PURE__ */ React.createElement(
|
|
193
|
+
PlainTextPlugin,
|
|
194
|
+
{
|
|
195
|
+
contentEditable: /* @__PURE__ */ React.createElement(
|
|
196
|
+
ContentEditable,
|
|
197
|
+
{
|
|
198
|
+
className: "\r\n flex-1 ml-3\r\n border-0 resize-none cursor-text\r\n block relative outline-none select-text\r\n whitespace-pre-wrap break-words\r\n ",
|
|
199
|
+
"aria-placeholder": "Write hint caption",
|
|
200
|
+
contentEditable: editor.isEditable(),
|
|
201
|
+
"aria-disabled": true,
|
|
202
|
+
placeholder: /* @__PURE__ */ React.createElement(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
className: " \r\n text-base text-[#999] overflow-hidden absolute top-[17px] left-[55px] \r\n select-none text-nowrap inline-block text-ellipsis pointer-events-none\r\n "
|
|
206
|
+
},
|
|
207
|
+
"Write your note"
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
212
|
+
}
|
|
213
|
+
)));
|
|
214
|
+
}
|
|
215
|
+
export {
|
|
216
|
+
HintComponent as default
|
|
217
|
+
};
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import {
|
|
3
|
+
DialogActions,
|
|
4
|
+
Select,
|
|
5
|
+
TextInput
|
|
6
|
+
} from "./chunk-YPHOEJ46.mjs";
|
|
7
|
+
import {
|
|
8
|
+
validateUrl
|
|
9
|
+
} from "./chunk-4VWFVWYP.mjs";
|
|
10
|
+
import {
|
|
11
|
+
Button
|
|
12
|
+
} from "./chunk-BIU7WTLX.mjs";
|
|
13
|
+
import "./chunk-YHPNOWFH.mjs";
|
|
14
|
+
import {
|
|
15
|
+
React,
|
|
16
|
+
init_react_shim
|
|
17
|
+
} from "./chunk-77KXU36M.mjs";
|
|
18
|
+
|
|
19
|
+
// src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx
|
|
20
|
+
init_react_shim();
|
|
21
|
+
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
22
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
23
|
+
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
24
|
+
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
25
|
+
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
26
|
+
import { useLexicalEditable } from "@lexical/react/useLexicalEditable";
|
|
27
|
+
import { useLexicalNodeSelection } from "@lexical/react/useLexicalNodeSelection";
|
|
28
|
+
import { mergeRegister } from "@lexical/utils";
|
|
29
|
+
import {
|
|
30
|
+
$getNodeByKey,
|
|
31
|
+
$getSelection,
|
|
32
|
+
$isNodeSelection,
|
|
33
|
+
$setSelection,
|
|
34
|
+
CLICK_COMMAND,
|
|
35
|
+
COMMAND_PRIORITY_LOW,
|
|
36
|
+
DRAGSTART_COMMAND,
|
|
37
|
+
KEY_ENTER_COMMAND,
|
|
38
|
+
KEY_ESCAPE_COMMAND,
|
|
39
|
+
SELECTION_CHANGE_COMMAND
|
|
40
|
+
} from "lexical";
|
|
41
|
+
import { Suspense, useCallback as useCallback2, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
42
|
+
|
|
43
|
+
// src/hooks/useModal.tsx
|
|
44
|
+
init_react_shim();
|
|
45
|
+
import { useCallback, useMemo, useState } from "react";
|
|
46
|
+
import * as React3 from "react";
|
|
47
|
+
|
|
48
|
+
// src/components/ui/Modal.tsx
|
|
49
|
+
init_react_shim();
|
|
50
|
+
import { isDOMNode } from "lexical";
|
|
51
|
+
import * as React2 from "react";
|
|
52
|
+
import { useEffect, useRef } from "react";
|
|
53
|
+
import { createPortal } from "react-dom";
|
|
54
|
+
function PortalImpl({
|
|
55
|
+
onClose,
|
|
56
|
+
children,
|
|
57
|
+
title,
|
|
58
|
+
closeOnClickOutside
|
|
59
|
+
}) {
|
|
60
|
+
const modalRef = useRef(null);
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (modalRef.current !== null) {
|
|
63
|
+
modalRef.current.focus();
|
|
64
|
+
}
|
|
65
|
+
}, []);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
let modalOverlayElement = null;
|
|
68
|
+
const handler = (event) => {
|
|
69
|
+
if (event.key === "Escape") {
|
|
70
|
+
onClose();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const clickOutsideHandler = (event) => {
|
|
74
|
+
const target = event.target;
|
|
75
|
+
if (modalRef.current !== null && isDOMNode(target) && !modalRef.current.contains(target) && closeOnClickOutside) {
|
|
76
|
+
onClose();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const modelElement = modalRef.current;
|
|
80
|
+
if (modelElement !== null) {
|
|
81
|
+
modalOverlayElement = modelElement.parentElement;
|
|
82
|
+
if (modalOverlayElement !== null) {
|
|
83
|
+
modalOverlayElement.addEventListener("click", clickOutsideHandler);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
window.addEventListener("keydown", handler);
|
|
87
|
+
return () => {
|
|
88
|
+
window.removeEventListener("keydown", handler);
|
|
89
|
+
if (modalOverlayElement !== null) {
|
|
90
|
+
modalOverlayElement == null ? void 0 : modalOverlayElement.removeEventListener("click", clickOutsideHandler);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}, [closeOnClickOutside, onClose]);
|
|
94
|
+
return /* @__PURE__ */ React2.createElement("div", { className: "Modal__overlay", role: "dialog" }, /* @__PURE__ */ React2.createElement("div", { className: "Modal__modal", tabIndex: -1, ref: modalRef }, /* @__PURE__ */ React2.createElement("h2", { className: "Modal__title" }, title), /* @__PURE__ */ React2.createElement(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
className: "Modal__closeButton",
|
|
98
|
+
"aria-label": "Close modal",
|
|
99
|
+
type: "button",
|
|
100
|
+
onClick: onClose
|
|
101
|
+
},
|
|
102
|
+
"X"
|
|
103
|
+
), /* @__PURE__ */ React2.createElement("div", { className: "Modal__content" }, children)));
|
|
104
|
+
}
|
|
105
|
+
function Modal({
|
|
106
|
+
onClose,
|
|
107
|
+
children,
|
|
108
|
+
title,
|
|
109
|
+
closeOnClickOutside = false
|
|
110
|
+
}) {
|
|
111
|
+
return createPortal(
|
|
112
|
+
/* @__PURE__ */ React2.createElement(
|
|
113
|
+
PortalImpl,
|
|
114
|
+
{
|
|
115
|
+
onClose,
|
|
116
|
+
title,
|
|
117
|
+
closeOnClickOutside
|
|
118
|
+
},
|
|
119
|
+
children
|
|
120
|
+
),
|
|
121
|
+
document.body
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/hooks/useModal.tsx
|
|
126
|
+
function useModal() {
|
|
127
|
+
const [modalContent, setModalContent] = useState(null);
|
|
128
|
+
const onClose = useCallback(() => {
|
|
129
|
+
setModalContent(null);
|
|
130
|
+
}, []);
|
|
131
|
+
const modal = useMemo(() => {
|
|
132
|
+
if (modalContent === null) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
const { title, content, closeOnClickOutside } = modalContent;
|
|
136
|
+
return /* @__PURE__ */ React3.createElement(
|
|
137
|
+
Modal,
|
|
138
|
+
{
|
|
139
|
+
onClose,
|
|
140
|
+
title,
|
|
141
|
+
closeOnClickOutside
|
|
142
|
+
},
|
|
143
|
+
content
|
|
144
|
+
);
|
|
145
|
+
}, [modalContent, onClose]);
|
|
146
|
+
const showModal = useCallback(
|
|
147
|
+
(title, getContent, closeOnClickOutside = false) => {
|
|
148
|
+
setModalContent({
|
|
149
|
+
closeOnClickOutside,
|
|
150
|
+
content: getContent(onClose),
|
|
151
|
+
title
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
[onClose]
|
|
155
|
+
);
|
|
156
|
+
return [modal, showModal];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// src/components/editor/plugins/LinkPlugin/index.tsx
|
|
160
|
+
init_react_shim();
|
|
161
|
+
import { LinkPlugin as LexicalLinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
162
|
+
import * as React4 from "react";
|
|
163
|
+
function LinkPlugin({
|
|
164
|
+
hasLinkAttributes = false
|
|
165
|
+
}) {
|
|
166
|
+
return /* @__PURE__ */ React4.createElement(
|
|
167
|
+
LexicalLinkPlugin,
|
|
168
|
+
{
|
|
169
|
+
validateUrl,
|
|
170
|
+
attributes: hasLinkAttributes ? {
|
|
171
|
+
rel: "noopener noreferrer",
|
|
172
|
+
target: "_blank"
|
|
173
|
+
} : void 0
|
|
174
|
+
}
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/components/ui/ContentEditable.tsx
|
|
179
|
+
init_react_shim();
|
|
180
|
+
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
181
|
+
import * as React5 from "react";
|
|
182
|
+
function LexicalContentEditable({
|
|
183
|
+
className,
|
|
184
|
+
placeholder,
|
|
185
|
+
placeholderClassName
|
|
186
|
+
}) {
|
|
187
|
+
return /* @__PURE__ */ React5.createElement(
|
|
188
|
+
ContentEditable,
|
|
189
|
+
{
|
|
190
|
+
className: className != null ? className : "ContentEditable__root",
|
|
191
|
+
"aria-placeholder": placeholder,
|
|
192
|
+
placeholder: /* @__PURE__ */ React5.createElement("div", { className: placeholderClassName != null ? placeholderClassName : "ContentEditable__placeholder" }, placeholder)
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/components/editor/nodes/InlineImageNode/InlineImageComponent.tsx
|
|
198
|
+
var imageCache = /* @__PURE__ */ new Set();
|
|
199
|
+
function useSuspenseImage(src) {
|
|
200
|
+
if (!imageCache.has(src)) {
|
|
201
|
+
throw new Promise((resolve) => {
|
|
202
|
+
const img = new Image();
|
|
203
|
+
img.src = src;
|
|
204
|
+
img.onload = () => {
|
|
205
|
+
imageCache.add(src);
|
|
206
|
+
resolve(null);
|
|
207
|
+
};
|
|
208
|
+
img.onerror = () => {
|
|
209
|
+
imageCache.add(src);
|
|
210
|
+
resolve(null);
|
|
211
|
+
};
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function LazyImage({
|
|
216
|
+
altText,
|
|
217
|
+
className,
|
|
218
|
+
imageRef,
|
|
219
|
+
src,
|
|
220
|
+
width,
|
|
221
|
+
height,
|
|
222
|
+
position
|
|
223
|
+
}) {
|
|
224
|
+
useSuspenseImage(src);
|
|
225
|
+
return /* @__PURE__ */ React.createElement(
|
|
226
|
+
"img",
|
|
227
|
+
{
|
|
228
|
+
className: `block ${className || ""}`,
|
|
229
|
+
src: src || "/placeholder.svg",
|
|
230
|
+
alt: altText,
|
|
231
|
+
ref: imageRef,
|
|
232
|
+
"data-position": position,
|
|
233
|
+
style: {
|
|
234
|
+
height,
|
|
235
|
+
width
|
|
236
|
+
},
|
|
237
|
+
draggable: "false"
|
|
238
|
+
}
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
function UpdateInlineImageDialog({
|
|
242
|
+
activeEditor,
|
|
243
|
+
nodeKey,
|
|
244
|
+
onClose
|
|
245
|
+
}) {
|
|
246
|
+
const editorState = activeEditor.getEditorState();
|
|
247
|
+
const node = editorState.read(() => $getNodeByKey(nodeKey));
|
|
248
|
+
const [altText, setAltText] = useState2(node.getAltText());
|
|
249
|
+
const [showCaption, setShowCaption] = useState2(node.getShowCaption());
|
|
250
|
+
const [position, setPosition] = useState2(node.getPosition());
|
|
251
|
+
const handleShowCaptionChange = (e) => {
|
|
252
|
+
setShowCaption(e.target.checked);
|
|
253
|
+
};
|
|
254
|
+
const handlePositionChange = (e) => {
|
|
255
|
+
setPosition(e.target.value);
|
|
256
|
+
};
|
|
257
|
+
const handleOnConfirm = () => {
|
|
258
|
+
const payload = { altText, position, showCaption };
|
|
259
|
+
if (node) {
|
|
260
|
+
activeEditor.update(() => {
|
|
261
|
+
node.update(payload);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
onClose();
|
|
265
|
+
};
|
|
266
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "mb-4" }, /* @__PURE__ */ React.createElement(
|
|
267
|
+
TextInput,
|
|
268
|
+
{
|
|
269
|
+
label: "Alt Text",
|
|
270
|
+
placeholder: "Descriptive alternative text",
|
|
271
|
+
onChange: setAltText,
|
|
272
|
+
value: altText,
|
|
273
|
+
"data-test-id": "image-modal-alt-text-input"
|
|
274
|
+
}
|
|
275
|
+
)), /* @__PURE__ */ React.createElement(
|
|
276
|
+
Select,
|
|
277
|
+
{
|
|
278
|
+
className: "mb-4 w-52",
|
|
279
|
+
value: position,
|
|
280
|
+
label: "Position",
|
|
281
|
+
name: "position",
|
|
282
|
+
id: "position-select",
|
|
283
|
+
onChange: handlePositionChange
|
|
284
|
+
},
|
|
285
|
+
/* @__PURE__ */ React.createElement("option", { value: "left" }, "Left"),
|
|
286
|
+
/* @__PURE__ */ React.createElement("option", { value: "right" }, "Right"),
|
|
287
|
+
/* @__PURE__ */ React.createElement("option", { value: "full" }, "Full Width")
|
|
288
|
+
), /* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-2 mb-4" }, /* @__PURE__ */ React.createElement(
|
|
289
|
+
"input",
|
|
290
|
+
{
|
|
291
|
+
id: "caption",
|
|
292
|
+
type: "checkbox",
|
|
293
|
+
checked: showCaption,
|
|
294
|
+
onChange: handleShowCaptionChange,
|
|
295
|
+
className: "w-4 h-4 text-primary bg-background border-border rounded focus:ring-ring focus:ring-2"
|
|
296
|
+
}
|
|
297
|
+
), /* @__PURE__ */ React.createElement("label", { htmlFor: "caption", className: "text-sm font-medium text-foreground cursor-pointer" }, "Show Caption")), /* @__PURE__ */ React.createElement(DialogActions, null, /* @__PURE__ */ React.createElement(Button, { "data-test-id": "image-modal-file-upload-btn", onClick: () => handleOnConfirm() }, "Confirm")));
|
|
298
|
+
}
|
|
299
|
+
function InlineImageComponent({
|
|
300
|
+
src,
|
|
301
|
+
altText,
|
|
302
|
+
nodeKey,
|
|
303
|
+
width,
|
|
304
|
+
height,
|
|
305
|
+
showCaption,
|
|
306
|
+
caption,
|
|
307
|
+
position
|
|
308
|
+
}) {
|
|
309
|
+
const [modal, showModal] = useModal();
|
|
310
|
+
const imageRef = useRef2(null);
|
|
311
|
+
const buttonRef = useRef2(null);
|
|
312
|
+
const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey);
|
|
313
|
+
const [editor] = useLexicalComposerContext();
|
|
314
|
+
const [selection, setSelection] = useState2(null);
|
|
315
|
+
const activeEditorRef = useRef2(null);
|
|
316
|
+
const isEditable = useLexicalEditable();
|
|
317
|
+
const $onEnter = useCallback2(
|
|
318
|
+
(event) => {
|
|
319
|
+
const latestSelection = $getSelection();
|
|
320
|
+
const buttonElem = buttonRef.current;
|
|
321
|
+
if (isSelected && $isNodeSelection(latestSelection) && latestSelection.getNodes().length === 1) {
|
|
322
|
+
if (showCaption) {
|
|
323
|
+
$setSelection(null);
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
caption.focus();
|
|
326
|
+
return true;
|
|
327
|
+
} else if (buttonElem !== null && buttonElem !== document.activeElement) {
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
buttonElem.focus();
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
},
|
|
335
|
+
[caption, isSelected, showCaption]
|
|
336
|
+
);
|
|
337
|
+
const $onEscape = useCallback2(
|
|
338
|
+
(event) => {
|
|
339
|
+
if (activeEditorRef.current === caption || buttonRef.current === event.target) {
|
|
340
|
+
$setSelection(null);
|
|
341
|
+
editor.update(() => {
|
|
342
|
+
setSelected(true);
|
|
343
|
+
const parentRootElement = editor.getRootElement();
|
|
344
|
+
if (parentRootElement !== null) {
|
|
345
|
+
parentRootElement.focus();
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
},
|
|
352
|
+
[caption, editor, setSelected]
|
|
353
|
+
);
|
|
354
|
+
useEffect2(() => {
|
|
355
|
+
let isMounted = true;
|
|
356
|
+
const unregister = mergeRegister(
|
|
357
|
+
editor.registerUpdateListener(({ editorState }) => {
|
|
358
|
+
if (isMounted) {
|
|
359
|
+
setSelection(editorState.read(() => $getSelection()));
|
|
360
|
+
}
|
|
361
|
+
}),
|
|
362
|
+
editor.registerCommand(
|
|
363
|
+
SELECTION_CHANGE_COMMAND,
|
|
364
|
+
(_, activeEditor) => {
|
|
365
|
+
activeEditorRef.current = activeEditor;
|
|
366
|
+
return false;
|
|
367
|
+
},
|
|
368
|
+
COMMAND_PRIORITY_LOW
|
|
369
|
+
),
|
|
370
|
+
editor.registerCommand(
|
|
371
|
+
CLICK_COMMAND,
|
|
372
|
+
(payload) => {
|
|
373
|
+
const event = payload;
|
|
374
|
+
if (event.target === imageRef.current) {
|
|
375
|
+
if (event.shiftKey) {
|
|
376
|
+
setSelected(!isSelected);
|
|
377
|
+
} else {
|
|
378
|
+
clearSelection();
|
|
379
|
+
setSelected(true);
|
|
380
|
+
}
|
|
381
|
+
return true;
|
|
382
|
+
}
|
|
383
|
+
return false;
|
|
384
|
+
},
|
|
385
|
+
COMMAND_PRIORITY_LOW
|
|
386
|
+
),
|
|
387
|
+
editor.registerCommand(
|
|
388
|
+
DRAGSTART_COMMAND,
|
|
389
|
+
(event) => {
|
|
390
|
+
if (event.target === imageRef.current) {
|
|
391
|
+
const dataTransfer = event.dataTransfer;
|
|
392
|
+
if (dataTransfer) {
|
|
393
|
+
dataTransfer.setData("text/plain", "_");
|
|
394
|
+
if (imageRef.current) {
|
|
395
|
+
dataTransfer.setDragImage(imageRef.current, 0, 0);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return false;
|
|
399
|
+
}
|
|
400
|
+
return false;
|
|
401
|
+
},
|
|
402
|
+
COMMAND_PRIORITY_LOW
|
|
403
|
+
),
|
|
404
|
+
editor.registerCommand(KEY_ENTER_COMMAND, $onEnter, COMMAND_PRIORITY_LOW),
|
|
405
|
+
editor.registerCommand(KEY_ESCAPE_COMMAND, $onEscape, COMMAND_PRIORITY_LOW)
|
|
406
|
+
);
|
|
407
|
+
return () => {
|
|
408
|
+
isMounted = false;
|
|
409
|
+
unregister();
|
|
410
|
+
};
|
|
411
|
+
}, [clearSelection, editor, isSelected, nodeKey, $onEnter, $onEscape, setSelected]);
|
|
412
|
+
const draggable = isSelected && $isNodeSelection(selection);
|
|
413
|
+
const isFocused = isSelected && isEditable;
|
|
414
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", { draggable, className: "relative inline-block" }, isEditable && /* @__PURE__ */ React.createElement(
|
|
415
|
+
"button",
|
|
416
|
+
{
|
|
417
|
+
className: "absolute top-2 right-2 z-10 px-2 py-1 text-xs bg-primary text-primary-foreground rounded hover:bg-primary/90 transition-colors",
|
|
418
|
+
ref: buttonRef,
|
|
419
|
+
onClick: () => {
|
|
420
|
+
showModal("Update Inline Image", (onClose) => /* @__PURE__ */ React.createElement(UpdateInlineImageDialog, { activeEditor: editor, nodeKey, onClose }));
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
"Edit"
|
|
424
|
+
), /* @__PURE__ */ React.createElement(
|
|
425
|
+
LazyImage,
|
|
426
|
+
{
|
|
427
|
+
className: isFocused ? `ring-2 ring-ring ring-offset-2 ${$isNodeSelection(selection) ? "cursor-move" : ""}` : null,
|
|
428
|
+
src,
|
|
429
|
+
altText,
|
|
430
|
+
imageRef,
|
|
431
|
+
width,
|
|
432
|
+
height,
|
|
433
|
+
position
|
|
434
|
+
}
|
|
435
|
+
)), showCaption && /* @__PURE__ */ React.createElement("span", { className: "block mt-2 p-2 border border-border rounded-md bg-muted/50" }, /* @__PURE__ */ React.createElement(LexicalNestedComposer, { initialEditor: caption }, /* @__PURE__ */ React.createElement(AutoFocusPlugin, null), /* @__PURE__ */ React.createElement(LinkPlugin, null), /* @__PURE__ */ React.createElement(
|
|
436
|
+
RichTextPlugin,
|
|
437
|
+
{
|
|
438
|
+
contentEditable: /* @__PURE__ */ React.createElement(
|
|
439
|
+
LexicalContentEditable,
|
|
440
|
+
{
|
|
441
|
+
placeholder: "Enter a caption...",
|
|
442
|
+
placeholderClassName: "text-xs text-muted-foreground absolute bottom-2.5 left-2.5 pointer-events-none select-none whitespace-nowrap inline-block overflow-hidden text-ellipsis",
|
|
443
|
+
className: "min-h-5 border-0 resize-none cursor-text block relative outline-none p-2.5 select-text text-sm leading-relaxed w-full whitespace-pre-wrap break-words"
|
|
444
|
+
}
|
|
445
|
+
),
|
|
446
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
447
|
+
}
|
|
448
|
+
)))), modal);
|
|
449
|
+
}
|
|
450
|
+
export {
|
|
451
|
+
UpdateInlineImageDialog,
|
|
452
|
+
InlineImageComponent as default
|
|
453
|
+
};
|