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.

67 lines (63 loc) 2.62 kB
'use strict'; var jsxRuntime = require('preact/jsx-runtime'); require('../../schema/paragraph.js'); require('../../schema/phrase.js'); var isSpecType = require('../../schema/utils/isSpecType.js'); var Heading = require('./Heading.js'); var TextLine = require('./TextLine.js'); var Bullets = require('./Bullets.js'); require('../context/hooks/theme.js'); var plugin = require('../context/hooks/plugin.js'); var event = require('../context/hooks/event.js'); require('../../plugin/index.js'); require('tslib'); require('../../theme/seed/index.js'); var hooks = require('preact/hooks'); var functionalize = require('../../utils/functionalize.js'); require('clarinet'); require('../styled/bullet.js'); require('../styled/container.js'); require('../styled/entity.js'); require('../styled/heading.js'); require('../styled/marks.js'); require('../styled/paragraph.js'); require('preact'); function Paragraph(_a) { var spec = _a.spec; var pluginManager = plugin.usePluginManager(); var onEvent = event.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 = hooks.useMemo(function () { if (isSpecType.isCustomParagraph(spec)) { var descriptor = pluginManager.getBlockDescriptor(spec.customType); if (descriptor) { return functionalize.functionalize(descriptor.render, null)(spec); } } return null; }, [spec]); if (paragraphContent) { return (jsxRuntime.jsx("div", { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dangerouslySetInnerHTML: { __html: paragraphContent.outerHTML } })); } if (isSpecType.isHeadingParagraph(spec)) { content = jsxRuntime.jsx(Heading.Heading, { spec: spec }); } if (isSpecType.isTextParagraph(spec)) { content = jsxRuntime.jsx(TextLine.TextLine, { spec: spec }); } if (isSpecType.isBulletParagraph(spec)) { content = jsxRuntime.jsx(Bullets.Bullets, { spec: spec }); } return content ? (jsxRuntime.jsx("div", { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, children: content })) : null; } exports.Paragraph = Paragraph; //# sourceMappingURL=index.js.map