@lobehub/editor 4.28.0 → 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.
@@ -11,19 +11,17 @@ 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 } from "@lobehub/ui";
14
+ import { Icon, useImagePreview } from "@lobehub/ui";
15
15
  import { cx } from "antd-style";
16
16
  import { COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND } from "lexical";
17
- import { Image } from "antd";
18
17
  //#region src/plugins/image/react/components/Image.tsx
19
18
  function getResizedImageWidth(startWidth, deltaX, maxWidth) {
20
19
  const adjustedDeltaX = deltaX * 2;
21
20
  return Math.max(50, Math.min(startWidth + adjustedDeltaX, maxWidth));
22
21
  }
23
- const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, onPickFile }) => {
22
+ const Image = memo(({ node, className, showScaleInfo = false, handleUpload, onPickFile }) => {
24
23
  const [isSelected, setSelected] = useLexicalNodeSelection(node.getKey());
25
24
  const [isHovered, setIsHovered] = useState(false);
26
- const [previewOpen, setPreviewOpen] = useState(false);
27
25
  const [scale, setScale] = useState(1);
28
26
  const [size, setSize] = useState({
29
27
  height: 0,
@@ -38,6 +36,8 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
38
36
  const editorRef = useRef(null);
39
37
  const startWidthRef = useRef(0);
40
38
  const lastLoadedSrcRef = useRef(null);
39
+ const previewImageRef = useRef(null);
40
+ const { open: openPreview, outlet: previewOutlet } = useImagePreview(previewImageRef);
41
41
  const t = useTranslation();
42
42
  const isBlock = useMemo(() => {
43
43
  return $isBlockImageNode(node);
@@ -100,8 +100,9 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
100
100
  const handlePreview = useCallback((e) => {
101
101
  e.preventDefault();
102
102
  e.stopPropagation();
103
- setPreviewOpen(true);
104
- }, []);
103
+ previewImageRef.current = imageRef.current?.querySelector("img") ?? null;
104
+ openPreview();
105
+ }, [openPreview]);
105
106
  const children = useMemo(() => {
106
107
  switch (node.status) {
107
108
  case "error": return /* @__PURE__ */ jsx(BrokenImage, {});
@@ -187,13 +188,7 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
187
188
  title: t("image.preview"),
188
189
  variant: "filled"
189
190
  }),
190
- /* @__PURE__ */ jsx(Image.PreviewGroup, {
191
- items: [node.src],
192
- preview: {
193
- open: previewOpen,
194
- onOpenChange: setPreviewOpen
195
- }
196
- }),
191
+ previewOutlet,
197
192
  showScaleInfo && isSelected && scale !== 1 && /* @__PURE__ */ jsxs("div", {
198
193
  className: styles.scaleInfo,
199
194
  children: [Math.round(scale * 100), "%"]
@@ -217,6 +212,6 @@ const Image$1 = memo(({ node, className, showScaleInfo = false, handleUpload, on
217
212
  })
218
213
  });
219
214
  });
220
- Image$1.displayName = "Image";
215
+ Image.displayName = "Image";
221
216
  //#endregion
222
- export { Image$1 as default };
217
+ export { Image as default };
@@ -9,6 +9,7 @@ const styles = createStaticStyles(({ css, cssVar }) => ({
9
9
  cursor: default;
10
10
  user-select: none;
11
11
 
12
+ isolation: isolate;
12
13
  position: relative;
13
14
 
14
15
  overflow: hidden;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.28.0",
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.54.0",
134
+ "@lobehub/ui": "^5.55.0",
135
135
  "antd": "^6.1.1",
136
136
  "motion": "^12.0.0",
137
137
  "react": "^19.0.0",