Documentation ¶
Overview ¶
Package note is the glue between the prosemirror models, the VFS, redis, the hub for realtime, etc.
Index ¶
- Constants
- Variables
- func ApplySteps(inst *instance.Instance, file *vfs.FileDoc, lastVersion string, steps []Step) (*vfs.FileDoc, error)
- func Create(inst *instance.Instance, doc *Document) (*vfs.FileDoc, error)
- func DefaultSchemaSpecs() map[string]interface{}
- func FlushPendings(inst *instance.Instance) error
- func GetFile(inst *instance.Instance, file *vfs.FileDoc) (*vfs.FileDoc, error)
- func ImportFile(inst *instance.Instance, newdoc, olddoc *vfs.FileDoc, body io.ReadCloser) error
- func List(inst *instance.Instance, bookmark string) ([]*vfs.FileDoc, string, error)
- func PublishThumbnail(inst *instance.Instance, event Event)
- func PutTelepointer(inst *instance.Instance, t Event) error
- func Update(inst *instance.Instance, fileID string) error
- func UpdateMetadataFromCache(inst *instance.Instance, docs []*vfs.FileDoc)
- func UpdateSchema(inst *instance.Instance, file *vfs.FileDoc, schema map[string]interface{}) (*vfs.FileDoc, error)
- func UpdateTitle(inst *instance.Instance, file *vfs.FileDoc, title, sessionID string) (*vfs.FileDoc, error)
- type DebounceMessage
- type Document
- func (d *Document) Clone() couchdb.Doc
- func (d *Document) Content() (*model.Node, error)
- func (d *Document) DocType() string
- func (d *Document) GetDirID(inst *instance.Instance) (string, error)
- func (d *Document) ID() string
- func (d *Document) Markdown(images []*Image) ([]byte, error)
- func (d *Document) Metadata() map[string]interface{}
- func (d *Document) Rev() string
- func (d *Document) Schema() (*model.Schema, error)
- func (d *Document) SetContent(content *model.Node)
- func (d *Document) SetID(id string)
- func (d *Document) SetRev(rev string)
- type Event
- func (e Event) Clone() couchdb.Doc
- func (e Event) DocType() string
- func (e Event) ID() string
- func (e Event) Included() []jsonapi.Object
- func (e Event) Links() *jsonapi.LinksList
- func (e Event) Relationships() jsonapi.RelationshipMap
- func (e Event) Rev() string
- func (e Event) SetID(id string)
- func (e Event) SetRev(rev string)
- type Image
- type ImageUpload
- type Opener
- type Step
- func (s Step) Clone() couchdb.Doc
- func (s Step) DocType() string
- func (s Step) ID() string
- func (s Step) Included() []jsonapi.Object
- func (s Step) Links() *jsonapi.LinksList
- func (s Step) Relationships() jsonapi.RelationshipMap
- func (s Step) Rev() string
- func (s Step) SetID(id string)
- func (s Step) SetRev(rev string)
Constants ¶
const MaxImageWeight = 100 * 1024 * 1024
MaxImageWeight is the maximal weight (in bytes) for an image.
const MaxMarkdownSize = 2 * 1024 * 1024
MaxMarkdownSize is the maximal size of a markdown that can be parsed.
const MaxWidth = 768
MaxWidth is the maximal width of an image for a note. If larger, the image will be resized.
Variables ¶
var ( // ErrInvalidSchema is used when the schema cannot be read by prosemirror. ErrInvalidSchema = errors.New("Invalid schema for prosemirror") // ErrInvalidFile is used when a file doesn't have the metadata to be used // as a note. ErrInvalidFile = errors.New("Invalid file, not a note") // ErrNoSteps is used when steps are expected, but there are none. ErrNoSteps = errors.New("No steps") // ErrInvalidSteps is used when prosemirror can't instantiate the steps. ErrInvalidSteps = errors.New("Invalid steps") // ErrCannotApply is used when trying to apply some steps, but it fails // because of a conflict. The client can try to rebase the steps. ErrCannotApply = errors.New("Cannot apply the steps") // ErrTooOld is used when the steps just after the given revision are no // longer available. ErrTooOld = errors.New("The revision is too old") // ErrMissingSessionID is used when a telepointer has no identifier. ErrMissingSessionID = errors.New("The session id is missing") )
Functions ¶
func ApplySteps ¶
func ApplySteps(inst *instance.Instance, file *vfs.FileDoc, lastVersion string, steps []Step) (*vfs.FileDoc, error)
ApplySteps takes a note and some steps, and tries to apply them. It is an all or nothing change: if there is one error, the note won't be changed.
func DefaultSchemaSpecs ¶
func DefaultSchemaSpecs() map[string]interface{}
DefaultSchemaSpecs returns the prosemirror schema used when importing files.
func FlushPendings ¶
FlushPendings is used to persist all the notes before an export.
func GetFile ¶
GetFile takes a file from the VFS as a note and returns its last version. It is useful when some changes have not yet been persisted to the VFS.
func ImportFile ¶
func List ¶
List returns a list of notes sorted by descending updated_at. It uses pagination via a mango bookmark.
func PublishThumbnail ¶
PublishThumbnail sends information about a resized image.
func PutTelepointer ¶
PutTelepointer sends the position of a pointer in the realtime hub.
func UpdateMetadataFromCache ¶
UpdateMetadataFromCache update the metadata for a file/note with the information in cache.
Types ¶
type DebounceMessage ¶
type DebounceMessage struct {
NoteID string `json:"note_id"`
}
DebounceMessage is used by the trigger for saving the note to the VFS with a debounce.
type Document ¶
type Document struct { DocID string `json:"_id"` DocRev string `json:"_rev,omitempty"` CreatedBy string `json:"-"` DirID string `json:"dir_id,omitempty"` // Only used at creation Title string `json:"title"` Version int64 `json:"version"` SchemaSpec map[string]interface{} `json:"schema"` RawContent map[string]interface{} `json:"content"` // contains filtered or unexported fields }
Document is the note document in memory. It is persisted to the VFS as a file, but with a debounce: the intermediate states are saved in Redis.
func (*Document) GetDirID ¶
GetDirID returns the ID of the directory where the note will be created.
func (*Document) SetContent ¶
SetContent updates the content of this note, and clears the cache.
type Event ¶
type Event map[string]interface{}
Event is a realtime event for a note (like the update of the position of a pointer).
func (Event) Relationships ¶
func (e Event) Relationships() jsonapi.RelationshipMap
Relationships is part of the jsonapi.Object interface
type Image ¶
type Image struct { DocID string `json:"_id,omitempty"` DocRev string `json:"_rev,omitempty"` Name string `json:"name"` Mime string `json:"mime"` Width int `json:"width,omitempty"` Height int `json:"height,omitempty"` ToResize bool `json:"willBeResized,omitempty"` ToRemove bool `json:"willBeRemoved,omitempty"` Metadata metadata.CozyMetadata `json:"cozyMetadata,omitempty"` // contains filtered or unexported fields }
Image is a file that will be persisted inside the note archive.
type ImageUpload ¶
type ImageUpload struct { Image *Image // contains filtered or unexported fields }
ImageUpload is used while an image is uploaded to the stack.
func NewImageUpload ¶
func NewImageUpload(inst *instance.Instance, note *vfs.FileDoc, name, mime string) (*ImageUpload, error)
NewImageUpload can be used to manage uploading a new image for a note.
func (*ImageUpload) Close ¶
func (u *ImageUpload) Close() error
Close is called to finalize an upload.
type Opener ¶
type Opener struct {
*sharing.FileOpener
}
Opener can be used to find the parameters for creating the URL where the note can be opened.
type Step ¶
type Step map[string]interface{}
Step is a patch to apply on a note.
func (Step) Relationships ¶
func (s Step) Relationships() jsonapi.RelationshipMap
Relationships is part of the jsonapi.Object interface