Replace referenced text with anchor name in richTextReference to support nested references.

This commit is contained in:
levlam 2020-11-11 16:39:45 +03:00
parent d63a16ef8b
commit 9725780fc6
3 changed files with 6 additions and 9 deletions

View File

@ -1053,14 +1053,14 @@ richTextPhoneNumber text:RichText phone_number:string = RichText;
//@height Height of a bounding box in which the image should be shown; 0 if unknown //@height Height of a bounding box in which the image should be shown; 0 if unknown
richTextIcon document:document width:int32 height:int32 = RichText; richTextIcon document:document width:int32 height:int32 = RichText;
//@description A rich text reference of a text on the same web page @text The text @reference_text The text to show on click @url An HTTP URL, opening the reference //@description A reference to a richTexts object on the same web page @text The text @anchor_name The name of a richTextAnchor object, which is the first element of the target richTexts object @url An HTTP URL, opening the reference
richTextReference text:RichText reference_text:RichText url:string = RichText; richTextReference text:RichText anchor_name:string url:string = RichText;
//@description An anchor @name Anchor name //@description An anchor @name Anchor name
richTextAnchor name:string = RichText; richTextAnchor name:string = RichText;
//@description A link to an anchor on the same web page @text The link text @name The anchor name. If the name is empty, the link should bring back to top @url An HTTP URL, opening the anchor //@description A link to an anchor on the same web page @text The link text @anchor_name The anchor name. If the name is empty, the link should bring back to top @url An HTTP URL, opening the anchor
richTextAnchorLink text:RichText name:string url:string = RichText; richTextAnchorLink text:RichText anchor_name:string url:string = RichText;
//@description A concatenation of rich texts @texts Texts //@description A concatenation of rich texts @texts Texts
richTexts texts:vector<RichText> = RichText; richTexts texts:vector<RichText> = RichText;

Binary file not shown.

View File

@ -128,11 +128,8 @@ class RichText {
return make_tl_object<td_api::richTextAnchorLink>(texts[0].get_rich_text_object(context), anchor.str(), return make_tl_object<td_api::richTextAnchorLink>(texts[0].get_rich_text_object(context), anchor.str(),
content); content);
} else { } else {
context->is_first_pass_ = true; return make_tl_object<td_api::richTextReference>(texts[0].get_rich_text_object(context), anchor.str(),
auto reference_text = it->second->get_rich_text_object(context); content);
context->is_first_pass_ = false;
return make_tl_object<td_api::richTextReference>(texts[0].get_rich_text_object(context),
std::move(reference_text), content);
} }
} }
} }