Skip to content

Commit 86f6fce

Browse files
committed
feat(json-crdt-peritext-ui): 🎸 create link element renderer
1 parent 5e81da9 commit 86f6fce

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// biome-ignore lint: React is used for JSX
2+
import * as React from 'react';
3+
import {rule} from 'nano-theme';
4+
5+
const delClass = rule({
6+
col: 'blue',
7+
});
8+
9+
export interface LinkProps {
10+
children: React.ReactNode;
11+
}
12+
13+
export const Link: React.FC<LinkProps> = (props) => {
14+
const {children} = props;
15+
16+
return <a className={delClass}>{children}</a>;
17+
};

src/json-crdt-peritext-ui/plugins/toolbar/inline/RenderInline.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {Code} from './Code';
66
import {Kbd} from './Kbd';
77
import {Ins} from './Ins';
88
import {Del} from './Del';
9+
import {Link} from './Link';
910
import type {InlineViewProps} from '../../../web/react/InlineView';
1011

1112
export interface RenderInlineProps extends InlineViewProps {
@@ -16,6 +17,7 @@ export const RenderInline: React.FC<RenderInlineProps> = (props) => {
1617
const {inline, children} = props;
1718
const attrs = inline.attr();
1819
let element = children;
20+
if (attrs[CommonSliceType.a]) element = <Link>{element}</Link>;
1921
if (attrs[CommonSliceType.mark]) element = <mark>{element}</mark>;
2022
if (attrs[CommonSliceType.sup]) element = <sup>{element}</sup>;
2123
if (attrs[CommonSliceType.sub]) element = <sub>{element}</sub>;

0 commit comments

Comments
 (0)