@collabchron/notiq 0.3.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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-YKYA4NB4.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 +67 -11
- 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,733 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$createDynamicBlockNode,
|
|
3
|
+
DynamicBlockNode
|
|
4
|
+
} from "./chunk-5BAKY5KN.mjs";
|
|
5
|
+
import {
|
|
6
|
+
DialogActions,
|
|
7
|
+
Select,
|
|
8
|
+
TextInput
|
|
9
|
+
} from "./chunk-YPHOEJ46.mjs";
|
|
10
|
+
import {
|
|
11
|
+
$createEquationNode,
|
|
12
|
+
EquationNode,
|
|
13
|
+
KatexRenderer
|
|
14
|
+
} from "./chunk-3JVFG7ER.mjs";
|
|
15
|
+
import {
|
|
16
|
+
$createStoryBuilderNode,
|
|
17
|
+
StoryBuilderNode
|
|
18
|
+
} from "./chunk-4MEDW3T6.mjs";
|
|
19
|
+
import {
|
|
20
|
+
Button
|
|
21
|
+
} from "./chunk-BIU7WTLX.mjs";
|
|
22
|
+
import {
|
|
23
|
+
React,
|
|
24
|
+
__spreadProps,
|
|
25
|
+
__spreadValues,
|
|
26
|
+
init_react_shim
|
|
27
|
+
} from "./chunk-77KXU36M.mjs";
|
|
28
|
+
|
|
29
|
+
// src/components/editor/plugins/StoryBuilderPlugin/index.tsx
|
|
30
|
+
init_react_shim();
|
|
31
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
32
|
+
import { $wrapNodeInElement } from "@lexical/utils";
|
|
33
|
+
import {
|
|
34
|
+
$createParagraphNode,
|
|
35
|
+
$insertNodes,
|
|
36
|
+
$isRootOrShadowRoot,
|
|
37
|
+
COMMAND_PRIORITY_EDITOR,
|
|
38
|
+
createCommand
|
|
39
|
+
} from "lexical";
|
|
40
|
+
import { useEffect } from "react";
|
|
41
|
+
var INSERT_STORY_BUILDER_COMMAND = createCommand("INSERT_STORY_BUILDER_COMMAND");
|
|
42
|
+
function StoryBuilderPlugin() {
|
|
43
|
+
const [editor] = useLexicalComposerContext();
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!editor.hasNodes([StoryBuilderNode])) {
|
|
46
|
+
throw new Error("StoryBuilderPlugin: StoryBuilderNode not registered on editor");
|
|
47
|
+
}
|
|
48
|
+
return editor.registerCommand(
|
|
49
|
+
INSERT_STORY_BUILDER_COMMAND,
|
|
50
|
+
(payload) => {
|
|
51
|
+
const storyBuilderNode = $createStoryBuilderNode(payload);
|
|
52
|
+
$insertNodes([storyBuilderNode]);
|
|
53
|
+
if ($isRootOrShadowRoot(storyBuilderNode.getParentOrThrow())) {
|
|
54
|
+
$wrapNodeInElement(storyBuilderNode, $createParagraphNode).selectEnd();
|
|
55
|
+
}
|
|
56
|
+
return true;
|
|
57
|
+
},
|
|
58
|
+
COMMAND_PRIORITY_EDITOR
|
|
59
|
+
);
|
|
60
|
+
}, [editor]);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// src/components/editor/plugins/InlineImagePlugin/index.tsx
|
|
65
|
+
init_react_shim();
|
|
66
|
+
import { useLexicalComposerContext as useLexicalComposerContext2 } from "@lexical/react/LexicalComposerContext";
|
|
67
|
+
import { $wrapNodeInElement as $wrapNodeInElement2, mergeRegister } from "@lexical/utils";
|
|
68
|
+
import {
|
|
69
|
+
$createParagraphNode as $createParagraphNode2,
|
|
70
|
+
$createRangeSelection,
|
|
71
|
+
$getSelection,
|
|
72
|
+
$insertNodes as $insertNodes2,
|
|
73
|
+
$isNodeSelection,
|
|
74
|
+
$isRootOrShadowRoot as $isRootOrShadowRoot2,
|
|
75
|
+
$setSelection,
|
|
76
|
+
COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR2,
|
|
77
|
+
COMMAND_PRIORITY_HIGH,
|
|
78
|
+
COMMAND_PRIORITY_LOW,
|
|
79
|
+
createCommand as createCommand2,
|
|
80
|
+
DRAGOVER_COMMAND,
|
|
81
|
+
DRAGSTART_COMMAND,
|
|
82
|
+
DROP_COMMAND,
|
|
83
|
+
getDOMSelectionFromTarget,
|
|
84
|
+
isHTMLElement as isHTMLElement2
|
|
85
|
+
} from "lexical";
|
|
86
|
+
import { useEffect as useEffect2, useRef, useState } from "react";
|
|
87
|
+
|
|
88
|
+
// src/components/editor/nodes/InlineImageNode/InlineImageNode.tsx
|
|
89
|
+
init_react_shim();
|
|
90
|
+
import {
|
|
91
|
+
addClassNamesToElement,
|
|
92
|
+
removeClassNamesFromElement
|
|
93
|
+
} from "@lexical/utils";
|
|
94
|
+
import {
|
|
95
|
+
$applyNodeReplacement,
|
|
96
|
+
createEditor,
|
|
97
|
+
DecoratorNode,
|
|
98
|
+
isHTMLElement
|
|
99
|
+
} from "lexical";
|
|
100
|
+
import * as React2 from "react";
|
|
101
|
+
var InlineImageComponent = React2.lazy(() => import("./InlineImageComponent-UWIUWBHI.mjs"));
|
|
102
|
+
function $convertInlineImageElement(domNode) {
|
|
103
|
+
if (isHTMLElement(domNode) && domNode.nodeName === "IMG") {
|
|
104
|
+
const { alt: altText, src, width, height } = domNode;
|
|
105
|
+
const node = $createInlineImageNode({ altText, height, src, width });
|
|
106
|
+
return { node };
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function getPositionClass(position) {
|
|
111
|
+
return typeof position === "string" ? `position-${position}` : void 0;
|
|
112
|
+
}
|
|
113
|
+
var InlineImageNode = class _InlineImageNode extends DecoratorNode {
|
|
114
|
+
static getType() {
|
|
115
|
+
return "inline-image";
|
|
116
|
+
}
|
|
117
|
+
static clone(node) {
|
|
118
|
+
return new _InlineImageNode(
|
|
119
|
+
node.__src,
|
|
120
|
+
node.__altText,
|
|
121
|
+
node.__position,
|
|
122
|
+
node.__width,
|
|
123
|
+
node.__height,
|
|
124
|
+
node.__showCaption,
|
|
125
|
+
node.__caption,
|
|
126
|
+
node.__key
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
static importJSON(serializedNode) {
|
|
130
|
+
const { altText, height, width, src, showCaption, position } = serializedNode;
|
|
131
|
+
return $createInlineImageNode({
|
|
132
|
+
altText,
|
|
133
|
+
height,
|
|
134
|
+
position,
|
|
135
|
+
showCaption,
|
|
136
|
+
src,
|
|
137
|
+
width
|
|
138
|
+
}).updateFromJSON(serializedNode);
|
|
139
|
+
}
|
|
140
|
+
updateFromJSON(serializedNode) {
|
|
141
|
+
const { caption } = serializedNode;
|
|
142
|
+
const node = super.updateFromJSON(serializedNode);
|
|
143
|
+
const nestedEditor = node.__caption;
|
|
144
|
+
const editorState = nestedEditor.parseEditorState(caption.editorState);
|
|
145
|
+
if (!editorState.isEmpty()) {
|
|
146
|
+
nestedEditor.setEditorState(editorState);
|
|
147
|
+
}
|
|
148
|
+
return node;
|
|
149
|
+
}
|
|
150
|
+
static importDOM() {
|
|
151
|
+
return {
|
|
152
|
+
img: (node) => ({
|
|
153
|
+
conversion: $convertInlineImageElement,
|
|
154
|
+
priority: 0
|
|
155
|
+
})
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
constructor(src, altText, position, width, height, showCaption, caption, key) {
|
|
159
|
+
super(key);
|
|
160
|
+
this.__src = src;
|
|
161
|
+
this.__altText = altText;
|
|
162
|
+
this.__width = width || "inherit";
|
|
163
|
+
this.__height = height || "inherit";
|
|
164
|
+
this.__showCaption = showCaption || false;
|
|
165
|
+
this.__caption = caption || createEditor();
|
|
166
|
+
this.__position = position;
|
|
167
|
+
}
|
|
168
|
+
exportDOM() {
|
|
169
|
+
const element = document.createElement("img");
|
|
170
|
+
element.setAttribute("src", this.__src);
|
|
171
|
+
element.setAttribute("alt", this.__altText);
|
|
172
|
+
element.setAttribute("width", this.__width.toString());
|
|
173
|
+
element.setAttribute("height", this.__height.toString());
|
|
174
|
+
return { element };
|
|
175
|
+
}
|
|
176
|
+
exportJSON() {
|
|
177
|
+
return __spreadProps(__spreadValues({}, super.exportJSON()), {
|
|
178
|
+
altText: this.getAltText(),
|
|
179
|
+
caption: this.__caption.toJSON(),
|
|
180
|
+
height: this.__height === "inherit" ? 0 : this.__height,
|
|
181
|
+
position: this.__position,
|
|
182
|
+
showCaption: this.__showCaption,
|
|
183
|
+
src: this.getSrc(),
|
|
184
|
+
width: this.__width === "inherit" ? 0 : this.__width
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
getSrc() {
|
|
188
|
+
return this.__src;
|
|
189
|
+
}
|
|
190
|
+
getAltText() {
|
|
191
|
+
return this.__altText;
|
|
192
|
+
}
|
|
193
|
+
setAltText(altText) {
|
|
194
|
+
const writable = this.getWritable();
|
|
195
|
+
writable.__altText = altText;
|
|
196
|
+
}
|
|
197
|
+
setWidthAndHeight(width, height) {
|
|
198
|
+
const writable = this.getWritable();
|
|
199
|
+
writable.__width = width;
|
|
200
|
+
writable.__height = height;
|
|
201
|
+
}
|
|
202
|
+
getShowCaption() {
|
|
203
|
+
return this.__showCaption;
|
|
204
|
+
}
|
|
205
|
+
setShowCaption(showCaption) {
|
|
206
|
+
const writable = this.getWritable();
|
|
207
|
+
writable.__showCaption = showCaption;
|
|
208
|
+
}
|
|
209
|
+
getPosition() {
|
|
210
|
+
return this.__position;
|
|
211
|
+
}
|
|
212
|
+
setPosition(position) {
|
|
213
|
+
const writable = this.getWritable();
|
|
214
|
+
writable.__position = position;
|
|
215
|
+
}
|
|
216
|
+
update(payload) {
|
|
217
|
+
const writable = this.getWritable();
|
|
218
|
+
const { altText, showCaption, position } = payload;
|
|
219
|
+
if (altText !== void 0) {
|
|
220
|
+
writable.__altText = altText;
|
|
221
|
+
}
|
|
222
|
+
if (showCaption !== void 0) {
|
|
223
|
+
writable.__showCaption = showCaption;
|
|
224
|
+
}
|
|
225
|
+
if (position !== void 0) {
|
|
226
|
+
writable.__position = position;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
// View
|
|
230
|
+
createDOM(config) {
|
|
231
|
+
const span = document.createElement("span");
|
|
232
|
+
for (const cls of [
|
|
233
|
+
config.theme.inlineImage,
|
|
234
|
+
getPositionClass(this.__position)
|
|
235
|
+
]) {
|
|
236
|
+
if (cls) {
|
|
237
|
+
addClassNamesToElement(span, cls);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return span;
|
|
241
|
+
}
|
|
242
|
+
updateDOM(prevNode, dom, config) {
|
|
243
|
+
const position = this.__position;
|
|
244
|
+
if (position !== prevNode.__position) {
|
|
245
|
+
removeClassNamesFromElement(dom, getPositionClass(prevNode.__position));
|
|
246
|
+
addClassNamesToElement(dom, getPositionClass(position));
|
|
247
|
+
}
|
|
248
|
+
return false;
|
|
249
|
+
}
|
|
250
|
+
decorate() {
|
|
251
|
+
return /* @__PURE__ */ React2.createElement(
|
|
252
|
+
InlineImageComponent,
|
|
253
|
+
{
|
|
254
|
+
src: this.__src,
|
|
255
|
+
altText: this.__altText,
|
|
256
|
+
width: this.__width,
|
|
257
|
+
height: this.__height,
|
|
258
|
+
nodeKey: this.getKey(),
|
|
259
|
+
showCaption: this.__showCaption,
|
|
260
|
+
caption: this.__caption,
|
|
261
|
+
position: this.__position
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
function $createInlineImageNode({
|
|
267
|
+
altText,
|
|
268
|
+
position,
|
|
269
|
+
height,
|
|
270
|
+
src,
|
|
271
|
+
width,
|
|
272
|
+
showCaption,
|
|
273
|
+
caption,
|
|
274
|
+
key
|
|
275
|
+
}) {
|
|
276
|
+
return $applyNodeReplacement(
|
|
277
|
+
new InlineImageNode(
|
|
278
|
+
src,
|
|
279
|
+
altText,
|
|
280
|
+
position,
|
|
281
|
+
width,
|
|
282
|
+
height,
|
|
283
|
+
showCaption,
|
|
284
|
+
caption,
|
|
285
|
+
key
|
|
286
|
+
)
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
function $isInlineImageNode(node) {
|
|
290
|
+
return node instanceof InlineImageNode;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// src/components/ui/FileInput.tsx
|
|
294
|
+
init_react_shim();
|
|
295
|
+
import * as React3 from "react";
|
|
296
|
+
function FileInput({
|
|
297
|
+
accept,
|
|
298
|
+
label,
|
|
299
|
+
onChange,
|
|
300
|
+
"data-test-id": dataTestId
|
|
301
|
+
}) {
|
|
302
|
+
return /* @__PURE__ */ React3.createElement("div", { className: "Input__wrapper" }, /* @__PURE__ */ React3.createElement("label", { className: "Input__label" }, label), /* @__PURE__ */ React3.createElement(
|
|
303
|
+
"input",
|
|
304
|
+
{
|
|
305
|
+
type: "file",
|
|
306
|
+
accept,
|
|
307
|
+
className: "Input__input",
|
|
308
|
+
onChange: (e) => onChange(e.target.files),
|
|
309
|
+
"data-test-id": dataTestId
|
|
310
|
+
}
|
|
311
|
+
));
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// src/components/editor/plugins/InlineImagePlugin/index.tsx
|
|
315
|
+
var INSERT_INLINE_IMAGE_COMMAND = createCommand2("INSERT_INLINE_IMAGE_COMMAND");
|
|
316
|
+
function InsertInlineImageDialog({
|
|
317
|
+
activeEditor,
|
|
318
|
+
onClose
|
|
319
|
+
}) {
|
|
320
|
+
const hasModifier = useRef(false);
|
|
321
|
+
const [src, setSrc] = useState("");
|
|
322
|
+
const [altText, setAltText] = useState("");
|
|
323
|
+
const [showCaption, setShowCaption] = useState(false);
|
|
324
|
+
const [position, setPosition] = useState("left");
|
|
325
|
+
const isDisabled = src === "";
|
|
326
|
+
const handleShowCaptionChange = (e) => {
|
|
327
|
+
setShowCaption(e.target.checked);
|
|
328
|
+
};
|
|
329
|
+
const handlePositionChange = (e) => {
|
|
330
|
+
setPosition(e.target.value);
|
|
331
|
+
};
|
|
332
|
+
const loadImage = (files) => {
|
|
333
|
+
const reader = new FileReader();
|
|
334
|
+
reader.onload = () => {
|
|
335
|
+
if (typeof reader.result === "string") {
|
|
336
|
+
setSrc(reader.result);
|
|
337
|
+
}
|
|
338
|
+
return "";
|
|
339
|
+
};
|
|
340
|
+
reader.onerror = () => {
|
|
341
|
+
console.error("Error reading file");
|
|
342
|
+
setSrc("");
|
|
343
|
+
};
|
|
344
|
+
if (files !== null && files.length > 0) {
|
|
345
|
+
reader.readAsDataURL(files[0]);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
useEffect2(() => {
|
|
349
|
+
hasModifier.current = false;
|
|
350
|
+
const handler = (e) => {
|
|
351
|
+
hasModifier.current = e.altKey;
|
|
352
|
+
};
|
|
353
|
+
document.addEventListener("keydown", handler);
|
|
354
|
+
return () => {
|
|
355
|
+
document.removeEventListener("keydown", handler);
|
|
356
|
+
};
|
|
357
|
+
}, [activeEditor]);
|
|
358
|
+
const handleOnClick = () => {
|
|
359
|
+
const payload = { altText, position, showCaption, src };
|
|
360
|
+
activeEditor.dispatchCommand(INSERT_INLINE_IMAGE_COMMAND, payload);
|
|
361
|
+
onClose();
|
|
362
|
+
};
|
|
363
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "mb-4" }, /* @__PURE__ */ React.createElement(FileInput, { label: "Image Upload", onChange: loadImage, accept: "image/*", "data-test-id": "image-modal-file-upload" })), /* @__PURE__ */ React.createElement("div", { className: "mb-4" }, /* @__PURE__ */ React.createElement(
|
|
364
|
+
TextInput,
|
|
365
|
+
{
|
|
366
|
+
label: "Alt Text",
|
|
367
|
+
placeholder: "Descriptive alternative text",
|
|
368
|
+
onChange: setAltText,
|
|
369
|
+
value: altText,
|
|
370
|
+
"data-test-id": "image-modal-alt-text-input"
|
|
371
|
+
}
|
|
372
|
+
)), /* @__PURE__ */ React.createElement(
|
|
373
|
+
Select,
|
|
374
|
+
{
|
|
375
|
+
className: "mb-4 w-72",
|
|
376
|
+
label: "Position",
|
|
377
|
+
name: "position",
|
|
378
|
+
id: "position-select",
|
|
379
|
+
onChange: handlePositionChange
|
|
380
|
+
},
|
|
381
|
+
/* @__PURE__ */ React.createElement("option", { value: "left" }, "Left"),
|
|
382
|
+
/* @__PURE__ */ React.createElement("option", { value: "right" }, "Right"),
|
|
383
|
+
/* @__PURE__ */ React.createElement("option", { value: "full" }, "Full Width")
|
|
384
|
+
), /* @__PURE__ */ React.createElement("div", { className: "flex items-center space-x-2 mb-4" }, /* @__PURE__ */ React.createElement(
|
|
385
|
+
"input",
|
|
386
|
+
{
|
|
387
|
+
id: "caption",
|
|
388
|
+
type: "checkbox",
|
|
389
|
+
checked: showCaption,
|
|
390
|
+
onChange: handleShowCaptionChange,
|
|
391
|
+
className: "w-4 h-4 text-primary bg-background border-border rounded focus:ring-ring focus:ring-2"
|
|
392
|
+
}
|
|
393
|
+
), /* @__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", disabled: isDisabled, onClick: () => handleOnClick() }, "Confirm")));
|
|
394
|
+
}
|
|
395
|
+
function InlineImagePlugin() {
|
|
396
|
+
const [editor] = useLexicalComposerContext2();
|
|
397
|
+
useEffect2(() => {
|
|
398
|
+
if (!editor.hasNodes([InlineImageNode])) {
|
|
399
|
+
throw new Error("ImagesPlugin: ImageNode not registered on editor");
|
|
400
|
+
}
|
|
401
|
+
return mergeRegister(
|
|
402
|
+
editor.registerCommand(
|
|
403
|
+
INSERT_INLINE_IMAGE_COMMAND,
|
|
404
|
+
(payload) => {
|
|
405
|
+
const imageNode = $createInlineImageNode(payload);
|
|
406
|
+
$insertNodes2([imageNode]);
|
|
407
|
+
if ($isRootOrShadowRoot2(imageNode.getParentOrThrow())) {
|
|
408
|
+
$wrapNodeInElement2(imageNode, $createParagraphNode2).selectEnd();
|
|
409
|
+
}
|
|
410
|
+
return true;
|
|
411
|
+
},
|
|
412
|
+
COMMAND_PRIORITY_EDITOR2
|
|
413
|
+
),
|
|
414
|
+
editor.registerCommand(
|
|
415
|
+
DRAGSTART_COMMAND,
|
|
416
|
+
(event) => {
|
|
417
|
+
return $onDragStart(event);
|
|
418
|
+
},
|
|
419
|
+
COMMAND_PRIORITY_HIGH
|
|
420
|
+
),
|
|
421
|
+
editor.registerCommand(
|
|
422
|
+
DRAGOVER_COMMAND,
|
|
423
|
+
(event) => {
|
|
424
|
+
return $onDragover(event);
|
|
425
|
+
},
|
|
426
|
+
COMMAND_PRIORITY_LOW
|
|
427
|
+
),
|
|
428
|
+
editor.registerCommand(
|
|
429
|
+
DROP_COMMAND,
|
|
430
|
+
(event) => {
|
|
431
|
+
return $onDrop(event, editor);
|
|
432
|
+
},
|
|
433
|
+
COMMAND_PRIORITY_HIGH
|
|
434
|
+
)
|
|
435
|
+
);
|
|
436
|
+
}, [editor]);
|
|
437
|
+
return null;
|
|
438
|
+
}
|
|
439
|
+
var TRANSPARENT_IMAGE = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
|
440
|
+
var img = null;
|
|
441
|
+
if (typeof document !== "undefined") {
|
|
442
|
+
img = document.createElement("img");
|
|
443
|
+
img.src = TRANSPARENT_IMAGE;
|
|
444
|
+
}
|
|
445
|
+
function $onDragStart(event) {
|
|
446
|
+
const node = $getImageNodeInSelection();
|
|
447
|
+
if (!node) {
|
|
448
|
+
return false;
|
|
449
|
+
}
|
|
450
|
+
const dataTransfer = event.dataTransfer;
|
|
451
|
+
if (!dataTransfer) {
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
454
|
+
dataTransfer.setData("text/plain", "_");
|
|
455
|
+
if (img) {
|
|
456
|
+
dataTransfer.setDragImage(img, 0, 0);
|
|
457
|
+
}
|
|
458
|
+
dataTransfer.setData(
|
|
459
|
+
"application/x-lexical-drag",
|
|
460
|
+
JSON.stringify({
|
|
461
|
+
data: {
|
|
462
|
+
altText: node.__altText,
|
|
463
|
+
caption: node.__caption,
|
|
464
|
+
height: node.__height,
|
|
465
|
+
key: node.getKey(),
|
|
466
|
+
showCaption: node.__showCaption,
|
|
467
|
+
src: node.__src,
|
|
468
|
+
width: node.__width
|
|
469
|
+
},
|
|
470
|
+
type: "image"
|
|
471
|
+
})
|
|
472
|
+
);
|
|
473
|
+
return true;
|
|
474
|
+
}
|
|
475
|
+
function $onDragover(event) {
|
|
476
|
+
const node = $getImageNodeInSelection();
|
|
477
|
+
if (!node) {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
if (!canDropImage(event)) {
|
|
481
|
+
event.preventDefault();
|
|
482
|
+
}
|
|
483
|
+
return true;
|
|
484
|
+
}
|
|
485
|
+
function $onDrop(event, editor) {
|
|
486
|
+
const node = $getImageNodeInSelection();
|
|
487
|
+
if (!node) {
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
const data = getDragImageData(event);
|
|
491
|
+
if (!data) {
|
|
492
|
+
return false;
|
|
493
|
+
}
|
|
494
|
+
event.preventDefault();
|
|
495
|
+
if (canDropImage(event)) {
|
|
496
|
+
const range = getDragSelection(event);
|
|
497
|
+
node.remove();
|
|
498
|
+
const rangeSelection = $createRangeSelection();
|
|
499
|
+
if (range !== null && range !== void 0) {
|
|
500
|
+
rangeSelection.applyDOMRange(range);
|
|
501
|
+
}
|
|
502
|
+
$setSelection(rangeSelection);
|
|
503
|
+
editor.dispatchCommand(INSERT_INLINE_IMAGE_COMMAND, data);
|
|
504
|
+
}
|
|
505
|
+
return true;
|
|
506
|
+
}
|
|
507
|
+
function $getImageNodeInSelection() {
|
|
508
|
+
const selection = $getSelection();
|
|
509
|
+
if (!$isNodeSelection(selection)) {
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
const nodes = selection.getNodes();
|
|
513
|
+
const node = nodes[0];
|
|
514
|
+
return $isInlineImageNode(node) ? node : null;
|
|
515
|
+
}
|
|
516
|
+
function getDragImageData(event) {
|
|
517
|
+
var _a;
|
|
518
|
+
const dragData = (_a = event.dataTransfer) == null ? void 0 : _a.getData("application/x-lexical-drag");
|
|
519
|
+
if (!dragData) {
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
const { type, data } = JSON.parse(dragData);
|
|
523
|
+
if (type !== "image") {
|
|
524
|
+
return null;
|
|
525
|
+
}
|
|
526
|
+
return data;
|
|
527
|
+
}
|
|
528
|
+
function canDropImage(event) {
|
|
529
|
+
const target = event.target;
|
|
530
|
+
return !!(isHTMLElement2(target) && !target.closest("code, span.editor-image") && isHTMLElement2(target.parentElement) && target.parentElement.closest("div.ContentEditable__root"));
|
|
531
|
+
}
|
|
532
|
+
function getDragSelection(event) {
|
|
533
|
+
let range;
|
|
534
|
+
const domSelection = getDOMSelectionFromTarget(event.target);
|
|
535
|
+
if (document.caretRangeFromPoint) {
|
|
536
|
+
range = document.caretRangeFromPoint(event.clientX, event.clientY);
|
|
537
|
+
} else if (event.rangeParent && domSelection !== null) {
|
|
538
|
+
domSelection.collapse(event.rangeParent, event.rangeOffset || 0);
|
|
539
|
+
range = domSelection.getRangeAt(0);
|
|
540
|
+
} else {
|
|
541
|
+
throw Error("Cannot get the selection when dragging");
|
|
542
|
+
}
|
|
543
|
+
return range;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/components/editor/plugins/EquationsPlugin/index.tsx
|
|
547
|
+
init_react_shim();
|
|
548
|
+
import "katex/dist/katex.css";
|
|
549
|
+
import { useLexicalComposerContext as useLexicalComposerContext4 } from "@lexical/react/LexicalComposerContext";
|
|
550
|
+
import { $wrapNodeInElement as $wrapNodeInElement3 } from "@lexical/utils";
|
|
551
|
+
import {
|
|
552
|
+
$createParagraphNode as $createParagraphNode3,
|
|
553
|
+
$insertNodes as $insertNodes3,
|
|
554
|
+
$isRootOrShadowRoot as $isRootOrShadowRoot3,
|
|
555
|
+
COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR3,
|
|
556
|
+
createCommand as createCommand3
|
|
557
|
+
} from "lexical";
|
|
558
|
+
import { useCallback as useCallback2, useEffect as useEffect3 } from "react";
|
|
559
|
+
import * as React5 from "react";
|
|
560
|
+
|
|
561
|
+
// src/components/ui/equation/KatexEquationAlterer.tsx
|
|
562
|
+
init_react_shim();
|
|
563
|
+
import { useLexicalComposerContext as useLexicalComposerContext3 } from "@lexical/react/LexicalComposerContext";
|
|
564
|
+
import * as React4 from "react";
|
|
565
|
+
import { useCallback, useState as useState2 } from "react";
|
|
566
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
567
|
+
function KatexEquationAlterer({
|
|
568
|
+
onConfirm,
|
|
569
|
+
initialEquation = ""
|
|
570
|
+
}) {
|
|
571
|
+
const [editor] = useLexicalComposerContext3();
|
|
572
|
+
const [equation, setEquation] = useState2(initialEquation);
|
|
573
|
+
const [inline, setInline] = useState2(true);
|
|
574
|
+
const onClick = useCallback(() => {
|
|
575
|
+
onConfirm(equation, inline);
|
|
576
|
+
}, [onConfirm, equation, inline]);
|
|
577
|
+
const onCheckboxChange = useCallback(() => {
|
|
578
|
+
setInline(!inline);
|
|
579
|
+
}, [setInline, inline]);
|
|
580
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", { className: "KatexEquationAlterer_defaultRow" }, "Inline", /* @__PURE__ */ React4.createElement("input", { type: "checkbox", checked: inline, onChange: onCheckboxChange })), /* @__PURE__ */ React4.createElement("div", { className: "KatexEquationAlterer_defaultRow" }, "Equation "), /* @__PURE__ */ React4.createElement("div", { className: "KatexEquationAlterer_centerRow" }, inline ? /* @__PURE__ */ React4.createElement(
|
|
581
|
+
"input",
|
|
582
|
+
{
|
|
583
|
+
onChange: (event) => {
|
|
584
|
+
setEquation(event.target.value);
|
|
585
|
+
},
|
|
586
|
+
value: equation,
|
|
587
|
+
className: "KatexEquationAlterer_textArea"
|
|
588
|
+
}
|
|
589
|
+
) : /* @__PURE__ */ React4.createElement(
|
|
590
|
+
"textarea",
|
|
591
|
+
{
|
|
592
|
+
onChange: (event) => {
|
|
593
|
+
setEquation(event.target.value);
|
|
594
|
+
},
|
|
595
|
+
value: equation,
|
|
596
|
+
className: "KatexEquationAlterer_textArea"
|
|
597
|
+
}
|
|
598
|
+
)), /* @__PURE__ */ React4.createElement("div", { className: "KatexEquationAlterer_defaultRow" }, "Visualization "), /* @__PURE__ */ React4.createElement("div", { className: "KatexEquationAlterer_centerRow" }, /* @__PURE__ */ React4.createElement(ErrorBoundary, { onError: (e) => editor._onError(e), fallback: null }, /* @__PURE__ */ React4.createElement(
|
|
599
|
+
KatexRenderer,
|
|
600
|
+
{
|
|
601
|
+
equation,
|
|
602
|
+
inline: false,
|
|
603
|
+
onDoubleClick: () => null
|
|
604
|
+
}
|
|
605
|
+
))), /* @__PURE__ */ React4.createElement("div", { className: "KatexEquationAlterer_dialogActions" }, /* @__PURE__ */ React4.createElement(Button, { onClick }, "Confirm")));
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
// src/components/editor/plugins/EquationsPlugin/index.tsx
|
|
609
|
+
var INSERT_EQUATION_COMMAND = createCommand3("INSERT_EQUATION_COMMAND");
|
|
610
|
+
function InsertEquationDialog({
|
|
611
|
+
activeEditor,
|
|
612
|
+
onClose
|
|
613
|
+
}) {
|
|
614
|
+
const onEquationConfirm = useCallback2(
|
|
615
|
+
(equation, inline) => {
|
|
616
|
+
activeEditor.dispatchCommand(INSERT_EQUATION_COMMAND, { equation, inline });
|
|
617
|
+
onClose();
|
|
618
|
+
},
|
|
619
|
+
[activeEditor, onClose]
|
|
620
|
+
);
|
|
621
|
+
return /* @__PURE__ */ React5.createElement(KatexEquationAlterer, { onConfirm: onEquationConfirm });
|
|
622
|
+
}
|
|
623
|
+
function EquationsPlugin() {
|
|
624
|
+
const [editor] = useLexicalComposerContext4();
|
|
625
|
+
useEffect3(() => {
|
|
626
|
+
if (!editor.hasNodes([EquationNode])) {
|
|
627
|
+
throw new Error(
|
|
628
|
+
"EquationsPlugins: EquationsNode not registered on editor"
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
return editor.registerCommand(
|
|
632
|
+
INSERT_EQUATION_COMMAND,
|
|
633
|
+
(payload) => {
|
|
634
|
+
const { equation, inline } = payload;
|
|
635
|
+
const equationNode = $createEquationNode(equation, inline);
|
|
636
|
+
$insertNodes3([equationNode]);
|
|
637
|
+
if ($isRootOrShadowRoot3(equationNode.getParentOrThrow())) {
|
|
638
|
+
$wrapNodeInElement3(equationNode, $createParagraphNode3).selectEnd();
|
|
639
|
+
}
|
|
640
|
+
return true;
|
|
641
|
+
},
|
|
642
|
+
COMMAND_PRIORITY_EDITOR3
|
|
643
|
+
);
|
|
644
|
+
}, [editor]);
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
// src/components/editor/plugins/DynamicBlockPluggin/index.tsx
|
|
649
|
+
init_react_shim();
|
|
650
|
+
import { useLexicalComposerContext as useLexicalComposerContext5 } from "@lexical/react/LexicalComposerContext";
|
|
651
|
+
import { $insertNodeToNearestRoot } from "@lexical/utils";
|
|
652
|
+
import { COMMAND_PRIORITY_EDITOR as COMMAND_PRIORITY_EDITOR4, createCommand as createCommand4 } from "lexical";
|
|
653
|
+
import { useEffect as useEffect4 } from "react";
|
|
654
|
+
var INSERT_DYNAMIC_BLOCK_COMMAND = createCommand4("INSERT_DYNAMIC_BLOCK_COMMAND");
|
|
655
|
+
function DynamicBlockPlugin() {
|
|
656
|
+
const [editor] = useLexicalComposerContext5();
|
|
657
|
+
useEffect4(() => {
|
|
658
|
+
if (!editor.hasNodes([DynamicBlockNode])) {
|
|
659
|
+
throw new Error("DynamicBlockPlugin: DynamicBlockNode not registered on editor");
|
|
660
|
+
}
|
|
661
|
+
return editor.registerCommand(
|
|
662
|
+
INSERT_DYNAMIC_BLOCK_COMMAND,
|
|
663
|
+
(payload) => {
|
|
664
|
+
const dynamicBlockNode = $createDynamicBlockNode(payload);
|
|
665
|
+
$insertNodeToNearestRoot(dynamicBlockNode);
|
|
666
|
+
return true;
|
|
667
|
+
},
|
|
668
|
+
COMMAND_PRIORITY_EDITOR4
|
|
669
|
+
);
|
|
670
|
+
}, [editor]);
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
var createDefaultDynamicBlock = () => ({
|
|
674
|
+
id: `dynamic-block-${Date.now()}`,
|
|
675
|
+
title: "Interactive Content Block",
|
|
676
|
+
currentBlockId: "block-1",
|
|
677
|
+
blocks: [
|
|
678
|
+
{
|
|
679
|
+
id: "block-1",
|
|
680
|
+
type: "text",
|
|
681
|
+
content: "<h3>Welcome!</h3><p>This is your first dynamic content block. Click to see the magic happen!</p>",
|
|
682
|
+
animation: "fade"
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
id: "block-2",
|
|
686
|
+
type: "text",
|
|
687
|
+
content: "<h3>Amazing!</h3><p>You triggered the interaction! This content appeared because you clicked. Try hovering for more surprises.</p>",
|
|
688
|
+
animation: "slide"
|
|
689
|
+
},
|
|
690
|
+
{
|
|
691
|
+
id: "block-3",
|
|
692
|
+
type: "text",
|
|
693
|
+
content: "<h3>Incredible!</h3><p>Hover interactions work too! You can create time-based triggers, scroll triggers, and much more.</p>",
|
|
694
|
+
animation: "bounce"
|
|
695
|
+
}
|
|
696
|
+
],
|
|
697
|
+
triggers: [
|
|
698
|
+
{
|
|
699
|
+
id: "trigger-1",
|
|
700
|
+
type: "click",
|
|
701
|
+
condition: "",
|
|
702
|
+
targetBlockId: "block-2",
|
|
703
|
+
action: "replace"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
id: "trigger-2",
|
|
707
|
+
type: "hover",
|
|
708
|
+
condition: "",
|
|
709
|
+
targetBlockId: "block-3",
|
|
710
|
+
action: "replace"
|
|
711
|
+
},
|
|
712
|
+
{
|
|
713
|
+
id: "trigger-3",
|
|
714
|
+
type: "time",
|
|
715
|
+
condition: 3,
|
|
716
|
+
targetBlockId: "block-2",
|
|
717
|
+
action: "replace"
|
|
718
|
+
}
|
|
719
|
+
]
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
export {
|
|
723
|
+
InlineImageNode,
|
|
724
|
+
INSERT_STORY_BUILDER_COMMAND,
|
|
725
|
+
StoryBuilderPlugin,
|
|
726
|
+
InsertInlineImageDialog,
|
|
727
|
+
InlineImagePlugin,
|
|
728
|
+
InsertEquationDialog,
|
|
729
|
+
EquationsPlugin,
|
|
730
|
+
INSERT_DYNAMIC_BLOCK_COMMAND,
|
|
731
|
+
DynamicBlockPlugin,
|
|
732
|
+
createDefaultDynamicBlock
|
|
733
|
+
};
|