Skip to content

Commit 6d461c5

Browse files
committed
Further modifications
1 parent 4d51adf commit 6d461c5

File tree

12 files changed

+49
-26
lines changed

12 files changed

+49
-26
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build-tools/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ fn run() -> Result<(), Error> {
455455
}
456456

457457
Cli::WasmBuild { no_vendor } => {
458-
let release_flag = Some("--release");
458+
// let release_flag = None; //Some("--release");
459459

460460
// Install wasm target
461461
execute!(
@@ -469,9 +469,9 @@ fn run() -> Result<(), Error> {
469469
execute!(
470470
r"
471471
cd edit-client
472-
cargo build {release_flag} --lib --target wasm32-unknown-unknown {cargo_args}
472+
cargo build --lib --target wasm32-unknown-unknown {cargo_args}
473473
",
474-
release_flag = release_flag,
474+
// release_flag = ,
475475
cargo_args = CARGO_ARGS_EDIT_CLIENT,
476476
)?;
477477

edit-client/src/client.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -328,17 +328,18 @@ fn controller_command<C: ClientController>(
328328
match (focus, anchor) {
329329
(Some(focus), Some(anchor)) => {
330330
client.client_op(|mut ctx| {
331-
let op = cur_to_caret(ctx.clone(), &focus, Pos::Focus)?;
332-
ctx.doc = Op::apply(&ctx.doc, &op);
333-
let op2 = cur_to_caret(ctx, &anchor, Pos::Anchor)?;
334-
Ok(Op::compose(&op, &op2))
331+
let op = cur_to_caret(&ctx, &focus, Pos::Focus)?;
332+
ctx = ctx.apply(&op)?;
333+
let op2 = cur_to_caret(&ctx, &anchor, Pos::Anchor)?;
334+
ctx = ctx.apply(&op2)?;
335+
Ok(ctx.result())
335336
})?;
336337
}
337338
(Some(focus), None) => {
338-
client.client_op(|doc| cur_to_caret(doc, &focus, Pos::Focus))?;
339+
client.client_op(|ctx| cur_to_caret(&ctx, &focus, Pos::Focus))?;
339340
}
340341
(None, Some(anchor)) => {
341-
client.client_op(|doc| cur_to_caret(doc, &anchor, Pos::Anchor))?;
342+
client.client_op(|ctx| cur_to_caret(&ctx, &anchor, Pos::Anchor))?;
342343
}
343344
(None, None) => {} // ???
344345
}
@@ -428,7 +429,7 @@ pub trait ClientController {
428429

429430
value = Task::ControllerCommand(ControllerCommand::Cursor {
430431
focus: Some(cursors[idx].clone()),
431-
anchor: None,
432+
anchor: Some(cursors[idx].clone()),
432433
});
433434
}
434435

edit-client/src/client/actions/caret.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ pub fn caret_clear(ctx: &ActionContext, position: Pos) -> Result<Op, Error> {
238238
caret_clear_inner(ctx.get_walker(position)?)
239239
}
240240

241-
pub fn cur_to_caret(ctx: ActionContext, cur: &CurSpan, pos: Pos) -> Result<Op, Error> {
241+
pub fn cur_to_caret(ctx: &ActionContext, cur: &CurSpan, pos: Pos) -> Result<Op, Error> {
242242
Ok(Op::transform_advance::<RtfSchema>(&{
243243
// First operation removes the caret.
244-
caret_clear(&ctx, pos).unwrap_or_else(|_| Op::empty())
244+
caret_clear(ctx, pos).unwrap_or_else(|_| Op::empty())
245245
}, &{
246246
// Second operation inserts a new caret.
247247
let walker = Walker::to_cursor(&ctx.doc, cur);

edit-client/src/client/actions/modify.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Actions that edit the document structure. Modify blocks or characters.
2+
13
use super::*;
24
use crate::walkers::*;
35
use failure::Error;

edit-frontend/src/debug.ts

+9
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ const DEBUG = {
185185
return div;
186186
},
187187

188+
randomCaretPosition: () => {
189+
globalClientBindings!.command(JSON.stringify({
190+
ControllerCommand: {
191+
"tag" : "RandomTarget" ,
192+
"fields" : { "position" : Math.random() , } ,
193+
},
194+
}));
195+
},
196+
188197
// Bindings to global ref for client module
189198
// NOTE: only for debugging! bindings should not be referenced globally.
190199

edit-frontend/src/ui/app.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -747,16 +747,16 @@ export function start() {
747747
/>,
748748
document.querySelector('#content')!,
749749
() => {
750-
// Default notification
751-
if (!sessionStorage.getItem("its-only-funny-once")) {
752-
editorFrame!.showNotification({
753-
element: (<div>
754-
Check out <a href="http://github.com/tcr/edit-text">edit-text</a> on Github for more information.
755-
</div>),
756-
level: 'notice',
757-
});
758-
sessionStorage.setItem("its-only-funny-once", 'true');
759-
}
750+
// NUX notification.
751+
// if (!sessionStorage.getItem("its-only-funny-once")) {
752+
// editorFrame!.showNotification({
753+
// element: (<div>
754+
// Check out <a href="http://github.com/tcr/edit-text">edit-text</a> on Github for more information.
755+
// </div>),
756+
// level: 'notice',
757+
// });
758+
// sessionStorage.setItem("its-only-funny-once", 'true');
759+
// }
760760

761761
// Connect client.
762762
DEBUG.measureTime('connect-client');

edit-server/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ r2d2 = "0.8.2"
2424
r2d2-diesel = "1.0.0"
2525
open = "1.2.2"
2626
rand = "0.4"
27+
regex = "1"
2728
reqwest = "0.8.5"
2829
ron = "0.4"
2930
libsqlite3-sys = { version = "*", features = ["bundled"] }

edit-server/src/bin/edit-server.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ extern crate failure;
1414

1515
use md5;
1616
use reqwest;
17+
use regex::Regex;
1718
use crypto::md5::Md5;
1819
use crypto::digest::Digest;
1920
use yansi::Paint;

oatie/src/core/apply.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ pub fn apply_del_bc(spanvec: &DocSpan, del: &DelSpan) -> (DocSpan, Program) {
405405
let actual = output_doc.clone();
406406
if actual != compare {
407407
console_log!("\n\n\n🚫🚫🚫 DELETION: {:?}", del);
408-
for item in &bc.0 {
409-
console_log!(" -> {:?}", item);
408+
for _item in &bc.0 {
409+
console_log!(" -> {:?}", _item);
410410
}
411411
console_log!(
412412
"\ntest =====> [ {} ]\n\nactual:\n {:?}\n\ncompare:\n {:?}\n\n",

oatie/src/core/schema.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
//! Performs operational transform.
1+
//! Contains types that define the different groups and styles the document
2+
//! tree can contain. This code should live outside of `oatie`, once all of
3+
//! DocSpan and Op are made generic over a <S: Schema> trait. Until then,
4+
//! oatie is hard-coded to this Markdown-like schema.
25
36
use super::transform::{
47
Schema,

oatie/src/stepper/docmutator.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -233,11 +233,16 @@ impl<'a> DocMutator for RecordingDocMutator<'a> {
233233
if self.flush_chars() {
234234
count -= 1;
235235
}
236+
237+
console_log!("advance elements: {:?}", count);
236238

237239
for _ in 0..count {
238240
self.bc.place(Bytecode::AdvanceElements(1));
239241

240-
self.writer.place(&self.stepper.head_raw().expect("oh god"));
242+
self.writer.place(match self.stepper.head_raw() {
243+
Some(head) => head,
244+
_ => panic!("no head element"),
245+
});
241246

242247
self.stepper.next();
243248
}

0 commit comments

Comments
 (0)