Skip to main content

Module blocks

Module blocks 

Source
Expand description

Block tree navigation by index path ([2, 0] = first child of the third top-level block).

Structs§

ExerciseCopy
An exercise block a copy duplicated. The caller creates the new exercise from the source’s settings.

Constants§

EXERCISE_BLOCK
The name of the block that embeds an exercise; its id attribute is the exercise id.
EXERCISE_INTERNAL_BLOCKS 🔒
Blocks that only exist inside an exercise block’s editor tree.
RENDERED_BLOCK_KEYS 🔒
Keys a page read adds to a block besides its stored fields. Writes ignore them, so a block read back can be written again.
TEXT_ATTRIBUTES 🔒
Attributes that hold a block’s text, most telling first: bulk edits search them unless told otherwise, and a block’s preview is the first one with text.

Functions§

ancestor_ids
The parent ids of the block at path, outermost first.
attribute 🔒
The value at JSON Pointer pointer (non-empty, escaped) inside attributes.
content_counts
A page’s block count, nested blocks included, and its exercise count, as the course structure shows them.
copy_blocks
Copies source for page_id with new block ids. Exercise blocks get new exercise ids, listed in the result.
count_blocks 🔒
find_path
The index path of the block id, if the tree has it.
for_each_string
Visits every string value inside attributes.
for_each_string_mut
Visits every string value inside attributes, to change it in place.
get
The block at an index path. Paths come from find_path on the same tree, so the error, for an empty path or one the tree doesn’t have, means the location went stale.
get_mut
get, to change the block.
is_exercise
Whether the block embeds an exercise.
is_exercise_part
An exercise block or a block of an exercise’s editor tree.
is_in_exercise
Whether the block at path is inside an exercise’s editor tree; with include_self, also whether it is part of one itself. Errors with stale_location if the tree lacks path.
list
list_mut, to read.
list_mut
The children list whose parent is at parent_path; the top level for an empty path.
stale_location 🔒
The error for a located block or range the tree no longer has.
walk
Depth-first, pre-order visit of every block with its index path ([2, 0] is the first child of the third top-level block).
walk_mut_outside_exercises
Like walk_mut, but never enters an exercise, whose blocks page edits don’t touch.
walk_outside_exercises
Like walk, but never enters an exercise, whose blocks page edits don’t touch.