@blocklet/editor 2.6.5 → 2.6.7
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.
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Component, ReactNode } from 'react';
|
|
2
|
+
interface Props {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}
|
|
5
|
+
interface State {
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class EditorErrorBoundary extends Component<Props, State> {
|
|
9
|
+
constructor(props: Props);
|
|
10
|
+
static getDerivedStateFromError(): State;
|
|
11
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
|
|
12
|
+
render(): string | number | boolean | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from '@mui/material';
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
export class EditorErrorBoundary extends Component {
|
|
5
|
+
constructor(props) {
|
|
6
|
+
super(props);
|
|
7
|
+
this.state = { hasError: false };
|
|
8
|
+
}
|
|
9
|
+
static getDerivedStateFromError() {
|
|
10
|
+
return { hasError: true };
|
|
11
|
+
}
|
|
12
|
+
componentDidCatch(error, errorInfo) {
|
|
13
|
+
console.error('[Editor Error]', error, errorInfo);
|
|
14
|
+
// Check if Sentry is available and capture the error
|
|
15
|
+
if (window.Sentry) {
|
|
16
|
+
try {
|
|
17
|
+
window.Sentry.captureException(error, {
|
|
18
|
+
extra: {
|
|
19
|
+
componentStack: errorInfo.componentStack,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (sentryError) {
|
|
24
|
+
console.error('[Editor Error] Sentry capture error', sentryError);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
render() {
|
|
29
|
+
if (this.state.hasError) {
|
|
30
|
+
return (_jsx(Box, { component: "span", sx: {
|
|
31
|
+
display: 'inline-block',
|
|
32
|
+
padding: '2px 12px',
|
|
33
|
+
fontSize: '12px',
|
|
34
|
+
bgcolor: 'warning.light',
|
|
35
|
+
borderRadius: 0.5,
|
|
36
|
+
}, children: "Editor unavailable" }));
|
|
37
|
+
}
|
|
38
|
+
return this.props.children;
|
|
39
|
+
}
|
|
40
|
+
}
|
package/lib/main/index.js
CHANGED
|
@@ -22,6 +22,7 @@ import PlaygroundNodes from './nodes/PlaygroundNodes';
|
|
|
22
22
|
import { TableContext } from './plugins/TablePlugin';
|
|
23
23
|
import { useCustomTheme } from './themes/customTheme';
|
|
24
24
|
import { getInitialEditorState } from '../lexical-utils';
|
|
25
|
+
import { EditorErrorBoundary } from './EditorErrorBoundary';
|
|
25
26
|
export default function BlockletEditor({ editorState, nodes = PlaygroundNodes, editable = true, markdown, ...props }) {
|
|
26
27
|
const theme = useCustomTheme();
|
|
27
28
|
const initialConfig = {
|
|
@@ -34,7 +35,7 @@ export default function BlockletEditor({ editorState, nodes = PlaygroundNodes, e
|
|
|
34
35
|
},
|
|
35
36
|
theme,
|
|
36
37
|
};
|
|
37
|
-
return (_jsx(SharedHistoryContext, { children: _jsx(SharedAutocompleteContext, { children: _jsx(TableContext, { children: _jsx(LexicalComposer, { initialConfig: initialConfig, children: _jsx(EditorShell, { ...props, editable: editable }) }) }) }) }));
|
|
38
|
+
return (_jsx(EditorErrorBoundary, { children: _jsx(SharedHistoryContext, { children: _jsx(SharedAutocompleteContext, { children: _jsx(TableContext, { children: _jsx(LexicalComposer, { initialConfig: initialConfig, children: _jsx(EditorShell, { ...props, editable: editable }) }) }) }) }) }));
|
|
38
39
|
}
|
|
39
40
|
function EditorShell({ placeholder, children, prepend, editable, onChange, autoFocus, showToolbar = true, editorRef, onReady, enableHeadingsIdPlugin, ...props }) {
|
|
40
41
|
const muiTheme = useTheme();
|
package/lib/main/viewer/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { useCustomTheme } from '../themes/customTheme';
|
|
|
8
8
|
import { EditorViewer } from './viewer';
|
|
9
9
|
import { EditorRoot } from '../editor-root';
|
|
10
10
|
import { getInitialEditorState } from '../../lexical-utils';
|
|
11
|
+
import { EditorErrorBoundary } from '../EditorErrorBoundary';
|
|
11
12
|
export function BlockletEditorViewer({ editorState, markdown, ...props }) {
|
|
12
13
|
const muiTheme = useTheme();
|
|
13
14
|
const theme = useCustomTheme();
|
|
@@ -21,5 +22,5 @@ export function BlockletEditorViewer({ editorState, markdown, ...props }) {
|
|
|
21
22
|
},
|
|
22
23
|
theme,
|
|
23
24
|
};
|
|
24
|
-
return (_jsx(LexicalComposer, { initialConfig: initialConfig, children: _jsx(EditorRoot, { className: cx(props.className, 'be-shell'), "data-mode": muiTheme.palette.mode, children: _jsx(EditorViewer, { ...props }) }) }));
|
|
25
|
+
return (_jsx(EditorErrorBoundary, { children: _jsx(LexicalComposer, { initialConfig: initialConfig, children: _jsx(EditorRoot, { className: cx(props.className, 'be-shell'), "data-mode": muiTheme.palette.mode, children: _jsx(EditorViewer, { ...props }) }) }) }));
|
|
25
26
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/editor",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.7",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@blocklet/code-editor": "^0.7.12",
|
|
29
29
|
"@blocklet/embed": "^0.3.5",
|
|
30
|
-
"@blocklet/js-sdk": "^1.17.8-beta-
|
|
30
|
+
"@blocklet/js-sdk": "^1.17.8-beta-20260106-113136-b3c09e14",
|
|
31
31
|
"@blocklet/pages-kit": "^0.7.37",
|
|
32
32
|
"@blocklet/pages-kit-runtime": "^0.7.37",
|
|
33
33
|
"@excalidraw/excalidraw": "^0.18.0",
|
|
@@ -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.6.
|
|
76
|
+
"@blocklet/pdf": "2.6.7"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@babel/core": "^7.25.2",
|