
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
@strelka/slate-edit-list
Advanced tools
A Slate plugin to handle keyboard events in lists. List items can contain blocks.
Demo: gitbookio.github.io/slate-edit-list/
npm install @strelka/slate-edit-list
Natural keybindings:
Simple validation/normalization (see assumptions about the schema):
Useful transforms: see Utilities and Transform.
import EditList from '@strelka/slate-edit-list'
const plugins = [
EditList()
]
This plugin accepts options to redefine the following block types:
types: string = ["ol_list", "ul_list"] — the array of possible types for list containers. First value will be used as default.typeItem: string = "list_item" — type for list items.typeDefault: string = "paragraph" — type for default block in list items.canMerge: (Node, Node) => boolean — controls which list can be merged automatically (for example when they are adjacent). Defaults to merging list with identical typesYou can use this plugins with custom list block types (using plugin arguments). But your lists structure should still conform to a few rules. These rules are implemented as schema.
Here is what a minimal list would look like:
nodes:
- kind: block
type: ul_list # Default type for bulleted lists container
nodes:
- kind: block
type: list_item # List containers can only contain list items
nodes:
# List items contain blocks. They cannot be the direct container of text.
- kind: block
type: paragraph # Default type of blocks in a list item
nodes:
- kind: text
text: Hello World
And here is an example of a multi-level list:
nodes:
- kind: block
type: ol_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
text: Item 1
- kind: block
type: ol_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
text: Item 1.1
- kind: block
type: list_item
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
text: Item 1.2
slate-edit-list exports utilities and transforms:
plugin.utils.isSelectionInList(value: Value, type?: string) => BooleanReturn true if selection is inside a list (and it can be unwrap). Optional param type can be supplied to deduce whether list is of specified type.
plugin.utils.isList(node: Node) => BooleanReturn true if the node is one of the list type.
plugin.utils.getItemDepth(value: Value, block: Block?) => NumberReturns the depth of the current item (or the depth of the given block) in a list. 0 means not in a list.
plugin.utils.getCurrentItem(value: Value, block: Block?) => Block || VoidReturns the current item at selection (or at the given block).
plugin.utils.getCurrentList(value: Value, block: Block?) => Block || VoidReturns the current list at selection (or at the given block).
plugin.utils.getItemsAtRange(value: Value, range: Selection?) => List<Node>Return the list of items at the given range. The returned items are the highest list of of successive items that cover the given range.
The returned list is empty if no such list can be found.
plugin.changes.increaseItemDepth(change: Change) => TransformIncrease the depth of the current item.
plugin.changes.decreaseItemDepth(change: Change) => TransformDecrease the depth of the current item.
plugin.changes.wrapInList(change: Change, type: String?, data: Object|Data?) => TransformWrap the current blocks in list items of a list container of the given type. You can pass optional data for the created list container.
plugin.changes.unwrapList(change: Change) => TransformUnwrap all items at range from their list.
plugin.changes.splitListItem(change: Change) => TransformSplit current block into a new list item.
FAQs
A Slate plugin to handle keyboard events in lists. (FORK)
The npm package @strelka/slate-edit-list receives a total of 0 weekly downloads. As such, @strelka/slate-edit-list popularity was classified as not popular.
We found that @strelka/slate-edit-list demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.