Documentation
¶
Overview ¶
Package note is the glue between the prosemirror models, the VFS, redis, the hub for realtime, etc.
Index ¶
- 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 GetFile(inst *instance.Instance, file *vfs.FileDoc) (*vfs.FileDoc, error)
- func List(inst *instance.Instance, bookmark string) ([]*vfs.FileDoc, string, error)
- 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 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() ([]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 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 ¶
This section is empty.
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 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 List ¶
List returns a list of notes sorted by descending updated_at. It uses pagination via a mango bookmark.
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 Opener ¶
type Opener struct {
// contains filtered or unexported fields
}
Opener can be used to find the parameters for creating the URL where the note can be opened.
func (*Opener) AddShareByLinkCode ¶
AddShareByLinkCode can be used to give a sharecode that can be used to open the note, when the note is in a directory shared by link.
func (*Opener) CheckPermission ¶
func (o *Opener) CheckPermission(pdoc *permission.Permission, sharingID string) error
CheckPermission takes the permission doc, and checks that the user has the right to open the note.
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