json-joy
Version:
Collection of libraries for building collaborative editing apps.
12 lines (11 loc) • 428 B
JavaScript
import { usePeritext } from '../context';
import { Char } from '../../constants';
export const AnchorView = (props) => {
const { plugins } = usePeritext();
// This zero-width non-breaking space prevents word wrapping at position where
// anchor is inserted.
let children = Char.ZeroLengthSpace;
for (const map of plugins)
children = map.anchor?.(props, children) ?? children;
return children;
};