@blocklet/editor 2.0.83 → 2.0.85
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.
|
@@ -1,38 +1,48 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { DecoratorNode } from 'lexical';
|
|
3
3
|
import { Suspense } from 'react';
|
|
4
|
-
import { joinURL } from 'ufo';
|
|
4
|
+
import { joinURL, withFragment } from 'ufo';
|
|
5
5
|
import Box from '@mui/material/Box';
|
|
6
6
|
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
7
|
-
import { exhaustiveGuard, safeParseJSON } from '../utils';
|
|
7
|
+
import { exhaustiveGuard, safeParseJSON, discussKitMountPoint } from '../utils';
|
|
8
8
|
function PostLinkComponent(postInfo) {
|
|
9
9
|
const { locale } = useLocaleContext();
|
|
10
10
|
// PostLinkNode 新/旧版本对于 link 的处理:
|
|
11
11
|
// - 旧版本: 存储 post link, 渲染 link 时直接使用 post link
|
|
12
12
|
// - 新版本: 连同 id, type, boardId 等信息一并存储, 渲染 link 时动态拼接 post link (与 embed 时的 post link 解耦)
|
|
13
13
|
let { link } = postInfo;
|
|
14
|
-
const prefix = window.blocklet?.prefix || '/';
|
|
15
14
|
// pageGroup 模式下 path 需要特殊处理
|
|
16
15
|
const { pageGroup } = window.blocklet;
|
|
17
16
|
// 存在 type, 说明是新版本, 拼接 post link
|
|
18
17
|
if (postInfo.type && !postInfo.external) {
|
|
19
18
|
switch (postInfo.type) {
|
|
20
19
|
case 'post':
|
|
21
|
-
link =
|
|
20
|
+
link =
|
|
21
|
+
pageGroup === 'discussion'
|
|
22
|
+
? joinURL(discussKitMountPoint, postInfo.id)
|
|
23
|
+
: joinURL(discussKitMountPoint, '/discussions', postInfo.id);
|
|
22
24
|
break;
|
|
23
25
|
case 'blog':
|
|
24
26
|
link =
|
|
25
|
-
pageGroup === 'blog'
|
|
27
|
+
pageGroup === 'blog'
|
|
28
|
+
? joinURL(discussKitMountPoint, locale, postInfo.id)
|
|
29
|
+
: joinURL(discussKitMountPoint, '/blog', locale, postInfo.id);
|
|
26
30
|
break;
|
|
27
31
|
case 'doc':
|
|
28
32
|
link =
|
|
29
33
|
pageGroup === 'doc'
|
|
30
|
-
? joinURL(
|
|
31
|
-
: joinURL(
|
|
34
|
+
? joinURL(discussKitMountPoint, postInfo.boardId, locale, postInfo.id)
|
|
35
|
+
: joinURL(discussKitMountPoint, '/docs', postInfo.boardId, locale, postInfo.id);
|
|
32
36
|
break;
|
|
33
37
|
default:
|
|
34
38
|
exhaustiveGuard(postInfo.type);
|
|
35
39
|
}
|
|
40
|
+
try {
|
|
41
|
+
link = withFragment(link, new URL(postInfo.link).hash.slice(1));
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
// ignore
|
|
45
|
+
}
|
|
36
46
|
}
|
|
37
47
|
return (_jsxs(Box, { sx: {
|
|
38
48
|
display: 'flex',
|
package/lib/ext/utils.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function joinUrl(...paths: string[]): string;
|
|
|
4
4
|
export declare function isValidUrl(url: string): boolean;
|
|
5
5
|
export declare const safeParseJSON: (json: string, defaultValue?: any) => any;
|
|
6
6
|
export declare const getBlockletMountPointInfo: (name: string) => any;
|
|
7
|
+
export declare const discussKitMountPoint: any;
|
|
7
8
|
export declare const blockletExists: (name: string) => boolean;
|
|
8
9
|
export declare const fetchOpenGraphInfo: (openGraphEndpoint: string, url: string) => Promise<{
|
|
9
10
|
url: any;
|
package/lib/ext/utils.js
CHANGED
|
@@ -28,6 +28,7 @@ export const safeParseJSON = (json, defaultValue = null) => {
|
|
|
28
28
|
export const getBlockletMountPointInfo = (name) => {
|
|
29
29
|
return window.blocklet?.componentMountPoints?.find((x) => x.name === name);
|
|
30
30
|
};
|
|
31
|
+
export const discussKitMountPoint = window.blocklet?.componentMountPoints?.find((x) => x.did === 'z8ia1WEiBZ7hxURf6LwH21Wpg99vophFwSJdu')?.mountPoint || '/';
|
|
31
32
|
export const blockletExists = (name) => {
|
|
32
33
|
return !!getBlockletMountPointInfo(name);
|
|
33
34
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.85",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "npm run storybook",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@arcblock/ux": "^2.10.6",
|
|
41
41
|
"@blocklet/embed": "^0.1.11",
|
|
42
42
|
"@blocklet/pages-kit": "^0.2.377",
|
|
43
|
-
"@blocklet/pdf": "2.0.
|
|
43
|
+
"@blocklet/pdf": "2.0.85",
|
|
44
44
|
"@excalidraw/excalidraw": "^0.14.2",
|
|
45
45
|
"@iconify/iconify": "^3.0.1",
|
|
46
46
|
"@iconify/icons-tabler": "^1.2.95",
|
|
@@ -113,5 +113,5 @@
|
|
|
113
113
|
"react": "*",
|
|
114
114
|
"react-dom": "*"
|
|
115
115
|
},
|
|
116
|
-
"gitHead": "
|
|
116
|
+
"gitHead": "a59a345501aeab25f6c71c1aeacfb94fd2e55de5"
|
|
117
117
|
}
|