Skip to the content
v1.0.1-beta.17

Steps, timelines and tabs

Blocks that hold other blocks, for content in parts: numbered steps or a timeline, and tabbed panels.

Steps and timelines

The steps add-on adds StepsNode, JSON type "steps": a numbered procedure, or a timeline whose entries each have a label such as a date. Each step holds text and blocks, the way a table cell does, so a step can have a code sample, a picture or a list under its text.

import {StepsNode, StepsStyles} from "./dist/addons/scriviamo.steps.js"

let steps = new StepsNode(3)
steps.cells[0].append(new RichText("Install the package."))
editor.addNode(steps)

let history = new StepsNode(2)
history.stepsStyle = StepsStyles.timeline
history.labels = ["2024", "March 2026"]
PropertyMeaning
stepsStyleStepsStyles.numbered (the default) or StepsStyles.timeline
labelsEach entry's label, shown on a timeline
countHow many steps there are
cellsEach step's content: its text and, in nodes, its blocks

insertRow(at) adds an empty step, removeRow(index) removes one with its label and blocks, and moveStep(index, by) moves one up (negative) or down. The toolbar offers the same, and switches between steps and a timeline. Tab moves to the next step, and adds one after the last.

Steps export as <ol class="steps"> and timelines as <ol class="timeline">, each step an <li class="step">, a timeline's label a <p class="step-label"> inside it; both import back. Markdown is a numbered list for steps, and a bulleted list with each label in bold for a timeline, with each step's blocks indented under it.

Tabs

The premium tabs add-on adds TabsNode, JSON type "tabs": a row of titles, with the panel of the chosen one under it. Each panel holds text and blocks. Click a title to show its panel, and type in it to rename the tab.

import {TabsNode} from "./dist/addons/scriviamo.tabs.js"

let tabs = TabsNode.create(editor) as TabsNode
tabs.titles = ["npm", "Yarn"]
tabs.cells[0].append(new RichText("npm install scriviamo"))
tabs.cells[1].append(new RichText("yarn add scriviamo"))
editor.addNode(tabs)
Property or methodMeaning
titlesEach tab's title
activeTabThe tab shown, which is saved, so a document opens on the tab it was left on
showTab(index)Shows a tab without recording a change
insertTab(at), removeTab(index), moveTab(index, by)Change the tabs, as one undo step each
titleOf(index)The title shown: the tab's own, or "Tab 2" when it has none

An exported document can't switch tabs without a script, so HTML shows every panel in turn, each a <section class="tab"> under an <h3 class="tab-title">, inside <div class="tabs">, which imports back as tabs. Markdown and text show each panel under its title in bold, so the document's own headings stay its own.