rme 0.1.0-beta.7 → 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 +22 -17
- 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
|
@@ -6543,9 +6543,7 @@ import { setBlockType } from "@remirror/pm/commands";
|
|
|
6543
6543
|
var LineHeadingExtension = class extends HeadingExtension {
|
|
6544
6544
|
createNodeSpec(extra, override) {
|
|
6545
6545
|
return {
|
|
6546
|
-
...super.createNodeSpec(extra, override)
|
|
6547
|
-
content: "text*"
|
|
6548
|
-
// Disallow hard breaks in headings
|
|
6546
|
+
...super.createNodeSpec(extra, override)
|
|
6549
6547
|
};
|
|
6550
6548
|
}
|
|
6551
6549
|
createKeymap() {
|
|
@@ -7077,7 +7075,6 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
7077
7075
|
Consolas,
|
|
7078
7076
|
Liberation Mono,
|
|
7079
7077
|
monospace;
|
|
7080
|
-
line-height: 10px;
|
|
7081
7078
|
color: ${(props) => props.theme.kbdFontColor};
|
|
7082
7079
|
vertical-align: middle;
|
|
7083
7080
|
background-color: ${(props) => props.theme.kbdBgColor};
|
|
@@ -7711,10 +7708,12 @@ var WysiwygThemeWrapper = styled.div.attrs((p) => ({
|
|
|
7711
7708
|
max-width: 400px;
|
|
7712
7709
|
border-radius: 0.2em;
|
|
7713
7710
|
background-color: ${(props) => props.theme.bgColor};
|
|
7711
|
+
line-height: normal;
|
|
7714
7712
|
z-index: 1;
|
|
7715
7713
|
}
|
|
7716
7714
|
|
|
7717
7715
|
.inline-html-render {
|
|
7716
|
+
line-height: normal;
|
|
7718
7717
|
}
|
|
7719
7718
|
|
|
7720
7719
|
.html-node {
|
|
@@ -8504,26 +8503,31 @@ import React2 from "react";
|
|
|
8504
8503
|
import styled5 from "styled-components";
|
|
8505
8504
|
import { Fragment as Fragment4, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
8506
8505
|
var Title = styled5.h1`
|
|
8507
|
-
|
|
8506
|
+
color: ${({ theme }) => theme.dangerColor};
|
|
8508
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
|
+
] });
|
|
8509
8512
|
var ErrorBoundary = class extends React2.Component {
|
|
8510
8513
|
constructor(props) {
|
|
8511
8514
|
super(props);
|
|
8512
8515
|
this.state = { hasError: this.props.hasError ?? false };
|
|
8513
8516
|
}
|
|
8514
|
-
static getDerivedStateFromError() {
|
|
8515
|
-
return { hasError: true };
|
|
8517
|
+
static getDerivedStateFromError(error) {
|
|
8518
|
+
return { hasError: true, error };
|
|
8516
8519
|
}
|
|
8517
8520
|
componentDidCatch(error, errorInfo) {
|
|
8518
8521
|
console.error("[ErrorBoundary]", error, errorInfo);
|
|
8519
8522
|
}
|
|
8520
8523
|
render() {
|
|
8524
|
+
const Fallback = this.props.fallback ?? DefaultFallback;
|
|
8521
8525
|
if (this.state.hasError) {
|
|
8522
|
-
|
|
8523
|
-
|
|
8524
|
-
|
|
8525
|
-
|
|
8526
|
-
|
|
8526
|
+
const error = this.props.error;
|
|
8527
|
+
this.props.onError?.({
|
|
8528
|
+
error
|
|
8529
|
+
});
|
|
8530
|
+
return /* @__PURE__ */ jsx5(Fallback, { error });
|
|
8527
8531
|
}
|
|
8528
8532
|
return this.props.children;
|
|
8529
8533
|
}
|
|
@@ -9324,9 +9328,9 @@ var WysiwygEditor = (props) => {
|
|
|
9324
9328
|
try {
|
|
9325
9329
|
initialContent = editorDelegate.stringToDoc(content);
|
|
9326
9330
|
} catch (error) {
|
|
9327
|
-
return /* @__PURE__ */ jsx10(ErrorBoundary_default, { hasError: true, error });
|
|
9331
|
+
return /* @__PURE__ */ jsx10(ErrorBoundary_default, { hasError: true, error, ...props.errorHandler || {} });
|
|
9328
9332
|
}
|
|
9329
|
-
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(
|
|
9330
9334
|
Remirror,
|
|
9331
9335
|
{
|
|
9332
9336
|
manager: editorDelegate.manager,
|
|
@@ -19557,9 +19561,9 @@ var SourceCodeEditorCore = memo7(
|
|
|
19557
19561
|
try {
|
|
19558
19562
|
initialCntent = markText.stringToDoc(content);
|
|
19559
19563
|
} catch (error) {
|
|
19560
|
-
return /* @__PURE__ */ jsx19(ErrorBoundary_default, { hasError: true, error });
|
|
19564
|
+
return /* @__PURE__ */ jsx19(ErrorBoundary_default, { hasError: true, error, ...props.errorHandler || {} });
|
|
19561
19565
|
}
|
|
19562
|
-
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(
|
|
19563
19567
|
Remirror2,
|
|
19564
19568
|
{
|
|
19565
19569
|
manager: markText.manager,
|
|
@@ -19608,7 +19612,8 @@ var SourceEditor = (props) => {
|
|
|
19608
19612
|
{
|
|
19609
19613
|
styleToken,
|
|
19610
19614
|
markdownToolBar,
|
|
19611
|
-
onChange: handleChange
|
|
19615
|
+
onChange: handleChange,
|
|
19616
|
+
errorHandler: props.errorHandler
|
|
19612
19617
|
}
|
|
19613
19618
|
)
|
|
19614
19619
|
}
|