Skip to the content.

Table of contents

Cozy notes doctypes

io.cozy.notes.documents

This doctype is not persisted in CouchDB, it is only used to create a note, and this note will be persisted as an io.cozy.files. Its attributes are:

Example (JSON-API format)

{
  "data": {
    "type": "io.cozy.notes.documents",
    "attributes": {
      "title": "My new note",
      "dir_id": "f48d9370-e1ec-0137-8547-543d7eb8149c",
      "schema": {
        "nodes": [
          ["doc", { "content": "block+" }],
          ["paragraph", { "content": "inline*", "group": "block" }],
          ["blockquote", { "content": "block+", "group": "block" }],
          ["horizontal_rule", { "group": "block" }],
          [
            "heading",
            {
              "content": "inline*",
              "group": "block",
              "attrs": { "level": { "default": 1 } }
            }
          ],
          ["code_block", { "content": "text*", "marks": "", "group": "block" }],
          ["text", { "group": "inline" }],
          [
            "image",
            {
              "group": "inline",
              "inline": true,
              "attrs": { "alt": {}, "src": {}, "title": {} }
            }
          ],
          ["hard_break", { "group": "inline", "inline": true }],
          [
            "ordered_list",
            {
              "content": "list_item+",
              "group": "block",
              "attrs": { "order": { "default": 1 } }
            }
          ],
          ["bullet_list", { "content": "list_item+", "group": "block" }],
          ["list_item", { "content": "paragraph block*" }]
        ],
        "marks": [
          ["link", { "attrs": { "href": {}, "title": {} }, "inclusive": false }],
          ["em", {}],
          ["strong", {}],
          ["code", {}]
        ],
        "topNode": "doc"
      }
    }
  }
}

io.cozy.notes.steps

This doctype is used for prosemirror steps. You can see them as a kind of patch on a note. It describes a small transformation on the note. Its attributes are:

Example (JSON in CouchDB)

{
  "_id": "d9fc3726f254a0ccfb2ca30d9e00142a/00000001",
  "_rev": "1-894d54b267404abad9a1cf08f1a8a663",
  "from": 1,
  "sessionID": "cozy.tools75:1576503622324.324.0.9928191162716804",
  "slice": {
    "content": [
      {
        "text": "H",
        "type": "text"
      }
    ]
  },
  "stepType": "replace",
  "timestamp": 1576503628,
  "to": 1,
  "version": 1
}

io.cozy.notes.telepointers

This doctype is not persisted, it is sent by the clients to the stack, and the stack send them to the other clients via the realtime websockets. Its attributes are:

Example (JSON-API format)

{
  "data": {
    "type": "io.cozy.notes.telepointers",
    "id": "f48d9370-e1ec-0137-8547-543d7eb8149c",
    "attributes": {
      "sessionID": "543781490137",
      "anchor": 7,
      "head": 12,
      "type": "textSelection"
    }
  }
}

io.cozy.notes.events

This doctype is only used for sending the events related to a note in the realtime websockets. The client subscribes to a note, and the server send events on this note, that can be a change on the note title, its content, or a telepointer update.

Example

client > {"method": "SUBSCRIBE",
          "payload": {"type": "io.cozy.notes.events",
                      "id": "f48d9370-e1ec-0137-8547-543d7eb8149c"}}
server > {"event": "UPDATED",
          "payload": {"id": "f48d9370-e1ec-0137-8547-543d7eb8149c",
                      "type": "io.cozy.notes.events",
                      "doc": {"doctype": "io.cozy.notes.documents",
                              "sessionID": "543781490137",
                              "title": "this is the new title of this note"}}}
server > {"event": "CREATED",
          "payload": {"id": "f48d9370-e1ec-0137-8547-543d7eb8149c",
                      "type": "io.cozy.notes.events",
                      "doc": {"doctype": "io.cozy.notes.steps",
                              "sessionID": "543781490137",
                              "version": 6,
                              "stepType": "replace",
                              "from": 1,
                              "to": 1,
                              "slice": {"content": [{"type": "text", "text": "H"}]}}}}
server > {"event": "UPDATED",
          "payload": {"id": "f48d9370-e1ec-0137-8547-543d7eb8149c",
                      "type": "io.cozy.notes.events",
                      "doc": {"doctype": "io.cozy.notes.telepointers", "sessionID": "543781490137", "anchor": 7, "head": 12, "type": "textSelection"}}}