Skip to content

Build your personal knowledge base with Trilium Notes

Merge branch 'main' of https://github.com/TriliumNext/Trilium into feat/link-preview-enhancements

Adorian Dorana9492dcc1de4
diff --cc apps/client/src/widgets/NoteDetail.tsx
index 973fa062e9,09b9681794..79d4930a14
--- a/apps/client/src/widgets/NoteDetail.tsx
+++ b/apps/client/src/widgets/NoteDetail.tsx
@@@ -10,15 -10,18 +10,19 @@@ import FNote from "../entities/fnote"
import type { PrintReport } from "../print";
import attributes from "../services/attributes";
import dialog from "../services/dialog";
+ import froca from "../services/froca";
import { t } from "../services/i18n";
+import { stopBackgroundMedia } from "../services/media_playback";
import protected_session_holder from "../services/protected_session_holder";
import toast from "../services/toast.js";
- import { isElectron, isMobile } from "../services/utils";
- import NoteTreeWidget from "./note_tree";
+ import { isElectron } from "../services/utils";
import { ExtendedNoteType, TYPE_MAPPINGS, TypeWidget } from "./note_types";
- import { useLegacyWidget, useNoteContext, useTriliumEvent } from "./react/hooks";
+ import Button from "./react/Button";
+ import { useDelayedVisibility, useGetContextDataFrom, useNoteContext, useTriliumEvent } from "./react/hooks";
+ import Icon from "./react/Icon";
+ import NoItems from "./react/NoItems";
import { NoteListWithLinks } from "./react/NoteList";
+ import { ContainerVisibilityContext } from "./react/react_utils";
import { TypeWidgetProps } from "./type_widgets/type_widget";
/**
@@@ -244,8 -259,11 +260,12 @@@ export function isContextInActiveTab(no
* while the widget is visible, to avoid rendering in the background. When not visible, the DOM element is simply hidden.
*/
function NoteDetailWrapper({ Element, type, isVisible, isFullHeight, props }: { Element: (props: TypeWidgetProps) => VNode, type: ExtendedNoteType, isVisible: boolean, isFullHeight: boolean, props: TypeWidgetProps }) {
+ // False when an enclosing dialog (e.g. the quick-edit popup) is hidden but kept in the DOM, so a widget
+ // there is told it isn't displayed even though it's the context's current type — letting a media player
+ // inside a closed popup stop, just like one in a navigated-away tab.
+ const containerVisible = useContext(ContainerVisibilityContext);
const [ cachedProps, setCachedProps ] = useState(props);
+ const wrapperRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (isVisible) {
diff --cc apps/desktop/src/main.ts
index dabd1e9afa,37e990b6fe..ccdf60b9af
--- a/apps/desktop/src/main.ts
+++ b/apps/desktop/src/main.ts
@@@ -24,8 -25,11 +25,12 @@@ import { PRODUCT_NAME } from "./app-inf
import IpcMessagingProvider from "./ipc_messaging_provider";
import DesktopPlatformProvider from "./platform_provider";
import { registerTriliumAppScheme, setupTriliumAppProtocol } from "./protocol";
+ import { applyLaunchOnStartup, setupAutoLaunch, wasLaunchedHidden } from "./services/auto_launch";
import { setupCustomDictionary } from "./services/custom_dictionary";
+import { setupEmbedReferer } from "./services/embed_referer";
+ import { setupExportHandlers } from "./services/export";
+ import { setupImportHandlers } from "./services/import";
+ import { setupOneNoteHandlers } from "./services/onenote";
import { setupPrintingHandlers } from "./services/printing";
import { getSecuritySettings, registerSecurityIpcHandlers } from "./services/security_settings";
import { setupShellHandlers } from "./services/shell";
diff --cc packages/ckeditor5/src/plugins/linkembed.ts
index cb2f6e2e46,bf3a5e1b48..cf1044c3ea
--- a/packages/ckeditor5/src/plugins/linkembed.ts
+++ b/packages/ckeditor5/src/plugins/linkembed.ts
@@@ -1,5 -1,4 +1,5 @@@
+import { type BlockChildLike, chooseLinkPreviewKind, isUrlAloneInBlock } from '@triliumnext/commons';
- import { ButtonView, Command, Plugin, toWidget, Widget, type Observable } from 'ckeditor5';
+ import { ButtonView, Command, Plugin, toWidget, viewToModelPositionOutsideModelElement, Widget, type Observable } from 'ckeditor5';
import linkEmbedIcon from '../icons/link-embed.svg?raw';
import { preventCKEditorHandling } from './widget_utils.js';
@@@ -62,9 -61,18 +63,19 @@@ class LinkEmbedEditing extends Plugin
init() {
this._defineSchema();
this._defineConverters();
+
+ // linkMention is an empty inline object whose editing view holds a UIElement child, so a
+ // view position inside the rendered widget would otherwise resolve to a degenerate model
+ // position *inside* the atomic element. Map it just outside the mention instead (mirrors
+ // ReferenceLink). The block linkEmbed is a $block object and needs no such mapping.
+ this.editor.editing.mapper.on(
+ 'viewToModelPosition',
+ viewToModelPositionOutsideModelElement(this.editor.model, viewElement => viewElement.hasClass('link-mention'))
+ );
+
this.editor.commands.add(LINK_EMBED_COMMAND, new InsertLinkEmbedCommand(this.editor));
this.editor.commands.add(CHANGE_LINK_DISPLAY_COMMAND, new ChangeLinkDisplayCommand(this.editor));
+ this.editor.commands.add(REMOVE_LINK_EMBED_COMMAND, new RemoveLinkEmbedCommand(this.editor));
}
_defineSchema() {
@@@ -404,9 -384,10 +415,10 @@@ class AutoLinkToMention extends Plugin
if (item.item.data.trim() !== href) continue;
const parent = item.item.parent;
+ /* v8 ignore next -- a $textProxy always has an element parent, so this guard never fires */
if (!parent?.is('element')) continue;
- this._replaceWithMention(href, parent.getPath());
+ this._replaceWithPreview(href, parent.getPath());
return;
}
}