@lobehub/editor 4.28.0 → 4.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/headless.js CHANGED
@@ -3527,7 +3527,7 @@ var LitexmlDataSource = class extends DataSource {
3527
3527
  * Escape XML special characters
3528
3528
  */
3529
3529
  escapeXML(text) {
3530
- return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
3530
+ return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;").replaceAll(" ", "&#9;").replaceAll("\n", "&#10;").replaceAll("\r", "&#13;");
3531
3531
  }
3532
3532
  };
3533
3533
  //#endregion
@@ -10347,14 +10347,14 @@ const MathPlugin = class extends KernelPlugin {
10347
10347
  if (!litexmlService) return;
10348
10348
  litexmlService.registerXMLWriter(MathInlineNode.getType(), (node, ctx) => {
10349
10349
  if (node instanceof MathInlineNode) {
10350
- const attributes = { code: node.getTextContent() };
10350
+ const attributes = { code: node.code };
10351
10351
  return ctx.createXmlNode("math", attributes);
10352
10352
  }
10353
10353
  return false;
10354
10354
  });
10355
10355
  litexmlService.registerXMLWriter(MathBlockNode.getType(), (node, ctx) => {
10356
10356
  if (node instanceof MathBlockNode) {
10357
- const attributes = { code: node.getTextContent() };
10357
+ const attributes = { code: node.code };
10358
10358
  return ctx.createXmlNode("mathBlock", attributes);
10359
10359
  }
10360
10360
  return false;
@@ -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;
@@ -281,7 +281,7 @@ var LitexmlDataSource = class extends DataSource {
281
281
  * Escape XML special characters
282
282
  */
283
283
  escapeXML(text) {
284
- return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
284
+ return text.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;").replaceAll(" ", "&#9;").replaceAll("\n", "&#10;").replaceAll("\r", "&#13;");
285
285
  }
286
286
  };
287
287
  //#endregion
@@ -39,14 +39,14 @@ const MathPlugin = class extends KernelPlugin {
39
39
  if (!litexmlService) return;
40
40
  litexmlService.registerXMLWriter(MathInlineNode.getType(), (node, ctx) => {
41
41
  if (node instanceof MathInlineNode) {
42
- const attributes = { code: node.getTextContent() };
42
+ const attributes = { code: node.code };
43
43
  return ctx.createXmlNode("math", attributes);
44
44
  }
45
45
  return false;
46
46
  });
47
47
  litexmlService.registerXMLWriter(MathBlockNode.getType(), (node, ctx) => {
48
48
  if (node instanceof MathBlockNode) {
49
- const attributes = { code: node.getTextContent() };
49
+ const attributes = { code: node.code };
50
50
  return ctx.createXmlNode("mathBlock", attributes);
51
51
  }
52
52
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "4.28.0",
3
+ "version": "4.29.1",
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",