@@ -117,7 +117,8 @@ impl DocumentTransaction {
117117
118118impl std:: convert:: From < Transaction > for DocumentTransaction {
119119 fn from ( transaction : Transaction ) -> Self {
120- let ( before_selection, after_selection) = match transaction. extension {
120+ let ( operations, extension) = transaction. split ( ) ;
121+ let ( before_selection, after_selection) = match extension {
121122 Extension :: Empty => ( Selection :: default ( ) , Selection :: default ( ) ) ,
122123 Extension :: TextSelection {
123124 before_selection,
@@ -126,9 +127,7 @@ impl std::convert::From<Transaction> for DocumentTransaction {
126127 } ;
127128
128129 DocumentTransaction {
129- operations : transaction
130- . operations
131- . into_inner ( )
130+ operations : operations
132131 . into_iter ( )
133132 . map ( |operation| operation. as_ref ( ) . into ( ) )
134133 . collect ( ) ,
@@ -139,19 +138,16 @@ impl std::convert::From<Transaction> for DocumentTransaction {
139138}
140139
141140impl std:: convert:: From < DocumentTransaction > for Transaction {
142- fn from ( transaction : DocumentTransaction ) -> Self {
143- Transaction {
144- operations : transaction
145- . operations
146- . into_iter ( )
147- . map ( |operation| operation. into ( ) )
148- . collect :: < Vec < NodeOperation > > ( )
149- . into ( ) ,
150- extension : Extension :: TextSelection {
151- before_selection : transaction. before_selection ,
152- after_selection : transaction. after_selection ,
153- } ,
141+ fn from ( document_transaction : DocumentTransaction ) -> Self {
142+ let mut transaction = Transaction :: new ( ) ;
143+ for document_operation in document_transaction. operations {
144+ transaction. push_operation ( document_operation) ;
154145 }
146+ transaction. extension = Extension :: TextSelection {
147+ before_selection : document_transaction. before_selection ,
148+ after_selection : document_transaction. after_selection ,
149+ } ;
150+ transaction
155151 }
156152}
157153
@@ -374,6 +370,17 @@ mod tests {
374370 let _ = serde_json:: to_string_pretty ( & document) . unwrap ( ) ;
375371 }
376372
373+ // #[test]
374+ // fn document_operation_compose_test() {
375+ // let json = include_str!("./test.json");
376+ // let transaction: Transaction = Transaction::from_json(json).unwrap();
377+ // let json = transaction.to_json().unwrap();
378+ // // let transaction: Transaction = Transaction::from_json(&json).unwrap();
379+ // let document = Document::from_transaction(transaction).unwrap();
380+ // let content = document.get_content(false).unwrap();
381+ // println!("{}", json);
382+ // }
383+
377384 const EXAMPLE_DOCUMENT : & str = r#"{
378385 "document": {
379386 "type": "editor",
0 commit comments