diff --git a/packages/next-common/components/appendants/common/item.jsx b/packages/next-common/components/appendants/common/item.jsx
index 1f6e8da078..850eb07ef2 100644
--- a/packages/next-common/components/appendants/common/item.jsx
+++ b/packages/next-common/components/appendants/common/item.jsx
@@ -12,6 +12,7 @@ import { SystemActivity } from "@osn/icons/subsquare";
import { formatTimeAgo } from "next-common/utils/viewfuncs/formatTimeAgo";
import Tooltip from "next-common/components/tooltip";
import useIsAppendantAuthor from "../useIsAppendantAuthor";
+import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";
function SplitDot() {
return ยท;
@@ -62,7 +63,10 @@ function Content({ data }) {
{data.contentType === "markdown" && (
)]}
+ plugins={[
+ renderMentionIdentityUserPlugin(),
+ correctionIpfsEndpointPlugin(),
+ ]}
markedOptions={{
breaks: true,
}}
@@ -75,6 +79,7 @@ function Content({ data }) {
renderMentionIdentityUserPlugin(, {
targetElement: { tag: "span" },
}),
+ correctionIpfsEndpointPlugin(),
]}
/>
)}
diff --git a/packages/next-common/components/comment/item.js b/packages/next-common/components/comment/item.js
index a93834b17b..3d035e0010 100644
--- a/packages/next-common/components/comment/item.js
+++ b/packages/next-common/components/comment/item.js
@@ -20,6 +20,7 @@ import { getRealField } from "next-common/sima/actions/common";
import useIsCommentProxyAuthor from "next-common/hooks/useIsCommentProxyAuthor";
import { useRootCommentContext, useRootCommentData } from "./rootComment";
import { SubsquareCommentSource } from "./commentSource";
+import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";
function useIsShouldUseSimaCommentEdit() {
const comment = useComment();
@@ -114,6 +115,7 @@ function CommentItemImpl({ isSecondLevel, scrollToTopLevelCommentBottom }) {
content={comment.content || ""}
plugins={[
renderMentionIdentityUserPlugin(),
+ correctionIpfsEndpointPlugin(),
]}
markedOptions={{
breaks: true,
@@ -127,6 +129,7 @@ function CommentItemImpl({ isSecondLevel, scrollToTopLevelCommentBottom }) {
renderMentionIdentityUserPlugin(, {
targetElement: { tag: "span" },
}),
+ correctionIpfsEndpointPlugin(),
]}
/>
)}
diff --git a/packages/next-common/components/commentSimple.js b/packages/next-common/components/commentSimple.js
index 5bafd6b911..f247da9fbf 100644
--- a/packages/next-common/components/commentSimple.js
+++ b/packages/next-common/components/commentSimple.js
@@ -17,6 +17,7 @@ import { hashEllipsis, textEllipsis } from "next-common/utils";
import { isNil } from "lodash-es";
import { formatTimeAgo } from "next-common/utils/viewfuncs/formatTimeAgo";
import { getChildBountyIndex } from "next-common/utils/viewfuncs/treasury/childBounty";
+import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";
const Wrapper = styled(HoverSecondaryCard)`
display: flex;
@@ -270,6 +271,7 @@ export default function CommentSimple({ data }) {
content={data.content || ""}
plugins={[
renderMentionIdentityUserPlugin(),
+ correctionIpfsEndpointPlugin(),
]}
maxLines={2}
markedOptions={{
@@ -284,6 +286,7 @@ export default function CommentSimple({ data }) {
renderMentionIdentityUserPlugin(, {
targetElement: { tag: "span" },
}),
+ correctionIpfsEndpointPlugin(),
]}
maxLines={2}
/>
diff --git a/packages/next-common/components/delegation/delegate/referenda/detailPopup/tabsContent/announcement.jsx b/packages/next-common/components/delegation/delegate/referenda/detailPopup/tabsContent/announcement.jsx
index d845d92928..fb012f301a 100644
--- a/packages/next-common/components/delegation/delegate/referenda/detailPopup/tabsContent/announcement.jsx
+++ b/packages/next-common/components/delegation/delegate/referenda/detailPopup/tabsContent/announcement.jsx
@@ -1,4 +1,5 @@
import { HtmlPreviewer, MarkdownPreviewer } from "@osn/previewer";
+import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";
export default function ReferendaDelegateeDetailPopupAnnouncement({
delegate,
@@ -39,8 +40,12 @@ export default function ReferendaDelegateeDetailPopupAnnouncement({
markedOptions={{
breaks: true,
}}
+ plugins={[correctionIpfsEndpointPlugin()]}
/>
) : (
-
+
);
}
diff --git a/packages/next-common/sima/components/post/detailItem/appendant.js b/packages/next-common/sima/components/post/detailItem/appendant.js
index 21b4fa254b..51b29f08b2 100644
--- a/packages/next-common/sima/components/post/detailItem/appendant.js
+++ b/packages/next-common/sima/components/post/detailItem/appendant.js
@@ -8,6 +8,7 @@ import {
} from "@osn/previewer";
import IdentityOrAddr from "next-common/components/IdentityOrAddr";
import { prettyHTML } from "next-common/utils/viewfuncs";
+import correctionIpfsEndpointPlugin from "next-common/utils/previewerPlugins/correctionIpfsEndpoint";
function AppendItem({ index, data }) {
return (
@@ -23,7 +24,10 @@ function AppendItem({ index, data }) {
{data.contentType === "markdown" && (
)]}
+ plugins={[
+ renderMentionIdentityUserPlugin(),
+ correctionIpfsEndpointPlugin(),
+ ]}
markedOptions={{
breaks: true,
}}
@@ -36,6 +40,7 @@ function AppendItem({ index, data }) {
renderMentionIdentityUserPlugin(, {
targetElement: { tag: "span" },
}),
+ correctionIpfsEndpointPlugin(),
]}
/>
)}
diff --git a/packages/next-common/utils/collective/getCidByEvidence.js b/packages/next-common/utils/collective/getCidByEvidence.js
index 58c3dc14d8..22ed3f65a5 100644
--- a/packages/next-common/utils/collective/getCidByEvidence.js
+++ b/packages/next-common/utils/collective/getCidByEvidence.js
@@ -5,7 +5,8 @@ import { create as createDigest } from "multiformats/hashes/digest";
const SHA_256_CODE = 0x12;
export function getCidByEvidence(evidence) {
- return CID.createV0(createDigest(SHA_256_CODE, hexToU8a(evidence)))
- .toV1()
- .toString();
+ const evidenceDigest = createDigest(SHA_256_CODE, hexToU8a(evidence));
+ const cidV0 = CID.createV0(evidenceDigest);
+
+ return cidV0.toString();
}
diff --git a/packages/next-common/utils/env/storageLink.js b/packages/next-common/utils/env/storageLink.js
index 13456dcb1c..3edeaf9b41 100644
--- a/packages/next-common/utils/env/storageLink.js
+++ b/packages/next-common/utils/env/storageLink.js
@@ -1,5 +1,16 @@
+import { CID } from "multiformats";
+
+export function convertToCidV0(cid) {
+ try {
+ return CID.parse(cid).toV0().toString();
+ } catch {
+ // Keep CIDv1 and non-CID storage keys unchanged.
+ return cid;
+ }
+}
+
export default function getStorageLink(cid) {
const endpoint = process.env.NEXT_PUBLIC_PREVIEW_IMG_ENDPOINT;
- return `${endpoint}/${cid}`;
+ return `${endpoint}/${convertToCidV0(cid)}`;
}