imio.omnia.tinymce 1.0__py3-none-any.whl

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.
Files changed (90) hide show
  1. imio/omnia/tinymce/__init__.py +6 -0
  2. imio/omnia/tinymce/browser/__init__.py +0 -0
  3. imio/omnia/tinymce/browser/action.py +6 -0
  4. imio/omnia/tinymce/browser/configure.zcml +40 -0
  5. imio/omnia/tinymce/browser/controlpanel.py +93 -0
  6. imio/omnia/tinymce/browser/npm/package-lock.json +125 -0
  7. imio/omnia/tinymce/browser/npm/package.json +8 -0
  8. imio/omnia/tinymce/browser/overrides/.gitkeep +0 -0
  9. imio/omnia/tinymce/browser/resources/.env.example +13 -0
  10. imio/omnia/tinymce/browser/resources/.git +1 -0
  11. imio/omnia/tinymce/browser/resources/.gitignore +26 -0
  12. imio/omnia/tinymce/browser/resources/.gitlab-ci.yml +77 -0
  13. imio/omnia/tinymce/browser/resources/.storybook/main.js +124 -0
  14. imio/omnia/tinymce/browser/resources/.storybook/preview.js +8 -0
  15. imio/omnia/tinymce/browser/resources/CHANGELOG.md +19 -0
  16. imio/omnia/tinymce/browser/resources/CLAUDE.md +62 -0
  17. imio/omnia/tinymce/browser/resources/Makefile +28 -0
  18. imio/omnia/tinymce/browser/resources/README.md +327 -0
  19. imio/omnia/tinymce/browser/resources/dev/index.html +41 -0
  20. imio/omnia/tinymce/browser/resources/dev/vite.config.js +78 -0
  21. imio/omnia/tinymce/browser/resources/docs/images/example1.png +0 -0
  22. imio/omnia/tinymce/browser/resources/eslint.config.js +36 -0
  23. imio/omnia/tinymce/browser/resources/package-lock.json +4913 -0
  24. imio/omnia/tinymce/browser/resources/package.json +61 -0
  25. imio/omnia/tinymce/browser/resources/src/assets/ia-icon.svg +5 -0
  26. imio/omnia/tinymce/browser/resources/src/assets/omnia-icon.svg +10 -0
  27. imio/omnia/tinymce/browser/resources/src/client.js +239 -0
  28. imio/omnia/tinymce/browser/resources/src/config.js +220 -0
  29. imio/omnia/tinymce/browser/resources/src/plugin.js +158 -0
  30. imio/omnia/tinymce/browser/resources/src/shortcuts.js +92 -0
  31. imio/omnia/tinymce/browser/resources/src/ui/App.jsx +75 -0
  32. imio/omnia/tinymce/browser/resources/src/ui/FloatingPanel.jsx +375 -0
  33. imio/omnia/tinymce/browser/resources/src/ui/PanelHeader.jsx +15 -0
  34. imio/omnia/tinymce/browser/resources/src/ui/SidePanel.jsx +284 -0
  35. imio/omnia/tinymce/browser/resources/src/ui/StreamingText.jsx +143 -0
  36. imio/omnia/tinymce/browser/resources/src/ui/components.jsx +70 -0
  37. imio/omnia/tinymce/browser/resources/src/ui/mount.jsx +35 -0
  38. imio/omnia/tinymce/browser/resources/src/ui/omnia.css +35 -0
  39. imio/omnia/tinymce/browser/resources/src/utils.js +56 -0
  40. imio/omnia/tinymce/browser/resources/stories/FloatingPanel.stories.jsx +66 -0
  41. imio/omnia/tinymce/browser/resources/stories/SidePanel.stories.jsx +31 -0
  42. imio/omnia/tinymce/browser/resources/stories/StreamingText.stories.jsx +85 -0
  43. imio/omnia/tinymce/browser/resources/stories/TinyMCEEditor.stories.js +228 -0
  44. imio/omnia/tinymce/browser/resources/stories/TypingDots.stories.jsx +31 -0
  45. imio/omnia/tinymce/browser/resources/stories/mocks/editor.js +66 -0
  46. imio/omnia/tinymce/browser/resources/stories/mocks/omnia-client.js +99 -0
  47. imio/omnia/tinymce/browser/resources/stories/presets/accessibilite-reglement.html +49 -0
  48. imio/omnia/tinymce/browser/resources/stories/presets/ameliorer-communication.html +36 -0
  49. imio/omnia/tinymce/browser/resources/stories/presets/corriger-bulletin.html +186 -0
  50. imio/omnia/tinymce/browser/resources/stories/presets/long-cdld.html +12389 -0
  51. imio/omnia/tinymce/browser/resources/stories/presets/reduire-deliberation.html +87 -0
  52. imio/omnia/tinymce/browser/resources/stories/presets/traduire-guide.html +234 -0
  53. imio/omnia/tinymce/browser/resources/vite.config.js +27 -0
  54. imio/omnia/tinymce/browser/static/omnia-tinymce.css +1 -0
  55. imio/omnia/tinymce/browser/static/omnia-tinymce.js +22 -0
  56. imio/omnia/tinymce/browser/templates/omnia_config.pt +10 -0
  57. imio/omnia/tinymce/browser/viewlets.py +57 -0
  58. imio/omnia/tinymce/configure.zcml +42 -0
  59. imio/omnia/tinymce/interfaces.py +7 -0
  60. imio/omnia/tinymce/locales/README.rst +37 -0
  61. imio/omnia/tinymce/locales/__init__.py +0 -0
  62. imio/omnia/tinymce/locales/en/LC_MESSAGES/imio.omnia.tinymce.po +83 -0
  63. imio/omnia/tinymce/locales/fr/LC_MESSAGES/imio.omnia.tinymce.po +83 -0
  64. imio/omnia/tinymce/locales/imio.omnia.tinymce.pot +86 -0
  65. imio/omnia/tinymce/locales/update.py +74 -0
  66. imio/omnia/tinymce/locales/update.sh +12 -0
  67. imio/omnia/tinymce/permissions.zcml +10 -0
  68. imio/omnia/tinymce/profiles/default/actions.xml +13 -0
  69. imio/omnia/tinymce/profiles/default/browserlayer.xml +7 -0
  70. imio/omnia/tinymce/profiles/default/catalog.xml +4 -0
  71. imio/omnia/tinymce/profiles/default/metadata.xml +7 -0
  72. imio/omnia/tinymce/profiles/default/registry/main.xml +35 -0
  73. imio/omnia/tinymce/profiles/default/rolemap.xml +7 -0
  74. imio/omnia/tinymce/profiles/uninstall/browserlayer.xml +7 -0
  75. imio/omnia/tinymce/setuphandlers.py +45 -0
  76. imio/omnia/tinymce/testing.py +48 -0
  77. imio/omnia/tinymce/tests/__init__.py +0 -0
  78. imio/omnia/tinymce/tests/robot/test_example.robot +66 -0
  79. imio/omnia/tinymce/tests/test_robot.py +28 -0
  80. imio/omnia/tinymce/tests/test_setup.py +68 -0
  81. imio/omnia/tinymce/tests/test_viewlet.py +99 -0
  82. imio.omnia.tinymce-1.0-py3.12-nspkg.pth +2 -0
  83. imio_omnia_tinymce-1.0.dist-info/METADATA +294 -0
  84. imio_omnia_tinymce-1.0.dist-info/RECORD +90 -0
  85. imio_omnia_tinymce-1.0.dist-info/WHEEL +5 -0
  86. imio_omnia_tinymce-1.0.dist-info/entry_points.txt +5 -0
  87. imio_omnia_tinymce-1.0.dist-info/licenses/LICENSE.GPL +339 -0
  88. imio_omnia_tinymce-1.0.dist-info/licenses/LICENSE.rst +15 -0
  89. imio_omnia_tinymce-1.0.dist-info/namespace_packages.txt +2 -0
  90. imio_omnia_tinymce-1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,327 @@
1
+ # @imiobe/omnia-tinymce
2
+
3
+ TinyMCE plugin that integrates [iMio's Omnia AI API](https://omnia.imio.be) for intelligent content manipulation: generation, expansion, improvement, reduction, correction, accessibility and translation.
4
+
5
+ ![Floating panel correcting text in a municipal bulletin](docs/images/example1.png)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @imiobe/omnia-tinymce tinymce
11
+ ```
12
+
13
+ ## Quick start
14
+
15
+ ```js
16
+ import tinymce from 'tinymce';
17
+ import '@imiobe/omnia-tinymce';
18
+
19
+ tinymce.init({
20
+ selector: '#editor',
21
+ plugins: 'omnia',
22
+ toolbar: 'undo redo | omnia | bold italic',
23
+ contextmenu: 'omnia',
24
+ omnia_base_url: '/omnia-api',
25
+ });
26
+ ```
27
+
28
+ The plugin registers itself as `omnia`. Once loaded, it adds a toolbar menu button and (optionally) context menu items for all AI features.
29
+
30
+ ## Options
31
+
32
+ All options are prefixed with `omnia_` and set in the TinyMCE `init()` config.
33
+
34
+ ### Alternative: `window.omnia_tinymce_settings`
35
+
36
+ When the host application cannot inject options directly into the `tinymce.init()` config (e.g. when TinyMCE is initialised inside a bundler-scoped module), you can set them via a global object instead:
37
+
38
+ ```html
39
+ <script>
40
+ window.omnia_tinymce_settings = {
41
+ omnia_base_url: '/omnia-api',
42
+ omnia_enabled_features: ['correct-text', 'translate-text'],
43
+ };
44
+ </script>
45
+ ```
46
+
47
+ The plugin reads from `window.omnia_tinymce_settings` at startup and applies any `omnia_*` key that was not already provided through the init config. Options passed directly to `tinymce.init()` always take precedence.
48
+
49
+ | Option | Type | Default | Description |
50
+ |--------|------|---------|-------------|
51
+ | `omnia_base_url` | `string` | `''` | **Required.** Base URL of the Omnia-compatible API. |
52
+ | `omnia_application` | `string` | `''` | Value sent as `x-imio-application` header. |
53
+ | `omnia_municipality` | `string` | `''` | Value sent as `x-imio-municipality` header. |
54
+ | `omnia_enabled_features` | `string[]` | all except `generate` | Restrict to a subset of feature IDs (see below). |
55
+ | `omnia_toolbar` | `boolean` | `true` | Show the Omnia toolbar button. |
56
+ | `omnia_context_menu` | `boolean` | `true` | Show Omnia items in the context menu. |
57
+ | `omnia_shortcuts` | `boolean \| object` | `true` | Enable keyboard shortcuts. Pass an object for custom bindings. |
58
+ | `omnia_translate_languages` | `string[]` | `['fr','nl','de','en','es','it']` | Languages available for translation. |
59
+ | `omnia_default_translate_language` | `string` | `'fr'` | Pre-selected translation target. |
60
+ | `omnia_history_limit` | `number` | `5` | Max items kept in the generation history. |
61
+ | `omnia_floating_panel_mode` | `'inline' \| 'blur'` | `'inline'` | Display mode: inline near selection or centred with blur overlay. |
62
+ | `omnia_floating_panel_width` | `number \| 'full'` | `500` | Floating panel width in pixels, or `'full'` for viewport width. |
63
+ | `omnia_endpoints` | `object` | `{}` | Override individual endpoint paths (see API section). |
64
+
65
+ ## Features
66
+
67
+ | ID | Label | Shortcut | Requires selection |
68
+ |----|-------|----------|--------------------|
69
+ | `generate` | Generer du contenu | `Alt+O`, `G` | No (not yet implemented server-side -- disabled by default) |
70
+ | `expand-text` | Developper | `Alt+O`, `D` | Yes |
71
+ | `improve-text` | Ameliorer | `Alt+O`, `A` | Yes |
72
+ | `reduce-text` | Reduire | `Alt+O`, `R` | Yes |
73
+ | `correct-text` | Corriger | `Alt+O`, `C` | Yes |
74
+ | `make-accessible` | Rendre accessible | `Alt+O`, `X` | Yes |
75
+ | `translate-text` | Traduire | `Alt+O`, `T` | Yes |
76
+
77
+ Shortcuts use a chord system: press `Alt+O` (the prefix), release, then press the letter within 1.5 s. Both the prefix key and individual bindings can be customised:
78
+
79
+ ```js
80
+ omnia_shortcuts: {
81
+ prefix: 'o',
82
+ timeoutMs: 2000,
83
+ bindings: {
84
+ 'generate': 'g',
85
+ 'improve-text': 'i',
86
+ },
87
+ }
88
+ ```
89
+
90
+ Set `omnia_shortcuts: false` to disable shortcuts entirely.
91
+
92
+ ## Implementing an Omnia-compatible API proxy
93
+
94
+ The plugin expects a backend that exposes the endpoints listed below. All requests are `POST` with `Content-Type: application/json`. The base URL is set via `omnia_base_url` and every path is appended to it.
95
+
96
+ ### Headers
97
+
98
+ Every request includes these headers when configured:
99
+
100
+ | Header | Source |
101
+ |--------|--------|
102
+ | `Content-Type` | Always `application/json` |
103
+ | `x-imio-application` | `omnia_application` option |
104
+ | `x-imio-municipality` | `omnia_municipality` option |
105
+
106
+ Streaming requests additionally send `Accept: text/event-stream`.
107
+
108
+ ### Endpoints
109
+
110
+ #### `POST /generate` (streaming)
111
+
112
+ > **Note:** This endpoint is not yet implemented in the Omnia API. The `generate` feature is disabled by default. To enable it (e.g. with your own backend), add `'generate'` to `omnia_enabled_features`.
113
+
114
+ Generate content from a free-text prompt. Returns a **Server-Sent Events** stream.
115
+
116
+ **Request:**
117
+
118
+ ```json
119
+ { "prompt": "Write an introduction about...", "tone": "formal" }
120
+ ```
121
+
122
+ The `tone` field is optional. Any extra options are forwarded as-is.
123
+
124
+ **Response:** SSE stream where each event contains a JSON chunk:
125
+
126
+ ```
127
+ data: {"chunk":"Hello "}
128
+
129
+ data: {"chunk":"world."}
130
+
131
+ data: [DONE]
132
+ ```
133
+
134
+ The stream ends with a `data: [DONE]` sentinel.
135
+
136
+ ---
137
+
138
+ #### `POST /v1/agents/expand-text`
139
+
140
+ Expand / enrich the input text.
141
+
142
+ ```json
143
+ // Request
144
+ { "input": "<p>Short text.</p>", "expansion_target": 2 }
145
+
146
+ // Response
147
+ { "result": "<p>Longer, more detailed text...</p>" }
148
+ ```
149
+
150
+ `expansion_target` is optional (multiplier, e.g. `2` = twice as long).
151
+
152
+ #### `POST /v1/agents/improve-text`
153
+
154
+ Improve the style and quality of the input text.
155
+
156
+ ```json
157
+ // Request
158
+ { "input": "<p>Draft text.</p>" }
159
+
160
+ // Response
161
+ { "result": "<p>Improved text.</p>" }
162
+ ```
163
+
164
+ #### `POST /v1/agents/reduce-text`
165
+
166
+ Shorten the input text.
167
+
168
+ ```json
169
+ // Request
170
+ { "input": "<p>Verbose text...</p>", "reduction_target": 0.5 }
171
+
172
+ // Response
173
+ { "result": "<p>Shorter text.</p>" }
174
+ ```
175
+
176
+ `reduction_target` is optional (ratio, e.g. `0.5` = half the length).
177
+
178
+ #### `POST /v1/agents/correct-text`
179
+
180
+ Fix spelling and grammar.
181
+
182
+ ```json
183
+ // Request
184
+ { "input": "<p>Text with erors.</p>" }
185
+
186
+ // Response
187
+ { "result": "<p>Text with errors.</p>" }
188
+ ```
189
+
190
+ #### `POST /v1/agents/make-accessible`
191
+
192
+ Rewrite for WCAG accessibility (plain language).
193
+
194
+ ```json
195
+ // Request
196
+ { "input": "<p>Complex legal jargon...</p>" }
197
+
198
+ // Response
199
+ { "result": "<p>Clear, accessible text...</p>" }
200
+ ```
201
+
202
+ #### `POST /v1/agents/translate-text`
203
+
204
+ Translate text to a target language.
205
+
206
+ ```json
207
+ // Request
208
+ { "input": "<p>Bonjour le monde.</p>", "target_language": "nl" }
209
+
210
+ // Response
211
+ { "result": "<p>Hallo wereld.</p>" }
212
+ ```
213
+
214
+ Supported language codes: `fr`, `nl`, `de`, `en`, `es`, `it`.
215
+
216
+ ---
217
+
218
+ ### Overriding endpoints
219
+
220
+ Use `omnia_endpoints` to point individual features at different paths or full URLs:
221
+
222
+ ```js
223
+ omnia_endpoints: {
224
+ 'generate': '/my/custom/generate',
225
+ 'translate-text': 'https://other-api.example.com/translate',
226
+ }
227
+ ```
228
+
229
+ ### Minimal proxy example (FastAPI)
230
+
231
+ ```python
232
+ import httpx
233
+ from fastapi import FastAPI
234
+ from fastapi.responses import StreamingResponse
235
+ from pydantic import BaseModel
236
+
237
+ app = FastAPI()
238
+ OMNIA_API = "https://omnia.example.be/api"
239
+
240
+ AGENTS = [
241
+ "expand-text", "improve-text", "reduce-text",
242
+ "correct-text", "make-accessible", "translate-text",
243
+ ]
244
+
245
+
246
+ # --- Streaming proxy for /generate ---
247
+
248
+ class GenerateRequest(BaseModel):
249
+ prompt: str
250
+ tone: str | None = None
251
+
252
+
253
+ @app.post("/omnia/generate")
254
+ async def generate(body: GenerateRequest):
255
+ async def stream():
256
+ async with httpx.AsyncClient() as client:
257
+ async with client.stream(
258
+ "POST", f"{OMNIA_API}/generate",
259
+ json=body.model_dump(exclude_none=True),
260
+ headers={"Content-Type": "application/json"},
261
+ ) as resp:
262
+ async for chunk in resp.aiter_bytes():
263
+ yield chunk
264
+
265
+ return StreamingResponse(stream(), media_type="text/event-stream")
266
+
267
+
268
+ # --- JSON proxy for agent endpoints ---
269
+
270
+ @app.post("/omnia/v1/agents/{agent}")
271
+ async def agent_proxy(agent: str, body: dict):
272
+ if agent not in AGENTS:
273
+ return {"error": "Unknown agent"}, 404
274
+ async with httpx.AsyncClient() as client:
275
+ resp = await client.post(
276
+ f"{OMNIA_API}/v1/agents/{agent}",
277
+ json=body,
278
+ headers={"Content-Type": "application/json"},
279
+ )
280
+ return resp.json()
281
+ ```
282
+
283
+ Then set `omnia_base_url: '/omnia'` in TinyMCE.
284
+
285
+ ## Development
286
+
287
+ ```bash
288
+ make install # npm install
289
+ make dev # Storybook on port 6006
290
+ make build # Build to dist/
291
+ ```
292
+
293
+ Copy `.env.example` to `.env` for the Storybook "Live API" story:
294
+
295
+ ```env
296
+ VITE_OMNIA_BASE_URL=https://omnia.example.be/api
297
+ VITE_OMNIA_APPLICATION=my-app
298
+ VITE_OMNIA_MUNICIPALITY=my-commune
299
+ ```
300
+
301
+ When `VITE_OMNIA_BASE_URL` is a full URL, Storybook automatically proxies requests to avoid CORS.
302
+
303
+ ### Available commands
304
+
305
+ | Command | Description |
306
+ |---------|-------------|
307
+ | `make install` | Install dependencies |
308
+ | `make dev` | Start Storybook dev server (port 6006) |
309
+ | `make dev-integration` | Start integration test page (port 5173) |
310
+ | `make build` | Build library to `dist/` (ES + UMD + CSS) |
311
+ | `make build-storybook` | Build static Storybook site |
312
+ | `make clean` | Remove `dist/` and `storybook-static/` |
313
+ | `make publish` | Build and publish to npm |
314
+
315
+ ## Build output
316
+
317
+ The library builds to `dist/` in two formats:
318
+
319
+ - `omnia-tinymce.js` -- ES module
320
+ - `omnia-tinymce.umd.cjs` -- UMD (global: `OmniaTinyMCE`)
321
+ - `omnia-tinymce.css` -- Scoped styles (Tailwind with `om:` prefix)
322
+
323
+ TinyMCE is **not** bundled -- it must be provided by the host application.
324
+
325
+ ## License
326
+
327
+ Proprietary -- (c) iMio
@@ -0,0 +1,41 @@
1
+ <!DOCTYPE html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Omnia TinyMCE — Integration Test</title>
7
+ <script src="https://cdn.tiny.cloud/1/no-api-key/tinymce/7/tinymce.min.js" referrerpolicy="origin"></script>
8
+ <style>
9
+ body { font-family: sans-serif; max-width: 900px; margin: 40px auto; padding: 0 20px; }
10
+ h1 { font-size: 1.3em; color: #333; }
11
+ .note { color: #888; font-size: 13px; margin-bottom: 16px; }
12
+ </style>
13
+ </head>
14
+ <body>
15
+ <h1>Omnia TinyMCE — Integration Test</h1>
16
+ <p class="note">
17
+ This page loads TinyMCE with the Omnia plugin. Select text and use the toolbar buttons or right-click.
18
+ The mock server at <code>/api/*</code> simulates SSE responses.
19
+ </p>
20
+ <textarea id="editor">
21
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
22
+ <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
23
+ <p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
24
+ </textarea>
25
+
26
+ <script type="module">
27
+ // Import the plugin — registers itself as side-effect
28
+ import '../src/plugin.js';
29
+
30
+ tinymce.init({
31
+ selector: '#editor',
32
+ plugins: 'omnia',
33
+ license_key: 'gpl',
34
+ toolbar: 'undo redo | omnia-generate omnia-rewrite omnia-translate omnia-summarize',
35
+ contextmenu: 'omnia',
36
+ height: 400,
37
+ omnia_base_url: '/api',
38
+ });
39
+ </script>
40
+ </body>
41
+ </html>
@@ -0,0 +1,78 @@
1
+ import { defineConfig } from 'vite';
2
+ import preact from '@preact/preset-vite';
3
+
4
+ /**
5
+ * Vite config for the integration test page.
6
+ * Includes a mock SSE API server via middleware.
7
+ */
8
+ export default defineConfig({
9
+ plugins: [
10
+ preact(),
11
+ mockApiPlugin(),
12
+ ],
13
+ root: '.',
14
+ });
15
+
16
+ function mockApiPlugin() {
17
+ return {
18
+ name: 'omnia-mock-api',
19
+ configureServer(server) {
20
+ // Shared SSE response helper
21
+ function sendSSE(res, text, delay = 40) {
22
+ res.writeHead(200, {
23
+ 'Content-Type': 'text/event-stream',
24
+ 'Cache-Control': 'no-cache',
25
+ Connection: 'keep-alive',
26
+ });
27
+
28
+ const words = text.split(' ');
29
+ let i = 0;
30
+
31
+ const interval = setInterval(() => {
32
+ if (i >= words.length) {
33
+ res.write('data: [DONE]\n\n');
34
+ res.end();
35
+ clearInterval(interval);
36
+ return;
37
+ }
38
+ const chunk = (i > 0 ? ' ' : '') + words[i];
39
+ res.write(`data: ${JSON.stringify({ chunk })}\n\n`);
40
+ i++;
41
+ }, delay);
42
+
43
+ // Handle client disconnect
44
+ res.on('close', () => clearInterval(interval));
45
+ }
46
+
47
+ function readBody(req) {
48
+ return new Promise((resolve) => {
49
+ let body = '';
50
+ req.on('data', (chunk) => (body += chunk));
51
+ req.on('end', () => {
52
+ try { resolve(JSON.parse(body)); }
53
+ catch { resolve({}); }
54
+ });
55
+ });
56
+ }
57
+
58
+ server.middlewares.use('/api/generate', async (req, res) => {
59
+ const body = await readBody(req);
60
+ sendSSE(res, `Voici le contenu généré pour : "${body.prompt || ''}". Ce texte a été produit par le serveur mock Omnia.`);
61
+ });
62
+
63
+ server.middlewares.use('/api/rewrite', async (req, res) => {
64
+ const body = await readBody(req);
65
+ sendSSE(res, `Texte réécrit selon l'instruction "${body.instruction || ''}": ${body.text || ''}`);
66
+ });
67
+
68
+ server.middlewares.use('/api/translate', async (req, res) => {
69
+ const body = await readBody(req);
70
+ sendSSE(res, `[Translated to ${body.target_lang || 'fr'}] ${body.text || ''}`);
71
+ });
72
+
73
+ server.middlewares.use('/api/summarize', async (req, res) => {
74
+ sendSSE(res, 'Résumé : ce texte traite de sujets variés et importants pour le contexte.');
75
+ });
76
+ },
77
+ };
78
+ }
@@ -0,0 +1,36 @@
1
+ import js from '@eslint/js';
2
+ import globals from 'globals';
3
+
4
+ export default [
5
+ js.configs.recommended,
6
+ {
7
+ files: ['src/**/*.{js,jsx}', 'stories/**/*.js', 'dev/**/*.js'],
8
+ languageOptions: {
9
+ ecmaVersion: 'latest',
10
+ sourceType: 'module',
11
+ globals: {
12
+ ...globals.browser,
13
+ },
14
+ parserOptions: {
15
+ ecmaFeatures: { jsx: true },
16
+ },
17
+ },
18
+ rules: {
19
+ 'no-unused-vars': ['warn', { argsIgnorePattern: '^_', varsIgnorePattern: '^_' }],
20
+ 'no-console': ['warn', { allow: ['warn', 'error'] }],
21
+ },
22
+ },
23
+ {
24
+ files: ['vite.config.js', 'dev/vite.config.js', 'eslint.config.js', '.storybook/**/*.js'],
25
+ languageOptions: {
26
+ ecmaVersion: 'latest',
27
+ sourceType: 'module',
28
+ globals: {
29
+ ...globals.node,
30
+ },
31
+ },
32
+ },
33
+ {
34
+ ignores: ['dist/', 'storybook-static/', 'node_modules/'],
35
+ },
36
+ ];