File tree Expand file tree Collapse file tree 13 files changed +33
-55
lines changed
nextjs-todolist/components Expand file tree Collapse file tree 13 files changed +33
-55
lines changed Original file line number Diff line number Diff line change @@ -55,16 +55,9 @@ export default function Editor() {
5555 // delete selected content at Yorkie's database
5656 deleteContent ( date : string ) {
5757 doc . update ( ( root ) => {
58- let target ;
59- for ( const item of root . content ) {
60- if ( item . date === date ) {
61- target = item ;
62- break ;
63- }
64- }
65-
66- if ( target ) {
67- root . content . deleteByID ! ( target . getID ( ) ) ;
58+ const idx = root . content . findIndex ( ( item ) => item . date === date ) ;
59+ if ( idx !== - 1 ) {
60+ root . content . delete ?.( idx ) ;
6861 }
6962 } ) ;
7063 } ,
Original file line number Diff line number Diff line change @@ -48,11 +48,9 @@ const TodoList = () => {
4848
4949 const deleteTodo = ( id : string ) => {
5050 update ( ( root ) => {
51- for ( const todo of root . todos ) {
52- if ( todo . id === id ) {
53- root . todos . deleteByID ! ( todo . getID ! ( ) ) ;
54- break ;
55- }
51+ const idx = root . todos . findIndex ( ( todo ) => todo . id === id ) ;
52+ if ( idx !== - 1 ) {
53+ root . todos . delete ?.( idx ) ;
5654 }
5755 } ) ;
5856 } ;
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ import '@xyflow/react/dist/style.css';
1414import './App.css' ;
1515
1616type Graph = {
17- nodes : JSONArray < JSONObject < Node > > ;
18- edges : JSONArray < JSONObject < Edge > > ;
17+ nodes : JSONArray < Node > ;
18+ edges : JSONArray < Edge > ;
1919} ;
2020
2121function App ( ) {
@@ -38,7 +38,7 @@ function App() {
3838 case 'remove' :
3939 {
4040 const idx = r . nodes . findIndex ( ( n ) => n . id === c . id ) ;
41- r . nodes . deleteByID ! ( r . nodes [ idx ] . getID ! ( ) ) ;
41+ r . nodes . delete ?. ( idx ) ;
4242 }
4343 break ;
4444 case 'position' :
@@ -79,7 +79,7 @@ function App() {
7979 case 'remove' :
8080 {
8181 const idx = r . edges . findIndex ( ( e ) => e . id === c . id ) ;
82- r . edges . deleteByID ! ( r . edges [ idx ] . getID ! ( ) ) ;
82+ r . edges . delete ?. ( idx ) ;
8383 }
8484 break ;
8585 case 'select' :
Original file line number Diff line number Diff line change @@ -4,33 +4,15 @@ import yorkie from '@yorkie-js/sdk';
44const defaultLists = [
55 {
66 title: ' Todo' ,
7- cards: [
8- {
9- title: ' Pruning document' ,
10- },
11- {
12- title: ' Clean up codes' ,
13- },
14- ],
7+ cards: [{ title: ' Pruning document' }, { title: ' Clean up codes' }],
158 },
169 {
1710 title: ' Doing' ,
18- cards: [
19- {
20- title: ' Array operations' ,
21- },
22- ],
11+ cards: [{ title: ' Array operations' }],
2312 },
2413 {
2514 title: ' Done' ,
26- cards: [
27- {
28- title: ' Create a sample page' ,
29- },
30- {
31- title: ' Launch demo site' ,
32- },
33- ],
15+ cards: [{ title: ' Create a sample page' }, { title: ' Launch demo site' }],
3416 },
3517];
3618
Original file line number Diff line number Diff line change @@ -184,10 +184,10 @@ <h4 class="title">
184184 </ div >
185185 </ div >
186186 </ div >
187- < script src ="./util.js "> </ script >
188187 < script src ="./devtool/text.js "> </ script >
189188 < script type ="module ">
190189 import './src/yorkie.ts' ;
190+ import Network from './public/devtool/network.js' ;
191191
192192 const textarea = document . getElementById ( 'textarea' ) ;
193193 const statusHolder = document . getElementById ( 'network-status' ) ;
Original file line number Diff line number Diff line change 1515 < button id ="decreaseButton "> -</ button >
1616 </ div >
1717 </ div >
18- < script src ="./util.js "> </ script >
1918 < script type ="module ">
2019 import './src/yorkie.ts' ;
20+ import Network from './devtool/network.js' ;
21+
2122 const statusHolder = document . getElementById ( 'network-status' ) ;
2223 const onlineClientsHolder = document . getElementById ( 'online-clients' ) ;
2324 const counter = document . getElementById ( 'counter' ) ;
Original file line number Diff line number Diff line change 11/**
22 * `Network` is a class that manages the network status.
33 */
4- export class Network {
4+ export default class Network {
55 constructor ( elem ) {
66 this . isOnline = false ;
77 this . elem = elem ;
Original file line number Diff line number Diff line change @@ -36,9 +36,10 @@ <h2>Quill Editor</h2>
3636 < h2 > yorkie document</ h2 >
3737 < pre style ="white-space: pre-wrap " id ="log-holder "> </ pre >
3838 </ div >
39- < script src ="./util.js "> </ script >
4039 < script type ="module ">
4140 import './src/yorkie.ts' ;
41+ import Network from './devtool/network.js' ;
42+
4243 const statusHolder = document . getElementById ( 'network-status' ) ;
4344 const placeholder = document . getElementById ( 'placeholder' ) ;
4445 const onlineClientsHolder = document . getElementById ( 'online-clients' ) ;
Original file line number Diff line number Diff line change 117117 < div class ="online-clients "> </ div >
118118 </ div >
119119 </ div >
120- < script src ="./util.js "> </ script >
121120 < script type ="module ">
122121 import './src/yorkie.ts' ;
122+ import Network from './devtool/network.js' ;
123+
123124 const colorHash = new ColorHash ( ) ;
124125 const clientAElem = document . getElementById ( 'client-a' ) ;
125126 const clientBElem = document . getElementById ( 'client-b' ) ;
Original file line number Diff line number Diff line change 1919 < div id ="editor "> </ div >
2020 < div id ="document "> </ div >
2121 < div id ="document-text "> </ div >
22- < script src ="./util.js "> </ script >
2322 < script type ="module ">
2423 import './src/yorkie.ts' ;
24+ import Network from './devtool/network.js' ;
25+
2526 const onlineClientsElem = document . getElementById ( 'online-clients' ) ;
2627 const documentElem = document . getElementById ( 'document' ) ;
2728 const documentTextElem = document . getElementById ( 'document-text' ) ;
You can’t perform that action at this time.
0 commit comments