rmapi-js
    Preparing search index...

    Class Template

    a template's .template: what it draws

    Hierarchy (View Summary)

    Index
    • get formatVersion(): number | undefined

      the format version of the file

      Returns number | undefined

    • get hasEdits(): boolean

      whether an edit changes the file from the version as read

      Returns boolean

    • get iconData(): string

      the icon, as the file holds it

      Returns string

    • get templateVersion(): string

      its version, as the file holds it

      Returns string

    • the categories it is listed under

      Returns string[]

    • every key the core does not read

      Returns Record<string, Json>

    • its labels

      Returns string[] | undefined

    • what it draws on a page of size

      Constants, groups, repeats, paths and text are worked out for the page, and the marks come back in the page's pixels in the order to draw them. A page starts the screen's size and grows taller as it is scrolled down, as PageSize.scrolled gives it. The template's sizes, templateWidth, templateHeight and paperOriginX, are the screen's, as the tablet works them out, while its repeats fill the whole page. A page records its screen's size, as Page.paperSize, but not how far it has grown.

      The size's width by height is the screen as the page stands: for a page of a landscape notebook, one whose .content orientation is "landscape", pass Page.paperSize swapped, its height then its width, since the tablet turns the whole notebook. The tablet lays a template out on the upright screen whichever way the page stands, and whatever orientation the template gives itself: templateWidth is the screen's shorter side. On a page wider than that the drawing is moved right to the middle, by half of how much wider it is, and its repeats fill the wider page.

      rmapi does not draw the marks. To draw them as the tablet does, set text in IBM Plex Sans, bold where bold is set: it is free under the Open Font License, and near reMarkable Sans, whose widths place the text. Stroke shapes with square (projecting) caps and bevel joins (lineCap = "square", lineJoin = "bevel" on a canvas), dashed by dash; a strokeWidth of 0 is the thinnest line the screen can draw. Hairlines come out 0.5 pixels wide in gray #c0c0c0.

      Parameters

      Returns TemplateDrawing

      LayoutError if the template cannot be worked out

      const drawing = Template.builtIn("linesSmall").layout(
      new PageSize(1404, 1872),
      );
      for (const mark of drawing.marks) {
      if (mark.type === "shape") {
      // stroke mark.steps mark.strokeWidth wide in mark.stroke
      }
      }
    • put this file's edits on newer, a copy read since, and hold that, returning the keys both changed to different values, as Metadata.merge does

      Parameters

      Returns string[]

    • remove a key of the file: a key the core reads clears its field, or sets it to what a file without the key reads it as

      Parameters

      • key: string

      Returns this

      Warning: as for setExtra, this can leave the file at odds with itself. Prefer the field's own setter.

      ValidationError if key names a field the file must have; the file is left as it was

    • set who made it

      Parameters

      • author: string

      Returns this

    • set the categories it is listed under

      Parameters

      • categories: string[]

      Returns this

    • set the constants its items use

      Parameters

      Returns this

    • set a key of the file: a key the core reads sets its field, and any other is kept in extra

      Parameters

      • key: string
      • value: Json

      Returns this

      Warning: a key the core reads is written as given, past the rules its own setter keeps, so it can leave the file at odds with itself, such as a pageCount that does not count the pages listed. Prefer the field's own setter, such as setPages for the page keys.

      ValidationError if value is not a value of the field key names; the file is left as it was

    • set the format version of the file, or remove it

      Parameters

      • version: number | undefined

      Returns this

      RangeError if version is not a safe integer

    • set the icon

      Parameters

      • icon: string

      Returns this

    • set its labels, or remove them

      Parameters

      • labels: string[] | undefined

      Returns this

    • rename it

      Parameters

      • name: string

      Returns this

    • set the screens it is made for

      Parameters

      Returns this

    • set its version

      Parameters

      • version: string

      Returns this

    • the file with its edits made, as the account holds it

      Returns Uint8Array

    • the file with its edits made, as JSON

      Returns Record<string, Json>

    • read a .template from what toJSON gave, or a copy of it, as read from the account at at; the core checks every field

      Parameters

      • value: unknown
      • at: Date = ...

      Returns Template

      TypeError if value is not an object

    • read a .template from its bytes, read from the account at at

      Parameters

      • bytes: Uint8Array
      • at: Date = ...

      Returns Template