1pub mod conflict;
2pub mod document;
3pub mod editor;
4pub mod language;
5pub mod layout;
6pub mod math;
7pub mod outline;
8pub mod reading;
9pub mod search;
10pub mod spelling;
11pub mod template;
12
13pub mod date;
14#[cfg(feature = "gpu")]
15pub mod gpu;
16#[cfg(feature = "interaction")]
17pub mod interaction;
18#[cfg(feature = "pdf")]
19pub mod print;
20#[cfg(feature = "gpu")]
21pub mod recording;
22
23/// Where an object stored with `layout` lies; an unset coordinate is zero.
24pub(crate) fn origin(layout: &onestore::document::Layout) -> [f32; 2] {
25 [layout.x.unwrap_or(0.0), layout.y.unwrap_or(0.0)]
26}
27
28/// `[x0, y0, x1, y1]` moved by `[x, y]`.
29pub(crate) fn translated([x0, y0, x1, y1]: [f32; 4], [x, y]: [f32; 2]) -> [f32; 4] {
30 [x0 + x, y0 + y, x1 + x, y1 + y]
31}
32
33/// Parley's caret affinity mapped onto the page model's hidden-field affinity.
34pub fn affinity(affinity: parley::Affinity) -> onestore::page::text::Affinity {
35 match affinity {
36 parley::Affinity::Upstream => onestore::page::text::Affinity::Upstream,
37 parley::Affinity::Downstream => onestore::page::text::Affinity::Downstream,
38 }
39}