mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 18:43:29 +00:00
Better handling for external link "mailto:" in Hovered Card in GBO (#3630)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Better handling for external link "mailto:" in Hovered Card in GBO
|
||||
@@ -46,6 +46,7 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
|
||||
);
|
||||
}
|
||||
const isExternal = inline.data.ref.kind === 'url';
|
||||
const isMailto = resolved.href.startsWith('mailto:');
|
||||
const content = (
|
||||
<StyledLink
|
||||
href={resolved.href}
|
||||
@@ -63,7 +64,12 @@ export async function InlineLink(props: InlineProps<DocumentInlineLink>) {
|
||||
nodes={inline.nodes}
|
||||
ancestorInlines={[...ancestorInlines, inline]}
|
||||
/>
|
||||
{isExternal ? (
|
||||
{isMailto ? (
|
||||
<Icon
|
||||
icon="envelope"
|
||||
className="ml-1 inline size-3 links-accent:text-tint-subtle"
|
||||
/>
|
||||
) : isExternal ? (
|
||||
<Icon
|
||||
icon="arrow-up-right"
|
||||
className="ml-0.5 inline size-3 links-accent:text-tint-subtle"
|
||||
@@ -96,16 +102,24 @@ function InlineLinkTooltipWrapper(props: {
|
||||
const { inline, language, resolved, children } = props;
|
||||
|
||||
let breadcrumbs = resolved.ancestors ?? [];
|
||||
const isMailto = resolved.href.startsWith('mailto:');
|
||||
const isExternal = inline.data.ref.kind === 'url';
|
||||
const isSamePage = inline.data.ref.kind === 'anchor' && inline.data.ref.page === undefined;
|
||||
if (isExternal) {
|
||||
|
||||
if (isMailto) {
|
||||
resolved.text = resolved.text.split('mailto:')[1] ?? resolved.text;
|
||||
breadcrumbs = [
|
||||
{
|
||||
label: tString(language, 'link_tooltip_email'),
|
||||
},
|
||||
];
|
||||
} else if (isExternal) {
|
||||
breadcrumbs = [
|
||||
{
|
||||
label: tString(language, 'link_tooltip_external_link'),
|
||||
},
|
||||
];
|
||||
}
|
||||
if (isSamePage) {
|
||||
} else if (isSamePage) {
|
||||
breadcrumbs = [
|
||||
{
|
||||
label: tString(language, 'link_tooltip_page_anchor'),
|
||||
|
||||
@@ -68,6 +68,7 @@ export const de = {
|
||||
pdf_limit_reached_continue: 'Mit ${1} weiteren Seiten erweitern.',
|
||||
more: 'Mehr',
|
||||
link_tooltip_external_link: 'Externe Verlinkung zu',
|
||||
link_tooltip_email: 'E-Mail senden an',
|
||||
link_tooltip_page_anchor: 'Zum Abschnitt springen',
|
||||
open_in_new_tab: 'In neuem Tab öffnen',
|
||||
ai_chat_assistant_name: 'GitBook-Assistent',
|
||||
|
||||
@@ -65,6 +65,7 @@ export const en = {
|
||||
pdf_limit_reached_continue: 'Extend with ${1} more pages.',
|
||||
more: 'More',
|
||||
link_tooltip_external_link: 'External link to',
|
||||
link_tooltip_email: 'Send an email to',
|
||||
link_tooltip_page_anchor: 'Jump to section',
|
||||
open_in_new_tab: 'Open in new tab',
|
||||
ai_chat_assistant_name: 'GitBook Assistant',
|
||||
|
||||
@@ -69,6 +69,7 @@ export const es: TranslationLanguage = {
|
||||
pdf_limit_reached_continue: 'Extender con ${1} páginas más.',
|
||||
more: 'Más',
|
||||
link_tooltip_external_link: 'Enlace externo a',
|
||||
link_tooltip_email: 'Enviar un correo electrónico a',
|
||||
link_tooltip_page_anchor: 'Saltar a la sección',
|
||||
open_in_new_tab: 'Abrir en una nueva pestaña',
|
||||
ai_chat_assistant_name: 'Asistente de GitBook',
|
||||
|
||||
@@ -64,6 +64,7 @@ export const fr = {
|
||||
pdf_limit_reached_continue: 'Ajouter ${1} pages supplémentaires',
|
||||
more: 'Plus',
|
||||
link_tooltip_external_link: 'Lien externe vers',
|
||||
link_tooltip_email: 'Envoyer un e-mail à',
|
||||
link_tooltip_page_anchor: 'Aller à la section',
|
||||
open_in_new_tab: 'Ouvrir dans un nouvel onglet',
|
||||
ai_chat_assistant_name: 'Assistant GitBook',
|
||||
|
||||
@@ -67,6 +67,7 @@ export const ja: TranslationLanguage = {
|
||||
pdf_limit_reached_continue: 'さらに${1}ページで拡張',
|
||||
more: '詳細',
|
||||
link_tooltip_external_link: '外部リンク先',
|
||||
link_tooltip_email: 'メールを送信',
|
||||
link_tooltip_page_anchor: 'ページ内リンク先',
|
||||
open_in_new_tab: '新しいタブで開く',
|
||||
ai_chat_assistant_name: 'GitBookアシスタント',
|
||||
|
||||
@@ -67,6 +67,7 @@ export const nl: TranslationLanguage = {
|
||||
pdf_limit_reached_continue: "Verleng met ${1} extra pagina's.",
|
||||
more: 'Meer',
|
||||
link_tooltip_external_link: 'Externe link naar',
|
||||
link_tooltip_email: 'E-mail versturen naar',
|
||||
link_tooltip_page_anchor: 'Spring naar sectie',
|
||||
open_in_new_tab: 'Open in nieuw tabblad',
|
||||
ai_chat_assistant_name: 'GitBook Assistent',
|
||||
|
||||
@@ -68,6 +68,7 @@ export const no: TranslationLanguage = {
|
||||
pdf_limit_reached_continue: 'Utvid med ${1} flere sider.',
|
||||
more: 'Mer',
|
||||
link_tooltip_external_link: 'Ekstern lenke til',
|
||||
link_tooltip_email: 'Send e-post til',
|
||||
link_tooltip_page_anchor: 'Hopp til seksjon',
|
||||
open_in_new_tab: 'Åpne i ny fane',
|
||||
ai_chat_assistant_name: 'GitBook-assistent',
|
||||
|
||||
@@ -67,6 +67,7 @@ export const pt_br = {
|
||||
pdf_limit_reached_continue: 'Extender com mais ${1} páginas.',
|
||||
more: 'Mais',
|
||||
link_tooltip_external_link: 'Link externo para',
|
||||
link_tooltip_email: 'Enviar e-mail para',
|
||||
link_tooltip_page_anchor: 'Pular para a seção',
|
||||
open_in_new_tab: 'Abrir em uma nova guia',
|
||||
ai_chat_assistant_name: 'Assistente do GitBook',
|
||||
|
||||
@@ -66,6 +66,7 @@ export const ru = {
|
||||
pdf_limit_reached_continue: 'Расширьте ещё на ${1} страниц.',
|
||||
more: 'Ещё',
|
||||
link_tooltip_external_link: 'Внешняя ссылка на',
|
||||
link_tooltip_email: 'Отправить письмо на',
|
||||
link_tooltip_page_anchor: 'Перейти к разделу',
|
||||
open_in_new_tab: 'Открыть в новой вкладке',
|
||||
ai_chat_assistant_name: 'GitBook-помощник',
|
||||
|
||||
@@ -65,6 +65,7 @@ export const zh: TranslationLanguage = {
|
||||
pdf_limit_reached_continue: '使用${1}页进行扩展。',
|
||||
more: '更多',
|
||||
link_tooltip_external_link: '外部链接到',
|
||||
link_tooltip_email: '发送邮件到',
|
||||
link_tooltip_page_anchor: '跳转到页面',
|
||||
open_in_new_tab: '在新标签页中打开',
|
||||
ai_chat_assistant_name: 'GitBook 助手',
|
||||
|
||||
Reference in New Issue
Block a user