Documentation
¶
Overview ¶
Package compose is the desktop app's compose window (docs/specs/compose-ui.md; plan 0015, Phase 5): the draft's HTML through MyGo's rich text editor, the recipients, the attachments, and sending.
Index ¶
- func HTMLText(src string) string
- func HasAttachment(src string, attachments int) bool
- func KeepPastedImages(t richtext.Text, html string) (lost int)
- func MentionsAttachment(text string) bool
- func NeedsReminder(src, signatureHTML string, attachments int) bool
- func OwnText(src, signatureHTML string) string
- func ParseAddresses(text string) (addresses []api.Address, invalid []string)
- func ToHTML(t richtext.Text) string
- func ToText(src string, load PartLoader) richtext.Text
- func Token(a api.Address) string
- func TomorrowMorning(now time.Time) time.Time
- func ValidAddress(text string) bool
- type Choice
- type Options
- type PartLoader
- type TimeSheet
- type Window
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTMLText ¶
HTMLText is the text of HTML: blocks and line breaks end a line, then white space is squashed.
func HasAttachment ¶
HasAttachment reports a chip, or an image outside every quote.
func KeepPastedImages ¶
KeepPastedImages gives each picture in t that has only a bitmap the source it had in html, the clipboard's HTML it was pasted from: the editor drops that source, and a bitmap's bytes cannot be read back. A paste repeated in one frame brings the same pictures again. It returns how many have no usable source, or one that would take the draft's HTML past maxDraftHTML; those lose their bitmap, so that they show empty and are not asked about again.
func MentionsAttachment ¶
MentionsAttachment reports whether text holds an attachment word as a whole word.
func NeedsReminder ¶
NeedsReminder reports whether the user's own text mentions an attachment and none is attached.
func OwnText ¶
OwnText is the text the user wrote: no quotes, no attribution line, no signature (docs/specs/compose-ui.md, Attachment reminder).
func ParseAddresses ¶
ParseAddresses splits typed or pasted text into addresses, dropping repeats without regard to case; pieces that do not parse come back as invalid, trimmed.
func ToHTML ¶
ToHTML writes the editor's text as the draft's HTML: a quotation's depth as nested <blockquote type="cite">, lists as <ul> and <ol>, nested by their items' Indent. QuoteDepth is independent of the list nesting.
func ToText ¶
func ToText(src string, load PartLoader) richtext.Text
ToText reads a draft's HTML as the editor's text. Headings read as body paragraphs, as TipTap's schema has none, and images that are neither data: nor mailpart: are dropped, since the app never loads remote content.
func Token ¶
Token writes an address as a recipient field's token, which reads back as this one recipient whatever the mail it came from says: the text is untrusted. An address that cannot be written plainly becomes one quoted piece, which is invalid and holds the send back.
func TomorrowMorning ¶
TomorrowMorning is where the Send Later sheet starts.
func ValidAddress ¶
ValidAddress reports whether text is a plausible email address.
Types ¶
type Choice ¶
Choice is a Send Later choice and its time.
func SendChoices ¶
SendChoices offers tonight at 9 PM while that is ahead, then tomorrow at 8 AM, in now's zone.
type Options ¶
type Options struct {
// Client is maild's client now, nil while there is none. It runs on
// the UI thread: a worker uses the client read for it there.
Client func() *api.Client
Draft int64
// Fresh says the draft was just made for this window: closed
// untouched, it is deleted.
Fresh bool
Post func(func())
Now func() time.Time
// Close closes the window, and may run on a worker; Hide hides it
// while its last save ends, and Show shows it again when that save
// failed; SetTitle names it.
Close func()
Hide func()
Show func()
SetTitle func(string)
// OpenFiles asks for files to attach; none when cancelled. It runs on
// a worker.
OpenFiles func() ([]string, error)
// FilesAsBytes sends a file's bytes rather than its path: maild cannot
// read this computer's paths behind lodge, or from the Flatpak. It says
// so for the connection of the moment.
FilesAsBytes func() bool
// LoadPart reads a mailpart: image for the editor, through c, which is
// nil while disconnected. It runs on a worker.
LoadPart func(c *api.Client, src string) ([]byte, error)
// Sent tells the main window a message went into the Outbox.
Sent func(item *api.OutboxItem)
// EditSnippets opens Settings on its Snippets pane.
EditSnippets func()
// Kept says a close ended with the window open again: its save on
// closing failed, which the window shows. It runs on the UI thread.
Kept func()
}
Options configure a compose window.
type PartLoader ¶
PartLoader reads a mailpart: image's bytes; nil, or an error, leaves the image without a picture but keeps it in the draft.
type TimeSheet ¶
type TimeSheet struct {
// contains filtered or unexported fields
}
TimeSheet asks for a future date and time, for Send Later and Remind Me. Keep one in the window's state, Show it, and call View every frame.
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is one draft's window. Its state belongs to the UI thread.
func (*Window) RequestClose ¶
RequestClose says whether the window may go now. Asked first, it says no: it hides the window and starts the save on closing, whose end closes the window again through Options.Close, and only then does it say yes. So the app, which quits with its last window, outlives the save. A snippet still being read goes in first, and the save starts after it. A save that fails shows the window again (keep).
func (*Window) SaveNow ¶
SaveNow writes what is left of the draft before it returns, waiting at most limit: the OS ends the session (logout, shutdown), and the process can end once the quit's listeners return. It never deletes an untouched draft. Call it on the UI thread.