From 5cdb9e1e2fa4ad5abdb3659bb35d0b3edc60123c Mon Sep 17 00:00:00 2001 From: Luan Date: Fri, 7 Jun 2024 14:15:44 -0300 Subject: [PATCH] fix(InfoPanelContainer): Use new attributed text prop + And update other related nodes. --- src/parser/classes/InfoPanelContainer.ts | 8 ++++++++ src/parser/classes/InfoPanelContent.ts | 5 +++-- src/parser/classes/misc/Text.ts | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/parser/classes/InfoPanelContainer.ts b/src/parser/classes/InfoPanelContainer.ts index 7b0b7f49..d8c8eb69 100644 --- a/src/parser/classes/InfoPanelContainer.ts +++ b/src/parser/classes/InfoPanelContainer.ts @@ -3,6 +3,7 @@ import { Parser, type RawNode } from '../index.js'; import InfoPanelContent from './InfoPanelContent.js'; import Menu from './menus/Menu.js'; import Text from './misc/Text.js'; +import NavigationEndpoint from './NavigationEndpoint.js'; export default class InfoPanelContainer extends YTNode { static type = 'InfoPanelContainer'; @@ -10,7 +11,9 @@ export default class InfoPanelContainer extends YTNode { title: Text; menu: Menu | null; content: InfoPanelContent | null; + header_endpoint?: NavigationEndpoint; background: string; + title_style?: string; icon_type?: string; constructor(data: RawNode) { @@ -18,7 +21,12 @@ export default class InfoPanelContainer extends YTNode { this.title = new Text(data.title); this.menu = Parser.parseItem(data.menu, Menu); this.content = Parser.parseItem(data.content, InfoPanelContent); + + if (data.headerEndpoint) + this.header_endpoint = new NavigationEndpoint(data.headerEndpoint); + this.background = data.background; + this.title_style = data.titleStyle; if (Reflect.has(data, 'icon')) { this.icon_type = data.icon?.iconType; diff --git a/src/parser/classes/InfoPanelContent.ts b/src/parser/classes/InfoPanelContent.ts index ea33df03..b25d9656 100644 --- a/src/parser/classes/InfoPanelContent.ts +++ b/src/parser/classes/InfoPanelContent.ts @@ -1,5 +1,6 @@ import { YTNode } from '../helpers.js'; import type { RawNode } from '../index.js'; +import type { AttributedText } from './misc/Text.js'; import Text from './misc/Text.js'; import Thumbnail from './misc/Thumbnail.js'; import NavigationEndpoint from './NavigationEndpoint.js'; @@ -9,7 +10,7 @@ export default class InfoPanelContent extends YTNode { title: Text; source: Text; - paragraphs: Text[]; + attributed_paragraphs: Text[]; thumbnail: Thumbnail[]; source_endpoint: NavigationEndpoint; truncate_paragraphs: boolean; @@ -20,7 +21,7 @@ export default class InfoPanelContent extends YTNode { super(); this.title = new Text(data.title); this.source = new Text(data.source); - this.paragraphs = data.paragraphs.map((p: RawNode) => new Text(p)); + this.attributed_paragraphs = data.attributedParagraphs.map((p: AttributedText) => Text.fromAttributed(p)); this.thumbnail = Thumbnail.fromResponse(data.thumbnail); this.source_endpoint = new NavigationEndpoint(data.sourceEndpoint); this.truncate_paragraphs = !!data.truncateParagraphs; diff --git a/src/parser/classes/misc/Text.ts b/src/parser/classes/misc/Text.ts index 3e1f3a1d..b05fb64d 100644 --- a/src/parser/classes/misc/Text.ts +++ b/src/parser/classes/misc/Text.ts @@ -258,7 +258,7 @@ interface RawRun { startIndex: number; } -interface AttributedText { +export interface AttributedText { content: string; styleRuns?: StyleRun[]; commandRuns?: CommandRun[];