Fix names
This commit is contained in:
parent
98dc11896e
commit
6b6b16af3c
5 changed files with 13 additions and 21 deletions
|
|
@ -174,7 +174,7 @@ function toTextWithCursors(
|
|||
function toCursorPosition(cursor: wasmCursorPosition): CursorPosition {
|
||||
return {
|
||||
id: cursor.id(),
|
||||
position: cursor.characterPosition(),
|
||||
position: cursor.characterIndex(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -257,15 +257,15 @@ where
|
|||
|
||||
match operation {
|
||||
Operation::Equal { .. } => {
|
||||
history.push(SpanWithHistory::new(History::Unchanged, builder.take()));
|
||||
history.push(SpanWithHistory::new(builder.take(), History::Unchanged));
|
||||
}
|
||||
Operation::Insert { side, .. } => match side {
|
||||
Side::Left => {
|
||||
history.push(SpanWithHistory::new(History::AddedFromLeft, builder.take()));
|
||||
history.push(SpanWithHistory::new(builder.take(), History::AddedFromLeft));
|
||||
}
|
||||
Side::Right => history.push(SpanWithHistory::new(
|
||||
History::AddedFromRight,
|
||||
builder.take(),
|
||||
History::AddedFromRight,
|
||||
)),
|
||||
},
|
||||
Operation::Delete {
|
||||
|
|
@ -277,10 +277,10 @@ where
|
|||
let deleted = self.text[*order..*order + *deleted_character_count].to_string();
|
||||
match side {
|
||||
Side::Left => {
|
||||
history.push(SpanWithHistory::new(History::RemovedFromLeft, deleted));
|
||||
history.push(SpanWithHistory::new(deleted, History::RemovedFromLeft));
|
||||
}
|
||||
Side::Right => {
|
||||
history.push(SpanWithHistory::new(History::RemovedFromRight, deleted));
|
||||
history.push(SpanWithHistory::new(deleted, History::RemovedFromRight));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ impl CursorPosition {
|
|||
#[must_use]
|
||||
pub fn id(&self) -> usize { self.id }
|
||||
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen(js_name = characterPosition))]
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen(js_name = characterIndex))]
|
||||
#[must_use]
|
||||
pub fn char_index(&self) -> usize { self.char_index }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,19 +5,20 @@ use wasm_bindgen::prelude::*;
|
|||
|
||||
use crate::types::history::History;
|
||||
|
||||
/// Wrapper type for `(History, String)`
|
||||
/// Wrapper type for `(String, History)` where History describes the origin of
|
||||
/// `text`.
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct SpanWithHistory {
|
||||
history: History,
|
||||
text: String,
|
||||
history: History,
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "wasm", wasm_bindgen)]
|
||||
impl SpanWithHistory {
|
||||
#[must_use]
|
||||
pub fn new(history: History, text: String) -> Self { SpanWithHistory { history, text } }
|
||||
pub fn new(text: String, history: History) -> Self { SpanWithHistory { text, history } }
|
||||
|
||||
#[must_use]
|
||||
pub fn history(&self) -> History { self.history }
|
||||
|
|
|
|||
13
src/wasm.rs
13
src/wasm.rs
|
|
@ -1,14 +1,4 @@
|
|||
//! This crate provides utilities for easily communicating between backend &
|
||||
//! frontend and ensuring the same logic for encoding and decoding binary data,
|
||||
//! and 3-way-merging documents in Rust and JavaScript.
|
||||
//!
|
||||
//! The crate is designed to be used as a Rust library and as a
|
||||
//! TypeScript/JavaScript package through WebAssembly (WASM).
|
||||
//!
|
||||
//! # Modules
|
||||
//!
|
||||
//! - `errors`: Contains error types used in this crate.
|
||||
|
||||
//! Expose the `reconcile` crate's functionality to WebAssembly.
|
||||
use core::str;
|
||||
|
||||
use cfg_if::cfg_if;
|
||||
|
|
@ -116,6 +106,7 @@ fn set_panic_hook() {
|
|||
console_error_panic_hook::set_once();
|
||||
}
|
||||
|
||||
/// WASM wrapper type for the return value of `reconcile_with_history`
|
||||
#[wasm_bindgen]
|
||||
#[derive(Debug, Clone, PartialEq, Default)]
|
||||
pub struct TextWithCursorsAndHistory {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue