reading

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package reading is the desktop app's reading view (docs/design/app.md#reading-view, plan 0009): notesd renders the note as Markdown for native views (note.renderMarkdown, docs/specs/render.md#markdown-for-native-views), and MyGo's Markdown view draws it, with images read from notesd's blob store by hash (ADR-0023) and note embeds and callouts drawn from their fenced blocks. MyGo's view shows raw HTML as text, so a note runs nothing.

Index

Constants

View Source
const MaxImageFile = 128 << 20

MaxImageFile bounds the bytes of an image in the vault.

View Source
const (
	// RefreshDelay is how long blocks wait after the vault changes before
	// those on screen render again, so an embedded note follows its edits.
	RefreshDelay = time.Second
)
View Source
const RenderDelay = 300 * time.Millisecond

RenderDelay is how long the view waits after a change of the text before it renders again, as the web app's.

Variables

This section is empty.

Functions

func Decode

func Decode(data []byte, ext string) (ui.ImageSource, error)

Decode reads an image of a note or the web. Its size in pixels is checked from its header first, as a small file can declare a huge image.

func ReadImage

func ReadImage(path string) ([]byte, error)

ReadImage reads an image file of the vault, refusing one over MaxImageFile before it holds any of it.

Types

type Blocks

type Blocks struct {
	// contains filtered or unexported fields
}

Blocks draws pieces of a note as the reading view would, for live preview's callouts, tables, embeds and images: notesd renders each as if it were the note, and only those on screen are asked for. UI thread only.

func NewBlocks

func NewBlocks(env notes.Env, client func() Renderer, doc *notes.Document, blobs string) *Blocks

NewBlocks makes the blocks of doc's editor.

func (*Blocks) Changed

func (b *Blocks) Changed()

Changed says the vault changed: what shows renders again a little later.

func (*Blocks) SetRemoteImages

func (b *Blocks) SetRemoteImages(on bool)

SetRemoteImages refreshes blocks whose image load was previously refused.

func (*Blocks) View

func (b *Blocks) View(c *ui.Context, source string, width int)

View draws source, within width when it is not 0; its source, dimmed, until notesd has answered.

type Links struct {
	// Note opens a note or file of the vault; newTab with Ctrl held.
	Note func(path, subpath string, newTab bool)
	// Tag searches the vault for a tag.
	Tag func(tag string)
	// URL opens a web link outside the app.
	URL func(url string)
}

Links are where the view's links lead; the window wires them.

type Renderer

type Renderer interface {
	RenderMarkdown(ctx context.Context, p *api.NoteRenderMarkdownParams) (*api.RenderedMarkdown, error)
}

Renderer is what the view needs of notesd; api.NoteClient has it.

type View

type View struct {
	// contains filtered or unexported fields
}

View is a tab's reading view of a note. UI thread only.

func New

func New(env notes.Env, client func() Renderer, doc *notes.Document, blobs string) *View

New makes the reading view of doc. blobs is notesd's blob store (config.Paths.Blobs).

func (*View) Changed

func (v *View) Changed()

Changed says the vault changed: what the note embeds may read otherwise.

func (*View) Err

func (v *View) Err() error

Err is why the latest rendering failed, nil when it did not.

func (*View) GoTo

func (v *View) GoTo(subpath string)

GoTo scrolls to a heading or an Obsidian block ID.

func (*View) Markdown

func (v *View) Markdown() string

Markdown is the latest rendering, "" before the first.

func (*View) OnChange

func (v *View) OnChange(fn func())

OnChange calls fn on the UI thread when a new rendering arrives.

func (*View) SetRemoteImages

func (v *View) SetRemoteImages(on bool)

SetRemoteImages refreshes cached image results when the preference changes.

func (*View) View

func (v *View) View(c *ui.Context) ui.Element

View draws the note.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL