@blocklet/editor 2.3.87 → 2.3.89
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,7 +1,8 @@
|
|
|
1
1
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
2
3
|
import { $insertNodeToNearestRoot } from '@lexical/utils';
|
|
3
4
|
import { COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
4
|
-
import { useEffect } from 'react';
|
|
5
|
+
import { useContext, useEffect } from 'react';
|
|
5
6
|
import { useRequest } from 'ahooks';
|
|
6
7
|
import { joinURL } from 'ufo';
|
|
7
8
|
import { $createPagesKitComponentNode, PagesKitComponentNode } from './PagesKitComponentNode';
|
|
@@ -22,9 +23,21 @@ export function PagesKitComponentPlugin() {
|
|
|
22
23
|
}, [editor]);
|
|
23
24
|
return null;
|
|
24
25
|
}
|
|
26
|
+
const isAuthorized = (role) => {
|
|
27
|
+
if (!role) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
if (['admin', 'owner'].includes(role)) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const { componentEmbedAllowedPassports } = window.blocklet.preferences;
|
|
34
|
+
const componentEmbedAllowedPassportsArray = componentEmbedAllowedPassports?.split(',').map((x) => x.trim()) || [];
|
|
35
|
+
return componentEmbedAllowedPassportsArray.includes(role);
|
|
36
|
+
};
|
|
25
37
|
export function usePagesKitComponents() {
|
|
38
|
+
const ctx = useContext(SessionContext);
|
|
26
39
|
const { data: pagesKitComponents = [] } = useRequest(() => {
|
|
27
|
-
if (!isBlockletRunning('pages-kit')) {
|
|
40
|
+
if (!isBlockletRunning('pages-kit') || !isAuthorized(ctx?.session?.user?.role)) {
|
|
28
41
|
return Promise.resolve([]);
|
|
29
42
|
}
|
|
30
43
|
return fetch(joinURL(getBlockletMountPointInfo('pages-kit').mountPoint || '/', `/api/components?mode=${mode}`))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.89",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"ufo": "^1.5.4",
|
|
69
69
|
"url-join": "^4.0.1",
|
|
70
70
|
"zustand": "^4.5.5",
|
|
71
|
-
"@blocklet/pdf": "^2.3.
|
|
71
|
+
"@blocklet/pdf": "^2.3.89"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/core": "^7.25.2",
|