@mrsf/marp-mrsf 0.4.8
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/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/browser.d.ts +6 -0
- package/dist/browser.js +317 -0
- package/dist/browser.js.map +7 -0
- package/dist/controller.d.ts +173 -0
- package/dist/controller.js +1179 -0
- package/dist/controller.js.map +7 -0
- package/dist/gutter.d.ts +50 -0
- package/dist/html.d.ts +13 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +353 -0
- package/dist/index.js.map +7 -0
- package/dist/rules/core.d.ts +17 -0
- package/dist/rules/renderer.d.ts +10 -0
- package/dist/shared.d.ts +20 -0
- package/dist/style.css +522 -0
- package/dist/types.d.ts +105 -0
- package/package.json +85 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidemark — MrsfController: overlay gutter architecture.
|
|
3
|
+
*
|
|
4
|
+
* The controller is the runtime engine for interactive MRSF rendering.
|
|
5
|
+
* It reads comment data from the DOM (embedded `<script type="application/mrsf+json">`)
|
|
6
|
+
* or constructor options, creates gutter overlay columns, positions
|
|
7
|
+
* badges/buttons at the correct vertical offsets, and handles all
|
|
8
|
+
* user interactions (tooltips, selection, action buttons).
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* import { MrsfController } from "@mrsf/plugin-shared/controller";
|
|
12
|
+
*
|
|
13
|
+
* const ctrl = new MrsfController(document.querySelector(".my-content")!, {
|
|
14
|
+
* interactive: true,
|
|
15
|
+
* gutterPosition: "left",
|
|
16
|
+
* });
|
|
17
|
+
* // ctrl.destroy() to clean up
|
|
18
|
+
*
|
|
19
|
+
* Events dispatched on document:
|
|
20
|
+
* - mrsf:resolve { commentId, line, ... }
|
|
21
|
+
* - mrsf:unresolve { commentId, line, ... }
|
|
22
|
+
* - mrsf:reply { commentId, line, ... }
|
|
23
|
+
* - mrsf:edit { commentId, line, ... }
|
|
24
|
+
* - mrsf:delete { commentId, line, ... }
|
|
25
|
+
* - mrsf:navigate { commentId, line, ... }
|
|
26
|
+
* - mrsf:add { commentId: null, line, selectionText?, ... }
|
|
27
|
+
* - mrsf:submit { action, commentId, text?, line?, ... }
|
|
28
|
+
*/
|
|
29
|
+
import type { CommentThread } from "./types.js";
|
|
30
|
+
import type { MrsfGutterRenderers } from "./gutter.js";
|
|
31
|
+
export type MrsfAction = "resolve" | "unresolve" | "reply" | "edit" | "delete" | "navigate" | "add";
|
|
32
|
+
export interface MrsfActionDetail {
|
|
33
|
+
commentId: string | null;
|
|
34
|
+
line: number | null;
|
|
35
|
+
action: MrsfAction;
|
|
36
|
+
selectionText?: string | null;
|
|
37
|
+
start_line?: number | null;
|
|
38
|
+
end_line?: number | null;
|
|
39
|
+
start_column?: number | null;
|
|
40
|
+
end_column?: number | null;
|
|
41
|
+
}
|
|
42
|
+
export interface MrsfSubmitDetail {
|
|
43
|
+
action: "add" | "edit" | "reply" | "resolve" | "unresolve" | "delete";
|
|
44
|
+
commentId: string | null;
|
|
45
|
+
text: string;
|
|
46
|
+
type?: string | null;
|
|
47
|
+
severity?: "low" | "medium" | "high" | null;
|
|
48
|
+
line?: number | null;
|
|
49
|
+
end_line?: number | null;
|
|
50
|
+
start_column?: number | null;
|
|
51
|
+
end_column?: number | null;
|
|
52
|
+
selection_text?: string | null;
|
|
53
|
+
}
|
|
54
|
+
export interface MrsfControllerOptions {
|
|
55
|
+
/** Show gutter on left or right side. Default: "right". */
|
|
56
|
+
gutterPosition?: "left" | "right";
|
|
57
|
+
/** Enable interactive actions (add, resolve, reply, etc.). Default: false. */
|
|
58
|
+
interactive?: boolean;
|
|
59
|
+
/** Comment data passed directly (overrides embedded script). */
|
|
60
|
+
comments?: CommentThread[];
|
|
61
|
+
/**
|
|
62
|
+
* Render inline text highlights for comments that have `selected_text`.
|
|
63
|
+
* Wraps matching text in `<mark>` elements with hover tooltips.
|
|
64
|
+
* Default: true.
|
|
65
|
+
*/
|
|
66
|
+
inlineHighlights?: boolean;
|
|
67
|
+
gutterRenderers?: MrsfGutterRenderers;
|
|
68
|
+
}
|
|
69
|
+
export declare class MrsfController {
|
|
70
|
+
private container;
|
|
71
|
+
private opts;
|
|
72
|
+
private threads;
|
|
73
|
+
private gutterLeft;
|
|
74
|
+
private gutterRight;
|
|
75
|
+
private activeTooltip;
|
|
76
|
+
private floatingAddButton;
|
|
77
|
+
private overlayEl;
|
|
78
|
+
private lastSelectionText;
|
|
79
|
+
private resizeObserver;
|
|
80
|
+
private mutationObserver;
|
|
81
|
+
private styleInjected;
|
|
82
|
+
private inlineMarks;
|
|
83
|
+
private inlineTooltipEl;
|
|
84
|
+
private orphanedSection;
|
|
85
|
+
private refreshQueued;
|
|
86
|
+
private handleResizeBound;
|
|
87
|
+
private handleMutationBound;
|
|
88
|
+
private handleClickBound;
|
|
89
|
+
private handleSelectionBound;
|
|
90
|
+
constructor(container: HTMLElement, options?: MrsfControllerOptions);
|
|
91
|
+
/** Remove all controller DOM and listeners. */
|
|
92
|
+
destroy(): void;
|
|
93
|
+
/** Recalculate gutter positions after async layout changes such as Mermaid renders. */
|
|
94
|
+
refresh(): void;
|
|
95
|
+
private loadCommentData;
|
|
96
|
+
private buildThreadMap;
|
|
97
|
+
private findCommentById;
|
|
98
|
+
private orderThreadsForDisplay;
|
|
99
|
+
private setupOverlayStructure;
|
|
100
|
+
private createGutter;
|
|
101
|
+
/** Build badge/add-button elements for each line in the gutter(s). */
|
|
102
|
+
private renderGutterItems;
|
|
103
|
+
private primaryGutter;
|
|
104
|
+
private shouldExpandRange;
|
|
105
|
+
private addVisibleLinesForElement;
|
|
106
|
+
/** Collect all unique line numbers from data-mrsf-line elements, expanding multi-line ranges. */
|
|
107
|
+
private collectLines;
|
|
108
|
+
private resolveThreadDisplayLine;
|
|
109
|
+
private collectThreadDisplayMap;
|
|
110
|
+
private createBadgeItem;
|
|
111
|
+
private createAddItem;
|
|
112
|
+
private createAddButton;
|
|
113
|
+
/** Measure [data-mrsf-line] elements and set gutter item Y offsets. */
|
|
114
|
+
positionGutterItems(): void;
|
|
115
|
+
private suppressAddItemsThatShareBadgeTargets;
|
|
116
|
+
private handleMutations;
|
|
117
|
+
private isExternalContentMutation;
|
|
118
|
+
private isControllerOwnedNode;
|
|
119
|
+
private queueRefresh;
|
|
120
|
+
private findDirectElementForLine;
|
|
121
|
+
private calculateItemTop;
|
|
122
|
+
/**
|
|
123
|
+
* Find the element whose start-line/end-line range contains the given line.
|
|
124
|
+
* Used for positioning gutter items on expanded multi-line elements.
|
|
125
|
+
*/
|
|
126
|
+
private findElementForLine;
|
|
127
|
+
/**
|
|
128
|
+
* Render orphaned comments (whose line doesn't match any DOM element)
|
|
129
|
+
* in a dedicated section at the bottom of the container.
|
|
130
|
+
*/
|
|
131
|
+
private renderOrphanedSection;
|
|
132
|
+
/**
|
|
133
|
+
* For comments with `selected_text`, find the matching text in the DOM
|
|
134
|
+
* and wrap it in a `<mark class="mrsf-inline-highlight">` element with
|
|
135
|
+
* hover/click behaviour to show the comment tooltip.
|
|
136
|
+
*/
|
|
137
|
+
private renderInlineHighlights;
|
|
138
|
+
/**
|
|
139
|
+
* Strip common inline markdown syntax so `selected_text` from source
|
|
140
|
+
* can be matched against rendered text content.
|
|
141
|
+
*/
|
|
142
|
+
private static stripInlineMarkdown;
|
|
143
|
+
/**
|
|
144
|
+
* Walk text nodes inside `root` to find `text`, then wrap the matching
|
|
145
|
+
* range in a `<mark>` element. Falls back to markdown-stripped matching.
|
|
146
|
+
*/
|
|
147
|
+
private wrapSelectedText;
|
|
148
|
+
private showInlineTooltip;
|
|
149
|
+
private applyThemeVariables;
|
|
150
|
+
private hideInlineTimeout;
|
|
151
|
+
private scheduleHideInlineTooltip;
|
|
152
|
+
private cancelHideInlineTooltip;
|
|
153
|
+
private hideInlineTooltip;
|
|
154
|
+
/** Remove all inline marks, unwrapping their contents back to text. */
|
|
155
|
+
private removeInlineHighlights;
|
|
156
|
+
private toggleTooltip;
|
|
157
|
+
private showTooltip;
|
|
158
|
+
private hideTooltip;
|
|
159
|
+
private handleClick;
|
|
160
|
+
private handleSelectionChange;
|
|
161
|
+
private selectionBelongsToContainer;
|
|
162
|
+
private findSelectionAnchor;
|
|
163
|
+
private ensureFloatingAddButton;
|
|
164
|
+
private hideFloatingAddButton;
|
|
165
|
+
private showFloatingAddButton;
|
|
166
|
+
private injectStyles;
|
|
167
|
+
private closeOverlay;
|
|
168
|
+
private openForm;
|
|
169
|
+
private openConfirm;
|
|
170
|
+
}
|
|
171
|
+
export declare function refreshAll(): void;
|
|
172
|
+
export declare function autoInit(): void;
|
|
173
|
+
//# sourceMappingURL=controller.d.ts.map
|