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": {