Skip to content

Commit 0b585fa

Browse files
committed
refactor(json-crdt-peritext-ui): 💡 rename plugin export symbols
1 parent 43e86c6 commit 0b585fa

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/json-crdt-peritext-ui/__demos__/components/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const App: React.FC = () => {
2222
<Provider theme={'light'}>
2323
<GlobalCss />
2424
<div style={{maxWidth: '690px', fontSize: '21px', lineHeight: '1.7em', margin: '32px auto'}}>
25-
<PeritextView peritext={peritext} renderers={[cursorPlugin, renderers, debugRenderers({enabled: false})]} />
25+
<PeritextView peritext={peritext} plugins={[cursorPlugin, renderers, debugRenderers({enabled: false})]} />
2626
</div>
2727
</Provider>
2828
);

src/json-crdt-peritext-ui/plugins/minimal/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {PeritextPlugin} from '../../react/types';
1010

1111
const h = React.createElement;
1212

13-
export const renderers: PeritextPlugin = {
13+
export const defaultPlugin: PeritextPlugin = {
1414
text,
1515
caret: (props, children) => h(RenderCaret, <any>props, children),
1616
focus: (props, children) => h(RenderFocus, <any>props, children),

src/json-crdt-peritext-ui/react/PeritextView.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {context, type PeritextSurfaceContextValue} from './context';
44
import {CssClass} from '../constants';
55
import {BlockView} from './BlockView';
66
import {DomController} from '../dom/DomController';
7-
import {renderers as defaultRenderers} from '../plugins/minimal';
7+
import {cursorPlugin} from '../plugins/cursor';
8+
import {defaultPlugin} from '../plugins/minimal';
89
import type {Peritext} from '../../json-crdt-extensions/peritext/Peritext';
910
import type {PeritextPlugin} from './types';
1011

@@ -33,13 +34,13 @@ put('.' + CssClass.Inline, {
3334
*/
3435
export interface PeritextViewProps {
3536
peritext: Peritext;
36-
renderers?: PeritextPlugin[];
37+
plugins?: PeritextPlugin[];
3738
onRender?: () => void;
3839
}
3940

4041
/** @todo Is `React.memo` needed here? */
4142
export const PeritextView: React.FC<PeritextViewProps> = React.memo((props) => {
42-
const {peritext, renderers = [defaultRenderers], onRender} = props;
43+
const {peritext, plugins = [cursorPlugin, defaultPlugin], onRender} = props;
4344
const [, setTick] = React.useState(0);
4445
const [dom, setDom] = React.useState<DomController | undefined>(undefined);
4546

@@ -71,8 +72,8 @@ export const PeritextView: React.FC<PeritextViewProps> = React.memo((props) => {
7172
);
7273

7374
const ctx: undefined | PeritextSurfaceContextValue = React.useMemo(
74-
() => (dom ? {peritext, dom, renderers, rerender} : undefined),
75-
[peritext, dom, renderers, rerender],
75+
() => (dom ? {peritext, dom, renderers: plugins, rerender} : undefined),
76+
[peritext, dom, plugins, rerender],
7677
);
7778

7879
const block = peritext.blocks.root;
@@ -88,7 +89,7 @@ export const PeritextView: React.FC<PeritextViewProps> = React.memo((props) => {
8889
</div>
8990
);
9091

91-
for (const map of renderers) children = map.peritext?.(props, children, ctx) ?? children;
92+
for (const map of plugins) children = map.peritext?.(props, children, ctx) ?? children;
9293

9394
return children;
9495
});

0 commit comments

Comments
 (0)