diff --git a/packages/ava/src/ntv/schema/common.ts b/packages/ava/src/ntv/schema/common.ts index 2b0ff43c..7d2007f1 100644 --- a/packages/ava/src/ntv/schema/common.ts +++ b/packages/ava/src/ntv/schema/common.ts @@ -11,6 +11,7 @@ export type CommonProps = { export type CustomBlockElement = CommonProps & { // customType is required for custom block structure customType: string; + metadata?: BlockMetaData; [key: string]: unknown; }; @@ -20,3 +21,10 @@ export type CustomMetaData = { customType: string; [key: string]: unknown; }; + +/** block element (section,paragraph) metadata info */ +export type BlockMetaData = Partial<{ + /** if element is generate by loop */ + loopId: string; + // TODO 之后这里还会扩展条件判断等... +}>; diff --git a/packages/ava/src/ntv/schema/paragraph.ts b/packages/ava/src/ntv/schema/paragraph.ts index 26b0a56d..b9dbe9b6 100644 --- a/packages/ava/src/ntv/schema/paragraph.ts +++ b/packages/ava/src/ntv/schema/paragraph.ts @@ -1,5 +1,5 @@ import type { PhraseSpec } from './phrase'; -import type { CommonProps, CustomBlockElement } from './common'; +import type { CommonProps, CustomBlockElement, BlockMetaData } from './common'; export type ParagraphSpec = HeadingParagraphSpec | TextParagraphSpec | BulletsParagraphSpec | CustomBlockElement; @@ -25,12 +25,14 @@ export type TextParagraphSpec = CommonProps & { type: 'normal'; phrases: PhraseSpec[]; indents?: ParagraphIndent[]; + metadata?: BlockMetaData; }; export type BulletsParagraphSpec = CommonProps & { type: 'bullets'; isOrder: boolean; bullets: BulletItemSpec[]; + metadata?: BlockMetaData; }; export type BulletItemSpec = CommonProps & { @@ -38,4 +40,5 @@ export type BulletItemSpec = CommonProps & { phrases: PhraseSpec[]; // nested list subBullet?: BulletsParagraphSpec; + metadata?: BlockMetaData; }; diff --git a/packages/ava/src/ntv/schema/structure.ts b/packages/ava/src/ntv/schema/structure.ts index d5cb0c57..1e0b924a 100644 --- a/packages/ava/src/ntv/schema/structure.ts +++ b/packages/ava/src/ntv/schema/structure.ts @@ -1,4 +1,4 @@ -import type { CommonProps, CustomBlockElement } from './common'; +import type { CommonProps, CustomBlockElement, BlockMetaData } from './common'; import type { PhraseSpec } from './phrase'; import type { ParagraphSpec } from './paragraph'; @@ -12,8 +12,9 @@ export type HeadlineSpec = CommonProps & { phrases: PhraseSpec[]; }; -export type StandardSectionSpec = { +export type StandardSectionSpec = CommonProps & { paragraphs?: ParagraphSpec[]; + metadata?: BlockMetaData; }; -export type SectionSpec = (StandardSectionSpec | CustomBlockElement) & CommonProps; +export type SectionSpec = StandardSectionSpec | CustomBlockElement;