Supported File Types
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
Writer is a distraction-free text editor designed for macOS that primarily focuses on Markdown and plain text workflows. The system is architected to handle specific file extensions for editing while providing robust transformation capabilities to export these documents into various distribution formats.
The application utilizes a central EditorStore to manage the lifecycle of supported files, including discovery, reading, writing, and security-scoped access via the macOS file system.
Sources: CLAUDE.md:1-10, Writer/EditorStore.swift:14-25
Editable File Types
The application restricts its file browser and editor to a specific set of text-based extensions. These files are treated as UTF-8 encoded strings within the EditorStore.
Validation Logic
The isEditableFile(_:) function in the EditorStore defines the filter for the file tree. It accepts four primary extensions and also allows files without extensions to be processed.
| Extension | Format Description | Implementation Reference |
|---|---|---|
.md | Markdown Document | isEditableFile |
.markdown | Markdown Document | isEditableFile |
.txt | Plain Text | isEditableFile |
.text | Plain Text | isEditableFile |
| (None) | Untyped Text | isEditableFile |
Sources: Writer/EditorStore.swift:343-351, CLAUDE.md:46
File Discovery Flow
The following diagram illustrates how the application filters the file system to display only supported types in the sidebar:
The file discovery process uses FileManager to fetch contents and resourceValues(forKeys: [.isDirectoryKey]) to differentiate between folders and files before applying extension filters.
Sources: Writer/EditorStore.swift:313-341
Export Formats
Writer supports converting the internal Markdown/Text representation into three distinct export formats. Each format is handled by a specialized exporter class.
Supported Export Types
| Format | MIME / UTType | Exporter Class | Description |
|---|---|---|---|
| HTML | public.html | HTMLExporter | Standalone HTML with inline CSS styling derived from themes. |
com.adobe.pdf | PDFExporter | Rendered PDF using a hidden WKWebView for high-fidelity layout. | |
| RTF | public.rtf | RTFExporter | Rich Text Format created by converting HTML to attributed strings. |
Sources: Writer/HTMLExporter.swift:15-20, Writer/PDFExporter.swift:28-33, Writer/RTFExporter.swift:21-26, Writer/WriterApp.swift:21-65
Export Pipeline Architecture
The conversion from editable Markdown to exportable formats follows a standardized pipeline:
Citations: Writer/HTMLExporter.swift:10-14, Writer/PDFExporter.swift:22-26, Writer/RTFExporter.swift:17-20
Implementation Details
File Creation
When a user creates a new file via the UI, the system defaults to specific extensions. While the editor supports several, the creation sheet specifically prompts for "Plain Text (.txt)".
// From Writer/ContentView.swift
if creation == .file {
editorStore.createFile(named: creationName, extension: "txt")
}
Sources: Writer/ContentView.swift:174-176
Security-Scoped Access
Because Writer is a macOS application that may be sandboxed, it uses security-scoped bookmarks to maintain access to folders containing supported file types across app launches. This is managed by URL.bookmarkData(options: .withSecurityScope) and startAccessingSecurityScopedResource().
Sources: Writer/EditorStore.swift:162-175, CLAUDE.md:43
Summary
Writer focuses on a narrow set of editable text formats (.md, .txt) to ensure a distraction-free environment while offering broad compatibility through its export system. By using MarkdownRenderer as an intermediate step, the application ensures that all supported input files can be reliably transformed into HTML, PDF, or RTF for external use.