From b4c5a139c995673738a42ebd347f32dacd298d9e Mon Sep 17 00:00:00 2001 From: PathGao <42336971+PathGao@users.noreply.github.com> Date: Sat, 24 Oct 2026 13:50:47 +0800 Subject: [PATCH] fix(bundle): list Markpad in Finder's Open With for .mdown and .mkd #1019 added both extensions to the Markdown file association, but on macOS an association with LSItemContentTypes ignores CFBundleTypeExtensions. The system's net.daringfireball.markdown only tags .md and .markdown, so .mdown and .mkd get dynamic UTIs that no association claimed. Move them to a second association with no content or MIME type, which Tauri emits as an extension-only document type. Windows registers the same ProgID and Linux the same MIME type as before. --- scripts/fileAssociations.test.ts | 21 ++++++++++++++++++++- src-tauri/tauri.conf.json | 8 +++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/scripts/fileAssociations.test.ts b/scripts/fileAssociations.test.ts index b4280caa..71880fb7 100644 --- a/scripts/fileAssociations.test.ts +++ b/scripts/fileAssociations.test.ts @@ -5,7 +5,9 @@ import { MARKDOWN_LINK_EXTENSIONS } from '../src/lib/utils/markdownLinks.js'; import { readSource } from './sourceTree.js'; const config = JSON.parse(readSource('src-tauri/tauri.conf.json')) as { - bundle: { fileAssociations: Array<{ ext: string[] }> }; + bundle: { + fileAssociations: Array<{ ext: string[]; contentTypes?: string[]; mimeType?: string; name: string }>; + }; }; // Every extension Markpad treats as a Markdown document is associated, except @@ -18,6 +20,23 @@ test('installer associates every Markdown extension except txt', () => { ); }); +// macOS ignores `ext` once an association has a content type, and its +// Markdown type (net.daringfireball.markdown, owned by the system) only tags +// .md and .markdown. Any other extension must sit in an association with no +// content type or MIME type, or it gets a dynamic UTI that no association +// claims and Markpad drops out of Finder's Open With. One name keeps a single +// Windows ProgID, which hooks.nsi registers under. +test('macOS claims extensions outside the system Markdown type by extension', () => { + for (const association of config.bundle.fileAssociations) { + if (association.contentTypes) { + assert.deepEqual(association.ext, ['md', 'markdown']); + } else { + assert.equal(association.mimeType, undefined); + } + assert.equal(association.name, 'Markdown File'); + } +}); + // The other half of the same policy, kept in this file so neither side moves // without the reader seeing both. Claiming `.txt` in the installer takes the // Text Document association away from Notepad (#179), which is why the test diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index dcb84a50..6a492e69 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -39,7 +39,7 @@ ], "fileAssociations": [ { - "ext": ["md", "markdown", "mdown", "mkd"], + "ext": ["md", "markdown"], "contentTypes": [ "net.daringfireball.markdown", "public.markdown" @@ -48,6 +48,12 @@ "name": "Markdown File", "description": "Opens Markdown files with Markpad", "role": "Editor" + }, + { + "ext": ["mdown", "mkd"], + "name": "Markdown File", + "description": "Opens Markdown files with Markpad", + "role": "Editor" } ], "windows": {