rmapi-js
    Preparing search index...

    Class ClientTemplate

    a template's .template read through a Client, with its reference, to edit and push back

    It reads and edits as a Template does, and pushes, pulls, merges and gives its file back as a ClientMetadata does. Its name is the item's: a push of a definition with a new name renames the template.

    Hierarchy (View Summary)

    Index
    • get author(): string

      who made it

      Returns string

    • 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 name(): string

      the name shown

      Returns string

    • get templateVersion(): string

      its version, as the file holds it

      Returns string

    • 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
      }
      }
    • 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 the categories it is listed under

      Parameters

      • categories: string[]

      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 its labels, or remove them

      Parameters

      • labels: string[] | undefined

      Returns this

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

      Returns Uint8Array

    • 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