diff --git a/package.json b/package.json index a40e5cd..538319c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "helixnotes", "private": true, "license": "AGPL-3.0-or-later", - "version": "1.2.5", + "version": "1.2.6", "type": "module", "scripts": { "dev": "vite dev", diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 58744eb..da875fb 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "HelixNotes", - "version": "1.2.5", + "version": "1.2.6", "identifier": "com.helixnotes.app", "build": { "frontendDist": "../build", diff --git a/src/lib/components/Editor.svelte b/src/lib/components/Editor.svelte index 7a6322f..5d822cd 100644 --- a/src/lib/components/Editor.svelte +++ b/src/lib/components/Editor.svelte @@ -307,24 +307,23 @@ renderHTML({ HTMLAttributes }) { const src = HTMLAttributes.src || ''; const name = HTMLAttributes.name || 'file.pdf'; - if (isMobile) { - // On mobile, render as a clickable link instead of iframe + const showInline = !isMobile && ($appConfig?.pdf_preview ?? false); + if (showInline) { const vaultRoot = $appConfig?.active_vault ?? ''; + const pdfHeight = $appConfig?.pdf_height ?? 600; 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 displaySrc = convertFileSrc(absPath); + return ['div', mergeAttributes({ 'data-pdf-src': src, 'data-pdf-name': name, class: 'pdf-embed' }), + ['iframe', { src: displaySrc, width: '100%', height: `${pdfHeight}px`, frameborder: '0' }], + ['p', { class: 'pdf-label' }, name], ]; } - const vaultRoot = $appConfig?.active_vault ?? ''; - const pdfHeight = $appConfig?.pdf_height ?? 600; - const absPath = normalizePath(`${vaultRoot}/${decodeURIComponent(src)}`); - const displaySrc = convertFileSrc(absPath); - return ['div', mergeAttributes({ 'data-pdf-src': src, 'data-pdf-name': name, class: 'pdf-embed' }), - ['iframe', { src: displaySrc, width: '100%', height: `${pdfHeight}px`, frameborder: '0' }], - ['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')})`; }); - // 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(/]*data-pdf-src="([^"]*)"[^>]*data-pdf-name="([^"]*)"[^>]*>[^<]*<\/div>/gi, (_, pdfSrc, name) => { const vaultRoot = $appConfig?.active_vault ?? ''; const absPath = normalizePath(`${vaultRoot}/${decodeURIComponent(pdfSrc)}`); - if (isMobile) { - return `
\uD83D\uDCC4 ${name}
`; + const showInline = !isMobile && ($appConfig?.pdf_preview ?? false); + if (showInline) { + const pdfHeight = $appConfig?.pdf_height ?? 600; + const displaySrc = convertFileSrc(absPath); + return `

${name}

`; } - const pdfHeight = $appConfig?.pdf_height ?? 600; - const displaySrc = convertFileSrc(absPath); - return `

${name}

`; + return `
\uD83D\uDCC4 ${name}
`; }); // 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. // File drops from OS are handled by Tauri's onDragDropEvent listener instead. dragstart: (_view, event) => { @@ -3792,7 +3778,7 @@ {/each} {/if} - {#if historySelected && historyPreview !== null} + {#if historySelected}