UNPKG

@antv/t8

Version:

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

60 lines (56 loc) 2.77 kB
'use strict'; var isType = require('../../utils/isType.js'); var paragraph = require('../paragraph.js'); var phrase = require('../phrase.js'); function isCustomSection(spec) { return !!spec && isType.isObject(spec) && 'customType' in spec; } function isCustomParagraph(spec) { return isType.isObject(spec) && 'customType' in spec; } function isStandardSection(spec) { return isType.isObject(spec) && 'paragraphs' in spec && Array.isArray(spec === null || spec === void 0 ? void 0 : spec.paragraphs); } function isTextParagraph(spec) { return isType.isObject(spec) && (spec === null || spec === void 0 ? void 0 : spec.type) === paragraph.ParagraphType.NORMAL && Array.isArray(spec === null || spec === void 0 ? void 0 : spec.phrases); } function isBulletParagraph(spec) { return isType.isObject(spec) && (spec === null || spec === void 0 ? void 0 : spec.type) === paragraph.ParagraphType.BULLETS && Array.isArray(spec === null || spec === void 0 ? void 0 : spec.bullets); } function isHeadingParagraph(spec) { if (!!spec && isType.isObject(spec) && 'type' in spec && isType.isString(spec.type)) { var weight = getHeadingWeight(spec === null || spec === void 0 ? void 0 : spec.type); return spec.type.startsWith('heading') && !Number.isNaN(weight); } return false; } function isCustomPhrase(spec) { var _a; return spec.type === phrase.PhraseType.CUSTOM && !!((_a = spec === null || spec === void 0 ? void 0 : spec.metadata) === null || _a === void 0 ? void 0 : _a.customType); } function isEntityPhrase(spec) { var _a, _b; return (spec.type === phrase.PhraseType.ENTITY && !!((_a = spec === null || spec === void 0 ? void 0 : spec.metadata) === null || _a === void 0 ? void 0 : _a.entityType) && phrase.EntityType.includes((_b = spec === null || spec === void 0 ? void 0 : spec.metadata) === null || _b === void 0 ? void 0 : _b.entityType)); } function isTextPhrase(spec) { return spec.type === phrase.PhraseType.TEXT; } function getHeadingWeight(pType) { if (pType === null || pType === void 0 ? void 0 : pType.startsWith('heading')) { var weight = Number(pType === null || pType === void 0 ? void 0 : pType.slice(-1)); if (weight >= 1 && weight <= 6) return weight; } return NaN; } exports.getHeadingWeight = getHeadingWeight; exports.isBulletParagraph = isBulletParagraph; exports.isCustomParagraph = isCustomParagraph; exports.isCustomPhrase = isCustomPhrase; exports.isCustomSection = isCustomSection; exports.isEntityPhrase = isEntityPhrase; exports.isHeadingParagraph = isHeadingParagraph; exports.isStandardSection = isStandardSection; exports.isTextParagraph = isTextParagraph; exports.isTextPhrase = isTextPhrase; //# sourceMappingURL=isSpecType.js.map