Commit f3c8702
committed
refactor: use core's chatPrefillFromUser hook instead of own click handler
PR #19 originally landed an entire user-list click handler inside
ep_ai_chat. That logic was generic — clicking a user in the user
list to prefill an @-mention is a discoverability win for any
multi-user pad, AI or no AI — and as @JohnMcLear pointed out, it
belongs in Etherpad core, not in this plugin.
The generic feature is now ether/etherpad#7660. This commit shrinks
ep_ai_chat's contribution to the only AI-specific bit: when the
clicked author is the AI, override the default "@AI_Assistant "
prefill with the configured trigger ("@ai " by default) so the
input lands in a useful state.
Implementation:
- Drop the in-plugin click delegation, the chatbox/chaticon DOM
poking, and the input-prefill logic. Core handles all of that
uniformly now.
- Add a chatPrefillFromUser client hook that returns the trigger
string when the clicked authorId matches the AI's. The clientVars
hook (added earlier in this PR) still exposes the trigger and
authorId; nothing changes there.
- On older cores the new hook is never fired, so this is a no-op
on a stock install — graceful degradation.
Net diff vs main is now: a tiny clientVars exposure on the server
and a ~10-line client hook handler. Everything else is core's job.1 parent 2382056 commit f3c8702
2 files changed
Lines changed: 18 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
| 12 | + | |
15 | 13 | | |
16 | 14 | | |
17 | 15 | | |
18 | | - | |
19 | 16 | | |
20 | 17 | | |
21 | 18 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
26 | 24 | | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
35 | 28 | | |
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 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
80 | 34 | | |
81 | | - | |
82 | | - | |
83 | | - | |
| 35 | + | |
| 36 | + | |
84 | 37 | | |
85 | 38 | | |
86 | 39 | | |
| |||
0 commit comments