v1.2.6 - unfiled notes, keyboard shortcuts, Android fixes

This commit is contained in:
Yuri Karamian committed 2026-03-19 00:36:42 +01:00
1 parent 565688b284
commit 1bc067d470
4 files changed
+91 -39

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
"name": "helixnotes", "name": "helixnotes",
"private": true, "private": true,
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"version": "1.2.5", "version": "1.2.6",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite dev", "dev": "vite dev",
+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "$schema": "../node_modules/@tauri-apps/cli/config.schema.json",
"productName": "HelixNotes", "productName": "HelixNotes",
"version": "1.2.5", "version": "1.2.6",
"identifier": "com.helixnotes.app", "identifier": "com.helixnotes.app",
"build": { "build": {
"frontendDist": "../build", "frontendDist": "../build",
+50 -33
View File
@@ -307,17 +307,8 @@
renderHTML({ HTMLAttributes }) { renderHTML({ HTMLAttributes }) {
const src = HTMLAttributes.src || ''; const src = HTMLAttributes.src || '';
const name = HTMLAttributes.name || 'file.pdf'; const name = HTMLAttributes.name || 'file.pdf';
if (isMobile) { const showInline = !isMobile && ($appConfig?.pdf_preview ?? false);
// On mobile, render as a clickable link instead of iframe if (showInline) {
const vaultRoot = $appConfig?.active_vault ?? '';
const absPath = normalizePath(`${vaultRoot}/${decodeURIComponent(src)}`);
return ['div', mergeAttributes({ 'data-pdf-src': src, 'data-pdf-name': name, class: 'pdf-embed-mobile' }),
['a', { href: '#', 'data-open-file': absPath, class: 'pdf-link-mobile', onclick: 'return false;' },
['span', { class: 'pdf-icon-mobile' }, '\uD83D\uDCC4'],
['span', {}, name],
],
];
}
const vaultRoot = $appConfig?.active_vault ?? ''; const vaultRoot = $appConfig?.active_vault ?? '';
const pdfHeight = $appConfig?.pdf_height ?? 600; const pdfHeight = $appConfig?.pdf_height ?? 600;
const absPath = normalizePath(`${vaultRoot}/${decodeURIComponent(src)}`); const absPath = normalizePath(`${vaultRoot}/${decodeURIComponent(src)}`);
@@ -326,6 +317,14 @@
['iframe', { src: displaySrc, width: '100%', height: `${pdfHeight}px`, frameborder: '0' }], ['iframe', { src: displaySrc, width: '100%', height: `${pdfHeight}px`, frameborder: '0' }],
['p', { class: 'pdf-label' }, name], ['p', { class: 'pdf-label' }, name],
]; ];
}
// Non-inline: render as a clickable link (mobile + desktop with setting off)
return ['div', mergeAttributes({ 'data-pdf-src': src, 'data-pdf-name': name, class: 'pdf-embed-mobile' }),
['a', { href: decodeURIComponent(src), class: 'pdf-link-mobile' },
['span', { class: 'pdf-icon-mobile' }, '\uD83D\uDCC4'],
['span', {}, name],
],
];
}, },
}); });
@@ -2086,16 +2085,17 @@
return `[${text}](${url.replace(/ /g, '%20')})`; return `[${text}](${url.replace(/ /g, '%20')})`;
}); });
// Pre-process: transform PDF embed divs — iframes on desktop, clickable links on mobile // Pre-process: transform PDF embed divs — iframes when inline preview is on, clickable links otherwise
src = src.replace(/<div[^>]*data-pdf-src="([^"]*)"[^>]*data-pdf-name="([^"]*)"[^>]*>[^<]*<\/div>/gi, (_, pdfSrc, name) => { src = src.replace(/<div[^>]*data-pdf-src="([^"]*)"[^>]*data-pdf-name="([^"]*)"[^>]*>[^<]*<\/div>/gi, (_, pdfSrc, name) => {
const vaultRoot = $appConfig?.active_vault ?? ''; const vaultRoot = $appConfig?.active_vault ?? '';
const absPath = normalizePath(`${vaultRoot}/${decodeURIComponent(pdfSrc)}`); const absPath = normalizePath(`${vaultRoot}/${decodeURIComponent(pdfSrc)}`);
if (isMobile) { const showInline = !isMobile && ($appConfig?.pdf_preview ?? false);
return `<div class="pdf-embed-mobile"><a href="#" data-open-file="${absPath}" class="pdf-link-mobile" onclick="return false;">\uD83D\uDCC4 ${name}</a></div>`; if (showInline) {
}
const pdfHeight = $appConfig?.pdf_height ?? 600; const pdfHeight = $appConfig?.pdf_height ?? 600;
const displaySrc = convertFileSrc(absPath); const displaySrc = convertFileSrc(absPath);
return `<div data-pdf-src="${pdfSrc}" data-pdf-name="${name}" class="pdf-embed"><iframe src="${displaySrc}" width="100%" height="${pdfHeight}px"></iframe><p class="pdf-label">${name}</p></div>`; return `<div data-pdf-src="${pdfSrc}" data-pdf-name="${name}" class="pdf-embed"><iframe src="${displaySrc}" width="100%" height="${pdfHeight}px"></iframe><p class="pdf-label">${name}</p></div>`;
}
return `<div data-pdf-src="${pdfSrc}" data-pdf-name="${name}" class="pdf-embed-mobile"><a href="${decodeURIComponent(pdfSrc)}" class="pdf-link-mobile">\uD83D\uDCC4 ${name}</a></div>`;
}); });
// Pre-process: render KaTeX math — only outside fenced code blocks // Pre-process: render KaTeX math — only outside fenced code blocks
@@ -2316,20 +2316,6 @@
} }
} }
}, },
// On mobile, handle clicks on PDF file links to open in external app
...(isMobile ? { click: (_view: any, event: MouseEvent) => {
const target = (event.target as HTMLElement).closest('[data-open-file]') as HTMLElement | null;
if (target) {
event.preventDefault();
const filePath = target.getAttribute('data-open-file');
if (filePath) {
const bridge = (window as any).Android;
if (bridge && typeof bridge.openFile === 'function') {
bridge.openFile(filePath);
}
}
}
}} : {}),
// Prevent native text drag — it causes copy-instead-of-move in Tauri's webview. // Prevent native text drag — it causes copy-instead-of-move in Tauri's webview.
// File drops from OS are handled by Tauri's onDragDropEvent listener instead. // File drops from OS are handled by Tauri's onDragDropEvent listener instead.
dragstart: (_view, event) => { dragstart: (_view, event) => {
@@ -3792,7 +3778,7 @@
{/each} {/each}
</div> </div>
{/if} {/if}
{#if historySelected && historyPreview !== null} {#if historySelected}
<div class="history-actions"> <div class="history-actions">
<button class="history-restore-btn" onclick={restoreVersion}> <button class="history-restore-btn" onclick={restoreVersion}>
Restore this version Restore this version
@@ -7194,14 +7180,45 @@
position: relative; position: relative;
} }
.editor-container.mobile .editor-body-row:has(.history-panel) > .editor-body,
.editor-container.mobile .editor-body-row:has(.outline-panel) > .editor-body {
display: none;
}
.editor-container.mobile .history-panel, .editor-container.mobile .history-panel,
.editor-container.mobile .outline-panel { .editor-container.mobile .outline-panel {
position: absolute; position: static;
inset: 0; flex: 1;
min-height: 0;
width: 100% !important; width: 100% !important;
max-width: 100%; max-width: 100%;
border-left: none; border-left: none;
z-index: 10; }
.editor-container.mobile .history-item {
padding: 12px 12px;
min-height: 48px;
}
.editor-container.mobile .history-list {
padding-bottom: 80px;
}
.editor-container.mobile .history-restore-btn {
padding: 14px 16px;
font-size: 15px;
}
.editor-container.mobile .history-actions {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 12px;
padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
background: var(--bg-secondary);
border-top: 1px solid var(--border-light);
z-index: 51;
} }
.editor-container.mobile .note-search-bar { .editor-container.mobile .note-search-bar {
+39 -4
View File
@@ -33,6 +33,19 @@
return resolved.join('/'); return resolved.join('/');
} }
const isAndroid = /android/i.test(navigator.userAgent);
function openLocalFile(path: string) {
if (isAndroid) {
const bridge = (window as any).Android;
if (bridge && typeof bridge.openFile === 'function') {
bridge.openFile(path);
}
} else {
openFile(path).catch((err) => console.error('Failed to open file:', err));
}
}
function resolveAndHandleLink(href: string) { function resolveAndHandleLink(href: string) {
if (href.startsWith('http://') || href.startsWith('https://') || href.startsWith('mailto:')) { if (href.startsWith('http://') || href.startsWith('https://') || href.startsWith('mailto:')) {
openUrl(href).catch((err) => console.error('Failed to open URL:', err)); openUrl(href).catch((err) => console.error('Failed to open URL:', err));
@@ -62,7 +75,7 @@
activeNotePath.set(absPath); activeNotePath.set(absPath);
}).catch((err) => console.error('Failed to navigate to note:', err)); }).catch((err) => console.error('Failed to navigate to note:', err));
} else { } else {
openFile(absPath).catch((err) => console.error('Failed to open file:', err)); openLocalFile(absPath);
} }
} }
} }
@@ -81,7 +94,17 @@
// Intercept all link clicks in capture phase to prevent webview navigation // Intercept all link clicks in capture phase to prevent webview navigation
onMount(() => { onMount(() => {
function handleLinkClick(e: MouseEvent) { function handleLinkClick(e: MouseEvent) {
const target = (e.target as HTMLElement)?.closest('a'); const el = e.target as HTMLElement;
// PDF/attachment embeds: check for data-open-file on target or ancestors
const fileTarget = el?.closest('[data-open-file]') as HTMLElement | null;
if (fileTarget) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
openLocalFile(fileTarget.getAttribute('data-open-file')!);
return;
}
const target = el?.closest('a');
if (!target) return; if (!target) return;
const href = target.getAttribute('href'); const href = target.getAttribute('href');
if (!href) return; if (!href) return;
@@ -102,10 +125,22 @@
touchStartY = e.touches[0]?.clientY ?? 0; touchStartY = e.touches[0]?.clientY ?? 0;
} }
function handleTouchEnd(e: TouchEvent) { function handleTouchEnd(e: TouchEvent) {
const endY = e.changedTouches[0]?.clientY ?? 0; const touch = e.changedTouches[0];
if (!touch) return;
const endY = touch.clientY;
// If the finger moved > 10px, it's a scroll, not a tap // If the finger moved > 10px, it's a scroll, not a tap
if (Math.abs(endY - touchStartY) > 10) return; if (Math.abs(endY - touchStartY) > 10) return;
const target = (e.target as HTMLElement)?.closest('a'); // Android WebView may report e.target as the editor root for elements
// inside contenteditable="false" blocks; use elementFromPoint instead
const el = (document.elementFromPoint(touch.clientX, touch.clientY) ?? e.target) as HTMLElement;
// PDF/attachment embeds: check for data-open-file on target or ancestors
const fileTarget = el?.closest('[data-open-file]') as HTMLElement | null;
if (fileTarget) {
e.preventDefault();
openLocalFile(fileTarget.getAttribute('data-open-file')!);
return;
}
const target = el?.closest('a');
if (!target) return; if (!target) return;
const href = target.getAttribute('href'); const href = target.getAttribute('href');
if (!href) return; if (!href) return;