forge
Explore
Log in

Don't you dare go Hollow

project_note

Clone
★ 0

0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits

schema.rs43 lines, 1.6 KiBHistoryRawDownload
1//! Node and mark names of the note layout, and the text style expand rules.
2
3use loro::{ExpandType, StyleConfig, StyleConfigMap};
4
5pub const NODE_DOC: &str = "doc";
6pub const NODE_PARAGRAPH: &str = "paragraph";
7pub const NODE_HEADING: &str = "heading";
8pub const NODE_CODE_BLOCK: &str = "code_block";
9pub const NODE_BLOCKQUOTE: &str = "blockquote";
10pub const NODE_HORIZONTAL_RULE: &str = "horizontal_rule";
11pub const NODE_BULLET_LIST: &str = "bullet_list";
12pub const NODE_ORDERED_LIST: &str = "ordered_list";
13pub const NODE_LIST_ITEM: &str = "list_item";
14pub const NODE_HARD_BREAK: &str = "hard_break";
15pub const NODE_IMAGE: &str = "image";
16
17pub const MARK_STRONG: &str = "strong";
18pub const MARK_EM: &str = "em";
19pub const MARK_CODE: &str = "code";
20pub const MARK_LINK: &str = "link";
21
22/// Expand rules of every mark key: inline marks grow at their end like ProseMirror's.
23pub fn text_style_config() -> StyleConfigMap {
24 let mut styles = StyleConfigMap::new();
25 styles.insert(
26 MARK_STRONG.into(),
27 StyleConfig::new().expand(ExpandType::After),
28 );
29 styles.insert(MARK_EM.into(), StyleConfig::new().expand(ExpandType::After));
30 styles.insert(
31 MARK_CODE.into(),
32 StyleConfig::new().expand(ExpandType::After),
33 );
34 styles.insert(
35 MARK_LINK.into(),
36 StyleConfig::new().expand(ExpandType::None),
37 );
38 // Block attributes on separators, and images: never lent to inserted text.
39 for key in crate::flat::BLOCK_KEYS.iter().chain(&[crate::flat::KEY_IMAGE]) {
40 styles.insert((*key).into(), StyleConfig::new().expand(ExpandType::None));
41 }
42 styles
43}