Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion scripts/fileAssociations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
],
"fileAssociations": [
{
"ext": ["md", "markdown", "mdown", "mkd"],
"ext": ["md", "markdown"],
"contentTypes": [
"net.daringfireball.markdown",
"public.markdown"
Expand All @@ -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": {
Expand Down
Loading