Add support for back to top anchor links.

GitOrigin-RevId: 4d1c15db95eca645e90df08e19b8cefd569ee158
This commit is contained in:
levlam 2020-03-05 03:36:30 +03:00
parent 82e43bc7eb
commit 22c1a88a79
2 changed files with 3 additions and 2 deletions

View File

@ -849,7 +849,7 @@ richTextReference text:RichText reference_text:RichText url:string = RichText;
//@description An anchor @name Anchor name
richTextAnchor name:string = RichText;
//@description A link to an anchor on the same web page @text The link text @name The anchor name @url An HTTP URL, opening the anchor
//@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
richTextAnchorLink text:RichText name:string url:string = RichText;
//@description A concatenation of rich texts @texts Texts

View File

@ -118,7 +118,7 @@ class RichText {
return make_tl_object<td_api::richTextFixed>(texts[0].get_rich_text_object(context));
case RichText::Type::Url:
if (!context->base_url_.empty() && begins_with(content, context->base_url_) &&
content.size() > context->base_url_.size() + 1 && content[context->base_url_.size()] == '#') {
content[context->base_url_.size()] == '#') {
if (context->is_first_pass_) {
context->has_anchor_urls_ = true;
} else {
@ -2399,6 +2399,7 @@ vector<td_api::object_ptr<td_api::PageBlock>> get_page_block_objects(
}
context.is_first_pass_ = false;
context.anchors_.emplace(Slice(), nullptr); // back to top
return get_page_block_objects(page_blocks, &context);
}