Skip to content
Open
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
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</head>
<body>
<div id="app">
<header id="titlebar" data-tauri-drag-region>
<header id="titlebar">
<div class="traffic-lights-spacer"></div>
<div class="title" data-tauri-drag-region>
<div class="title">
<span id="filename">untitled.md</span>
<span id="modified-indicator" class="hidden" title="Unsaved changes"></span>
</div>
Expand Down
1 change: 0 additions & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-deep-link = "2.4.6"
url = "2.5.8"

1 change: 1 addition & 0 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"core:window:allow-destroy",
"core:window:allow-set-title",
"core:window:allow-set-focus",
"core:window:allow-set-position",
"opener:default",
"dialog:default",
"fs:default",
Expand Down
33 changes: 33 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Editor } from '@tiptap/core'
import { TextSelection } from '@tiptap/pm/state'
import { LogicalPosition } from '@tauri-apps/api/dpi'
import { getCurrentWindow } from '@tauri-apps/api/window'
import { createQuillEditor, ensureGrammarsForDoc, getMarkdown, setMarkdown } from './editor-setup'
import { FileOps } from './file-ops'
import { selectStartupFiles } from './startup-files'
Expand Down Expand Up @@ -86,6 +88,37 @@ document.addEventListener('DOMContentLoaded', async () => {
const modifiedIndicator = document.getElementById('modified-indicator')!
const wordCountEl = document.getElementById('word-count')!
const editorEl = document.getElementById('editor')!
const titlebarEl = document.getElementById('titlebar')!

// macOS 27 can reject AppKit's performWindowDragWithEvent for an overlay
// titlebar. Move only this header by cursor delta instead; the editor never
// receives this listener, so text selection and its own drag/drop are intact.
titlebarEl.addEventListener('mousedown', async event => {
if (event.button !== 0) return
event.preventDefault()

try {
const win = getCurrentWindow()
const [position, scale] = await Promise.all([win.outerPosition(), win.scaleFactor()])
const startX = event.screenX
const startY = event.screenY

const move = (moveEvent: MouseEvent) => {
const x = position.x / scale + moveEvent.screenX - startX
const y = position.y / scale + moveEvent.screenY - startY
void win.setPosition(new LogicalPosition(x, y))
}
const stop = () => {
window.removeEventListener('mousemove', move)
window.removeEventListener('mouseup', stop)
}

window.addEventListener('mousemove', move)
window.addEventListener('mouseup', stop, { once: true })
} catch {
// Browser-based harness: no native window.
}
})

// --- editor ---
let fileOps: FileOps
Expand Down
1 change: 0 additions & 1 deletion src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ button {
background: var(--bg-primary);
user-select: none;
-webkit-user-select: none;
-webkit-app-region: drag;
flex-shrink: 0;
}

Expand Down