Skip to content

Build your personal knowledge base with Trilium Notes

refactor(share): mark external links with the app's arrow

Elian Doranb7d904a80fd8
diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts
index e6058adc25..989934e32c 100644
--- a/apps/client/src/index.ts
+++ b/apps/client/src/index.ts
@@ -2,6 +2,7 @@
// `@import` there would reach the browser unresolved; Vite bundles these into the entry's CSS,
// which loads ahead of the stylesheets `loadStylesheets()` appends.
import "@triliumnext/ckeditor5/src/theme/adaptive_colors.css";
+import "@triliumnext/ckeditor5/src/theme/external_links.css";
import "@triliumnext/ckeditor5/src/theme/footnotes.css";
import "@triliumnext/ckeditor5/src/theme/headings.css";
import "@triliumnext/ckeditor5/src/theme/reference_links.css";
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 60ef8b95ca..8e01549380 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -1127,13 +1127,6 @@ svg.ck-icon.note-icon {
padding: 2px;
}
-a.external:not(.no-arrow):after, a[href^="http://"]:not(.no-arrow):after, a[href^="https://"]:not(.no-arrow):after
-{
- font-size: smaller;
- content: "\2197";
- vertical-align: top;
-}
-
.card {
color: inherit !important;
border-color: var(--main-border-color) !important;
diff --git a/apps/client/src/widgets/type_widgets/text/LinkEmbed.css b/apps/client/src/widgets/type_widgets/text/LinkEmbed.css
index fc9365a4e9..a3d1b4529c 100644
--- a/apps/client/src/widgets/type_widgets/text/LinkEmbed.css
+++ b/apps/client/src/widgets/type_widgets/text/LinkEmbed.css
@@ -236,10 +236,6 @@ body.light-theme .link-embed-favicon-light {
}
}
-a.link-embed-card::after {
- display: none !important;
-}
-
/* Cards in a series share flush edges; only the outer corners stay rounded. A card that
stands alone matches neither rule below and keeps the default 8px on every corner. */
diff --git a/packages/ckeditor5/src/theme/external_links.css b/packages/ckeditor5/src/theme/external_links.css
new file mode 100644
index 0000000000..018e34d4ab
--- /dev/null
+++ b/packages/ckeditor5/src/theme/external_links.css
@@ -0,0 +1,5 @@
+a:is(.external, [href^="http://"], [href^="https://"]):not(.no-arrow, .link-embed-card)::after {
+ font-size: smaller;
+ content: "\2197";
+ vertical-align: top;
+}
diff --git a/packages/share-theme/src/content/external_links.css b/packages/share-theme/src/content/external_links.css
index e9c7072b1b..806fb2d6a9 100644
--- a/packages/share-theme/src/content/external_links.css
+++ b/packages/share-theme/src/content/external_links.css
@@ -1,10 +1,21 @@
-#content :is(a[href^="https://"], a[href^="http://"]):not(.link-embed-mention, .link-embed-card)::after {
- content: "";
+@import "@triliumnext/ckeditor5/src/theme/external_links.css";
+
+/* The arrow of the app's default theme, `theme-next/forms.css`. */
+#content a:is(.external, [href^="http://"], [href^="https://"]):not(.no-arrow)::after {
display: inline-block;
- width: 0.85em;
- height: 0.85em;
- margin-inline-start: 0.3em;
- vertical-align: -0.05em;
- background-color: currentcolor;
- mask: url("data:image/svg+xml;utf8,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\"><path d=\"M21 13v10h-21v-19h12v2h-10v15h17v-8h2zm3-12h-10.988l4.035 4-6.977 7.07 2.828 2.828 6.977-7.07 4.125 4.172v-11z\"></path></svg>") center / contain no-repeat;
+ opacity: 0.5;
+}
+
+#content a:is(.external, [href^="http://"], [href^="https://"]):not(.no-arrow):hover::after {
+ animation: external-link-arrow-blink 500ms linear alternate infinite;
+}
+
+@keyframes external-link-arrow-blink {
+ from {
+ opacity: 1;
+ }
+
+ to {
+ opacity: 0.5;
+ }
}
diff --git a/packages/share-theme/src/templates/page.ejs b/packages/share-theme/src/templates/page.ejs
index 9ab7618128..cad2828e50 100644
--- a/packages/share-theme/src/templates/page.ejs
+++ b/packages/share-theme/src/templates/page.ejs
@@ -29,7 +29,7 @@
<%- snippets["body:start"] %>
<div id="header">
<button aria-label="<%= t("share_theme.toggle-navigation") %>" id="left-pane-toggle-button" class="header-button"><span class="tn-icon bx bx-menu" aria-hidden="true"></span></button>
- <a href="<%= logo.href %>" id="header-logo">
+ <a href="<%= logo.href %>" id="header-logo" class="no-arrow">
<% if (logo.image) { %>
<img src="<%= logo.image %>" width="<%= logo.width %>" height="<%= logo.height %>" alt="<%= t("share_theme.logo-alt") %>" />
<% } else { %>
@@ -92,7 +92,7 @@
<ul>
<% for (const child of childLinks) { %>
<li>
- <a class="type-<%= child.type %>" href="<%= child.href %>"<% if (child.isExternal) { %> target="_blank" rel="noopener noreferrer"<% } %>><%= child.title %></a>
+ <a class="type-<%= child.type %> no-arrow" href="<%= child.href %>"<% if (child.isExternal) { %> target="_blank" rel="noopener noreferrer"<% } %>><%= child.title %></a>
</li>
<% } %>
</ul>
diff --git a/packages/share-theme/src/templates/tree_item.ejs b/packages/share-theme/src/templates/tree_item.ejs
index 7ef8284c77..93be13a08f 100644
--- a/packages/share-theme/src/templates/tree_item.ejs
+++ b/packages/share-theme/src/templates/tree_item.ejs
@@ -1,7 +1,7 @@
<ul>
<% for (const item of items) { %>
<li class="<%= item.children.length ? "submenu-item" : "item" %><%= item.isExpanded ? " expanded" : "" %>">
- <a class="type-<%= item.type %><%= item.isActive ? " active" : "" %>" href="<%= item.href %>"<% if (item.isExternal) { %> target="_blank" rel="noopener noreferrer"<% } %>>
+ <a class="type-<%= item.type %> no-arrow<%= item.isActive ? " active" : "" %>" href="<%= item.href %>"<% if (item.isExternal) { %> target="_blank" rel="noopener noreferrer"<% } %>>
<% if (item.children.length) { %><button class="collapse-button" aria-label="<%= t("share_theme.expand") %>"><span class="tn-icon bx bx-chevron-down" aria-hidden="true"></span></button><% } %>
<span><span class="tn-icon <%= item.icon %>" aria-hidden="true"></span> <%= item.title %></span>
</a>