Skip to main content

Crate devup_editor_input_rules

Crate devup_editor_input_rules 

Source
Expand description

Markdown shortcut, special-character, and inline-mark matchers for the devup editor input-rule pipeline.

Every matcher is a pure function of (block_text, cursor_offset): no DOM, no editor handle, no commands. The React layer calls into these matchers, inspects the returned [Match] payload, and synthesises the appropriate dispatchBatch sequence on the JS side. This keeps command dispatch (which needs an EditorHandle) in React and confines the hot-path string work to Rust.

The regex patterns, delimiter rules, and skip-~~ reservation are mirrored byte-for-byte from the TypeScript source so behaviour is identical under typical clipboard / keyboard interactions.

Structs§

InlineMatch
Match payload for the seven delimiter-pair marks (bold, italic *2, strike, underline, highlight, code).
LinkMatch
Match payload specifically for [text](url). Carries both the text and the URL so the React side can store href on the mark.
MarkdownMatch
Result of a successful markdown-shortcut match. The dispatch side (React + WASM) turns this into setSelection(0..prefix_len) + Backspace + SetBlockType(block_type, props).
SpecialCharMatch
Matched trigger and its replacement, ready for the React side to dispatch setSelection(start..start+trigger_len) + Backspace + InsertText(replacement).

Enums§

MarkKind
The eight kinds of inline-mark matchers exposed to callers. Using an enum (rather than eight separate free functions) keeps the WASM boundary narrow — JS passes a tag string, Rust dispatches.

Functions§

match_inline_mark
Run the matcher associated with kind against block_text up to cursor_offset (UTF-16 units). Returns None when no match.
match_markdown_shortcut
Match a markdown shortcut against block_text up to cursor_offset (UTF-16 code-unit offset, same unit the engine uses for selections).
match_special_char
Scan block_text[..cursor_offset] for a trailing trigger and return the replacement info, or None when nothing matched.