@jx3box/jx3box-editor 3.2.10 → 3.2.11

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jx3box/jx3box-editor",
3
- "version": "3.2.10",
3
+ "version": "3.2.11",
4
4
  "description": "JX3BOX Article & Editor",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -1,4 +1,5 @@
1
1
  import { load } from "cheerio";
2
+ import { resolveImagePath } from "@jx3box/jx3box-common/js/utils";
2
3
 
3
4
  function joinDomain(domain, path) {
4
5
  const d = String(domain || "").replace(/\/+$/, "");
@@ -16,7 +17,13 @@ function isAbsoluteLike(src) {
16
17
 
17
18
  function normalizeImgSrc(src, domain) {
18
19
  const s = String(src || "").trim();
19
- if (!s || !domain) return s;
20
+ if (!s) return s;
21
+
22
+ // 历史 OSS 图片域名先统一转换为当前 CDN,随后再处理可选的相对路径拼接。
23
+ const resolved = resolveImagePath(s);
24
+ if (resolved && resolved !== s) return resolved;
25
+
26
+ if (!domain) return s;
20
27
  if (isAbsoluteLike(s)) return s;
21
28
 
22
29
  // 最常见:/uploads/xxx
@@ -52,15 +59,12 @@ export default function lazyLoad(html, domain = "") {
52
59
  // 固定懒加载:无论如何都加/覆盖
53
60
  img.attr("loading", "lazy");
54
61
 
55
- // 只有传了 domain 才处理 src 拼接
56
- if (domain) {
57
- const src = img.attr("src");
58
- if (src) img.attr("src", normalizeImgSrc(src, domain));
62
+ // 无论是否传入 domain,都先统一历史 OSS/CDN 地址;相对路径仅在有 domain 时拼接。
63
+ const src = img.attr("src");
64
+ if (src) img.attr("src", normalizeImgSrc(src, domain));
59
65
 
60
- // 如果你有用 data-src 之类,也可以一起处理(可删)
61
- const dataSrc = img.attr("data-src");
62
- if (dataSrc) img.attr("data-src", normalizeImgSrc(dataSrc, domain));
63
- }
66
+ const dataSrc = img.attr("data-src");
67
+ if (dataSrc) img.attr("data-src", normalizeImgSrc(dataSrc, domain));
64
68
  });
65
69
 
66
70
  return $("root").html() || "";