@collabchron/notiq 0.3.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 +66 -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,236 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__spreadProps,
|
|
3
|
+
__spreadValues,
|
|
4
|
+
init_react_shim
|
|
5
|
+
} from "./chunk-77KXU36M.mjs";
|
|
6
|
+
|
|
7
|
+
// src/components/editor/nodes/ImageNode/index.tsx
|
|
8
|
+
init_react_shim();
|
|
9
|
+
import { $applyNodeReplacement, createEditor, DecoratorNode } from "lexical";
|
|
10
|
+
import * as React from "react";
|
|
11
|
+
import { Suspense } from "react";
|
|
12
|
+
var ImageComponent = React.lazy(() => import("./image-2PJIAYAT.mjs"));
|
|
13
|
+
function isGoogleDocCheckboxImg(img) {
|
|
14
|
+
return img.parentElement != null && img.parentElement.tagName === "LI" && img.previousSibling === null && img.getAttribute("aria-roledescription") === "checkbox";
|
|
15
|
+
}
|
|
16
|
+
function $convertImageElement(domNode) {
|
|
17
|
+
const img = domNode;
|
|
18
|
+
if (img.src.startsWith("file:///") || isGoogleDocCheckboxImg(img)) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const { alt: altText, src, width, height } = img;
|
|
22
|
+
const node = $createImageNode({
|
|
23
|
+
altText,
|
|
24
|
+
height,
|
|
25
|
+
src,
|
|
26
|
+
width,
|
|
27
|
+
alignment: "center",
|
|
28
|
+
rounded: 0
|
|
29
|
+
});
|
|
30
|
+
return { node };
|
|
31
|
+
}
|
|
32
|
+
var ImageNode = class _ImageNode extends DecoratorNode {
|
|
33
|
+
static getType() {
|
|
34
|
+
return "image";
|
|
35
|
+
}
|
|
36
|
+
static clone(node) {
|
|
37
|
+
return new _ImageNode(
|
|
38
|
+
node.__src,
|
|
39
|
+
node.__altText,
|
|
40
|
+
node.__maxWidth,
|
|
41
|
+
node.__width,
|
|
42
|
+
node.__height,
|
|
43
|
+
node.__showCaption,
|
|
44
|
+
node.__caption,
|
|
45
|
+
node.__captionsEnabled,
|
|
46
|
+
node.__key,
|
|
47
|
+
node.__rounded,
|
|
48
|
+
node.__alignment
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
static importJSON(serializedNode) {
|
|
52
|
+
const {
|
|
53
|
+
altText,
|
|
54
|
+
height,
|
|
55
|
+
width,
|
|
56
|
+
maxWidth,
|
|
57
|
+
src,
|
|
58
|
+
showCaption,
|
|
59
|
+
alignment,
|
|
60
|
+
rounded
|
|
61
|
+
} = serializedNode;
|
|
62
|
+
return $createImageNode({
|
|
63
|
+
altText,
|
|
64
|
+
height,
|
|
65
|
+
maxWidth,
|
|
66
|
+
showCaption,
|
|
67
|
+
src,
|
|
68
|
+
width,
|
|
69
|
+
rounded,
|
|
70
|
+
alignment
|
|
71
|
+
}).updateFromJSON(serializedNode);
|
|
72
|
+
}
|
|
73
|
+
setAlignment(newAlignment) {
|
|
74
|
+
const writable = this.getWritable();
|
|
75
|
+
writable.__alignment = newAlignment;
|
|
76
|
+
}
|
|
77
|
+
getWidth() {
|
|
78
|
+
return this.__width;
|
|
79
|
+
}
|
|
80
|
+
getHeight() {
|
|
81
|
+
return this.__height;
|
|
82
|
+
}
|
|
83
|
+
setRounded(rounded) {
|
|
84
|
+
const writable = this.getWritable();
|
|
85
|
+
writable.__rounded = rounded;
|
|
86
|
+
}
|
|
87
|
+
updateFromJSON(serializedNode) {
|
|
88
|
+
const node = super.updateFromJSON(serializedNode);
|
|
89
|
+
const { caption } = serializedNode;
|
|
90
|
+
const nestedEditor = node.__caption;
|
|
91
|
+
const editorState = nestedEditor.parseEditorState(caption.editorState);
|
|
92
|
+
if (!editorState.isEmpty()) {
|
|
93
|
+
nestedEditor.setEditorState(editorState);
|
|
94
|
+
}
|
|
95
|
+
return node;
|
|
96
|
+
}
|
|
97
|
+
exportDOM() {
|
|
98
|
+
const element = document.createElement("img");
|
|
99
|
+
element.setAttribute("src", this.__src);
|
|
100
|
+
element.setAttribute("alt", this.__altText);
|
|
101
|
+
element.setAttribute("width", this.__width.toString());
|
|
102
|
+
element.setAttribute("height", this.__height.toString());
|
|
103
|
+
return { element };
|
|
104
|
+
}
|
|
105
|
+
static importDOM() {
|
|
106
|
+
return {
|
|
107
|
+
img: () => ({
|
|
108
|
+
conversion: $convertImageElement,
|
|
109
|
+
priority: 0
|
|
110
|
+
})
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
setSrc(src) {
|
|
114
|
+
const self = this.getWritable();
|
|
115
|
+
self.__src = src;
|
|
116
|
+
}
|
|
117
|
+
constructor(src, altText, maxWidth, width, height, showCaption, caption, captionsEnabled, key, rounded = 0, alignment = "center") {
|
|
118
|
+
super(key);
|
|
119
|
+
this.__src = src;
|
|
120
|
+
this.__altText = altText;
|
|
121
|
+
this.__maxWidth = maxWidth;
|
|
122
|
+
this.__width = width || "inherit";
|
|
123
|
+
this.__height = height || "inherit";
|
|
124
|
+
this.__showCaption = showCaption || false;
|
|
125
|
+
this.__alignment = alignment;
|
|
126
|
+
this.__rounded = rounded;
|
|
127
|
+
this.__caption = caption || createEditor({
|
|
128
|
+
nodes: []
|
|
129
|
+
});
|
|
130
|
+
this.__captionsEnabled = captionsEnabled || captionsEnabled === void 0;
|
|
131
|
+
}
|
|
132
|
+
exportJSON() {
|
|
133
|
+
return __spreadProps(__spreadValues({}, super.exportJSON()), {
|
|
134
|
+
altText: this.getAltText(),
|
|
135
|
+
caption: this.__caption.toJSON(),
|
|
136
|
+
height: this.__height === "inherit" ? 0 : this.__height,
|
|
137
|
+
maxWidth: this.__maxWidth,
|
|
138
|
+
showCaption: this.__showCaption,
|
|
139
|
+
rounded: this.__rounded,
|
|
140
|
+
alignment: this.__alignment,
|
|
141
|
+
src: this.getSrc(),
|
|
142
|
+
width: this.__width === "inherit" ? 0 : this.__width
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
setWidthAndHeight(width, height) {
|
|
146
|
+
const writable = this.getWritable();
|
|
147
|
+
writable.__width = width;
|
|
148
|
+
writable.__height = height;
|
|
149
|
+
}
|
|
150
|
+
setShowCaption(showCaption) {
|
|
151
|
+
const writable = this.getWritable();
|
|
152
|
+
writable.__showCaption = showCaption;
|
|
153
|
+
}
|
|
154
|
+
createDOM(config) {
|
|
155
|
+
const span = document.createElement("span");
|
|
156
|
+
const theme = config.theme;
|
|
157
|
+
const className = theme.image;
|
|
158
|
+
if (className !== void 0) {
|
|
159
|
+
span.className = className;
|
|
160
|
+
}
|
|
161
|
+
return span;
|
|
162
|
+
}
|
|
163
|
+
updateDOM() {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
getSrc() {
|
|
167
|
+
return this.__src;
|
|
168
|
+
}
|
|
169
|
+
getAltText() {
|
|
170
|
+
return this.__altText;
|
|
171
|
+
}
|
|
172
|
+
decorate() {
|
|
173
|
+
return /* @__PURE__ */ React.createElement(Suspense, { fallback: null }, /* @__PURE__ */ React.createElement(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
style: {
|
|
177
|
+
textAlign: this.__alignment
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
/* @__PURE__ */ React.createElement(
|
|
181
|
+
ImageComponent,
|
|
182
|
+
{
|
|
183
|
+
src: this.__src,
|
|
184
|
+
altText: this.__altText,
|
|
185
|
+
width: this.__width,
|
|
186
|
+
height: this.__height,
|
|
187
|
+
maxWidth: this.__maxWidth,
|
|
188
|
+
nodeKey: this.getKey(),
|
|
189
|
+
showCaption: this.__showCaption,
|
|
190
|
+
caption: this.__caption,
|
|
191
|
+
captionsEnabled: this.__captionsEnabled,
|
|
192
|
+
resizable: true,
|
|
193
|
+
rounded: this.__rounded
|
|
194
|
+
}
|
|
195
|
+
)
|
|
196
|
+
));
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
function $createImageNode({
|
|
200
|
+
altText,
|
|
201
|
+
height,
|
|
202
|
+
maxWidth = 500,
|
|
203
|
+
captionsEnabled,
|
|
204
|
+
src,
|
|
205
|
+
width,
|
|
206
|
+
showCaption,
|
|
207
|
+
caption,
|
|
208
|
+
key,
|
|
209
|
+
rounded,
|
|
210
|
+
alignment
|
|
211
|
+
}) {
|
|
212
|
+
return $applyNodeReplacement(
|
|
213
|
+
new ImageNode(
|
|
214
|
+
src,
|
|
215
|
+
altText,
|
|
216
|
+
maxWidth,
|
|
217
|
+
width,
|
|
218
|
+
height,
|
|
219
|
+
showCaption,
|
|
220
|
+
caption,
|
|
221
|
+
captionsEnabled,
|
|
222
|
+
key,
|
|
223
|
+
rounded,
|
|
224
|
+
alignment
|
|
225
|
+
)
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
function $isImageNode(node) {
|
|
229
|
+
return node instanceof ImageNode;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export {
|
|
233
|
+
ImageNode,
|
|
234
|
+
$createImageNode,
|
|
235
|
+
$isImageNode
|
|
236
|
+
};
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodeList
|
|
3
|
+
} from "./chunk-TTHQCW5F.mjs";
|
|
4
|
+
import {
|
|
5
|
+
useDebounce
|
|
6
|
+
} from "./chunk-GK35L7UY.mjs";
|
|
7
|
+
import {
|
|
8
|
+
Button
|
|
9
|
+
} from "./chunk-BIU7WTLX.mjs";
|
|
10
|
+
import {
|
|
11
|
+
React,
|
|
12
|
+
__spreadValues,
|
|
13
|
+
init_react_shim
|
|
14
|
+
} from "./chunk-77KXU36M.mjs";
|
|
15
|
+
|
|
16
|
+
// src/components/editor/plugins/CodeActionMenuPlugin/index.tsx
|
|
17
|
+
init_react_shim();
|
|
18
|
+
import {
|
|
19
|
+
$isCodeNode as $isCodeNode3,
|
|
20
|
+
CodeNode,
|
|
21
|
+
getLanguageFriendlyName,
|
|
22
|
+
normalizeCodeLang
|
|
23
|
+
} from "@lexical/code";
|
|
24
|
+
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
25
|
+
import {
|
|
26
|
+
$getNearestNodeFromDOMNode as $getNearestNodeFromDOMNode3,
|
|
27
|
+
$getNodeByKey,
|
|
28
|
+
isHTMLElement
|
|
29
|
+
} from "lexical";
|
|
30
|
+
import { useEffect, useRef, useState as useState3 } from "react";
|
|
31
|
+
import * as React3 from "react";
|
|
32
|
+
import { createPortal } from "react-dom";
|
|
33
|
+
|
|
34
|
+
// src/components/editor/plugins/CodeActionMenuPlugin/components/CopyButton.tsx
|
|
35
|
+
init_react_shim();
|
|
36
|
+
import { $isCodeNode } from "@lexical/code";
|
|
37
|
+
import {
|
|
38
|
+
$getNearestNodeFromDOMNode,
|
|
39
|
+
$getSelection,
|
|
40
|
+
$setSelection
|
|
41
|
+
} from "lexical";
|
|
42
|
+
import * as React2 from "react";
|
|
43
|
+
import { useState } from "react";
|
|
44
|
+
import { Copy, Check } from "lucide-react";
|
|
45
|
+
function CopyButton({ editor, getCodeDOMNode }) {
|
|
46
|
+
const [isCopyCompleted, setCopyCompleted] = useState(false);
|
|
47
|
+
const copyToClipboard = async () => {
|
|
48
|
+
const codeDOMNode = getCodeDOMNode();
|
|
49
|
+
if (!codeDOMNode) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
let content = "";
|
|
53
|
+
editor.update(() => {
|
|
54
|
+
const codeNode = $getNearestNodeFromDOMNode(codeDOMNode);
|
|
55
|
+
if ($isCodeNode(codeNode)) {
|
|
56
|
+
content = codeNode.getTextContent();
|
|
57
|
+
}
|
|
58
|
+
const selection = $getSelection();
|
|
59
|
+
$setSelection(selection);
|
|
60
|
+
});
|
|
61
|
+
try {
|
|
62
|
+
await navigator.clipboard.writeText(content);
|
|
63
|
+
setCopyCompleted(true);
|
|
64
|
+
setTimeout(() => setCopyCompleted(false), 2e3);
|
|
65
|
+
} catch (err) {
|
|
66
|
+
console.error("Failed to copy: ", err);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return /* @__PURE__ */ React2.createElement(
|
|
70
|
+
Button,
|
|
71
|
+
{
|
|
72
|
+
variant: "outline",
|
|
73
|
+
size: "Toolbar",
|
|
74
|
+
className: "relative rounded-md",
|
|
75
|
+
onClick: copyToClipboard,
|
|
76
|
+
"aria-label": isCopyCompleted ? "Copied" : "Copy to clipboard"
|
|
77
|
+
},
|
|
78
|
+
/* @__PURE__ */ React2.createElement("span", { className: "sr-only" }, isCopyCompleted ? "Copied" : "Copy"),
|
|
79
|
+
/* @__PURE__ */ React2.createElement(
|
|
80
|
+
Copy,
|
|
81
|
+
{
|
|
82
|
+
className: `h-4 w-4 transition-all duration-300 ${isCopyCompleted ? "scale-0" : "scale-100"}`
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
/* @__PURE__ */ React2.createElement(
|
|
86
|
+
Check,
|
|
87
|
+
{
|
|
88
|
+
className: `absolute inset-0 m-auto h-4 w-4 transition-all duration-300 ${isCopyCompleted ? "scale-100" : "scale-0"}`
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// src/components/editor/plugins/CodeActionMenuPlugin/components/PrettierButton.tsx
|
|
95
|
+
init_react_shim();
|
|
96
|
+
import { $isCodeNode as $isCodeNode2 } from "@lexical/code";
|
|
97
|
+
import { $getNearestNodeFromDOMNode as $getNearestNodeFromDOMNode2 } from "lexical";
|
|
98
|
+
import { useState as useState2 } from "react";
|
|
99
|
+
var PRETTIER_PARSER_MODULES = {
|
|
100
|
+
css: [() => import("./postcss-ONF3VDIM.mjs")],
|
|
101
|
+
html: [() => import("./html-S3ACX7NI.mjs")],
|
|
102
|
+
js: [
|
|
103
|
+
() => import("./babel-JZ2EV6AX.mjs"),
|
|
104
|
+
() => import("./estree-XC56IUFX.mjs")
|
|
105
|
+
],
|
|
106
|
+
markdown: [() => import("./markdown-SNVBOSRA.mjs")],
|
|
107
|
+
typescript: [
|
|
108
|
+
() => import("./typescript-AMPI6OVS.mjs"),
|
|
109
|
+
() => import("./estree-XC56IUFX.mjs")
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
async function loadPrettierParserByLang(lang) {
|
|
113
|
+
const dynamicImports = PRETTIER_PARSER_MODULES[lang];
|
|
114
|
+
const modules = await Promise.all(
|
|
115
|
+
dynamicImports.map((dynamicImport) => dynamicImport())
|
|
116
|
+
);
|
|
117
|
+
return modules;
|
|
118
|
+
}
|
|
119
|
+
async function loadPrettierFormat() {
|
|
120
|
+
const { format } = await import("./standalone-EOIALU3M.mjs");
|
|
121
|
+
return format;
|
|
122
|
+
}
|
|
123
|
+
var PRETTIER_OPTIONS_BY_LANG = {
|
|
124
|
+
css: { parser: "css" },
|
|
125
|
+
html: { parser: "html" },
|
|
126
|
+
js: { parser: "babel" },
|
|
127
|
+
markdown: { parser: "markdown" },
|
|
128
|
+
typescript: { parser: "typescript" }
|
|
129
|
+
};
|
|
130
|
+
var LANG_CAN_BE_PRETTIER = Object.keys(PRETTIER_OPTIONS_BY_LANG);
|
|
131
|
+
function canBePrettier(lang) {
|
|
132
|
+
return LANG_CAN_BE_PRETTIER.includes(lang);
|
|
133
|
+
}
|
|
134
|
+
function getPrettierOptions(lang) {
|
|
135
|
+
const options = PRETTIER_OPTIONS_BY_LANG[lang];
|
|
136
|
+
if (!options) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
`CodeActionMenuPlugin: Prettier does not support this language: ${lang}`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
return options;
|
|
142
|
+
}
|
|
143
|
+
function PrettierButton({ lang, editor, getCodeDOMNode }) {
|
|
144
|
+
const [syntaxError, setSyntaxError] = useState2("");
|
|
145
|
+
const [tipsVisible, setTipsVisible] = useState2(false);
|
|
146
|
+
async function handleClick() {
|
|
147
|
+
const codeDOMNode = getCodeDOMNode();
|
|
148
|
+
if (!codeDOMNode) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let content = "";
|
|
152
|
+
editor.update(() => {
|
|
153
|
+
const codeNode = $getNearestNodeFromDOMNode2(codeDOMNode);
|
|
154
|
+
if ($isCodeNode2(codeNode)) {
|
|
155
|
+
content = codeNode.getTextContent();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
if (content === "") {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
try {
|
|
162
|
+
const format = await loadPrettierFormat();
|
|
163
|
+
const options = getPrettierOptions(lang);
|
|
164
|
+
const prettierParsers = await loadPrettierParserByLang(lang);
|
|
165
|
+
options.plugins = prettierParsers.map(
|
|
166
|
+
(parser) => parser.default || parser
|
|
167
|
+
);
|
|
168
|
+
const formattedCode = await format(content, options);
|
|
169
|
+
editor.update(() => {
|
|
170
|
+
const codeNode = $getNearestNodeFromDOMNode2(codeDOMNode);
|
|
171
|
+
if ($isCodeNode2(codeNode)) {
|
|
172
|
+
const selection = codeNode.select(0);
|
|
173
|
+
selection.insertText(formattedCode);
|
|
174
|
+
setSyntaxError("");
|
|
175
|
+
setTipsVisible(false);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
} catch (error) {
|
|
179
|
+
setError(error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function setError(error) {
|
|
183
|
+
if (error instanceof Error) {
|
|
184
|
+
setSyntaxError(error.message);
|
|
185
|
+
setTipsVisible(true);
|
|
186
|
+
} else {
|
|
187
|
+
console.error("Unexpected error: ", error);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
function handleMouseEnter() {
|
|
191
|
+
if (syntaxError !== "") {
|
|
192
|
+
setTipsVisible(true);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function handleMouseLeave() {
|
|
196
|
+
if (syntaxError !== "") {
|
|
197
|
+
setTipsVisible(false);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return /* @__PURE__ */ React.createElement("div", { className: "w-full group h-full relative" }, /* @__PURE__ */ React.createElement(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
onClick: handleClick,
|
|
204
|
+
onMouseEnter: handleMouseEnter,
|
|
205
|
+
onMouseLeave: handleMouseLeave,
|
|
206
|
+
"aria-label": "prettier"
|
|
207
|
+
},
|
|
208
|
+
/* @__PURE__ */ React.createElement("svg", { width: "20", height: "20", className: "mt-2", viewBox: "0 0 100 100", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React.createElement("g", { id: "prettier" }, /* @__PURE__ */ React.createElement("g", { id: "prettier_2" }, /* @__PURE__ */ React.createElement("path", { id: "Rectangle", d: "M73.8095 19.0481H78.5715C79.9048 19.0481 80.9524 20.0957 80.9524 21.429C80.9524 22.7624 79.9048 23.81 78.5715 23.81H73.8095C72.4762 23.81 71.4286 22.7624 71.4286 21.429C71.4286 20.0957 72.4762 19.0481 73.8095 19.0481Z", fill: "#56B3B4" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_1_", d: "M2.38095 95.2388H26.1904C27.5238 95.2388 28.5714 96.2864 28.5714 97.6197C28.5714 98.9531 27.5238 100.001 26.1904 100.001H2.38095C1.04762 100.001 0 98.9531 0 97.6197C0 96.2864 1.04762 95.2388 2.38095 95.2388Z", fill: "#EA5E5E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_2_", d: "M59.5239 57.1436H73.8095C75.1428 57.1436 76.1904 58.1911 76.1904 59.5244C76.1904 60.8577 75.1428 61.9052 73.8095 61.9052H59.5239C58.1906 61.9052 57.1429 60.8577 57.1429 59.5244C57.1429 58.1911 58.1906 57.1436 59.5239 57.1436Z", fill: "#BF85BF" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_3_", d: "M30.9525 57.1436H50.0002C51.3335 57.1436 52.3811 58.1911 52.3811 59.5244C52.3811 60.8577 51.3335 61.9052 50.0002 61.9052H30.9525C29.6192 61.9052 28.5715 60.8577 28.5715 59.5244C28.5715 58.1911 29.6192 57.1436 30.9525 57.1436Z", fill: "#EA5E5E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_4_", d: "M2.38095 57.1436H21.4286C22.7619 57.1436 23.8095 58.1911 23.8095 59.5244C23.8095 60.8577 22.7619 61.9052 21.4286 61.9052H2.38095C1.04762 61.9052 0 60.8577 0 59.5244C0 58.1911 1.04762 57.1436 2.38095 57.1436Z", fill: "#56B3B4" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_5_", d: "M2.38095 76.1909H26.1904C27.5238 76.1909 28.5714 77.2385 28.5714 78.5719C28.5714 79.9052 27.5238 80.9528 26.1904 80.9528H2.38095C1.04762 80.9528 0 79.9052 0 78.5719C0 77.2385 1.04762 76.1909 2.38095 76.1909Z", fill: "#BF85BF" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_6_", d: "M2.38095 38.0957H26.1904C27.5238 38.0957 28.5714 39.1433 28.5714 40.4767C28.5714 41.81 27.5238 42.8577 26.1904 42.8577H2.38095C1.04762 42.8577 0 41.81 0 40.4767C0 39.1433 1.04762 38.0957 2.38095 38.0957Z", fill: "#BF85BF" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_7_", d: "M26.1905 9.52441H73.8095C75.1428 9.52441 76.1905 10.572 76.1905 11.9054C76.1905 13.2387 75.1428 14.2863 73.8095 14.2863H26.1905C24.8572 14.2863 23.8096 13.2387 23.8096 11.9054C23.8096 10.572 24.8572 9.52441 26.1905 9.52441Z", fill: "#F7BA3E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_8_", d: "M2.38095 9.52441H16.6667C18 9.52441 19.0476 10.572 19.0476 11.9054C19.0476 13.2387 18 14.2863 16.6667 14.2863H2.38095C1.04762 14.2863 0 13.2387 0 11.9054C0 10.572 1.04762 9.52441 2.38095 9.52441Z", fill: "#EA5E5E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_9_", d: "M21.4286 85.7148H26.1905C27.5239 85.7148 28.5715 86.7625 28.5715 88.0958C28.5715 89.4291 27.5239 90.4768 26.1905 90.4768H21.4286C20.0952 90.4768 19.0476 89.4291 19.0476 88.0958C19.0476 86.7625 20.0952 85.7148 21.4286 85.7148Z", fill: "#F7BA3E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_10_", d: "M21.4286 28.572H26.1905C27.5239 28.572 28.5715 29.6196 28.5715 30.9529C28.5715 32.2862 27.5239 33.3338 26.1905 33.3338H21.4286C20.0952 33.3338 19.0476 32.2862 19.0476 30.9529C19.0476 29.6196 20.0952 28.572 21.4286 28.572Z", fill: "#56B3B4" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_11_", d: "M2.38096 85.7148H11.9048C13.2381 85.7148 14.2857 86.7625 14.2857 88.0958C14.2857 89.4291 13.2381 90.4768 11.9048 90.4768H2.38096C1.04762 90.4768 0 89.4291 0 88.0958C0 86.7625 1.04762 85.7148 2.38096 85.7148Z", fill: "#56B3B4" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_12_", d: "M2.38096 28.572H11.9048C13.2381 28.572 14.2857 29.6196 14.2857 30.9529C14.2857 32.2862 13.2381 33.3338 11.9048 33.3338H2.38096C1.04762 33.3338 0 32.2862 0 30.9529C0 29.6196 1.04762 28.572 2.38096 28.572Z", fill: "#F7BA3E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_13_", opacity: "0.5", d: "M64.2858 85.7148H69.0476C70.3809 85.7148 71.4285 86.7625 71.4285 88.0958C71.4285 89.4291 70.3809 90.4768 69.0476 90.4768H64.2858C62.9525 90.4768 61.9049 89.4291 61.9049 88.0958C61.9049 86.7625 62.9525 85.7148 64.2858 85.7148Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_14_", opacity: "0.5", d: "M35.7142 85.7148H54.7619C56.0953 85.7148 57.1429 86.7625 57.1429 88.0958C57.1429 89.4291 56.0953 90.4768 54.7619 90.4768H35.7142C34.3809 90.4768 33.3333 89.4291 33.3333 88.0958C33.3333 86.7625 34.3809 85.7148 35.7142 85.7148Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_15_", opacity: "0.5", d: "M78.5714 85.7148H97.6191C98.9524 85.7148 100 86.7625 100 88.0958C100 89.4291 98.9524 90.4768 97.6191 90.4768H78.5714C77.2381 90.4768 76.1904 89.4291 76.1904 88.0958C76.1904 86.7625 77.2381 85.7148 78.5714 85.7148Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_16_", d: "M40.4762 47.6196H78.5714C79.9047 47.6196 80.9523 48.6672 80.9523 50.0005C80.9523 51.3338 79.9047 52.3814 78.5714 52.3814H40.4762C39.1428 52.3814 38.0952 51.3338 38.0952 50.0005C38.0952 48.6672 39.1428 47.6196 40.4762 47.6196Z", fill: "#56B3B4" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_17_", d: "M16.6666 47.6196H30.9523C32.2856 47.6196 33.3333 48.6672 33.3333 50.0005C33.3333 51.3338 32.2856 52.3814 30.9523 52.3814H16.6666C15.3333 52.3814 14.2856 51.3338 14.2856 50.0005C14.2856 48.6672 15.3333 47.6196 16.6666 47.6196Z", fill: "#F7BA3E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_18_", d: "M2.38095 47.6196H7.14286C8.4762 47.6196 9.52382 48.6672 9.52382 50.0005C9.52382 51.3338 8.4762 52.3814 7.14286 52.3814H2.38095C1.04762 52.3814 0 51.3338 0 50.0005C0 48.6672 1.04762 47.6196 2.38095 47.6196Z", fill: "#EA5E5E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_19_", d: "M45.2381 19.0481H64.2857C65.619 19.0481 66.6666 20.0957 66.6666 21.429C66.6666 22.7624 65.619 23.81 64.2857 23.81H45.2381C43.9048 23.81 42.8572 22.7624 42.8572 21.429C42.8572 20.0957 43.9048 19.0481 45.2381 19.0481Z", fill: "#BF85BF" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_20_", d: "M2.38095 19.0481H35.7142C37.0476 19.0481 38.0952 20.0957 38.0952 21.429C38.0952 22.7624 37.0476 23.81 35.7142 23.81H2.38095C1.04762 23.81 0 22.7624 0 21.429C0 20.0957 1.04762 19.0481 2.38095 19.0481Z", fill: "#56B3B4" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_21_", d: "M16.6666 66.667H59.5239C60.8572 66.667 61.9048 67.7146 61.9048 69.048C61.9048 70.3813 60.8572 71.4289 59.5239 71.4289H16.6666C15.3333 71.4289 14.2856 70.3813 14.2856 69.048C14.2856 67.7146 15.3333 66.667 16.6666 66.667Z", fill: "#F7BA3E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_22_", d: "M2.38095 66.667H7.14286C8.4762 66.667 9.52382 67.7146 9.52382 69.048C9.52382 70.3813 8.4762 71.4289 7.14286 71.4289H2.38095C1.04762 71.4289 0 70.3813 0 69.048C0 67.7146 1.04762 66.667 2.38095 66.667Z", fill: "#BF85BF" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_23_", d: "M59.5239 28.572H83.3333C84.6666 28.572 85.7143 29.6196 85.7143 30.9529C85.7143 32.2862 84.6666 33.3338 83.3333 33.3338H59.5239C58.1906 33.3338 57.1429 32.2862 57.1429 30.9529C57.1429 29.6196 58.1906 28.572 59.5239 28.572Z", fill: "#EA5E5E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_24_", d: "M59.5239 38.0957H83.3333C84.6666 38.0957 85.7143 39.1433 85.7143 40.4767C85.7143 41.81 84.6666 42.8577 83.3333 42.8577H59.5239C58.1906 42.8577 57.1429 41.81 57.1429 40.4767C57.1429 39.1433 58.1906 38.0957 59.5239 38.0957Z", fill: "#F7BA3E" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_25_", d: "M2.38095 0.000488281H59.5238C60.8571 0.000488281 61.9048 1.04811 61.9048 2.38144C61.9048 3.71477 60.8571 4.76239 59.5238 4.76239H2.38095C1.04762 4.76239 0 3.71477 0 2.38144C0 1.04811 1.04762 0.000488281 2.38095 0.000488281Z", fill: "#56B3B4" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_26_", opacity: "0.5", d: "M69.0477 0.000488281H97.6191C98.9525 0.000488281 100 1.04811 100 2.38144C100 3.71477 98.9525 4.76239 97.6191 4.76239H69.0477C67.7144 4.76239 66.6667 3.71477 66.6667 2.38144C66.6667 1.04811 67.7144 0.000488281 69.0477 0.000488281Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_27_", opacity: "0.5", d: "M69.0477 66.667H78.5715C79.9048 66.667 80.9524 67.7146 80.9524 69.048C80.9524 70.3813 79.9048 71.4289 78.5715 71.4289H69.0477C67.7144 71.4289 66.6667 70.3813 66.6667 69.048C66.6667 67.7146 67.7144 66.667 69.0477 66.667Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_28_", opacity: "0.5", d: "M88.0953 66.667H97.6192C98.9525 66.667 100 67.7146 100 69.048C100 70.3813 98.9525 71.4289 97.6192 71.4289H88.0953C86.762 71.4289 85.7144 70.3813 85.7144 69.048C85.7144 67.7146 86.762 66.667 88.0953 66.667Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_29_", opacity: "0.5", d: "M83.3334 57.1436H97.6191C98.9524 57.1436 100 58.1911 100 59.5244C100 60.8577 98.9524 61.9052 97.6191 61.9052H83.3334C82 61.9052 80.9524 60.8577 80.9524 59.5244C80.9524 58.1911 82 57.1436 83.3334 57.1436Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_30_", opacity: "0.5", d: "M83.3334 9.52441H97.6191C98.9524 9.52441 100 10.572 100 11.9054C100 13.2387 98.9524 14.2863 97.6191 14.2863H83.3334C82 14.2863 80.9524 13.2387 80.9524 11.9054C80.9524 10.572 82 9.52441 83.3334 9.52441Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_31_", opacity: "0.5", d: "M88.0953 47.6196H97.6192C98.9525 47.6196 100 48.6672 100 50.0005C100 51.3338 98.9525 52.3814 97.6192 52.3814H88.0953C86.762 52.3814 85.7144 51.3338 85.7144 50.0005C85.7144 48.6672 86.762 47.6196 88.0953 47.6196Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_32_", opacity: "0.5", d: "M88.0953 19.0481H97.6192C98.9525 19.0481 100 20.0957 100 21.429C100 22.7624 98.9525 23.81 97.6192 23.81H88.0953C86.762 23.81 85.7144 22.7624 85.7144 21.429C85.7144 20.0957 86.762 19.0481 88.0953 19.0481Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_33_", opacity: "0.5", d: "M92.8572 28.572H97.6191C98.9524 28.572 100 29.6196 100 30.9529C100 32.2862 98.9524 33.3338 97.6191 33.3338H92.8572C91.5238 33.3338 90.4762 32.2862 90.4762 30.9529C90.4762 29.6196 91.5238 28.572 92.8572 28.572Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_34_", opacity: "0.5", d: "M92.8572 38.0957H97.6191C98.9524 38.0957 100 39.1433 100 40.4767C100 41.81 98.9524 42.8577 97.6191 42.8577H92.8572C91.5238 42.8577 90.4762 41.81 90.4762 40.4767C90.4762 39.1433 91.5238 38.0957 92.8572 38.0957Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_35_", opacity: "0.5", d: "M54.762 76.1909H97.6191C98.9524 76.1909 100 77.2385 100 78.5719C100 79.9052 98.9524 80.9528 97.6191 80.9528H54.762C53.4287 80.9528 52.3811 79.9052 52.3811 78.5719C52.3811 77.2385 53.4287 76.1909 54.762 76.1909Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_36_", opacity: "0.5", d: "M35.7142 76.1909H45.238C46.5714 76.1909 47.619 77.2385 47.619 78.5719C47.619 79.9052 46.5714 80.9528 45.238 80.9528H35.7142C34.3809 80.9528 33.3333 79.9052 33.3333 78.5719C33.3333 77.2385 34.3809 76.1909 35.7142 76.1909Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_37_", opacity: "0.5", d: "M73.8096 95.2388H97.6192C98.9525 95.2388 100 96.2864 100 97.6197C100 98.9531 98.9525 100.001 97.6192 100.001H73.8096C72.4762 100.001 71.4286 98.9531 71.4286 97.6197C71.4286 96.2864 72.4762 95.2388 73.8096 95.2388Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_38_", opacity: "0.5", d: "M35.7142 95.2388H64.2856C65.6189 95.2388 66.6665 96.2864 66.6665 97.6197C66.6665 98.9531 65.6189 100.001 64.2856 100.001H35.7142C34.3809 100.001 33.3333 98.9531 33.3333 97.6197C33.3333 96.2864 34.3809 95.2388 35.7142 95.2388Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_39_", opacity: "0.5", d: "M35.7142 28.572H50C51.3334 28.572 52.381 29.6196 52.381 30.9529C52.381 32.2862 51.3334 33.3338 50 33.3338H35.7142C34.3809 33.3338 33.3333 32.2862 33.3333 30.9529C33.3333 29.6196 34.3809 28.572 35.7142 28.572Z", fill: "#D0D4D8" }), /* @__PURE__ */ React.createElement("path", { id: "Rectangle_40_", opacity: "0.5", d: "M35.7142 38.0957H50C51.3334 38.0957 52.381 39.1433 52.381 40.4767C52.381 41.81 51.3334 42.8577 50 42.8577H35.7142C34.3809 42.8577 33.3333 41.81 33.3333 40.4767C33.3333 39.1433 34.3809 38.0957 35.7142 38.0957Z", fill: "#D0D4D8" }))))
|
|
209
|
+
), tipsVisible ? /* @__PURE__ */ React.createElement("pre", { className: " hover:opacity-100 group-hover:opacity-100 text-xs opacity-0 transition-all absolute top-8 right-0 p-2 bg-red-500/50 rounded-sm" }, syntaxError) : null);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// src/components/editor/plugins/CodeActionMenuPlugin/index.tsx
|
|
213
|
+
var CODE_PADDING = 8;
|
|
214
|
+
function CodeActionMenuContainer({
|
|
215
|
+
anchorElem
|
|
216
|
+
}) {
|
|
217
|
+
const [editor] = useLexicalComposerContext();
|
|
218
|
+
const [lang, setLang] = useState3("");
|
|
219
|
+
const [isShown, setShown] = useState3(false);
|
|
220
|
+
const [selectedElementKey, setSelectedElementKey] = useState3(
|
|
221
|
+
null
|
|
222
|
+
);
|
|
223
|
+
const [shouldListenMouseMove, setShouldListenMouseMove] = useState3(false);
|
|
224
|
+
const [position, setPosition] = useState3({
|
|
225
|
+
right: "0",
|
|
226
|
+
top: "0"
|
|
227
|
+
});
|
|
228
|
+
const codeSetRef = useRef(/* @__PURE__ */ new Set());
|
|
229
|
+
const codeDOMNodeRef = useRef(null);
|
|
230
|
+
function getCodeDOMNode() {
|
|
231
|
+
return codeDOMNodeRef.current;
|
|
232
|
+
}
|
|
233
|
+
const debouncedOnMouseMove = useDebounce(
|
|
234
|
+
(event) => {
|
|
235
|
+
const { codeDOMNode, isOutside } = getMouseInfo(event);
|
|
236
|
+
if (isOutside) {
|
|
237
|
+
setShown(false);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (!codeDOMNode) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
codeDOMNodeRef.current = codeDOMNode;
|
|
244
|
+
let codeNode = null;
|
|
245
|
+
let _lang = "";
|
|
246
|
+
editor.update(() => {
|
|
247
|
+
const maybeCodeNode = $getNearestNodeFromDOMNode3(codeDOMNode);
|
|
248
|
+
if ($isCodeNode3(maybeCodeNode)) {
|
|
249
|
+
codeNode = maybeCodeNode;
|
|
250
|
+
_lang = codeNode.getLanguage() || "";
|
|
251
|
+
setSelectedElementKey(codeNode.getKey());
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
if (codeNode) {
|
|
255
|
+
const { y: editorElemY, right: editorElemRight } = anchorElem.getBoundingClientRect();
|
|
256
|
+
const { y, right } = codeDOMNode.getBoundingClientRect();
|
|
257
|
+
setLang(_lang);
|
|
258
|
+
setShown(true);
|
|
259
|
+
setPosition({
|
|
260
|
+
right: `${editorElemRight - right + CODE_PADDING}px`,
|
|
261
|
+
top: `${y - editorElemY}px`
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
1e3,
|
|
266
|
+
500
|
|
267
|
+
);
|
|
268
|
+
useEffect(() => {
|
|
269
|
+
if (!shouldListenMouseMove) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
document.addEventListener("mousemove", debouncedOnMouseMove);
|
|
273
|
+
return () => {
|
|
274
|
+
setShown(false);
|
|
275
|
+
debouncedOnMouseMove.cancel();
|
|
276
|
+
document.removeEventListener("mousemove", debouncedOnMouseMove);
|
|
277
|
+
};
|
|
278
|
+
}, [shouldListenMouseMove, debouncedOnMouseMove]);
|
|
279
|
+
useEffect(() => {
|
|
280
|
+
return editor.registerMutationListener(
|
|
281
|
+
CodeNode,
|
|
282
|
+
(mutations) => {
|
|
283
|
+
editor.getEditorState().read(() => {
|
|
284
|
+
for (const [key, type] of mutations) {
|
|
285
|
+
switch (type) {
|
|
286
|
+
case "created":
|
|
287
|
+
codeSetRef.current.add(key);
|
|
288
|
+
break;
|
|
289
|
+
case "destroyed":
|
|
290
|
+
codeSetRef.current.delete(key);
|
|
291
|
+
break;
|
|
292
|
+
default:
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
setShouldListenMouseMove(codeSetRef.current.size > 0);
|
|
298
|
+
},
|
|
299
|
+
{ skipInitialization: false }
|
|
300
|
+
);
|
|
301
|
+
}, [editor]);
|
|
302
|
+
const normalizedLang = normalizeCodeLang(lang);
|
|
303
|
+
const codeFriendlyName = getLanguageFriendlyName(lang);
|
|
304
|
+
const onCodeLanguageSelect = React3.useCallback(
|
|
305
|
+
(value) => {
|
|
306
|
+
editor.update(() => {
|
|
307
|
+
if (selectedElementKey !== null) {
|
|
308
|
+
const node = $getNodeByKey(selectedElementKey);
|
|
309
|
+
if ($isCodeNode3(node)) {
|
|
310
|
+
node.setLanguage(value);
|
|
311
|
+
setLang(value);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
},
|
|
316
|
+
[editor, selectedElementKey]
|
|
317
|
+
);
|
|
318
|
+
return /* @__PURE__ */ React3.createElement("div", null, isShown ? /* @__PURE__ */ React3.createElement(
|
|
319
|
+
"div",
|
|
320
|
+
{
|
|
321
|
+
className: "code-action-menu-container flex flex-row items-center gap-x-2 p-2 absolute ",
|
|
322
|
+
style: __spreadValues({}, position)
|
|
323
|
+
},
|
|
324
|
+
/* @__PURE__ */ React3.createElement("div", null, /* @__PURE__ */ React3.createElement(
|
|
325
|
+
CodeList,
|
|
326
|
+
{
|
|
327
|
+
codeLanguage: codeFriendlyName,
|
|
328
|
+
disabled: !editor.isEditable(),
|
|
329
|
+
onCodeLanguageSelect
|
|
330
|
+
}
|
|
331
|
+
)),
|
|
332
|
+
/* @__PURE__ */ React3.createElement(CopyButton, { editor, getCodeDOMNode }),
|
|
333
|
+
canBePrettier(normalizedLang) ? /* @__PURE__ */ React3.createElement(
|
|
334
|
+
PrettierButton,
|
|
335
|
+
{
|
|
336
|
+
editor,
|
|
337
|
+
getCodeDOMNode,
|
|
338
|
+
lang: normalizedLang
|
|
339
|
+
}
|
|
340
|
+
) : null
|
|
341
|
+
) : null);
|
|
342
|
+
}
|
|
343
|
+
function getMouseInfo(event) {
|
|
344
|
+
const target = event.target;
|
|
345
|
+
if (isHTMLElement(target)) {
|
|
346
|
+
const codeDOMNode = target.closest(
|
|
347
|
+
"code.line-code"
|
|
348
|
+
);
|
|
349
|
+
const isOutside = !(codeDOMNode || target.closest("div.code-action-menu-container") || target.closest("div.code-selector") || target.closest("code.line-code"));
|
|
350
|
+
return { codeDOMNode, isOutside };
|
|
351
|
+
} else {
|
|
352
|
+
return { codeDOMNode: null, isOutside: true };
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function CodeActionMenuPlugin({
|
|
356
|
+
anchorElem = document.body
|
|
357
|
+
}) {
|
|
358
|
+
return createPortal(
|
|
359
|
+
/* @__PURE__ */ React3.createElement(CodeActionMenuContainer, { anchorElem }),
|
|
360
|
+
anchorElem
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export {
|
|
365
|
+
CodeActionMenuPlugin
|
|
366
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cn
|
|
3
|
+
} from "./chunk-YHPNOWFH.mjs";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadValues,
|
|
7
|
+
init_react_shim
|
|
8
|
+
} from "./chunk-77KXU36M.mjs";
|
|
9
|
+
|
|
10
|
+
// src/components/ui/input.tsx
|
|
11
|
+
init_react_shim();
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
var Input = React.forwardRef(
|
|
14
|
+
(_a, ref) => {
|
|
15
|
+
var _b = _a, { className, type } = _b, props = __objRest(_b, ["className", "type"]);
|
|
16
|
+
return /* @__PURE__ */ React.createElement(
|
|
17
|
+
"input",
|
|
18
|
+
__spreadValues({
|
|
19
|
+
type,
|
|
20
|
+
className: cn(
|
|
21
|
+
"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
22
|
+
className
|
|
23
|
+
),
|
|
24
|
+
ref
|
|
25
|
+
}, props)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
Input.displayName = "Input";
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
Input
|
|
33
|
+
};
|