# Plak v1 spec Plak is a native macOS notepad with one long page of plain text. It has no files to open or save: you open it, you paste or type at the bottom, and it keeps everything. The only thing that renders is images: what you paste or drop shows as the image itself. ## 1. Behaviour ### 1.1 The page - There is one page. It grows at the bottom, without limit. - The page is one plain text: you can click anywhere and type, and you can select across paragraphs. There is no markdown rendering: `# title` or `**bold**` show as you type them. - The text sits in one reading column, about 68 characters wide, in the centre of the window. - A **block** is a run of lines without a blank line in it. Blocks exist only for the created date (1.6); you do not see them as boxes. ### 1.2 Open the app - Plak has no Dock icon and is not in ⌘Tab. It lives in the menu bar: the menu bar icon has a menu with Show Plak, Hide Plak and Quit Plak. - ⌘P, from any app on any desktop, shows the window on the current desktop, also over an app in fullscreen. Plak takes ⌘P from every other app on purpose. - ⌘P is a toggle: while you are in plak (plak is in front and its window is visible), ⌘P hides plak and you are back in the app you came from. Esc does the same. - When plak is not running, you start it from Spotlight or Finder. - Plak opens scrolled to the bottom, with the caret at the end of the text. - The end of the text is always in the vertical middle of the window. To make this possible, the page has empty space below the text of half the window height. This is also true when the page is empty or short. - You can type or paste at once, without a click. - When plak is already running and you open it again from Spotlight or Finder, it shows scrolled to the end, as at a launch. ⌘P and Show Plak in the menu bar bring it back to the front without a scroll. - Opening plak (Spotlight, ⌘P, Show Plak) always brings it in front of other apps, with the caret ready. It does not stay on top: click another app and that app comes in front. ### 1.3 Type and paste - Typing and editing work as in any Mac text field, anywhere on the page. - While you type, the caret never goes lower than 20% of the window height above the bottom edge. When it would go lower, the page scrolls so that the caret sits on that 20% line, and you see as much of the text above as possible. The page does not scroll while the caret stays above that line. At launch the end still starts in the middle (1.2); typing then moves the caret down to the 20% line. - A paste of rich text inserts only its plain text. - A click in the empty space below the text puts the caret at the end of the text. ### 1.4 Save - Plak saves the page to the page file about 0.5 seconds after you stop typing, and again when you quit and when plak goes to the background. - The page file is plain text, saved exactly as you typed it. Blank lines are kept, also several in a row. Plak adds only two kinds of line: the date line above a block (1.6) and the image line (1.7). - If plak cannot write the page file, a small message shows at the top of the window, and plak tries again on the next change. Plak never loses the text in memory. - If the page file does not exist, plak starts with an empty page and makes the file on the first save. - If the page file exists but cannot be read, plak shows an alert and quits without saving, so it never overwrites the file. ### 1.5 Window - One window. Plak remembers its size and position. - Esc, ⌘P (while you are in plak), ⌘W, the close button and Hide Plak in the menu bar hide plak, and the app you came from comes in front again. ⌘P, Show Plak or Spotlight shows it again. ⌘Q and Quit Plak quit. - During an input-method composition (Japanese or Chinese input, the accent popup) Esc only cancels the composition; it does not hide plak. - The window comes to the desktop you are on, and shows over an app in fullscreen. - The window has no toolbar and no title text. The title bar is transparent and shows the paper; the text scrolls under it. - The top 28 pt of the window is a drag strip over its full width: press and drag there to move the window, a double-click there does what the macOS setting for a title bar double-click says (zoom or minimise). A click in the strip never moves the caret. The pointer over the strip is the normal arrow, not the text cursor. The window buttons keep working. ### 1.6 Created date - Each block knows when it was made: the moment you typed or pasted its first character, or dropped its image. - When the margin left of the column is at least 120 pt wide, the date shows there, at the height of the first line of the block, right-aligned, small, in `inkMuted`. When the margin is narrower, no date shows. A click in the margin acts as a click in the text next to it. - Format: `16 okt 08:55` (Dutch month names, 24-hour time). The year is added only when it is not the current year: `3 mrt 2025 14:02`. - When you split a block by typing a blank line inside it, both parts keep the date of the block. When you join two blocks by deleting the blank line between them, the joined block keeps the date of the upper block. - Text you paste into a block becomes part of that block and gets no own date. A paste that starts a new block (after a blank line, or on an empty page) dates that block. - A block without a date (text from before this feature, or text typed into page.md in another app) shows no date. - In the page file, the date is a comment line directly above the first line of the block: ``, local time. Only a line that matches this exact pattern is a date; any other comment is normal text. You never see the date line in the page. ### 1.7 Images - **Paste**: ⌘V with an image on the pasteboard (a screenshot, a copied image, or a copied image file in Finder) inserts the image at the caret, on its own line. - **Drag and drop**: drag one or more image files (from Finder or a screenshot thumbnail) onto the page. While you drag, the text caret shows where the image will land. On drop, each image goes on its own line at that place. - The drop works at once, also when plak is in the background and not focused: no wait for the window to activate or for the caret to settle. - **One object**: an image is one character in the text. You can type above and below it, select it with the text, and delete it with Backspace. You never see its file name. - **Look**: an image shows at its own size, but never wider than the column. It keeps its aspect ratio. A missing file shows `image missing` in `inkMuted`, and saves back as the same line, so nothing is lost. - **Files**: plak copies each image into `~/Library/Application Support/plak/images/`. Name: `2026-10-16-085512-<4 random hex>.`. A file keeps its own type (png, jpg, gif, heic, webp). A pasted image without a file (raw image data) is saved as PNG. - **Page file**: an image is the line `![](images/)`. On read, only a line that is exactly this pattern becomes an image; any other text stays text. - **Copy**: ⌘C on a selection with an image puts plain text with the `![](images/…)` line on the pasteboard. A paste of that text back into plak shows the image again. - Plak never deletes an image file. An image you delete keeps its file in `images/` (cleaning up is for later). - Remote images (`https://…`) and browser drags without a real file are not supported in v1. ### 1.8 Keyboard | Keys | Action | |---|---| | ⌘↓ / ⌘↑ | End / start of the page | | ⌘Z / ⇧⌘Z | Undo and redo, image inserts included | | ⌘C / ⌘X / ⌘V | Normal text actions | | ⌘A | Does nothing. Plak has no Select All: the page is not meant to be cleared in one go. The Edit menu has no Select All item. | | ⌘+ / ⌘− / ⌘0 | Text size bigger, smaller, default | | ⌘P | Show the window, from any app on any desktop; in plak, hide it and go back to the previous app | | Esc | Hide plak and go back to the previous app; during an input-method composition, cancel the composition | | ⌘W | Hide plak and go back to the previous app | | ⌘Q | Save and quit | ## 2. Look - **Paper**: a mid-tone warm paper, not bright and not dark. The start values are below; we tune them on screen. | Token | Value | Use | |---|---|---| | `paper` | `#D8D0C0` | Window and page background | | `ink` | `#2B2621` | Text | | `inkMuted` | `#6E655A` | Dates, `image missing` | | `accent` | `#8A4B2A` | The caret | | `selection` | `#B9AE98` | Selected text | - **Font**: OpenDyslexic for all text, bundled in the app (OFL licence, `OFL.txt` next to the files). - **Text size** is 16 pt by default, with a line height of 1.6. - No shadows, no borders, no scroll bar unless you scroll. ## 3. Architecture SwiftPM package, macOS 14+, Swift 6, AppKit. No dependencies. | Target | Contents | |---|---| | `PlakCore` | `PageFile`: reads the page file text into plain text plus block dates and image lines, and writes it back. Block splitting (blank lines), the date line pattern, the image line pattern, the date formatter. Pure Swift, no AppKit. | | `PlakServices` | `PageStore`: reads and writes the page file, the debounced save. `ImageStore`: copies or writes image files into `images/` and gives back the relative path. | | `PlakUI` | The window, the page text view, the image attachments, the date margin, paste and drop, the theme and the fonts. | | `Plak` | The executable: the app delegate, the menu, the menu bar icon, the global ⌘P. | ### Page view - An `NSScrollView` with one editable `NSTextView` for the whole page, the text in the reading column, and a bottom inset of half the visible height. The inset changes when the window changes size. - An image is an `NSTextAttachment` that knows its relative path. - The created date is a custom text attribute on every character of a block. The date of a block is the date on its first character. When a new block has no date, plak stamps it with now. Because the characters carry the date, a split keeps the date for both parts. New typing at the start of a new block must not inherit the date of the block above. - The margin draws the dates; it is not made of views that take clicks. ### Round trip - Read the page file, then save it without a change: the file must be the same, byte for byte, except that a trailing newline is always written and CRLF becomes LF. ## 4. Build The Command Line Tools versions of `swift` and `xcodebuild` are broken on this Mac. Plak uses the same scripts as Helder: ```bash scripts/build.sh # debug build (--release for release) scripts/test.sh # all test targets; --filter scripts/run.sh # build and run scripts/bundle.sh # build/Plak.app, ad-hoc signed (--install copies it to ~/Applications) ``` - `scripts/env.sh` is a copy of Helder's: Xcode's toolchain on `PATH`, `SDKROOT` to the macOS SDK, and `DEVELOPER_DIR` set to the Command Line Tools on purpose. - Bundle id `nl.blijnder.plak`, name `Plak`. `LSUIElement` is on, so the app has no Dock icon and no ⌘Tab entry. `--install` puts it in `~/Applications`, so Spotlight finds it. - An app icon is for later. Until then the bundle has no icon. ## 5. Validation rules ### Unit tests (Swift Testing, `scripts/test.sh`) 1. Round trip: a page file with text, several blank lines in a row, date lines and image lines reads and writes back the same (rule in section 3). 2. Blocks: three paragraphs separated by blank lines give three blocks; several blank lines in a row are one separator. 3. A date line that does not match the exact pattern stays normal text. 4. A line that is not exactly `![](images/)` stays normal text. 5. The date formatter gives `16 okt 08:55` in the current year and `3 mrt 2025 14:02` in another year. 6. Typing a new block at the end stamps it with now (injected clock); typing inside a block adds no new date. 7. Typing a blank line inside a dated block gives two blocks with the same date; deleting it again gives one block with the upper date. 8. Text loaded into the text view and saved back gives the same page file, with images and dates in place. 9. `ImageStore` copies a file with its extension, writes raw image data as PNG, and makes the `images/` folder when it is missing; names follow the pattern in 1.7. 10. An image attachment is never wider than the column; a missing file gives the `image missing` placeholder and saves back as the same line. 11. Copy of a selection with an image gives the `![](images/…)` line as plain text; pasting that text gives the image again. 12. `PageStore` writes once after a burst of changes (debounce), with the latest text, and starts with an empty page when the page file is missing. ### Manual checks on the running app 13. Launch with a long page: the window shows the end of the text in the vertical middle, with the caret there. 14. Launch with an empty page: the caret is in the vertical middle. 15. Click in the middle of the page and type: the text goes there. Select across two paragraphs and delete: it works as in any text field. 16. Type `# title` and `**bold**`: they show as typed, without styling. 17. In a wide window the dates show in the left margin; in a narrow window they disappear. 18. Paste a screenshot (⇧⌃⌘4, then ⌘V): the image shows at the caret. Backspace after it deletes it; ⌘Z brings it back. 19. Drag an image from Finder into the middle of the page: the caret shows the drop place, and the image lands there. 20. Quit and open again: text, dates and images are back; page.md holds the date lines and the `![](images/…)` lines. 21. ⌘W hides the window; ⌘P shows it again with the same scroll position. 22. Plak shows no Dock icon and is not in ⌘Tab; the menu bar icon is there. Hide Plak hides the window, Show Plak shows it. 23. Show the window on desktop 1, go to desktop 2 and press ⌘P: the window comes to desktop 2. 24. Put another app in fullscreen and press ⌘P: the window shows over it. With another app in front, press ⌘P: plak comes in front with the caret ready; click the other app and it comes in front again. 25. Quit Plak from the menu bar icon, then open plak from Spotlight: it starts, scrolled to the end. 26. With plak running, scroll up, then open plak from Spotlight: it shows scrolled to the end. Do it again after ⌘W: the same. Scroll up and press ⌘P, or use Show Plak: the scroll position stays. 27. Move the pointer into the top 28 pt of the window, also after a scroll, a resize, and with another app in front: it is the arrow, and press and drag moves the window. Below the strip it is the text cursor. 28. In another app, press ⌘P, then Esc: plak hides and the other app is in front with its caret ready. Do it again with ⌘P instead of Esc: the same. ⌘P again shows plak with the same scroll position, on the current desktop. 29. ⌘W and Hide Plak also give the other app its focus back; type a word just before, quit and open again: the word is there. 30. Hold `e` for the accent popup and press Esc: the popup closes and plak stays. Start a Japanese or Chinese composition and press Esc: the composition is cancelled and plak stays. ## 6. Out of scope for v1 Remembered for later, not built now: - Cleaning up image files that no text uses any more. - Remote images and browser drags without a file. - Pasting code that becomes a code block by itself. - Drawing with the touch screen or the mouse. - A diagram editor: lines, arrows, shapes. ## 7. Choices made without asking These follow from the answers, but you did not choose them yourself. Change them here if they are wrong. - The caret starts at the end of the page when plak opens (1.2). - A launch and a reopen from Spotlight or Finder scroll to the end; ⌘P and Show Plak keep your place (1.2). - ⌘W hides the window instead of quitting (1.5). - ⌘P toggles: in plak it hides plak, from another app it shows it (1.2). Esc hides plak too (1.5). - Hiding hides the whole app, not only the window, so that the previous app gets its focus back (1.5). - The menu bar icon is the SF Symbol `note.text` (1.2). - The paper colours in section 2. - Blocks from before the date feature get no date (1.6). - A split block keeps its date in both parts; a join keeps the upper date (1.6). - A paste inside a block gets no own date (1.6). - While dragging an image, the text caret shows the drop place, not a separate line (1.7). - Blank lines are kept exactly as typed (1.4).