-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
1175 lines (1012 loc) · 75.4 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Main</title>
<link rel="manifest" href="manifest.json">
<script>
const renderedClass = "rendered-callback";
const renderedEvent = "rendered";
</script>
<script src="js/elm.js"></script>
<script src="js/bundle.js"></script>
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<!-- <script src="js/katex.min.css.js"></script> -->
<script src="js/katex-custom-element.js"></script>
<script onLoad="initKatex()"
defer src="katex/katex.min.js"></script>
<script src="katex/katex.min.css.js"></script>
<style>
/* override vscode theme color */
body {
background-color: white;
color: black;
}
/* Make foreignobject in svg visible */
foreignObject { overflow:visible;
/* to allow clicking through the overflow */
pointer-events: none
}
foreignObject * {
pointer-events: all;
}
#canvas {
width: 4000px;
height: 4000px;
}
.active-edge {
stroke-width: 4px;
}
.weak-active-edge {
filter: drop-shadow(3px 5px 2px rgb(0 0 0 / 0.4));
}
.tabs .tab-button {
position: relative;
padding: 0.5em 1em;
border: 0;
border-radius: 0.5em;
background-color: pink;
box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.5);
cursor: pointer;
/* width: 100%;
max-width: 100%;
box-sizing: border-box;
display: block; */
}
.tabs .tab-button.active-tab, .tabs .tab-button:active {
top: 2px;
left: 1px;
box-shadow: none;
}
.active-label {
border-color: black;
border-style: solid;
border-width: 2px;
}
.weak-active-label {
border-color: black;
border-style: dashed;
border-width: 2px;
}
/* selection rectangle */
.rect-select {
stroke: black;
stroke-width: 1px;
stroke-dasharray: 2;
fill:transparent;
}
.help-div {
height: 10em;
overflow: scroll;
}
.overlay .help-div {
position:fixed;
top:0;
bottom:0;
height:auto;
right:2px;
width:50%;
}
.overlay .help-div div {
background-color: lightgrey;
}
path:hover {
stroke-width : 4;
}
</style>
<script>
// This is for caching the files for offline use in the PWA version
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./service-worker.js')
.then(registration => {
console.log('ServiceWorker registration successful with scope: ', registration.scope);
}, err => {
console.log('ServiceWorker registration failed: ', err);
});
});
}
const defaultServer = "ws://localhost:8080";
// LocalStorage key used for quicksave
const storageKey = "yadegraph";
const gridStorageKey = "yadegridsize"
const rulerMarginKey = "yaderulermargin"
const supportStorage = typeof(Storage) !== "undefined";
var fulltutorial = {"graph":{"activeTabId":0,"latexPreamble":"\\newcommand{\\coqproof}[1]{\\checkmark{}}","nextTabId":1,"tabs":[{"edges":[{"from":9,"id":144,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":10},{"from":10,"id":145,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":11},{"from":15,"id":146,"label":{"kind":"normal","label":"\\text{rename me}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":18},{"from":19,"id":147,"label":{"kind":"normal","label":"\\text{select me}","style":{"alignment":"right","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":22},{"from":19,"id":148,"label":{"kind":"normal","label":"\\text{target me}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":23},{"from":22,"id":149,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":23},{"from":25,"id":150,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":7},{"from":25,"id":151,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":8},{"from":31,"id":152,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":32},{"from":31,"id":153,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":33},{"from":33,"id":154,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":34},{"from":32,"id":155,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":34},{"from":36,"id":156,"label":{"kind":"normal","label":"f","style":{"alignment":"left","bend":-0.2,"color":"blue","dashed":true,"head":"twoheads","headColor":"red","kind":"double","marker":"","position":0.7,"tail":"hook","tailColor":"blue","wavy":false},"zindex":1},"to":37},{"from":39,"id":157,"label":{"kind":"normal","label":"f","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":40},{"from":43,"id":158,"label":{"kind":"normal","label":"\\text{\\normalsize select me}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":44},{"from":43,"id":159,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":45},{"from":43,"id":160,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":46},{"from":47,"id":161,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":44},{"from":49,"id":162,"label":{"kind":"normal","label":"F f","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":50},{"from":50,"id":163,"label":{"kind":"normal","label":"F g","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":51},{"from":51,"id":164,"label":{"kind":"normal","label":"n_{c}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":52},{"from":50,"id":165,"label":{"kind":"normal","label":"n_{b}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":53},{"from":53,"id":166,"label":{"kind":"normal","label":"G g","style":{"alignment":"right","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":52},{"from":49,"id":167,"label":{"kind":"normal","label":"n_{a}","style":{"alignment":"right","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":54},{"from":54,"id":168,"label":{"kind":"normal","label":"G f","style":{"alignment":"right","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":53},{"from":75,"id":169,"label":{"kind":"normal","label":"F g","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":76},{"from":76,"id":170,"label":{"kind":"normal","label":"n_{c}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":77},{"from":99,"id":171,"label":{"kind":"normal","label":"f","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":100},{"from":103,"id":172,"label":{"kind":"normal","label":"F f","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":104},{"from":104,"id":173,"label":{"kind":"normal","label":"F g","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":105},{"from":105,"id":174,"label":{"kind":"normal","label":"n_{c}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":106},{"from":104,"id":175,"label":{"kind":"normal","label":"n_{b}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":107},{"from":107,"id":176,"label":{"kind":"normal","label":"G g","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":106},{"from":103,"id":177,"label":{"kind":"normal","label":"n_{a}","style":{"alignment":"right","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":108},{"from":108,"id":178,"label":{"kind":"normal","label":"G f","style":{"alignment":"right","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":107},{"from":111,"id":179,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":112},{"from":120,"id":180,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"none","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":121},{"from":123,"id":181,"label":{"kind":"normal","label":"F g","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":124},{"from":124,"id":182,"label":{"kind":"normal","label":"n_{c}","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":125},{"from":123,"id":183,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":125},{"from":128,"id":184,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"none","headColor":"black","kind":"normal","marker":"","position":0.5,"tail":"none","tailColor":"black","wavy":false},"zindex":0},"to":129},{"from":129,"id":185,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":0,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"|","position":0.5,"tail":"hook","tailColor":"red","wavy":false},"zindex":0},"to":140},{"from":128,"id":186,"label":{"kind":"normal","label":"","style":{"alignment":"left","bend":-0.4,"color":"black","dashed":false,"head":"default","headColor":"black","kind":"normal","marker":"|","position":0.5,"tail":"none","tailColor":"black","wavy":true},"zindex":0},"to":37}],"id":0,"nextGraphId":187,"nodes":[{"id":0,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[362,1870.1333312988281],"zindex":2}},{"id":1,"label":{"isCoqValidated":false,"isMath":true,"label":"\\textbf{Tutorial}","pos":[86,24.133331298828125],"zindex":2}},{"id":2,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Select the point below, and press 'a' . Use the mouse or 'hjkl' (keyboard) to move the target point.}","pos":[579.75,1733.6333312988281],"zindex":2}},{"id":3,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Arrow creation}}","pos":[76.75,1733.6333312988281],"zindex":2}},{"id":4,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Commutative square}}","pos":[95.5,2511.9666748046875],"zindex":2}},{"id":5,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Select the top right node in the diagram above, then press 's'.}","pos":[443,2510.7166748046875],"zindex":2}},{"id":6,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Move \\& Merge}}","pos":[83,2858.133331298828],"zindex":2}},{"id":7,"label":{"isCoqValidated":false,"isMath":true,"label":"a","pos":[203,2952.820831298828],"zindex":2}},{"id":8,"label":{"isCoqValidated":false,"isMath":true,"label":"c","pos":[200,3078.820831298828],"zindex":2}},{"id":9,"label":{"isCoqValidated":false,"isMath":true,"label":"a'","pos":[490,2952.820831298828],"zindex":2}},{"id":10,"label":{"isCoqValidated":false,"isMath":true,"label":"b'","pos":[432,3011.820831298828],"zindex":2}},{"id":11,"label":{"isCoqValidated":false,"isMath":true,"label":"c'","pos":[487,3078.820831298828],"zindex":2}},{"id":12,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Select the node $\\mathbf{b}$ below, press 'g' , use the mouse or 'hjkl' to move.}","pos":[485,2863.13330078125],"zindex":2}},{"id":13,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{When moving $\\mathbf{b}$, press 'ctrl' to merge.}","pos":[382,2925.800048828125],"zindex":2}},{"id":14,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Use \\textbf{escape} any time to cancel any pending action (such as label editing).}","pos":[527,26.133331298828125],"zindex":2}},{"id":15,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[225,2175.7166900634766],"zindex":2}},{"id":16,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Select the arrow below, press 'r' to edit the label (or double click on it), Tab to confirm.}","pos":[451,2105.7166595458984],"zindex":2}},{"id":17,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Rename}}","pos":[44,2106.7166900634766],"zindex":2}},{"id":18,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[425,2175.7166900634766],"zindex":2}},{"id":19,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[176.5,2058.3416748046875],"zindex":2}},{"id":20,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Select the arrow below, press 'a', move around, then press '='. }","pos":[400,1903.796875],"zindex":2}},{"id":21,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Higher cells}}","pos":[60,1903.7166748046875],"zindex":2}},{"id":22,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[370.5,2058.3416748046875],"zindex":2}},{"id":23,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[270.5,1963.0916748046875],"zindex":2}},{"id":24,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Point creation}}","pos":[75.5,411.8833312988281],"zindex":2}},{"id":25,"label":{"isCoqValidated":false,"isMath":true,"label":"\\mathbf{b}","pos":[307,3009.133331298828],"zindex":2}},{"id":26,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{All the commands presented above are listed above the canvas}","pos":[258,88.7166748046875],"zindex":2}},{"id":27,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Enter to validate the guessed labels (otherwise, use tab).}","pos":[422,2543.7166748046875],"zindex":2}},{"id":28,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Add xy space}}","pos":[84.5,3251.5332946777344],"zindex":2}},{"id":29,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Move the cursor inside the square below}","pos":[355.5,3260.5333557128906],"zindex":2}},{"id":30,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Presse 'e', and draw a rectangle}","pos":[319.5,3293.5333557128906],"zindex":2}},{"id":31,"label":{"isCoqValidated":false,"isMath":true,"label":"a","pos":[585.5,3230.216552734375],"zindex":2}},{"id":32,"label":{"isCoqValidated":false,"isMath":true,"label":"b","pos":[674.5,3230.216552734375],"zindex":2}},{"id":33,"label":{"isCoqValidated":false,"isMath":true,"label":"c","pos":[585.5,3313.216552734375],"zindex":2}},{"id":34,"label":{"isCoqValidated":false,"isMath":true,"label":"d","pos":[674.5,3313.216552734375],"zindex":2}},{"id":35,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Arrow style}}","pos":[69.5,1391.7666473388672],"zindex":2}},{"id":36,"label":{"isCoqValidated":false,"isMath":true,"label":"a","pos":[220,1644.7166595458984],"zindex":2}},{"id":37,"label":{"isCoqValidated":false,"isMath":true,"label":"b","pos":[436,1644.7166595458984],"zindex":2}},{"id":38,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{\\underline{Detach arrow head/tail}}","pos":[132.5,3363.2915649414062],"zindex":2}},{"id":39,"label":{"isCoqValidated":false,"isMath":true,"label":"a","pos":[197,3460.1415405273438],"zindex":2}},{"id":40,"label":{"isCoqValidated":false,"isMath":true,"label":"b","pos":[394,3460.1415405273438],"zindex":2}},{"id":41,"label":{"isCoqValidated":false,"isMath":true,"label":"\\text{Select the arrow and press C. Then, press c to alternate between the head and the tail.}","pos":[625,3367.13330078125],"zindex":2}},{"id":42,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Pullbacks/Pushouts}","pos":[51,3715.183349609375],"zindex":2}},{"id":43,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[249.75,3840.1749267578125],"zindex":2}},{"id":44,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[249.25,3949.1580810546875],"zindex":2}},{"id":45,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[343.75,3840.1749267578125],"zindex":2}},{"id":46,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[321.75,3801.1749267578125],"zindex":2}},{"id":47,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[177.25,3952.2581787109375],"zindex":2}},{"id":48,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Coq script generation}","pos":[1224.5,71.21672058105469],"zindex":2}},{"id":49,"label":{"isCoqValidated":false,"isMath":true,"label":"F a","pos":[202,754.7166748046875],"zindex":2}},{"id":50,"label":{"isCoqValidated":false,"isMath":true,"label":"F b","pos":[333,754.7166748046875],"zindex":2}},{"id":51,"label":{"isCoqValidated":false,"isMath":true,"label":"F c","pos":[469,754.7166748046875],"zindex":2}},{"id":52,"label":{"isCoqValidated":false,"isMath":true,"label":"G c","pos":[469,890.7166748046875],"zindex":2}},{"id":53,"label":{"isCoqValidated":false,"isMath":true,"label":"G b","pos":[333,890.7166748046875],"zindex":2}},{"id":54,"label":{"isCoqValidated":false,"isMath":true,"label":"G a","pos":[202,890.7166748046875],"zindex":2}},{"id":55,"label":{"isCoqValidated":false,"isMath":false,"label":"select the diagram below and press 'G'","pos":[1332.5,134.2165985107422],"zindex":2}},{"id":56,"label":{"isCoqValidated":false,"isMath":false,"label":"The following keys change selected arrow style : |>(=~-bBA][ic+<.","pos":[165,1383.7166595458984],"zindex":2}},{"id":57,"label":{"isCoqValidated":false,"isMath":false,"label":"'>' arrow head","pos":[252.375,1423.7166748046875],"zindex":2}},{"id":58,"label":{"isCoqValidated":false,"isMath":false,"label":"'(','|' arrow tail","pos":[253.375,1457.7166748046875],"zindex":2}},{"id":59,"label":{"isCoqValidated":false,"isMath":false,"label":"'-' dashed arrow","pos":[413.875,1425.7166748046875],"zindex":2}},{"id":60,"label":{"isCoqValidated":false,"isMath":false,"label":"'=' double arrow","pos":[408.19999998807907,1451.800048828125],"zindex":2}},{"id":61,"label":{"isCoqValidated":false,"isMath":false,"label":"'][' label position (left/right)","pos":[599.625,1457.7166595458984],"zindex":2}},{"id":62,"label":{"isCoqValidated":false,"isMath":false,"label":"Try them after selecting the arrow below","pos":[167,1552.1666870117188],"zindex":2}},{"id":63,"label":{"isCoqValidated":false,"isMath":false,"label":"'A' label position (above/below)","pos":[599.625,1426.7166595458984],"zindex":2}},{"id":64,"label":{"isCoqValidated":false,"isMath":false,"label":"'b'/'B' : bend arrow","pos":[50.002840995788574,1501.068115234375],"zindex":2}},{"id":65,"label":{"isCoqValidated":false,"isMath":false,"label":"Arrow style can be customised before confirming (by clicking or Tab)","pos":[176,1749.7166748046875],"zindex":2}},{"id":66,"label":{"isCoqValidated":false,"isMath":false,"label":"Edit the point label, then press Tab to edit the arrow label and then confirm it.","pos":[180,1777.7166748046875],"zindex":2}},{"id":67,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Quicksave}","pos":[13.5,179.2166748046875],"zindex":2}},{"id":68,"label":{"isCoqValidated":false,"isMath":false,"label":"Press 'Q' to quicksave.","pos":[114.5,180.2166748046875],"zindex":2}},{"id":69,"label":{"isCoqValidated":false,"isMath":false,"label":"The quickload button above reloads the quicksaved graph (even after closing and reopening the window)","pos":[60.5,225.2166748046875],"zindex":2}},{"id":70,"label":{"isCoqValidated":false,"isMath":false,"label":"The autosave checkbox quicksaves every minute.","pos":[60.5,257.2166748046875],"zindex":2}},{"id":71,"label":{"isCoqValidated":false,"isMath":false,"label":"Quicksaving stores the graph in the browser for the web version of the editor,","pos":[62.5,291.2166748046875],"zindex":2}},{"id":72,"label":{"isCoqValidated":false,"isMath":false,"label":"or in the specified file (Filename input above) for the desktop version","pos":[62.5,334.2166748046875],"zindex":2}},{"id":73,"label":{"isCoqValidated":false,"isMath":false,"label":"Press 't' instead of 'p' to create a text point (no LaTeX, anchored left instead of center)","pos":[172,463.71665954589844],"zindex":2}},{"id":74,"label":{"isCoqValidated":false,"isMath":false,"label":" Or press Enter to skip label editing.","pos":[180,1812.7166748046875],"zindex":2}},{"id":75,"label":{"isCoqValidated":false,"isMath":true,"label":"F b","pos":[301.0499997138977,2301.0584106445312],"zindex":2}},{"id":76,"label":{"isCoqValidated":false,"isMath":true,"label":"F c","pos":[381.34999990463257,2301.0584106445312],"zindex":2}},{"id":77,"label":{"isCoqValidated":false,"isMath":true,"label":"G c","pos":[381.34999990463257,2371.7418823242188],"zindex":2}},{"id":78,"label":{"isCoqValidated":false,"isMath":false,"label":"Alternatively, hold 'g' to move and release to confirm","pos":[133,3132.38330078125],"zindex":2}},{"id":79,"label":{"isCoqValidated":false,"isMath":false,"label":"Press 'd' to duplicate (keeping the original arrow)","pos":[273.5,3400.1415405273438],"zindex":2}},{"id":80,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{LaTeX / SVG export}","pos":[20.5,936.2166748046875],"zindex":2}},{"id":81,"label":{"isCoqValidated":false,"isMath":false,"label":"Select the diagram above and press 'X' or 'V' ","pos":[220.5,938.2166748046875],"zindex":2}},{"id":82,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Deleting}","pos":[21.5,981.2166748046875],"zindex":2}},{"id":83,"label":{"isCoqValidated":false,"isMath":false,"label":"Press 'x' to delete selected object(s)","pos":[148.5,983.2166748046875],"zindex":2}},{"id":84,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Selection}","pos":[19,497.21665954589844],"zindex":2}},{"id":85,"label":{"isCoqValidated":false,"isMath":false,"label":"'w' clears selection. 'u' extends selection to connected components. 'S' Selects surrounding diagram","pos":[113,634.7166748046875],"zindex":2}},{"id":86,"label":{"isCoqValidated":false,"isMath":false,"label":"Hold 'shift' (and click / move mouse) to add stuff to selection.","pos":[112,598.7166595458984],"zindex":2}},{"id":87,"label":{"isCoqValidated":false,"isMath":false,"label":"If something is already selected, shadowed or dotted objects are what would be selected on a click.","pos":[109,559.7166595458984],"zindex":2}},{"id":88,"label":{"isCoqValidated":false,"isMath":false,"label":" Click on an object to select it, or hold the mouse button to draw a selection rectangle","pos":[117,502.71665954589844],"zindex":2}},{"id":89,"label":{"isCoqValidated":false,"isMath":false,"label":"Press 'p' and click somewhere to create and label a point. Enter/Tab to confirm","pos":[172,407.71665954589844],"zindex":2}},{"id":90,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Copy \\& Paste}","pos":[19,1302.7166748046875],"zindex":2}},{"id":91,"label":{"isCoqValidated":false,"isMath":false,"label":"C-c copies selected objects in the clipboard in a json format.","pos":[169,1307.7166748046875],"zindex":2}},{"id":92,"label":{"isCoqValidated":false,"isMath":false,"label":"C-v pastes from json data stored in the clipboard","pos":[169,1340.7166748046875],"zindex":2}},{"id":93,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Undo}","pos":[17,363.7166748046875],"zindex":2}},{"id":94,"label":{"isCoqValidated":false,"isMath":false,"label":"C-z","pos":[86,364.7166748046875],"zindex":2}},{"id":95,"label":{"isCoqValidated":false,"isMath":false,"label":"Example: move your mouse in the right square below. Press 'S', then 'u', then 'w'.","pos":[109,697.7166748046875],"zindex":2}},{"id":96,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Find \\& replace}","pos":[11,2241.7166748046875],"zindex":2}},{"id":97,"label":{"isCoqValidated":false,"isMath":false,"label":"Select the diagram below, press 'q' and enter '/F/H' to replace $F$ by $H$","pos":[170,2242.7166748046875],"zindex":2}},{"id":98,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Split arrow}","pos":[48,3509.716552734375],"zindex":2}},{"id":99,"label":{"isCoqValidated":false,"isMath":true,"label":"a","pos":[165.5,3630.716552734375],"zindex":2}},{"id":100,"label":{"isCoqValidated":false,"isMath":true,"label":"b","pos":[358.5,3630.716552734375],"zindex":2}},{"id":101,"label":{"isCoqValidated":false,"isMath":false,"label":"Select the arrow below and press '/' to split it.","pos":[168,3509.716552734375],"zindex":2}},{"id":102,"label":{"isCoqValidated":false,"isMath":false,"label":"Before confirming (by enter) or editing the label (by Tab), press '/' again to swap the labels","pos":[166,3544.716552734375],"zindex":2}},{"id":103,"label":{"isCoqValidated":false,"isMath":true,"label":"F a","pos":[1342,184.2165985107422],"zindex":2}},{"id":104,"label":{"isCoqValidated":false,"isMath":true,"label":"F b","pos":[1476,184.2165985107422],"zindex":2}},{"id":105,"label":{"isCoqValidated":false,"isMath":true,"label":"F c","pos":[1612,184.2165985107422],"zindex":2}},{"id":106,"label":{"isCoqValidated":false,"isMath":true,"label":"G c","pos":[1612,320.2165985107422],"zindex":2}},{"id":107,"label":{"isCoqValidated":false,"isMath":true,"label":"G b","pos":[1476,320.2165985107422],"zindex":2}},{"id":108,"label":{"isCoqValidated":false,"isMath":true,"label":"G a","pos":[1342,320.2165985107422],"zindex":2}},{"id":109,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Grid}","pos":[32,1053.7166748046875],"zindex":2}},{"id":110,"label":{"isCoqValidated":false,"isMath":false,"label":"Press 'f' to snap the selected nodes to the grid. Try it below.","pos":[114,1057.7166748046875],"zindex":2}},{"id":111,"label":{"isCoqValidated":false,"isMath":true,"label":"a","pos":[179,1129.7166748046875],"zindex":2}},{"id":112,"label":{"isCoqValidated":false,"isMath":true,"label":"b","pos":[330,1165.7166748046875],"zindex":2}},{"id":113,"label":{"isCoqValidated":false,"isMath":false,"label":"'R' enters the resize mode. The grid size can be adjusted either with the keyboard (jk) or with a slider above the canvas","pos":[112,1207.7166748046875],"zindex":2}},{"id":114,"label":{"isCoqValidated":false,"isMath":false,"label":"While in resize mode, press 'g' to resize the grid only (and leave objects unchanged).","pos":[111,1253.7166748046875],"zindex":2}},{"id":115,"label":{"isCoqValidated":false,"isMath":false,"label":"'i' invert arrow","pos":[35.002840995788574,1528.068115234375],"zindex":2}},{"id":116,"label":{"isCoqValidated":false,"isMath":false,"label":"Enter to confirm, ESC to cancel","pos":[112,1230.7166748046875],"zindex":2}},{"id":117,"label":{"isCoqValidated":false,"isMath":false,"label":"This is LaTeX enabled. A preamble can be provided (click on the link Latex preamble above the canvas)","pos":[170,435.71665954589844],"zindex":2}},{"id":118,"label":{"isCoqValidated":false,"isMath":false,"label":"Select the arrow below. Then, press 'a' then 'p' (or 'P') and 'p' (or 'P') again to cycle between possibilities).","pos":[122,3750.716552734375],"zindex":2}},{"id":119,"label":{"isCoqValidated":false,"isMath":false,"label":"Enter to confirm","pos":[453,3831.716552734375],"zindex":2}},{"id":120,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[1151,42.71665954589844],"zindex":2}},{"id":121,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[1150,4197.716552734375],"zindex":2}},{"id":122,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Textual completion}","pos":[23,2604.716552734375],"zindex":2}},{"id":123,"label":{"isCoqValidated":false,"isMath":true,"label":"F b","pos":[322.5,2711.216552734375],"zindex":2}},{"id":124,"label":{"isCoqValidated":false,"isMath":true,"label":"F c","pos":[457.5,2711.216552734375],"zindex":2}},{"id":125,"label":{"isCoqValidated":false,"isMath":true,"label":"G c","pos":[455,2816.216552734375],"zindex":2}},{"id":126,"label":{"isCoqValidated":false,"isMath":false,"label":"Select diagram below, press E and enter","pos":[227,2614.716552734375],"zindex":2}},{"id":127,"label":{"isCoqValidated":false,"isMath":false,"label":"\\verb|_ = F b -- n_{b} -> G b -- G g -> G c|","pos":[221,2644.716552734375],"zindex":2}},{"id":128,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[294,1592.7166748046875],"zindex":2}},{"id":129,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[323,1663.7166748046875],"zindex":2}},{"id":130,"label":{"isCoqValidated":false,"isMath":false,"label":"'+' move forwards (z)","pos":[28,1425.7166748046875],"zindex":2}},{"id":131,"label":{"isCoqValidated":false,"isMath":false,"label":"'<' move backwards (z)","pos":[29,1452.7166748046875],"zindex":2}},{"id":132,"label":{"isCoqValidated":false,"isMath":false,"label":"Press '?' at any time to display the full list of the available commands on the right","pos":[25,129.7166748046875],"zindex":2}},{"id":133,"label":{"isCoqValidated":false,"isMath":false,"label":"'c' change color (then press '?' to see the options)","pos":[603,1506.7166748046875],"zindex":2}},{"id":134,"label":{"isCoqValidated":false,"isMath":true,"label":"\\coqproof{naturality.}","pos":[1395,249.71665954589844],"zindex":2}},{"id":135,"label":{"isCoqValidated":false,"isMath":true,"label":"\\coqproof{naturality.}","pos":[1546,250.7166748046875],"zindex":2}},{"id":136,"label":{"isCoqValidated":false,"isMath":false,"label":"Press 'x' or 'y' to restrict to horizontal/vertical movement (press 'f' to remove the restriction)","pos":[206,2880.13330078125],"zindex":0}},{"id":137,"label":{"isCoqValidated":false,"isMath":false,"label":"\\underline{Cylinder / cone creation}","pos":[20.199999809265137,2416.400146484375],"zindex":2}},{"id":138,"label":{"isCoqValidated":false,"isMath":false,"label":"Select the diagram above, press 'a', then 'C' (to turn the cylinder into a cone)","pos":[241.19999980926514,2414.400146484375],"zindex":0}},{"id":139,"label":{"isCoqValidated":false,"isMath":false,"label":"'d' to turn into an adjunction symbol. Press ctrl or 'a' to confirm","pos":[147,1930.796875],"zindex":0}},{"id":140,"label":{"isCoqValidated":false,"isMath":true,"label":"","pos":[460.0028409957886,1680.068115234375],"zindex":0}},{"id":141,"label":{"isCoqValidated":false,"isMath":false,"label":"'.' arrow middle marker (below: '|')","pos":[235.00284099578857,1502.068115234375],"zindex":0}},{"id":142,"label":{"isCoqValidated":false,"isMath":false,"label":"Press '[',']','b','B' to customize the size of the pullback sign","pos":[407.0028409957886,3792.3408203125],"zindex":0}},{"id":143,"label":{"isCoqValidated":false,"isMath":false,"label":"'~' squiggly arrow","pos":[408.19999998807907,1478.800048828125],"zindex":2}}],"sizeGrid":136,"title":"1"}]},"version":16};
var tutorial = fulltutorial["graph"];
var tutorial_format_version = fulltutorial["version"];
// webview does not support synchronous window.prompt
var customPrompt = function(question, defaut, callback) {
var ret = window.prompt(question, defaut);
if (ret !== null)
callback(ret);
}
var customAlert = function(message) {
window.alert(message);
}
var gridSize = 200;
var rulerMargin = 550;
if (supportStorage) {
function getInt(key, def) {
var result = parseInt(localStorage.getItem(key), 10);
if (! isNaN(result) && result > 0) {
return result;
}
return def;
}
gridSize = getInt(gridStorageKey, gridSize);
rulerMargin = getInt(rulerMarginKey, rulerMargin);
}
// if (fulltutorial.hasOwnProperty("graph") && fulltutorial.graph.hasOwnProperty("sizeGrid"))
// fulltutorial.graph.sizeGrid = result;
// else
// alert("Can't update size grid from preferences");
// }
// }
scenarios = {
"exercise1" : {"graph":{"edges":[{"from":1,"id":12,"label":{"label":"Ff","style":{"alignment":"left","bend":-0.1,"dashed":false,"double":true,"head":"twoheads","position":0.5,"tail":"hook"}},"to":0},{"from":0,"id":13,"label":{"label":"n_y","style":{"alignment":"left","bend":0,"dashed":false,"double":false,"head":"default","position":0.5,"tail":"none"}},"to":2},{"from":1,"id":14,"label":{"label":"n_x","style":{"alignment":"left","bend":0,"dashed":false,"double":false,"head":"default","position":0.5,"tail":"none"}},"to":3},{"from":3,"id":15,"label":{"label":"Gf","style":{"alignment":"left","bend":0,"dashed":false,"double":false,"head":"default","position":0.5,"tail":"none"}},"to":2}],"latexPreamble":"","nodes":[{"id":0,"label":{"isMath":true,"label":"Fy","pos":[531.5,115.33335876464844]}},{"id":1,"label":{"isMath":true,"label":"Fx","pos":[331.5,115.33335876464844]}},{"id":2,"label":{"isMath":true,"label":"Gy","pos":[531.5,315.33335876464844]}},{"id":3,"label":{"isMath":true,"label":"Gx","pos":[331.5,315.33335876464844]}},{"id":4,"label":{"isMath":false,"label":"Number of taken actions so far: \\textbf{$\\depthHistory$}","pos":[82,369.5333251953125]}},{"id":5,"label":{"isMath":false,"label":"Reproduce this square in 4 actions starting from the selected vertex below (mouse is disabled)","pos":[96,30.5333251953125]}},{"id":6,"label":{"isMath":true,"label":"\\bullet","pos":[276,460.18333435058594]}},{"id":7,"label":{"isMath":false,"label":"See hints below.","pos":[82,404.3833312988281]}},{"id":8,"label":{"isMath":false,"label":"- when creating an arrow, use hjkl for keyboard placement, and (>=bB for styling, before validating with TAB (hence jumping to next label)","pos":[126.5,742.3833312988281]}},{"id":9,"label":{"isMath":false,"label":"- to move selection to a close node, use hjkl.","pos":[129.5,786.3833312988281]}},{"id":10,"label":{"isMath":false,"label":"- use 's' to create a square from a node connected to two other nodes","pos":[127,825.2833404541016]}},{"id":11,"label":{"isMath":false,"label":"- rename with 'r'","pos":[130,701.1833343505859]}}],"sizeGrid":200},"version":5},
};
</script>
</head>
<body>
<h1>Diagram editor</h1>
File: <span id="filename">(no file)</span>
<button id="install" hidden>Install for offline use</button>
<button id="connect" onclick="tryConnect()">Connect to server</button>
<span id="connect-status"></span>
<!-- <p>
A vi-inspired diagram editor, with
(latex) labelled nodes and edges, tested with Firefox, written in <a href="https://elm-lang.org/">Elm</a> (see the code on
<a href="https://github.com/amblafont/graph-editor-web">github</a>).
Higher cells are supported.
You can draw anywhere, not just on the grid (whose size can be later adjusted).
</p>
<p>
For a LaTeX export, first export to <a href="https://q.uiver.app">Quiver</a> (beware that vertices will be snapped
to the grid in the process).
</p>
<p>
Read the tutorial first, and then try some <a href="?scenario=exercise1">exercise</a>.
</p>
<button onclick="loadGraph()" id="load-button" >Load graph</button>
<button title="Local or session storage" onclick="quickloadGraph()" >QuickLoad graph</button> -->
<!-- <button onclick="dispatchRenderedChildren(document)">
Recompute the layer
</button> -->
<!-- first use of katex element. It seems it should be done
beforehand, otherwise dispatchRendered on the first labelled point
gets wrong dimensions.
-->
<math-latex> </math-latex>
<div id="myapp"></div>
<script>
let installPrompt = null;
const installButton = document.querySelector("#install");
window.addEventListener("beforeinstallprompt", (event) => {
event.preventDefault();
installPrompt = event;
installButton.removeAttribute("hidden");
});
installButton.addEventListener("click", async () => {
if (!installPrompt) {
return;
}
const result = await installPrompt.prompt();
console.log(`Install prompt was: ${result.outcome}`);
disableInAppInstallPrompt();
});
function disableInAppInstallPrompt() {
installPrompt = null;
installButton.setAttribute("hidden", "");
}
const isFileAPI = typeof showDirectoryPicker != 'undefined';
const configFilename = "yade-config.json";
var vscode = undefined;
if (typeof acquireVsCodeApi != 'undefined') {
vscode = acquireVsCodeApi();
}
var currentFileHandle = undefined;
// copied from index.ts
function sendExternalMsg(key, content) {
vscode.postMessage({key:key, content:content})
}
var appDiv = document.getElementById('myapp');
document.addEventListener('keydown', function(e) {
// Desactivate globally the tab key
// Before, I did with ports: one to notify elm the keydown, another to tell js to prevent the default
// but the delay was too long and meanwhile the browser had dealt with the event.
if (e.keyCode == 9)
e.preventDefault();
// let us do it with the space key as well
// no, that's a bad idea: then it doesn't work when editing a label
// if (e.keyCode == 32)
// e.preventDefault();
// Deactivate reloading with ctrl-R
if (e.ctrlKey && e.key === "r")
e.preventDefault();
});
function dispatchRendered(node) {
if (node.clientWidth != null)
{
// could be optimized by having an additionnal
// attribute that tells whether it has
// a listener
var rect = { width : node.clientWidth , height : node.clientHeight }
/* if (node.tagName = "MATH-LATEX") {
console.log (rect);
console.log (node.getBoundingClientRect());
} */
node.dispatchEvent(new CustomEvent(renderedEvent, { detail : rect } ));
}
};
function dispatchRenderedChildren(node) {
children = node.getElementsByClassName(renderedClass);
for (var i = 0; i < children.length; ++i) {
dispatchRendered(children[i]);
}
}
function fullDispatchRendered(node) {
dispatchRendered(node);
if (node.getElementsByClassName != null) {
dispatchRenderedChildren(node);
}
}
// rendered event handlers
// Fonction callback à éxécuter quand une mutation est observée
var callbackMutation = function(mutationsList) {
for(var mutation of mutationsList) {
for(var node of mutation.addedNodes) {
fullDispatchRendered(node);
}
/* for(var node of mutation.removedNodes) {
if (node.getBoundingClientRect != null)
{
node.dispatchEvent(new CustomEvent("remove"));
}
} */
}
};
// Créé une instance de l'observateur lié à la fonction de callback
var observer = new MutationObserver(callbackMutation);
observer.observe(appDiv,
{ subtree: true, childList: true });
// initialisation de Elm
var app = Elm.Main.init({
node: appDiv,
flags: { defaultGridSize : gridSize, rulerMargin : rulerMargin
, saveLoadButtons : vscode == undefined
}
});
if (window.safari !== undefined) {
alert("The editor does not work properly in Safari.");
}
function setFileName(newName) {
document.title = newName;
document.getElementById("filename").textContent = newName;
}
function getFileName(newName) {
return document.getElementById("filename").textContent;
}
function resetFileName() {
setFileName("(no file)");
}
// we send a signal [keyInput] to elm and recieve
// the answer on [keyOutput]
function makeElmRequest(keyInput, keyOutput, f) {
app.ports[keyOutput].subscribe(f);
return function (data) {
app.ports[keyInput].send(data);
}
}
// when receiving a signal [keyInput] from Elm
// we answer by applying [f] and send the result to [keyOutput]
function answerElmRequestCallback(keyInput, keyOutput, f) {
var answer = function (data) {
f(data, function (outData) {
if (outData)
app.ports[keyOutput].send(outData);
})
};
app.ports[keyInput].subscribe(answer);
return answer;
}
function answerElmRequest(keyInput, keyOutput, f) {
return answerElmRequestCallback(keyInput, keyOutput,
(data, callback) => callback(f(data))
);
}
function sendGraphTxtToElm(txt, scenario = "standard", clipboard = false, setFirstTab = false) {
if (txt.trim() == "") {
console.log("Empty graph");
app.ports.clear.send({scenario:scenario, preamble:""});
return;
}
var json = JSON.parse(txt);
sendGraphToElm(json, scenario, clipboard, setFirstTab);
}
function sendGraphToElm(json, scenario = "standard", clipboard = false, setFirstTab = false) {
var graph = json;
var version = 0;
if (json.hasOwnProperty('version')) {
version = json.version;
graph = json.graph;
}
var args = { graph , scenario,
clipboard, setFirstTab};
app.ports["loadedGraph" + version].send(args);
}
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
var tutoData = {"graph" : tutorial, "scenario" : "standard", "clipboard" : false,
setFirstTab : false };
if (urlParams.has("scenario") && scenarios.hasOwnProperty(urlParams.get("scenario"))) {
scenario = urlParams.get("scenario");
sendGraphToElm(scenarios[scenario], scenario);
}
else {
app.ports["loadedGraph" + tutorial_format_version].send(tutoData);
}
// load a json graph file, send it to the elm component
var openFileFun = function() {
var input = document.createElement('input');
input.type = 'file';
input.accept = ".json,.yade";
input.onchange = e => {
var file = e.target.files[0];
var fr=new FileReader();
fr.onload=function(){
sendGraphTxtToElm(fr.result);
}
fr.readAsText(file);
setFileName(file.name);
// document.title = file.name;
}
input.click();
};
function openFile() {
openFileFun();
}
app.ports.openFile.subscribe(openFile);
if(isFileAPI) {
function openFileAPI(fileHandle) {
currentFileHandle = fileHandle;
currentFileHandle.getFile().then(function (file) {
setFileName(file.name);
return file.text();
})
.then(function (text) {
sendGraphTxtToElm(text);
});
}
// open the file picker with showFilePicker and sends the content to Elm
openFileFun = function() {
console.log("Opening file");
showOpenFilePicker({ types: [{ accept: { 'application/json': ['.json','.yade'] } }] })
.then(function (fileHandles) {
if (fileHandles.length != 1) {
throw new Error("No file selected");
}
return openFileAPI(fileHandles[0]);
});
};
}
function processWatchedFile(configs,preamble,dirHandle) {
function doit() {
var p = Promise.resolve();
function next(i) {
if (i >= configs.length)
return Promise.resolve(false);
return Bundle.checkWatchedFile(configs[i],dirHandle)
.then((r) => {
if (r === false)
return next(i+1);
if (r === undefined)
return Promise.resolve(undefined);
return r;
});
}
return next(0).then(function (r) {
if (r === undefined) {
return;
}
if(!r) {
var watchedFiles = configs.map((c) => c.watchedFile);
resetFileName();
app.ports.simpleMsg.send(
"Waiting for incomplete diagram in " + watchedFiles.join (", "));
window.onfocus = function () {
window.onfocus = function () {};
doit();
};
return;
}
setFileName(r.watchedFile + ":" + r.line);
saveGraphFun = function(d){
if (d.autosave) {
defaultQuickSave(d, false);
return;
}
saveGraphFun = function (d) {};
quicksaveFun = function (d) {};
Bundle.watchSaveDiagram(r, dirHandle, fromElmGraph(d.info), d.export)
.then(() => {
doit();
});
}
quicksaveFun = saveGraphFun;
loadEditor(preamble, r.content);
if (r.onlyExternalFile)
app.ports.makeSave.send(null);
});
};
doit();
}
function loadEditor(defaultPreamble, diag) {
let stripped_diag = diag.trim();
if (stripped_diag == "") {
console.log("Creating new diagram");
app.ports.clear.send({scenario:"watch", preamble:defaultPreamble});
} else {
console.log("Loading diagram ");
sendGraphTxtToElm(stripped_diag, "watch");
}
}
function extractExtensionFromPath(path) {
var parts = path.split(".");
if (parts.length < 2)
return "";
return parts[parts.length - 1];
}
app.ports.openDirectory.subscribe(
function() {
if (!isFileAPI) {
customAlert("Your browser does not support the File System Access API");
return;
}
showDirectoryPicker().then(function (dirHandle) {
dirHandle.getFileHandle(configFilename)
.then((f) => f.getFile(),(e) => {
customAlert("Cannot access " + configFilename + ": " + e.toString());
throw (e); })
.then((file) => file.text())
.then((text) => {
var json = JSON.parse(text);
if (!json.watchedFile) {
customAlert("watchedFile unspecified in the json");
return;
}
var watchedFiles = [];
if (typeof json.watchedFile == "string")
watchedFiles = [json.watchedFile]
else
watchedFiles = json.watchedFile;
delete json.watchedFile;
if (watchedFiles == []) {
console.log("No file to watch");
return;
}
var configs = [];
for (var i = 0; i < watchedFiles.length; i++) {
var extension = extractExtensionFromPath(watchedFiles[i]);
var config = Object.assign({}, Bundle.defaultConfig);
config.watchedFile = watchedFiles[i];
if (extension in Bundle.defaultsExt)
Object.assign(config, Bundle.defaultsExt[extension]);
else
console.log("Unknown extension " + extension + ".");
Object.assign(config, json);
configs.push(config);
}
var promise = new Promise((resolve) => resolve("") );
if (json.preambleFile)
promise = Bundle.getTextFromFilepath(dirHandle,json.preambleFile);
promise.then(function(preamble) {
app.ports.clear.send({scenario:"watch", preamble:preamble});
processWatchedFile(configs,preamble, dirHandle);
});
});
})
.catch((e) => { console.log(e); customAlert("Cannot access the directory"); });
}
);
// load a json graph file, from local storage
function quickloadGraph() {
if (!supportStorage) {
customAlert("Sorry, your browser does not support Web Storage.");
return;
}
// we first try loading from the current
// session storage, to avoid conflicts with
// other possibly opened tabs
var result = sessionStorage.getItem(storageKey);
if (!result) {
result = localStorage.getItem(storageKey);
if (result)
// we put it in the temporary session storage
sessionStorage.setItem(storageKey, result);
}
if (!result) {
customAlert('No quicksaved graph found');
return;
}
sendGraphTxtToElm(result);
};
app.ports.quickLoad.subscribe(quickloadGraph);
app.ports.alert.subscribe(function(s) {
customAlert(s);
});
app.ports.select.subscribe(function(id) {
var elmnt = document.getElementById(id);
if (elmnt != null)
elmnt.select();
});
app.ports.computeLayout.subscribe(function(s) {
var children = document.getElementsByClassName(renderedClass);
for (var i = 0; i < children.length; ++i) {
dispatchRendered(children[i]);
}
});
app.ports.preventDefault.subscribe(function (e) {
e.preventDefault();
});
// asks the user to download some file, generated from content
function download(content, fileName, contentType) {
var a = document.createElement("a");
var file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
function fromElmGraph(a) {
return {graph : a.graph, version : a.version };;
}
function defaultQuickSave(arg, feedback) {
console.log("Quicksaving...");
var a = arg.info;
var d = fromElmGraph(a);
// var feedback = ! arg.autosave;
// d.fileName = getFileName();
// Check browser support
if (!supportStorage) {
if (feedback)
customAlert("Sorry, your browser does not support Web Storage.");
return;
}
// Store even if the browser is closed
localStorage.setItem(storageKey, JSON.stringify(d));
// we put it also in a temporary session storage
// in case multiple tabs are opened
sessionStorage.setItem(storageKey, JSON.stringify(d));
if (feedback)
customAlert("Successful quicksave");
}
var quicksaveFun = function(a) {
defaultQuickSave(a, !a.autosave);
};
app.ports.quicksaveGraph.subscribe((e) => quicksaveFun(e));
function saveFileApi(arg) {
var a = arg.info;
var d = fromElmGraph(a);
return currentFileHandle.createWritable()
.then(
(fileWriter) =>
fileWriter.write(JSON.stringify(d))
.then(() => {
return fileWriter.close();
})
);
};
if (isFileAPI) {
quicksaveFun = function(arg) {
var feedback = !arg.autosave;
if (!currentFileHandle) {
defaultQuickSave(arg, feedback);
return;
}
defaultQuickSave(arg, false);
saveFileApi(arg)
.then(() => {
if (feedback) {
customAlert("Successful quicksave to " + currentFileHandle.name);
}
});
};
}
app.ports.saveRulerGridSize.subscribe(function(arg) {
console.log("Saving grid size preferences.");
// Check browser support
if (!supportStorage) {
customAlert("Sorry, your browser does not support Web Storage.");
return;
}
// Store even if the browser is closed
localStorage.setItem(gridStorageKey, arg.gridSize);
localStorage.setItem(rulerMarginKey, arg.rulerMargin);
});
app.ports.exportQuiver.subscribe(function(d) {
// copied from quiver/quiver.js (export base64)
var s = `https://q.uiver.app/?q=${
btoa(unescape(encodeURIComponent(JSON.stringify(d))))}`;
window.open(s);
});
var saveGraphFun = function (b) {
var a = b.info;
// var name = getFileName();
var name = "graph.json"
var d = fromElmGraph(a);
download(JSON.stringify(d), name /* + '.json' */, 'application/json');
document.title = name;
};
app.ports.saveGraph.subscribe((b) => saveGraphFun(b));
if (isFileAPI) {
saveGraphFun = function (d) {
// open showsavefilepicker
showSaveFilePicker({ types: [{ accept: { 'application/json': ['.json', '.yade'] } }] })
.then(function (fileHandle) {
currentFileHandle = fileHandle;
setFileName(currentFileHandle.name);
return saveFileApi(d);
})
};
}
// this event handler computes the relative position
// of the mouse with respect to the current target
// (the one to which the event is attached)
answerElmRequest('onMouseMove', 'onMouseMoveFromJS', function(e) {
if ( e.currentTarget) {
var rect = e.currentTarget.getBoundingClientRect();
var x = e.clientX - rect.left; //x position within the element.
var y = e.clientY - rect.top; //y position within the element.
return [x, y];
}
});
document.addEventListener("paste", function (e) {
const clipboardData = e.clipboardData || window.clipboardData;
console.log("paste");
const text = clipboardData.getData('text') || "";
// console.log(text);
var json;
try {
json = JSON.parse(text);
}
catch (e) { json = false; }
// console.log(json);
if (json) {
sendGraphToElm(json, "standard", true);
// cnonsole.log(json);
}
// app.ports.onPaste.send(text);
});
// answerElmRequest('decodeGraph', 'decodedGraph', function (paste) {
// var json;
// try { json = JSON.parse(paste); }
// catch (e) { json = false; }
// if (json)
// return json.graph
// })
answerElmRequestCallback('promptFindReplace', 'findReplace', (a, callback) =>
customPrompt("Replace in selection (/find/replace, where '/' can be replaced by any character)",
"/find/replace",
function (rep) {
if (rep.length > 2) {
reps = rep.split(rep[0])
if (reps && reps.length == 3 && reps[1]) {
var search = reps[1];
var replace = reps[2];
callback({'search':search, 'replace': replace});
}
}
})
);
answerElmRequestCallback('promptEquation', 'promptedEquation', (a, callback) =>
customPrompt("Enter equation",
"a -- f -> b -- g -> c = a -- h -> d -- k -> c", function (rep) {
if (rep.length > 0) {
callback(rep); //{ equation : rep, final: false, scenario: ""};
}
})
);
answerElmRequestCallback('promptTabTitle', 'promptedTabTitle', (a, callback) =>
customPrompt("Rename tab",
a, function (rep) {
// console.log("reponse: " + rep);
// if (rep && rep.length > 0) {
callback(rep); //{ equation : rep, final: false, scenario: ""};
})
);
app.ports.clipboardWriteGraph.subscribe(function(g) {
navigator.clipboard.writeText(JSON.stringify(g));
});
app.ports.clipboardWriteLatex.subscribe(function(g) {
navigator.clipboard.writeText(
"% YADE DIAGRAM " + JSON.stringify(g.graph)
+ "\n% GENERATED LATEX\n"
+ g.tex
+ "\n% END OF GENERATED LATEX"
).then(
() => {
customAlert("LaTeX copied to clipboard");
});
});
/*
function toClipboard({content, success, failure}) {
navigator.clipboard.writeText(content).then(
() => {
success && customAlert(success);
},
() => {
failure && customAlert(failure);
});
};
app.ports.toClipboard.subscribe(toClipboard);
*/
app.ports.requestMarker.subscribe((oldMarker) => {
customPrompt("Enter middle marker", oldMarker, (marker) => {
app.ports.returnMarker.send(marker);
});
});
const err = "This feature is only enabled with the webview version embedded in the appropriate vscode extension";
if (vscode) {
app.ports.applyProof.subscribe(function(data){
sendExternalMsg("apply-proof", data)
});
app.ports.requestProof.subscribe((data) => {
customPrompt("Enter proof for " + data.statement + " (leave blank for interactive)", data.script, (proof) => {
newData = {script: proof, statement:data.statement};
if (proof == "") {
sendExternalMsg("incomplete-equation", newData);
}
else {
sendExternalMsg("apply-proof", newData);
}
});
});
}
else {
// 0.7em c'est bien
//utiliser \relscale{0.7} pour changer la taille de la police
// bah non ca ne marche pas..
// app.ports.incompleteEquation.subscribe((data) => customAlert(err));
app.ports.applyProof.subscribe((data) => customAlert(err));
app.ports.requestProof.subscribe((data) => {
navigator.clipboard.writeText(data.statement)
.then(() => customAlert("Statement copied to clipboard"));
}
);
}
function copyErr(s, emptyErr, success, failure) {
if (s == "") {
customAlert("No selected subdiagram found!");
return;
}
toClipboard(
{ content : s,
success : success,
failure : failure});
}
function processProof(script) {
var s = script.proof;
if (s != "") {
var json = JSON.stringify(script.graph);
if (json)
s =
"(*\n YADE DIAGRAM " +
json + "\n *)\n" + s;
}
return s;
}
app.ports.generateProofJs.subscribe(function(script) {
var s = processProof(script);
copyErr(s,
"No selected diagram found!",
"Coq script successfully copied",
"Copy failed"
);
});
app.ports.generateSvg.subscribe(function(svg) {
copyErr(svg,
"No selected diagram found!",
"SVG code successfully copied",
"Copy failed"
);
});
document.addEventListener("copy", function(event) {
app.ports.onCopy.send(null);
});
document.addEventListener("cut", function(event) {
app.ports.onCut.send(null);
});
// Elm browser keydown handler is passive
// and thus cannot prevent default behaviour
// so we make our custom event listener.
document.addEventListener("keydown", function(event) {
app.ports.onKeyDownActive.send(event);
});
app.ports.focusPosition.subscribe(function(pos) {
var x = pos[0];
var y = pos[1];
const svg = document.getElementById("canvas");
const svgRect = svg.getBoundingClientRect();
const centerX = svgRect.x + window.pageXOffset + x - window.innerWidth / 2;
const centerY = svgRect.y + window.pageYOffset + y - window.innerHeight / 2;
// Scroll to the calculated position
window.scrollTo({
top: centerY,
left: centerX,
behavior: 'smooth' // Optional: 'smooth' for a smooth scrolling effect
});
});
/*
Interaction with server with websocket
*/
var online = false;
var ws = null;
function connectToServer(rep) {
console.log("connecting to " + rep);
ws = new WebSocket(rep);
var intervalId = null;
ws.onclose = function(event) {
online = false;
if (intervalId !== null)
clearInterval(intervalId);
document.getElementById("connect-status").textContent = "";
if (event.wasClean) {
customAlert(`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`);
} else {
// par exemple : processus serveur arrêté ou réseau en panne
// event.code est généralement 1006 dans ce cas
customAlert('[close] Connection died');
}
};
// La connexion est ouverte