@mrsf/markdown-it-mrsf 0.1.0 → 0.3.0
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 +14 -4
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +366 -35
- package/dist/browser.js.map +7 -0
- package/dist/controller.d.ts +31 -11
- package/dist/controller.js +320 -38
- package/dist/controller.js.map +7 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +392 -75
- package/dist/index.js.map +7 -0
- package/dist/shared.d.ts +2 -16
- package/dist/style.css +85 -0
- package/dist/types.d.ts +6 -2
- package/package.json +14 -7
- package/dist/rules/core.js +0 -149
- package/dist/rules/renderer.js +0 -159
- package/dist/shared.js +0 -86
- package/dist/types.js +0 -5
package/README.md
CHANGED
|
@@ -112,7 +112,12 @@ Customise with CSS custom properties:
|
|
|
112
112
|
|
|
113
113
|
## Interactive Mode
|
|
114
114
|
|
|
115
|
-
Enable `interactive: true` to add action buttons (Resolve, Reply, Edit) inside tooltips
|
|
115
|
+
Enable `interactive: true` to add action buttons (Resolve, Reply, Edit) inside tooltips, plus:
|
|
116
|
+
|
|
117
|
+
- Gutter “Add comment” buttons for each line badge
|
|
118
|
+
- An inline “Add comment” floater that appears when users select text
|
|
119
|
+
|
|
120
|
+
Buttons render as `<button data-mrsf-action="..." data-mrsf-comment-id="...">` elements — inert without JavaScript.
|
|
116
121
|
|
|
117
122
|
```ts
|
|
118
123
|
md.use(mrsfPlugin, {
|
|
@@ -135,11 +140,15 @@ document.addEventListener("mrsf:resolve", (e) => {
|
|
|
135
140
|
document.addEventListener("mrsf:reply", (e) => {
|
|
136
141
|
console.log("Reply to:", e.detail.commentId);
|
|
137
142
|
});
|
|
143
|
+
|
|
144
|
+
document.addEventListener("mrsf:add", (e) => {
|
|
145
|
+
console.log("Add on line", e.detail.line, "selection", e.detail.selectionText);
|
|
146
|
+
});
|
|
138
147
|
```
|
|
139
148
|
|
|
140
|
-
Events dispatched: `mrsf:resolve`, `mrsf:unresolve`, `mrsf:reply`, `mrsf:edit`, `mrsf:navigate`.
|
|
149
|
+
Events dispatched: `mrsf:add`, `mrsf:resolve`, `mrsf:unresolve`, `mrsf:reply`, `mrsf:edit`, `mrsf:navigate`.
|
|
141
150
|
|
|
142
|
-
Each event's `detail` contains `{ commentId: string, line: number | null, action: string }
|
|
151
|
+
Each event's `detail` contains `{ commentId: string | null, line: number | null, action: string, selectionText?: string | null, start_line?: number | null, end_line?: number | null, start_column?: number | null, end_column?: number | null }` (snake_case to align with the CLI SDK parameters).
|
|
143
152
|
|
|
144
153
|
## Options
|
|
145
154
|
|
|
@@ -171,7 +180,8 @@ All rendered elements follow a strict data-attribute contract:
|
|
|
171
180
|
|
|
172
181
|
- `data-mrsf-line` — source line number (1-based)
|
|
173
182
|
- `data-mrsf-comment-id` — comment identifier
|
|
174
|
-
- `data-mrsf-action` — action type (`resolve`, `unresolve`, `reply`, `edit`, `navigate`)
|
|
183
|
+
- `data-mrsf-action` — action type (`add`, `resolve`, `unresolve`, `reply`, `edit`, `navigate`)
|
|
184
|
+
- `data-mrsf-start-line`, `data-mrsf-end-line`, `data-mrsf-start-column`, `data-mrsf-end-column` — optional selection anchors when present
|
|
175
185
|
|
|
176
186
|
## License
|
|
177
187
|
|
package/dist/browser.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* a browser environment.
|
|
13
13
|
*/
|
|
14
14
|
import type { MrsfPluginOptions } from "./types.js";
|
|
15
|
-
export type { MrsfPluginOptions, SlimComment, CommentThread, LineMap } from "./types.js";
|
|
15
|
+
export type { MrsfPluginOptions, SlimComment, CommentThread, LineMap, CommentLoader } from "./types.js";
|
|
16
16
|
/**
|
|
17
17
|
* The markdown-it plugin function (browser-safe).
|
|
18
18
|
*
|
package/dist/browser.js
CHANGED
|
@@ -1,39 +1,370 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
1
|
+
// ../shared/dist/comments.js
|
|
2
|
+
function toSlimComments(doc) {
|
|
3
|
+
return doc.comments.map((c) => ({
|
|
4
|
+
id: c.id,
|
|
5
|
+
author: c.author || "Unknown",
|
|
6
|
+
text: c.text || "",
|
|
7
|
+
line: c.line ?? null,
|
|
8
|
+
end_line: c.end_line ?? null,
|
|
9
|
+
start_column: c.start_column ?? null,
|
|
10
|
+
end_column: c.end_column ?? null,
|
|
11
|
+
selected_text: c.selected_text || null,
|
|
12
|
+
resolved: !!c.resolved,
|
|
13
|
+
reply_to: c.reply_to || null,
|
|
14
|
+
severity: c.severity || null,
|
|
15
|
+
type: c.type || null,
|
|
16
|
+
timestamp: c.timestamp || null
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
function groupByLine(comments) {
|
|
20
|
+
const rootComments = comments.filter((c) => !c.reply_to && c.line != null);
|
|
21
|
+
const replies = comments.filter((c) => c.reply_to);
|
|
22
|
+
const replyMap = /* @__PURE__ */ new Map();
|
|
23
|
+
for (const r of replies) {
|
|
24
|
+
const list = replyMap.get(r.reply_to) || [];
|
|
25
|
+
list.push(r);
|
|
26
|
+
replyMap.set(r.reply_to, list);
|
|
27
|
+
}
|
|
28
|
+
const lineMap = /* @__PURE__ */ new Map();
|
|
29
|
+
for (const c of rootComments) {
|
|
30
|
+
const line = c.line;
|
|
31
|
+
const threads = lineMap.get(line) || [];
|
|
32
|
+
threads.push({
|
|
33
|
+
comment: c,
|
|
34
|
+
replies: replyMap.get(c.id) || []
|
|
35
|
+
});
|
|
36
|
+
lineMap.set(line, threads);
|
|
37
|
+
}
|
|
38
|
+
return lineMap;
|
|
39
|
+
}
|
|
40
|
+
function resolveComments(loader, options) {
|
|
41
|
+
const showResolved = options.showResolved ?? true;
|
|
42
|
+
const doc = loader(options);
|
|
43
|
+
if (!doc || !doc.comments || doc.comments.length === 0) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
let comments = toSlimComments(doc);
|
|
47
|
+
if (!showResolved) {
|
|
48
|
+
comments = comments.filter((c) => !c.resolved);
|
|
49
|
+
}
|
|
50
|
+
if (comments.length === 0)
|
|
51
|
+
return null;
|
|
52
|
+
const lineMap = groupByLine(comments);
|
|
53
|
+
return { lineMap, comments };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ../shared/dist/html.js
|
|
57
|
+
function escapeHtml(str) {
|
|
58
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
59
|
+
}
|
|
60
|
+
function formatTime(iso) {
|
|
61
|
+
if (!iso)
|
|
62
|
+
return "";
|
|
63
|
+
try {
|
|
64
|
+
const d = new Date(iso);
|
|
65
|
+
return d.toLocaleDateString(void 0, {
|
|
66
|
+
year: "numeric",
|
|
67
|
+
month: "short",
|
|
68
|
+
day: "numeric"
|
|
69
|
+
});
|
|
70
|
+
} catch {
|
|
71
|
+
return "";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function renderCommentHtml(comment, isReply, interactive) {
|
|
75
|
+
const resolvedClass = comment.resolved ? " mrsf-resolved" : "";
|
|
76
|
+
const replyClass = isReply ? " mrsf-reply" : "";
|
|
77
|
+
let html = `<span class="mrsf-comment${resolvedClass}${replyClass}" data-mrsf-comment-id="${escapeHtml(comment.id)}">`;
|
|
78
|
+
html += `<span class="mrsf-comment-header">`;
|
|
79
|
+
html += `<span class="mrsf-author">${escapeHtml(comment.author)}</span>`;
|
|
80
|
+
if (comment.timestamp) {
|
|
81
|
+
html += `<span class="mrsf-date">${escapeHtml(formatTime(comment.timestamp))}</span>`;
|
|
82
|
+
}
|
|
83
|
+
if (comment.severity) {
|
|
84
|
+
html += `<span class="mrsf-severity mrsf-severity-${escapeHtml(comment.severity)}">${escapeHtml(comment.severity)}</span>`;
|
|
85
|
+
}
|
|
86
|
+
if (comment.type) {
|
|
87
|
+
html += `<span class="mrsf-type">${escapeHtml(comment.type)}</span>`;
|
|
88
|
+
}
|
|
89
|
+
if (comment.resolved) {
|
|
90
|
+
html += `<span class="mrsf-resolved-badge">\u2713 resolved</span>`;
|
|
91
|
+
}
|
|
92
|
+
html += `</span>`;
|
|
93
|
+
if (comment.selected_text) {
|
|
94
|
+
html += `<span class="mrsf-selected-text">${escapeHtml(comment.selected_text)}</span>`;
|
|
95
|
+
}
|
|
96
|
+
html += `<span class="mrsf-comment-body">${escapeHtml(comment.text)}</span>`;
|
|
97
|
+
if (interactive) {
|
|
98
|
+
const line = comment.line != null ? String(comment.line) : "";
|
|
99
|
+
html += `<span class="mrsf-actions">`;
|
|
100
|
+
if (comment.resolved) {
|
|
101
|
+
html += `<button class="mrsf-action-btn" data-mrsf-action="unresolve" data-mrsf-comment-id="${escapeHtml(comment.id)}" data-mrsf-line="${line}">Unresolve</button>`;
|
|
102
|
+
} else {
|
|
103
|
+
html += `<button class="mrsf-action-btn" data-mrsf-action="resolve" data-mrsf-comment-id="${escapeHtml(comment.id)}" data-mrsf-line="${line}">Resolve</button>`;
|
|
104
|
+
}
|
|
105
|
+
html += `<button class="mrsf-action-btn" data-mrsf-action="reply" data-mrsf-comment-id="${escapeHtml(comment.id)}" data-mrsf-line="${line}">Reply</button>`;
|
|
106
|
+
html += `<button class="mrsf-action-btn" data-mrsf-action="edit" data-mrsf-comment-id="${escapeHtml(comment.id)}" data-mrsf-line="${line}">Edit</button>`;
|
|
107
|
+
html += `</span>`;
|
|
108
|
+
}
|
|
109
|
+
html += `</span>`;
|
|
110
|
+
return html;
|
|
111
|
+
}
|
|
112
|
+
function renderThreadHtml(thread, interactive) {
|
|
113
|
+
let html = `<span class="mrsf-thread">`;
|
|
114
|
+
html += renderCommentHtml(thread.comment, false, interactive);
|
|
115
|
+
if (thread.replies.length > 0) {
|
|
116
|
+
html += `<span class="mrsf-replies">`;
|
|
117
|
+
for (const reply of thread.replies) {
|
|
118
|
+
html += renderCommentHtml(reply, true, interactive);
|
|
119
|
+
}
|
|
120
|
+
html += `</span>`;
|
|
121
|
+
}
|
|
122
|
+
html += `</span>`;
|
|
123
|
+
return html;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// src/rules/core.ts
|
|
127
|
+
function highlightInlineText(token, thread, interactive, Token) {
|
|
128
|
+
if (!token.children) return false;
|
|
129
|
+
const text = thread.comment.selected_text;
|
|
130
|
+
if (!text) return false;
|
|
131
|
+
const trimmed = text.trim();
|
|
132
|
+
if (!trimmed) return false;
|
|
133
|
+
for (let i = 0; i < token.children.length; i++) {
|
|
134
|
+
const child = token.children[i];
|
|
135
|
+
if (child.type !== "text") continue;
|
|
136
|
+
const idx = child.content.indexOf(trimmed);
|
|
137
|
+
if (idx === -1) continue;
|
|
138
|
+
const newTokens = [];
|
|
139
|
+
if (idx > 0) {
|
|
140
|
+
const before = new Token("text", "", 0);
|
|
141
|
+
before.content = child.content.slice(0, idx);
|
|
142
|
+
newTokens.push(before);
|
|
143
|
+
}
|
|
144
|
+
const open = new Token("mrsf_highlight_open", "mark", 1);
|
|
145
|
+
open.attrSet("class", "mrsf-highlight");
|
|
146
|
+
open.attrSet("data-mrsf-comment-id", thread.comment.id);
|
|
147
|
+
open.meta = { thread };
|
|
148
|
+
newTokens.push(open);
|
|
149
|
+
const matched = new Token("text", "", 0);
|
|
150
|
+
matched.content = trimmed;
|
|
151
|
+
newTokens.push(matched);
|
|
152
|
+
const close = new Token("mrsf_highlight_close", "mark", -1);
|
|
153
|
+
close.meta = { thread, interactive };
|
|
154
|
+
newTokens.push(close);
|
|
155
|
+
if (idx + trimmed.length < child.content.length) {
|
|
156
|
+
const after = new Token("text", "", 0);
|
|
157
|
+
after.content = child.content.slice(idx + trimmed.length);
|
|
158
|
+
newTokens.push(after);
|
|
159
|
+
}
|
|
160
|
+
token.children.splice(i, 1, ...newTokens);
|
|
161
|
+
return true;
|
|
162
|
+
}
|
|
163
|
+
return false;
|
|
164
|
+
}
|
|
165
|
+
function installCoreRule(md, lineMap, options) {
|
|
166
|
+
const { interactive, gutterPosition, gutterForInline, inlineHighlights } = options;
|
|
167
|
+
md.core.ruler.push("mrsf_inject", (state) => {
|
|
168
|
+
const tokens = state.tokens;
|
|
169
|
+
const TokenCtor = state.Token;
|
|
170
|
+
const processed = /* @__PURE__ */ new Set();
|
|
171
|
+
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
172
|
+
const token = tokens[i];
|
|
173
|
+
const map = token.map;
|
|
174
|
+
if (!map) continue;
|
|
175
|
+
if (token.type === "inline") continue;
|
|
176
|
+
const startLine1 = map[0] + 1;
|
|
177
|
+
const endLine1 = map[1];
|
|
178
|
+
token.attrSet("data-mrsf-line", String(startLine1));
|
|
179
|
+
token.attrSet("data-mrsf-start-line", String(startLine1));
|
|
180
|
+
token.attrSet("data-mrsf-end-line", String(endLine1));
|
|
181
|
+
if (interactive) {
|
|
182
|
+
const existingClass = token.attrGet("class") || "";
|
|
183
|
+
token.attrSet(
|
|
184
|
+
"class",
|
|
185
|
+
existingClass ? `${existingClass} mrsf-line-hover-target` : "mrsf-line-hover-target"
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
for (let line0 = map[0]; line0 < map[1]; line0++) {
|
|
189
|
+
const line = line0 + 1;
|
|
190
|
+
if (processed.has(line)) continue;
|
|
191
|
+
const threads = lineMap.get(line) || [];
|
|
192
|
+
const hasThreads = threads.length > 0;
|
|
193
|
+
processed.add(line);
|
|
194
|
+
if (hasThreads) {
|
|
195
|
+
const existingClass = token.attrGet("class") || "";
|
|
196
|
+
token.attrSet(
|
|
197
|
+
"class",
|
|
198
|
+
existingClass ? `${existingClass} mrsf-line-highlight` : "mrsf-line-highlight"
|
|
199
|
+
);
|
|
200
|
+
token.attrSet("data-mrsf-line", String(line));
|
|
201
|
+
const allHaveInline = inlineHighlights && threads.every((t) => !!t.comment.selected_text);
|
|
202
|
+
const showBadge = gutterForInline || !allHaveInline || !inlineHighlights;
|
|
203
|
+
if (showBadge) {
|
|
204
|
+
const badgeToken = new TokenCtor("mrsf_badge", "", 0);
|
|
205
|
+
badgeToken.meta = { line, threads, interactive, gutterPosition };
|
|
206
|
+
tokens.splice(i + 1, 0, badgeToken);
|
|
207
|
+
}
|
|
208
|
+
if (inlineHighlights) {
|
|
209
|
+
const offset = showBadge ? 2 : 1;
|
|
210
|
+
const inlineAfter = tokens[i + offset];
|
|
211
|
+
if (inlineAfter && inlineAfter.type === "inline") {
|
|
212
|
+
for (const thread of threads) {
|
|
213
|
+
if (thread.comment.selected_text) {
|
|
214
|
+
highlightInlineText(inlineAfter, thread, interactive, TokenCtor);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
} else if (interactive) {
|
|
220
|
+
const addToken = new TokenCtor("mrsf_gutter_add", "", 0);
|
|
221
|
+
addToken.meta = { line, gutterPosition };
|
|
222
|
+
tokens.splice(i + 1, 0, addToken);
|
|
30
223
|
}
|
|
224
|
+
}
|
|
31
225
|
}
|
|
32
|
-
if (
|
|
33
|
-
|
|
34
|
-
|
|
226
|
+
if (gutterPosition === "left" && processed.size > 0) {
|
|
227
|
+
const openToken = new TokenCtor("mrsf_gutter_open", "div", 1);
|
|
228
|
+
openToken.attrSet("class", "mrsf-gutter-container");
|
|
229
|
+
tokens.unshift(openToken);
|
|
230
|
+
const closeToken = new TokenCtor("mrsf_gutter_close", "div", -1);
|
|
231
|
+
tokens.push(closeToken);
|
|
35
232
|
}
|
|
36
|
-
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/rules/renderer.ts
|
|
237
|
+
function installRendererRules(md) {
|
|
238
|
+
md.renderer.rules["mrsf_badge"] = (tokens, idx) => {
|
|
239
|
+
const { line, threads, interactive, gutterPosition } = tokens[idx].meta;
|
|
240
|
+
const total = threads.reduce(
|
|
241
|
+
(n, t) => n + 1 + t.replies.length,
|
|
242
|
+
0
|
|
243
|
+
);
|
|
244
|
+
const allResolved = threads.every((t) => t.comment.resolved);
|
|
245
|
+
const highestSeverity = threads.reduce((sev, t) => {
|
|
246
|
+
if (t.comment.severity === "high" || sev === "high") return "high";
|
|
247
|
+
if (t.comment.severity === "medium" || sev === "medium") return "medium";
|
|
248
|
+
if (t.comment.severity === "low" || sev === "low") return "low";
|
|
249
|
+
return sev;
|
|
250
|
+
}, null);
|
|
251
|
+
const resolvedClass = allResolved ? " mrsf-badge-resolved" : "";
|
|
252
|
+
const severityClass = highestSeverity === "high" || highestSeverity === "medium" ? ` mrsf-badge-severity-${highestSeverity}` : "";
|
|
253
|
+
const positionClass = ` mrsf-gutter-${gutterPosition}`;
|
|
254
|
+
const icon = allResolved ? "\u2713" : "\u{1F4AC}";
|
|
255
|
+
let html = `<span class="mrsf-tooltip-anchor${positionClass}">`;
|
|
256
|
+
html += `<span class="mrsf-badge${resolvedClass}${severityClass}" data-mrsf-line="${line}" data-mrsf-action="navigate" data-mrsf-comment-id="${escapeHtml(threads[0].comment.id)}" tabindex="0">${icon} ${total}</span>`;
|
|
257
|
+
if (interactive) {
|
|
258
|
+
html += `<button class="mrsf-gutter-add" data-mrsf-action="add" data-mrsf-line="${line}" data-mrsf-start-line="${line}" data-mrsf-end-line="${line}" aria-label="Add comment">+</button>`;
|
|
259
|
+
}
|
|
260
|
+
const tooltipClass = interactive ? "mrsf-tooltip mrsf-interactive" : "mrsf-tooltip";
|
|
261
|
+
html += `<span class="${tooltipClass}" data-mrsf-line="${line}">`;
|
|
262
|
+
for (const thread of threads) {
|
|
263
|
+
html += renderThreadHtml(thread, interactive);
|
|
264
|
+
}
|
|
265
|
+
if (interactive) {
|
|
266
|
+
html += `<span class="mrsf-tooltip-actions"><button class="mrsf-action-btn" data-mrsf-action="add" data-mrsf-line="${line}">Add comment</button></span>`;
|
|
267
|
+
}
|
|
268
|
+
html += `</span>`;
|
|
269
|
+
html += `</span>`;
|
|
270
|
+
return html;
|
|
271
|
+
};
|
|
272
|
+
md.renderer.rules["mrsf_gutter_add"] = (tokens, idx) => {
|
|
273
|
+
const { line, gutterPosition } = tokens[idx].meta;
|
|
274
|
+
const positionClass = ` mrsf-gutter-${gutterPosition}`;
|
|
275
|
+
let html = `<span class="mrsf-tooltip-anchor mrsf-gutter-add-only${positionClass}">`;
|
|
276
|
+
html += `<button class="mrsf-gutter-add" data-mrsf-action="add" data-mrsf-line="${line}" data-mrsf-start-line="${line}" data-mrsf-end-line="${line}" aria-label="Add comment">+</button>`;
|
|
277
|
+
html += `</span>`;
|
|
278
|
+
return html;
|
|
279
|
+
};
|
|
280
|
+
md.renderer.rules["mrsf_highlight_open"] = (tokens, idx) => {
|
|
281
|
+
const token = tokens[idx];
|
|
282
|
+
const cls = token.attrGet("class") || "mrsf-highlight";
|
|
283
|
+
const commentId = token.attrGet("data-mrsf-comment-id") || "";
|
|
284
|
+
const thread = token.meta?.thread;
|
|
285
|
+
const line = thread?.comment.line ?? null;
|
|
286
|
+
const endLine = thread?.comment.end_line ?? line ?? null;
|
|
287
|
+
const startCol = thread?.comment.start_column ?? null;
|
|
288
|
+
const endCol = thread?.comment.end_column ?? null;
|
|
289
|
+
let html = "";
|
|
290
|
+
if (thread) {
|
|
291
|
+
const dataAttrs = [
|
|
292
|
+
line != null ? `data-mrsf-line="${line}"` : "",
|
|
293
|
+
line != null ? `data-mrsf-start-line="${line}"` : "",
|
|
294
|
+
endLine != null ? `data-mrsf-end-line="${endLine}"` : "",
|
|
295
|
+
startCol != null ? `data-mrsf-start-column="${startCol}"` : "",
|
|
296
|
+
endCol != null ? `data-mrsf-end-column="${endCol}"` : ""
|
|
297
|
+
].filter(Boolean).join(" ");
|
|
298
|
+
html += `<span class="mrsf-tooltip-anchor mrsf-inline-anchor" ${dataAttrs}>`;
|
|
299
|
+
}
|
|
300
|
+
html += `<mark class="${escapeHtml(cls)}" data-mrsf-comment-id="${escapeHtml(commentId)}" tabindex="0">`;
|
|
301
|
+
return html;
|
|
302
|
+
};
|
|
303
|
+
md.renderer.rules["mrsf_highlight_close"] = (tokens, idx) => {
|
|
304
|
+
const token = tokens[idx];
|
|
305
|
+
const meta = token.meta;
|
|
306
|
+
let html = "</mark>";
|
|
307
|
+
if (meta?.thread) {
|
|
308
|
+
const thread = meta.thread;
|
|
309
|
+
const interactive = meta.interactive;
|
|
310
|
+
const tooltipClass = interactive ? "mrsf-tooltip mrsf-inline-tooltip mrsf-interactive" : "mrsf-tooltip mrsf-inline-tooltip";
|
|
311
|
+
html += `<span class="${tooltipClass}">`;
|
|
312
|
+
html += renderThreadHtml(thread, interactive);
|
|
313
|
+
html += `</span>`;
|
|
314
|
+
html += `</span>`;
|
|
315
|
+
}
|
|
316
|
+
return html;
|
|
317
|
+
};
|
|
318
|
+
md.renderer.rules["mrsf_gutter_open"] = (tokens, idx) => {
|
|
319
|
+
const cls = tokens[idx].attrGet("class") || "mrsf-gutter-container";
|
|
320
|
+
return `<div class="${escapeHtml(cls)}">`;
|
|
321
|
+
};
|
|
322
|
+
md.renderer.rules["mrsf_gutter_close"] = () => {
|
|
323
|
+
return `</div>`;
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/shared.ts
|
|
328
|
+
function createMrsfPlugin(loader) {
|
|
329
|
+
return function mrsfPlugin2(md, options = {}) {
|
|
330
|
+
const interactive = options.interactive ?? false;
|
|
331
|
+
const gutterPosition = options.gutterPosition ?? "right";
|
|
332
|
+
const gutterForInline = options.gutterForInline ?? true;
|
|
333
|
+
const inlineHighlights = options.inlineHighlights ?? true;
|
|
334
|
+
const result = resolveComments(loader, options);
|
|
335
|
+
if (!result) return;
|
|
336
|
+
installCoreRule(md, result.lineMap, {
|
|
337
|
+
interactive,
|
|
338
|
+
gutterPosition,
|
|
339
|
+
gutterForInline,
|
|
340
|
+
inlineHighlights
|
|
341
|
+
});
|
|
342
|
+
installRendererRules(md);
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
// src/browser.ts
|
|
347
|
+
var mrsfPlugin = createMrsfPlugin((options) => {
|
|
348
|
+
if (options.comments) {
|
|
349
|
+
return options.comments;
|
|
350
|
+
}
|
|
351
|
+
if (options.loader) {
|
|
352
|
+
try {
|
|
353
|
+
return options.loader();
|
|
354
|
+
} catch {
|
|
355
|
+
return null;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
if (options.sidecarPath || options.documentPath) {
|
|
359
|
+
console.warn(
|
|
360
|
+
"[@mrsf/markdown-it-mrsf] sidecarPath and documentPath require Node.js. Use `comments` or `loader` options in browser environments."
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
return null;
|
|
37
364
|
});
|
|
38
|
-
|
|
39
|
-
|
|
365
|
+
var browser_default = mrsfPlugin;
|
|
366
|
+
export {
|
|
367
|
+
browser_default as default,
|
|
368
|
+
mrsfPlugin
|
|
369
|
+
};
|
|
370
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../shared/src/comments.ts", "../../shared/src/html.ts", "../src/rules/core.ts", "../src/rules/renderer.ts", "../src/shared.ts", "../src/browser.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Shared comment loading and grouping logic for MRSF rendering plugins.\n */\n\nimport type { MrsfDocument } from \"@mrsf/cli\";\nimport type { MrsfPluginOptions, SlimComment, CommentThread, LineMap, CommentLoader } from \"./types.js\";\n\nexport type { CommentLoader };\n\n/**\n * Convert an MrsfDocument into a slim comment array.\n */\nexport function toSlimComments(doc: MrsfDocument): SlimComment[] {\n return doc.comments.map((c) => ({\n id: c.id,\n author: c.author || \"Unknown\",\n text: c.text || \"\",\n line: c.line ?? null,\n end_line: c.end_line ?? null,\n start_column: c.start_column ?? null,\n end_column: c.end_column ?? null,\n selected_text: c.selected_text || null,\n resolved: !!c.resolved,\n reply_to: c.reply_to || null,\n severity: c.severity || null,\n type: c.type || null,\n timestamp: c.timestamp || null,\n }));\n}\n\n/**\n * Group comments by line number, threading replies under parents.\n */\nexport function groupByLine(comments: SlimComment[]): LineMap {\n const rootComments = comments.filter((c) => !c.reply_to && c.line != null);\n const replies = comments.filter((c) => c.reply_to);\n\n const replyMap = new Map<string, SlimComment[]>();\n for (const r of replies) {\n const list = replyMap.get(r.reply_to!) || [];\n list.push(r);\n replyMap.set(r.reply_to!, list);\n }\n\n const lineMap: LineMap = new Map();\n for (const c of rootComments) {\n const line = c.line!;\n const threads = lineMap.get(line) || [];\n threads.push({\n comment: c,\n replies: replyMap.get(c.id) || [],\n });\n lineMap.set(line, threads);\n }\n\n return lineMap;\n}\n\n/**\n * Resolve options into a filtered LineMap ready for rendering.\n * Returns null if there are no comments to render.\n */\nexport function resolveComments(\n loader: CommentLoader,\n options: MrsfPluginOptions,\n): { lineMap: LineMap; comments: SlimComment[] } | null {\n const showResolved = options.showResolved ?? true;\n\n const doc = loader(options);\n if (!doc || !doc.comments || doc.comments.length === 0) {\n return null;\n }\n\n let comments = toSlimComments(doc);\n if (!showResolved) {\n comments = comments.filter((c) => !c.resolved);\n }\n\n if (comments.length === 0) return null;\n\n const lineMap = groupByLine(comments);\n return { lineMap, comments };\n}\n", "/**\n * Shared HTML rendering helpers for MRSF rendering plugins.\n *\n * These produce the HTML strings used in tooltips, badges, and comment\n * rendering. Both the markdown-it and rehype plugins use these functions\n * to ensure identical visual output.\n */\n\nimport type { CommentThread, SlimComment } from \"./types.js\";\n\nexport function escapeHtml(str: string): string {\n return str\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\");\n}\n\nexport function formatTime(iso: string | null): string {\n if (!iso) return \"\";\n try {\n const d = new Date(iso);\n return d.toLocaleDateString(undefined, {\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n });\n } catch {\n return \"\";\n }\n}\n\nexport function renderCommentHtml(\n comment: SlimComment,\n isReply: boolean,\n interactive: boolean,\n): string {\n const resolvedClass = comment.resolved ? \" mrsf-resolved\" : \"\";\n const replyClass = isReply ? \" mrsf-reply\" : \"\";\n let html = `<span class=\"mrsf-comment${resolvedClass}${replyClass}\" data-mrsf-comment-id=\"${escapeHtml(comment.id)}\">`;\n\n // Header\n html += `<span class=\"mrsf-comment-header\">`;\n html += `<span class=\"mrsf-author\">${escapeHtml(comment.author)}</span>`;\n if (comment.timestamp) {\n html += `<span class=\"mrsf-date\">${escapeHtml(formatTime(comment.timestamp))}</span>`;\n }\n if (comment.severity) {\n html += `<span class=\"mrsf-severity mrsf-severity-${escapeHtml(comment.severity)}\">${escapeHtml(comment.severity)}</span>`;\n }\n if (comment.type) {\n html += `<span class=\"mrsf-type\">${escapeHtml(comment.type)}</span>`;\n }\n if (comment.resolved) {\n html += `<span class=\"mrsf-resolved-badge\">\u2713 resolved</span>`;\n }\n html += `</span>`;\n\n // Selected text quote\n if (comment.selected_text) {\n html += `<span class=\"mrsf-selected-text\">${escapeHtml(comment.selected_text)}</span>`;\n }\n\n // Body\n html += `<span class=\"mrsf-comment-body\">${escapeHtml(comment.text)}</span>`;\n\n // Action buttons (interactive mode)\n if (interactive) {\n const line = comment.line != null ? String(comment.line) : \"\";\n html += `<span class=\"mrsf-actions\">`;\n if (comment.resolved) {\n html += `<button class=\"mrsf-action-btn\" data-mrsf-action=\"unresolve\" data-mrsf-comment-id=\"${escapeHtml(comment.id)}\" data-mrsf-line=\"${line}\">Unresolve</button>`;\n } else {\n html += `<button class=\"mrsf-action-btn\" data-mrsf-action=\"resolve\" data-mrsf-comment-id=\"${escapeHtml(comment.id)}\" data-mrsf-line=\"${line}\">Resolve</button>`;\n }\n html += `<button class=\"mrsf-action-btn\" data-mrsf-action=\"reply\" data-mrsf-comment-id=\"${escapeHtml(comment.id)}\" data-mrsf-line=\"${line}\">Reply</button>`;\n html += `<button class=\"mrsf-action-btn\" data-mrsf-action=\"edit\" data-mrsf-comment-id=\"${escapeHtml(comment.id)}\" data-mrsf-line=\"${line}\">Edit</button>`;\n html += `<button class=\"mrsf-action-btn mrsf-action-danger\" data-mrsf-action=\"delete\" data-mrsf-comment-id=\"${escapeHtml(comment.id)}\" data-mrsf-line=\"${line}\">Delete</button>`;\n html += `</span>`;\n }\n\n html += `</span>`;\n return html;\n}\n\nexport function renderThreadHtml(thread: CommentThread, interactive: boolean): string {\n let html = `<span class=\"mrsf-thread\">`;\n html += renderCommentHtml(thread.comment, false, interactive);\n if (thread.replies.length > 0) {\n html += `<span class=\"mrsf-replies\">`;\n for (const reply of thread.replies) {\n html += renderCommentHtml(reply, true, interactive);\n }\n html += `</span>`;\n }\n html += `</span>`;\n return html;\n}\n", "/**\n * MRSF markdown-it plugin \u2014 core rule.\n *\n * Walks the parsed token stream and injects `mrsf_badge` tokens\n * at lines that have comments, and wraps `selected_text` matches\n * with `mrsf_highlight_open`/`close` tokens (with tooltip metadata).\n */\n\nimport type Token from \"markdown-it/lib/token.mjs\";\nimport type { Nesting } from \"markdown-it/lib/token.mjs\";\nimport type StateCore from \"markdown-it/lib/rules_core/state_core.mjs\";\nimport type { LineMap, CommentThread } from \"../types.js\";\n\n/** Options forwarded from the plugin to the core rule. */\nexport interface CoreOptions {\n interactive: boolean;\n gutterPosition: \"left\" | \"tight\" | \"right\";\n gutterForInline: boolean;\n inlineHighlights: boolean;\n}\n\n/**\n * Find the token index for a given 1-based source line.\n * markdown-it tokens use `token.map = [startLine, endLine]` (0-based).\n */\nfunction findTokenIndexForLine(\n tokens: Token[],\n line: number,\n): number {\n const line0 = line - 1; // convert to 0-based\n for (let i = 0; i < tokens.length; i++) {\n const map = tokens[i].map;\n if (map && map[0] <= line0 && line0 < map[1]) {\n return i;\n }\n }\n return -1;\n}\n\n/**\n * Wrap occurrences of `text` inside inline token children with\n * highlight open/close tokens. Stores thread data on the tokens\n * so the renderer can produce an inline tooltip.\n */\nfunction highlightInlineText(\n token: Token,\n thread: CommentThread,\n interactive: boolean,\n Token: new (type: string, tag: string, nesting: Nesting) => Token,\n): boolean {\n if (!token.children) return false;\n\n const text = thread.comment.selected_text;\n if (!text) return false;\n const trimmed = text.trim();\n if (!trimmed) return false;\n\n for (let i = 0; i < token.children.length; i++) {\n const child = token.children[i];\n if (child.type !== \"text\") continue;\n\n const idx = child.content.indexOf(trimmed);\n if (idx === -1) continue;\n\n // Split the text token into: before + highlight_open + matched + highlight_close + after\n const newTokens: Token[] = [];\n\n // Text before match\n if (idx > 0) {\n const before = new Token(\"text\", \"\", 0);\n before.content = child.content.slice(0, idx);\n newTokens.push(before);\n }\n\n // Highlight open \u2014 carries thread metadata for inline tooltip\n const open = new Token(\"mrsf_highlight_open\", \"mark\", 1);\n open.attrSet(\"class\", \"mrsf-highlight\");\n open.attrSet(\"data-mrsf-comment-id\", thread.comment.id);\n open.meta = { thread };\n newTokens.push(open);\n\n // Matched text\n const matched = new Token(\"text\", \"\", 0);\n matched.content = trimmed;\n newTokens.push(matched);\n\n // Highlight close \u2014 carries thread metadata for inline tooltip\n const close = new Token(\"mrsf_highlight_close\", \"mark\", -1);\n close.meta = { thread, interactive };\n newTokens.push(close);\n\n // Text after match\n if (idx + trimmed.length < child.content.length) {\n const after = new Token(\"text\", \"\", 0);\n after.content = child.content.slice(idx + trimmed.length);\n newTokens.push(after);\n }\n\n // Replace the original child with our new tokens\n token.children.splice(i, 1, ...newTokens);\n return true;\n }\n\n return false;\n}\n\n/**\n * Install the MRSF core rule on a markdown-it instance.\n */\nexport function installCoreRule(\n md: { core: { ruler: { push: (name: string, fn: (state: StateCore) => void) => void } } },\n lineMap: LineMap,\n options: CoreOptions,\n): void {\n const { interactive, gutterPosition, gutterForInline, inlineHighlights } = options;\n\n md.core.ruler.push(\"mrsf_inject\", (state: StateCore) => {\n const tokens = state.tokens;\n const TokenCtor = state.Token;\n\n // Track which lines we've already processed (to avoid double-injection\n // when multiple tokens share the same source line).\n const processed = new Set<number>();\n\n // We iterate backwards so that inserting tokens doesn't shift indices\n // for tokens we haven't visited yet.\n for (let i = tokens.length - 1; i >= 0; i--) {\n const token = tokens[i];\n const map = token.map;\n if (!map) continue;\n\n // Skip inline tokens \u2014 they share the same map as their parent block.\n // We must process the parent block (paragraph_open, heading_open, etc.)\n // so the badge and class land on the correct rendered element.\n if (token.type === \"inline\") continue;\n\n // Always expose source line metadata for selection-based adds\n const startLine1 = map[0] + 1;\n const endLine1 = map[1];\n token.attrSet(\"data-mrsf-line\", String(startLine1));\n token.attrSet(\"data-mrsf-start-line\", String(startLine1));\n token.attrSet(\"data-mrsf-end-line\", String(endLine1));\n\n // Mark line elements as hover targets (for gutter add visibility)\n if (interactive) {\n const existingClass = token.attrGet(\"class\") || \"\";\n token.attrSet(\n \"class\",\n existingClass\n ? `${existingClass} mrsf-line-hover-target`\n : \"mrsf-line-hover-target\",\n );\n }\n\n // Check each line in this token's range for comments\n for (let line0 = map[0]; line0 < map[1]; line0++) {\n const line = line0 + 1; // 1-based\n if (processed.has(line)) continue;\n\n const threads = lineMap.get(line) || [];\n const hasThreads = threads.length > 0;\n processed.add(line);\n\n // Add line-highlight class to the block token if we have threads on this line\n if (hasThreads) {\n const existingClass = token.attrGet(\"class\") || \"\";\n token.attrSet(\n \"class\",\n existingClass\n ? `${existingClass} mrsf-line-highlight`\n : \"mrsf-line-highlight\",\n );\n token.attrSet(\"data-mrsf-line\", String(line));\n\n // Determine whether all threads on this line have inline highlights\n const allHaveInline = inlineHighlights &&\n threads.every((t) => !!t.comment.selected_text);\n\n // Inject badge unless gutterForInline is false AND all threads are inline-highlighted\n const showBadge = gutterForInline || !allHaveInline || !inlineHighlights;\n if (showBadge) {\n const badgeToken = new TokenCtor(\"mrsf_badge\", \"\", 0);\n badgeToken.meta = { line, threads, interactive, gutterPosition };\n tokens.splice(i + 1, 0, badgeToken);\n }\n\n // Highlight selected_text in the following inline token\n if (inlineHighlights) {\n const offset = showBadge ? 2 : 1;\n const inlineAfter = tokens[i + offset];\n if (inlineAfter && inlineAfter.type === \"inline\") {\n for (const thread of threads) {\n if (thread.comment.selected_text) {\n highlightInlineText(inlineAfter, thread, interactive, TokenCtor);\n }\n }\n }\n }\n } else if (interactive) {\n // No existing threads: inject a gutter add button for this line\n const addToken = new TokenCtor(\"mrsf_gutter_add\", \"\", 0);\n addToken.meta = { line, gutterPosition };\n tokens.splice(i + 1, 0, addToken);\n }\n }\n }\n\n // Wrap the entire output in a gutter container when using left gutter\n if (gutterPosition === \"left\" && processed.size > 0) {\n const openToken = new TokenCtor(\"mrsf_gutter_open\", \"div\", 1);\n openToken.attrSet(\"class\", \"mrsf-gutter-container\");\n tokens.unshift(openToken);\n const closeToken = new TokenCtor(\"mrsf_gutter_close\", \"div\", -1 as Nesting);\n tokens.push(closeToken);\n }\n });\n}\n", "/**\n * MRSF markdown-it plugin \u2014 renderer rules.\n *\n * Adds custom renderer rules for MRSF tokens:\n * - mrsf_badge: renders badge + tooltip HTML (gutter)\n * - mrsf_highlight_open/close: renders <mark> wrappers with inline tooltips\n */\n\nimport type { CommentThread } from \"../types.js\";\nimport { escapeHtml, renderThreadHtml } from \"@mrsf/plugin-shared\";\n\n/**\n * Install MRSF renderer rules on a markdown-it instance.\n */\nexport function installRendererRules(\n md: { renderer: { rules: Record<string, ((...args: any[]) => string) | undefined> } },\n): void {\n // Badge + tooltip (gutter)\n md.renderer.rules[\"mrsf_badge\"] = (\n tokens: { meta: { line: number; threads: CommentThread[]; interactive: boolean; gutterPosition: \"left\" | \"tight\" | \"right\" } }[],\n idx: number,\n ): string => {\n const { line, threads, interactive, gutterPosition } = tokens[idx].meta;\n\n const total = threads.reduce(\n (n, t) => n + 1 + t.replies.length,\n 0,\n );\n const allResolved = threads.every((t) => t.comment.resolved);\n const highestSeverity = threads.reduce<string | null>((sev, t) => {\n if (t.comment.severity === \"high\" || sev === \"high\") return \"high\";\n if (t.comment.severity === \"medium\" || sev === \"medium\") return \"medium\";\n if (t.comment.severity === \"low\" || sev === \"low\") return \"low\";\n return sev;\n }, null);\n\n const resolvedClass = allResolved ? \" mrsf-badge-resolved\" : \"\";\n const severityClass = highestSeverity === \"high\" || highestSeverity === \"medium\"\n ? ` mrsf-badge-severity-${highestSeverity}`\n : \"\";\n const positionClass = ` mrsf-gutter-${gutterPosition}`;\n\n const icon = allResolved ? \"\u2713\" : \"\uD83D\uDCAC\";\n\n let html = `<span class=\"mrsf-tooltip-anchor${positionClass}\">`;\n\n // Badge\n html += `<span class=\"mrsf-badge${resolvedClass}${severityClass}\" data-mrsf-line=\"${line}\" data-mrsf-action=\"navigate\" data-mrsf-comment-id=\"${escapeHtml(threads[0].comment.id)}\" tabindex=\"0\">${icon} ${total}</span>`;\n\n if (interactive) {\n html += `<button class=\"mrsf-gutter-add\" data-mrsf-action=\"add\" data-mrsf-line=\"${line}\" data-mrsf-start-line=\"${line}\" data-mrsf-end-line=\"${line}\" aria-label=\"Add comment\">+</button>`;\n }\n\n // Tooltip\n const tooltipClass = interactive ? \"mrsf-tooltip mrsf-interactive\" : \"mrsf-tooltip\";\n html += `<span class=\"${tooltipClass}\" data-mrsf-line=\"${line}\">`;\n for (const thread of threads) {\n html += renderThreadHtml(thread, interactive);\n }\n if (interactive) {\n html += `<span class=\"mrsf-tooltip-actions\"><button class=\"mrsf-action-btn\" data-mrsf-action=\"add\" data-mrsf-line=\"${line}\">Add comment</button></span>`;\n }\n html += `</span>`;\n\n html += `</span>`;\n return html;\n };\n\n // Gutter add button for lines without existing threads\n md.renderer.rules[\"mrsf_gutter_add\"] = (\n tokens: { meta: { line: number; gutterPosition: \"left\" | \"tight\" | \"right\" } }[],\n idx: number,\n ): string => {\n const { line, gutterPosition } = tokens[idx].meta;\n const positionClass = ` mrsf-gutter-${gutterPosition}`;\n let html = `<span class=\"mrsf-tooltip-anchor mrsf-gutter-add-only${positionClass}\">`;\n html += `<button class=\"mrsf-gutter-add\" data-mrsf-action=\"add\" data-mrsf-line=\"${line}\" data-mrsf-start-line=\"${line}\" data-mrsf-end-line=\"${line}\" aria-label=\"Add comment\">+</button>`;\n html += `</span>`;\n return html;\n };\n\n // Highlight open \u2014 wraps in tooltip-anchor for inline hover (feature D)\n md.renderer.rules[\"mrsf_highlight_open\"] = (\n tokens: any[],\n idx: number,\n ): string => {\n const token = tokens[idx];\n const cls = token.attrGet(\"class\") || \"mrsf-highlight\";\n const commentId = token.attrGet(\"data-mrsf-comment-id\") || \"\";\n const thread = token.meta?.thread as CommentThread | undefined;\n\n const line = thread?.comment.line ?? null;\n const endLine = thread?.comment.end_line ?? line ?? null;\n const startCol = thread?.comment.start_column ?? null;\n const endCol = thread?.comment.end_column ?? null;\n\n let html = \"\";\n if (thread) {\n const dataAttrs = [\n line != null ? `data-mrsf-line=\"${line}\"` : \"\",\n line != null ? `data-mrsf-start-line=\"${line}\"` : \"\",\n endLine != null ? `data-mrsf-end-line=\"${endLine}\"` : \"\",\n startCol != null ? `data-mrsf-start-column=\"${startCol}\"` : \"\",\n endCol != null ? `data-mrsf-end-column=\"${endCol}\"` : \"\",\n ].filter(Boolean).join(\" \");\n html += `<span class=\"mrsf-tooltip-anchor mrsf-inline-anchor\" ${dataAttrs}>`;\n }\n html += `<mark class=\"${escapeHtml(cls)}\" data-mrsf-comment-id=\"${escapeHtml(commentId)}\" tabindex=\"0\">`;\n return html;\n };\n\n // Highlight close \u2014 adds inline tooltip and closes tooltip-anchor\n md.renderer.rules[\"mrsf_highlight_close\"] = (\n tokens: any[],\n idx: number,\n ): string => {\n const token = tokens[idx];\n const meta = token.meta;\n let html = \"</mark>\";\n\n if (meta?.thread) {\n const thread = meta.thread as CommentThread;\n const interactive = meta.interactive as boolean;\n const tooltipClass = interactive\n ? \"mrsf-tooltip mrsf-inline-tooltip mrsf-interactive\"\n : \"mrsf-tooltip mrsf-inline-tooltip\";\n html += `<span class=\"${tooltipClass}\">`;\n html += renderThreadHtml(thread, interactive);\n html += `</span>`;\n html += `</span>`;\n }\n\n return html;\n };\n\n // Gutter container wrapper (left gutter mode)\n md.renderer.rules[\"mrsf_gutter_open\"] = (\n tokens: any[],\n idx: number,\n ): string => {\n const cls = tokens[idx].attrGet(\"class\") || \"mrsf-gutter-container\";\n return `<div class=\"${escapeHtml(cls)}\">`;\n };\n\n md.renderer.rules[\"mrsf_gutter_close\"] = (): string => {\n return `</div>`;\n };\n}\n", "/**\n * Shared logic for @mrsf/markdown-it-mrsf.\n *\n * Contains the plugin factory using shared comment loading/grouping logic.\n */\n\nimport type MarkdownIt from \"markdown-it\";\nimport type { MrsfPluginOptions, CommentLoader } from \"./types.js\";\nimport { resolveComments } from \"@mrsf/plugin-shared\";\nimport { installCoreRule } from \"./rules/core.js\";\nimport { installRendererRules } from \"./rules/renderer.js\";\n\n/**\n * Create a markdown-it plugin function with the given comment loader.\n *\n * @param loader - Function that resolves sidecar data from plugin options\n * @returns A markdown-it plugin function\n */\nexport function createMrsfPlugin(loader: CommentLoader) {\n return function mrsfPlugin(md: MarkdownIt, options: MrsfPluginOptions = {}): void {\n const interactive = options.interactive ?? false;\n const gutterPosition = options.gutterPosition ?? \"right\";\n const gutterForInline = options.gutterForInline ?? true;\n const inlineHighlights = options.inlineHighlights ?? true;\n\n const result = resolveComments(loader, options);\n if (!result) return;\n\n installCoreRule(md, result.lineMap, {\n interactive,\n gutterPosition,\n gutterForInline,\n inlineHighlights,\n });\n installRendererRules(md);\n };\n}\n", "/**\n * Browser-safe entry point for @mrsf/markdown-it-mrsf.\n *\n * This entry is automatically selected by bundlers (Vite, webpack, esbuild)\n * via the `\"browser\"` export condition in package.json. It supports the\n * `comments` and `loader` provisioning modes \u2014 no Node.js file-system APIs.\n *\n * You do NOT need to import this directly. Just use:\n * import { mrsfPlugin } from \"@mrsf/markdown-it-mrsf\";\n *\n * Your bundler will resolve to this file automatically when targeting\n * a browser environment.\n */\n\nimport type { MrsfPluginOptions } from \"./types.js\";\nimport { createMrsfPlugin } from \"./shared.js\";\n\nexport type { MrsfPluginOptions, SlimComment, CommentThread, LineMap, CommentLoader } from \"./types.js\";\n\n/**\n * The markdown-it plugin function (browser-safe).\n *\n * Supports `comments` (inline data) and `loader` (custom function) options.\n */\nexport const mrsfPlugin = createMrsfPlugin((options: MrsfPluginOptions) => {\n if (options.comments) {\n return options.comments;\n }\n\n if (options.loader) {\n try {\n return options.loader();\n } catch {\n return null;\n }\n }\n\n if (options.sidecarPath || options.documentPath) {\n console.warn(\n \"[@mrsf/markdown-it-mrsf] sidecarPath and documentPath require Node.js. \" +\n \"Use `comments` or `loader` options in browser environments.\"\n );\n }\n\n return null;\n});\n\nexport default mrsfPlugin;\n"],
|
|
5
|
+
"mappings": ";AAYM,SAAU,eAAe,KAAiB;AAC9C,SAAO,IAAI,SAAS,IAAI,CAAC,OAAO;IAC9B,IAAI,EAAE;IACN,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,cAAc,EAAE,gBAAgB;IAChC,YAAY,EAAE,cAAc;IAC5B,eAAe,EAAE,iBAAiB;IAClC,UAAU,CAAC,CAAC,EAAE;IACd,UAAU,EAAE,YAAY;IACxB,UAAU,EAAE,YAAY;IACxB,MAAM,EAAE,QAAQ;IAChB,WAAW,EAAE,aAAa;IAC1B;AACJ;AAKM,SAAU,YAAY,UAAuB;AACjD,QAAM,eAAe,SAAS,OAAO,CAAC,MAAM,CAAC,EAAE,YAAY,EAAE,QAAQ,IAAI;AACzE,QAAM,UAAU,SAAS,OAAO,CAAC,MAAM,EAAE,QAAQ;AAEjD,QAAM,WAAW,oBAAI,IAAG;AACxB,aAAW,KAAK,SAAS;AACvB,UAAM,OAAO,SAAS,IAAI,EAAE,QAAS,KAAK,CAAA;AAC1C,SAAK,KAAK,CAAC;AACX,aAAS,IAAI,EAAE,UAAW,IAAI;EAChC;AAEA,QAAM,UAAmB,oBAAI,IAAG;AAChC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QACW;AACX,UAAM,MAAM,OAAO,GAAG,EAAE,QAAQ,OAAO,KAAK;AAC5C,WAAO,eAAe,WAAW,GAAG,CAAC;AAAA,EACvC;AAEA,KAAG,SAAS,MAAM,mBAAmB,IAAI,MAAc;AACrD,WAAO;AAAA,EACT;AACF;;;ACjIO,SAAS,iBAAiB,QAAuB;AACtD,SAAO,SAASA,YAAW,IAAgB,UAA6B,CAAC,GAAS;AAChF,UAAM,cAAc,QAAQ,eAAe;AAC3C,UAAM,iBAAiB,QAAQ,kBAAkB;AACjD,UAAM,kBAAkB,QAAQ,mBAAmB;AACnD,UAAM,mBAAmB,QAAQ,oBAAoB;AAErD,UAAM,SAAS,gBAAgB,QAAQ,OAAO;AAC9C,QAAI,CAAC,OAAQ;AAEb,oBAAgB,IAAI,OAAO,SAAS;AAAA,MAClC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AACD,yBAAqB,EAAE;AAAA,EACzB;AACF;;;ACZO,IAAM,aAAa,iBAAiB,CAAC,YAA+B;AACzE,MAAI,QAAQ,UAAU;AACpB,WAAO,QAAQ;AAAA,EACjB;AAEA,MAAI,QAAQ,QAAQ;AAClB,QAAI;AACF,aAAO,QAAQ,OAAO;AAAA,IACxB,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAEA,MAAI,QAAQ,eAAe,QAAQ,cAAc;AAC/C,YAAQ;AAAA,MACN;AAAA,IAEF;AAAA,EACF;AAEA,SAAO;AACT,CAAC;AAED,IAAO,kBAAQ;",
|
|
6
|
+
"names": ["mrsfPlugin"]
|
|
7
|
+
}
|
package/dist/controller.d.ts
CHANGED
|
@@ -5,22 +5,42 @@
|
|
|
5
5
|
* and dispatches CustomEvents on the document for host applications.
|
|
6
6
|
*
|
|
7
7
|
* Usage (ESM):
|
|
8
|
-
* import "@mrsf/
|
|
8
|
+
* import "@mrsf/plugin-shared/controller";
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
10
|
+
* Events dispatched (host listens on document):
|
|
11
|
+
* - mrsf:resolve { commentId, line, ... }
|
|
12
|
+
* - mrsf:unresolve { commentId, line, ... }
|
|
13
|
+
* - mrsf:reply { commentId, line, ... }
|
|
14
|
+
* - mrsf:edit { commentId, line, ... }
|
|
15
|
+
* - mrsf:delete { commentId, line, ... }
|
|
16
|
+
* - mrsf:navigate { commentId, line, ... }
|
|
17
|
+
* - mrsf:add { commentId: null, line, selectionText?, ... }
|
|
18
|
+
* - mrsf:submit { action, commentId, text?, line?, end_line?, start_column?, end_column?, selection_text? }
|
|
12
19
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* - mrsf:unresolve { commentId, line }
|
|
16
|
-
* - mrsf:reply { commentId, line }
|
|
17
|
-
* - mrsf:edit { commentId, line }
|
|
18
|
-
* - mrsf:navigate { commentId, line }
|
|
20
|
+
* For actions that open built-in UI (add/edit/reply/resolve/unresolve/delete), the
|
|
21
|
+
* mrsf:<action> event is fired with the same payload as mrsf:submit after the user confirms.
|
|
19
22
|
*/
|
|
20
|
-
export type MrsfAction = "resolve" | "unresolve" | "reply" | "edit" | "navigate";
|
|
23
|
+
export type MrsfAction = "resolve" | "unresolve" | "reply" | "edit" | "delete" | "navigate" | "add";
|
|
21
24
|
export interface MrsfActionDetail {
|
|
22
|
-
commentId: string;
|
|
25
|
+
commentId: string | null;
|
|
23
26
|
line: number | null;
|
|
24
27
|
action: MrsfAction;
|
|
28
|
+
selectionText?: string | null;
|
|
29
|
+
start_line?: number | null;
|
|
30
|
+
end_line?: number | null;
|
|
31
|
+
start_column?: number | null;
|
|
32
|
+
end_column?: number | null;
|
|
33
|
+
}
|
|
34
|
+
export interface MrsfSubmitDetail {
|
|
35
|
+
action: "add" | "edit" | "reply" | "resolve" | "unresolve" | "delete";
|
|
36
|
+
commentId: string | null;
|
|
37
|
+
text: string;
|
|
38
|
+
type?: string | null;
|
|
39
|
+
severity?: "low" | "medium" | "high" | null;
|
|
40
|
+
line?: number | null;
|
|
41
|
+
end_line?: number | null;
|
|
42
|
+
start_column?: number | null;
|
|
43
|
+
end_column?: number | null;
|
|
44
|
+
selection_text?: string | null;
|
|
25
45
|
}
|
|
26
46
|
//# sourceMappingURL=controller.d.ts.map
|