tiptap-markdown-react 0.8.10 → 0.8.11

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
@@ -6,8 +6,10 @@ 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
8
  import { forwardRef, useEffect, useRef, useImperativeHandle, useMemo, useState, useId, 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 renderMathInto, g as subscribeMathClick, R as ReportContent } from "./extractToc-DiY1iu1J.js";
10
- import { h, i, j, k } from "./extractToc-DiY1iu1J.js";
9
+ import { e as enrichMarkdownCitations, s as styles$5 } from "./ReportContent-c_UlJnVY.js";
10
+ import { R, a } from "./ReportContent-c_UlJnVY.js";
11
+ import { C as CitationRef, g as mergeCommentIntervals, f as mapCommentAnchors, b as baseExtensions, c as CommentMark, l as lowlight, m as makeTocGetId, p as pureCodeBlock, a as pureImage, h as renderMathInto, i as subscribeMathClick } from "./extractToc-CecK9W_w.js";
12
+ import { d, e, s } from "./extractToc-CecK9W_w.js";
11
13
  import { Slice, Fragment } from "@tiptap/pm/model";
12
14
  import { Extension, Node as Node$1 } from "@tiptap/core";
13
15
  import { PluginKey, Plugin } from "@tiptap/pm/state";
@@ -16,6 +18,7 @@ import { FileHandlePlugin } from "@tiptap/extension-file-handler";
16
18
  import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
17
19
  import * as Popover from "@radix-ui/react-popover";
18
20
  import { createPortal } from "react-dom";
21
+ import { C, R as R2, f, r, s as s2 } from "./scrollToTocHeading-CwapFaVP.js";
19
22
  function CitationRefView({ node, extension }) {
20
23
  const index = String(node.attrs.index ?? "");
21
24
  const url = node.attrs.url || null;
@@ -132,7 +135,7 @@ function collectCommentRanges(doc) {
132
135
  return byId;
133
136
  }
134
137
  function rangesIntersectBlock(ranges, start, end) {
135
- return ranges.some((r) => r.from < end && r.to > start);
138
+ return ranges.some((r2) => r2.from < end && r2.to > start);
136
139
  }
137
140
  function gutterDom(commentIds, view, blockPos) {
138
141
  const el = document.createElement("span");
@@ -140,13 +143,13 @@ function gutterDom(commentIds, view, blockPos) {
140
143
  el.setAttribute("data-comment-ids", commentIds.join(" "));
141
144
  el.textContent = String(commentIds.length);
142
145
  el.title = `${commentIds.length}`;
143
- el.addEventListener("mousedown", (e) => {
144
- e.preventDefault();
145
- e.stopPropagation();
146
+ el.addEventListener("mousedown", (e2) => {
147
+ e2.preventDefault();
148
+ e2.stopPropagation();
146
149
  });
147
- el.addEventListener("click", (e) => {
148
- e.preventDefault();
149
- e.stopPropagation();
150
+ el.addEventListener("click", (e2) => {
151
+ e2.preventDefault();
152
+ e2.stopPropagation();
150
153
  view.dispatch(
151
154
  view.state.tr.setMeta(COMMENT_ACTIVE_META, commentIds[0] ?? null).setMeta(COMMENT_GUTTER_META, {
152
155
  commentIds,
@@ -197,9 +200,9 @@ function commentAnchorPlugin(options = {}) {
197
200
  const activeId = ((_a = commentAnchorPluginKey.getState(state)) == null ? void 0 : _a.activeCommentId) ?? null;
198
201
  if (activeId) {
199
202
  const ranges = byId.get(activeId) ?? [];
200
- for (const r of ranges) {
203
+ for (const r2 of ranges) {
201
204
  decos.push(
202
- Decoration.inline(r.from, r.to, { class: "tmr-comment-active" })
205
+ Decoration.inline(r2.from, r2.to, { class: "tmr-comment-active" })
203
206
  );
204
207
  }
205
208
  for (const b of bounds) {
@@ -258,7 +261,7 @@ function applyCommentAnchorsToEditor(editor, comments) {
258
261
  mapCommentAnchors(
259
262
  editor.state.doc,
260
263
  comments.map((c) => ({ commentId: c.commentId, segments: c.segments }))
261
- ).map((r) => ({ commentId: r.commentId, ranges: r.ranges }))
264
+ ).map((r2) => ({ commentId: r2.commentId, ranges: r2.ranges }))
262
265
  ) : [];
263
266
  const chain = editor.chain().clearCommentAnchors();
264
267
  if (intervals.length > 0) chain.applyCommentAnchors(intervals);
@@ -412,11 +415,11 @@ const ImportPlaceholder = Node$1.create({
412
415
  const MD_FILE_RE$1 = /\.(md|markdown)$/i;
413
416
  const MD_MIME_TYPES = ["text/markdown", "text/x-markdown", ""];
414
417
  async function insertMarkdownFiles(editor, files, pos) {
415
- const mdFiles = files.filter((f) => MD_FILE_RE$1.test(f.name));
418
+ const mdFiles = files.filter((f2) => MD_FILE_RE$1.test(f2.name));
416
419
  if (mdFiles.length === 0) return;
417
420
  const markdown = editor.markdown;
418
421
  if (!markdown) return;
419
- const texts = await Promise.all(mdFiles.map((f) => f.text()));
422
+ const texts = await Promise.all(mdFiles.map((f2) => f2.text()));
420
423
  const json = markdown.parse(texts.join("\n\n"));
421
424
  if (pos != null) {
422
425
  editor.chain().focus().insertContentAt(pos, json).run();
@@ -924,7 +927,7 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
924
927
  getId: makeTocGetId(),
925
928
  onUpdate: (anchors) => {
926
929
  onTocChange == null ? void 0 : onTocChange(
927
- anchors.filter((a) => a.level <= 6).map((a) => ({ id: a.id, level: a.level, text: a.textContent }))
930
+ anchors.filter((a2) => a2.level <= 6).map((a2) => ({ id: a2.id, level: a2.level, text: a2.textContent }))
928
931
  );
929
932
  }
930
933
  }),
@@ -1124,9 +1127,9 @@ function insertPlainParagraph(editor, text) {
1124
1127
  }
1125
1128
  function splitTopLevelBlocks(markdown) {
1126
1129
  const out = [];
1127
- for (const [i2, part] of markdown.split(/(```[\s\S]*?```)/).entries()) {
1130
+ for (const [i, part] of markdown.split(/(```[\s\S]*?```)/).entries()) {
1128
1131
  if (!part) continue;
1129
- if (i2 % 2 === 1) {
1132
+ if (i % 2 === 1) {
1130
1133
  out.push(part);
1131
1134
  continue;
1132
1135
  }
@@ -1245,7 +1248,7 @@ function ColorPalette({ value, onPick, labels }) {
1245
1248
  {
1246
1249
  type: "button",
1247
1250
  className: styles$2.noneRow,
1248
- onMouseDown: (e) => e.preventDefault(),
1251
+ onMouseDown: (e2) => e2.preventDefault(),
1249
1252
  onClick: () => onPick(null),
1250
1253
  children: [
1251
1254
  /* @__PURE__ */ jsx("span", { className: styles$2.noneIcon, "aria-hidden": true }),
@@ -1261,7 +1264,7 @@ function ColorPalette({ value, onPick, labels }) {
1261
1264
  style: { background: c },
1262
1265
  title: c,
1263
1266
  "aria-label": c,
1264
- onMouseDown: (e) => e.preventDefault(),
1267
+ onMouseDown: (e2) => e2.preventDefault(),
1265
1268
  onClick: () => onPick(c)
1266
1269
  },
1267
1270
  c
@@ -1275,7 +1278,7 @@ function ColorPalette({ value, onPick, labels }) {
1275
1278
  style: { background: c },
1276
1279
  title: c,
1277
1280
  "aria-label": c,
1278
- onMouseDown: (e) => e.preventDefault(),
1281
+ onMouseDown: (e2) => e2.preventDefault(),
1279
1282
  onClick: () => onPick(c)
1280
1283
  },
1281
1284
  c
@@ -1302,8 +1305,8 @@ function getMathLayerStyle(editor, kind, pos) {
1302
1305
  if (pos != null) {
1303
1306
  const el = resolveNodeEl(editor, pos);
1304
1307
  if (el) {
1305
- const r = el.getBoundingClientRect();
1306
- const top = r.bottom - hostRect.top + gap;
1308
+ const r2 = el.getBoundingClientRect();
1309
+ const top = r2.bottom - hostRect.top + gap;
1307
1310
  if (kind === "block") {
1308
1311
  return {
1309
1312
  left: editorRect.left - hostRect.left,
@@ -1312,7 +1315,7 @@ function getMathLayerStyle(editor, kind, pos) {
1312
1315
  };
1313
1316
  }
1314
1317
  return {
1315
- left: r.left - hostRect.left,
1318
+ left: r2.left - hostRect.left,
1316
1319
  top
1317
1320
  };
1318
1321
  }
@@ -1395,9 +1398,9 @@ function MathEditorPopover({
1395
1398
  };
1396
1399
  }, [pos, editor, isBlock, latex, isNew]);
1397
1400
  useEffect(() => {
1398
- const onPtr = (e) => {
1401
+ const onPtr = (e2) => {
1399
1402
  var _a;
1400
- const target = e.target;
1403
+ const target = e2.target;
1401
1404
  if (!(target instanceof Node)) return;
1402
1405
  if ((_a = rootRef.current) == null ? void 0 : _a.contains(target)) return;
1403
1406
  if (pos != null) {
@@ -1415,15 +1418,15 @@ function MathEditorPopover({
1415
1418
  if (!canSubmit) return;
1416
1419
  onConfirm(draft.trim());
1417
1420
  };
1418
- const onKeyDown = (e) => {
1419
- if (e.key === "Escape") {
1420
- e.preventDefault();
1421
+ const onKeyDown = (e2) => {
1422
+ if (e2.key === "Escape") {
1423
+ e2.preventDefault();
1421
1424
  onCancel();
1422
1425
  return;
1423
1426
  }
1424
- if (e.key !== "Enter") return;
1425
- if (isBlock && !(e.metaKey || e.ctrlKey)) return;
1426
- e.preventDefault();
1427
+ if (e2.key !== "Enter") return;
1428
+ if (isBlock && !(e2.metaKey || e2.ctrlKey)) return;
1429
+ e2.preventDefault();
1427
1430
  submit();
1428
1431
  };
1429
1432
  const field = isBlock ? /* @__PURE__ */ jsx(
@@ -1435,7 +1438,7 @@ function MathEditorPopover({
1435
1438
  placeholder,
1436
1439
  rows: Math.max(3, draft.split("\n").length),
1437
1440
  "aria-labelledby": titleId,
1438
- onChange: (e) => setDraft(e.target.value),
1441
+ onChange: (e2) => setDraft(e2.target.value),
1439
1442
  onKeyDown
1440
1443
  }
1441
1444
  ) : /* @__PURE__ */ jsx(
@@ -1446,7 +1449,7 @@ function MathEditorPopover({
1446
1449
  value: draft,
1447
1450
  placeholder,
1448
1451
  "aria-labelledby": titleId,
1449
- onChange: (e) => setDraft(e.target.value),
1452
+ onChange: (e2) => setDraft(e2.target.value),
1450
1453
  onKeyDown
1451
1454
  }
1452
1455
  );
@@ -1527,7 +1530,7 @@ function ToolbarButton({
1527
1530
  "aria-busy": busy,
1528
1531
  disabled,
1529
1532
  className: `${styles$3.btn} ${active2 ? styles$3.btnActive : ""}`,
1530
- onMouseDown: (e) => e.preventDefault(),
1533
+ onMouseDown: (e2) => e2.preventDefault(),
1531
1534
  onClick,
1532
1535
  children
1533
1536
  }
@@ -1552,8 +1555,8 @@ function MenuPopover({
1552
1555
  className: styles$3.menu,
1553
1556
  sideOffset: 4,
1554
1557
  align: "start",
1555
- onOpenAutoFocus: (e) => e.preventDefault(),
1556
- onCloseAutoFocus: (e) => e.preventDefault(),
1558
+ onOpenAutoFocus: (e2) => e2.preventDefault(),
1559
+ onCloseAutoFocus: (e2) => e2.preventDefault(),
1557
1560
  children: /* @__PURE__ */ jsx(MenuCloseCtx.Provider, { value: close, children })
1558
1561
  }
1559
1562
  ) })
@@ -1572,7 +1575,7 @@ function MenuItem({
1572
1575
  type: "button",
1573
1576
  disabled,
1574
1577
  className: `${styles$3.menuItem} ${selected ? styles$3.menuItemSelected : ""}`,
1575
- onMouseDown: (e) => e.preventDefault(),
1578
+ onMouseDown: (e2) => e2.preventDefault(),
1576
1579
  onClick: () => {
1577
1580
  onSelect();
1578
1581
  close();
@@ -1598,7 +1601,7 @@ function ColorPopover({
1598
1601
  className: styles$3.btn,
1599
1602
  title,
1600
1603
  "aria-label": title,
1601
- onMouseDown: (e) => e.preventDefault(),
1604
+ onMouseDown: (e2) => e2.preventDefault(),
1602
1605
  children: /* @__PURE__ */ jsxs("span", { className: styles$3.colorIcon, children: [
1603
1606
  /* @__PURE__ */ jsx("span", { className: styles$3.colorIconGlyph, children: glyph }),
1604
1607
  /* @__PURE__ */ jsx("span", { className: styles$3.colorIconBar, style: { background: bar } })
@@ -1611,8 +1614,8 @@ function ColorPopover({
1611
1614
  className: styles$3.popoverContent,
1612
1615
  sideOffset: 4,
1613
1616
  align: "start",
1614
- onOpenAutoFocus: (e) => e.preventDefault(),
1615
- onCloseAutoFocus: (e) => e.preventDefault(),
1617
+ onOpenAutoFocus: (e2) => e2.preventDefault(),
1618
+ onCloseAutoFocus: (e2) => e2.preventDefault(),
1616
1619
  children: /* @__PURE__ */ jsx(
1617
1620
  ColorPalette,
1618
1621
  {
@@ -1645,30 +1648,30 @@ function EditorToolbar({
1645
1648
  const t = { ...defaultToolbarLabels, ...labels };
1646
1649
  const state = useEditorState({
1647
1650
  editor,
1648
- selector: ({ editor: e }) => ({
1649
- bold: e.isActive("bold"),
1650
- italic: e.isActive("italic"),
1651
- underline: e.isActive("underline"),
1652
- strike: e.isActive("strike"),
1653
- code: e.isActive("code"),
1654
- link: e.isActive("link"),
1655
- taskList: e.isActive("taskList"),
1651
+ selector: ({ editor: e2 }) => ({
1652
+ bold: e2.isActive("bold"),
1653
+ italic: e2.isActive("italic"),
1654
+ underline: e2.isActive("underline"),
1655
+ strike: e2.isActive("strike"),
1656
+ code: e2.isActive("code"),
1657
+ link: e2.isActive("link"),
1658
+ taskList: e2.isActive("taskList"),
1656
1659
  headingLevel: [1, 2, 3, 4, 5, 6].find(
1657
- (lv) => e.isActive("heading", { level: lv })
1660
+ (lv) => e2.isActive("heading", { level: lv })
1658
1661
  ),
1659
- fontSize: e.getAttributes("textStyle").fontSize || void 0,
1660
- isParagraph: e.isActive("paragraph"),
1661
- bulletList: e.isActive("bulletList"),
1662
- orderedList: e.isActive("orderedList"),
1663
- blockquote: e.isActive("blockquote"),
1664
- textColor: e.getAttributes("textStyle").color || void 0,
1665
- highlightColor: e.getAttributes("highlight").color || void 0,
1666
- superscript: e.isActive("superscript"),
1667
- subscript: e.isActive("subscript"),
1668
- inTable: e.isActive("table"),
1669
- inTableHeader: e.isActive("tableHeader"),
1670
- canUndo: e.can().undo(),
1671
- canRedo: e.can().redo()
1662
+ fontSize: e2.getAttributes("textStyle").fontSize || void 0,
1663
+ isParagraph: e2.isActive("paragraph"),
1664
+ bulletList: e2.isActive("bulletList"),
1665
+ orderedList: e2.isActive("orderedList"),
1666
+ blockquote: e2.isActive("blockquote"),
1667
+ textColor: e2.getAttributes("textStyle").color || void 0,
1668
+ highlightColor: e2.getAttributes("highlight").color || void 0,
1669
+ superscript: e2.isActive("superscript"),
1670
+ subscript: e2.isActive("subscript"),
1671
+ inTable: e2.isActive("table"),
1672
+ inTableHeader: e2.isActive("tableHeader"),
1673
+ canUndo: e2.can().undo(),
1674
+ canRedo: e2.can().redo()
1672
1675
  })
1673
1676
  });
1674
1677
  const [editorFocused, setEditorFocused] = useState(() => editor.isFocused);
@@ -1690,32 +1693,32 @@ function EditorToolbar({
1690
1693
  const closeTableMenu = useCallback(() => setTableMenu(null), []);
1691
1694
  useEffect(() => {
1692
1695
  const dom = editor.view.dom;
1693
- const onContextMenu = (e) => {
1696
+ const onContextMenu = (e2) => {
1694
1697
  const coords = editor.view.posAtCoords({
1695
- left: e.clientX,
1696
- top: e.clientY
1698
+ left: e2.clientX,
1699
+ top: e2.clientY
1697
1700
  });
1698
1701
  if (!coords) return;
1699
1702
  const $pos = editor.state.doc.resolve(coords.pos);
1700
1703
  let inTable = false;
1701
- for (let d = $pos.depth; d > 0; d--) {
1702
- if ($pos.node(d).type.name === "table") {
1704
+ for (let d2 = $pos.depth; d2 > 0; d2--) {
1705
+ if ($pos.node(d2).type.name === "table") {
1703
1706
  inTable = true;
1704
1707
  break;
1705
1708
  }
1706
1709
  }
1707
1710
  if (!inTable) return;
1708
- e.preventDefault();
1711
+ e2.preventDefault();
1709
1712
  editor.chain().focus().setTextSelection(coords.pos).run();
1710
- setTableMenu({ x: e.clientX, y: e.clientY });
1713
+ setTableMenu({ x: e2.clientX, y: e2.clientY });
1711
1714
  };
1712
1715
  dom.addEventListener("contextmenu", onContextMenu);
1713
1716
  return () => dom.removeEventListener("contextmenu", onContextMenu);
1714
1717
  }, [editor]);
1715
1718
  useEffect(() => {
1716
1719
  if (!tableMenu) return;
1717
- const onKey = (e) => {
1718
- if (e.key === "Escape") closeTableMenu();
1720
+ const onKey = (e2) => {
1721
+ if (e2.key === "Escape") closeTableMenu();
1719
1722
  };
1720
1723
  document.addEventListener("mousedown", closeTableMenu);
1721
1724
  document.addEventListener("keydown", onKey, true);
@@ -1735,10 +1738,10 @@ function EditorToolbar({
1735
1738
  var _a;
1736
1739
  return (_a = fileInputRef.current) == null ? void 0 : _a.click();
1737
1740
  };
1738
- const handleImageChange = async (e) => {
1741
+ const handleImageChange = async (e2) => {
1739
1742
  var _a;
1740
- const file = (_a = e.target.files) == null ? void 0 : _a[0];
1741
- e.target.value = "";
1743
+ const file = (_a = e2.target.files) == null ? void 0 : _a[0];
1744
+ e2.target.value = "";
1742
1745
  if (!file || !onImageUpload) return;
1743
1746
  try {
1744
1747
  const url = await onImageUpload(file);
@@ -1758,10 +1761,10 @@ function EditorToolbar({
1758
1761
  var _a;
1759
1762
  return (_a = importAbortRef.current) == null ? void 0 : _a.abort();
1760
1763
  }, []);
1761
- const handleImportChange = async (e) => {
1764
+ const handleImportChange = async (e2) => {
1762
1765
  var _a;
1763
- const file = (_a = e.target.files) == null ? void 0 : _a[0];
1764
- e.target.value = "";
1766
+ const file = (_a = e2.target.files) == null ? void 0 : _a[0];
1767
+ e2.target.value = "";
1765
1768
  if (!file) return;
1766
1769
  if (MD_FILE_RE.test(file.name)) {
1767
1770
  try {
@@ -1948,7 +1951,7 @@ function EditorToolbar({
1948
1951
  type: "button",
1949
1952
  className: styles$3.styleTrigger,
1950
1953
  title: t.style,
1951
- onMouseDown: (e) => e.preventDefault(),
1954
+ onMouseDown: (e2) => e2.preventDefault(),
1952
1955
  children: [
1953
1956
  /* @__PURE__ */ jsx("span", { className: styles$3.styleTriggerLabel, children: t.style }),
1954
1957
  /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
@@ -1993,7 +1996,7 @@ function EditorToolbar({
1993
1996
  title: t.fontSize,
1994
1997
  "aria-label": t.fontSize,
1995
1998
  disabled: !canEditFontSize,
1996
- onMouseDown: (e) => e.preventDefault(),
1999
+ onMouseDown: (e2) => e2.preventDefault(),
1997
2000
  children: [
1998
2001
  /* @__PURE__ */ jsx("span", { className: styles$3.styleTriggerLabel, children: state.fontSize || t.fontSize }),
1999
2002
  /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
@@ -2105,7 +2108,7 @@ function EditorToolbar({
2105
2108
  className: `${styles$3.scriptTrigger} ${scriptActive !== "normal" ? styles$3.btnActive : ""}`,
2106
2109
  title: t.scriptMenu,
2107
2110
  "aria-label": t.scriptMenu,
2108
- onMouseDown: (e) => e.preventDefault(),
2111
+ onMouseDown: (e2) => e2.preventDefault(),
2109
2112
  children: [
2110
2113
  /* @__PURE__ */ jsx("span", { className: styles$3.scriptTriggerGlyph, children: "A" }),
2111
2114
  /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
@@ -2182,7 +2185,7 @@ function EditorToolbar({
2182
2185
  "aria-label": importTitle,
2183
2186
  "aria-busy": !!importing,
2184
2187
  disabled: !!importing,
2185
- onMouseDown: (e) => e.preventDefault(),
2188
+ onMouseDown: (e2) => e2.preventDefault(),
2186
2189
  children: [
2187
2190
  /* @__PURE__ */ jsx("span", { className: styles$3.styleTriggerLabel, children: t.importDocument }),
2188
2191
  /* @__PURE__ */ jsx(
@@ -2252,7 +2255,7 @@ function EditorToolbar({
2252
2255
  type: "button",
2253
2256
  className: styles$3.styleTrigger,
2254
2257
  title: t.more,
2255
- onMouseDown: (e) => e.preventDefault(),
2258
+ onMouseDown: (e2) => e2.preventDefault(),
2256
2259
  children: [
2257
2260
  /* @__PURE__ */ jsx("span", { className: styles$3.styleTriggerLabel, children: t.more }),
2258
2261
  /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$3.styleTriggerCaret })
@@ -2336,8 +2339,8 @@ function EditorToolbar({
2336
2339
  {
2337
2340
  className: styles$3.tableBubble,
2338
2341
  style: { position: "fixed", left: tableMenu.x, top: tableMenu.y },
2339
- onMouseDown: (e) => e.stopPropagation(),
2340
- onContextMenu: (e) => e.preventDefault(),
2342
+ onMouseDown: (e2) => e2.stopPropagation(),
2343
+ onContextMenu: (e2) => e2.preventDefault(),
2341
2344
  children: [
2342
2345
  /* @__PURE__ */ jsx(
2343
2346
  ToolbarButton,
@@ -2468,7 +2471,7 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
2468
2471
  });
2469
2472
  }, [activeId]);
2470
2473
  if (!items.length) return null;
2471
- const minLevel = Math.min(...items.map((i2) => i2.level));
2474
+ const minLevel = Math.min(...items.map((i) => i.level));
2472
2475
  const handleClick = (item2) => {
2473
2476
  if (item2.locked) return;
2474
2477
  onItemClick == null ? void 0 : onItemClick(item2);
@@ -2482,8 +2485,8 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
2482
2485
  style: { paddingLeft: `${(item2.level - minLevel) * 12 + 12}px` },
2483
2486
  "aria-current": item2.id === activeId ? "true" : void 0,
2484
2487
  "aria-disabled": item2.locked ? "true" : void 0,
2485
- onClick: (e) => {
2486
- e.preventDefault();
2488
+ onClick: (e2) => {
2489
+ e2.preventDefault();
2487
2490
  handleClick(item2);
2488
2491
  },
2489
2492
  children: [
@@ -2556,120 +2559,6 @@ function TocPanel({ items, activeId, onItemClick, labels }) {
2556
2559
  list2
2557
2560
  ] });
2558
2561
  }
2559
- function findCitationRefElement(target, root) {
2560
- let node = null;
2561
- if (target instanceof Element) node = target;
2562
- else if (target instanceof Text) node = target.parentElement;
2563
- else if (target instanceof Node) node = target.parentElement;
2564
- if (!(node instanceof Element)) return null;
2565
- const el = node.closest(".citation-ref");
2566
- if (!(el instanceof HTMLElement)) return null;
2567
- if (!root.contains(el)) return null;
2568
- return el;
2569
- }
2570
- function readCitationAttrs(el) {
2571
- var _a;
2572
- return {
2573
- index: el.getAttribute("data-index") || ((_a = el.textContent) == null ? void 0 : _a.trim()) || "",
2574
- url: el.getAttribute("data-url"),
2575
- title: el.getAttribute("data-title")
2576
- };
2577
- }
2578
- function CitationInteractive({
2579
- containerRef,
2580
- onCitationEnter,
2581
- onCitationLeave
2582
- }) {
2583
- const enterRef = useRef(onCitationEnter);
2584
- const leaveRef = useRef(onCitationLeave);
2585
- enterRef.current = onCitationEnter;
2586
- leaveRef.current = onCitationLeave;
2587
- useEffect(() => {
2588
- const root = containerRef.current;
2589
- if (!root) return;
2590
- let currentEl = null;
2591
- const emitEnter = (el) => {
2592
- currentEl = el;
2593
- const attrs = readCitationAttrs(el);
2594
- enterRef.current({ index: attrs.index, attrs, anchorEl: el });
2595
- };
2596
- const emitLeave = () => {
2597
- if (!currentEl) return;
2598
- currentEl = null;
2599
- leaveRef.current();
2600
- };
2601
- const ACTIVE_ATTR = "data-tmr-citation-active";
2602
- const onClick = (e) => {
2603
- const el = findCitationRefElement(e.target, root);
2604
- if (el) {
2605
- e.preventDefault();
2606
- e.stopPropagation();
2607
- if (el === currentEl && el.hasAttribute(ACTIVE_ATTR)) {
2608
- emitLeave();
2609
- return;
2610
- }
2611
- emitEnter(el);
2612
- return;
2613
- }
2614
- emitLeave();
2615
- };
2616
- const onKeyDown = (e) => {
2617
- if (e.key === "Escape") emitLeave();
2618
- };
2619
- root.addEventListener("click", onClick, true);
2620
- document.addEventListener("keydown", onKeyDown);
2621
- return () => {
2622
- root.removeEventListener("click", onClick, true);
2623
- document.removeEventListener("keydown", onKeyDown);
2624
- };
2625
- }, [containerRef]);
2626
- return null;
2627
- }
2628
- function ReportContentInteractive({
2629
- onCitationEnter,
2630
- onCitationLeave,
2631
- className,
2632
- html,
2633
- ...rest
2634
- }) {
2635
- const ref = useRef(null);
2636
- return /* @__PURE__ */ jsxs("div", { ref, className, children: [
2637
- /* @__PURE__ */ jsx(ReportContent, { html, ...rest }),
2638
- /* @__PURE__ */ jsx(
2639
- CitationInteractive,
2640
- {
2641
- containerRef: ref,
2642
- onCitationEnter,
2643
- onCitationLeave
2644
- }
2645
- )
2646
- ] });
2647
- }
2648
- function easeOutCubic(t) {
2649
- return 1 - (1 - t) * (1 - t) * (1 - t);
2650
- }
2651
- function scrollToTocHeading(headingId, scrollContainer, options) {
2652
- const el = scrollContainer.querySelector(
2653
- `[data-toc-id="${CSS.escape(headingId)}"]`
2654
- );
2655
- if (!el) return;
2656
- const startTop = scrollContainer.scrollTop;
2657
- const rootRect = scrollContainer.getBoundingClientRect();
2658
- const elRect = el.getBoundingClientRect();
2659
- const targetTop = startTop + (elRect.top - rootRect.top);
2660
- if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
2661
- scrollContainer.scrollTop = targetTop;
2662
- return;
2663
- }
2664
- const duration = (options == null ? void 0 : options.duration) ?? 400;
2665
- const start = performance.now();
2666
- const animate = () => {
2667
- const t = Math.min((performance.now() - start) / duration, 1);
2668
- scrollContainer.scrollTop = startTop + (targetTop - startTop) * easeOutCubic(t);
2669
- if (t < 1) requestAnimationFrame(animate);
2670
- };
2671
- requestAnimationFrame(animate);
2672
- }
2673
2562
  const popoverAnchor = "_popoverAnchor_9y5t0_55";
2674
2563
  const popoverContent = "_popoverContent_9y5t0_62";
2675
2564
  const styles = {
@@ -2701,8 +2590,8 @@ function CommentPopover({
2701
2590
  side,
2702
2591
  align,
2703
2592
  sideOffset,
2704
- onOpenAutoFocus: (e) => e.preventDefault(),
2705
- onCloseAutoFocus: (e) => e.preventDefault(),
2593
+ onOpenAutoFocus: (e2) => e2.preventDefault(),
2594
+ onCloseAutoFocus: (e2) => e2.preventDefault(),
2706
2595
  children
2707
2596
  }
2708
2597
  ) })
@@ -2715,7 +2604,7 @@ export {
2715
2604
  COMMENT_GUTTER_META,
2716
2605
  CheckIcon,
2717
2606
  ChevronDownIcon,
2718
- CitationInteractive,
2607
+ C as CitationInteractive,
2719
2608
  CitationRef,
2720
2609
  CodeBlockView,
2721
2610
  CodeIcon,
@@ -2741,8 +2630,8 @@ export {
2741
2630
  MarkdownWysiwygEditor,
2742
2631
  MenuIcon,
2743
2632
  RedoIcon,
2744
- ReportContent,
2745
- ReportContentInteractive,
2633
+ R as ReportContent,
2634
+ R2 as ReportContentInteractive,
2746
2635
  RowAfterIcon,
2747
2636
  RowBeforeIcon,
2748
2637
  RowDeleteIcon,
@@ -2751,10 +2640,10 @@ export {
2751
2640
  TrashIcon,
2752
2641
  UnderlineIcon,
2753
2642
  UndoIcon,
2754
- h as applyCitationSources,
2643
+ a as applyCitationSources,
2755
2644
  applyCommentAnchorsToEditor,
2756
2645
  baseExtensions,
2757
- i as blockTextHash,
2646
+ d as blockTextHash,
2758
2647
  collectCommentIds,
2759
2648
  commentAnchorExtension,
2760
2649
  commentAnchorPlugin,
@@ -2767,8 +2656,8 @@ export {
2767
2656
  defaultTocLabels,
2768
2657
  defaultToolbarLabels,
2769
2658
  enrichMarkdownCitations,
2770
- j as extractToc,
2771
- findCitationRefElement,
2659
+ e as extractToc,
2660
+ f as findCitationRefElement,
2772
2661
  focusComment,
2773
2662
  insertMarkdown,
2774
2663
  looksLikeMarkdown,
@@ -2779,9 +2668,9 @@ export {
2779
2668
  nextComment,
2780
2669
  pureCodeBlock,
2781
2670
  pureImage,
2782
- readCitationAttrs,
2783
- scrollToTocHeading,
2784
- k as stabilizeMarkdown,
2671
+ r as readCitationAttrs,
2672
+ s2 as scrollToTocHeading,
2673
+ s as stabilizeMarkdown,
2785
2674
  stripCommentAnchorMarks,
2786
2675
  useIsMobile
2787
2676
  };