tiptap-markdown-react 0.6.3 → 0.7.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/dist/index.js CHANGED
@@ -1,16 +1,18 @@
1
1
  "use client";
2
2
  import { Markdown } from "@tiptap/markdown";
3
- import { jsx, jsxs, Fragment } from "react/jsx-runtime";
3
+ import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
4
4
  import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
5
5
  import Image from "@tiptap/extension-image";
6
6
  import { TableOfContents } from "@tiptap/extension-table-of-contents";
7
7
  import { NodeViewWrapper, ReactNodeViewRenderer, NodeViewContent, useEditor, EditorContent, useEditorState } from "@tiptap/react";
8
- import { forwardRef, useEffect, useImperativeHandle, useMemo, useState, useRef, useCallback, useContext, createContext } from "react";
9
- import { C as CitationRef, e as enrichMarkdownCitations, s as styles$4, b as baseExtensions, l as lowlight, m as makeTocGetId, p as pureCodeBlock, a as pureImage, R as ReportContent } from "./extractToc-DknI9ylT.js";
10
- import { c, d } from "./extractToc-DknI9ylT.js";
8
+ import { forwardRef, useEffect, useRef, useImperativeHandle, useMemo, useState, useCallback, useContext, createContext } from "react";
9
+ import { C as CitationRef, m as mergeCommentIntervals, a as mapCommentAnchors, e as enrichMarkdownCitations, s as styles$5, b as baseExtensions, c as CommentMark, l as lowlight, d as makeTocGetId, p as pureCodeBlock, f as pureImage, R as ReportContent } from "./extractToc-AUH9u6o-.js";
10
+ import { g, h, i } from "./extractToc-AUH9u6o-.js";
11
+ import { Slice, Fragment } from "@tiptap/pm/model";
11
12
  import { Extension } from "@tiptap/core";
12
- import { FileHandlePlugin } from "@tiptap/extension-file-handler";
13
13
  import { PluginKey, Plugin } from "@tiptap/pm/state";
14
+ import { DecorationSet, Decoration } from "@tiptap/pm/view";
15
+ import { FileHandlePlugin } from "@tiptap/extension-file-handler";
14
16
  import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
15
17
  import * as Popover from "@radix-ui/react-popover";
16
18
  import { createPortal } from "react-dom";
@@ -70,6 +72,261 @@ function createCitationRef(options = {}) {
70
72
  renderCitation: options.renderCitation
71
73
  });
72
74
  }
75
+ const COMMENT_ACTIVE_META = "tmr:comment:active";
76
+ const COMMENT_CLICK_META = "tmr:comment:click";
77
+ const COMMENT_GUTTER_META = "tmr:comment:gutter";
78
+ const commentAnchorPluginKey = new PluginKey(
79
+ "tmrCommentAnchor"
80
+ );
81
+ function stripCommentAnchorMarks(slice, markType) {
82
+ const strip = (fragment) => {
83
+ const children = [];
84
+ fragment.forEach((child) => {
85
+ if (child.isText && child.marks.some((m) => m.type === markType)) {
86
+ children.push(
87
+ child.mark(child.marks.filter((m) => m.type !== markType))
88
+ );
89
+ } else if (child.content.size > 0) {
90
+ children.push(child.copy(strip(child.content)));
91
+ } else {
92
+ children.push(child);
93
+ }
94
+ });
95
+ return Fragment.fromArray(children);
96
+ };
97
+ return new Slice(strip(slice.content), slice.openStart, slice.openEnd);
98
+ }
99
+ function sliceHasCommentMarks(slice, markType) {
100
+ let found = false;
101
+ slice.content.descendants((node) => {
102
+ if (node.isText && node.marks.some((m) => m.type === markType)) {
103
+ found = true;
104
+ return false;
105
+ }
106
+ return true;
107
+ });
108
+ return found;
109
+ }
110
+ function blockBounds(doc) {
111
+ const bounds = [];
112
+ doc.forEach((child, offset) => {
113
+ bounds.push({ start: offset, end: offset + child.nodeSize });
114
+ });
115
+ return bounds;
116
+ }
117
+ function collectCommentRanges(doc) {
118
+ const byId = /* @__PURE__ */ new Map();
119
+ doc.descendants((node, pos) => {
120
+ if (!node.isText) return true;
121
+ for (const m of node.marks) {
122
+ if (m.type.name !== "commentAnchor") continue;
123
+ const ids = m.attrs.commentIds ?? [];
124
+ for (const id of ids) {
125
+ const arr = byId.get(id) ?? [];
126
+ arr.push({ from: pos, to: pos + node.nodeSize });
127
+ byId.set(id, arr);
128
+ }
129
+ }
130
+ return true;
131
+ });
132
+ return byId;
133
+ }
134
+ function rangesIntersectBlock(ranges, start, end) {
135
+ return ranges.some((r) => r.from < end && r.to > start);
136
+ }
137
+ function gutterDom(commentIds, view, blockPos) {
138
+ const el = document.createElement("span");
139
+ el.className = "tmr-comment-gutter";
140
+ el.setAttribute("data-comment-ids", commentIds.join(" "));
141
+ el.textContent = String(commentIds.length);
142
+ el.title = `${commentIds.length}`;
143
+ el.addEventListener("mousedown", (e) => {
144
+ e.preventDefault();
145
+ e.stopPropagation();
146
+ });
147
+ el.addEventListener("click", (e) => {
148
+ e.preventDefault();
149
+ e.stopPropagation();
150
+ view.dispatch(
151
+ view.state.tr.setMeta(COMMENT_ACTIVE_META, commentIds[0] ?? null).setMeta(COMMENT_GUTTER_META, {
152
+ commentIds,
153
+ pos: blockPos
154
+ })
155
+ );
156
+ });
157
+ return el;
158
+ }
159
+ function commentAnchorPlugin(options = {}) {
160
+ const showGutter = options.showGutter !== false;
161
+ const interactive = options.interactive !== false;
162
+ return new Plugin({
163
+ key: commentAnchorPluginKey,
164
+ state: {
165
+ init: () => ({ activeCommentId: null }),
166
+ apply: (tr, value) => {
167
+ const active2 = tr.getMeta(COMMENT_ACTIVE_META);
168
+ return active2 !== void 0 ? { activeCommentId: active2 } : value;
169
+ }
170
+ },
171
+ props: {
172
+ decorations(state) {
173
+ var _a;
174
+ const byId = collectCommentRanges(state.doc);
175
+ if (byId.size === 0) return DecorationSet.empty;
176
+ const decos = [];
177
+ const bounds = blockBounds(state.doc);
178
+ if (showGutter) {
179
+ for (const b of bounds) {
180
+ const idsInBlock = [];
181
+ for (const [id, ranges] of byId) {
182
+ if (rangesIntersectBlock(ranges, b.start, b.end)) {
183
+ idsInBlock.push(id);
184
+ }
185
+ }
186
+ if (idsInBlock.length > 0) {
187
+ decos.push(
188
+ Decoration.widget(
189
+ b.start,
190
+ (view) => gutterDom(idsInBlock, view, b.start),
191
+ { side: -1, key: `tmr-gutter:${b.start}` }
192
+ )
193
+ );
194
+ }
195
+ }
196
+ }
197
+ const activeId = ((_a = commentAnchorPluginKey.getState(state)) == null ? void 0 : _a.activeCommentId) ?? null;
198
+ if (activeId) {
199
+ const ranges = byId.get(activeId) ?? [];
200
+ for (const r of ranges) {
201
+ decos.push(
202
+ Decoration.inline(r.from, r.to, { class: "tmr-comment-active" })
203
+ );
204
+ }
205
+ for (const b of bounds) {
206
+ if (rangesIntersectBlock(ranges, b.start, b.end)) {
207
+ decos.push(
208
+ Decoration.node(b.start, b.end, {
209
+ class: "tmr-comment-block-active"
210
+ })
211
+ );
212
+ }
213
+ }
214
+ }
215
+ return DecorationSet.create(state.doc, decos);
216
+ },
217
+ handleClick(view, pos, event) {
218
+ var _a;
219
+ if (!interactive) return false;
220
+ const target = event.target;
221
+ const el = (_a = target == null ? void 0 : target.closest) == null ? void 0 : _a.call(
222
+ target,
223
+ "mark.tmr-comment[data-comment-ids]"
224
+ );
225
+ if (!el) return false;
226
+ const commentIds = (el.getAttribute("data-comment-ids") ?? "").split(" ").filter(Boolean);
227
+ if (commentIds.length === 0) return false;
228
+ view.dispatch(
229
+ view.state.tr.setMeta(COMMENT_ACTIVE_META, commentIds[0] ?? null).setMeta(COMMENT_CLICK_META, {
230
+ commentIds,
231
+ anchorEl: el,
232
+ pos
233
+ })
234
+ );
235
+ return true;
236
+ },
237
+ // 粘贴 / 拖拽 / 编辑器内拖动的 slice 统一走这里:剥离评论 mark,
238
+ // 防止复制粘贴产生幽灵高亮。正文内容不变,只是丢掉会话级元数据。
239
+ transformPasted(slice, view) {
240
+ const markType = view.state.schema.marks.commentAnchor;
241
+ if (!markType || !sliceHasCommentMarks(slice, markType)) return slice;
242
+ return stripCommentAnchorMarks(slice, markType);
243
+ }
244
+ }
245
+ });
246
+ }
247
+ function commentAnchorExtension(options = {}) {
248
+ return Extension.create({
249
+ name: "tmrCommentAnchor",
250
+ addProseMirrorPlugins() {
251
+ return [commentAnchorPlugin(options)];
252
+ }
253
+ });
254
+ }
255
+ function applyCommentAnchorsToEditor(editor, comments) {
256
+ if (!editor.isEditable) return;
257
+ const intervals = comments.length > 0 ? mergeCommentIntervals(
258
+ mapCommentAnchors(
259
+ editor.state.doc,
260
+ comments.map((c) => ({ commentId: c.commentId, segments: c.segments }))
261
+ ).map((r) => ({ commentId: r.commentId, ranges: r.ranges }))
262
+ ) : [];
263
+ const chain = editor.chain().clearCommentAnchors();
264
+ if (intervals.length > 0) chain.applyCommentAnchors(intervals);
265
+ chain.run();
266
+ }
267
+ function collectCommentIds(editor) {
268
+ const ids = [];
269
+ editor.state.doc.descendants((node) => {
270
+ if (!node.isText) return true;
271
+ for (const m of node.marks) {
272
+ if (m.type.name !== "commentAnchor") continue;
273
+ for (const id of m.attrs.commentIds ?? []) {
274
+ if (!ids.includes(id)) ids.push(id);
275
+ }
276
+ }
277
+ return true;
278
+ });
279
+ return ids;
280
+ }
281
+ function commentRangesById(editor, commentId) {
282
+ const ranges = [];
283
+ editor.state.doc.descendants((node, pos) => {
284
+ if (!node.isText) return true;
285
+ for (const m of node.marks) {
286
+ if (m.type.name !== "commentAnchor") continue;
287
+ const ids = m.attrs.commentIds ?? [];
288
+ if (ids.includes(commentId)) {
289
+ ranges.push({ from: pos, to: pos + node.nodeSize });
290
+ }
291
+ }
292
+ return true;
293
+ });
294
+ return ranges;
295
+ }
296
+ function setActive(editor, commentId) {
297
+ editor.view.dispatch(
298
+ editor.state.tr.setMeta(COMMENT_ACTIVE_META, commentId)
299
+ );
300
+ }
301
+ function getActive(editor) {
302
+ var _a;
303
+ return ((_a = commentAnchorPluginKey.getState(editor.state)) == null ? void 0 : _a.activeCommentId) ?? null;
304
+ }
305
+ function focusComment(editor, commentId) {
306
+ var _a;
307
+ const ranges = commentRangesById(editor, commentId);
308
+ if (ranges.length === 0) {
309
+ setActive(editor, null);
310
+ return false;
311
+ }
312
+ setActive(editor, commentId);
313
+ const markEl = editor.view.dom.querySelector(
314
+ `mark.tmr-comment[data-comment-ids~="${CSS.escape(commentId)}"]`
315
+ );
316
+ (_a = markEl == null ? void 0 : markEl.scrollIntoView) == null ? void 0 : _a.call(markEl, { block: "center", behavior: "smooth" });
317
+ editor.chain().setTextSelection(ranges[0].from).run();
318
+ return true;
319
+ }
320
+ function nextComment(editor, dir = "next") {
321
+ const ids = collectCommentIds(editor);
322
+ if (ids.length === 0) return null;
323
+ const active2 = getActive(editor);
324
+ const current = active2 ? ids.indexOf(active2) : -1;
325
+ const nextIdx = dir === "next" ? (current + 1) % ids.length : (current - 1 + ids.length) % ids.length;
326
+ const target = ids[nextIdx];
327
+ focusComment(editor, target);
328
+ return target;
329
+ }
73
330
  const MD_FILE_RE = /\.(md|markdown)$/i;
74
331
  const MD_MIME_TYPES = ["text/markdown", "text/x-markdown", ""];
75
332
  async function insertMarkdownFiles(editor, files, pos) {
@@ -343,21 +600,32 @@ const defaultCodeBlockLabels = {
343
600
  autoDetect: "Auto-detect",
344
601
  delete: "Delete code block"
345
602
  };
346
- const wrapper = "_wrapper_2dv2g_2";
347
- const header$1 = "_header_2dv2g_18";
348
- const langTrigger = "_langTrigger_2dv2g_28";
349
- const langChevron = "_langChevron_2dv2g_50";
350
- const langMenu = "_langMenu_2dv2g_56";
351
- const langItem = "_langItem_2dv2g_69";
352
- const langItemSelected = "_langItemSelected_2dv2g_88";
353
- const langItemCheck = "_langItemCheck_2dv2g_93";
354
- const deleteBtn = "_deleteBtn_2dv2g_101";
355
- const pre = "_pre_2dv2g_121";
356
- const styles$3 = {
603
+ const defaultCommentLabels = {
604
+ open: "Open",
605
+ resolved: "Resolved",
606
+ dismissed: "Dismissed",
607
+ outdated: "Outdated",
608
+ ambiguous: "Ambiguous",
609
+ partial: "Partially matched",
610
+ gutterTitle: "Comment"
611
+ };
612
+ const wrapper = "_wrapper_5i2vi_2";
613
+ const header$1 = "_header_5i2vi_18";
614
+ const langTrigger = "_langTrigger_5i2vi_28";
615
+ const langChevron = "_langChevron_5i2vi_50";
616
+ const langBadge = "_langBadge_5i2vi_56";
617
+ const langMenu = "_langMenu_5i2vi_71";
618
+ const langItem = "_langItem_5i2vi_84";
619
+ const langItemSelected = "_langItemSelected_5i2vi_103";
620
+ const langItemCheck = "_langItemCheck_5i2vi_108";
621
+ const deleteBtn = "_deleteBtn_5i2vi_116";
622
+ const pre = "_pre_5i2vi_136";
623
+ const styles$4 = {
357
624
  wrapper,
358
625
  header: header$1,
359
626
  langTrigger,
360
627
  langChevron,
628
+ langBadge,
361
629
  langMenu,
362
630
  langItem,
363
631
  langItemSelected,
@@ -389,7 +657,8 @@ function CodeBlockView({
389
657
  node,
390
658
  updateAttributes,
391
659
  deleteNode,
392
- extension
660
+ extension,
661
+ editor
393
662
  }) {
394
663
  var _a;
395
664
  const labels = {
@@ -399,25 +668,26 @@ function CodeBlockView({
399
668
  const language = node.attrs.language || "";
400
669
  const current = LANGUAGES.find((l) => l.value === language);
401
670
  const currentLabel = current ? current.value === "" ? labels.autoDetect : current.label : labels.autoDetect;
402
- return /* @__PURE__ */ jsxs(NodeViewWrapper, { className: styles$3.wrapper, children: [
403
- /* @__PURE__ */ jsxs("div", { className: styles$3.header, contentEditable: false, children: [
671
+ const editable = editor.isEditable;
672
+ return /* @__PURE__ */ jsxs(NodeViewWrapper, { className: styles$4.wrapper, children: [
673
+ editable ? /* @__PURE__ */ jsxs("div", { className: styles$4.header, contentEditable: false, children: [
404
674
  /* @__PURE__ */ jsxs(DropdownMenu.Root, { children: [
405
675
  /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs(
406
676
  "button",
407
677
  {
408
678
  type: "button",
409
- className: styles$3.langTrigger,
679
+ className: styles$4.langTrigger,
410
680
  "aria-label": "Code language",
411
681
  children: [
412
682
  /* @__PURE__ */ jsx("span", { children: currentLabel }),
413
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 14, className: styles$3.langChevron })
683
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 14, className: styles$4.langChevron })
414
684
  ]
415
685
  }
416
686
  ) }),
417
687
  /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx(
418
688
  DropdownMenu.Content,
419
689
  {
420
- className: styles$3.langMenu,
690
+ className: styles$4.langMenu,
421
691
  sideOffset: 4,
422
692
  align: "end",
423
693
  children: LANGUAGES.map((l) => {
@@ -426,10 +696,10 @@ function CodeBlockView({
426
696
  return /* @__PURE__ */ jsxs(
427
697
  DropdownMenu.Item,
428
698
  {
429
- className: `${styles$3.langItem}${selected ? ` ${styles$3.langItemSelected}` : ""}`,
699
+ className: `${styles$4.langItem}${selected ? ` ${styles$4.langItemSelected}` : ""}`,
430
700
  onSelect: () => updateAttributes({ language: l.value }),
431
701
  children: [
432
- /* @__PURE__ */ jsx("span", { className: styles$3.langItemCheck, children: selected ? /* @__PURE__ */ jsx(CheckIcon, { size: 14 }) : null }),
702
+ /* @__PURE__ */ jsx("span", { className: styles$4.langItemCheck, children: selected ? /* @__PURE__ */ jsx(CheckIcon, { size: 14 }) : null }),
433
703
  optionLabel
434
704
  ]
435
705
  },
@@ -443,15 +713,18 @@ function CodeBlockView({
443
713
  "button",
444
714
  {
445
715
  type: "button",
446
- className: styles$3.deleteBtn,
716
+ className: styles$4.deleteBtn,
447
717
  title: labels.delete,
448
718
  "aria-label": labels.delete,
449
719
  onClick: () => deleteNode(),
450
720
  children: /* @__PURE__ */ jsx(TrashIcon, {})
451
721
  }
452
722
  )
453
- ] }),
454
- /* @__PURE__ */ jsx("pre", { className: styles$3.pre, children: /* @__PURE__ */ jsx(NodeViewContent, { as: "code" }) })
723
+ ] }) : (
724
+ // 只读:只展示语言标签,无下拉 / 删除等交互件
725
+ /* @__PURE__ */ jsx("div", { className: styles$4.langBadge, contentEditable: false, children: currentLabel })
726
+ ),
727
+ /* @__PURE__ */ jsx("pre", { className: styles$4.pre, children: /* @__PURE__ */ jsx(NodeViewContent, { as: "code" }) })
455
728
  ] });
456
729
  }
457
730
  const CodeBlock = CodeBlockLowlight.extend({
@@ -510,6 +783,7 @@ const ImageWithConfirmDelete = Image.extend({
510
783
  });
511
784
  const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
512
785
  initialMarkdown = "",
786
+ editable = true,
513
787
  sources,
514
788
  renderCitation,
515
789
  placeholder,
@@ -519,7 +793,13 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
519
793
  markdownFileDrop = true,
520
794
  extraExtensions,
521
795
  codeBlockLabels,
522
- className
796
+ className,
797
+ comments,
798
+ activeCommentId,
799
+ onCommentClick,
800
+ onActiveCommentChange,
801
+ showCommentGutter = true,
802
+ commentInteractive = true
523
803
  }, ref) {
524
804
  const preparedInitial = enrichMarkdownCitations(
525
805
  initialMarkdown,
@@ -531,6 +811,11 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
531
811
  CodeBlock.configure({ lowlight, codeBlockLabels }),
532
812
  ImageWithConfirmDelete.configure({ inline: false }),
533
813
  createCitationRef({ renderCitation }),
814
+ CommentMark,
815
+ commentAnchorExtension({
816
+ showGutter: showCommentGutter,
817
+ interactive: commentInteractive
818
+ }),
534
819
  Markdown,
535
820
  TableOfContents.configure({
536
821
  getId: makeTocGetId(),
@@ -546,11 +831,12 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
546
831
  ],
547
832
  content: preparedInitial,
548
833
  contentType: "markdown",
834
+ editable,
549
835
  // Next.js SSR:服务端不立即渲染,避免 hydration 不一致
550
836
  immediatelyRender: false,
551
837
  editorProps: {
552
838
  attributes: {
553
- class: styles$4.editorContent,
839
+ class: styles$5.editorContent,
554
840
  "data-placeholder": placeholder ?? ""
555
841
  }
556
842
  }
@@ -559,6 +845,56 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
559
845
  onEditorReady == null ? void 0 : onEditorReady(editor);
560
846
  return () => onEditorReady == null ? void 0 : onEditorReady(null);
561
847
  }, [editor, onEditorReady]);
848
+ useEffect(() => {
849
+ editor == null ? void 0 : editor.setEditable(editable);
850
+ }, [editor, editable]);
851
+ const commentsSignatureRef = useRef("");
852
+ useEffect(() => {
853
+ if (!editor || !editable) return;
854
+ const signature = (comments ?? []).map((c) => `${c.commentId}:${c.segments.length}`).join("|");
855
+ if (signature === commentsSignatureRef.current) return;
856
+ commentsSignatureRef.current = signature;
857
+ applyCommentAnchorsToEditor(editor, comments ?? []);
858
+ }, [editor, editable, comments]);
859
+ useEffect(() => {
860
+ if (!editor) return;
861
+ editor.view.dispatch(
862
+ editor.state.tr.setMeta(
863
+ COMMENT_ACTIVE_META,
864
+ activeCommentId ?? null
865
+ )
866
+ );
867
+ }, [editor, activeCommentId]);
868
+ const onCommentClickRef = useRef(onCommentClick);
869
+ const onActiveCommentChangeRef = useRef(onActiveCommentChange);
870
+ onCommentClickRef.current = onCommentClick;
871
+ onActiveCommentChangeRef.current = onActiveCommentChange;
872
+ useEffect(() => {
873
+ if (!editor) return;
874
+ const onTransaction = ({
875
+ transaction
876
+ }) => {
877
+ var _a, _b, _c, _d;
878
+ const click = transaction.getMeta(COMMENT_CLICK_META);
879
+ if (click) {
880
+ (_a = onCommentClickRef.current) == null ? void 0 : _a.call(onCommentClickRef, click);
881
+ (_b = onActiveCommentChangeRef.current) == null ? void 0 : _b.call(onActiveCommentChangeRef, click.commentIds[0] ?? null);
882
+ }
883
+ const gutter = transaction.getMeta(COMMENT_GUTTER_META);
884
+ if (gutter) {
885
+ (_c = onCommentClickRef.current) == null ? void 0 : _c.call(onCommentClickRef, {
886
+ commentIds: gutter.commentIds,
887
+ anchorEl: null,
888
+ pos: gutter.pos
889
+ });
890
+ (_d = onActiveCommentChangeRef.current) == null ? void 0 : _d.call(onActiveCommentChangeRef, gutter.commentIds[0] ?? null);
891
+ }
892
+ };
893
+ editor.on("transaction", onTransaction);
894
+ return () => {
895
+ editor.off("transaction", onTransaction);
896
+ };
897
+ }, [editor]);
562
898
  useImperativeHandle(
563
899
  ref,
564
900
  () => ({
@@ -574,7 +910,10 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
574
910
  var _a;
575
911
  return ((_a = editor == null ? void 0 : editor.getJSON) == null ? void 0 : _a.call(editor)) ?? {};
576
912
  },
577
- getEditor: () => editor ?? null
913
+ getEditor: () => editor ?? null,
914
+ focusComment: (commentId) => editor ? focusComment(editor, commentId) : false,
915
+ nextComment: (dir) => editor ? nextComment(editor, dir ?? "next") : null,
916
+ getCommentIds: () => editor ? collectCommentIds(editor) : []
578
917
  }),
579
918
  [editor]
580
919
  );
@@ -582,7 +921,7 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
582
921
  EditorContent,
583
922
  {
584
923
  editor,
585
- className: className ? `${styles$4.editorScroll} ${className}` : styles$4.editorScroll
924
+ className: className ? `${styles$5.editorScroll} ${className}` : styles$5.editorScroll
586
925
  }
587
926
  );
588
927
  });
@@ -614,7 +953,7 @@ function MarkdownPreview({
614
953
  editable: false,
615
954
  immediatelyRender: false,
616
955
  editorProps: {
617
- attributes: { class: styles$4.editorContent }
956
+ attributes: { class: styles$5.editorContent }
618
957
  }
619
958
  },
620
959
  [extensions]
@@ -627,7 +966,7 @@ function MarkdownPreview({
627
966
  EditorContent,
628
967
  {
629
968
  editor,
630
- className: className ?? styles$4.editorScroll
969
+ className: className ?? styles$5.editorScroll
631
970
  }
632
971
  );
633
972
  }
@@ -656,8 +995,8 @@ const scriptGlyph = "_scriptGlyph_i2emf_203";
656
995
  const menu = "_menu_i2emf_215";
657
996
  const menuItem = "_menuItem_i2emf_226";
658
997
  const menuItemSelected = "_menuItemSelected_i2emf_252";
659
- const popoverContent = "_popoverContent_i2emf_266";
660
- const styles$2 = {
998
+ const popoverContent$1 = "_popoverContent_i2emf_266";
999
+ const styles$3 = {
661
1000
  toolbar,
662
1001
  inner,
663
1002
  btn,
@@ -679,7 +1018,7 @@ const styles$2 = {
679
1018
  menu,
680
1019
  menuItem,
681
1020
  menuItemSelected,
682
- popoverContent
1021
+ popoverContent: popoverContent$1
683
1022
  };
684
1023
  const palette = "_palette_x5lrq_2";
685
1024
  const noneRow = "_noneRow_x5lrq_11";
@@ -690,7 +1029,7 @@ const swatch = "_swatch_x5lrq_54";
690
1029
  const swatchActive = "_swatchActive_x5lrq_70";
691
1030
  const themeLabel = "_themeLabel_x5lrq_76";
692
1031
  const themeRow = "_themeRow_x5lrq_84";
693
- const styles$1 = {
1032
+ const styles$2 = {
694
1033
  palette,
695
1034
  noneRow,
696
1035
  noneIcon,
@@ -713,46 +1052,46 @@ const THEME_COLORS = ["#ff6719", "#ff5500"];
713
1052
  function ColorPalette({ value, onPick, labels }) {
714
1053
  const t = { ...defaultColorPaletteLabels, ...labels };
715
1054
  const current = value == null ? void 0 : value.toLowerCase();
716
- return /* @__PURE__ */ jsxs("div", { className: styles$1.palette, children: [
1055
+ return /* @__PURE__ */ jsxs("div", { className: styles$2.palette, children: [
717
1056
  /* @__PURE__ */ jsxs(
718
1057
  "button",
719
1058
  {
720
1059
  type: "button",
721
- className: styles$1.noneRow,
1060
+ className: styles$2.noneRow,
722
1061
  onMouseDown: (e) => e.preventDefault(),
723
1062
  onClick: () => onPick(null),
724
1063
  children: [
725
- /* @__PURE__ */ jsx("span", { className: styles$1.noneIcon, "aria-hidden": true }),
726
- /* @__PURE__ */ jsx("span", { className: styles$1.noneLabel, children: t.none })
1064
+ /* @__PURE__ */ jsx("span", { className: styles$2.noneIcon, "aria-hidden": true }),
1065
+ /* @__PURE__ */ jsx("span", { className: styles$2.noneLabel, children: t.none })
727
1066
  ]
728
1067
  }
729
1068
  ),
730
- /* @__PURE__ */ jsx("div", { className: styles$1.grid, children: PALETTE.flat().map((c2) => /* @__PURE__ */ jsx(
1069
+ /* @__PURE__ */ jsx("div", { className: styles$2.grid, children: PALETTE.flat().map((c) => /* @__PURE__ */ jsx(
731
1070
  "button",
732
1071
  {
733
1072
  type: "button",
734
- className: `${styles$1.swatch} ${current === c2.toLowerCase() ? styles$1.swatchActive : ""}`,
735
- style: { background: c2 },
736
- title: c2,
737
- "aria-label": c2,
1073
+ className: `${styles$2.swatch} ${current === c.toLowerCase() ? styles$2.swatchActive : ""}`,
1074
+ style: { background: c },
1075
+ title: c,
1076
+ "aria-label": c,
738
1077
  onMouseDown: (e) => e.preventDefault(),
739
- onClick: () => onPick(c2)
1078
+ onClick: () => onPick(c)
740
1079
  },
741
- c2
1080
+ c
742
1081
  )) }),
743
- /* @__PURE__ */ jsx("div", { className: styles$1.themeLabel, children: t.theme }),
744
- /* @__PURE__ */ jsx("div", { className: styles$1.themeRow, children: THEME_COLORS.map((c2) => /* @__PURE__ */ jsx(
1082
+ /* @__PURE__ */ jsx("div", { className: styles$2.themeLabel, children: t.theme }),
1083
+ /* @__PURE__ */ jsx("div", { className: styles$2.themeRow, children: THEME_COLORS.map((c) => /* @__PURE__ */ jsx(
745
1084
  "button",
746
1085
  {
747
1086
  type: "button",
748
- className: `${styles$1.swatch} ${current === c2.toLowerCase() ? styles$1.swatchActive : ""}`,
749
- style: { background: c2 },
750
- title: c2,
751
- "aria-label": c2,
1087
+ className: `${styles$2.swatch} ${current === c.toLowerCase() ? styles$2.swatchActive : ""}`,
1088
+ style: { background: c },
1089
+ title: c,
1090
+ "aria-label": c,
752
1091
  onMouseDown: (e) => e.preventDefault(),
753
- onClick: () => onPick(c2)
1092
+ onClick: () => onPick(c)
754
1093
  },
755
- c2
1094
+ c
756
1095
  )) })
757
1096
  ] });
758
1097
  }
@@ -771,7 +1110,7 @@ function ToolbarButton({
771
1110
  "aria-label": title,
772
1111
  "aria-pressed": active2,
773
1112
  disabled,
774
- className: `${styles$2.btn} ${active2 ? styles$2.btnActive : ""}`,
1113
+ className: `${styles$3.btn} ${active2 ? styles$3.btnActive : ""}`,
775
1114
  onMouseDown: (e) => e.preventDefault(),
776
1115
  onClick,
777
1116
  children
@@ -779,7 +1118,7 @@ function ToolbarButton({
779
1118
  );
780
1119
  }
781
1120
  function Divider() {
782
- return /* @__PURE__ */ jsx("span", { className: styles$2.divider, "aria-hidden": true });
1121
+ return /* @__PURE__ */ jsx("span", { className: styles$3.divider, "aria-hidden": true });
783
1122
  }
784
1123
  const MenuCloseCtx = createContext(() => {
785
1124
  });
@@ -794,7 +1133,7 @@ function MenuPopover({
794
1133
  /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(
795
1134
  Popover.Content,
796
1135
  {
797
- className: styles$2.menu,
1136
+ className: styles$3.menu,
798
1137
  sideOffset: 4,
799
1138
  align: "start",
800
1139
  onOpenAutoFocus: (e) => e.preventDefault(),
@@ -816,7 +1155,7 @@ function MenuItem({
816
1155
  {
817
1156
  type: "button",
818
1157
  disabled,
819
- className: `${styles$2.menuItem} ${selected ? styles$2.menuItemSelected : ""}`,
1158
+ className: `${styles$3.menuItem} ${selected ? styles$3.menuItemSelected : ""}`,
820
1159
  onMouseDown: (e) => e.preventDefault(),
821
1160
  onClick: () => {
822
1161
  onSelect();
@@ -840,20 +1179,20 @@ function ColorPopover({
840
1179
  "button",
841
1180
  {
842
1181
  type: "button",
843
- className: styles$2.btn,
1182
+ className: styles$3.btn,
844
1183
  title,
845
1184
  "aria-label": title,
846
1185
  onMouseDown: (e) => e.preventDefault(),
847
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.colorIcon, children: [
848
- /* @__PURE__ */ jsx("span", { className: styles$2.colorIconGlyph, children: glyph }),
849
- /* @__PURE__ */ jsx("span", { className: styles$2.colorIconBar, style: { background: bar } })
1186
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.colorIcon, children: [
1187
+ /* @__PURE__ */ jsx("span", { className: styles$3.colorIconGlyph, children: glyph }),
1188
+ /* @__PURE__ */ jsx("span", { className: styles$3.colorIconBar, style: { background: bar } })
850
1189
  ] })
851
1190
  }
852
1191
  ) }),
853
1192
  /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(
854
1193
  Popover.Content,
855
1194
  {
856
- className: styles$2.popoverContent,
1195
+ className: styles$3.popoverContent,
857
1196
  sideOffset: 4,
858
1197
  align: "start",
859
1198
  onOpenAutoFocus: (e) => e.preventDefault(),
@@ -862,8 +1201,8 @@ function ColorPopover({
862
1201
  ColorPalette,
863
1202
  {
864
1203
  value,
865
- onPick: (c2) => {
866
- onPick(c2);
1204
+ onPick: (c) => {
1205
+ onPick(c);
867
1206
  setOpen(false);
868
1207
  },
869
1208
  labels: paletteLabels
@@ -939,8 +1278,8 @@ function EditorToolbar({
939
1278
  if (!coords) return;
940
1279
  const $pos = editor.state.doc.resolve(coords.pos);
941
1280
  let inTable = false;
942
- for (let d2 = $pos.depth; d2 > 0; d2--) {
943
- if ($pos.node(d2).type.name === "table") {
1281
+ for (let d = $pos.depth; d > 0; d--) {
1282
+ if ($pos.node(d).type.name === "table") {
944
1283
  inTable = true;
945
1284
  break;
946
1285
  }
@@ -1031,12 +1370,12 @@ function EditorToolbar({
1031
1370
  };
1032
1371
  const canEditFontSize = editorFocused && state.isParagraph;
1033
1372
  const scriptActive = state.superscript ? "superscript" : state.subscript ? "subscript" : "normal";
1034
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1373
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
1035
1374
  /* @__PURE__ */ jsx(
1036
1375
  "div",
1037
1376
  {
1038
- className: className ? `${styles$2.toolbar} ${className}` : styles$2.toolbar,
1039
- children: /* @__PURE__ */ jsxs("div", { className: styles$2.inner, children: [
1377
+ className: className ? `${styles$3.toolbar} ${className}` : styles$3.toolbar,
1378
+ children: /* @__PURE__ */ jsxs("div", { className: styles$3.inner, children: [
1040
1379
  /* @__PURE__ */ jsx(
1041
1380
  ToolbarButton,
1042
1381
  {
@@ -1063,12 +1402,12 @@ function EditorToolbar({
1063
1402
  "button",
1064
1403
  {
1065
1404
  type: "button",
1066
- className: styles$2.styleTrigger,
1405
+ className: styles$3.styleTrigger,
1067
1406
  title: t.style,
1068
1407
  onMouseDown: (e) => e.preventDefault(),
1069
1408
  children: [
1070
- /* @__PURE__ */ jsx("span", { className: styles$2.styleTriggerLabel, children: t.style }),
1071
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$2.styleTriggerCaret })
1409
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleTriggerLabel, children: t.style }),
1410
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
1072
1411
  ]
1073
1412
  }
1074
1413
  ),
@@ -1078,8 +1417,8 @@ function EditorToolbar({
1078
1417
  {
1079
1418
  selected: (state.headingLevel ?? 0) === 0,
1080
1419
  onSelect: () => setBlockStyle(0),
1081
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1082
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: "¶" }),
1420
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1421
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: "¶" }),
1083
1422
  t.normalText
1084
1423
  ] })
1085
1424
  }
@@ -1089,8 +1428,8 @@ function EditorToolbar({
1089
1428
  {
1090
1429
  selected: state.headingLevel === lv,
1091
1430
  onSelect: () => setBlockStyle(lv),
1092
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1093
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: `H${lv}` }),
1431
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1432
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: `H${lv}` }),
1094
1433
  t.headingLabel(lv)
1095
1434
  ] })
1096
1435
  },
@@ -1106,14 +1445,14 @@ function EditorToolbar({
1106
1445
  "button",
1107
1446
  {
1108
1447
  type: "button",
1109
- className: styles$2.styleTrigger,
1448
+ className: styles$3.styleTrigger,
1110
1449
  title: t.fontSize,
1111
1450
  "aria-label": t.fontSize,
1112
1451
  disabled: !canEditFontSize,
1113
1452
  onMouseDown: (e) => e.preventDefault(),
1114
1453
  children: [
1115
- /* @__PURE__ */ jsx("span", { className: styles$2.styleTriggerLabel, children: state.fontSize || t.fontSize }),
1116
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$2.styleTriggerCaret })
1454
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleTriggerLabel, children: state.fontSize || t.fontSize }),
1455
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
1117
1456
  ]
1118
1457
  }
1119
1458
  ),
@@ -1123,8 +1462,8 @@ function EditorToolbar({
1123
1462
  {
1124
1463
  selected: !state.fontSize,
1125
1464
  onSelect: () => applyFontSize(""),
1126
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1127
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: "A" }),
1465
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1466
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: "A" }),
1128
1467
  t.fontSizeDefault
1129
1468
  ] })
1130
1469
  }
@@ -1134,8 +1473,8 @@ function EditorToolbar({
1134
1473
  {
1135
1474
  selected: state.fontSize === size,
1136
1475
  onSelect: () => applyFontSize(size),
1137
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1138
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: parseInt(size, 10) }),
1476
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1477
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: parseInt(size, 10) }),
1139
1478
  size
1140
1479
  ] })
1141
1480
  },
@@ -1219,13 +1558,13 @@ function EditorToolbar({
1219
1558
  "button",
1220
1559
  {
1221
1560
  type: "button",
1222
- className: `${styles$2.scriptTrigger} ${scriptActive !== "normal" ? styles$2.btnActive : ""}`,
1561
+ className: `${styles$3.scriptTrigger} ${scriptActive !== "normal" ? styles$3.btnActive : ""}`,
1223
1562
  title: t.scriptMenu,
1224
1563
  "aria-label": t.scriptMenu,
1225
1564
  onMouseDown: (e) => e.preventDefault(),
1226
1565
  children: [
1227
- /* @__PURE__ */ jsx("span", { className: styles$2.scriptTriggerGlyph, children: "A" }),
1228
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$2.styleTriggerCaret })
1566
+ /* @__PURE__ */ jsx("span", { className: styles$3.scriptTriggerGlyph, children: "A" }),
1567
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
1229
1568
  ]
1230
1569
  }
1231
1570
  ),
@@ -1235,8 +1574,8 @@ function EditorToolbar({
1235
1574
  {
1236
1575
  selected: scriptActive === "normal",
1237
1576
  onSelect: () => chain().unsetSuperscript().unsetSubscript().run(),
1238
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1239
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: "A" }),
1577
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1578
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: "A" }),
1240
1579
  t.scriptNormal
1241
1580
  ] })
1242
1581
  }
@@ -1246,8 +1585,8 @@ function EditorToolbar({
1246
1585
  {
1247
1586
  selected: scriptActive === "superscript",
1248
1587
  onSelect: () => chain().unsetSubscript().toggleSuperscript().run(),
1249
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1250
- /* @__PURE__ */ jsxs("span", { className: `${styles$2.styleIcon} ${styles$2.scriptGlyph}`, children: [
1588
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1589
+ /* @__PURE__ */ jsxs("span", { className: `${styles$3.styleIcon} ${styles$3.scriptGlyph}`, children: [
1251
1590
  "x",
1252
1591
  /* @__PURE__ */ jsx("sup", { children: "2" })
1253
1592
  ] }),
@@ -1260,8 +1599,8 @@ function EditorToolbar({
1260
1599
  {
1261
1600
  selected: scriptActive === "subscript",
1262
1601
  onSelect: () => chain().unsetSuperscript().toggleSubscript().run(),
1263
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1264
- /* @__PURE__ */ jsxs("span", { className: `${styles$2.styleIcon} ${styles$2.scriptGlyph}`, children: [
1602
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1603
+ /* @__PURE__ */ jsxs("span", { className: `${styles$3.styleIcon} ${styles$3.scriptGlyph}`, children: [
1265
1604
  "x",
1266
1605
  /* @__PURE__ */ jsx("sub", { children: "2" })
1267
1606
  ] }),
@@ -1274,7 +1613,7 @@ function EditorToolbar({
1274
1613
  ),
1275
1614
  /* @__PURE__ */ jsx(Divider, {}),
1276
1615
  /* @__PURE__ */ jsx(ToolbarButton, { title: t.link, active: state.link, onClick: toggleLink, children: /* @__PURE__ */ jsx(LinkIcon, {}) }),
1277
- onImageUpload ? /* @__PURE__ */ jsxs(Fragment, { children: [
1616
+ onImageUpload ? /* @__PURE__ */ jsxs(Fragment$1, { children: [
1278
1617
  /* @__PURE__ */ jsx(ToolbarButton, { title: t.image, onClick: handlePickImage, children: /* @__PURE__ */ jsx(ImageIcon, {}) }),
1279
1618
  /* @__PURE__ */ jsx(
1280
1619
  "input",
@@ -1293,7 +1632,7 @@ function EditorToolbar({
1293
1632
  title: t.blockquote,
1294
1633
  active: state.blockquote,
1295
1634
  onClick: () => chain().toggleBlockquote().run(),
1296
- children: /* @__PURE__ */ jsx("span", { className: styles$2.txtIcon, children: "❝" })
1635
+ children: /* @__PURE__ */ jsx("span", { className: styles$3.txtIcon, children: "❝" })
1297
1636
  }
1298
1637
  ),
1299
1638
  /* @__PURE__ */ jsx(Divider, {}),
@@ -1332,22 +1671,22 @@ function EditorToolbar({
1332
1671
  "button",
1333
1672
  {
1334
1673
  type: "button",
1335
- className: styles$2.styleTrigger,
1674
+ className: styles$3.styleTrigger,
1336
1675
  title: t.more,
1337
1676
  onMouseDown: (e) => e.preventDefault(),
1338
1677
  children: [
1339
- /* @__PURE__ */ jsx("span", { className: styles$2.styleTriggerLabel, children: t.more }),
1340
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$2.styleTriggerCaret })
1678
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleTriggerLabel, children: t.more }),
1679
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
1341
1680
  ]
1342
1681
  }
1343
1682
  ),
1344
1683
  children: [
1345
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().toggleCodeBlock().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1346
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: "{ }" }),
1684
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().toggleCodeBlock().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1685
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: "{ }" }),
1347
1686
  t.codeBlock
1348
1687
  ] }) }),
1349
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().setHorizontalRule().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1350
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: "—" }),
1688
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().setHorizontalRule().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1689
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: "—" }),
1351
1690
  t.hr
1352
1691
  ] }) }),
1353
1692
  /* @__PURE__ */ jsx(
@@ -1355,8 +1694,8 @@ function EditorToolbar({
1355
1694
  {
1356
1695
  disabled: state.inTable,
1357
1696
  onSelect: () => chain().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),
1358
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1359
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: "⊞" }),
1697
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1698
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: "⊞" }),
1360
1699
  t.tableInsert
1361
1700
  ] })
1362
1701
  }
@@ -1364,8 +1703,8 @@ function EditorToolbar({
1364
1703
  /* @__PURE__ */ jsx(MenuItem, { onSelect: () => {
1365
1704
  var _a;
1366
1705
  return (_a = mdFileInputRef.current) == null ? void 0 : _a.click();
1367
- }, children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1368
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: "M↓" }),
1706
+ }, children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1707
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: "M↓" }),
1369
1708
  t.importMarkdown
1370
1709
  ] }) }),
1371
1710
  extraToolbarItems == null ? void 0 : extraToolbarItems.map((item2) => /* @__PURE__ */ jsx(
@@ -1373,8 +1712,8 @@ function EditorToolbar({
1373
1712
  {
1374
1713
  disabled: item2.disabled,
1375
1714
  onSelect: () => item2.onSelect(editor),
1376
- children: /* @__PURE__ */ jsxs("span", { className: styles$2.styleItem, children: [
1377
- /* @__PURE__ */ jsx("span", { className: styles$2.styleIcon, children: item2.icon }),
1715
+ children: /* @__PURE__ */ jsxs("span", { className: styles$3.styleItem, children: [
1716
+ /* @__PURE__ */ jsx("span", { className: styles$3.styleIcon, children: item2.icon }),
1378
1717
  item2.label
1379
1718
  ] })
1380
1719
  },
@@ -1400,7 +1739,7 @@ function EditorToolbar({
1400
1739
  /* @__PURE__ */ jsxs(
1401
1740
  "div",
1402
1741
  {
1403
- className: styles$2.tableBubble,
1742
+ className: styles$3.tableBubble,
1404
1743
  style: { position: "fixed", left: tableMenu.x, top: tableMenu.y },
1405
1744
  onMouseDown: (e) => e.stopPropagation(),
1406
1745
  onContextMenu: (e) => e.preventDefault(),
@@ -1492,7 +1831,7 @@ const chevron = "_chevron_euqdt_159";
1492
1831
  const chevronUp = "_chevronUp_euqdt_166";
1493
1832
  const mobilePanel = "_mobilePanel_euqdt_170";
1494
1833
  const mobilePanelOpen = "_mobilePanelOpen_euqdt_176";
1495
- const styles = {
1834
+ const styles$1 = {
1496
1835
  desktop,
1497
1836
  header,
1498
1837
  headerTitle,
@@ -1534,17 +1873,17 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
1534
1873
  });
1535
1874
  }, [activeId]);
1536
1875
  if (!items.length) return null;
1537
- const minLevel = Math.min(...items.map((i) => i.level));
1876
+ const minLevel = Math.min(...items.map((i2) => i2.level));
1538
1877
  const handleClick = (item2) => {
1539
1878
  if (item2.locked) return;
1540
1879
  onItemClick == null ? void 0 : onItemClick(item2);
1541
1880
  if (isMobile) setMobileOpen(false);
1542
1881
  };
1543
- const list2 = /* @__PURE__ */ jsx("ul", { className: styles.list, children: items.map((item2) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
1882
+ const list2 = /* @__PURE__ */ jsx("ul", { className: styles$1.list, children: items.map((item2) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
1544
1883
  "a",
1545
1884
  {
1546
1885
  href: item2.locked ? void 0 : `#${item2.id}`,
1547
- className: `${styles.item} ${item2.id === activeId ? styles.active : ""} ${item2.locked ? styles.locked : ""}`,
1886
+ className: `${styles$1.item} ${item2.id === activeId ? styles$1.active : ""} ${item2.locked ? styles$1.locked : ""}`,
1548
1887
  style: { paddingLeft: `${(item2.level - minLevel) * 12 + 12}px` },
1549
1888
  "aria-current": item2.id === activeId ? "true" : void 0,
1550
1889
  "aria-disabled": item2.locked ? "true" : void 0,
@@ -1553,27 +1892,27 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
1553
1892
  handleClick(item2);
1554
1893
  },
1555
1894
  children: [
1556
- /* @__PURE__ */ jsx("span", { className: styles.itemText, children: item2.text }),
1557
- item2.locked ? /* @__PURE__ */ jsx(LockIcon, { className: styles.lockIcon, "aria-hidden": true }) : null
1895
+ /* @__PURE__ */ jsx("span", { className: styles$1.itemText, children: item2.text }),
1896
+ item2.locked ? /* @__PURE__ */ jsx(LockIcon, { className: styles$1.lockIcon, "aria-hidden": true }) : null
1558
1897
  ]
1559
1898
  }
1560
1899
  ) }, item2.id)) });
1561
1900
  if (isMobile) {
1562
- return /* @__PURE__ */ jsxs("nav", { className: styles.mobile, "aria-label": t.title, children: [
1901
+ return /* @__PURE__ */ jsxs("nav", { className: styles$1.mobile, "aria-label": t.title, children: [
1563
1902
  /* @__PURE__ */ jsxs(
1564
1903
  "button",
1565
1904
  {
1566
1905
  type: "button",
1567
- className: styles.mobileBar,
1906
+ className: styles$1.mobileBar,
1568
1907
  "aria-expanded": mobileOpen,
1569
1908
  onClick: () => setMobileOpen((v) => !v),
1570
1909
  children: [
1571
- /* @__PURE__ */ jsx(MenuIcon, { className: styles.mobileBarIcon, "aria-hidden": true }),
1910
+ /* @__PURE__ */ jsx(MenuIcon, { className: styles$1.mobileBarIcon, "aria-hidden": true }),
1572
1911
  /* @__PURE__ */ jsx("span", { children: t.title }),
1573
1912
  /* @__PURE__ */ jsx(
1574
1913
  "span",
1575
1914
  {
1576
- className: `${styles.chevron} ${mobileOpen ? styles.chevronUp : ""}`,
1915
+ className: `${styles$1.chevron} ${mobileOpen ? styles$1.chevronUp : ""}`,
1577
1916
  "aria-hidden": true,
1578
1917
  children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
1579
1918
  }
@@ -1585,7 +1924,7 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
1585
1924
  "div",
1586
1925
  {
1587
1926
  ref: mobilePanelRef,
1588
- className: `${styles.mobilePanel} ${mobileOpen ? styles.mobilePanelOpen : ""}`,
1927
+ className: `${styles$1.mobilePanel} ${mobileOpen ? styles$1.mobilePanelOpen : ""}`,
1589
1928
  children: list2
1590
1929
  }
1591
1930
  )
@@ -1596,7 +1935,7 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
1596
1935
  "button",
1597
1936
  {
1598
1937
  type: "button",
1599
- className: styles.collapsedRail,
1938
+ className: styles$1.collapsedRail,
1600
1939
  "aria-label": t.expand,
1601
1940
  title: t.expand,
1602
1941
  onClick: () => setCollapsed(false),
@@ -1604,14 +1943,14 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
1604
1943
  }
1605
1944
  );
1606
1945
  }
1607
- return /* @__PURE__ */ jsxs("nav", { className: styles.desktop, "aria-label": t.title, ref: desktopNavRef, children: [
1608
- /* @__PURE__ */ jsxs("div", { className: styles.header, children: [
1609
- /* @__PURE__ */ jsx("span", { className: styles.headerTitle, children: t.title }),
1946
+ return /* @__PURE__ */ jsxs("nav", { className: styles$1.desktop, "aria-label": t.title, ref: desktopNavRef, children: [
1947
+ /* @__PURE__ */ jsxs("div", { className: styles$1.header, children: [
1948
+ /* @__PURE__ */ jsx("span", { className: styles$1.headerTitle, children: t.title }),
1610
1949
  /* @__PURE__ */ jsx(
1611
1950
  "button",
1612
1951
  {
1613
1952
  type: "button",
1614
- className: styles.collapseBtn,
1953
+ className: styles$1.collapseBtn,
1615
1954
  "aria-label": t.collapse,
1616
1955
  title: t.collapse,
1617
1956
  onClick: () => setCollapsed(true),
@@ -1736,8 +2075,49 @@ function scrollToTocHeading(headingId, scrollContainer, options) {
1736
2075
  };
1737
2076
  requestAnimationFrame(animate);
1738
2077
  }
2078
+ const popoverAnchor = "_popoverAnchor_1ceh7_57";
2079
+ const popoverContent = "_popoverContent_1ceh7_64";
2080
+ const styles = {
2081
+ popoverAnchor,
2082
+ popoverContent
2083
+ };
2084
+ function CommentPopover({
2085
+ open,
2086
+ onOpenChange,
2087
+ anchorEl,
2088
+ children,
2089
+ side = "top",
2090
+ align = "start",
2091
+ sideOffset = 6
2092
+ }) {
2093
+ const rect = open && anchorEl ? anchorEl.getBoundingClientRect() : null;
2094
+ return /* @__PURE__ */ jsxs(Popover.Root, { open, onOpenChange, children: [
2095
+ rect && /* @__PURE__ */ jsx(Popover.Anchor, { asChild: true, children: /* @__PURE__ */ jsx(
2096
+ "span",
2097
+ {
2098
+ className: styles.popoverAnchor,
2099
+ style: { left: rect.left, top: rect.top }
2100
+ }
2101
+ ) }),
2102
+ /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(
2103
+ Popover.Content,
2104
+ {
2105
+ className: styles.popoverContent,
2106
+ side,
2107
+ align,
2108
+ sideOffset,
2109
+ onOpenAutoFocus: (e) => e.preventDefault(),
2110
+ onCloseAutoFocus: (e) => e.preventDefault(),
2111
+ children
2112
+ }
2113
+ ) })
2114
+ ] });
2115
+ }
1739
2116
  export {
1740
2117
  BoldIcon,
2118
+ COMMENT_ACTIVE_META,
2119
+ COMMENT_CLICK_META,
2120
+ COMMENT_GUTTER_META,
1741
2121
  CheckIcon,
1742
2122
  ChevronDownIcon,
1743
2123
  CitationInteractive,
@@ -1748,6 +2128,8 @@ export {
1748
2128
  ColumnAfterIcon,
1749
2129
  ColumnBeforeIcon,
1750
2130
  ColumnDeleteIcon,
2131
+ CommentMark,
2132
+ CommentPopover,
1751
2133
  EditorToolbar,
1752
2134
  ImageIcon,
1753
2135
  ItalicIcon,
@@ -1772,24 +2154,37 @@ export {
1772
2154
  TrashIcon,
1773
2155
  UnderlineIcon,
1774
2156
  UndoIcon,
1775
- c as applyCitationSources,
2157
+ g as applyCitationSources,
2158
+ applyCommentAnchorsToEditor,
1776
2159
  baseExtensions,
2160
+ h as blockTextHash,
2161
+ collectCommentIds,
2162
+ commentAnchorExtension,
2163
+ commentAnchorPlugin,
2164
+ commentAnchorPluginKey,
2165
+ commentRangesById,
1777
2166
  createCitationRef,
1778
2167
  defaultCodeBlockLabels,
1779
2168
  defaultColorPaletteLabels,
2169
+ defaultCommentLabels,
1780
2170
  defaultTocLabels,
1781
2171
  defaultToolbarLabels,
1782
2172
  enrichMarkdownCitations,
1783
- d as extractToc,
2173
+ i as extractToc,
1784
2174
  findCitationRefElement,
2175
+ focusComment,
1785
2176
  insertMarkdown,
1786
2177
  looksLikeMarkdown,
1787
2178
  lowlight,
1788
2179
  makeTocGetId,
2180
+ mapCommentAnchors,
2181
+ mergeCommentIntervals,
2182
+ nextComment,
1789
2183
  pureCodeBlock,
1790
2184
  pureImage,
1791
2185
  readCitationAttrs,
1792
2186
  scrollToTocHeading,
2187
+ stripCommentAnchorMarks,
1793
2188
  useIsMobile
1794
2189
  };
1795
2190
  //# sourceMappingURL=index.js.map