Skip to content

Commit 9ec18d4

Browse files
committed
Add SSE streaming support to Ajax class and enhance documentation
- Implement `stream()` method in the Ajax class for Server-Sent Events (SSE) streaming. - Update README.md with full API reference, usage examples, and SSE streaming guide. - Add tests for SSE streaming functionality in ajax.test.js. - Ensure proper handling of various SSE event formats and connection errors.
1 parent ddf030d commit 9ec18d4

6 files changed

Lines changed: 1249 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,34 @@
99
> - :house: [Internal]
1010
> - :nail_care: [Polish]
1111

12+
## 4.11.14
13+
14+
#### :rocket: New Feature
15+
16+
- Add `stream()` method to `Ajax` class for SSE (Server-Sent Events) streaming over XMLHttpRequest. Returns an `AsyncGenerator<string>` that yields parsed `data:` fields incrementally via `onprogress`.
17+
18+
```js
19+
const ajax = new Jodit.modules.Ajax({
20+
method: 'POST',
21+
url: '/api/ai/stream',
22+
contentType: 'application/json',
23+
data: { prompt: 'Hello' }
24+
});
25+
26+
try {
27+
for await (const data of ajax.stream()) {
28+
const event = JSON.parse(data);
29+
editor.s.insertHTML(event.text);
30+
}
31+
} finally {
32+
ajax.destruct();
33+
}
34+
```
35+
36+
#### :memo: Documentation
37+
38+
- Rewrite `src/core/request/README.md` with full API reference, usage examples, SSE streaming guide, AbortController integration, and real-world patterns (FileBrowser, Uploader, plugins).
39+
1240
## 4.11.12
1341

1442
#### :rocket: New Feature

0 commit comments

Comments
 (0)