@refinex-md/react 0.1.0-canary.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/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/index.d.ts +128 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +363 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Refinex-Space
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @refinex-md/react
|
|
2
|
+
|
|
3
|
+
React 18+ 适配器,提供 `useRefinexMd` hook、`<RefinexMDEditor />` 组件和菜单组件。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @refinex-md/react @refinex-md/theme
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 最短示例
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { RefinexMDEditor } from '@refinex-md/react'
|
|
15
|
+
import '@refinex-md/theme/styles.css'
|
|
16
|
+
|
|
17
|
+
export function App() {
|
|
18
|
+
return <RefinexMDEditor onChange={(doc) => console.log(doc)} />
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 本仓库示例
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm --filter @refinex-md/examples-react dev
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 文档
|
|
29
|
+
|
|
30
|
+
- [React 接入](../../docs/guides/react.md)
|
|
31
|
+
- [API 参考](../../docs/api/README.md#refinex-mdreact)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactElement, ReactNode, RefCallback } from 'react';
|
|
2
|
+
import { RefinexCommandDispatchOptions, RefinexCommandResult, RefinexEditor, RefinexEventEmitOptions, RefinexExtension, RefinexRuntimeError, RefinexRuntimeStatus, RefinexSnapshot, RefinexTransactionOrigin, RefinexViewDriver } from '@refinex-md/core';
|
|
3
|
+
import { RefinexCapabilityToken, RefinexDoc } from '@refinex-md/model';
|
|
4
|
+
export type RefinexReactValue = RefinexDoc;
|
|
5
|
+
export interface RefinexReactSnapshot {
|
|
6
|
+
readonly editor: RefinexEditor | null;
|
|
7
|
+
readonly status: RefinexRuntimeStatus | 'ssr';
|
|
8
|
+
readonly snapshot: RefinexSnapshot | null;
|
|
9
|
+
readonly doc: RefinexDoc | null;
|
|
10
|
+
readonly version: number;
|
|
11
|
+
readonly selection: unknown;
|
|
12
|
+
readonly mounted: boolean;
|
|
13
|
+
readonly readonly: boolean;
|
|
14
|
+
readonly error: RefinexRuntimeError | Error | null;
|
|
15
|
+
}
|
|
16
|
+
export interface RefinexReactChangeEvent {
|
|
17
|
+
readonly editor: RefinexEditor;
|
|
18
|
+
readonly snapshot: RefinexSnapshot;
|
|
19
|
+
readonly origin: RefinexTransactionOrigin;
|
|
20
|
+
readonly changedBlocks: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
export interface UseRefinexMdOptions {
|
|
23
|
+
readonly value?: RefinexDoc;
|
|
24
|
+
readonly defaultValue?: RefinexDoc;
|
|
25
|
+
readonly onChange?: (doc: RefinexDoc, event: RefinexReactChangeEvent) => void;
|
|
26
|
+
readonly onSnapshot?: (snapshot: RefinexSnapshot) => void;
|
|
27
|
+
readonly onMount?: (editor: RefinexEditor) => void;
|
|
28
|
+
readonly onDestroy?: () => void;
|
|
29
|
+
readonly onError?: (error: Error) => void;
|
|
30
|
+
readonly readonly?: boolean;
|
|
31
|
+
readonly capabilities?: readonly RefinexCapabilityToken[];
|
|
32
|
+
readonly extensions?: readonly RefinexExtension[];
|
|
33
|
+
readonly viewDriver?: RefinexViewDriver;
|
|
34
|
+
readonly serializer?: (doc: RefinexDoc) => string;
|
|
35
|
+
readonly mountOnInit?: boolean;
|
|
36
|
+
readonly getServerSnapshot?: () => RefinexReactSnapshot;
|
|
37
|
+
}
|
|
38
|
+
export interface UseRefinexMdResult {
|
|
39
|
+
readonly editor: RefinexEditor | null;
|
|
40
|
+
readonly snapshot: RefinexReactSnapshot;
|
|
41
|
+
readonly containerRef: RefCallback<HTMLElement>;
|
|
42
|
+
readonly mounted: boolean;
|
|
43
|
+
readonly error: Error | null;
|
|
44
|
+
focus(): void;
|
|
45
|
+
blur(): void;
|
|
46
|
+
destroy(): Promise<void>;
|
|
47
|
+
replaceContent(doc: RefinexDoc, options?: RefinexEventEmitOptions): void;
|
|
48
|
+
command<TValue = unknown>(name: string, payload?: unknown, options?: RefinexCommandDispatchOptions): Promise<RefinexCommandResult<TValue>>;
|
|
49
|
+
getJSON(): RefinexDoc | null;
|
|
50
|
+
getMarkdown(): string | null;
|
|
51
|
+
}
|
|
52
|
+
export interface RefinexMdContextValue extends UseRefinexMdResult {
|
|
53
|
+
readonly readonly: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface RefinexMenuRenderProps {
|
|
56
|
+
readonly editor: RefinexEditor | null;
|
|
57
|
+
readonly snapshot: RefinexReactSnapshot;
|
|
58
|
+
readonly readonly: boolean;
|
|
59
|
+
command<TValue = unknown>(name: string, payload?: unknown, options?: RefinexCommandDispatchOptions): Promise<RefinexCommandResult<TValue>>;
|
|
60
|
+
}
|
|
61
|
+
export interface RefinexMDEditorProps extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange' | 'onError' | 'children'> {
|
|
62
|
+
readonly value?: RefinexDoc;
|
|
63
|
+
readonly defaultValue?: RefinexDoc;
|
|
64
|
+
readonly onChange?: (doc: RefinexDoc, event: RefinexReactChangeEvent) => void;
|
|
65
|
+
readonly onSnapshot?: (snapshot: RefinexSnapshot) => void;
|
|
66
|
+
readonly onMount?: (editor: RefinexEditor) => void;
|
|
67
|
+
readonly onDestroy?: () => void;
|
|
68
|
+
readonly onError?: (error: Error) => void;
|
|
69
|
+
readonly readonly?: boolean;
|
|
70
|
+
readonly capabilities?: readonly RefinexCapabilityToken[];
|
|
71
|
+
readonly extensions?: readonly RefinexExtension[];
|
|
72
|
+
readonly viewDriver?: RefinexViewDriver;
|
|
73
|
+
readonly serializer?: (doc: RefinexDoc) => string;
|
|
74
|
+
readonly ssrHtml?: string;
|
|
75
|
+
readonly placeholder?: ReactNode;
|
|
76
|
+
readonly renderToolbar?: (props: RefinexMenuRenderProps) => ReactNode;
|
|
77
|
+
readonly children?: ReactNode | ((context: RefinexMdContextValue) => ReactNode);
|
|
78
|
+
}
|
|
79
|
+
export interface RefinexMDEditorHandle {
|
|
80
|
+
readonly editor: RefinexEditor | null;
|
|
81
|
+
focus(): void;
|
|
82
|
+
blur(): void;
|
|
83
|
+
destroy(): Promise<void>;
|
|
84
|
+
getJSON(): RefinexDoc | null;
|
|
85
|
+
getMarkdown(): string | null;
|
|
86
|
+
replaceContent(doc: RefinexDoc, options?: RefinexEventEmitOptions): void;
|
|
87
|
+
command<TValue = unknown>(name: string, payload?: unknown, options?: RefinexCommandDispatchOptions): Promise<RefinexCommandResult<TValue>>;
|
|
88
|
+
}
|
|
89
|
+
export interface BubbleMenuProps {
|
|
90
|
+
readonly editor?: RefinexEditor | null;
|
|
91
|
+
readonly disabled?: boolean;
|
|
92
|
+
readonly children?: ReactNode | ((props: RefinexMenuRenderProps) => ReactNode);
|
|
93
|
+
}
|
|
94
|
+
export interface RefinexSlashMenuItem {
|
|
95
|
+
readonly id: string;
|
|
96
|
+
readonly label: string;
|
|
97
|
+
readonly command?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface RefinexSlashMenuItemState {
|
|
100
|
+
readonly active: boolean;
|
|
101
|
+
readonly disabled: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface SlashMenuProps {
|
|
104
|
+
readonly editor?: RefinexEditor | null;
|
|
105
|
+
readonly disabled?: boolean;
|
|
106
|
+
readonly items?: readonly RefinexSlashMenuItem[];
|
|
107
|
+
readonly renderItem?: (item: RefinexSlashMenuItem, state: RefinexSlashMenuItemState) => ReactNode;
|
|
108
|
+
}
|
|
109
|
+
export interface BlockHandleProps {
|
|
110
|
+
readonly editor?: RefinexEditor | null;
|
|
111
|
+
readonly disabled?: boolean;
|
|
112
|
+
readonly blockId?: string | null;
|
|
113
|
+
readonly renderMenu?: (props: RefinexMenuRenderProps & {
|
|
114
|
+
readonly blockId: string | null;
|
|
115
|
+
}) => ReactNode;
|
|
116
|
+
}
|
|
117
|
+
export declare function useRefinexMd(options?: UseRefinexMdOptions): UseRefinexMdResult;
|
|
118
|
+
export declare const RefinexMDEditor: import('react').ForwardRefExoticComponent<RefinexMDEditorProps & import('react').RefAttributes<RefinexMDEditorHandle>>;
|
|
119
|
+
export declare function RefinexMdProvider(props: {
|
|
120
|
+
readonly value: RefinexMdContextValue;
|
|
121
|
+
readonly children?: ReactNode;
|
|
122
|
+
}): ReactElement;
|
|
123
|
+
export declare function useRefinexMdContext(): RefinexMdContextValue;
|
|
124
|
+
export declare function useRefinexSnapshot(): RefinexReactSnapshot;
|
|
125
|
+
export declare function BubbleMenu(props: BubbleMenuProps): ReactElement | null;
|
|
126
|
+
export declare function SlashMenu(props: SlashMenuProps): ReactElement | null;
|
|
127
|
+
export declare function BlockHandle(props: BlockHandleProps): ReactElement | null;
|
|
128
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAYL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAA;AAEd,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EACzB,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAE7B,KAAK,iBAAiB,EACvB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE3E,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAA;AAE1C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,oBAAoB,GAAG,KAAK,CAAA;IAC7C,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAA;IACzC,QAAQ,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI,CA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AC,KAAK,EAAE,gBAAgB,GAAG,YAAY,GAAG,IAAI,CAaxE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { createContext as j, forwardRef as L, useMemo as _, useImperativeHandle as G, createElement as h, useRef as S, useSyncExternalStore as T, useCallback as H, startTransition as W, useEffect as N, useContext as z } from "react";
|
|
2
|
+
import { createEditor as q } from "@refinex-md/core";
|
|
3
|
+
import { createProseViewDriver as A } from "@refinex-md/prose";
|
|
4
|
+
const O = j(null);
|
|
5
|
+
function K(e = {}) {
|
|
6
|
+
const r = Z(e), l = S(null), o = S(null), i = S(null), d = S(null), f = S(!1), C = e.value !== void 0, k = S(null);
|
|
7
|
+
k.current || (k.current = X(F(e)));
|
|
8
|
+
const m = k.current, y = T(m.subscribe, m.getSnapshot, m.getServerSnapshot), v = H((n) => {
|
|
9
|
+
W(() => {
|
|
10
|
+
m.setSnapshot(n);
|
|
11
|
+
});
|
|
12
|
+
}, [m]), w = H((n) => {
|
|
13
|
+
l.current = n;
|
|
14
|
+
}, []);
|
|
15
|
+
return N(() => {
|
|
16
|
+
if (e.mountOnInit === !1 || !l.current) return;
|
|
17
|
+
let n = !1;
|
|
18
|
+
const t = q({
|
|
19
|
+
initialDoc: r.current.value ?? r.current.defaultValue,
|
|
20
|
+
readonly: r.current.readonly,
|
|
21
|
+
capabilities: r.current.capabilities,
|
|
22
|
+
extensions: r.current.extensions,
|
|
23
|
+
viewDriver: r.current.viewDriver ?? A(),
|
|
24
|
+
serializer: r.current.serializer
|
|
25
|
+
});
|
|
26
|
+
o.current = t, d.current = r.current.value ? x(r.current.value) : null;
|
|
27
|
+
const b = [
|
|
28
|
+
t.on("snapshot", (c) => {
|
|
29
|
+
var R, E, P, B;
|
|
30
|
+
const u = c.payload, s = !f.current && c.origin === "api" && u.changedBlocks.length === 0;
|
|
31
|
+
f.current = !0;
|
|
32
|
+
const a = M(t, u, t.isReadonly, null);
|
|
33
|
+
v(a), (E = (R = r.current).onSnapshot) == null || E.call(R, u), !s && (c.origin !== "api" || !V(u.docJson, r.current.value)) && ((B = (P = r.current).onChange) == null || B.call(P, u.docJson, {
|
|
34
|
+
editor: t,
|
|
35
|
+
snapshot: u,
|
|
36
|
+
origin: c.origin,
|
|
37
|
+
changedBlocks: u.changedBlocks
|
|
38
|
+
}));
|
|
39
|
+
}),
|
|
40
|
+
t.on("error", (c) => {
|
|
41
|
+
var s, a;
|
|
42
|
+
const u = c.payload.error;
|
|
43
|
+
v(M(t, null, t.isReadonly, u)), (a = (s = r.current).onError) == null || a.call(s, u);
|
|
44
|
+
}),
|
|
45
|
+
t.on("modeChanged", () => {
|
|
46
|
+
v(M(t, null, t.isReadonly, null));
|
|
47
|
+
}),
|
|
48
|
+
t.on("destroyed", () => {
|
|
49
|
+
var c, u;
|
|
50
|
+
v(M(t, null, t.isReadonly, null)), (u = (c = r.current).onDestroy) == null || u.call(c);
|
|
51
|
+
})
|
|
52
|
+
];
|
|
53
|
+
v({
|
|
54
|
+
...m.getSnapshot(),
|
|
55
|
+
editor: t,
|
|
56
|
+
status: "mounting",
|
|
57
|
+
mounted: !1,
|
|
58
|
+
readonly: t.isReadonly,
|
|
59
|
+
error: null
|
|
60
|
+
});
|
|
61
|
+
const g = t.mount(l.current).then(() => {
|
|
62
|
+
var c, u;
|
|
63
|
+
n || (u = (c = r.current).onMount) == null || u.call(c, t);
|
|
64
|
+
}).catch((c) => {
|
|
65
|
+
var s, a;
|
|
66
|
+
const u = $(c);
|
|
67
|
+
v(M(t, null, t.isReadonly, u)), (a = (s = r.current).onError) == null || a.call(s, u);
|
|
68
|
+
});
|
|
69
|
+
return () => {
|
|
70
|
+
n = !0;
|
|
71
|
+
for (const u of b) u();
|
|
72
|
+
const c = g.finally(() => t.destroy());
|
|
73
|
+
i.current = c, c.finally(() => {
|
|
74
|
+
var u, s;
|
|
75
|
+
o.current === t && (o.current = null), (s = (u = r.current).onDestroy) == null || s.call(u);
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
}, [v, r, e.mountOnInit, m]), N(() => {
|
|
79
|
+
const n = o.current;
|
|
80
|
+
n && n.setMode(e.readonly === !0 ? "readonly" : "editable");
|
|
81
|
+
}, [e.readonly, y.status]), N(() => {
|
|
82
|
+
if (!C || !e.value) return;
|
|
83
|
+
const n = o.current;
|
|
84
|
+
if (!n || n.status !== "mounted") return;
|
|
85
|
+
const t = x(e.value);
|
|
86
|
+
if (d.current !== t) {
|
|
87
|
+
if (V(e.value, n.getJSON())) {
|
|
88
|
+
d.current = t;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
d.current = t, n.replaceContent(e.value, { origin: "api" });
|
|
92
|
+
}
|
|
93
|
+
}, [C, e.value, y.status]), _(() => ({
|
|
94
|
+
editor: y.editor,
|
|
95
|
+
snapshot: y,
|
|
96
|
+
containerRef: w,
|
|
97
|
+
mounted: y.mounted,
|
|
98
|
+
error: y.error,
|
|
99
|
+
focus() {
|
|
100
|
+
var n;
|
|
101
|
+
(n = o.current) == null || n.focus();
|
|
102
|
+
},
|
|
103
|
+
blur() {
|
|
104
|
+
var n;
|
|
105
|
+
(n = o.current) == null || n.blur();
|
|
106
|
+
},
|
|
107
|
+
async destroy() {
|
|
108
|
+
const n = o.current;
|
|
109
|
+
if (!n) {
|
|
110
|
+
await i.current;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
await n.destroy();
|
|
114
|
+
},
|
|
115
|
+
replaceContent(n, t) {
|
|
116
|
+
var b;
|
|
117
|
+
(b = o.current) == null || b.replaceContent(n, t);
|
|
118
|
+
},
|
|
119
|
+
command(n, t, b) {
|
|
120
|
+
var g;
|
|
121
|
+
return ((g = o.current) == null ? void 0 : g.command(n, t, b)) ?? Promise.resolve({
|
|
122
|
+
ok: !1,
|
|
123
|
+
error: new Error("Refinex editor is not mounted.")
|
|
124
|
+
});
|
|
125
|
+
},
|
|
126
|
+
getJSON() {
|
|
127
|
+
var n;
|
|
128
|
+
return ((n = o.current) == null ? void 0 : n.getJSON()) ?? null;
|
|
129
|
+
},
|
|
130
|
+
getMarkdown() {
|
|
131
|
+
var n;
|
|
132
|
+
try {
|
|
133
|
+
return ((n = o.current) == null ? void 0 : n.getMarkdown()) ?? null;
|
|
134
|
+
} catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}), [w, y]);
|
|
139
|
+
}
|
|
140
|
+
const ne = L(function(r, l) {
|
|
141
|
+
const {
|
|
142
|
+
value: o,
|
|
143
|
+
defaultValue: i,
|
|
144
|
+
onChange: d,
|
|
145
|
+
onSnapshot: f,
|
|
146
|
+
onMount: C,
|
|
147
|
+
onDestroy: k,
|
|
148
|
+
onError: m,
|
|
149
|
+
readonly: y,
|
|
150
|
+
capabilities: v,
|
|
151
|
+
extensions: w,
|
|
152
|
+
viewDriver: I,
|
|
153
|
+
serializer: n,
|
|
154
|
+
ssrHtml: t,
|
|
155
|
+
placeholder: b,
|
|
156
|
+
renderToolbar: g,
|
|
157
|
+
children: c,
|
|
158
|
+
className: u,
|
|
159
|
+
...s
|
|
160
|
+
} = r, a = K({
|
|
161
|
+
value: o,
|
|
162
|
+
defaultValue: i,
|
|
163
|
+
onChange: d,
|
|
164
|
+
onSnapshot: f,
|
|
165
|
+
onMount: C,
|
|
166
|
+
onDestroy: k,
|
|
167
|
+
onError: m,
|
|
168
|
+
readonly: y,
|
|
169
|
+
capabilities: v,
|
|
170
|
+
extensions: w,
|
|
171
|
+
viewDriver: I,
|
|
172
|
+
serializer: n
|
|
173
|
+
}), R = _(() => ({
|
|
174
|
+
...a,
|
|
175
|
+
readonly: a.snapshot.readonly
|
|
176
|
+
}), [a]), E = D(R);
|
|
177
|
+
G(l, () => ({
|
|
178
|
+
get editor() {
|
|
179
|
+
return a.editor;
|
|
180
|
+
},
|
|
181
|
+
focus: a.focus,
|
|
182
|
+
blur: a.blur,
|
|
183
|
+
destroy: a.destroy,
|
|
184
|
+
getJSON: a.getJSON,
|
|
185
|
+
getMarkdown: a.getMarkdown,
|
|
186
|
+
replaceContent: a.replaceContent,
|
|
187
|
+
command: a.command
|
|
188
|
+
}), [a]);
|
|
189
|
+
const P = typeof c == "function" ? c(R) : c;
|
|
190
|
+
return h(
|
|
191
|
+
Q,
|
|
192
|
+
{ value: R },
|
|
193
|
+
h(
|
|
194
|
+
"div",
|
|
195
|
+
{
|
|
196
|
+
...s,
|
|
197
|
+
className: ["rmd-react-editor", u].filter(Boolean).join(" "),
|
|
198
|
+
"data-rmd-react-status": a.snapshot.status
|
|
199
|
+
},
|
|
200
|
+
g == null ? void 0 : g(E),
|
|
201
|
+
h("div", {
|
|
202
|
+
ref: a.containerRef,
|
|
203
|
+
className: "rmd-react-editor__content",
|
|
204
|
+
suppressHydrationWarning: t !== void 0,
|
|
205
|
+
dangerouslySetInnerHTML: !a.mounted && t ? { __html: t } : void 0
|
|
206
|
+
}),
|
|
207
|
+
!a.mounted && !t ? b : null,
|
|
208
|
+
P
|
|
209
|
+
)
|
|
210
|
+
);
|
|
211
|
+
});
|
|
212
|
+
function Q(e) {
|
|
213
|
+
return h(O.Provider, e);
|
|
214
|
+
}
|
|
215
|
+
function U() {
|
|
216
|
+
const e = z(O);
|
|
217
|
+
if (!e) throw new Error("useRefinexMdContext must be used inside <RefinexMdProvider>.");
|
|
218
|
+
return e;
|
|
219
|
+
}
|
|
220
|
+
function te() {
|
|
221
|
+
return U().snapshot;
|
|
222
|
+
}
|
|
223
|
+
function oe(e) {
|
|
224
|
+
const r = J(), l = D(r, e.editor);
|
|
225
|
+
if (e.disabled) return null;
|
|
226
|
+
const o = typeof e.children == "function" ? e.children(l) : e.children;
|
|
227
|
+
return h("div", { "data-testid": "bubble-menu", "data-rmd-react-menu": "bubble" }, o);
|
|
228
|
+
}
|
|
229
|
+
function ue(e) {
|
|
230
|
+
const r = J(), l = D(r, e.editor);
|
|
231
|
+
if (e.disabled) return null;
|
|
232
|
+
const o = e.items ?? [];
|
|
233
|
+
return h(
|
|
234
|
+
"div",
|
|
235
|
+
{ "data-testid": "slash-menu", "data-rmd-react-menu": "slash" },
|
|
236
|
+
o.map((i, d) => {
|
|
237
|
+
var f;
|
|
238
|
+
return h(
|
|
239
|
+
"button",
|
|
240
|
+
{
|
|
241
|
+
key: i.id,
|
|
242
|
+
type: "button",
|
|
243
|
+
disabled: l.readonly,
|
|
244
|
+
onClick: () => {
|
|
245
|
+
i.command && l.command(i.command);
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
((f = e.renderItem) == null ? void 0 : f.call(e, i, { active: d === 0, disabled: l.readonly })) ?? i.label
|
|
249
|
+
);
|
|
250
|
+
})
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
function le(e) {
|
|
254
|
+
var o;
|
|
255
|
+
const r = J(), l = D(r, e.editor);
|
|
256
|
+
return e.disabled ? null : h(
|
|
257
|
+
"div",
|
|
258
|
+
{
|
|
259
|
+
"data-testid": "block-handle",
|
|
260
|
+
"data-rmd-react-menu": "block-handle",
|
|
261
|
+
"data-block-id": e.blockId ?? void 0
|
|
262
|
+
},
|
|
263
|
+
((o = e.renderMenu) == null ? void 0 : o.call(e, { ...l, blockId: e.blockId ?? null })) ?? null
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
function X(e) {
|
|
267
|
+
let r = e;
|
|
268
|
+
const l = /* @__PURE__ */ new Set();
|
|
269
|
+
return {
|
|
270
|
+
subscribe(o) {
|
|
271
|
+
return l.add(o), () => {
|
|
272
|
+
l.delete(o);
|
|
273
|
+
};
|
|
274
|
+
},
|
|
275
|
+
getSnapshot() {
|
|
276
|
+
return r;
|
|
277
|
+
},
|
|
278
|
+
getServerSnapshot() {
|
|
279
|
+
return e;
|
|
280
|
+
},
|
|
281
|
+
setSnapshot(o) {
|
|
282
|
+
if (!Object.is(r, o)) {
|
|
283
|
+
r = o;
|
|
284
|
+
for (const i of l) i();
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function F(e) {
|
|
290
|
+
var r;
|
|
291
|
+
return ((r = e.getServerSnapshot) == null ? void 0 : r.call(e)) ?? {
|
|
292
|
+
editor: null,
|
|
293
|
+
status: "ssr",
|
|
294
|
+
snapshot: null,
|
|
295
|
+
doc: e.value ?? e.defaultValue ?? null,
|
|
296
|
+
version: 0,
|
|
297
|
+
selection: null,
|
|
298
|
+
mounted: !1,
|
|
299
|
+
readonly: e.readonly === !0,
|
|
300
|
+
error: null
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
function M(e, r, l, o) {
|
|
304
|
+
return {
|
|
305
|
+
editor: e,
|
|
306
|
+
status: e.status,
|
|
307
|
+
snapshot: r,
|
|
308
|
+
doc: (r == null ? void 0 : r.docJson) ?? Y(e),
|
|
309
|
+
version: (r == null ? void 0 : r.version) ?? e.version,
|
|
310
|
+
selection: (r == null ? void 0 : r.selection) ?? null,
|
|
311
|
+
mounted: e.status === "mounted",
|
|
312
|
+
readonly: l,
|
|
313
|
+
error: o
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function Y(e) {
|
|
317
|
+
try {
|
|
318
|
+
return e.getJSON();
|
|
319
|
+
} catch {
|
|
320
|
+
return null;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
function D(e, r) {
|
|
324
|
+
const l = r ?? (e == null ? void 0 : e.editor) ?? null, o = (e == null ? void 0 : e.snapshot) ?? F({});
|
|
325
|
+
return {
|
|
326
|
+
editor: l,
|
|
327
|
+
snapshot: o,
|
|
328
|
+
readonly: (e == null ? void 0 : e.readonly) ?? !1,
|
|
329
|
+
command(i, d, f) {
|
|
330
|
+
return (l == null ? void 0 : l.command(i, d, f)) ?? Promise.resolve({
|
|
331
|
+
ok: !1,
|
|
332
|
+
error: new Error("Refinex editor is not mounted.")
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function J() {
|
|
338
|
+
return z(O);
|
|
339
|
+
}
|
|
340
|
+
function Z(e) {
|
|
341
|
+
const r = S(e);
|
|
342
|
+
return r.current = e, r;
|
|
343
|
+
}
|
|
344
|
+
function x(e) {
|
|
345
|
+
return JSON.stringify(e.content);
|
|
346
|
+
}
|
|
347
|
+
function V(e, r) {
|
|
348
|
+
return r !== void 0 && x(e) === x(r);
|
|
349
|
+
}
|
|
350
|
+
function $(e) {
|
|
351
|
+
return e instanceof Error ? e : new Error(String(e));
|
|
352
|
+
}
|
|
353
|
+
export {
|
|
354
|
+
le as BlockHandle,
|
|
355
|
+
oe as BubbleMenu,
|
|
356
|
+
ne as RefinexMDEditor,
|
|
357
|
+
Q as RefinexMdProvider,
|
|
358
|
+
ue as SlashMenu,
|
|
359
|
+
K as useRefinexMd,
|
|
360
|
+
U as useRefinexMdContext,
|
|
361
|
+
te as useRefinexSnapshot
|
|
362
|
+
};
|
|
363
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n createContext,\n createElement,\n forwardRef,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useSyncExternalStore,\n type HTMLAttributes,\n type ReactElement,\n type ReactNode,\n type RefCallback,\n} from 'react'\n\nimport {\n createEditor,\n type RefinexCommandDispatchOptions,\n type RefinexCommandResult,\n type RefinexEditor,\n type RefinexEventEmitOptions,\n type RefinexExtension,\n type RefinexRuntimeError,\n type RefinexRuntimeStatus,\n type RefinexSnapshot,\n type RefinexTransactionOrigin,\n type RefinexUnsubscribe,\n type RefinexViewDriver,\n} from '@refinex-md/core'\nimport { createProseViewDriver } from '@refinex-md/prose'\nimport type { RefinexCapabilityToken, RefinexDoc } from '@refinex-md/model'\n\nexport type RefinexReactValue = RefinexDoc\n\nexport interface RefinexReactSnapshot {\n readonly editor: RefinexEditor | null\n readonly status: RefinexRuntimeStatus | 'ssr'\n readonly snapshot: RefinexSnapshot | null\n readonly doc: RefinexDoc | null\n readonly version: number\n readonly selection: unknown\n readonly mounted: boolean\n readonly readonly: boolean\n readonly error: RefinexRuntimeError | Error | null\n}\n\nexport interface RefinexReactChangeEvent {\n readonly editor: RefinexEditor\n readonly snapshot: RefinexSnapshot\n readonly origin: RefinexTransactionOrigin\n readonly changedBlocks: readonly string[]\n}\n\nexport interface UseRefinexMdOptions {\n readonly value?: RefinexDoc\n readonly defaultValue?: RefinexDoc\n readonly onChange?: (doc: RefinexDoc, event: RefinexReactChangeEvent) => void\n readonly onSnapshot?: (snapshot: RefinexSnapshot) => void\n readonly onMount?: (editor: RefinexEditor) => void\n readonly onDestroy?: () => void\n readonly onError?: (error: Error) => void\n readonly readonly?: boolean\n readonly capabilities?: readonly RefinexCapabilityToken[]\n readonly extensions?: readonly RefinexExtension[]\n readonly viewDriver?: RefinexViewDriver\n readonly serializer?: (doc: RefinexDoc) => string\n readonly mountOnInit?: boolean\n readonly getServerSnapshot?: () => RefinexReactSnapshot\n}\n\nexport interface UseRefinexMdResult {\n readonly editor: RefinexEditor | null\n readonly snapshot: RefinexReactSnapshot\n readonly containerRef: RefCallback<HTMLElement>\n readonly mounted: boolean\n readonly error: Error | null\n focus(): void\n blur(): void\n destroy(): Promise<void>\n replaceContent(doc: RefinexDoc, options?: RefinexEventEmitOptions): void\n command<TValue = unknown>(\n name: string,\n payload?: unknown,\n options?: RefinexCommandDispatchOptions,\n ): Promise<RefinexCommandResult<TValue>>\n getJSON(): RefinexDoc | null\n getMarkdown(): string | null\n}\n\nexport interface RefinexMdContextValue extends UseRefinexMdResult {\n readonly readonly: boolean\n}\n\nexport interface RefinexMenuRenderProps {\n readonly editor: RefinexEditor | null\n readonly snapshot: RefinexReactSnapshot\n readonly readonly: boolean\n command<TValue = unknown>(\n name: string,\n payload?: unknown,\n options?: RefinexCommandDispatchOptions,\n ): Promise<RefinexCommandResult<TValue>>\n}\n\nexport interface RefinexMDEditorProps\n extends Omit<HTMLAttributes<HTMLDivElement>, 'defaultValue' | 'onChange' | 'onError' | 'children'> {\n readonly value?: RefinexDoc\n readonly defaultValue?: RefinexDoc\n readonly onChange?: (doc: RefinexDoc, event: RefinexReactChangeEvent) => void\n readonly onSnapshot?: (snapshot: RefinexSnapshot) => void\n readonly onMount?: (editor: RefinexEditor) => void\n readonly onDestroy?: () => void\n readonly onError?: (error: Error) => void\n readonly readonly?: boolean\n readonly capabilities?: readonly RefinexCapabilityToken[]\n readonly extensions?: readonly RefinexExtension[]\n readonly viewDriver?: RefinexViewDriver\n readonly serializer?: (doc: RefinexDoc) => string\n readonly ssrHtml?: string\n readonly placeholder?: ReactNode\n readonly renderToolbar?: (props: RefinexMenuRenderProps) => ReactNode\n readonly children?: ReactNode | ((context: RefinexMdContextValue) => ReactNode)\n}\n\nexport interface RefinexMDEditorHandle {\n readonly editor: RefinexEditor | null\n focus(): void\n blur(): void\n destroy(): Promise<void>\n getJSON(): RefinexDoc | null\n getMarkdown(): string | null\n replaceContent(doc: RefinexDoc, options?: RefinexEventEmitOptions): void\n command<TValue = unknown>(\n name: string,\n payload?: unknown,\n options?: RefinexCommandDispatchOptions,\n ): Promise<RefinexCommandResult<TValue>>\n}\n\nexport interface BubbleMenuProps {\n readonly editor?: RefinexEditor | null\n readonly disabled?: boolean\n readonly children?: ReactNode | ((props: RefinexMenuRenderProps) => ReactNode)\n}\n\nexport interface RefinexSlashMenuItem {\n readonly id: string\n readonly label: string\n readonly command?: string\n}\n\nexport interface RefinexSlashMenuItemState {\n readonly active: boolean\n readonly disabled: boolean\n}\n\nexport interface SlashMenuProps {\n readonly editor?: RefinexEditor | null\n readonly disabled?: boolean\n readonly items?: readonly RefinexSlashMenuItem[]\n readonly renderItem?: (item: RefinexSlashMenuItem, state: RefinexSlashMenuItemState) => ReactNode\n}\n\nexport interface BlockHandleProps {\n readonly editor?: RefinexEditor | null\n readonly disabled?: boolean\n readonly blockId?: string | null\n readonly renderMenu?: (props: RefinexMenuRenderProps & { readonly blockId: string | null }) => ReactNode\n}\n\ninterface RefinexReactStore {\n subscribe(callback: () => void): () => void\n getSnapshot(): RefinexReactSnapshot\n getServerSnapshot(): RefinexReactSnapshot\n setSnapshot(next: RefinexReactSnapshot): void\n}\n\nconst RefinexMdContext = createContext<RefinexMdContextValue | null>(null)\n\nexport function useRefinexMd(options: UseRefinexMdOptions = {}): UseRefinexMdResult {\n const callbacksRef = useLatest(options)\n const containerNodeRef = useRef<HTMLElement | null>(null)\n const editorRef = useRef<RefinexEditor | null>(null)\n const destroyPromiseRef = useRef<Promise<void> | null>(null)\n const controlledFingerprintRef = useRef<string | null>(null)\n const hasMountedSnapshotRef = useRef(false)\n const controlled = options.value !== undefined\n const storeRef = useRef<RefinexReactStore | null>(null)\n\n if (!storeRef.current) {\n storeRef.current = createReactStore(createServerSnapshot(options))\n }\n\n const store = storeRef.current\n const snapshot = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot)\n\n const applySnapshot = useCallback((next: RefinexReactSnapshot) => {\n startTransition(() => {\n store.setSnapshot(next)\n })\n }, [store])\n\n const containerRef = useCallback<RefCallback<HTMLElement>>((node) => {\n containerNodeRef.current = node\n }, [])\n\n useEffect(() => {\n if (options.mountOnInit === false || !containerNodeRef.current) return undefined\n\n let cancelled = false\n const editor = createEditor({\n initialDoc: callbacksRef.current.value ?? callbacksRef.current.defaultValue,\n readonly: callbacksRef.current.readonly,\n capabilities: callbacksRef.current.capabilities,\n extensions: callbacksRef.current.extensions,\n viewDriver: callbacksRef.current.viewDriver ?? createProseViewDriver(),\n serializer: callbacksRef.current.serializer,\n })\n editorRef.current = editor\n controlledFingerprintRef.current = callbacksRef.current.value ? fingerprintDoc(callbacksRef.current.value) : null\n\n const unsubscribes: RefinexUnsubscribe[] = [\n editor.on('snapshot', (event) => {\n const coreSnapshot = event.payload\n const initialSnapshot = !hasMountedSnapshotRef.current && event.origin === 'api' && coreSnapshot.changedBlocks.length === 0\n hasMountedSnapshotRef.current = true\n const nextSnapshot = toReactSnapshot(editor, coreSnapshot, editor.isReadonly, null)\n applySnapshot(nextSnapshot)\n callbacksRef.current.onSnapshot?.(coreSnapshot)\n if (!initialSnapshot && (event.origin !== 'api' || !sameDocFingerprint(coreSnapshot.docJson, callbacksRef.current.value))) {\n callbacksRef.current.onChange?.(coreSnapshot.docJson, {\n editor,\n snapshot: coreSnapshot,\n origin: event.origin,\n changedBlocks: coreSnapshot.changedBlocks,\n })\n }\n }),\n editor.on('error', (event) => {\n const error = event.payload.error\n applySnapshot(toReactSnapshot(editor, null, editor.isReadonly, error))\n callbacksRef.current.onError?.(error)\n }),\n editor.on('modeChanged', () => {\n applySnapshot(toReactSnapshot(editor, null, editor.isReadonly, null))\n }),\n editor.on('destroyed', () => {\n applySnapshot(toReactSnapshot(editor, null, editor.isReadonly, null))\n callbacksRef.current.onDestroy?.()\n }),\n ]\n\n applySnapshot({\n ...store.getSnapshot(),\n editor,\n status: 'mounting',\n mounted: false,\n readonly: editor.isReadonly,\n error: null,\n })\n\n const mountPromise = editor.mount(containerNodeRef.current).then(() => {\n if (cancelled) return\n callbacksRef.current.onMount?.(editor)\n }).catch((cause: unknown) => {\n const error = toError(cause)\n applySnapshot(toReactSnapshot(editor, null, editor.isReadonly, error))\n callbacksRef.current.onError?.(error)\n })\n\n return () => {\n cancelled = true\n for (const unsubscribe of unsubscribes) unsubscribe()\n const destroyPromise = mountPromise.finally(() => editor.destroy())\n destroyPromiseRef.current = destroyPromise\n void destroyPromise.finally(() => {\n if (editorRef.current === editor) editorRef.current = null\n callbacksRef.current.onDestroy?.()\n })\n }\n }, [applySnapshot, callbacksRef, options.mountOnInit, store])\n\n useEffect(() => {\n const editor = editorRef.current\n if (!editor) return\n editor.setMode(options.readonly === true ? 'readonly' : 'editable')\n }, [options.readonly, snapshot.status])\n\n useEffect(() => {\n if (!controlled || !options.value) return\n const editor = editorRef.current\n if (!editor || editor.status !== 'mounted') return\n const nextFingerprint = fingerprintDoc(options.value)\n if (controlledFingerprintRef.current === nextFingerprint) return\n if (sameDocFingerprint(options.value, editor.getJSON())) {\n controlledFingerprintRef.current = nextFingerprint\n return\n }\n controlledFingerprintRef.current = nextFingerprint\n editor.replaceContent(options.value, { origin: 'api' })\n }, [controlled, options.value, snapshot.status])\n\n const result = useMemo<UseRefinexMdResult>(() => ({\n editor: snapshot.editor,\n snapshot,\n containerRef,\n mounted: snapshot.mounted,\n error: snapshot.error,\n focus() {\n editorRef.current?.focus()\n },\n blur() {\n editorRef.current?.blur()\n },\n async destroy() {\n const editor = editorRef.current\n if (!editor) {\n await destroyPromiseRef.current\n return\n }\n await editor.destroy()\n },\n replaceContent(doc, replaceOptions) {\n editorRef.current?.replaceContent(doc, replaceOptions)\n },\n command(name, payload, commandOptions) {\n return editorRef.current?.command(name, payload, commandOptions) ?? Promise.resolve({\n ok: false,\n error: new Error('Refinex editor is not mounted.'),\n } as RefinexCommandResult<never>)\n },\n getJSON() {\n return editorRef.current?.getJSON() ?? null\n },\n getMarkdown() {\n try {\n return editorRef.current?.getMarkdown() ?? null\n } catch {\n return null\n }\n },\n }), [containerRef, snapshot])\n\n return result\n}\n\nexport const RefinexMDEditor = forwardRef<RefinexMDEditorHandle, RefinexMDEditorProps>(function RefinexMDEditor(\n props,\n ref,\n) {\n const {\n value,\n defaultValue,\n onChange,\n onSnapshot,\n onMount,\n onDestroy,\n onError,\n readonly,\n capabilities,\n extensions,\n viewDriver,\n serializer,\n ssrHtml,\n placeholder,\n renderToolbar,\n children,\n className,\n ...domProps\n } = props\n\n const adapter = useRefinexMd({\n value,\n defaultValue,\n onChange,\n onSnapshot,\n onMount,\n onDestroy,\n onError,\n readonly,\n capabilities,\n extensions,\n viewDriver,\n serializer,\n })\n\n const contextValue = useMemo<RefinexMdContextValue>(() => ({\n ...adapter,\n readonly: adapter.snapshot.readonly,\n }), [adapter])\n const menuProps = toMenuProps(contextValue)\n\n useImperativeHandle(ref, () => ({\n get editor() {\n return adapter.editor\n },\n focus: adapter.focus,\n blur: adapter.blur,\n destroy: adapter.destroy,\n getJSON: adapter.getJSON,\n getMarkdown: adapter.getMarkdown,\n replaceContent: adapter.replaceContent,\n command: adapter.command,\n }), [adapter])\n\n const renderedChildren = typeof children === 'function' ? children(contextValue) : children\n\n return createElement(\n RefinexMdProvider,\n { value: contextValue },\n createElement(\n 'div',\n {\n ...domProps,\n className: ['rmd-react-editor', className].filter(Boolean).join(' '),\n 'data-rmd-react-status': adapter.snapshot.status,\n },\n renderToolbar?.(menuProps),\n createElement('div', {\n ref: adapter.containerRef,\n className: 'rmd-react-editor__content',\n suppressHydrationWarning: ssrHtml !== undefined,\n dangerouslySetInnerHTML: !adapter.mounted && ssrHtml ? { __html: ssrHtml } : undefined,\n }),\n !adapter.mounted && !ssrHtml ? placeholder : null,\n renderedChildren,\n ),\n )\n})\n\nexport function RefinexMdProvider(props: {\n readonly value: RefinexMdContextValue\n readonly children?: ReactNode\n}): ReactElement {\n return createElement(RefinexMdContext.Provider, props)\n}\n\nexport function useRefinexMdContext(): RefinexMdContextValue {\n const context = useContext(RefinexMdContext)\n if (!context) throw new Error('useRefinexMdContext must be used inside <RefinexMdProvider>.')\n return context\n}\n\nexport function useRefinexSnapshot(): RefinexReactSnapshot {\n return useRefinexMdContext().snapshot\n}\n\nexport function BubbleMenu(props: BubbleMenuProps): ReactElement | null {\n const fallbackContext = useOptionalContext()\n const menuProps = toMenuProps(fallbackContext, props.editor)\n if (props.disabled) return null\n const children = typeof props.children === 'function' ? props.children(menuProps) : props.children\n return createElement('div', { 'data-testid': 'bubble-menu', 'data-rmd-react-menu': 'bubble' }, children)\n}\n\nexport function SlashMenu(props: SlashMenuProps): ReactElement | null {\n const fallbackContext = useOptionalContext()\n const menuProps = toMenuProps(fallbackContext, props.editor)\n if (props.disabled) return null\n const items = props.items ?? []\n return createElement(\n 'div',\n { 'data-testid': 'slash-menu', 'data-rmd-react-menu': 'slash' },\n items.map((item, index) => createElement(\n 'button',\n {\n key: item.id,\n type: 'button',\n disabled: menuProps.readonly,\n onClick: () => {\n if (item.command) void menuProps.command(item.command)\n },\n },\n props.renderItem?.(item, { active: index === 0, disabled: menuProps.readonly }) ?? item.label,\n )),\n )\n}\n\nexport function BlockHandle(props: BlockHandleProps): ReactElement | null {\n const fallbackContext = useOptionalContext()\n const menuProps = toMenuProps(fallbackContext, props.editor)\n if (props.disabled) return null\n return createElement(\n 'div',\n {\n 'data-testid': 'block-handle',\n 'data-rmd-react-menu': 'block-handle',\n 'data-block-id': props.blockId ?? undefined,\n },\n props.renderMenu?.({ ...menuProps, blockId: props.blockId ?? null }) ?? null,\n )\n}\n\nfunction createReactStore(initialSnapshot: RefinexReactSnapshot): RefinexReactStore {\n let current = initialSnapshot\n const listeners = new Set<() => void>()\n\n return {\n subscribe(callback) {\n listeners.add(callback)\n return () => {\n listeners.delete(callback)\n }\n },\n getSnapshot() {\n return current\n },\n getServerSnapshot() {\n return initialSnapshot\n },\n setSnapshot(next) {\n if (Object.is(current, next)) return\n current = next\n for (const listener of listeners) listener()\n },\n }\n}\n\nfunction createServerSnapshot(options: UseRefinexMdOptions): RefinexReactSnapshot {\n return options.getServerSnapshot?.() ?? {\n editor: null,\n status: 'ssr',\n snapshot: null,\n doc: options.value ?? options.defaultValue ?? null,\n version: 0,\n selection: null,\n mounted: false,\n readonly: options.readonly === true,\n error: null,\n }\n}\n\nfunction toReactSnapshot(\n editor: RefinexEditor,\n snapshot: RefinexSnapshot | null,\n readonly: boolean,\n error: RefinexRuntimeError | Error | null,\n): RefinexReactSnapshot {\n return {\n editor,\n status: editor.status,\n snapshot,\n doc: snapshot?.docJson ?? safeGetJSON(editor),\n version: snapshot?.version ?? editor.version,\n selection: snapshot?.selection ?? null,\n mounted: editor.status === 'mounted',\n readonly,\n error,\n }\n}\n\nfunction safeGetJSON(editor: RefinexEditor): RefinexDoc | null {\n try {\n return editor.getJSON()\n } catch {\n return null\n }\n}\n\nfunction toMenuProps(context: RefinexMdContextValue | null, editorOverride?: RefinexEditor | null): RefinexMenuRenderProps {\n const editor = editorOverride ?? context?.editor ?? null\n const snapshot = context?.snapshot ?? createServerSnapshot({})\n return {\n editor,\n snapshot,\n readonly: context?.readonly ?? false,\n command(name, payload, options) {\n return editor?.command(name, payload, options) ?? Promise.resolve({\n ok: false,\n error: new Error('Refinex editor is not mounted.'),\n } as RefinexCommandResult<never>)\n },\n }\n}\n\nfunction useOptionalContext(): RefinexMdContextValue | null {\n return useContext(RefinexMdContext)\n}\n\nfunction useLatest<T>(value: T): { readonly current: T } {\n const ref = useRef(value)\n ref.current = value\n return ref\n}\n\nfunction fingerprintDoc(doc: RefinexDoc): string {\n return JSON.stringify(doc.content)\n}\n\nfunction sameDocFingerprint(left: RefinexDoc, right: RefinexDoc | undefined): boolean {\n return right !== undefined && fingerprintDoc(left) === fingerprintDoc(right)\n}\n\nfunction toError(cause: unknown): Error {\n return cause instanceof Error ? cause : new Error(String(cause))\n}\n"],"names":["RefinexMdContext","createContext","useRefinexMd","options","callbacksRef","useLatest","containerNodeRef","useRef","editorRef","destroyPromiseRef","controlledFingerprintRef","hasMountedSnapshotRef","controlled","storeRef","createReactStore","createServerSnapshot","store","snapshot","useSyncExternalStore","applySnapshot","useCallback","next","startTransition","containerRef","node","useEffect","cancelled","editor","createEditor","createProseViewDriver","fingerprintDoc","unsubscribes","event","coreSnapshot","initialSnapshot","nextSnapshot","toReactSnapshot","_b","_a","sameDocFingerprint","_d","_c","error","mountPromise","cause","toError","unsubscribe","destroyPromise","nextFingerprint","useMemo","doc","replaceOptions","name","payload","commandOptions","RefinexMDEditor","forwardRef","props","ref","value","defaultValue","onChange","onSnapshot","onMount","onDestroy","onError","readonly","capabilities","extensions","viewDriver","serializer","ssrHtml","placeholder","renderToolbar","children","className","domProps","adapter","contextValue","menuProps","toMenuProps","useImperativeHandle","renderedChildren","createElement","RefinexMdProvider","useRefinexMdContext","context","useContext","useRefinexSnapshot","BubbleMenu","fallbackContext","useOptionalContext","SlashMenu","items","item","index","BlockHandle","current","listeners","callback","listener","safeGetJSON","editorOverride","left","right"],"mappings":";;;AAoLA,MA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AAA,IACA,UAAAV;AAAA,IACA,WAAUqE,KAAA,gBAAAA,EAAS,aAAY;AAAA,IAC/B,QAAQlC,GAAMC,GAASlD,GAAS;AAC9B,cAAOwB,KAAA,gBAAAA,EAAQ,QAAQyB,GAAMC,GAASlD,OAAY,QAAQ,QAAQ;AAAA,QAChE,IAAI;AAAA,QACJ,OAAO,IAAI,MAAM,gCAAgC;AAAA,MAAA,CACnB;AAAA,IAClC;AAAA,EAAA;AAEJ;AAEA,SAASwF,IAAmD;AAC1D,SAAOJ,EAAWvF,CAAgB;AACpC;AAEA,SAASK,EAAasD,GAAmC;AACvD,QAAMD,IAAMnD,EAAOoD,CAAK;AACxB,SAAAD,EAAI,UAAUC,GACPD;AACT;AAEA,SAAS5B,EAAeoB,GAAyB;AAC/C,SAAO,KAAK,UAAUA,EAAI,OAAO;AACnC;AAEA,SAASX,EAAmBgE,GAAkBC,GAAwC;AACpF,SAAOA,MAAU,UAAa1E,EAAeyE,CAAI,MAAMzE,EAAe0E,CAAK;AAC7E;AAEA,SAAS3D,EAAQD,GAAuB;AACtC,SAAOA,aAAiB,QAAQA,IAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC;AACjE;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@refinex-md/react",
|
|
3
|
+
"version": "0.1.0-canary.0",
|
|
4
|
+
"description": "React adapter, hooks, and components for Refinex MD Editor.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"module": "./dist/index.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md"
|
|
19
|
+
],
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"react": ">=18.2 <20",
|
|
22
|
+
"react-dom": ">=18.2 <20"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@refinex-md/core": "0.1.0-canary.0",
|
|
26
|
+
"@refinex-md/model": "0.1.0-canary.0",
|
|
27
|
+
"@refinex-md/prose": "0.1.0-canary.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@refinex-md/testing": "0.1.0-canary.0",
|
|
31
|
+
"@testing-library/react": "^16.0.0",
|
|
32
|
+
"@types/react": "^18.3.0",
|
|
33
|
+
"@types/react-dom": "^18.3.0",
|
|
34
|
+
"jsdom": "^26.0.0",
|
|
35
|
+
"react": "^18.3.0",
|
|
36
|
+
"react-dom": "^18.3.0",
|
|
37
|
+
"typescript": "^5.7.0",
|
|
38
|
+
"vite": "^6.0.0",
|
|
39
|
+
"vitest": "^3.0.0"
|
|
40
|
+
},
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/Refinex-Space/Refinex-Md-Editor.git",
|
|
44
|
+
"directory": "packages/react"
|
|
45
|
+
},
|
|
46
|
+
"homepage": "https://github.com/Refinex-Space/Refinex-Md-Editor#readme",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/Refinex-Space/Refinex-Md-Editor/issues"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public",
|
|
52
|
+
"provenance": true
|
|
53
|
+
},
|
|
54
|
+
"sideEffects": false,
|
|
55
|
+
"scripts": {
|
|
56
|
+
"build": "vite build",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"test:watch": "vitest"
|
|
59
|
+
}
|
|
60
|
+
}
|