Telegram-iOS/submodules/TelegramCore/FlatSerialization/Models/InstantPageBlock.fbs
isaac 81e3be1923 InstantPage list checkboxes (task-list style): parse, serialize, render
Add a first-class `checked: Bool?` to InstantPageListItem (orthogonal to the
ordered-list `num`), replacing the prior sentinel-string-in-num prototype.

- Data model: enum third associated value on .text/.blocks; Postbox + a new
  FlatBuffers `checkState` tri-state field (0=nil,1=unchecked,2=checked,
  backward-compatible); Equatable.
- Transmission: read/write the native API `checkbox`=flags.0 / `checked`=flags.1
  bits on all four PageListItem / PageListOrderedItem constructors, so checkbox
  state survives the server round-trip for sender and recipients.
- Markdown: forward parser routes detected `[ ]`/`[x]` into `checked` (keeping
  the real number for ordered items); reverse converter emits `- [ ]`/`- [x]`
  so editing a rich message round-trips.
- Display: V1 + V2 layout detect via `item.checked`; the V2 renderer draws real
  CheckNode artwork (was a placeholder); preview text shows a checkbox glyph
  instead of leaking the old sentinel.

Spec: docs/superpowers/specs/2026-05-27-instantpage-list-checkbox-design.md
Plan: docs/superpowers/plans/2026-05-27-instantpage-list-checkbox.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 16:44:47 +02:00

249 lines
5.7 KiB
Text

include "RichText.fbs";
include "MediaId.fbs";
include "TelegramChannel.fbs";
include "PixelDimensions.fbs";
include "RichText.fbs";
namespace TelegramCore;
union InstantPageBlock_Value {
InstantPageBlock_Unsupported,
InstantPageBlock_Title,
InstantPageBlock_Subtitle,
InstantPageBlock_AuthorDate,
InstantPageBlock_Header,
InstantPageBlock_Subheader,
InstantPageBlock_Paragraph,
InstantPageBlock_Preformatted,
InstantPageBlock_Footer,
InstantPageBlock_Divider,
InstantPageBlock_Anchor,
InstantPageBlock_List,
InstantPageBlock_BlockQuote,
InstantPageBlock_PullQuote,
InstantPageBlock_Image,
InstantPageBlock_Video,
InstantPageBlock_Audio,
InstantPageBlock_Cover,
InstantPageBlock_WebEmbed,
InstantPageBlock_PostEmbed,
InstantPageBlock_Collage,
InstantPageBlock_Slideshow,
InstantPageBlock_ChannelBanner,
InstantPageBlock_Kicker,
InstantPageBlock_Table,
InstantPageBlock_Details,
InstantPageBlock_RelatedArticles,
InstantPageBlock_Map,
InstantPageBlock_Heading,
InstantPageBlock_Formula
}
table InstantPageBlock {
value:InstantPageBlock_Value (id: 1, required);
}
table InstantPageBlock_Unsupported {}
table InstantPageBlock_Title {
text:RichText (id: 0, required);
}
table InstantPageBlock_Subtitle {
text:RichText (id: 0, required);
}
table InstantPageBlock_AuthorDate {
author:RichText (id: 0, required);
date:int32 (id: 1);
}
table InstantPageBlock_Header {
text:RichText (id: 0, required);
}
table InstantPageBlock_Subheader {
text:RichText (id: 0, required);
}
table InstantPageBlock_Paragraph {
text:RichText (id: 0, required);
}
table InstantPageBlock_Preformatted {
text:RichText (id: 0, required);
language:string (id: 1);
}
table InstantPageBlock_Footer {
text:RichText (id: 0, required);
}
table InstantPageBlock_Divider {}
table InstantPageBlock_Anchor {
name:string (id: 0, required);
}
table InstantPageBlock_List {
items:[InstantPageListItem] (id: 0, required);
ordered:bool (id: 1);
}
table InstantPageBlock_BlockQuote {
text:RichText (id: 0, required);
caption:RichText (id: 1, required);
}
table InstantPageBlock_PullQuote {
text:RichText (id: 0, required);
caption:RichText (id: 1, required);
}
table InstantPageBlock_Image {
id:MediaId (id: 0, required);
caption:InstantPageCaption (id: 1, required);
url:string (id: 2);
webpageId:MediaId (id: 3);
}
table InstantPageBlock_Video {
id:MediaId (id: 0, required);
caption:InstantPageCaption (id: 1, required);
autoplay:bool (id: 2);
loop:bool (id: 3);
}
table InstantPageBlock_Audio {
id:MediaId (id: 0, required);
caption:InstantPageCaption (id: 1, required);
}
table InstantPageBlock_Cover {
block:InstantPageBlock (id: 0, required);
}
table InstantPageBlock_WebEmbed {
url:string (id: 0);
html:string (id: 1);
dimensions:PixelDimensions (id: 2);
caption:InstantPageCaption (id: 3, required);
stretchToWidth:bool (id: 4);
allowScrolling:bool (id: 5);
coverId:MediaId (id: 6);
}
table InstantPageBlock_PostEmbed {
url:string (id: 0, required);
webpageId:MediaId (id: 1);
avatarId:MediaId (id: 2);
author:string (id: 3, required);
date:int32 (id: 4);
blocks:[InstantPageBlock] (id: 5, required);
caption:InstantPageCaption (id: 6, required);
}
table InstantPageBlock_Collage {
items:[InstantPageBlock] (id: 0, required);
caption:InstantPageCaption (id: 1, required);
}
table InstantPageBlock_Slideshow {
items:[InstantPageBlock] (id: 0, required);
caption:InstantPageCaption (id: 1, required);
}
table InstantPageBlock_ChannelBanner {
channel:TelegramChannel (id: 0);
}
table InstantPageBlock_Kicker {
text:RichText (id: 0, required);
}
table InstantPageBlock_Table {
title:RichText (id: 0, required);
rows:[InstantPageTableRow] (id: 1, required);
bordered:bool (id: 2);
striped:bool (id: 3);
}
table InstantPageBlock_Details {
title:RichText (id: 0, required);
blocks:[InstantPageBlock] (id: 1, required);
expanded:bool (id: 2);
}
table InstantPageBlock_RelatedArticles {
title:RichText (id: 0, required);
articles:[InstantPageRelatedArticle] (id: 1, required);
}
table InstantPageBlock_Map {
latitude:float64 (id: 0);
longitude:float64 (id: 1);
zoom:int32 (id: 2);
dimensions:PixelDimensions (id: 3, required);
caption:InstantPageCaption (id: 4, required);
}
table InstantPageBlock_Heading {
text:RichText (id: 0, required);
level:int32 (id: 1);
}
table InstantPageBlock_Formula {
latex:string (id: 0, required);
}
table InstantPageCaption {
text:RichText (id: 0, required);
credit:RichText (id: 1, required);
}
union InstantPageListItem_Value {
InstantPageListItem_Text,
InstantPageListItem_Blocks,
InstantPageListItem_Unknown
}
table InstantPageListItem {
value:InstantPageListItem_Value (id: 1, required);
}
table InstantPageListItem_Text {
text:RichText (id: 0, required);
number:string (id: 1);
checkState:int32 (id: 2);
}
table InstantPageListItem_Blocks {
blocks:[InstantPageBlock] (id: 0, required);
number:string (id: 1);
checkState:int32 (id: 2);
}
table InstantPageListItem_Unknown {}
table InstantPageTableCell {
text:RichText (id: 0);
header:bool (id: 1);
alignment:int32 (id: 2);
verticalAlignment:int32 (id: 3);
colspan:int32 (id: 4);
rowspan:int32 (id: 5);
}
table InstantPageTableRow {
cells:[InstantPageTableCell] (id: 0, required);
}
table InstantPageRelatedArticle {
url:string (id: 0, required);
webpageId:MediaId (id: 1, required);
title:string (id: 2);
description:string (id: 3);
photoId:MediaId (id: 4);
author:string (id: 5);
date:int32 (id: 6);
}