Commit 9c9d970
XWIKI-24372: Implement auto-save for BlockNote realtime collaboration sessions
* Separate the generic XWiki document API from the real-time specific one, by splitting the XWikiDocument class in
two: XWikiDocument, which holds the generic API, and RealtimeXWikiDocument, which adds the Netflux channels API on
top of it. Both stay in the same module for now.
* Decouple XWikiDocument from the current document, so that it can target any document: the constructor became a copy
constructor, update() merges only the data it is given, and the current document is now obtained through the static
currentDocument() factory. The page state side effect (the meta version and the hidden fields of the edit form)
moved to syncCurrentDocumentState().
* Limit the jQuery usage to event handling, which is the only place where it is required, since XWiki triggers its
events with jQuery: $.extend became Object.assign, $.param became URLSearchParams, $.getJSON and $.post became
fetch, and $('#id').val() became plain DOM access. Note that fetch keeps the form token and the custom XWiki
response headers working because xwiki.js wraps it for that purpose.
* Remove XWikiDocument#save(), which never had a caller since it was introduced.
* Request the REST API of the edited document translation rather than the one of the original translation, which is
exposed through a different URL. The Netflux channels are still requested from the page, because they are not
exposed per translation: the translations are separated by the channel path instead.
* Stop overwriting the language field received from the REST API. The raw locale is kept in 'language' while the real
locale is exposed by the new realLocale accessor, computed from the raw locale and the default locale.
* Align the XWikiDocument implementation with the one from XWiki.InplaceEditing, in order to ease a future
de-duplication: reuse its getOldAPI() and removeNullProperties() helpers, its real locale computation and its
translation aware REST URL. The fallback on document.documentElement.lang is deliberately left out, because two
users having different UI locales would then compute different real locales for a technical document (the one
having the root locale as default locale), and thus end up using different Netflux channels.
Verified with RealtimeWYSIWYGEditorIT (28 tests) after each step. Two cases are not covered by the automated tests
and were checked by reading the code only:
* a technical document, having the root locale as default locale, edited by two users having different UI locales;
* the toolbar version entries, whose author and date come from the document translation history.
Both deserve a follow-up, together with these two findings:
* Saver#_notifyInitialVersion() swallows every error with a console.debug(), which is why the REST URL targeting the
wrong document translation produced no signal at all.
* The in-place editor and lock.js compute the real locale of a technical document from the UI locale, so two users
having different UI locales use different lock keys for the same document translation.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>1 parent 879250a commit 9c9d970
5 files changed
Lines changed: 192 additions & 101 deletions
File tree
- xwiki-platform-core/xwiki-platform-realtime
- xwiki-platform-realtime-ui/src/main/resources/XWiki/Realtime
- xwiki-platform-realtime-webjar/src/main/webjar
- xwiki-platform-realtime-wysiwyg/xwiki-platform-realtime-wysiwyg-webjar/src/main/webjar
Lines changed: 6 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
540 | 540 | | |
541 | 541 | | |
542 | 542 | | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
547 | 548 | | |
548 | 549 | | |
549 | 550 | | |
550 | 551 | | |
551 | 552 | | |
552 | 553 | | |
553 | 554 | | |
554 | | - | |
| 555 | + | |
555 | 556 | | |
556 | 557 | | |
557 | 558 | | |
| |||
Lines changed: 171 additions & 81 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
34 | 32 | | |
35 | | - | |
| 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 | + | |
36 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
37 | 87 | | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
55 | 111 | | |
56 | | - | |
| 112 | + | |
57 | 113 | | |
58 | 114 | | |
59 | | - | |
| 115 | + | |
60 | 116 | | |
61 | 117 | | |
62 | 118 | | |
63 | 119 | | |
64 | 120 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | 121 | | |
69 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
70 | 125 | | |
71 | 126 | | |
72 | 127 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
85 | 141 | | |
86 | | - | |
87 | | - | |
| 142 | + | |
| 143 | + | |
88 | 144 | | |
89 | | - | |
90 | 145 | | |
91 | 146 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
| 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 | + | |
107 | 210 | | |
108 | 211 | | |
109 | 212 | | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
| 213 | + | |
| 214 | + | |
116 | 215 | | |
117 | | - | |
| 216 | + | |
118 | 217 | | |
119 | 218 | | |
120 | 219 | | |
| |||
123 | 222 | | |
124 | 223 | | |
125 | 224 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 225 | | |
137 | 226 | | |
138 | | - | |
139 | | - | |
| 227 | + | |
| 228 | + | |
140 | 229 | | |
141 | 230 | | |
| 231 | + | |
142 | 232 | | |
143 | | - | |
| 233 | + | |
144 | 234 | | |
145 | 235 | | |
146 | 236 | | |
| |||
Lines changed: 9 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
485 | | - | |
| 485 | + | |
486 | 486 | | |
487 | 487 | | |
488 | 488 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
| 323 | + | |
324 | 324 | | |
325 | | - | |
326 | | - | |
| 325 | + | |
| 326 | + | |
327 | 327 | | |
328 | 328 | | |
329 | 329 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
422 | 422 | | |
423 | 423 | | |
424 | 424 | | |
425 | | - | |
| 425 | + | |
426 | 426 | | |
427 | 427 | | |
428 | 428 | | |
429 | 429 | | |
430 | | - | |
431 | | - | |
| 430 | + | |
| 431 | + | |
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| |||
0 commit comments