UNPKG

@antv/t8

Version:

T8 is a text visualization solution for unstructured data within the AntV technology stack, and it is a declarative JSON Schema syntax that can be used to describe the content of data interpretation reports.

65 lines (62 loc) 2.49 kB
import { jsx } from 'preact/jsx-runtime'; import '../../schema/paragraph.js'; import '../../schema/phrase.js'; import { isCustomParagraph, isHeadingParagraph, isTextParagraph, isBulletParagraph } from '../../schema/utils/isSpecType.js'; import { Heading } from './Heading.js'; import { TextLine } from './TextLine.js'; import { Bullets } from './Bullets.js'; import '../context/hooks/theme.js'; import { usePluginManager } from '../context/hooks/plugin.js'; import { useEvent } from '../context/hooks/event.js'; import '../../plugin/index.js'; import 'tslib'; import '../../theme/seed/index.js'; import { useMemo } from 'preact/hooks'; import { functionalize } from '../../utils/functionalize.js'; import 'clarinet'; import '../styled/bullet.js'; import '../styled/container.js'; import '../styled/entity.js'; import '../styled/heading.js'; import '../styled/marks.js'; import '../styled/paragraph.js'; import 'preact'; function Paragraph(_a) { var spec = _a.spec; var pluginManager = usePluginManager(); var onEvent = useEvent().onEvent; var onClick = function () { onEvent === null || onEvent === void 0 ? void 0 : onEvent('paragraph:click', spec); }; var onMouseEnter = function () { onEvent === null || onEvent === void 0 ? void 0 : onEvent('paragraph:mouseenter', spec); }; var onMouseLeave = function () { onEvent === null || onEvent === void 0 ? void 0 : onEvent('paragraph:mouseleave', spec); }; var content = null; var paragraphContent = useMemo(function () { if (isCustomParagraph(spec)) { var descriptor = pluginManager.getBlockDescriptor(spec.customType); if (descriptor) { return functionalize(descriptor.render, null)(spec); } } return null; }, [spec]); if (paragraphContent) { return (jsx("div", { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dangerouslySetInnerHTML: { __html: paragraphContent.outerHTML } })); } if (isHeadingParagraph(spec)) { content = jsx(Heading, { spec: spec }); } if (isTextParagraph(spec)) { content = jsx(TextLine, { spec: spec }); } if (isBulletParagraph(spec)) { content = jsx(Bullets, { spec: spec }); } return content ? (jsx("div", { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: content })) : null; } export { Paragraph }; //# sourceMappingURL=index.js.map