@blocklet/editor 2.4.104 → 2.4.105
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,9 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
3
|
import { ErrorBoundary } from 'react-error-boundary';
|
|
4
|
+
import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
|
|
4
5
|
import components from './components';
|
|
6
|
+
const translations = {
|
|
7
|
+
en: 'Editing not available',
|
|
8
|
+
zh: '此组件暂不支持编辑',
|
|
9
|
+
};
|
|
5
10
|
export function CustomComponent({ component, properties, editorTheme }) {
|
|
6
11
|
const Component = components[component];
|
|
12
|
+
const { locale } = useLocaleContext();
|
|
7
13
|
if (!Component) {
|
|
8
14
|
return null;
|
|
9
15
|
}
|
|
@@ -11,5 +17,24 @@ export function CustomComponent({ component, properties, editorTheme }) {
|
|
|
11
17
|
console.error('CustomComponent error', component, properties, error);
|
|
12
18
|
return null;
|
|
13
19
|
};
|
|
14
|
-
return (_jsx(Box, { sx: {
|
|
20
|
+
return (_jsx(Box, { sx: {
|
|
21
|
+
position: 'relative',
|
|
22
|
+
'.editable &:hover': {
|
|
23
|
+
'&::before': {
|
|
24
|
+
content: `"${translations[locale] || translations.en}"`,
|
|
25
|
+
display: 'inline-block',
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
top: -4,
|
|
28
|
+
left: 0,
|
|
29
|
+
zIndex: 1,
|
|
30
|
+
px: 1,
|
|
31
|
+
py: 0.25,
|
|
32
|
+
typography: 'body2',
|
|
33
|
+
color: '#fff',
|
|
34
|
+
bgcolor: 'grey.400',
|
|
35
|
+
transform: 'translateY(-100%)',
|
|
36
|
+
borderRadius: 0.5,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}, children: _jsx(ErrorBoundary, { fallbackRender: fallbackRender, children: _jsx(Component, { ...properties, editorTheme: editorTheme }) }) }));
|
|
15
40
|
}
|
|
@@ -98,10 +98,10 @@ export class CustomComponentNode extends DecoratorBlockNode {
|
|
|
98
98
|
return false;
|
|
99
99
|
}
|
|
100
100
|
decorate(editor, config) {
|
|
101
|
-
const
|
|
101
|
+
const xComponentTheme = config.theme.xComponent || {};
|
|
102
102
|
const className = {
|
|
103
|
-
base:
|
|
104
|
-
focus:
|
|
103
|
+
base: xComponentTheme.base || '',
|
|
104
|
+
focus: xComponentTheme.focus || '',
|
|
105
105
|
};
|
|
106
106
|
return (_jsx(BlockWithAlignableContents, { className: className, format: this.__format, nodeKey: this.__key, children: _jsx(CustomComponent, { component: this.__data.component, properties: this.__data.properties, editorTheme: config.theme }) }));
|
|
107
107
|
}
|
|
@@ -200,6 +200,12 @@ const createCustomTheme = (theme) => {
|
|
|
200
200
|
`;
|
|
201
201
|
const alertFocus = css `
|
|
202
202
|
outline: 2px solid var(--mui-palette-primary-light);
|
|
203
|
+
`;
|
|
204
|
+
const xComponent = css `
|
|
205
|
+
padding: 8px 0;
|
|
206
|
+
`;
|
|
207
|
+
const xComponentFocus = css `
|
|
208
|
+
outline: 2px solid var(--mui-palette-primary-light);
|
|
203
209
|
`;
|
|
204
210
|
const image = css `
|
|
205
211
|
.image-caption-container {
|
|
@@ -302,6 +308,10 @@ const createCustomTheme = (theme) => {
|
|
|
302
308
|
base: alert,
|
|
303
309
|
focus: alertFocus,
|
|
304
310
|
},
|
|
311
|
+
xComponent: {
|
|
312
|
+
base: xComponent,
|
|
313
|
+
focus: xComponentFocus,
|
|
314
|
+
},
|
|
305
315
|
image: `${defaultTheme.image} ${image}`,
|
|
306
316
|
code,
|
|
307
317
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.105",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"ufo": "^1.5.4",
|
|
74
74
|
"url-join": "^4.0.1",
|
|
75
75
|
"zustand": "^4.5.5",
|
|
76
|
-
"@blocklet/pdf": "2.4.
|
|
76
|
+
"@blocklet/pdf": "2.4.105"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@babel/core": "^7.25.2",
|