@erdemtuna/doc-review 0.7.0 → 0.8.1
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.
- package/README.md +58 -5
- package/package.json +3 -2
- package/src/SKILL.md +54 -7
- package/src/anchor-text.js +45 -0
- package/src/atomic-write.js +53 -0
- package/src/chrome-client.js +1272 -252
- package/src/chrome-session.js +70 -0
- package/src/chrome.css +278 -329
- package/src/chrome.html +81 -35
- package/src/cli.js +58 -132
- package/src/comment-anchor.js +22 -0
- package/src/comment-target.js +77 -0
- package/src/edit-limits.js +23 -0
- package/src/icons.js +251 -0
- package/src/paths.js +5 -1
- package/src/poll-transport.js +222 -0
- package/src/positioning.js +107 -0
- package/src/review-mode.js +59 -0
- package/src/sdk.js +792 -69
- package/src/serialize.js +0 -14
- package/src/server.js +39 -9
- package/src/setup-guidance.js +128 -0
- package/src/setup.js +41 -15
- package/src/state.js +37 -21
package/src/chrome-session.js
CHANGED
|
@@ -13,3 +13,73 @@ export function newestComments(comments) {
|
|
|
13
13
|
(a, b) => (b.updatedAt || b.createdAt || 0) - (a.updatedAt || a.createdAt || 0)
|
|
14
14
|
);
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
export function modePresentation(mode) {
|
|
18
|
+
return mode === "edit"
|
|
19
|
+
? { label: "Edit", icon: "pencil", description: "Direct editing on" }
|
|
20
|
+
: { label: "View", icon: "eye", description: "Editing off, comments enabled" };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createCommentUi() {
|
|
24
|
+
return { menu: null, confirmation: null, edit: null };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function ownMenu(ui, commentId, surface, triggerId) {
|
|
28
|
+
if (ui.edit) return false;
|
|
29
|
+
ui.menu = { commentId, surface, triggerId };
|
|
30
|
+
ui.confirmation = null;
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function ownConfirmation(ui, commentId, surface) {
|
|
35
|
+
if (ui.edit) return false;
|
|
36
|
+
ui.menu = null;
|
|
37
|
+
ui.confirmation = { commentId, surface, status: "idle" };
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function ownEdit(ui, comment, surface) {
|
|
42
|
+
if (ui.edit) return ui.edit.commentId === comment.id;
|
|
43
|
+
ui.menu = null;
|
|
44
|
+
ui.confirmation = null;
|
|
45
|
+
ui.edit = {
|
|
46
|
+
commentId: comment.id,
|
|
47
|
+
draft: comment.feedback,
|
|
48
|
+
original: comment.feedback,
|
|
49
|
+
originSurface: surface,
|
|
50
|
+
status: "idle",
|
|
51
|
+
selectionStart: comment.feedback.length,
|
|
52
|
+
selectionEnd: comment.feedback.length,
|
|
53
|
+
composing: false,
|
|
54
|
+
validation: "",
|
|
55
|
+
};
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function clearOwned(ui, kind) {
|
|
60
|
+
ui[kind] = null;
|
|
61
|
+
return ui;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function migrateCommentUi(ui, fromId, toId) {
|
|
65
|
+
for (const key of ["menu", "confirmation", "edit"]) {
|
|
66
|
+
if (ui[key]?.commentId === fromId) ui[key].commentId = toId;
|
|
67
|
+
}
|
|
68
|
+
return ui;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function reconcileCommentUi(ui, comments) {
|
|
72
|
+
const ids = new Set((comments || []).map((comment) => comment.id));
|
|
73
|
+
const removed = new Set();
|
|
74
|
+
for (const key of ["menu", "confirmation", "edit"]) {
|
|
75
|
+
if (ui[key] && !ids.has(ui[key].commentId)) {
|
|
76
|
+
removed.add(ui[key].commentId);
|
|
77
|
+
ui[key] = null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return removed;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function mutationIsCurrent(startEpoch, currentEpoch, comments, commentId) {
|
|
84
|
+
return startEpoch === currentEpoch && (comments || []).some((comment) => comment.id === commentId);
|
|
85
|
+
}
|