rme 0.1.0-beta.8 → 0.1.0
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.
- package/dist/index.d.ts +12 -0
- package/dist/index.mjs +19 -13
- package/dist/index.mjs.map +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,6 +16,17 @@ import { LanguageSupport, LanguageDescription } from '@codemirror/language';
|
|
|
16
16
|
import * as styled_components from 'styled-components';
|
|
17
17
|
import * as styled_components_dist_types from 'styled-components/dist/types';
|
|
18
18
|
|
|
19
|
+
interface ErrorBoundaryProps {
|
|
20
|
+
hasError?: boolean;
|
|
21
|
+
error?: unknown;
|
|
22
|
+
fallback?: react__default.ComponentType<{
|
|
23
|
+
error: Error;
|
|
24
|
+
}>;
|
|
25
|
+
onError?: (params: {
|
|
26
|
+
error: Error;
|
|
27
|
+
}) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
19
30
|
declare const Editor: react.MemoExoticComponent<react.ForwardRefExoticComponent<EditorProps & react.RefAttributes<EditorRef>>>;
|
|
20
31
|
type EditorChangeEventParams = RemirrorEventListenerProps<Extension>;
|
|
21
32
|
type EditorChangeHandler = (params: EditorChangeEventParams) => void;
|
|
@@ -50,6 +61,7 @@ interface EditorProps {
|
|
|
50
61
|
markdownToolBar?: React.ReactNode[];
|
|
51
62
|
wysiwygToolBar?: React.ReactNode[];
|
|
52
63
|
onContextMounted?: (context: EditorContext) => void;
|
|
64
|
+
errorHandler?: Pick<ErrorBoundaryProps, 'onError' | 'fallback'>;
|
|
53
65
|
}
|
|
54
66
|
|
|
55
67
|
type StringToDoc = (content: string) => Node;
|
package/dist/index.mjs
CHANGED
|
@@ -8503,26 +8503,31 @@ import React2 from "react";
|
|
|
8503
8503
|
import styled5 from "styled-components";
|
|
8504
8504
|
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
8505
8505
|
var Title = styled5.h1`
|
|
8506
|
-
|
|
8506
|
+
color: ${({ theme }) => theme.dangerColor};
|
|
8507
8507
|
`;
|
|
8508
|
+
var DefaultFallback = (props) => /* @__PURE__ */ jsxs2(Fragment4, { children: [
|
|
8509
|
+
/* @__PURE__ */ jsx5(Title, { children: "Sorry, something went wrong!" }),
|
|
8510
|
+
/* @__PURE__ */ jsx5("p", { children: String(props.error) })
|
|
8511
|
+
] });
|
|
8508
8512
|
var ErrorBoundary = class extends React2.Component {
|
|
8509
8513
|
constructor(props) {
|
|
8510
8514
|
super(props);
|
|
8511
8515
|
this.state = { hasError: this.props.hasError ?? false };
|
|
8512
8516
|
}
|
|
8513
|
-
static getDerivedStateFromError() {
|
|
8514
|
-
return { hasError: true };
|
|
8517
|
+
static getDerivedStateFromError(error) {
|
|
8518
|
+
return { hasError: true, error };
|
|
8515
8519
|
}
|
|
8516
8520
|
componentDidCatch(error, errorInfo) {
|
|
8517
8521
|
console.error("[ErrorBoundary]", error, errorInfo);
|
|
8518
8522
|
}
|
|
8519
8523
|
render() {
|
|
8524
|
+
const Fallback = this.props.fallback ?? DefaultFallback;
|
|
8520
8525
|
if (this.state.hasError) {
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
+
const error = this.props.error;
|
|
8527
|
+
this.props.onError?.({
|
|
8528
|
+
error
|
|
8529
|
+
});
|
|
8530
|
+
return /* @__PURE__ */ jsx5(Fallback, { error });
|
|
8526
8531
|
}
|
|
8527
8532
|
return this.props.children;
|
|
8528
8533
|
}
|
|
@@ -9323,9 +9328,9 @@ var WysiwygEditor = (props) => {
|
|
|
9323
9328
|
try {
|
|
9324
9329
|
initialContent = editorDelegate.stringToDoc(content);
|
|
9325
9330
|
} catch (error) {
|
|
9326
|
-
return /* @__PURE__ */ jsx10(ErrorBoundary_default, { hasError: true, error });
|
|
9331
|
+
return /* @__PURE__ */ jsx10(ErrorBoundary_default, { hasError: true, error, ...props.errorHandler || {} });
|
|
9327
9332
|
}
|
|
9328
|
-
return /* @__PURE__ */ jsx10(ErrorBoundary_default, { children: /* @__PURE__ */ jsx10(WysiwygThemeWrapper, { ...styleToken, children: /* @__PURE__ */ jsxs5(
|
|
9333
|
+
return /* @__PURE__ */ jsx10(ErrorBoundary_default, { ...props.errorHandler || {}, children: /* @__PURE__ */ jsx10(WysiwygThemeWrapper, { ...styleToken, children: /* @__PURE__ */ jsxs5(
|
|
9329
9334
|
Remirror,
|
|
9330
9335
|
{
|
|
9331
9336
|
manager: editorDelegate.manager,
|
|
@@ -19556,9 +19561,9 @@ var SourceCodeEditorCore = memo7(
|
|
|
19556
19561
|
try {
|
|
19557
19562
|
initialCntent = markText.stringToDoc(content);
|
|
19558
19563
|
} catch (error) {
|
|
19559
|
-
return /* @__PURE__ */ jsx19(ErrorBoundary_default, { hasError: true, error });
|
|
19564
|
+
return /* @__PURE__ */ jsx19(ErrorBoundary_default, { hasError: true, error, ...props.errorHandler || {} });
|
|
19560
19565
|
}
|
|
19561
|
-
return /* @__PURE__ */ jsx19(ErrorBoundary_default, { children: /* @__PURE__ */ jsx19(SourceCodeThemeWrapper, { ...styleToken, children: /* @__PURE__ */ jsxs7(
|
|
19566
|
+
return /* @__PURE__ */ jsx19(ErrorBoundary_default, { ...props.errorHandler || {}, children: /* @__PURE__ */ jsx19(SourceCodeThemeWrapper, { ...styleToken, children: /* @__PURE__ */ jsxs7(
|
|
19562
19567
|
Remirror2,
|
|
19563
19568
|
{
|
|
19564
19569
|
manager: markText.manager,
|
|
@@ -19607,7 +19612,8 @@ var SourceEditor = (props) => {
|
|
|
19607
19612
|
{
|
|
19608
19613
|
styleToken,
|
|
19609
19614
|
markdownToolBar,
|
|
19610
|
-
onChange: handleChange
|
|
19615
|
+
onChange: handleChange,
|
|
19616
|
+
errorHandler: props.errorHandler
|
|
19611
19617
|
}
|
|
19612
19618
|
)
|
|
19613
19619
|
}
|