Editor:
- Toggles (Tiptap Details). Open state is per reader, not saved.
- Embeds for YouTube, Vimeo, Loom, Figma, CodePen, Spotify, Google Docs
and Maps, in sandboxed frames. Other addresses become link cards.
- Link cards with title, description and picture read by docwell-server
(GET /link-preview). The fetcher refuses private, loopback, link-local
and CGNAT addresses after DNS resolution, redirects included.
- Block links: a margin button gives a block a short id and copies
/p/<id>#b-<block>. Opening one jumps to the block and flashes it.
- Markdown, HTML and PDF exports handle the new blocks; HTML import reads
<details> as a toggle.
Pages and spaces:
- History gets a Changes view: block and word diff against the previous
version or the page as it is now.
- Archive: archived pages leave the tree and become read-only but stay
readable; a space's Archive lists them with Unarchive. New migration
(pages.archived_at) and page.archived / page.unarchived webhook events.
- Full space export (GET /spaces/{id}/export): a zip of Markdown or HTML
files with subpages in folders, an index, and attachments under _files/.
Links between exported pages and to attachments become relative paths.
Desktop 1.0:
- Several servers, each with its own sign-in; old settings files carry over.
- Session tokens in the system keychain (go-keyring), moved out of
localStorage on first start.
- Native menu bar (File, Edit, View, Window, Help) with a Server submenu.
- docwell:// links may point at a block.
- Release workflow builds Windows NSIS, macOS DMG and Linux deb, rpm and
AppImage installers and attaches them to the release;
build/set-version.mjs stamps the version into their metadata.
Not yet run: the release workflow, the desktop menus by eye, and macOS or
Linux builds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
133 lines
3.8 KiB
Go
133 lines
3.8 KiB
Go
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
"runtime"
|
|
|
|
"github.com/wailsapp/wails/v3/pkg/application"
|
|
)
|
|
|
|
// commandEvent carries a menu command to the frontend: "new-page", "search"
|
|
// or "toggle-sidebar".
|
|
const commandEvent = "docwell:command"
|
|
|
|
// docsURL is where Help → Documentation goes; release builds set it with
|
|
// -ldflags "-X main.docsURL=…". Without it the item is left out.
|
|
var docsURL = ""
|
|
|
|
// appMenu builds the native menu bar: File, Edit, View, Window and Help,
|
|
// plus the app menu on macOS. Commands that act on the page are sent to the
|
|
// frontend; switching servers saves the choice and reloads the window.
|
|
type appMenu struct {
|
|
app *application.App
|
|
win *application.WebviewWindow
|
|
settings *SettingsService
|
|
updates bool
|
|
menu *application.Menu
|
|
}
|
|
|
|
func newAppMenu(app *application.App, win *application.WebviewWindow, settings *SettingsService, updates bool) *appMenu {
|
|
m := &appMenu{app: app, win: win, settings: settings, updates: updates, menu: app.NewMenu()}
|
|
m.build()
|
|
app.Menu.Set(m.menu)
|
|
return m
|
|
}
|
|
|
|
func (m *appMenu) command(name string) func(*application.Context) {
|
|
return func(*application.Context) {
|
|
showWindow(m.win)
|
|
m.app.Event.Emit(commandEvent, name)
|
|
}
|
|
}
|
|
|
|
func (m *appMenu) route(route string) func(*application.Context) {
|
|
return func(*application.Context) {
|
|
showWindow(m.win)
|
|
m.app.Event.Emit(openRouteEvent, route)
|
|
}
|
|
}
|
|
|
|
// build fills the menu; it runs again when the server list changes.
|
|
func (m *appMenu) build() {
|
|
menu := m.menu
|
|
menu.Clear()
|
|
if runtime.GOOS == "darwin" {
|
|
menu.AddRole(application.AppMenu)
|
|
}
|
|
|
|
file := menu.AddSubmenu("File")
|
|
file.Add("New Page").SetAccelerator("CmdOrCtrl+N").OnClick(m.command("new-page"))
|
|
// Search (Ctrl+K) and the sidebar (Ctrl+/) have shortcuts in the page
|
|
// itself; an accelerator here as well would run them twice.
|
|
file.Add("Search…").OnClick(m.command("search"))
|
|
file.AddSeparator()
|
|
servers := file.AddSubmenu("Server")
|
|
if s, err := m.settings.Get(); err == nil {
|
|
for _, sv := range s.Servers {
|
|
id := sv.ID
|
|
servers.AddRadio(sv.Name, sv.ID == s.Active).OnClick(func(*application.Context) { m.switchTo(id) })
|
|
}
|
|
}
|
|
servers.AddSeparator()
|
|
servers.Add("Add or Manage Servers…").OnClick(m.route("/settings/servers"))
|
|
file.Add("Account Settings…").SetAccelerator("CmdOrCtrl+,").OnClick(m.route("/settings/account"))
|
|
file.AddSeparator()
|
|
if runtime.GOOS == "darwin" {
|
|
file.AddRole(application.CloseWindow)
|
|
} else {
|
|
file.AddRole(application.Quit)
|
|
}
|
|
|
|
menu.AddRole(application.EditMenu)
|
|
|
|
view := menu.AddSubmenu("View")
|
|
view.Add("Toggle Sidebar").OnClick(m.command("toggle-sidebar"))
|
|
view.AddSeparator()
|
|
view.AddRole(application.Reload)
|
|
view.AddSeparator()
|
|
view.AddRole(application.ResetZoom)
|
|
view.AddRole(application.ZoomIn)
|
|
view.AddRole(application.ZoomOut)
|
|
view.AddSeparator()
|
|
view.AddRole(application.ToggleFullscreen)
|
|
|
|
menu.AddRole(application.WindowMenu)
|
|
|
|
help := menu.AddSubmenu("Help")
|
|
if docsURL != "" {
|
|
help.Add("Docwell Documentation").OnClick(func(*application.Context) {
|
|
if err := m.app.Browser.OpenURL(docsURL); err != nil {
|
|
slog.Warn("could not open the documentation", "err", err)
|
|
}
|
|
})
|
|
}
|
|
if m.updates {
|
|
help.Add("Check for Updates…").OnClick(func(*application.Context) {
|
|
go func() {
|
|
if err := m.app.Updater.CheckAndInstall(context.Background()); err != nil {
|
|
slog.Warn("update check failed", "err", err)
|
|
}
|
|
}()
|
|
})
|
|
}
|
|
if runtime.GOOS != "darwin" {
|
|
help.AddSeparator()
|
|
help.AddRole(application.About)
|
|
}
|
|
menu.Update()
|
|
}
|
|
|
|
// switchTo makes another saved server active and reloads the window, which
|
|
// then loads that server's settings and keychain token.
|
|
func (m *appMenu) switchTo(id string) {
|
|
if _, err := m.settings.SetActive(id); err != nil {
|
|
slog.Warn("could not switch server", "server", id, "err", err)
|
|
return
|
|
}
|
|
showWindow(m.win)
|
|
m.win.Reload()
|
|
}
|