Skip to content

Commit 7c75311

Browse files
authored
Merge pull request #1913 from TriliumNext/css-tweaks
Some css fine tunes
2 parents eed5ce0 + 6d7abac commit 7c75311

File tree

6 files changed

+50
-12
lines changed

6 files changed

+50
-12
lines changed

apps/client/src/services/note_tooltip.ts

+38-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import appContext from "../components/app_context.js";
88
import type FNote from "../entities/fnote.js";
99
import { t } from "./i18n.js";
1010

11+
// Track all elements that open tooltips
12+
let openTooltipElements: JQuery<HTMLElement>[] = [];
13+
let dismissTimer: ReturnType<typeof setTimeout>;
14+
1115
function setupGlobalTooltip() {
1216
$(document).on("mouseenter", "a", mouseEnterHandler);
1317

@@ -23,7 +27,12 @@ function setupGlobalTooltip() {
2327
}
2428

2529
function dismissAllTooltips() {
26-
$(".note-tooltip").remove();
30+
clearTimeout(dismissTimer);
31+
openTooltipElements.forEach($el => {
32+
$el.tooltip("dispose");
33+
$el.removeAttr("aria-describedby");
34+
});
35+
openTooltipElements = [];
2736
}
2837

2938
function setupElementTooltip($el: JQuery<HTMLElement>) {
@@ -86,8 +95,8 @@ async function mouseEnterHandler(this: HTMLElement) {
8695
// we need to check if we're still hovering over the element
8796
// since the operation to get tooltip content was async, it is possible that
8897
// we now create tooltip which won't close because it won't receive mouseleave event
89-
if ($(this).filter(":hover").length > 0) {
90-
$(this).tooltip({
98+
if ($link.filter(":hover").length > 0) {
99+
$link.tooltip({
91100
container: "body",
92101
// https://github.com/zadam/trilium/issues/2794 https://github.com/zadam/trilium/issues/2988
93102
// with bottom this flickering happens a bit less
@@ -103,7 +112,9 @@ async function mouseEnterHandler(this: HTMLElement) {
103112
});
104113

105114
dismissAllTooltips();
106-
$(this).tooltip("show");
115+
$link.tooltip("show");
116+
117+
openTooltipElements.push($link);
107118

108119
// Dismiss the tooltip immediately if a link was clicked inside the tooltip.
109120
$(`.${tooltipClass} a`).on("click", (e) => {
@@ -115,15 +126,16 @@ async function mouseEnterHandler(this: HTMLElement) {
115126
// click on links within tooltip etc. without tooltip disappearing
116127
// - once the user moves the cursor away from both link and the tooltip, hide the tooltip
117128
const checkTooltip = () => {
118-
if (!$(this).filter(":hover").length && !$(`.${linkId}:hover`).length) {
129+
130+
if (!$link.filter(":hover").length && !$(`.${linkId}:hover`).length) {
119131
// cursor is neither over the link nor over the tooltip, user likely is not interested
120132
dismissAllTooltips();
121133
} else {
122-
setTimeout(checkTooltip, 1000);
134+
dismissTimer = setTimeout(checkTooltip, 1000);
123135
}
124136
};
125137

126-
setTimeout(checkTooltip, 1000);
138+
dismissTimer = setTimeout(checkTooltip, 1000);
127139
}
128140
}
129141

@@ -176,7 +188,25 @@ function renderFootnote($link: JQuery<HTMLElement>, url: string) {
176188
.closest(".footnote-item") // find the parent container of the footnote
177189
.find(".footnote-content"); // find the actual text content of the footnote
178190

179-
return $footnoteContent.html() || "";
191+
const isEditable = $link.closest(".ck-content").hasClass("note-detail-editable-text-editor");
192+
if (isEditable) {
193+
/* Remove widget buttons for tables, formulas, and images in editable notes. */
194+
$footnoteContent.find('.ck-widget__selection-handle').remove();
195+
$footnoteContent.find('.ck-widget__type-around').remove();
196+
$footnoteContent.find('.ck-widget__resizer').remove();
197+
198+
/* Handling in-line math formulas */
199+
$footnoteContent.find('.ck-math-tex.ck-math-tex-inline.ck-widget').each(function () {
200+
const $katex = $(this).find('.katex').first();
201+
if ($katex.length) {
202+
$(this).replaceWith($('<span class="math-tex"></span>').append($('<span></span>').append($katex.clone())));
203+
}
204+
});
205+
}
206+
207+
let footnoteContent = $footnoteContent.html();
208+
footnoteContent = `<div class="ck-content">${footnoteContent}</div>`
209+
return footnoteContent || "";
180210
}
181211

182212
export default {

apps/client/src/stylesheets/style.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,10 @@ body:not(.mobile) #launcher-pane.horizontal .dropdown-submenu > .dropdown-menu {
12131213
background-color: inherit;
12141214
}
12151215

1216+
::selection {
1217+
background-color: var(--selection-background-color);
1218+
}
1219+
12161220
[data-bs-toggle="tooltip"]:not(.button-widget) span {
12171221
padding-bottom: 0;
12181222
border-bottom: 1px dotted;
@@ -1769,7 +1773,7 @@ body.zen .title-row {
17691773
height: unset !important;
17701774
-webkit-app-region: drag;
17711775
padding-left: env(titlebar-area-x);
1772-
padding-right: 2.5em;
1776+
padding-right: calc(100vw - env(titlebar-area-width, 100vw) + 2.5em);
17731777
}
17741778

17751779
body.zen .floating-buttons {

apps/client/src/stylesheets/theme-next-dark.css

+2
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@
195195
--scrollbar-background-color: transparent;
196196
--scrollbar-border-color: unset; /* Deprecated */
197197

198+
--selection-background-color: #3399FF70;
199+
198200
--link-color: lightskyblue;
199201

200202
--mermaid-theme: dark;

apps/client/src/stylesheets/theme-next-light.css

+2
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,8 @@
194194
--scrollbar-background-color: transparent;
195195
--scrollbar-border-color: unset; /* Deprecated */
196196

197+
--selection-background-color: #3399FF70;
198+
197199
--link-color: blue;
198200

199201
--mermaid-theme: default;

apps/client/src/stylesheets/theme-next/shell.css

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ body.layout-horizontal > .horizontal {
131131
}
132132

133133
#launcher-pane.vertical #launcher-container {
134+
width: var(--launcher-pane-size);
134135
height: 100%;
135136
overflow-x: hidden;
136137
overflow-y: auto;

packages/ckeditor5-footnotes/theme/footnote.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@
4444
flex-grow: 1;
4545
}
4646

47-
.ck .ck-widget.footnote-section .ck-widget__type-around__button_after {
48-
display:none; /* hides the 'insert after' button from the ckeditor widget */
47+
.ck .ck-widget.footnote-section > .ck-reset_all.ck-widget__type-around > .ck-widget__type-around__button_after {
48+
display: none; /* hides the 'insert after' button from the ckeditor widget, but displays the button inside the footnote content. */
4949
}
50-
5150
.placeholder {
5251
padding: 2px 2px;
5352
outline-offset: -2px;

0 commit comments

Comments
 (0)