updates plak menu item

This commit is contained in:
2026-10-28 16:18:03 +01:00
parent 92b90c0e13
commit 9bdda896af
13 changed files with 339 additions and 8 deletions
+63
View File
@@ -0,0 +1,63 @@
# Plak URL scheme
Plak is the user's scratchpad app for macOS. Other apps add text to it through two `plak://` URLs. This page is the contract that Helder relies on.
## `plak://append?text=<text>`
Adds the text at the end of the Plak page, as a new block with its own created date.
- Percent-encode the text as a URL query value: space `%20`, newline `%0A`, `&` `%26`, `+` `%2B`, `#` `%23`.
- Never encode a space as `+`. Plak keeps a `+` literal, so the block would show `+` signs.
- Plak detects the content type as for a paste. PHP, JSON, XML and CSV become a code block or a table. All other text becomes plain text.
## `plak://paste`
Adds the current contents of the macOS general pasteboard, text or images.
- Use it for images and for text over about 100 KB, where a long URL can fail to open.
- Put the content on the pasteboard first, then open the URL.
- Save the user's clipboard before, and restore it one second after.
## What Plak does
- Plak starts if it is not running. It shows its window, scrolled to the new content, and takes the focus.
- An empty or missing `text` adds nothing, but Plak still shows.
- Every other `plak://` URL does nothing.
- There is no callback and no error result. The sender cannot know if the add worked.
## Opening the URL
```sh
open "plak://append?text=Hello%20from%20my%20app"
```
```swift
var components = URLComponents()
components.scheme = "plak"
components.host = "append"
components.queryItems = [URLQueryItem(name: "text", value: text)]
// URLQueryItem leaves "+" as it is; encode it yourself.
components.percentEncodedQuery = components.percentEncodedQuery?
.replacingOccurrences(of: "+", with: "%2B")
if let url = components.url { NSWorkspace.shared.open(url) }
```
```applescript
open location "plak://append?text=Hello%20from%20my%20app"
```
```js
shell.openExternal("plak://append?text=" + encodeURIComponent(text))
```
```python
subprocess.run(["open", "plak://append?text=" + urllib.parse.quote(text, safe="")])
```
## In Helder
- The **Plak** item in the right-click menu of the code and of both terminal panes uses this scheme. See [behaviour.md](behaviour.md#plak) and the [right-click guide](guide/right-click-menu.md#plak).
- URL building and the 100 KB choice: `Plak` in `Sources/HelderCore/Files/Plak.swift`. The limit counts UTF-8 bytes.
- Opening the URL and the clipboard save and restore: `SystemActing.sendToPlak` in `Sources/HelderUI/Shell/SystemActions.swift`.
Later, Plak will replace Helder's own notes (`.notes.txt`, `Cmd+N`; see [Notes](guide/notes.md)).