UNPKG

json-joy

Version:

Collection of libraries for building collaborative editing apps.

39 lines (38 loc) 1.53 kB
// biome-ignore lint: React is used for JSX import * as React from 'react'; import { CommonSliceType } from '../../../../json-crdt-extensions'; import { Spoiler } from './Spoiler'; import { Code } from './Code'; import { Kbd } from './Kbd'; import { Ins } from './Ins'; import { Del } from './Del'; export const RenderInline = (props) => { const { inline, children } = props; const attrs = inline.attr(); let element = children; if (attrs[CommonSliceType.mark]) element = React.createElement("mark", null, element); if (attrs[CommonSliceType.sup]) element = React.createElement("sup", null, element); if (attrs[CommonSliceType.sub]) element = React.createElement("sub", null, element); if (attrs[CommonSliceType.math]) element = React.createElement("code", null, element); if (attrs[CommonSliceType.ins]) element = React.createElement(Ins, null, element); if (attrs[CommonSliceType.del]) element = React.createElement(Del, null, element); if (attrs[CommonSliceType.code]) { const attr = attrs[CommonSliceType.code][0]; if (attr) element = React.createElement(Code, { attr: attr }, element); } if (attrs[CommonSliceType.kbd]) { const attr = attrs[CommonSliceType.kbd][0]; if (attr) element = React.createElement(Kbd, { attr: attr }, element); } if (attrs[CommonSliceType.spoiler]) element = React.createElement(Spoiler, null, element); return element; };