@lobehub/editor 4.27.4 → 4.29.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/es/codemirror/components/CopyButton.js +1 -1
- package/es/codemirror/components/LanguageSelect.js +8 -11
- package/es/codemirror/components/MoreOptions.js +3 -2
- package/es/codemirror/components/Toolbar.js +2 -1
- package/es/editor-kernel/react/useAnchor.js +1 -1
- package/es/plugins/block/react/ReactBlockPlugin.js +6 -5
- package/es/plugins/codemirror-block/react/CodemirrorNode.js +2 -1
- package/es/plugins/codemirror-block/react/MermaidPreview.js +1 -1
- package/es/plugins/file/react/components/ReactFile.js +1 -1
- package/es/plugins/image/react/components/Image.js +11 -15
- package/es/plugins/image/react/components/ImageEditPopover.js +3 -3
- package/es/plugins/image/react/components/style.js +1 -0
- package/es/plugins/link/react/ReactLinkPlugin.js +2 -2
- package/es/plugins/link/react/components/LinkEdit.js +7 -7
- package/es/plugins/link/react/components/LinkToolbar.js +1 -1
- package/es/plugins/litexml/react/DiffNodeToolbar/index.js +2 -1
- package/es/plugins/litexml/react/TableRowDiffToolbar.js +2 -1
- package/es/plugins/markdown/react/index.js +1 -1
- package/es/plugins/math/react/components/MathEditor.js +1 -1
- package/es/plugins/math/react/components/MathEditorContainer.js +1 -1
- package/es/plugins/math/react/components/MathEditorContent.js +3 -3
- package/es/plugins/math/react/components/Placeholder.js +2 -1
- package/es/plugins/slash/react/components/DefaultSlashMenu.js +1 -1
- package/es/plugins/slash/service/i-slash-service.d.ts +1 -1
- package/es/plugins/table/react/TableActionMenu/ActionMenu.js +1 -1
- package/es/plugins/table/react/TableActionMenu/index.js +1 -1
- package/es/plugins/table/react/TableHoverActions/index.js +1 -1
- package/es/plugins/toolbar/react/index.js +1 -1
- package/es/react/ChatInput/ChatInput.js +1 -1
- package/es/react/ChatInput/type.d.ts +1 -1
- package/es/react/ChatInputActionBar/ChatInputActionBar.js +1 -1
- package/es/react/ChatInputActionBar/type.d.ts +1 -1
- package/es/react/ChatInputActions/ChatInputActions.js +1 -1
- package/es/react/ChatInputActions/components/ActionItem.js +4 -3
- package/es/react/ChatInputActions/components/ActionRender.js +1 -2
- package/es/react/ChatInputActions/components/CollapsedActions.js +2 -1
- package/es/react/ChatInputActions/type.d.ts +1 -1
- package/es/react/CodeLanguageSelect/CodeLanguageSelect.js +4 -10
- package/es/react/CodeLanguageSelect/type.d.ts +1 -1
- package/es/react/FloatActions/FloatActions.js +1 -1
- package/es/react/FloatActions/components/ActionItem.js +4 -3
- package/es/react/FloatActions/components/ActionRender.js +1 -2
- package/es/react/FloatActions/components/CollapsedActions.js +2 -1
- package/es/react/FloatActions/type.d.ts +1 -1
- package/es/react/SendButton/SendButton.js +26 -46
- package/es/react/SendButton/index.d.ts +2 -2
- package/es/react/SendButton/style.js +36 -44
- package/es/react/SendButton/type.d.ts +20 -5
- package/es/renderer/LexicalRenderer.js +1 -1
- package/es/renderer/renderers/codeblock.js +1 -1
- package/es/renderer/renderers/mermaid.js +1 -1
- package/package.json +2 -2
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { LANGUAGES } from "../constants.js";
|
|
3
3
|
import { styles } from "./style.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Select, Text } from "@lobehub/ui/base-ui";
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Flexbox, MaterialFileTypeIcon } from "@lobehub/ui";
|
|
7
8
|
import { cx } from "antd-style";
|
|
8
9
|
//#region src/codemirror/components/LanguageSelect.tsx
|
|
9
10
|
const LanguageSelect = ({ selectedLang, onLanguageChange, options, labels, className }) => {
|
|
10
11
|
const modes = options ?? LANGUAGES;
|
|
11
12
|
const languageOptions = useMemo(() => modes.map((mode) => ({
|
|
12
|
-
aliases: mode.ext || [],
|
|
13
13
|
label: /* @__PURE__ */ jsxs(Flexbox, {
|
|
14
14
|
align: "center",
|
|
15
15
|
gap: 4,
|
|
@@ -26,7 +26,11 @@ const LanguageSelect = ({ selectedLang, onLanguageChange, options, labels, class
|
|
|
26
26
|
children: mode.name
|
|
27
27
|
})]
|
|
28
28
|
}),
|
|
29
|
-
title:
|
|
29
|
+
title: [
|
|
30
|
+
mode.value,
|
|
31
|
+
mode.name,
|
|
32
|
+
...mode.ext || []
|
|
33
|
+
].join(" "),
|
|
30
34
|
value: mode.value
|
|
31
35
|
})), [modes]);
|
|
32
36
|
return /* @__PURE__ */ jsx(Flexbox, {
|
|
@@ -37,14 +41,7 @@ const LanguageSelect = ({ selectedLang, onLanguageChange, options, labels, class
|
|
|
37
41
|
onClick: (e) => e.stopPropagation(),
|
|
38
42
|
children: /* @__PURE__ */ jsx(Select, {
|
|
39
43
|
className: cx(styles.container),
|
|
40
|
-
|
|
41
|
-
const lang = input.toLowerCase();
|
|
42
|
-
if ((option?.value)?.toLowerCase().startsWith(lang)) return true;
|
|
43
|
-
if (String(option?.label).toLowerCase().includes(lang)) return true;
|
|
44
|
-
if (option?.aliases?.some((ext) => ext.toLowerCase().startsWith(lang))) return true;
|
|
45
|
-
return false;
|
|
46
|
-
},
|
|
47
|
-
onChange: onLanguageChange,
|
|
44
|
+
onChange: (value) => onLanguageChange(value),
|
|
48
45
|
options: languageOptions,
|
|
49
46
|
placeholder: labels?.selectLanguage ?? "Select language",
|
|
50
47
|
showSearch: true,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { ActionIcon,
|
|
2
|
+
import { ActionIcon, InputNumber, Switch, Text } from "@lobehub/ui/base-ui";
|
|
3
3
|
import { MoreHorizontalIcon } from "lucide-react";
|
|
4
4
|
import { useCallback } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
import {
|
|
6
|
+
import { Flexbox, Popover } from "@lobehub/ui";
|
|
7
7
|
//#region src/codemirror/components/MoreOptions.tsx
|
|
8
8
|
const MoreOptions = ({ tabSize, onTabSizeChange, useTabs, onUseTabsChange, showLineNumbers, onShowLineNumbersChange, labels }) => {
|
|
9
9
|
const handleTabSizeChange = useCallback((value = 2) => {
|
|
@@ -25,6 +25,7 @@ const MoreOptions = ({ tabSize, onTabSizeChange, useTabs, onUseTabsChange, showL
|
|
|
25
25
|
min: 1,
|
|
26
26
|
onChange: handleTabSizeChange,
|
|
27
27
|
size: "small",
|
|
28
|
+
style: { width: 80 },
|
|
28
29
|
value: tabSize
|
|
29
30
|
})]
|
|
30
31
|
}),
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
import { CopyButton } from "./CopyButton.js";
|
|
3
3
|
import { LanguageSelect } from "./LanguageSelect.js";
|
|
4
4
|
import { MoreOptions } from "./MoreOptions.js";
|
|
5
|
-
import { ActionIcon
|
|
5
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
6
6
|
import { ChevronDown, ChevronRight } from "lucide-react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Flexbox } from "@lobehub/ui";
|
|
8
9
|
//#region src/codemirror/components/Toolbar.tsx
|
|
9
10
|
const Toolbar = ({ selectedLang, onLanguageChange, onCopy, tabSize, onTabSizeChange, useTabs, onUseTabsChange, showLineNumbers, onShowLineNumbersChange, onClick, expand, toggleExpand, labels, languageOptions, extra }) => {
|
|
10
11
|
return /* @__PURE__ */ jsxs(Flexbox, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLexicalComposerContext } from "./react-context.js";
|
|
3
|
-
import { LOBE_THEME_APP_ID } from "@lobehub/ui";
|
|
4
3
|
import { useMemo } from "react";
|
|
4
|
+
import { LOBE_THEME_APP_ID } from "@lobehub/ui";
|
|
5
5
|
//#region src/editor-kernel/react/useAnchor.ts
|
|
6
6
|
const useAnchor = () => {
|
|
7
7
|
const [editor] = useLexicalComposerContext();
|
|
@@ -10,15 +10,16 @@ import { createRuntimeContext } from "./core/runtime-context.js";
|
|
|
10
10
|
import { collectDragBlocks, getBlockMeasureRect, getTableBlockRect, isTableBlockElement } from "./drag/drag-utils.js";
|
|
11
11
|
import { startBlockDragSession } from "./drag/drag-session.js";
|
|
12
12
|
import { ANCHOR_PADDING_CSS_VAR, styles } from "./style.js";
|
|
13
|
-
import {
|
|
13
|
+
import { Button } from "@lobehub/ui/base-ui";
|
|
14
14
|
import { GripVerticalIcon, PlusIcon } from "lucide-react";
|
|
15
15
|
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
16
16
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { DropdownMenu as DropdownMenu$1, Icon, useAppElement } from "@lobehub/ui";
|
|
17
18
|
import { cx } from "antd-style";
|
|
18
|
-
import { Button as Button$1, theme } from "antd";
|
|
19
19
|
import { $findTableNode, $isTableSelection } from "@lexical/table";
|
|
20
20
|
import { $getNodeByKey, $getSelection, $isRangeSelection } from "lexical";
|
|
21
21
|
import { createPortal } from "react-dom";
|
|
22
|
+
import { theme } from "antd";
|
|
22
23
|
//#region src/plugins/block/react/ReactBlockPlugin.tsx
|
|
23
24
|
init_debug();
|
|
24
25
|
const logger = createDebugLogger("plugin", "block-react");
|
|
@@ -627,7 +628,7 @@ const ReactBlockPlugin = (props) => {
|
|
|
627
628
|
icon: PlusIcon,
|
|
628
629
|
size: 14
|
|
629
630
|
}) : void 0;
|
|
630
|
-
return /* @__PURE__ */ jsx(Button
|
|
631
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
631
632
|
"aria-label": title,
|
|
632
633
|
icon,
|
|
633
634
|
onClick: () => item.onClick(menuContext),
|
|
@@ -635,14 +636,14 @@ const ReactBlockPlugin = (props) => {
|
|
|
635
636
|
title,
|
|
636
637
|
type: "text"
|
|
637
638
|
}, item.key);
|
|
638
|
-
}), /* @__PURE__ */ jsx(DropdownMenu, {
|
|
639
|
+
}), /* @__PURE__ */ jsx(DropdownMenu$1, {
|
|
639
640
|
items: dropdownItems,
|
|
640
641
|
onOpenChange: handleOperationMenuOpenChange,
|
|
641
642
|
open: operationMenuOpen && operationMenuContext?.blockId === menuContext.blockId,
|
|
642
643
|
placement: "leftTop",
|
|
643
644
|
popupProps: { className: OPERATION_MENU_OVERLAY_CLASS },
|
|
644
645
|
positionerProps: { style: { zIndex: 1e3 } },
|
|
645
|
-
children: /* @__PURE__ */ jsx(Button
|
|
646
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
646
647
|
"aria-label": "Block actions and drag",
|
|
647
648
|
className: styles.dragHandle,
|
|
648
649
|
"data-block-drag-handle": "true",
|
|
@@ -8,10 +8,11 @@ import { SELECT_AFTER_CODEMIRROR_COMMAND, SELECT_BEFORE_CODEMIRROR_COMMAND } fro
|
|
|
8
8
|
import { useLexicalNodeSelection } from "../../../editor-kernel/react/useLexicalNodeSelection.js";
|
|
9
9
|
import MermaidPreview from "./MermaidPreview.js";
|
|
10
10
|
import { useCodemirrorEditLock } from "./useCodemirrorEditLock.js";
|
|
11
|
-
import { ActionIcon
|
|
11
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
12
12
|
import { CodeXml, Eye } from "lucide-react";
|
|
13
13
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
14
14
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
15
|
+
import { Block } from "@lobehub/ui";
|
|
15
16
|
import { cx } from "antd-style";
|
|
16
17
|
import { debounce } from "es-toolkit/compat";
|
|
17
18
|
import { $getSelection, $setSelection, COMMAND_PRIORITY_CRITICAL, KEY_DOWN_COMMAND } from "lexical";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { Mermaid } from "@lobehub/ui";
|
|
3
2
|
import { useEffect, useState } from "react";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Mermaid } from "@lobehub/ui";
|
|
5
5
|
import { cssVar } from "antd-style";
|
|
6
6
|
//#region src/plugins/codemirror-block/react/MermaidPreview.tsx
|
|
7
7
|
const MermaidPreview = ({ code }) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
2
2
|
import { useLexicalNodeSelection } from "../../../../editor-kernel/react/useLexicalNodeSelection.js";
|
|
3
|
-
import { Center, MaterialFileTypeIcon } from "@lobehub/ui";
|
|
4
3
|
import { useCallback, useEffect, useRef } from "react";
|
|
5
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Center, MaterialFileTypeIcon } from "@lobehub/ui";
|
|
6
6
|
import { CLICK_COMMAND, COMMAND_PRIORITY_LOW } from "lexical";
|
|
7
7
|
//#region src/plugins/file/react/components/ReactFile.tsx
|
|
8
8
|
const ReactFile = ({ className, editor, node }) => {
|
|
@@ -7,22 +7,21 @@ import BrokenImage from "./BrokenImage.js";
|
|
|
7
7
|
import ImageEditPopover from "./ImageEditPopover.js";
|
|
8
8
|
import LazyImage from "./LazyImage.js";
|
|
9
9
|
import { ResizeHandle } from "./ResizeHandle.js";
|
|
10
|
-
import { ActionIcon
|
|
10
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
11
11
|
import { LoaderCircleIcon, ZoomInIcon } from "lucide-react";
|
|
12
12
|
import { Suspense, memo, useCallback, useMemo, useRef, useState } from "react";
|
|
13
13
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { Icon, useImagePreview } from "@lobehub/ui";
|
|
14
15
|
import { cx } from "antd-style";
|
|
15
|
-
import { Image } from "antd";
|
|
16
16
|
import { COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND } from "lexical";
|
|
17
17
|
//#region src/plugins/image/react/components/Image.tsx
|
|
18
18
|
function getResizedImageWidth(startWidth, deltaX, maxWidth) {
|
|
19
19
|
const adjustedDeltaX = deltaX * 2;
|
|
20
20
|
return Math.max(50, Math.min(startWidth + adjustedDeltaX, maxWidth));
|
|
21
21
|
}
|
|
22
|
-
const Image
|
|
22
|
+
const Image = memo(({ node, className, showScaleInfo = false, handleUpload, onPickFile }) => {
|
|
23
23
|
const [isSelected, setSelected] = useLexicalNodeSelection(node.getKey());
|
|
24
24
|
const [isHovered, setIsHovered] = useState(false);
|
|
25
|
-
const [previewOpen, setPreviewOpen] = useState(false);
|
|
26
25
|
const [scale, setScale] = useState(1);
|
|
27
26
|
const [size, setSize] = useState({
|
|
28
27
|
height: 0,
|
|
@@ -37,6 +36,8 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
|
|
|
37
36
|
const editorRef = useRef(null);
|
|
38
37
|
const startWidthRef = useRef(0);
|
|
39
38
|
const lastLoadedSrcRef = useRef(null);
|
|
39
|
+
const previewImageRef = useRef(null);
|
|
40
|
+
const { open: openPreview, outlet: previewOutlet } = useImagePreview(previewImageRef);
|
|
40
41
|
const t = useTranslation();
|
|
41
42
|
const isBlock = useMemo(() => {
|
|
42
43
|
return $isBlockImageNode(node);
|
|
@@ -99,8 +100,9 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
|
|
|
99
100
|
const handlePreview = useCallback((e) => {
|
|
100
101
|
e.preventDefault();
|
|
101
102
|
e.stopPropagation();
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
previewImageRef.current = imageRef.current?.querySelector("img") ?? null;
|
|
104
|
+
openPreview();
|
|
105
|
+
}, [openPreview]);
|
|
104
106
|
const children = useMemo(() => {
|
|
105
107
|
switch (node.status) {
|
|
106
108
|
case "error": return /* @__PURE__ */ jsx(BrokenImage, {});
|
|
@@ -186,13 +188,7 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
|
|
|
186
188
|
title: t("image.preview"),
|
|
187
189
|
variant: "filled"
|
|
188
190
|
}),
|
|
189
|
-
|
|
190
|
-
items: [node.src],
|
|
191
|
-
preview: {
|
|
192
|
-
open: previewOpen,
|
|
193
|
-
onOpenChange: setPreviewOpen
|
|
194
|
-
}
|
|
195
|
-
}),
|
|
191
|
+
previewOutlet,
|
|
196
192
|
showScaleInfo && isSelected && scale !== 1 && /* @__PURE__ */ jsxs("div", {
|
|
197
193
|
className: styles.scaleInfo,
|
|
198
194
|
children: [Math.round(scale * 100), "%"]
|
|
@@ -216,6 +212,6 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
|
|
|
216
212
|
})
|
|
217
213
|
});
|
|
218
214
|
});
|
|
219
|
-
Image
|
|
215
|
+
Image.displayName = "Image";
|
|
220
216
|
//#endregion
|
|
221
|
-
export { Image
|
|
217
|
+
export { Image as default };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useLexicalEditor } from "../../../../editor-kernel/react/useLexicalEditor.js";
|
|
2
2
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
3
3
|
import { useEditable } from "../../../../editor-kernel/react/useEditable.js";
|
|
4
|
-
import { Button,
|
|
4
|
+
import { Button, Input } from "@lobehub/ui/base-ui";
|
|
5
5
|
import { LinkIcon, UploadIcon } from "lucide-react";
|
|
6
6
|
import { memo, useCallback, useRef, useState } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Flexbox, Icon, Popover } from "@lobehub/ui";
|
|
8
9
|
import { cssVar } from "antd-style";
|
|
9
10
|
//#region src/plugins/image/react/components/ImageEditPopover.tsx
|
|
10
11
|
const ImageEditPopover = memo(({ children, node, handleUpload, onPickFile }) => {
|
|
@@ -138,8 +139,7 @@ const ImageEditPopover = memo(({ children, node, handleUpload, onPickFile }) =>
|
|
|
138
139
|
})] }), /* @__PURE__ */ jsx(Button, {
|
|
139
140
|
onClick: handleUrlSubmit,
|
|
140
141
|
size: "small",
|
|
141
|
-
type: "
|
|
142
|
-
variant: "filled",
|
|
142
|
+
type: "fill",
|
|
143
143
|
children: t("confirm")
|
|
144
144
|
})]
|
|
145
145
|
})]
|
|
@@ -15,9 +15,9 @@ import LinkIframe from "./components/LinkIframe.js";
|
|
|
15
15
|
import LinkToolbar from "./components/LinkToolbar.js";
|
|
16
16
|
import SchemaLink from "./components/SchemaLink.js";
|
|
17
17
|
import { LinkReactRendererRegistry, splitReactSchemaRules } from "./renderer-registry.js";
|
|
18
|
+
import { toast } from "@lobehub/ui/base-ui";
|
|
18
19
|
import { useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
19
20
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
-
import { message } from "antd";
|
|
21
21
|
//#region src/plugins/link/react/ReactLinkPlugin.tsx
|
|
22
22
|
async function copyTextToClipboard(text) {
|
|
23
23
|
try {
|
|
@@ -175,7 +175,7 @@ const ReactLinkPlugin = ({ allowedProtocols, theme, enableHotkey = true, validat
|
|
|
175
175
|
label: "link.copy",
|
|
176
176
|
onClick: async ({ editor, linkNode }) => {
|
|
177
177
|
await copyTextToClipboard(editor.getEditorState().read(() => linkNode.getURL()));
|
|
178
|
-
|
|
178
|
+
toast.success(t("link.copySuccess"));
|
|
179
179
|
},
|
|
180
180
|
order: 30
|
|
181
181
|
});
|
|
@@ -4,10 +4,11 @@ import { UPDATE_LINK_TEXT_COMMAND } from "../../command/index.js";
|
|
|
4
4
|
import { EDIT_LINK_CARD_COMMAND } from "../../node/LinkCardNode.js";
|
|
5
5
|
import { cleanPosition, updatePosition } from "../../../../utils/updatePosition.js";
|
|
6
6
|
import { styles } from "../style.js";
|
|
7
|
-
import {
|
|
7
|
+
import { Button, Input, Text } from "@lobehub/ui/base-ui";
|
|
8
8
|
import { BaselineIcon, LinkIcon } from "lucide-react";
|
|
9
9
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
10
10
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { Block, Flexbox, Hotkey, Icon } from "@lobehub/ui";
|
|
11
12
|
import { cssVar } from "antd-style";
|
|
12
13
|
import { COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_NORMAL, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, createCommand } from "lexical";
|
|
13
14
|
import { mergeRegister } from "@lexical/utils";
|
|
@@ -38,8 +39,8 @@ const LinkEdit = ({ editor }) => {
|
|
|
38
39
|
const handleSubmit = useCallback(() => {
|
|
39
40
|
if (!editor.isEditable()) return;
|
|
40
41
|
if (!linkInputRef.current || !linkTextInputRef.current || !editor) return;
|
|
41
|
-
const inputDOM = linkInputRef.current
|
|
42
|
-
const textInputDOM = linkTextInputRef.current
|
|
42
|
+
const inputDOM = linkInputRef.current;
|
|
43
|
+
const textInputDOM = linkTextInputRef.current;
|
|
43
44
|
if (cardNodeRef.current) {
|
|
44
45
|
const cardNode = cardNodeRef.current;
|
|
45
46
|
editor.update(() => {
|
|
@@ -73,8 +74,8 @@ const LinkEdit = ({ editor }) => {
|
|
|
73
74
|
const handleKeyDown = useCallback((event) => {
|
|
74
75
|
if (!linkNodeRef.current && !cardNodeRef.current || !linkInputRef.current || !linkTextInputRef.current || !editor) return;
|
|
75
76
|
const linkNode = linkNodeRef.current;
|
|
76
|
-
const inputDOM = linkInputRef.current
|
|
77
|
-
const textInputDOM = linkTextInputRef.current
|
|
77
|
+
const inputDOM = linkInputRef.current;
|
|
78
|
+
const textInputDOM = linkTextInputRef.current;
|
|
78
79
|
switch (event.key) {
|
|
79
80
|
case "Enter":
|
|
80
81
|
event.preventDefault();
|
|
@@ -268,8 +269,7 @@ const LinkEdit = ({ editor }) => {
|
|
|
268
269
|
handleSubmit();
|
|
269
270
|
},
|
|
270
271
|
size: "small",
|
|
271
|
-
type: "
|
|
272
|
-
variant: "filled",
|
|
272
|
+
type: "fill",
|
|
273
273
|
children: [t("confirm"), /* @__PURE__ */ jsx(Hotkey, {
|
|
274
274
|
compact: true,
|
|
275
275
|
keys: "enter",
|
|
@@ -8,10 +8,10 @@ import { useEditable } from "../../../../editor-kernel/react/useEditable.js";
|
|
|
8
8
|
import { cleanPosition, updatePosition } from "../../../../utils/updatePosition.js";
|
|
9
9
|
import { styles } from "../style.js";
|
|
10
10
|
import { $isLinkToolbarNode, convertLinkNodeByKeyToSchema, convertLinkToolbarNodeByKeyToLink, getLinkToolbarCapabilities, replaceNodeByKeyWithBlockCardNode, replaceNodeByKeyWithCardNode, replaceNodeByKeyWithIframeNode } from "../../conversion/index.js";
|
|
11
|
-
import { Flexbox, Icon } from "@lobehub/ui";
|
|
12
11
|
import { CopyIcon, EditIcon, ExternalLinkIcon, GalleryHorizontalEndIcon, LinkIcon, PanelTopOpenIcon, PanelsTopLeftIcon, UnlinkIcon } from "lucide-react";
|
|
13
12
|
import { memo, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
14
13
|
import { jsx } from "react/jsx-runtime";
|
|
14
|
+
import { Flexbox, Icon } from "@lobehub/ui";
|
|
15
15
|
import { $getNodeByKey, $getSelection, $isRangeSelection, COMMAND_PRIORITY_NORMAL } from "lexical";
|
|
16
16
|
import { mergeRegister } from "@lexical/utils";
|
|
17
17
|
//#region src/plugins/link/react/components/LinkToolbar.tsx
|
|
@@ -2,9 +2,10 @@ import { LexicalPortalContainer } from "../../../../editor-kernel/react/PortalCo
|
|
|
2
2
|
import { LITEXML_DIFFNODE_COMMAND } from "../../command/symbols.js";
|
|
3
3
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
4
4
|
import { styles } from "./style.js";
|
|
5
|
-
import { ActionIcon
|
|
5
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
6
6
|
import { Check, X } from "lucide-react";
|
|
7
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Block } from "@lobehub/ui";
|
|
8
9
|
import { useThemeMode } from "antd-style";
|
|
9
10
|
//#region src/plugins/litexml/react/DiffNodeToolbar/index.tsx
|
|
10
11
|
const ReactDiffNodeToolbar = ({ editor, node }) => {
|
|
@@ -2,10 +2,11 @@ import { $isTableRowDiffNode } from "../node/TableRowDiffNode.js";
|
|
|
2
2
|
import { LITEXML_DIFFNODE_COMMAND } from "../command/symbols.js";
|
|
3
3
|
import { useTranslation } from "../../../editor-kernel/react/useTranslation.js";
|
|
4
4
|
import { styles } from "./DiffNodeToolbar/style.js";
|
|
5
|
-
import { ActionIcon
|
|
5
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
6
6
|
import { Check, X } from "lucide-react";
|
|
7
7
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Block } from "@lobehub/ui";
|
|
9
10
|
import { useThemeMode } from "antd-style";
|
|
10
11
|
import { $getNearestNodeFromDOMNode } from "lexical";
|
|
11
12
|
import { createPortal } from "react-dom";
|
|
@@ -3,8 +3,8 @@ import { useLexicalComposerContext } from "../../../editor-kernel/react/react-co
|
|
|
3
3
|
import { INodePlugin } from "../../inode/plugin/index.js";
|
|
4
4
|
import { MarkdownPlugin } from "../plugin/index.js";
|
|
5
5
|
import { useTranslation } from "../../../editor-kernel/react/useTranslation.js";
|
|
6
|
-
import { toast } from "@lobehub/ui";
|
|
7
6
|
import { useLayoutEffect } from "react";
|
|
7
|
+
import { toast } from "@lobehub/ui";
|
|
8
8
|
//#region src/plugins/markdown/react/index.tsx
|
|
9
9
|
const ReactMarkdownPlugin = () => {
|
|
10
10
|
const [editor] = useLexicalComposerContext();
|
|
@@ -101,7 +101,7 @@ const MathEdit = memo(({ renderComp }) => {
|
|
|
101
101
|
}, [mathNode, editor]);
|
|
102
102
|
const handleFocus = useCallback(() => {
|
|
103
103
|
textareaRef.current?.focus();
|
|
104
|
-
if (prev) textareaRef.current?.
|
|
104
|
+
if (prev) textareaRef.current?.setSelectionRange(0, 0);
|
|
105
105
|
}, [prev]);
|
|
106
106
|
const setTextareaRef = useCallback((ref) => {
|
|
107
107
|
textareaRef.current = ref;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { cleanPosition, updatePosition } from "../../../../utils/updatePosition.js";
|
|
2
2
|
import { styles } from "../style.js";
|
|
3
|
-
import { Flexbox, Popover } from "@lobehub/ui";
|
|
4
3
|
import { memo, useCallback, useEffect, useRef, useState } from "react";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Flexbox, Popover } from "@lobehub/ui";
|
|
6
6
|
//#region src/plugins/math/react/components/MathEditorContainer.tsx
|
|
7
7
|
const MathEditorContainer = memo(({ children, isBlockMode, mathDOM, onFocus, prev }) => {
|
|
8
8
|
const anchorRef = useRef(null);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CONTROL_OR_META, init_sys } from "../../../../common/sys.js";
|
|
2
2
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
3
3
|
import { styles } from "../style.js";
|
|
4
|
-
import { Button,
|
|
4
|
+
import { Button, Text, TextArea } from "@lobehub/ui/base-ui";
|
|
5
5
|
import { memo, useCallback, useEffect, useRef, useState } from "react";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { Flexbox, Hotkey } from "@lobehub/ui";
|
|
7
8
|
import { isModifierMatch } from "lexical";
|
|
8
9
|
import { renderToString } from "katex";
|
|
9
10
|
//#region src/plugins/math/react/components/MathEditorContent.tsx
|
|
@@ -118,8 +119,7 @@ const MathEditorContent = memo(({ focusRef, mathNode, onArrowLeft, onArrowRight,
|
|
|
118
119
|
onSubmit();
|
|
119
120
|
},
|
|
120
121
|
size: "small",
|
|
121
|
-
type: "
|
|
122
|
-
variant: "filled",
|
|
122
|
+
type: "fill",
|
|
123
123
|
children: [t("confirm"), /* @__PURE__ */ jsx(Hotkey, {
|
|
124
124
|
compact: true,
|
|
125
125
|
keys: "mod+enter",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
2
2
|
import { styles } from "../style.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Text } from "@lobehub/ui/base-ui";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Center } from "@lobehub/ui";
|
|
5
6
|
import { cx } from "antd-style";
|
|
6
7
|
//#region src/plugins/math/react/components/Placeholder.tsx
|
|
7
8
|
const Placeholder = ({ mathBlock }) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { flattenSlashOptions, isSlashDividerOption, isSlashSectionOption } from "../../service/i-slash-service.js";
|
|
3
3
|
import { shouldShowLoadingPlaceholder } from "./menuLoading.js";
|
|
4
|
-
import { Icon, LOBE_THEME_APP_ID, menuSharedStyles } from "@lobehub/ui";
|
|
5
4
|
import { isValidElement, useEffect, useLayoutEffect, useMemo, useRef } from "react";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Icon, LOBE_THEME_APP_ID, menuSharedStyles } from "@lobehub/ui";
|
|
7
7
|
import { createStaticStyles } from "antd-style";
|
|
8
8
|
import { createPortal } from "react-dom";
|
|
9
9
|
import { autoUpdate, flip, offset, shift, size, useFloating } from "@floating-ui/react";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IEditor, IServiceID } from "../../../types/kernel.js";
|
|
2
2
|
import "../../../types/index.js";
|
|
3
3
|
import "../utils/utils.js";
|
|
4
|
-
import { DropdownMenuItemType } from "@lobehub/ui";
|
|
5
4
|
import { ReactNode } from "react";
|
|
5
|
+
import { DropdownMenuItemType } from "@lobehub/ui";
|
|
6
6
|
import Fuse, { IFuseOptions } from "fuse.js";
|
|
7
7
|
//#region src/plugins/slash/service/i-slash-service.d.ts
|
|
8
8
|
type ISlashDividerOption = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useTranslation } from "../../../../editor-kernel/react/useTranslation.js";
|
|
2
2
|
import { $canUnmerge, $selectLastDescendant, computeSelectionCount, currentCellBackgroundColor } from "./utils.js";
|
|
3
|
-
import { DropdownMenu } from "@lobehub/ui";
|
|
4
3
|
import { Grid2X2XIcon, PanelBottomCloseIcon, PanelLeftCloseIcon, PanelRightCloseIcon, PanelTopCloseIcon, TableColumnsSplitIcon, TableRowsSplitIcon } from "lucide-react";
|
|
5
4
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { DropdownMenu } from "@lobehub/ui";
|
|
7
7
|
import { $computeTableMapSkipCellCheck, $deleteTableColumnAtSelection, $deleteTableRowAtSelection, $getTableColumnIndexFromTableCellNode, $getTableNodeFromLexicalNodeOrThrow, $getTableRowIndexFromTableCellNode, $insertTableColumnAtSelection, $insertTableRowAtSelection, $isTableCellNode, $isTableSelection, $mergeCells, $unmergeCell, TableCellHeaderStates, TableCellNode, getTableElement, getTableObserverFromTableElement } from "@lexical/table";
|
|
8
8
|
import { $getSelection, $setSelection } from "lexical";
|
|
9
9
|
//#region src/plugins/table/react/TableActionMenu/ActionMenu.tsx
|
|
@@ -2,7 +2,7 @@ import { useAnchor } from "../../../../editor-kernel/react/useAnchor.js";
|
|
|
2
2
|
import { cleanPosition, updatePosition } from "../../../../utils/updatePosition.js";
|
|
3
3
|
import TableActionMenu$1 from "./ActionMenu.js";
|
|
4
4
|
import { styles } from "./style.js";
|
|
5
|
-
import { ActionIcon } from "@lobehub/ui";
|
|
5
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
6
6
|
import { ChevronDown } from "lucide-react";
|
|
7
7
|
import { memo, useCallback, useEffect, useRef, useState } from "react";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -2,7 +2,7 @@ import { useLexicalComposerContext } from "../../../../editor-kernel/react/react
|
|
|
2
2
|
import { useAnchor } from "../../../../editor-kernel/react/useAnchor.js";
|
|
3
3
|
import { styles } from "./style.js";
|
|
4
4
|
import { getMouseInfo, useDebounce } from "./utils.js";
|
|
5
|
-
import { ActionIcon } from "@lobehub/ui";
|
|
5
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
6
6
|
import { PlusIcon } from "lucide-react";
|
|
7
7
|
import { memo, useEffect, useMemo, useRef, useState } from "react";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -6,9 +6,9 @@ import { HIDE_TOOLBAR_COMMAND, registerToolbarCommand } from "../command/index.j
|
|
|
6
6
|
import { getDOMRangeRect } from "../utils/getDOMRangeRect.js";
|
|
7
7
|
import { setFloatingElemPosition } from "../utils/setFloatingElemPosition.js";
|
|
8
8
|
import { styles } from "./style.js";
|
|
9
|
-
import { Block, LOBE_THEME_APP_ID } from "@lobehub/ui";
|
|
10
9
|
import { useCallback, useRef, useState } from "react";
|
|
11
10
|
import { jsx } from "react/jsx-runtime";
|
|
11
|
+
import { Block, LOBE_THEME_APP_ID } from "@lobehub/ui";
|
|
12
12
|
import { cx, useThemeMode } from "antd-style";
|
|
13
13
|
import { $getSelection, COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND, getDOMSelection } from "lexical";
|
|
14
14
|
import { mergeRegister } from "@lexical/utils";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useHeight } from "../hooks/useSize.js";
|
|
3
3
|
import { styles } from "./style.js";
|
|
4
|
-
import { Flexbox } from "@lobehub/ui";
|
|
5
4
|
import { useCallback } from "react";
|
|
6
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Flexbox } from "@lobehub/ui";
|
|
7
7
|
import { cx, useThemeMode } from "antd-style";
|
|
8
8
|
import { Resizable } from "re-resizable";
|
|
9
9
|
import useMergeState from "use-merge-value";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FlexboxProps } from "@lobehub/ui";
|
|
2
1
|
import { CSSProperties, ReactNode, Ref } from "react";
|
|
2
|
+
import { FlexboxProps } from "@lobehub/ui";
|
|
3
3
|
//#region src/react/ChatInput/type.d.ts
|
|
4
4
|
interface ChatInputProps extends Omit<FlexboxProps, 'height'> {
|
|
5
5
|
classNames?: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { styles } from "./style.js";
|
|
3
|
-
import { Flexbox } from "@lobehub/ui";
|
|
4
3
|
import { jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Flexbox } from "@lobehub/ui";
|
|
5
5
|
import { cx } from "antd-style";
|
|
6
6
|
//#region src/react/ChatInputActionBar/ChatInputActionBar.tsx
|
|
7
7
|
const ChatInputActionBar = ({ className, style, left, right, ...rest }) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FlexboxProps } from "@lobehub/ui";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { FlexboxProps } from "@lobehub/ui";
|
|
3
3
|
//#region src/react/ChatInputActionBar/type.d.ts
|
|
4
4
|
interface ChatInputActionBarProps extends Omit<FlexboxProps, 'children'> {
|
|
5
5
|
left?: ReactNode;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { styles } from "./style.js";
|
|
3
3
|
import ActionItem from "./components/ActionItem.js";
|
|
4
4
|
import { useDisplayActionCount } from "./components/useDisplayActionCount.js";
|
|
5
|
-
import { Flexbox, TooltipGroup } from "@lobehub/ui";
|
|
6
5
|
import { memo, useMemo } from "react";
|
|
7
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
import { Flexbox, TooltipGroup } from "@lobehub/ui";
|
|
8
8
|
import { cx } from "antd-style";
|
|
9
9
|
import useMergeState from "use-merge-value";
|
|
10
10
|
//#region src/react/ChatInputActions/ChatInputActions.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import ActionRender from "./ActionRender.js";
|
|
3
3
|
import CollapsedActions from "./CollapsedActions.js";
|
|
4
|
-
import { ActionIcon,
|
|
4
|
+
import { ActionIcon, DropdownMenu } from "@lobehub/ui/base-ui";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/ChatInputActions/components/ActionItem.tsx
|
|
7
7
|
const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, collapsed, gap, setGroupCollapsed }) => {
|
|
@@ -16,8 +16,9 @@ const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, collapsed,
|
|
|
16
16
|
onActionClick
|
|
17
17
|
}, child?.key || `action-${childIndex}`))
|
|
18
18
|
});
|
|
19
|
-
if (item.type === "dropdown") return /* @__PURE__ */ jsx(
|
|
20
|
-
|
|
19
|
+
if (item.type === "dropdown") return /* @__PURE__ */ jsx(DropdownMenu, {
|
|
20
|
+
items: item.children,
|
|
21
|
+
trigger: "hover",
|
|
21
22
|
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
22
23
|
active: item.active,
|
|
23
24
|
danger: item.danger,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { styles } from "../style.js";
|
|
2
|
-
import { ActionIcon } from "@lobehub/ui";
|
|
2
|
+
import { ActionIcon, Divider } from "@lobehub/ui/base-ui";
|
|
3
3
|
import { isValidElement } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import { Divider } from "antd";
|
|
6
5
|
//#region src/react/ChatInputActions/components/ActionRender.tsx
|
|
7
6
|
const ActionRender = ({ item, onActionClick, disabled }) => {
|
|
8
7
|
if (item.type === "divider") return /* @__PURE__ */ jsx(Divider, {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { styles } from "../style.js";
|
|
3
|
-
import { ActionIcon
|
|
3
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
4
4
|
import { CircleChevronLeftIcon, CircleChevronRightIcon, CircleChevronUpIcon } from "lucide-react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Flexbox, Popover, useMotionComponent } from "@lobehub/ui";
|
|
6
7
|
//#region src/react/ChatInputActions/components/CollapsedActions.tsx
|
|
7
8
|
const CollapsedActions = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
|
|
8
9
|
const Motion = useMotionComponent();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FlexboxProps, MenuInfo, MenuItemType, TooltipProps } from "@lobehub/ui";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { FlexboxProps, MenuInfo, MenuItemType, TooltipProps } from "@lobehub/ui";
|
|
3
3
|
//#region src/react/ChatInputActions/type.d.ts
|
|
4
4
|
type ChatInputActionEvent = Pick<MenuInfo, 'key' | 'keyPath' | 'domEvent'>;
|
|
5
5
|
interface ActionItem extends MenuItemType {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { styles } from "./style.js";
|
|
3
|
-
import {
|
|
3
|
+
import { Select, Text } from "@lobehub/ui/base-ui";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Flexbox, MaterialFileTypeIcon } from "@lobehub/ui";
|
|
6
7
|
import { cx } from "antd-style";
|
|
7
8
|
import { bundledLanguagesInfo } from "shiki";
|
|
8
9
|
//#region src/react/CodeLanguageSelect/CodeLanguageSelect.tsx
|
|
9
10
|
const CodeLanguageSelect = ({ className, ...rest }) => {
|
|
10
11
|
const options = useMemo(() => [{
|
|
11
|
-
aliases: ["text", "txt"],
|
|
12
12
|
label: /* @__PURE__ */ jsxs(Flexbox, {
|
|
13
13
|
align: "center",
|
|
14
14
|
gap: 4,
|
|
@@ -25,9 +25,9 @@ const CodeLanguageSelect = ({ className, ...rest }) => {
|
|
|
25
25
|
children: "Plaintext"
|
|
26
26
|
})]
|
|
27
27
|
}),
|
|
28
|
+
title: "plaintext text txt",
|
|
28
29
|
value: "plaintext"
|
|
29
30
|
}, ...bundledLanguagesInfo.map((item) => ({
|
|
30
|
-
aliases: item.aliases,
|
|
31
31
|
label: /* @__PURE__ */ jsxs(Flexbox, {
|
|
32
32
|
align: "center",
|
|
33
33
|
gap: 4,
|
|
@@ -44,18 +44,12 @@ const CodeLanguageSelect = ({ className, ...rest }) => {
|
|
|
44
44
|
children: item.name
|
|
45
45
|
})]
|
|
46
46
|
}),
|
|
47
|
-
title:
|
|
47
|
+
title: [item.id, ...item.aliases || []].join(" "),
|
|
48
48
|
value: item.id
|
|
49
49
|
}))], []);
|
|
50
50
|
return /* @__PURE__ */ jsx(Select, {
|
|
51
51
|
className: cx(styles.container, className),
|
|
52
52
|
defaultValue: "plaintext",
|
|
53
|
-
filterOption: (input, option) => {
|
|
54
|
-
const lang = input.toLowerCase();
|
|
55
|
-
if ((option?.value)?.startsWith(lang)) return true;
|
|
56
|
-
if (option?.aliases?.some((item) => item.startsWith(lang))) return true;
|
|
57
|
-
return false;
|
|
58
|
-
},
|
|
59
53
|
options,
|
|
60
54
|
showSearch: true,
|
|
61
55
|
variant: "filled",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { styles } from "./style.js";
|
|
3
3
|
import ActionItem from "./components/ActionItem.js";
|
|
4
|
-
import { Flexbox } from "@lobehub/ui";
|
|
5
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { Flexbox } from "@lobehub/ui";
|
|
6
6
|
import { cx } from "antd-style";
|
|
7
7
|
import useMergeState from "use-merge-value";
|
|
8
8
|
//#region src/react/FloatActions/FloatActions.tsx
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import ActionRender from "./ActionRender.js";
|
|
3
3
|
import CollapsedActions from "./CollapsedActions.js";
|
|
4
|
-
import { ActionIcon,
|
|
4
|
+
import { ActionIcon, DropdownMenu } from "@lobehub/ui/base-ui";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region src/react/FloatActions/components/ActionItem.tsx
|
|
7
7
|
const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, gap, setGroupCollapsed }) => {
|
|
@@ -16,8 +16,9 @@ const ActionItem = ({ item, disabled, onActionClick, groupCollapsed, gap, setGro
|
|
|
16
16
|
onActionClick
|
|
17
17
|
}, child?.key || `action-${childIndex}`))
|
|
18
18
|
});
|
|
19
|
-
if (item.type === "dropdown") return /* @__PURE__ */ jsx(
|
|
20
|
-
|
|
19
|
+
if (item.type === "dropdown") return /* @__PURE__ */ jsx(DropdownMenu, {
|
|
20
|
+
items: item.children,
|
|
21
|
+
trigger: "hover",
|
|
21
22
|
children: /* @__PURE__ */ jsx(ActionIcon, {
|
|
22
23
|
active: item.active,
|
|
23
24
|
danger: item.danger,
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { styles } from "../style.js";
|
|
2
|
-
import { ActionIcon } from "@lobehub/ui";
|
|
2
|
+
import { ActionIcon, Divider } from "@lobehub/ui/base-ui";
|
|
3
3
|
import { isValidElement } from "react";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
|
-
import { Divider } from "antd";
|
|
6
5
|
//#region src/react/FloatActions/components/ActionRender.tsx
|
|
7
6
|
const ActionRender = ({ item, onActionClick, disabled }) => {
|
|
8
7
|
if (item.type === "divider") return /* @__PURE__ */ jsx(Divider, {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { styles } from "../style.js";
|
|
3
|
-
import { ActionIcon
|
|
3
|
+
import { ActionIcon } from "@lobehub/ui/base-ui";
|
|
4
4
|
import { CircleChevronLeftIcon, CircleChevronRightIcon, CircleChevronUpIcon } from "lucide-react";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Flexbox, Popover, useMotionComponent } from "@lobehub/ui";
|
|
6
7
|
//#region src/react/FloatActions/components/CollapsedActions.tsx
|
|
7
8
|
const CollapsedActions = ({ children, groupCollapse = false, onGroupCollapseChange, gap, mode }) => {
|
|
8
9
|
const Motion = useMotionComponent();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FlexboxProps, MenuInfo, MenuItemType, TooltipProps } from "@lobehub/ui";
|
|
2
1
|
import { ReactNode } from "react";
|
|
2
|
+
import { FlexboxProps, MenuInfo, MenuItemType, TooltipProps } from "@lobehub/ui";
|
|
3
3
|
//#region src/react/FloatActions/type.d.ts
|
|
4
4
|
type FloatActionsEvent = Pick<MenuInfo, 'key' | 'keyPath' | 'domEvent'>;
|
|
5
5
|
interface ActionItem extends MenuItemType {
|
|
@@ -2,22 +2,26 @@
|
|
|
2
2
|
import SendIcon from "./components/SendIcon.js";
|
|
3
3
|
import StopIcon from "./components/StopIcon.js";
|
|
4
4
|
import { styles } from "./style.js";
|
|
5
|
-
import { Button,
|
|
6
|
-
import { ChevronDownIcon } from "lucide-react";
|
|
5
|
+
import { Button, SplitButton } from "@lobehub/ui/base-ui";
|
|
7
6
|
import { useMemo } from "react";
|
|
8
7
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
8
|
import { cx } from "antd-style";
|
|
10
|
-
import { Dropdown as Dropdown$1, Space } from "antd";
|
|
11
9
|
//#region src/react/SendButton/SendButton.tsx
|
|
12
|
-
const SendButton = ({ type = "primary", menu, className, style, loading, generating, size = 32, shape, onSend, onStop, disabled, onClick,
|
|
10
|
+
const SendButton = ({ type = "primary", menu, className, style, loading, generating, size = 32, shape, onSend, onStop, disabled, onClick, placement = "topRight", trigger, title, ...rest }) => {
|
|
13
11
|
const cssVariables = useMemo(() => ({ "--send-button-size": `${size}px` }), [size]);
|
|
12
|
+
const handleSend = (e) => {
|
|
13
|
+
e.stopPropagation();
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
onSend?.(e);
|
|
16
|
+
onClick?.(e);
|
|
17
|
+
};
|
|
14
18
|
if (generating) return /* @__PURE__ */ jsx(Button, {
|
|
15
19
|
className: cx(styles.loadingButton, className),
|
|
16
20
|
onClick: (e) => {
|
|
17
21
|
e.stopPropagation();
|
|
18
22
|
e.preventDefault();
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
onStop?.(e);
|
|
24
|
+
onClick?.(e);
|
|
21
25
|
},
|
|
22
26
|
shape,
|
|
23
27
|
style: {
|
|
@@ -25,7 +29,8 @@ const SendButton = ({ type = "primary", menu, className, style, loading, generat
|
|
|
25
29
|
...style,
|
|
26
30
|
width: menu ? size * 2 : size
|
|
27
31
|
},
|
|
28
|
-
|
|
32
|
+
title,
|
|
33
|
+
type: "fill",
|
|
29
34
|
...rest,
|
|
30
35
|
children: /* @__PURE__ */ jsx(StopIcon, { size: size * .75 })
|
|
31
36
|
});
|
|
@@ -39,6 +44,7 @@ const SendButton = ({ type = "primary", menu, className, style, loading, generat
|
|
|
39
44
|
...style,
|
|
40
45
|
width: menu ? size * 2 : size
|
|
41
46
|
},
|
|
47
|
+
title,
|
|
42
48
|
type,
|
|
43
49
|
...rest
|
|
44
50
|
});
|
|
@@ -46,59 +52,33 @@ const SendButton = ({ type = "primary", menu, className, style, loading, generat
|
|
|
46
52
|
className: cx(styles.button, disabled && styles.disabled, className),
|
|
47
53
|
disabled,
|
|
48
54
|
icon: /* @__PURE__ */ jsx(SendIcon, {}),
|
|
49
|
-
onClick:
|
|
50
|
-
e.stopPropagation();
|
|
51
|
-
e.preventDefault();
|
|
52
|
-
if (onSend) onSend(e);
|
|
53
|
-
if (onClick) onClick(e);
|
|
54
|
-
},
|
|
55
|
+
onClick: handleSend,
|
|
55
56
|
shape,
|
|
56
57
|
style: {
|
|
57
58
|
...cssVariables,
|
|
58
59
|
...style
|
|
59
60
|
},
|
|
61
|
+
title,
|
|
60
62
|
type,
|
|
61
63
|
...rest
|
|
62
64
|
});
|
|
63
|
-
return /* @__PURE__ */ jsxs(
|
|
64
|
-
className: cx(styles.
|
|
65
|
+
return /* @__PURE__ */ jsxs(SplitButton, {
|
|
66
|
+
className: cx(styles.splitButton, disabled && styles.splitButtonDisabled, shape === "round" && styles.splitButtonRound, className),
|
|
67
|
+
disabled,
|
|
65
68
|
style: {
|
|
66
69
|
...cssVariables,
|
|
67
70
|
...style
|
|
68
71
|
},
|
|
69
|
-
|
|
70
|
-
children: [/* @__PURE__ */ jsx(
|
|
71
|
-
className: cx(styles.button, disabled && styles.disabled, className),
|
|
72
|
-
disabled,
|
|
72
|
+
type,
|
|
73
|
+
children: [/* @__PURE__ */ jsx(SplitButton.Main, {
|
|
73
74
|
icon: /* @__PURE__ */ jsx(SendIcon, {}),
|
|
74
|
-
onClick:
|
|
75
|
-
|
|
76
|
-
e.preventDefault();
|
|
77
|
-
if (onSend) onSend(e);
|
|
78
|
-
if (onClick) onClick(e);
|
|
79
|
-
},
|
|
80
|
-
shape,
|
|
81
|
-
style: {
|
|
82
|
-
...cssVariables,
|
|
83
|
-
...style
|
|
84
|
-
},
|
|
85
|
-
type,
|
|
75
|
+
onClick: handleSend,
|
|
76
|
+
title,
|
|
86
77
|
...rest
|
|
87
|
-
}), /* @__PURE__ */ jsx(
|
|
88
|
-
menu,
|
|
89
|
-
placement
|
|
90
|
-
|
|
91
|
-
children: /* @__PURE__ */ jsx(Button, {
|
|
92
|
-
className: cx(styles.button, disabled && styles.disabled, className),
|
|
93
|
-
disabled,
|
|
94
|
-
icon: /* @__PURE__ */ jsx(Icon, { icon: ChevronDownIcon }),
|
|
95
|
-
shape,
|
|
96
|
-
style: {
|
|
97
|
-
...cssVariables,
|
|
98
|
-
cursor: "pointer"
|
|
99
|
-
},
|
|
100
|
-
type
|
|
101
|
-
})
|
|
78
|
+
}), /* @__PURE__ */ jsx(SplitButton.Menu, {
|
|
79
|
+
items: menu.items,
|
|
80
|
+
placement,
|
|
81
|
+
trigger
|
|
102
82
|
})]
|
|
103
83
|
});
|
|
104
84
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SendButtonProps } from "./type.js";
|
|
1
|
+
import { SendButtonClickHandler, SendButtonProps } from "./type.js";
|
|
2
2
|
import SendButton from "./SendButton.js";
|
|
3
|
-
export { SendButtonProps, SendButton as default };
|
|
3
|
+
export { SendButtonClickHandler, SendButtonProps, SendButton as default };
|
|
@@ -1,67 +1,59 @@
|
|
|
1
1
|
import { createStaticStyles } from "antd-style";
|
|
2
2
|
//#region src/react/SendButton/style.ts
|
|
3
|
-
const prefixCls = "ant";
|
|
4
3
|
const styles = createStaticStyles(({ css, cssVar }) => ({
|
|
5
4
|
button: css`
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
padding-inline: 0 !important;
|
|
11
|
-
}
|
|
5
|
+
flex: none;
|
|
6
|
+
width: var(--send-button-size, 32px) !important;
|
|
7
|
+
height: var(--send-button-size, 32px) !important;
|
|
8
|
+
padding-inline: 0 !important;
|
|
12
9
|
`,
|
|
13
10
|
disabled: css`
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
cursor: default;
|
|
12
|
+
border-color: ${cssVar.colorBorderSecondary};
|
|
13
|
+
background: transparent;
|
|
14
|
+
`,
|
|
15
|
+
loadingButton: css`
|
|
16
|
+
flex: none;
|
|
17
|
+
height: var(--send-button-size, 32px) !important;
|
|
18
|
+
padding-inline: 0 !important;
|
|
19
|
+
`,
|
|
20
|
+
splitButton: css`
|
|
21
|
+
flex: none;
|
|
22
|
+
width: fit-content;
|
|
23
|
+
|
|
24
|
+
& > :where(button, a) {
|
|
25
|
+
height: var(--send-button-size, 32px) !important;
|
|
26
|
+
padding-inline: 0 !important;
|
|
18
27
|
}
|
|
19
28
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
& > :where(button, a):first-of-type {
|
|
30
|
+
width: calc(var(--send-button-size, 32px) * 1.2) !important;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
& > :where(button, a):last-of-type {
|
|
34
|
+
width: calc(var(--send-button-size, 32px) * 0.8) !important;
|
|
24
35
|
}
|
|
25
|
-
|
|
36
|
+
`,
|
|
37
|
+
splitButtonDisabled: css`
|
|
38
|
+
opacity: 1;
|
|
39
|
+
|
|
40
|
+
& > :where(button, a) {
|
|
26
41
|
cursor: default;
|
|
27
42
|
border-color: ${cssVar.colorBorderSecondary};
|
|
28
|
-
border-inline-start-color: transparent;
|
|
29
43
|
background: transparent;
|
|
30
44
|
}
|
|
31
45
|
`,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
width: fit-content;
|
|
35
|
-
.${prefixCls}-btn {
|
|
36
|
-
width: calc(var(--send-button-size, 32px) * 1.2);
|
|
37
|
-
height: var(--send-button-size, 32px);
|
|
38
|
-
}
|
|
39
|
-
.${prefixCls}-dropdown-trigger {
|
|
40
|
-
width: calc(var(--send-button-size, 32px) * 0.8);
|
|
41
|
-
&.${prefixCls}-btn-primary {
|
|
42
|
-
&::before {
|
|
43
|
-
background-color: color-mix(in srgb, ${cssVar.colorBgLayout} 10%, transparent) !important;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
`,
|
|
48
|
-
dropdownButtonRound: css`
|
|
49
|
-
.${prefixCls}-btn-compact-first-item {
|
|
46
|
+
splitButtonRound: css`
|
|
47
|
+
& > :where(button, a):first-of-type {
|
|
50
48
|
border-start-start-radius: calc(var(--send-button-size, 32px) / 2);
|
|
51
49
|
border-end-start-radius: calc(var(--send-button-size, 32px) / 2);
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
|
|
52
|
+
& > :where(button, a):last-of-type {
|
|
53
|
+
width: var(--send-button-size, 32px) !important;
|
|
55
54
|
border-start-end-radius: calc(var(--send-button-size, 32px) / 2);
|
|
56
55
|
border-end-end-radius: calc(var(--send-button-size, 32px) / 2);
|
|
57
56
|
}
|
|
58
|
-
`,
|
|
59
|
-
loadingButton: css`
|
|
60
|
-
&.${prefixCls}-btn {
|
|
61
|
-
flex: none;
|
|
62
|
-
height: var(--send-button-size, 32px);
|
|
63
|
-
padding-inline: 0 !important;
|
|
64
|
-
}
|
|
65
57
|
`
|
|
66
58
|
}));
|
|
67
59
|
//#endregion
|
|
@@ -1,11 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ButtonProps, DropdownItem, DropdownMenuProps } from "@lobehub/ui/base-ui";
|
|
2
|
+
import { CSSProperties, MouseEvent, Ref } from "react";
|
|
2
3
|
//#region src/react/SendButton/type.d.ts
|
|
3
|
-
|
|
4
|
+
type SendButtonClickHandler = (e: MouseEvent<HTMLElement>) => void;
|
|
5
|
+
interface SendButtonProps extends Omit<ButtonProps, 'children' | 'className' | 'disabled' | 'icon' | 'loading' | 'onClick' | 'outdent' | 'ref' | 'shape' | 'size' | 'style' | 'title' | 'type'> {
|
|
6
|
+
className?: string;
|
|
7
|
+
disabled?: boolean;
|
|
4
8
|
generating?: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
9
|
+
loading?: boolean;
|
|
10
|
+
menu?: {
|
|
11
|
+
items: DropdownItem[];
|
|
12
|
+
};
|
|
13
|
+
onClick?: SendButtonClickHandler;
|
|
14
|
+
onSend?: SendButtonClickHandler;
|
|
15
|
+
onStop?: SendButtonClickHandler;
|
|
16
|
+
placement?: DropdownMenuProps['placement'];
|
|
17
|
+
ref?: Ref<HTMLButtonElement>;
|
|
7
18
|
shape?: 'default' | 'round';
|
|
8
19
|
size?: number;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
title?: string;
|
|
22
|
+
trigger?: DropdownMenuProps['trigger'];
|
|
23
|
+
type?: ButtonProps['type'];
|
|
9
24
|
}
|
|
10
25
|
//#endregion
|
|
11
|
-
export { SendButtonProps };
|
|
26
|
+
export { SendButtonClickHandler, SendButtonProps };
|
|
@@ -2,8 +2,8 @@ import { getCSSVariables, getRendererClassName } from "./style.js";
|
|
|
2
2
|
import { renderNode } from "./engine/render-tree.js";
|
|
3
3
|
import { rendererNodes } from "./nodes/index.js";
|
|
4
4
|
import { createDefaultRenderers } from "./renderers/index.js";
|
|
5
|
-
import { MotionComponent, MotionProvider } from "@lobehub/ui";
|
|
6
5
|
import { createElement, use, useMemo } from "react";
|
|
6
|
+
import { MotionComponent, MotionProvider } from "@lobehub/ui";
|
|
7
7
|
import { createHeadlessEditor } from "@lexical/headless";
|
|
8
8
|
import { $getRoot } from "lexical";
|
|
9
9
|
import { motion } from "motion/react";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { renderMermaidBlock } from "./mermaid.js";
|
|
3
|
-
import { Highlighter } from "@lobehub/ui";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Highlighter } from "@lobehub/ui";
|
|
5
5
|
//#region src/renderer/renderers/codeblock.tsx
|
|
6
6
|
function CodeBlockRenderer({ node }) {
|
|
7
7
|
const language = node.language || "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/editor",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.29.0",
|
|
4
4
|
"description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"yjs": "^13.6.31"
|
|
132
132
|
},
|
|
133
133
|
"peerDependencies": {
|
|
134
|
-
"@lobehub/ui": "^5.
|
|
134
|
+
"@lobehub/ui": "^5.55.0",
|
|
135
135
|
"antd": "^6.1.1",
|
|
136
136
|
"motion": "^12.0.0",
|
|
137
137
|
"react": "^19.0.0",
|