braid-text 0.5.7 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,32 +1,13 @@
1
- <body style="margin: 0px; padding: 0px; box-sizing: border-box">
2
- <textarea id="the_editor" style="width: 100%; height: 100%;" disabled></textarea>
1
+ <body style="margin: 0; padding: 0; box-sizing: border-box">
2
+ <synced-textarea id="the_editor" style="width: 100%; height: 100vh;"></synced-textarea>
3
3
  </body>
4
- <script src="https://braid.org/code/myers-diff1.js"></script>
5
4
  <script src="https://unpkg.com/braid-http@~1.3/braid-http-client.js"></script>
6
- <script src="/web-utils.js"></script>
7
- <script src="/simpleton-sync.js"></script>
5
+ <script src="/myers-diff.js"></script>
6
+ <script src="/text-client.js"></script>
7
+ <script src="/simpleton.js"></script>
8
8
  <script src="/textarea-highlights.js"></script>
9
9
  <script src="/cursor-sync.js"></script>
10
+ <script src="/syncarea.js"></script>
10
11
  <script>
11
-
12
- var cursors = cursor_highlights(the_editor, location.pathname)
13
-
14
- var simpleton = simpleton_client(location.pathname, {
15
- on_online: (online) => { online ? cursors.online() : cursors.offline() },
16
- on_patches: (patches) => {
17
- the_editor.disabled = false
18
- apply_patches_and_update_selection(the_editor, patches)
19
- cursors.on_patches(patches)
20
- },
21
- get_patches: (prev_state) => diff(prev_state, the_editor.value),
22
- get_state: () => the_editor.value,
23
- on_error: (e) => set_error_state(the_editor),
24
- on_ack: () => set_acked_state(the_editor)
25
- })
26
-
27
- the_editor.oninput = (e) => {
28
- set_acked_state(the_editor, false)
29
- cursors.on_edit(simpleton.changed())
30
- }
31
-
12
+ the_editor.setAttribute('src', location.pathname)
32
13
  </script>
@@ -1,43 +1,30 @@
1
1
  <meta name="viewport" content="width=device-width,initial-scale=.62"/>
2
2
  <script src="https://invisible.college/js/marked.min.js"></script>
3
- <script src="https://braid.org/code/myers-diff1.js"></script>
4
3
  <script src="https://unpkg.com/braid-http@~1.3/braid-http-client.js"></script>
5
- <script src="/web-utils.js"></script>
6
- <script src="/simpleton-sync.js"></script>
4
+ <script src="/myers-diff.js"></script>
5
+ <script src="/text-client.js"></script>
6
+ <script src="/simpleton.js"></script>
7
7
  <script src="/textarea-highlights.js"></script>
8
8
  <script src="/cursor-sync.js"></script>
9
+ <script src="/syncarea.js"></script>
9
10
  <body>
10
11
  <div id="markdown_container" style="max-width: 750px; padding: 10px 60px"></div>
11
12
  <div id="bottom_spacer" style="height: 50vh; display: none;"></div>
12
- <div id="editor_wrap" style="
13
- position: fixed;
14
- bottom: 0;
15
- right: 0;
16
- width: 45vw;
17
- height: 100%;
18
- ">
19
- <textarea
13
+ <div id="editor_wrap" style="position: fixed; bottom: 0; right: 0; width: 45vw; height: 100%;">
14
+ <synced-textarea
20
15
  id="the_editor"
21
- disabled
22
16
  style="
23
- width: 100%;
24
- height: 100%;
25
- font-size: 15px;
17
+ width: 100%; height: 100%; font-size: 15px;
26
18
  font-family: helvetica, arial, avenir, lucida grande;
27
19
  hyphens: none;
28
- "></textarea>
20
+ "></synced-textarea>
29
21
  </div>
30
- <div
22
+ <div
31
23
  id="edit-button"
32
24
  style="
33
- position: fixed;
34
- bottom: 0;
35
- right: 0;
36
- padding: 30px;
37
- cursor: pointer;
38
- text-decoration: none;
39
- background-color: rgba(250, 250, 250, .5);
40
- " onclick="toggle_editor()">edit</div>
25
+ position: fixed; bottom: 0; right: 0; padding: 30px; cursor: pointer;
26
+ text-decoration: none; background-color: rgba(250, 250, 250, .5); "
27
+ onclick="toggle_editor()">edit</div>
41
28
  </body>
42
29
  <script>
43
30
 
@@ -46,27 +33,8 @@ var first_time = true
46
33
  var render_timer = null
47
34
  var render_delay = 100
48
35
 
49
- var cursors = cursor_highlights(the_editor, location.pathname)
50
-
51
- var simpleton = simpleton_client(location.pathname, {
52
- on_online: (online) => { online ? cursors.online() : cursors.offline() },
53
- on_patches: (patches) => {
54
- the_editor.disabled = false
55
- apply_patches_and_update_selection(the_editor, patches)
56
- cursors.on_patches(patches)
57
- update_markdown_later()
58
- },
59
- get_patches: (prev_state) => diff(prev_state, the_editor.value),
60
- get_state: () => the_editor.value,
61
- on_error: (e) => set_error_state(the_editor),
62
- on_ack: () => set_acked_state(the_editor)
63
- })
64
-
65
- the_editor.oninput = (e) => {
66
- set_acked_state(the_editor, false)
67
- cursors.on_edit(simpleton.changed())
68
- update_markdown_later()
69
- }
36
+ the_editor.setAttribute('src', location.pathname)
37
+ the_editor.addEventListener('update', update_markdown_later)
70
38
 
71
39
  document.body.onkeydown = (e) => {
72
40
  if (e.keyCode === 27) { // Escape key
@@ -108,4 +76,4 @@ function update_markdown() {
108
76
  markdown_container.innerHTML = marked(the_editor.value, { sanitize: false })
109
77
  }
110
78
 
111
- </script>
79
+ </script>