tiptap-markdown-react 1.0.0 → 1.1.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/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { Markdown, MarkdownManager } from "@tiptap/markdown";
3
- import { c as renderOrUpdateChart, d as destroyChart } from "./scrollToTocHeading-kPgsn3cu.js";
4
- import { C, a, R, b, f, m, r, s } from "./scrollToTocHeading-kPgsn3cu.js";
3
+ import { c as renderOrUpdateChart, d as destroyChart, s as scrollToTocHeading } from "./ReportContentWithCharts-CDwS4OH9.js";
4
+ import { C, a, R, b, f, m, r } from "./ReportContentWithCharts-CDwS4OH9.js";
5
5
  import { jsx, jsxs, Fragment as Fragment$2 } from "react/jsx-runtime";
6
6
  import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
7
7
  import FindAndReplace, { FindAndReplacePluginKey, createSearchRegex } from "@tiptap/extension-find-and-replace";
@@ -14,10 +14,10 @@ import { NodeViewWrapper, ReactNodeViewRenderer, useEditorState, ReactRenderer,
14
14
  import { Extension, Node as Node$1, mergeAttributes } from "@tiptap/core";
15
15
  import { createPortal } from "react-dom";
16
16
  import { useState, useEffect, useCallback, useRef, useMemo, useSyncExternalStore, useLayoutEffect, forwardRef, useId, useImperativeHandle, Fragment as Fragment$1, useContext, createContext } from "react";
17
- import { e as enrichMarkdownCitations, c as styles$e } from "./ReportContent-w08GFm8v.js";
18
- import { R as R2, a as a2, b as b2, s as s2 } from "./ReportContent-w08GFm8v.js";
19
- import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, n as normalizeImageAlign, p as prepareChartMarkdown, j as reportChart, f as CommentMark, b as baseExtensions, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, o as imageMarkdownTokenizer, q as imageParseMarkdown, t as imageRenderMarkdown, u as imageNodeHtml, v as imageFigureParseRule, w as imageCaptionAttribute, x as imageAlignAttribute, y as normalizeImageCaption, a as pureCodeBlock, c as pureImage, z as renderMathInto, A as readCurrentNumberingFormat, B as subscribeMathClick, D as applyNumberingFormat, N as NUMBERING_FORMAT_IDS, E as NUMBERING_FORMAT_LABELS, F as NUMBERING_FORMAT_PREVIEWS, d as pureChart } from "./extractToc-Cr470fBy.js";
20
- import { P, g, e, s as s3 } from "./extractToc-Cr470fBy.js";
17
+ import { e as enrichMarkdownCitations, c as styles$e } from "./ReportContent-B7okwVW0.js";
18
+ import { R as R2, a as a2, b as b2, s } from "./ReportContent-B7okwVW0.js";
19
+ import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, n as normalizeImageAlign, p as prepareChartMarkdown, j as reportChart, f as CommentMark, b as baseExtensions, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, o as imageMarkdownTokenizer, q as imageParseMarkdown, t as imageRenderMarkdown, u as imageNodeHtml, v as imageFigureParseRule, w as imageCaptionAttribute, x as imageAlignAttribute, y as normalizeImageCaption, a as pureCodeBlock, c as pureImage, z as renderMathInto, A as readCurrentNumberingFormat, B as subscribeMathClick, D as applyNumberingFormat, N as NUMBERING_FORMAT_IDS, E as NUMBERING_FORMAT_LABELS, F as NUMBERING_FORMAT_PREVIEWS, d as pureChart } from "./extractToc-B50WvHao.js";
20
+ import { P, g, e, s as s2 } from "./extractToc-B50WvHao.js";
21
21
  import { Slice, Fragment } from "@tiptap/pm/model";
22
22
  import { PluginKey, Plugin, Selection, TextSelection, NodeSelection } from "@tiptap/pm/state";
23
23
  import { DecorationSet, Decoration } from "@tiptap/pm/view";
@@ -177,8 +177,8 @@ function commentAnchorPlugin(options = {}) {
177
177
  state: {
178
178
  init: () => ({ activeCommentId: null }),
179
179
  apply: (tr, value) => {
180
- const active2 = tr.getMeta(COMMENT_ACTIVE_META);
181
- return active2 !== void 0 ? { activeCommentId: active2 } : value;
180
+ const active = tr.getMeta(COMMENT_ACTIVE_META);
181
+ return active !== void 0 ? { activeCommentId: active } : value;
182
182
  }
183
183
  },
184
184
  props: {
@@ -333,8 +333,8 @@ function focusComment(editor, commentId) {
333
333
  function nextComment(editor, dir = "next") {
334
334
  const ids = collectCommentIds(editor);
335
335
  if (ids.length === 0) return null;
336
- const active2 = getActive(editor);
337
- const current = active2 ? ids.indexOf(active2) : -1;
336
+ const active = getActive(editor);
337
+ const current = active ? ids.indexOf(active) : -1;
338
338
  const nextIdx = dir === "next" ? (current + 1) % ids.length : (current - 1 + ids.length) % ids.length;
339
339
  const target = ids[nextIdx];
340
340
  focusComment(editor, target);
@@ -1146,7 +1146,7 @@ const bundles = { en, zh };
1146
1146
  function getLocaleBundle(locale = "en") {
1147
1147
  return bundles[locale] ?? en;
1148
1148
  }
1149
- const bar$1 = "_bar_1h61e_3";
1149
+ const bar$2 = "_bar_1h61e_3";
1150
1150
  const row$1 = "_row_1h61e_25";
1151
1151
  const field$1 = "_field_1h61e_43";
1152
1152
  const fieldIcon = "_fieldIcon_1h61e_62";
@@ -1160,7 +1160,7 @@ const iconGroup = "_iconGroup_1h61e_29";
1160
1160
  const spacer = "_spacer_1h61e_150";
1161
1161
  const readOnly = "_readOnly_1h61e_155";
1162
1162
  const styles$d = {
1163
- bar: bar$1,
1163
+ bar: bar$2,
1164
1164
  row: row$1,
1165
1165
  field: field$1,
1166
1166
  fieldIcon,
@@ -1603,7 +1603,7 @@ const textMain = "_textMain_1k6n1_100";
1603
1603
  const textEm = "_textEm_1k6n1_107";
1604
1604
  const subtext = "_subtext_1k6n1_112";
1605
1605
  const previews = "_previews_1k6n1_121";
1606
- const header$2 = "_header_1k6n1_127";
1606
+ const header$1 = "_header_1k6n1_127";
1607
1607
  const clearAll = "_clearAll_1k6n1_139";
1608
1608
  const preview = "_preview_1k6n1_121";
1609
1609
  const progress = "_progress_1k6n1_161";
@@ -1629,7 +1629,7 @@ const styles$c = {
1629
1629
  textEm,
1630
1630
  subtext,
1631
1631
  previews,
1632
- header: header$2,
1632
+ header: header$1,
1633
1633
  clearAll,
1634
1634
  preview,
1635
1635
  progress,
@@ -1744,7 +1744,7 @@ function ImageUploadView(props) {
1744
1744
  files.map(async (file) => ({ file, url: await uploadOne(file) }))
1745
1745
  );
1746
1746
  const uploaded = settled.filter(
1747
- (s4) => s4.url != null
1747
+ (s3) => s3.url != null
1748
1748
  );
1749
1749
  if (uploaded.length === 0) return;
1750
1750
  const pos = getPos();
@@ -2380,7 +2380,7 @@ const popupHost = "_popupHost_1noza_11";
2380
2380
  const menu$2 = "_menu_1noza_1";
2381
2381
  const groupLabel$1 = "_groupLabel_1noza_43";
2382
2382
  const item$2 = "_item_1noza_53";
2383
- const itemActive$1 = "_itemActive_1noza_54";
2383
+ const itemActive$2 = "_itemActive_1noza_54";
2384
2384
  const itemIcon$1 = "_itemIcon_1noza_79";
2385
2385
  const itemTitle = "_itemTitle_1noza_102";
2386
2386
  const styles$a = {
@@ -2388,7 +2388,7 @@ const styles$a = {
2388
2388
  menu: menu$2,
2389
2389
  groupLabel: groupLabel$1,
2390
2390
  item: item$2,
2391
- itemActive: itemActive$1,
2391
+ itemActive: itemActive$2,
2392
2392
  itemIcon: itemIcon$1,
2393
2393
  itemTitle
2394
2394
  };
@@ -2931,8 +2931,8 @@ function buildDecorations(doc, anchors) {
2931
2931
  bounds.push({ from: offset2, to: offset2 + child.nodeSize });
2932
2932
  });
2933
2933
  const decorations = [];
2934
- for (const anchor of anchors) {
2935
- for (const range of anchor.ranges) {
2934
+ for (const anchor2 of anchors) {
2935
+ for (const range of anchor2.ranges) {
2936
2936
  const from = Math.max(0, Math.min(range.from, range.to));
2937
2937
  const to = Math.min(doc.content.size, Math.max(range.from, range.to));
2938
2938
  if (from >= to) continue;
@@ -2940,7 +2940,7 @@ function buildDecorations(doc, anchors) {
2940
2940
  if (bound.to <= from || bound.from >= to) continue;
2941
2941
  const attrs = {
2942
2942
  class: PENDING_ANCHOR_CLASS,
2943
- "data-pending-id": anchor.id
2943
+ "data-pending-id": anchor2.id
2944
2944
  };
2945
2945
  if (from <= bound.from && to >= bound.to) {
2946
2946
  decorations.push(Decoration.node(bound.from, bound.to, attrs));
@@ -3019,7 +3019,7 @@ function ChartView({
3019
3019
  }) {
3020
3020
  const canvasRef = useRef(null);
3021
3021
  const chartRef = useRef(null);
3022
- const [active2, setActive2] = useState(0);
3022
+ const [active, setActive2] = useState(0);
3023
3023
  const labels = useEditorBundle(editor).chart;
3024
3024
  const payload = useMemo(
3025
3025
  () => ({
@@ -3031,7 +3031,7 @@ function ChartView({
3031
3031
  );
3032
3032
  const theme = extension.options.chartTheme ?? null;
3033
3033
  const configs = payload.config;
3034
- const safeIndex = Math.min(active2, Math.max(0, configs.length - 1));
3034
+ const safeIndex = Math.min(active, Math.max(0, configs.length - 1));
3035
3035
  const config = configs[safeIndex];
3036
3036
  const height = (config == null ? void 0 : config.height) ?? 320;
3037
3037
  const canSelect = Boolean(editor == null ? void 0 : editor.isEditable);
@@ -3125,7 +3125,7 @@ function createChart(options = {}) {
3125
3125
  });
3126
3126
  }
3127
3127
  const wrapper = "_wrapper_k8th1_2";
3128
- const header$1 = "_header_k8th1_18";
3128
+ const header = "_header_k8th1_18";
3129
3129
  const langTrigger = "_langTrigger_k8th1_28";
3130
3130
  const langChevron = "_langChevron_k8th1_50";
3131
3131
  const readonlyHeader = "_readonlyHeader_k8th1_56";
@@ -3145,7 +3145,7 @@ const actionBtn = "_actionBtn_k8th1_194";
3145
3145
  const langBraces = "_langBraces_k8th1_213";
3146
3146
  const styles$8 = {
3147
3147
  wrapper,
3148
- header: header$1,
3148
+ header,
3149
3149
  langTrigger,
3150
3150
  langChevron,
3151
3151
  readonlyHeader,
@@ -3698,9 +3698,9 @@ function placeBlockDropCursor(view, pos) {
3698
3698
  const $pos = view.state.doc.resolve(pos);
3699
3699
  const before = $pos.nodeBefore;
3700
3700
  const anchorPos = before ? pos - before.nodeSize : pos;
3701
- const anchor = view.nodeDOM(anchorPos);
3702
- if (!(anchor instanceof HTMLElement)) return;
3703
- const anchorRect = anchor.getBoundingClientRect();
3701
+ const anchor2 = view.nodeDOM(anchorPos);
3702
+ if (!(anchor2 instanceof HTMLElement)) return;
3703
+ const anchorRect = anchor2.getBoundingClientRect();
3704
3704
  let lineTop = before ? anchorRect.bottom : anchorRect.top;
3705
3705
  if (before && $pos.nodeAfter) {
3706
3706
  const next = view.nodeDOM(pos);
@@ -3768,7 +3768,7 @@ const menu$1 = "_menu_5edcs_61";
3768
3768
  const groupLabel = "_groupLabel_5edcs_84";
3769
3769
  const divider$3 = "_divider_5edcs_94";
3770
3770
  const item$1 = "_item_5edcs_100";
3771
- const itemActive = "_itemActive_5edcs_118";
3771
+ const itemActive$1 = "_itemActive_5edcs_118";
3772
3772
  const itemDanger = "_itemDanger_5edcs_123";
3773
3773
  const itemIcon = "_itemIcon_5edcs_132";
3774
3774
  const styles$7 = {
@@ -3780,7 +3780,7 @@ const styles$7 = {
3780
3780
  groupLabel,
3781
3781
  divider: divider$3,
3782
3782
  item: item$1,
3783
- itemActive,
3783
+ itemActive: itemActive$1,
3784
3784
  itemDanger,
3785
3785
  itemIcon
3786
3786
  };
@@ -3799,10 +3799,10 @@ const THEME_VARS = [
3799
3799
  "--tmr-danger",
3800
3800
  "--tmr-code-bg"
3801
3801
  ];
3802
- function lockDragHandle(editor, locked2) {
3802
+ function lockDragHandle(editor, locked) {
3803
3803
  if (editor.isDestroyed) return;
3804
3804
  editor.view.dispatch(
3805
- editor.state.tr.setMeta("lockDragHandle", locked2).setMeta("addToHistory", false)
3805
+ editor.state.tr.setMeta("lockDragHandle", locked).setMeta("addToHistory", false)
3806
3806
  );
3807
3807
  }
3808
3808
  async function copyMarkdown(markdown) {
@@ -3883,9 +3883,9 @@ function BlockDragHandle({ editor }) {
3883
3883
  }
3884
3884
  }, [menu2, editor]);
3885
3885
  useEffect(() => () => lockDragHandle(editor, false), [editor, closeMenu]);
3886
- const openMenu = (anchor) => {
3886
+ const openMenu = (anchor2) => {
3887
3887
  if (!target) return;
3888
- const rect = anchor.getBoundingClientRect();
3888
+ const rect = anchor2.getBoundingClientRect();
3889
3889
  const estimated = 380;
3890
3890
  const y = rect.top + estimated > window.innerHeight ? Math.max(8, window.innerHeight - estimated - 8) : rect.top;
3891
3891
  const x = Math.min(rect.right + 6, window.innerWidth - 220);
@@ -4110,6 +4110,210 @@ function BlockDragHandle({ editor }) {
4110
4110
  ) : null
4111
4111
  ] });
4112
4112
  }
4113
+ const anchor = "_anchor_1b977_4";
4114
+ const nav = "_nav_1b977_15";
4115
+ const navOpen = "_navOpen_1b977_16";
4116
+ const list = "_list_1b977_58";
4117
+ const barButton = "_barButton_1b977_64";
4118
+ const bar$1 = "_bar_1b977_64";
4119
+ const barActive = "_barActive_1b977_78";
4120
+ const item = "_item_1b977_89";
4121
+ const itemActive = "_itemActive_1b977_110";
4122
+ const itemText = "_itemText_1b977_117";
4123
+ const styles$6 = {
4124
+ anchor,
4125
+ nav,
4126
+ navOpen,
4127
+ list,
4128
+ barButton,
4129
+ bar: bar$1,
4130
+ barActive,
4131
+ item,
4132
+ itemActive,
4133
+ itemText
4134
+ };
4135
+ function barWidth(level) {
4136
+ if (level <= 1) return 16;
4137
+ if (level === 2) return 12;
4138
+ if (level === 3) return 8;
4139
+ return 6;
4140
+ }
4141
+ function findScrollParent(start) {
4142
+ let node = start.parentElement;
4143
+ while (node && node !== document.documentElement) {
4144
+ const style = getComputedStyle(node);
4145
+ const overflowY = style.overflowY;
4146
+ const canScroll = overflowY === "auto" || overflowY === "scroll" || overflowY === "overlay";
4147
+ if (canScroll && (node.scrollHeight > node.clientHeight + 1 || style.maxHeight !== "none")) {
4148
+ return node;
4149
+ }
4150
+ node = node.parentElement;
4151
+ }
4152
+ return document.scrollingElement ?? document.documentElement;
4153
+ }
4154
+ function isViewportScroller(node) {
4155
+ return node === document.documentElement || node === document.body || node === document.scrollingElement;
4156
+ }
4157
+ function EditorToc({ items, editorDom, locale = "en" }) {
4158
+ var _a;
4159
+ const t = getLocaleBundle(locale).toc;
4160
+ const [open, setOpen] = useState(false);
4161
+ const [activeId, setActiveId] = useState(((_a = items[0]) == null ? void 0 : _a.id) ?? "");
4162
+ const [roving, setRoving] = useState(0);
4163
+ const navRef = useRef(null);
4164
+ const itemRefs = useRef([]);
4165
+ const hideTimer = useRef(null);
4166
+ const clearHide = () => {
4167
+ if (hideTimer.current !== null) {
4168
+ window.clearTimeout(hideTimer.current);
4169
+ hideTimer.current = null;
4170
+ }
4171
+ };
4172
+ const show = () => {
4173
+ clearHide();
4174
+ setOpen(true);
4175
+ };
4176
+ const hideSoon = () => {
4177
+ clearHide();
4178
+ hideTimer.current = window.setTimeout(() => {
4179
+ var _a2;
4180
+ hideTimer.current = null;
4181
+ if ((_a2 = navRef.current) == null ? void 0 : _a2.contains(document.activeElement)) return;
4182
+ setOpen(false);
4183
+ }, 80);
4184
+ };
4185
+ useEffect(() => () => clearHide(), []);
4186
+ useEffect(() => {
4187
+ const headings = items.map(
4188
+ (item2) => editorDom.querySelector(
4189
+ `[data-toc-id="${CSS.escape(item2.id)}"]`
4190
+ )
4191
+ ).filter((el) => el !== null);
4192
+ if (!headings.length) return;
4193
+ const scrollParent = findScrollParent(editorDom);
4194
+ const viewport = isViewportScroller(scrollParent);
4195
+ const visible = /* @__PURE__ */ new Set();
4196
+ const apply2 = () => {
4197
+ const rootTop = viewport ? 0 : scrollParent.getBoundingClientRect().top;
4198
+ let best = null;
4199
+ let bestTop = Infinity;
4200
+ for (const el of visible) {
4201
+ const top = el.getBoundingClientRect().top;
4202
+ if (top < bestTop) {
4203
+ bestTop = top;
4204
+ best = el;
4205
+ }
4206
+ }
4207
+ if (!best) {
4208
+ let last = null;
4209
+ for (const heading of headings) {
4210
+ if (heading.getBoundingClientRect().top <= rootTop + 12) last = heading;
4211
+ }
4212
+ best = last ?? headings[0];
4213
+ }
4214
+ const id = best.getAttribute("data-toc-id");
4215
+ if (id) setActiveId(id);
4216
+ };
4217
+ const observer = new IntersectionObserver(
4218
+ (entries) => {
4219
+ for (const entry of entries) {
4220
+ if (entry.isIntersecting) visible.add(entry.target);
4221
+ else visible.delete(entry.target);
4222
+ }
4223
+ apply2();
4224
+ },
4225
+ {
4226
+ root: viewport ? null : scrollParent,
4227
+ rootMargin: "0px 0px -60% 0px",
4228
+ threshold: [0, 1]
4229
+ }
4230
+ );
4231
+ for (const heading of headings) observer.observe(heading);
4232
+ const onScroll = () => apply2();
4233
+ const scrollTarget = viewport ? window : scrollParent;
4234
+ scrollTarget.addEventListener("scroll", onScroll, { passive: true });
4235
+ apply2();
4236
+ return () => {
4237
+ observer.disconnect();
4238
+ scrollTarget.removeEventListener("scroll", onScroll);
4239
+ };
4240
+ }, [items, editorDom]);
4241
+ useEffect(() => {
4242
+ var _a2;
4243
+ if ((_a2 = navRef.current) == null ? void 0 : _a2.contains(document.activeElement)) return;
4244
+ const index = items.findIndex((item2) => item2.id === activeId);
4245
+ if (index >= 0) setRoving(index);
4246
+ }, [activeId, items]);
4247
+ useEffect(() => {
4248
+ var _a2, _b;
4249
+ if (!open || !activeId) return;
4250
+ const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
4251
+ (_b = (_a2 = navRef.current) == null ? void 0 : _a2.querySelector(`[data-toc-item="${CSS.escape(activeId)}"]`)) == null ? void 0 : _b.scrollIntoView({ block: "nearest", behavior: reduce ? "auto" : "smooth" });
4252
+ }, [activeId, open]);
4253
+ const jump = (item2) => {
4254
+ setActiveId(item2.id);
4255
+ scrollToTocHeading(item2.id, findScrollParent(editorDom));
4256
+ };
4257
+ const move = (delta) => {
4258
+ var _a2;
4259
+ const next = Math.min(items.length - 1, Math.max(0, roving + delta));
4260
+ setRoving(next);
4261
+ setOpen(true);
4262
+ (_a2 = itemRefs.current[next]) == null ? void 0 : _a2.focus();
4263
+ };
4264
+ return /* @__PURE__ */ jsx("div", { className: styles$6.anchor, children: /* @__PURE__ */ jsx(
4265
+ "nav",
4266
+ {
4267
+ ref: navRef,
4268
+ className: open ? styles$6.navOpen : styles$6.nav,
4269
+ "aria-label": t.title,
4270
+ "data-editor-toc": "",
4271
+ onMouseEnter: show,
4272
+ onMouseLeave: hideSoon,
4273
+ onFocus: show,
4274
+ onBlur: (event) => {
4275
+ if (!event.currentTarget.contains(event.relatedTarget)) hideSoon();
4276
+ },
4277
+ onKeyDown: (event) => {
4278
+ if (event.key === "ArrowDown") {
4279
+ event.preventDefault();
4280
+ move(1);
4281
+ } else if (event.key === "ArrowUp") {
4282
+ event.preventDefault();
4283
+ move(-1);
4284
+ } else if (event.key === "Escape") {
4285
+ setOpen(false);
4286
+ }
4287
+ },
4288
+ children: /* @__PURE__ */ jsx("ul", { className: styles$6.list, children: items.map((item2, index) => {
4289
+ const active = item2.id === activeId;
4290
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
4291
+ "button",
4292
+ {
4293
+ type: "button",
4294
+ ref: (node) => {
4295
+ itemRefs.current[index] = node;
4296
+ },
4297
+ "data-toc-item": item2.id,
4298
+ tabIndex: index === roving ? 0 : -1,
4299
+ className: open ? `${styles$6.item} ${active ? styles$6.itemActive : ""}` : styles$6.barButton,
4300
+ style: open ? { paddingLeft: `${(item2.level - 1) * 12 + 10}px` } : void 0,
4301
+ "aria-current": active ? "true" : void 0,
4302
+ "aria-label": item2.text,
4303
+ onClick: () => jump(item2),
4304
+ children: open ? /* @__PURE__ */ jsx("span", { className: styles$6.itemText, children: item2.text }) : /* @__PURE__ */ jsx(
4305
+ "span",
4306
+ {
4307
+ className: active ? styles$6.barActive : styles$6.bar,
4308
+ style: { width: barWidth(item2.level) }
4309
+ }
4310
+ )
4311
+ }
4312
+ ) }, item2.id);
4313
+ }) })
4314
+ }
4315
+ ) });
4316
+ }
4113
4317
  function useIsMobile(breakpoint = 768) {
4114
4318
  const [isMobile, setIsMobile] = useState(false);
4115
4319
  useEffect(() => {
@@ -4310,12 +4514,18 @@ function CharacterCountStatus({
4310
4514
  );
4311
4515
  }
4312
4516
  function editorOwnsKeyboard(editor) {
4313
- const active2 = document.activeElement;
4314
- const inEditor = !!active2 && editor.view.dom.contains(active2);
4517
+ const active = document.activeElement;
4518
+ const inEditor = !!active && editor.view.dom.contains(active);
4315
4519
  if (inEditor || editor.isFocused) return true;
4316
- const nothingFocused = active2 === null || active2 === document.body;
4520
+ const nothingFocused = active === null || active === document.body;
4317
4521
  return nothingFocused && document.querySelectorAll(".ProseMirror").length <= 1;
4318
4522
  }
4523
+ function sameTocItems(a3, b3) {
4524
+ if (a3.length !== b3.length) return false;
4525
+ return a3.every(
4526
+ (item2, index) => item2.id === b3[index].id && item2.level === b3[index].level && item2.text === b3[index].text
4527
+ );
4528
+ }
4319
4529
  const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
4320
4530
  initialMarkdown = "",
4321
4531
  editable = true,
@@ -4325,6 +4535,7 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
4325
4535
  placeholder,
4326
4536
  onEditorReady,
4327
4537
  onTocChange,
4538
+ toc = true,
4328
4539
  markdownPaste = true,
4329
4540
  markdownFileDrop = true,
4330
4541
  extraExtensions,
@@ -4361,7 +4572,11 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
4361
4572
  const showBlockDrag = blockDrag && editable && !blockDragMobile;
4362
4573
  const [findOpen, setFindOpen] = useState(false);
4363
4574
  const [shortcutsOpen, setShortcutsOpen] = useState(false);
4575
+ const [tocItems, setTocItems] = useState([]);
4364
4576
  const findInputRef = useRef(null);
4577
+ const onTocChangeRef = useRef(onTocChange);
4578
+ onTocChangeRef.current = onTocChange;
4579
+ const tocItemsRef = useRef([]);
4365
4580
  const editor = useEditor({
4366
4581
  extensions: [
4367
4582
  ...baseExtensions.map(
@@ -4417,10 +4632,19 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
4417
4632
  ...characterCount ? [CharacterCount.configure({ wordCounter: countWords })] : [],
4418
4633
  TableOfContents.configure({
4419
4634
  getId: makeTocGetId(),
4635
+ // 官方扩展在滚动时也会 onUpdate(只为刷新 isActive)。目录项没变就不通知,
4636
+ // 否则每次滚动都 setState。回调走 ref:扩展只在创建时绑一次。
4420
4637
  onUpdate: (anchors) => {
4421
- onTocChange == null ? void 0 : onTocChange(
4422
- anchors.filter((a3) => a3.level <= 6).map((a3) => ({ id: a3.id, level: a3.level, text: a3.textContent }))
4423
- );
4638
+ var _a;
4639
+ const next = anchors.filter((a3) => a3.originalLevel <= 6 && a3.textContent.trim()).map((a3) => ({
4640
+ id: a3.id,
4641
+ level: a3.originalLevel,
4642
+ text: a3.textContent
4643
+ }));
4644
+ if (sameTocItems(tocItemsRef.current, next)) return;
4645
+ tocItemsRef.current = next;
4646
+ setTocItems(next);
4647
+ (_a = onTocChangeRef.current) == null ? void 0 : _a.call(onTocChangeRef, next);
4424
4648
  }
4425
4649
  }),
4426
4650
  ...markdownPaste ? [MarkdownPaste] : [],
@@ -4671,6 +4895,14 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
4671
4895
  children: [
4672
4896
  findBarNode && !findBarTarget ? /* @__PURE__ */ jsx("div", { className: styles$e.findBarAnchor, children: findBarNode }) : null,
4673
4897
  findBarNode && findBarTarget ? createPortal(findBarNode, findBarTarget) : null,
4898
+ editor && toc && !blockDragMobile && tocItems.length > 0 ? /* @__PURE__ */ jsx(
4899
+ EditorToc,
4900
+ {
4901
+ items: tocItems,
4902
+ editorDom: editor.view.dom,
4903
+ locale
4904
+ }
4905
+ ) : null,
4674
4906
  /* @__PURE__ */ jsx(
4675
4907
  EditorContent,
4676
4908
  {
@@ -4678,6 +4910,7 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
4678
4910
  className: [
4679
4911
  styles$e.editorScroll,
4680
4912
  showBlockDrag ? styles$e.withBlockDrag : "",
4913
+ toc && !blockDragMobile && tocItems.length > 0 ? styles$e.withToc : "",
4681
4914
  className ?? ""
4682
4915
  ].filter(Boolean).join(" ")
4683
4916
  }
@@ -4877,7 +5110,7 @@ const mathFieldBlock = "_mathFieldBlock_1l6t0_531";
4877
5110
  const mathInput = "_mathInput_1l6t0_538";
4878
5111
  const mathDone = "_mathDone_1l6t0_556";
4879
5112
  const mathDoneKbd = "_mathDoneKbd_1l6t0_581";
4880
- const styles$6 = {
5113
+ const styles$5 = {
4881
5114
  toolbar,
4882
5115
  inner,
4883
5116
  btn: btn$2,
@@ -4939,7 +5172,7 @@ const swatch = "_swatch_x5lrq_54";
4939
5172
  const swatchActive = "_swatchActive_x5lrq_70";
4940
5173
  const themeLabel = "_themeLabel_x5lrq_76";
4941
5174
  const themeRow = "_themeRow_x5lrq_84";
4942
- const styles$5 = {
5175
+ const styles$4 = {
4943
5176
  palette,
4944
5177
  noneRow,
4945
5178
  noneIcon,
@@ -4962,25 +5195,25 @@ const THEME_COLORS = ["#ff6719", "#ff5500"];
4962
5195
  function ColorPalette({ value, onPick, locale = "en" }) {
4963
5196
  const t = getLocaleBundle(locale).palette;
4964
5197
  const current = value == null ? void 0 : value.toLowerCase();
4965
- return /* @__PURE__ */ jsxs("div", { className: styles$5.palette, children: [
5198
+ return /* @__PURE__ */ jsxs("div", { className: styles$4.palette, children: [
4966
5199
  /* @__PURE__ */ jsxs(
4967
5200
  "button",
4968
5201
  {
4969
5202
  type: "button",
4970
- className: styles$5.noneRow,
5203
+ className: styles$4.noneRow,
4971
5204
  onMouseDown: (e2) => e2.preventDefault(),
4972
5205
  onClick: () => onPick(null),
4973
5206
  children: [
4974
- /* @__PURE__ */ jsx("span", { className: styles$5.noneIcon, "aria-hidden": true }),
4975
- /* @__PURE__ */ jsx("span", { className: styles$5.noneLabel, children: t.none })
5207
+ /* @__PURE__ */ jsx("span", { className: styles$4.noneIcon, "aria-hidden": true }),
5208
+ /* @__PURE__ */ jsx("span", { className: styles$4.noneLabel, children: t.none })
4976
5209
  ]
4977
5210
  }
4978
5211
  ),
4979
- /* @__PURE__ */ jsx("div", { className: styles$5.grid, children: PALETTE.flat().map((c) => /* @__PURE__ */ jsx(
5212
+ /* @__PURE__ */ jsx("div", { className: styles$4.grid, children: PALETTE.flat().map((c) => /* @__PURE__ */ jsx(
4980
5213
  "button",
4981
5214
  {
4982
5215
  type: "button",
4983
- className: `${styles$5.swatch} ${current === c.toLowerCase() ? styles$5.swatchActive : ""}`,
5216
+ className: `${styles$4.swatch} ${current === c.toLowerCase() ? styles$4.swatchActive : ""}`,
4984
5217
  style: { background: c },
4985
5218
  title: c,
4986
5219
  "aria-label": c,
@@ -4989,12 +5222,12 @@ function ColorPalette({ value, onPick, locale = "en" }) {
4989
5222
  },
4990
5223
  c
4991
5224
  )) }),
4992
- /* @__PURE__ */ jsx("div", { className: styles$5.themeLabel, children: t.theme }),
4993
- /* @__PURE__ */ jsx("div", { className: styles$5.themeRow, children: THEME_COLORS.map((c) => /* @__PURE__ */ jsx(
5225
+ /* @__PURE__ */ jsx("div", { className: styles$4.themeLabel, children: t.theme }),
5226
+ /* @__PURE__ */ jsx("div", { className: styles$4.themeRow, children: THEME_COLORS.map((c) => /* @__PURE__ */ jsx(
4994
5227
  "button",
4995
5228
  {
4996
5229
  type: "button",
4997
- className: `${styles$5.swatch} ${current === c.toLowerCase() ? styles$5.swatchActive : ""}`,
5230
+ className: `${styles$4.swatch} ${current === c.toLowerCase() ? styles$4.swatchActive : ""}`,
4998
5231
  style: { background: c },
4999
5232
  title: c,
5000
5233
  "aria-label": c,
@@ -5025,7 +5258,7 @@ const captionRow = "_captionRow_mp2o5_13";
5025
5258
  const captionInput = "_captionInput_mp2o5_40";
5026
5259
  const btn$1 = "_btn_mp2o5_58";
5027
5260
  const btnActive = "_btnActive_mp2o5_76";
5028
- const styles$4 = {
5261
+ const styles$3 = {
5029
5262
  bar,
5030
5263
  divider: divider$1,
5031
5264
  captionRow,
@@ -5143,7 +5376,7 @@ function ImageAlignTools({ editor, labels }) {
5143
5376
  if (!hover || !editor.isEditable) return null;
5144
5377
  const above = hover.top - TOOLBAR_HEIGHT - TOOLBAR_GAP >= 8;
5145
5378
  const nodeAttrs = (_a = editor.state.doc.nodeAt(hover.pos)) == null ? void 0 : _a.attrs;
5146
- const active2 = normalizeImageAlign(nodeAttrs == null ? void 0 : nodeAttrs.align);
5379
+ const active = normalizeImageAlign(nodeAttrs == null ? void 0 : nodeAttrs.align);
5147
5380
  const caption = normalizeImageCaption(nodeAttrs == null ? void 0 : nodeAttrs.caption);
5148
5381
  const labelOf = {
5149
5382
  left: labels.imageAlignLeft,
@@ -5161,7 +5394,7 @@ function ImageAlignTools({ editor, labels }) {
5161
5394
  "div",
5162
5395
  {
5163
5396
  "data-image-align": "",
5164
- className: styles$4.bar,
5397
+ className: styles$3.bar,
5165
5398
  role: "toolbar",
5166
5399
  "aria-label": labels.imageAlign,
5167
5400
  style: {
@@ -5181,10 +5414,10 @@ function ImageAlignTools({ editor, labels }) {
5181
5414
  {
5182
5415
  type: "button",
5183
5416
  "data-image-align-action": align,
5184
- className: `${styles$4.btn} ${active2 === align ? styles$4.btnActive : ""}`,
5417
+ className: `${styles$3.btn} ${active === align ? styles$3.btnActive : ""}`,
5185
5418
  title: labelOf[align],
5186
5419
  "aria-label": labelOf[align],
5187
- "aria-pressed": active2 === align,
5420
+ "aria-pressed": active === align,
5188
5421
  onClick: () => {
5189
5422
  setImageAlignAtPos(editor, hover.pos, align);
5190
5423
  remeasureHover();
@@ -5194,13 +5427,13 @@ function ImageAlignTools({ editor, labels }) {
5194
5427
  align
5195
5428
  );
5196
5429
  }),
5197
- /* @__PURE__ */ jsx("span", { className: styles$4.divider, "aria-hidden": true }),
5430
+ /* @__PURE__ */ jsx("span", { className: styles$3.divider, "aria-hidden": true }),
5198
5431
  /* @__PURE__ */ jsx(
5199
5432
  "button",
5200
5433
  {
5201
5434
  type: "button",
5202
5435
  "data-image-align-action": "caption",
5203
- className: `${styles$4.btn} ${caption ? styles$4.btnActive : ""}`,
5436
+ className: `${styles$3.btn} ${caption ? styles$3.btnActive : ""}`,
5204
5437
  title: labels.imageCaption,
5205
5438
  "aria-label": labels.imageCaption,
5206
5439
  "aria-pressed": !!caption,
@@ -5211,10 +5444,10 @@ function ImageAlignTools({ editor, labels }) {
5211
5444
  children: /* @__PURE__ */ jsx(CaptionsIcon, { size: 14 })
5212
5445
  }
5213
5446
  ),
5214
- captionDraft !== null ? /* @__PURE__ */ jsx("div", { className: styles$4.captionRow, children: /* @__PURE__ */ jsx(
5447
+ captionDraft !== null ? /* @__PURE__ */ jsx("div", { className: styles$3.captionRow, children: /* @__PURE__ */ jsx(
5215
5448
  "input",
5216
5449
  {
5217
- className: styles$4.captionInput,
5450
+ className: styles$3.captionInput,
5218
5451
  value: captionDraft,
5219
5452
  placeholder: labels.imageCaptionPlaceholder,
5220
5453
  "aria-label": labels.imageCaptionPlaceholder,
@@ -5325,7 +5558,7 @@ const input = "_input_qysb1_52";
5325
5558
  const divider = "_divider_qysb1_63";
5326
5559
  const btn = "_btn_qysb1_71";
5327
5560
  const apply = "_apply_qysb1_99";
5328
- const styles$3 = {
5561
+ const styles$2 = {
5329
5562
  panel,
5330
5563
  field,
5331
5564
  fieldInvalid,
@@ -5400,16 +5633,16 @@ function LinkPanel({
5400
5633
  return /* @__PURE__ */ jsxs(
5401
5634
  "div",
5402
5635
  {
5403
- className: className ? `${styles$3.panel} ${className}` : styles$3.panel,
5636
+ className: className ? `${styles$2.panel} ${className}` : styles$2.panel,
5404
5637
  style,
5405
5638
  "data-link-popover": "",
5406
5639
  role: "dialog",
5407
5640
  "aria-label": t.field,
5408
5641
  children: [
5409
- /* @__PURE__ */ jsx("span", { className: `${styles$3.field}${invalid ? ` ${styles$3.fieldInvalid}` : ""}`, children: /* @__PURE__ */ jsx(
5642
+ /* @__PURE__ */ jsx("span", { className: `${styles$2.field}${invalid ? ` ${styles$2.fieldInvalid}` : ""}`, children: /* @__PURE__ */ jsx(
5410
5643
  "input",
5411
5644
  {
5412
- className: styles$3.input,
5645
+ className: styles$2.input,
5413
5646
  "data-link-field": "",
5414
5647
  "data-link-invalid": invalid ? "" : void 0,
5415
5648
  type: "url",
@@ -5434,7 +5667,7 @@ function LinkPanel({
5434
5667
  "button",
5435
5668
  {
5436
5669
  type: "button",
5437
- className: `${styles$3.btn} ${styles$3.apply}`,
5670
+ className: `${styles$2.btn} ${styles$2.apply}`,
5438
5671
  "data-link-action": "apply",
5439
5672
  title: t.apply,
5440
5673
  "aria-label": t.apply,
@@ -5444,12 +5677,12 @@ function LinkPanel({
5444
5677
  children: /* @__PURE__ */ jsx(CheckIcon, { size: 16 })
5445
5678
  }
5446
5679
  ),
5447
- /* @__PURE__ */ jsx("span", { className: styles$3.divider, "aria-hidden": "true" }),
5680
+ /* @__PURE__ */ jsx("span", { className: styles$2.divider, "aria-hidden": "true" }),
5448
5681
  /* @__PURE__ */ jsx(
5449
5682
  "button",
5450
5683
  {
5451
5684
  type: "button",
5452
- className: styles$3.btn,
5685
+ className: styles$2.btn,
5453
5686
  "data-link-action": "open",
5454
5687
  title: t.open,
5455
5688
  "aria-label": t.open,
@@ -5463,7 +5696,7 @@ function LinkPanel({
5463
5696
  "button",
5464
5697
  {
5465
5698
  type: "button",
5466
- className: styles$3.btn,
5699
+ className: styles$2.btn,
5467
5700
  "data-link-action": "remove",
5468
5701
  title: t.remove,
5469
5702
  "aria-label": t.remove,
@@ -5662,7 +5895,7 @@ const tableMenuItem = "_tableMenuItem_1m19y_130";
5662
5895
  const tableMenuItemIcon = "_tableMenuItemIcon_1m19y_156";
5663
5896
  const tableMenuItemLabel = "_tableMenuItemLabel_1m19y_166";
5664
5897
  const tableMenuDivider = "_tableMenuDivider_1m19y_171";
5665
- const styles$2 = {
5898
+ const styles$1 = {
5666
5899
  handle,
5667
5900
  handleRow,
5668
5901
  handleCol,
@@ -5936,7 +6169,7 @@ function TableHandles({ editor, labels }) {
5936
6169
  {
5937
6170
  type: "button",
5938
6171
  "data-table-handle": "row",
5939
- className: `${styles$2.handle} ${styles$2.handleRow}`,
6172
+ className: `${styles$1.handle} ${styles$1.handleRow}`,
5940
6173
  style: {
5941
6174
  left: hover.tableLeft - ROW_HANDLE_GAP,
5942
6175
  top: hover.rowTop,
@@ -5955,7 +6188,7 @@ function TableHandles({ editor, labels }) {
5955
6188
  {
5956
6189
  type: "button",
5957
6190
  "data-table-handle": "col",
5958
- className: `${styles$2.handle} ${styles$2.handleCol}`,
6191
+ className: `${styles$1.handle} ${styles$1.handleCol}`,
5959
6192
  style: {
5960
6193
  left: hover.colLeft,
5961
6194
  top: hover.tableTop - COL_HANDLE_GAP,
@@ -5974,7 +6207,7 @@ function TableHandles({ editor, labels }) {
5974
6207
  {
5975
6208
  type: "button",
5976
6209
  "data-table-extend": "col",
5977
- className: styles$2.extend,
6210
+ className: styles$1.extend,
5978
6211
  style: {
5979
6212
  left: hover.tableRight + EXTEND_GAP,
5980
6213
  top: hover.tableTop,
@@ -5996,7 +6229,7 @@ function TableHandles({ editor, labels }) {
5996
6229
  {
5997
6230
  type: "button",
5998
6231
  "data-table-extend": "row",
5999
- className: styles$2.extend,
6232
+ className: styles$1.extend,
6000
6233
  style: {
6001
6234
  left: hover.tableLeft,
6002
6235
  top: hover.tableBottom + EXTEND_GAP,
@@ -6017,7 +6250,7 @@ function TableHandles({ editor, labels }) {
6017
6250
  menu2 ? /* @__PURE__ */ jsxs(
6018
6251
  "div",
6019
6252
  {
6020
- className: styles$2.tableBubble,
6253
+ className: styles$1.tableBubble,
6021
6254
  "data-table-menu": "",
6022
6255
  style: { left: menu2.x, top: menu2.y },
6023
6256
  role: "menu",
@@ -6025,39 +6258,39 @@ function TableHandles({ editor, labels }) {
6025
6258
  onContextMenu: (e2) => e2.preventDefault(),
6026
6259
  children: [
6027
6260
  items.map((item2, index) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
6028
- index > 0 && item2.group !== items[index - 1].group ? /* @__PURE__ */ jsx("span", { className: styles$2.tableMenuDivider, "aria-hidden": true }) : null,
6261
+ index > 0 && item2.group !== items[index - 1].group ? /* @__PURE__ */ jsx("span", { className: styles$1.tableMenuDivider, "aria-hidden": true }) : null,
6029
6262
  /* @__PURE__ */ jsxs(
6030
6263
  "button",
6031
6264
  {
6032
6265
  type: "button",
6033
6266
  role: "menuitem",
6034
- className: styles$2.tableMenuItem,
6267
+ className: styles$1.tableMenuItem,
6035
6268
  disabled: item2.disabled,
6036
6269
  onClick: () => {
6037
6270
  item2.run();
6038
6271
  closeMenu();
6039
6272
  },
6040
6273
  children: [
6041
- /* @__PURE__ */ jsx("span", { className: styles$2.tableMenuItemIcon, "aria-hidden": true, children: item2.icon }),
6042
- /* @__PURE__ */ jsx("span", { className: styles$2.tableMenuItemLabel, children: item2.label })
6274
+ /* @__PURE__ */ jsx("span", { className: styles$1.tableMenuItemIcon, "aria-hidden": true, children: item2.icon }),
6275
+ /* @__PURE__ */ jsx("span", { className: styles$1.tableMenuItemLabel, children: item2.label })
6043
6276
  ]
6044
6277
  }
6045
6278
  )
6046
6279
  ] }, item2.key)),
6047
- /* @__PURE__ */ jsx("span", { className: styles$2.tableMenuDivider, "aria-hidden": true }),
6280
+ /* @__PURE__ */ jsx("span", { className: styles$1.tableMenuDivider, "aria-hidden": true }),
6048
6281
  /* @__PURE__ */ jsxs(
6049
6282
  "button",
6050
6283
  {
6051
6284
  type: "button",
6052
6285
  role: "menuitem",
6053
- className: styles$2.tableMenuItem,
6286
+ className: styles$1.tableMenuItem,
6054
6287
  onClick: () => {
6055
6288
  editor.commands.deleteTable();
6056
6289
  closeMenu();
6057
6290
  },
6058
6291
  children: [
6059
- /* @__PURE__ */ jsx("span", { className: styles$2.tableMenuItemIcon, "aria-hidden": true, children: /* @__PURE__ */ jsx(TableDeleteIcon, {}) }),
6060
- /* @__PURE__ */ jsx("span", { className: styles$2.tableMenuItemLabel, children: labels.tableDeleteTable })
6292
+ /* @__PURE__ */ jsx("span", { className: styles$1.tableMenuItemIcon, "aria-hidden": true, children: /* @__PURE__ */ jsx(TableDeleteIcon, {}) }),
6293
+ /* @__PURE__ */ jsx("span", { className: styles$1.tableMenuItemLabel, children: labels.tableDeleteTable })
6061
6294
  ]
6062
6295
  }
6063
6296
  )
@@ -6216,7 +6449,7 @@ function MathEditorPopover({
6216
6449
  "textarea",
6217
6450
  {
6218
6451
  ref: inputRef,
6219
- className: styles$6.mathInput,
6452
+ className: styles$5.mathInput,
6220
6453
  value: draft,
6221
6454
  placeholder,
6222
6455
  rows: Math.max(3, draft.split("\n").length),
@@ -6228,7 +6461,7 @@ function MathEditorPopover({
6228
6461
  "input",
6229
6462
  {
6230
6463
  ref: inputRef,
6231
- className: styles$6.mathInput,
6464
+ className: styles$5.mathInput,
6232
6465
  value: draft,
6233
6466
  placeholder,
6234
6467
  "aria-labelledby": titleId,
@@ -6242,7 +6475,7 @@ function MathEditorPopover({
6242
6475
  "div",
6243
6476
  {
6244
6477
  ref: rootRef,
6245
- className: styles$6.mathLayer,
6478
+ className: styles$5.mathLayer,
6246
6479
  style: layerStyle,
6247
6480
  role: "dialog",
6248
6481
  "aria-modal": "false",
@@ -6250,15 +6483,15 @@ function MathEditorPopover({
6250
6483
  children: /* @__PURE__ */ jsxs(
6251
6484
  "div",
6252
6485
  {
6253
- className: isBlock ? `${styles$6.mathStack} ${styles$6.mathStackBlock}` : styles$6.mathStack,
6486
+ className: isBlock ? `${styles$5.mathStack} ${styles$5.mathStackBlock}` : styles$5.mathStack,
6254
6487
  children: [
6255
6488
  showHint ? /* @__PURE__ */ jsxs(
6256
6489
  "div",
6257
6490
  {
6258
6491
  id: titleId,
6259
- className: isBlock ? `${styles$6.mathHint} ${styles$6.mathHintBlock}` : styles$6.mathHint,
6492
+ className: isBlock ? `${styles$5.mathHint} ${styles$5.mathHintBlock}` : styles$5.mathHint,
6260
6493
  children: [
6261
- /* @__PURE__ */ jsx("span", { className: styles$6.mathHintIcon, "aria-hidden": true, children: isBlock ? "TeX" : "√x" }),
6494
+ /* @__PURE__ */ jsx("span", { className: styles$5.mathHintIcon, "aria-hidden": true, children: isBlock ? "TeX" : "√x" }),
6262
6495
  newLabel
6263
6496
  ]
6264
6497
  }
@@ -6267,20 +6500,20 @@ function MathEditorPopover({
6267
6500
  "div",
6268
6501
  {
6269
6502
  id: showHint ? void 0 : titleId,
6270
- className: isBlock ? `${styles$6.mathField} ${styles$6.mathFieldBlock}` : styles$6.mathField,
6503
+ className: isBlock ? `${styles$5.mathField} ${styles$5.mathFieldBlock}` : styles$5.mathField,
6271
6504
  children: [
6272
6505
  field2,
6273
6506
  /* @__PURE__ */ jsxs(
6274
6507
  "button",
6275
6508
  {
6276
6509
  type: "button",
6277
- className: styles$6.mathDone,
6510
+ className: styles$5.mathDone,
6278
6511
  disabled: !canSubmit,
6279
6512
  title: isBlock ? `${doneLabel} (⌘/Ctrl+Enter)` : `${doneLabel} (Enter)`,
6280
6513
  onClick: submit,
6281
6514
  children: [
6282
6515
  doneLabel,
6283
- /* @__PURE__ */ jsx("span", { className: styles$6.mathDoneKbd, "aria-hidden": true, children: "↵" })
6516
+ /* @__PURE__ */ jsx("span", { className: styles$5.mathDoneKbd, "aria-hidden": true, children: "↵" })
6284
6517
  ]
6285
6518
  }
6286
6519
  )
@@ -6295,7 +6528,7 @@ function MathEditorPopover({
6295
6528
  host
6296
6529
  );
6297
6530
  }
6298
- const ToolbarButton = forwardRef(function ToolbarButton2({ title, active: active2, disabled, busy, onClick, children, className, ...rest }, ref) {
6531
+ const ToolbarButton = forwardRef(function ToolbarButton2({ title, active, disabled, busy, onClick, children, className, ...rest }, ref) {
6299
6532
  return /* @__PURE__ */ jsx(
6300
6533
  "button",
6301
6534
  {
@@ -6304,10 +6537,10 @@ const ToolbarButton = forwardRef(function ToolbarButton2({ title, active: active
6304
6537
  type: "button",
6305
6538
  title,
6306
6539
  "aria-label": title,
6307
- "aria-pressed": active2,
6540
+ "aria-pressed": active,
6308
6541
  "aria-busy": busy,
6309
6542
  disabled,
6310
- className: `${styles$6.btn} ${active2 ? styles$6.btnActive : ""}${className ? ` ${className}` : ""}`,
6543
+ className: `${styles$5.btn} ${active ? styles$5.btnActive : ""}${className ? ` ${className}` : ""}`,
6311
6544
  onMouseDown: (e2) => e2.preventDefault(),
6312
6545
  onClick,
6313
6546
  children
@@ -6315,7 +6548,7 @@ const ToolbarButton = forwardRef(function ToolbarButton2({ title, active: active
6315
6548
  );
6316
6549
  });
6317
6550
  function Divider() {
6318
- return /* @__PURE__ */ jsx("span", { className: styles$6.divider, "aria-hidden": true });
6551
+ return /* @__PURE__ */ jsx("span", { className: styles$5.divider, "aria-hidden": true });
6319
6552
  }
6320
6553
  const LINE_HEIGHTS = ["1", "1.15", "1.5", "2", "2.5", "3"];
6321
6554
  function readParaAttr(editor, name) {
@@ -6336,7 +6569,7 @@ function MenuPopover({
6336
6569
  /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(
6337
6570
  Popover.Content,
6338
6571
  {
6339
- className: contentClassName ? `${styles$6.menu} ${contentClassName}` : styles$6.menu,
6572
+ className: contentClassName ? `${styles$5.menu} ${contentClassName}` : styles$5.menu,
6340
6573
  sideOffset: 4,
6341
6574
  align,
6342
6575
  onOpenAutoFocus: (e2) => e2.preventDefault(),
@@ -6358,7 +6591,7 @@ function MenuItem({
6358
6591
  {
6359
6592
  type: "button",
6360
6593
  disabled,
6361
- className: `${styles$6.menuItem} ${selected ? styles$6.menuItemSelected : ""}`,
6594
+ className: `${styles$5.menuItem} ${selected ? styles$5.menuItemSelected : ""}`,
6362
6595
  onMouseDown: (e2) => e2.preventDefault(),
6363
6596
  onClick: () => {
6364
6597
  onSelect();
@@ -6373,29 +6606,29 @@ function NumberingFormatGrid({
6373
6606
  onSelect
6374
6607
  }) {
6375
6608
  const close = useContext(MenuCloseCtx);
6376
- return /* @__PURE__ */ jsx("div", { className: styles$6.numberingGrid, role: "group", "aria-label": "Numbering formats", children: NUMBERING_FORMAT_IDS.map((format) => {
6377
- const active2 = current === format;
6609
+ return /* @__PURE__ */ jsx("div", { className: styles$5.numberingGrid, role: "group", "aria-label": "Numbering formats", children: NUMBERING_FORMAT_IDS.map((format) => {
6610
+ const active = current === format;
6378
6611
  return /* @__PURE__ */ jsx(
6379
6612
  "button",
6380
6613
  {
6381
6614
  type: "button",
6382
6615
  role: "menuitem",
6383
6616
  "aria-label": NUMBERING_FORMAT_LABELS[format],
6384
- "aria-pressed": active2,
6385
- className: `${styles$6.numberingOption}${active2 ? ` ${styles$6.numberingOptionActive}` : ""}`,
6617
+ "aria-pressed": active,
6618
+ className: `${styles$5.numberingOption}${active ? ` ${styles$5.numberingOptionActive}` : ""}`,
6386
6619
  onMouseDown: (e2) => e2.preventDefault(),
6387
6620
  onClick: () => {
6388
6621
  onSelect(format);
6389
6622
  close();
6390
6623
  },
6391
- children: /* @__PURE__ */ jsx("span", { className: styles$6.numberingPreview, children: NUMBERING_FORMAT_PREVIEWS[format].map((row2, index) => /* @__PURE__ */ jsxs(
6624
+ children: /* @__PURE__ */ jsx("span", { className: styles$5.numberingPreview, children: NUMBERING_FORMAT_PREVIEWS[format].map((row2, index) => /* @__PURE__ */ jsxs(
6392
6625
  "span",
6393
6626
  {
6394
- className: styles$6.numberingPreviewRow,
6627
+ className: styles$5.numberingPreviewRow,
6395
6628
  "data-depth": row2.depth,
6396
6629
  children: [
6397
- /* @__PURE__ */ jsx("span", { className: styles$6.numberingPreviewMarker, children: row2.marker }),
6398
- /* @__PURE__ */ jsx("span", { className: styles$6.numberingPreviewLine })
6630
+ /* @__PURE__ */ jsx("span", { className: styles$5.numberingPreviewMarker, children: row2.marker }),
6631
+ /* @__PURE__ */ jsx("span", { className: styles$5.numberingPreviewLine })
6399
6632
  ]
6400
6633
  },
6401
6634
  `${format}-${index}`
@@ -6430,21 +6663,21 @@ function TableInsertItem({
6430
6663
  {
6431
6664
  type: "button",
6432
6665
  disabled,
6433
- className: `${styles$6.menuItem} ${open ? styles$6.menuItemSelected : ""}`,
6666
+ className: `${styles$5.menuItem} ${open ? styles$5.menuItemSelected : ""}`,
6434
6667
  onMouseDown: (e2) => e2.preventDefault(),
6435
6668
  children: [
6436
- /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
6437
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "⊞" }),
6669
+ /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
6670
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "⊞" }),
6438
6671
  labels.tableInsert
6439
6672
  ] }),
6440
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.tableInsertCaret })
6673
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.tableInsertCaret })
6441
6674
  ]
6442
6675
  }
6443
6676
  ) }),
6444
6677
  /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsxs(
6445
6678
  Popover.Content,
6446
6679
  {
6447
- className: styles$6.tableSizePicker,
6680
+ className: styles$5.tableSizePicker,
6448
6681
  side: "right",
6449
6682
  align: "start",
6450
6683
  sideOffset: 6,
@@ -6454,7 +6687,7 @@ function TableInsertItem({
6454
6687
  /* @__PURE__ */ jsx(
6455
6688
  "div",
6456
6689
  {
6457
- className: styles$6.tableSizeGrid,
6690
+ className: styles$5.tableSizeGrid,
6458
6691
  style: {
6459
6692
  gridTemplateColumns: `repeat(${TABLE_PICKER_COLS}, 1fr)`
6460
6693
  },
@@ -6462,13 +6695,13 @@ function TableInsertItem({
6462
6695
  children: Array.from({ length: TABLE_PICKER_ROWS * TABLE_PICKER_COLS }, (_, i) => {
6463
6696
  const col = i % TABLE_PICKER_COLS + 1;
6464
6697
  const row2 = Math.floor(i / TABLE_PICKER_COLS) + 1;
6465
- const active2 = hover.cols > 0 && col <= hover.cols && row2 <= hover.rows;
6698
+ const active = hover.cols > 0 && col <= hover.cols && row2 <= hover.rows;
6466
6699
  return /* @__PURE__ */ jsx(
6467
6700
  "button",
6468
6701
  {
6469
6702
  type: "button",
6470
6703
  "aria-label": labels.tableSizeSelected(col, row2),
6471
- className: `${styles$6.tableSizeCell} ${active2 ? styles$6.tableSizeCellActive : ""}`,
6704
+ className: `${styles$5.tableSizeCell} ${active ? styles$5.tableSizeCellActive : ""}`,
6472
6705
  onMouseDown: (e2) => e2.preventDefault(),
6473
6706
  onMouseEnter: () => setHover({ cols: col, rows: row2 }),
6474
6707
  onClick: () => {
@@ -6483,7 +6716,7 @@ function TableInsertItem({
6483
6716
  })
6484
6717
  }
6485
6718
  ),
6486
- /* @__PURE__ */ jsx("div", { className: styles$6.tableSizeLabel, children: hover.cols > 0 ? labels.tableSizeSelected(hover.cols, hover.rows) : labels.tableInsert })
6719
+ /* @__PURE__ */ jsx("div", { className: styles$5.tableSizeLabel, children: hover.cols > 0 ? labels.tableSizeSelected(hover.cols, hover.rows) : labels.tableInsert })
6487
6720
  ]
6488
6721
  }
6489
6722
  ) })
@@ -6505,20 +6738,20 @@ function ColorPopover({
6505
6738
  "button",
6506
6739
  {
6507
6740
  type: "button",
6508
- className: styles$6.btn,
6741
+ className: styles$5.btn,
6509
6742
  title,
6510
6743
  "aria-label": title,
6511
6744
  onMouseDown: (e2) => e2.preventDefault(),
6512
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.colorIcon, children: [
6513
- /* @__PURE__ */ jsx("span", { className: styles$6.colorIconGlyph, children: glyph }),
6514
- /* @__PURE__ */ jsx("span", { className: styles$6.colorIconBar, style: { background: bar2 } })
6745
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.colorIcon, children: [
6746
+ /* @__PURE__ */ jsx("span", { className: styles$5.colorIconGlyph, children: glyph }),
6747
+ /* @__PURE__ */ jsx("span", { className: styles$5.colorIconBar, style: { background: bar2 } })
6515
6748
  ] })
6516
6749
  }
6517
6750
  ) }),
6518
6751
  /* @__PURE__ */ jsx(Popover.Portal, { children: /* @__PURE__ */ jsx(
6519
6752
  Popover.Content,
6520
6753
  {
6521
- className: styles$6.popoverContent,
6754
+ className: styles$5.popoverContent,
6522
6755
  sideOffset: 4,
6523
6756
  align: "start",
6524
6757
  onOpenAutoFocus: (e2) => e2.preventDefault(),
@@ -6784,8 +7017,8 @@ function EditorToolbar({
6784
7017
  /* @__PURE__ */ jsx(
6785
7018
  "div",
6786
7019
  {
6787
- className: className ? `${styles$6.toolbar} ${className}` : styles$6.toolbar,
6788
- children: /* @__PURE__ */ jsxs("div", { className: styles$6.inner, children: [
7020
+ className: className ? `${styles$5.toolbar} ${className}` : styles$5.toolbar,
7021
+ children: /* @__PURE__ */ jsxs("div", { className: styles$5.inner, children: [
6789
7022
  /* @__PURE__ */ jsx(
6790
7023
  ToolbarButton,
6791
7024
  {
@@ -6812,12 +7045,12 @@ function EditorToolbar({
6812
7045
  "button",
6813
7046
  {
6814
7047
  type: "button",
6815
- className: styles$6.styleTrigger,
7048
+ className: styles$5.styleTrigger,
6816
7049
  title: t.style,
6817
7050
  onMouseDown: (e2) => e2.preventDefault(),
6818
7051
  children: [
6819
- /* @__PURE__ */ jsx("span", { className: styles$6.styleTriggerLabel, children: t.style }),
6820
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.styleTriggerCaret })
7052
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleTriggerLabel, children: t.style }),
7053
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.styleTriggerCaret })
6821
7054
  ]
6822
7055
  }
6823
7056
  ),
@@ -6827,8 +7060,8 @@ function EditorToolbar({
6827
7060
  {
6828
7061
  selected: (state.headingLevel ?? 0) === 0,
6829
7062
  onSelect: () => setBlockStyle(0),
6830
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
6831
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "¶" }),
7063
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7064
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "¶" }),
6832
7065
  t.normalText
6833
7066
  ] })
6834
7067
  }
@@ -6838,8 +7071,8 @@ function EditorToolbar({
6838
7071
  {
6839
7072
  selected: state.headingLevel === lv,
6840
7073
  onSelect: () => setBlockStyle(lv),
6841
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
6842
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: `H${lv}` }),
7074
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7075
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: `H${lv}` }),
6843
7076
  t.headingLabel(lv)
6844
7077
  ] })
6845
7078
  },
@@ -6855,14 +7088,14 @@ function EditorToolbar({
6855
7088
  "button",
6856
7089
  {
6857
7090
  type: "button",
6858
- className: styles$6.styleTrigger,
7091
+ className: styles$5.styleTrigger,
6859
7092
  title: t.fontSize,
6860
7093
  "aria-label": t.fontSize,
6861
7094
  disabled: !canEditFontSize,
6862
7095
  onMouseDown: (e2) => e2.preventDefault(),
6863
7096
  children: [
6864
- /* @__PURE__ */ jsx("span", { className: styles$6.styleTriggerLabel, children: state.fontSize || t.fontSize }),
6865
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.styleTriggerCaret })
7097
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleTriggerLabel, children: state.fontSize || t.fontSize }),
7098
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.styleTriggerCaret })
6866
7099
  ]
6867
7100
  }
6868
7101
  ),
@@ -6872,8 +7105,8 @@ function EditorToolbar({
6872
7105
  {
6873
7106
  selected: !state.fontSize,
6874
7107
  onSelect: () => applyFontSize(""),
6875
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
6876
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "A" }),
7108
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7109
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "A" }),
6877
7110
  t.fontSizeDefault
6878
7111
  ] })
6879
7112
  }
@@ -6883,8 +7116,8 @@ function EditorToolbar({
6883
7116
  {
6884
7117
  selected: state.fontSize === size,
6885
7118
  onSelect: () => applyFontSize(size),
6886
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
6887
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: parseInt(size, 10) }),
7119
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7120
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: parseInt(size, 10) }),
6888
7121
  size
6889
7122
  ] })
6890
7123
  },
@@ -6968,13 +7201,13 @@ function EditorToolbar({
6968
7201
  "button",
6969
7202
  {
6970
7203
  type: "button",
6971
- className: `${styles$6.scriptTrigger} ${scriptActive !== "normal" ? styles$6.btnActive : ""}`,
7204
+ className: `${styles$5.scriptTrigger} ${scriptActive !== "normal" ? styles$5.btnActive : ""}`,
6972
7205
  title: t.scriptMenu,
6973
7206
  "aria-label": t.scriptMenu,
6974
7207
  onMouseDown: (e2) => e2.preventDefault(),
6975
7208
  children: [
6976
- /* @__PURE__ */ jsx("span", { className: styles$6.scriptTriggerGlyph, children: "A" }),
6977
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.styleTriggerCaret })
7209
+ /* @__PURE__ */ jsx("span", { className: styles$5.scriptTriggerGlyph, children: "A" }),
7210
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.styleTriggerCaret })
6978
7211
  ]
6979
7212
  }
6980
7213
  ),
@@ -6984,8 +7217,8 @@ function EditorToolbar({
6984
7217
  {
6985
7218
  selected: scriptActive === "normal",
6986
7219
  onSelect: () => chain().unsetSuperscript().unsetSubscript().run(),
6987
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
6988
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "A" }),
7220
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7221
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "A" }),
6989
7222
  t.scriptNormal
6990
7223
  ] })
6991
7224
  }
@@ -6995,8 +7228,8 @@ function EditorToolbar({
6995
7228
  {
6996
7229
  selected: scriptActive === "superscript",
6997
7230
  onSelect: () => chain().unsetSubscript().toggleSuperscript().run(),
6998
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
6999
- /* @__PURE__ */ jsxs("span", { className: `${styles$6.styleIcon} ${styles$6.scriptGlyph}`, children: [
7231
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7232
+ /* @__PURE__ */ jsxs("span", { className: `${styles$5.styleIcon} ${styles$5.scriptGlyph}`, children: [
7000
7233
  "x",
7001
7234
  /* @__PURE__ */ jsx("sup", { children: "2" })
7002
7235
  ] }),
@@ -7009,8 +7242,8 @@ function EditorToolbar({
7009
7242
  {
7010
7243
  selected: scriptActive === "subscript",
7011
7244
  onSelect: () => chain().unsetSuperscript().toggleSubscript().run(),
7012
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7013
- /* @__PURE__ */ jsxs("span", { className: `${styles$6.styleIcon} ${styles$6.scriptGlyph}`, children: [
7245
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7246
+ /* @__PURE__ */ jsxs("span", { className: `${styles$5.styleIcon} ${styles$5.scriptGlyph}`, children: [
7014
7247
  "x",
7015
7248
  /* @__PURE__ */ jsx("sub", { children: "2" })
7016
7249
  ] }),
@@ -7050,19 +7283,19 @@ function EditorToolbar({
7050
7283
  "button",
7051
7284
  {
7052
7285
  type: "button",
7053
- className: styles$6.styleTrigger,
7286
+ className: styles$5.styleTrigger,
7054
7287
  title: importTitle,
7055
7288
  "aria-label": importTitle,
7056
7289
  "aria-busy": !!importing,
7057
7290
  disabled: !!importing,
7058
7291
  onMouseDown: (e2) => e2.preventDefault(),
7059
7292
  children: [
7060
- /* @__PURE__ */ jsx("span", { className: styles$6.styleTriggerLabel, children: t.importDocument }),
7293
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleTriggerLabel, children: t.importDocument }),
7061
7294
  /* @__PURE__ */ jsx(
7062
7295
  ChevronDownIcon,
7063
7296
  {
7064
7297
  size: 12,
7065
- className: styles$6.styleTriggerCaret
7298
+ className: styles$5.styleTriggerCaret
7066
7299
  }
7067
7300
  )
7068
7301
  ]
@@ -7084,7 +7317,7 @@ function EditorToolbar({
7084
7317
  title: t.blockquote,
7085
7318
  active: state.blockquote,
7086
7319
  onClick: () => chain().toggleBlockquote().run(),
7087
- children: /* @__PURE__ */ jsx("span", { className: styles$6.txtIcon, children: "❝" })
7320
+ children: /* @__PURE__ */ jsx("span", { className: styles$5.txtIcon, children: "❝" })
7088
7321
  }
7089
7322
  ),
7090
7323
  /* @__PURE__ */ jsx(
@@ -7108,13 +7341,13 @@ function EditorToolbar({
7108
7341
  "button",
7109
7342
  {
7110
7343
  type: "button",
7111
- className: `${styles$6.styleTrigger} ${styles$6.iconTrigger}`,
7344
+ className: `${styles$5.styleTrigger} ${styles$5.iconTrigger}`,
7112
7345
  title: t.align,
7113
7346
  "aria-label": t.align,
7114
7347
  onMouseDown: (e2) => e2.preventDefault(),
7115
7348
  children: [
7116
7349
  state.textAlign === "center" ? /* @__PURE__ */ jsx(AlignCenterIcon, {}) : state.textAlign === "right" ? /* @__PURE__ */ jsx(AlignRightIcon, {}) : state.textAlign === "justify" ? /* @__PURE__ */ jsx(AlignJustifyIcon, {}) : /* @__PURE__ */ jsx(AlignLeftIcon, {}),
7117
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.styleTriggerCaret })
7350
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.styleTriggerCaret })
7118
7351
  ]
7119
7352
  }
7120
7353
  ),
@@ -7128,8 +7361,8 @@ function EditorToolbar({
7128
7361
  {
7129
7362
  selected: state.textAlign === value,
7130
7363
  onSelect: () => chain().setTextAlign(value).run(),
7131
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7132
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: /* @__PURE__ */ jsx(Icon, { size: 14 }) }),
7364
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7365
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: /* @__PURE__ */ jsx(Icon, { size: 14 }) }),
7133
7366
  label
7134
7367
  ] })
7135
7368
  },
@@ -7144,23 +7377,23 @@ function EditorToolbar({
7144
7377
  "button",
7145
7378
  {
7146
7379
  type: "button",
7147
- className: `${styles$6.styleTrigger} ${styles$6.iconTrigger}`,
7380
+ className: `${styles$5.styleTrigger} ${styles$5.iconTrigger}`,
7148
7381
  title: t.indent,
7149
7382
  "aria-label": t.indent,
7150
7383
  onMouseDown: (e2) => e2.preventDefault(),
7151
7384
  children: [
7152
7385
  /* @__PURE__ */ jsx(IndentIncreaseIcon, {}),
7153
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.styleTriggerCaret })
7386
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.styleTriggerCaret })
7154
7387
  ]
7155
7388
  }
7156
7389
  ),
7157
7390
  children: [
7158
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().increaseIndent().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7159
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: /* @__PURE__ */ jsx(IndentIncreaseIcon, { size: 14 }) }),
7391
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().increaseIndent().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7392
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: /* @__PURE__ */ jsx(IndentIncreaseIcon, { size: 14 }) }),
7160
7393
  t.indentIncrease
7161
7394
  ] }) }),
7162
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().decreaseIndent().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7163
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: /* @__PURE__ */ jsx(IndentDecreaseIcon, { size: 14 }) }),
7395
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().decreaseIndent().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7396
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: /* @__PURE__ */ jsx(IndentDecreaseIcon, { size: 14 }) }),
7164
7397
  t.indentDecrease
7165
7398
  ] }) })
7166
7399
  ]
@@ -7173,13 +7406,13 @@ function EditorToolbar({
7173
7406
  "button",
7174
7407
  {
7175
7408
  type: "button",
7176
- className: `${styles$6.styleTrigger} ${styles$6.iconTrigger}`,
7409
+ className: `${styles$5.styleTrigger} ${styles$5.iconTrigger}`,
7177
7410
  title: t.lineHeight,
7178
7411
  "aria-label": t.lineHeight,
7179
7412
  onMouseDown: (e2) => e2.preventDefault(),
7180
7413
  children: [
7181
7414
  /* @__PURE__ */ jsx(LineHeightIcon, {}),
7182
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.styleTriggerCaret })
7415
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.styleTriggerCaret })
7183
7416
  ]
7184
7417
  }
7185
7418
  ),
@@ -7189,8 +7422,8 @@ function EditorToolbar({
7189
7422
  {
7190
7423
  selected: !state.lineHeight,
7191
7424
  onSelect: () => chain().setLineHeight(null).run(),
7192
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7193
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "—" }),
7425
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7426
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "—" }),
7194
7427
  t.lineHeightDefault
7195
7428
  ] })
7196
7429
  }
@@ -7200,8 +7433,8 @@ function EditorToolbar({
7200
7433
  {
7201
7434
  selected: state.lineHeight === Number(value),
7202
7435
  onSelect: () => chain().setLineHeight(Number(value)).run(),
7203
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7204
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "≡" }),
7436
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7437
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "≡" }),
7205
7438
  value
7206
7439
  ] })
7207
7440
  },
@@ -7223,7 +7456,7 @@ function EditorToolbar({
7223
7456
  /* @__PURE__ */ jsxs(
7224
7457
  "span",
7225
7458
  {
7226
- className: `${styles$6.listSplit}${state.orderedList ? ` ${styles$6.listSplitActive}` : ""}`,
7459
+ className: `${styles$5.listSplit}${state.orderedList ? ` ${styles$5.listSplitActive}` : ""}`,
7227
7460
  children: [
7228
7461
  /* @__PURE__ */ jsx(
7229
7462
  ToolbarButton,
@@ -7238,12 +7471,12 @@ function EditorToolbar({
7238
7471
  MenuPopover,
7239
7472
  {
7240
7473
  align: "end",
7241
- contentClassName: styles$6.numberingMenu,
7474
+ contentClassName: styles$5.numberingMenu,
7242
7475
  trigger: /* @__PURE__ */ jsx(
7243
7476
  "button",
7244
7477
  {
7245
7478
  type: "button",
7246
- className: `${styles$6.numberingCaret}${state.numberingFormat ? ` ${styles$6.numberingCaretActive}` : ""}`,
7479
+ className: `${styles$5.numberingCaret}${state.numberingFormat ? ` ${styles$5.numberingCaretActive}` : ""}`,
7247
7480
  title: t.numberingFormat,
7248
7481
  "aria-label": t.numberingFormat,
7249
7482
  onMouseDown: (e2) => e2.preventDefault(),
@@ -7288,30 +7521,30 @@ function EditorToolbar({
7288
7521
  "button",
7289
7522
  {
7290
7523
  type: "button",
7291
- className: styles$6.styleTrigger,
7524
+ className: styles$5.styleTrigger,
7292
7525
  title: t.more,
7293
7526
  onMouseDown: (e2) => e2.preventDefault(),
7294
7527
  children: [
7295
- /* @__PURE__ */ jsx("span", { className: styles$6.styleTriggerLabel, children: t.more }),
7296
- /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$6.styleTriggerCaret })
7528
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleTriggerLabel, children: t.more }),
7529
+ /* @__PURE__ */ jsx(ChevronDownIcon, { size: 12, className: styles$5.styleTriggerCaret })
7297
7530
  ]
7298
7531
  }
7299
7532
  ),
7300
7533
  children: [
7301
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().toggleCodeBlock().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7302
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "{ }" }),
7534
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().toggleCodeBlock().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7535
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "{ }" }),
7303
7536
  t.codeBlock
7304
7537
  ] }) }),
7305
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => openInsertMath("inline"), children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7306
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "√x" }),
7538
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => openInsertMath("inline"), children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7539
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "√x" }),
7307
7540
  t.inlineMath
7308
7541
  ] }) }),
7309
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => openInsertMath("block"), children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7310
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "∑" }),
7542
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => openInsertMath("block"), children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7543
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "∑" }),
7311
7544
  t.blockMath
7312
7545
  ] }) }),
7313
- /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().setHorizontalRule().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7314
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: "—" }),
7546
+ /* @__PURE__ */ jsx(MenuItem, { onSelect: () => chain().setHorizontalRule().run(), children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7547
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: "—" }),
7315
7548
  t.hr
7316
7549
  ] }) }),
7317
7550
  /* @__PURE__ */ jsx(
@@ -7327,8 +7560,8 @@ function EditorToolbar({
7327
7560
  {
7328
7561
  disabled: item2.disabled,
7329
7562
  onSelect: () => item2.onSelect(editor),
7330
- children: /* @__PURE__ */ jsxs("span", { className: styles$6.styleItem, children: [
7331
- /* @__PURE__ */ jsx("span", { className: styles$6.styleIcon, children: item2.icon }),
7563
+ children: /* @__PURE__ */ jsxs("span", { className: styles$5.styleItem, children: [
7564
+ /* @__PURE__ */ jsx("span", { className: styles$5.styleIcon, children: item2.icon }),
7332
7565
  item2.label
7333
7566
  ] })
7334
7567
  },
@@ -7369,159 +7602,6 @@ function EditorToolbar({
7369
7602
  /* @__PURE__ */ jsx(ImageAlignTools, { editor, labels: t })
7370
7603
  ] });
7371
7604
  }
7372
- const desktop = "_desktop_euqdt_3";
7373
- const header = "_header_euqdt_19";
7374
- const headerTitle = "_headerTitle_euqdt_27";
7375
- const collapseBtn = "_collapseBtn_euqdt_35";
7376
- const collapsedRail = "_collapsedRail_euqdt_55";
7377
- const list = "_list_euqdt_75";
7378
- const item = "_item_euqdt_81";
7379
- const itemText = "_itemText_euqdt_102";
7380
- const active = "_active_euqdt_109";
7381
- const locked = "_locked_euqdt_116";
7382
- const lockIcon = "_lockIcon_euqdt_126";
7383
- const mobile = "_mobile_euqdt_133";
7384
- const mobileBar = "_mobileBar_euqdt_138";
7385
- const mobileBarIcon = "_mobileBarIcon_euqdt_154";
7386
- const chevron = "_chevron_euqdt_159";
7387
- const chevronUp = "_chevronUp_euqdt_166";
7388
- const mobilePanel = "_mobilePanel_euqdt_170";
7389
- const mobilePanelOpen = "_mobilePanelOpen_euqdt_176";
7390
- const styles$1 = {
7391
- desktop,
7392
- header,
7393
- headerTitle,
7394
- collapseBtn,
7395
- collapsedRail,
7396
- list,
7397
- item,
7398
- itemText,
7399
- active,
7400
- locked,
7401
- lockIcon,
7402
- mobile,
7403
- mobileBar,
7404
- mobileBarIcon,
7405
- chevron,
7406
- chevronUp,
7407
- mobilePanel,
7408
- mobilePanelOpen
7409
- };
7410
- function TocPanel({
7411
- items,
7412
- activeId,
7413
- onItemClick,
7414
- locale = "en"
7415
- }) {
7416
- const t = getLocaleBundle(locale).toc;
7417
- const isMobile = useIsMobile();
7418
- const [collapsed, setCollapsed] = useState(false);
7419
- const [mobileOpen, setMobileOpen] = useState(false);
7420
- const desktopNavRef = useRef(null);
7421
- const mobilePanelRef = useRef(null);
7422
- useEffect(() => {
7423
- if (!activeId) return;
7424
- const reduce = window.matchMedia(
7425
- "(prefers-reduced-motion: reduce)"
7426
- ).matches;
7427
- const container = desktopNavRef.current || mobilePanelRef.current;
7428
- if (!container) return;
7429
- const el = container.querySelector(`a[href="#${CSS.escape(activeId)}"]`);
7430
- if (!el) return;
7431
- el.scrollIntoView({
7432
- block: "nearest",
7433
- behavior: reduce ? "auto" : "smooth"
7434
- });
7435
- }, [activeId]);
7436
- if (!items.length) return null;
7437
- const minLevel = Math.min(...items.map((i) => i.level));
7438
- const handleClick = (item2) => {
7439
- if (item2.locked) return;
7440
- onItemClick == null ? void 0 : onItemClick(item2);
7441
- if (isMobile) setMobileOpen(false);
7442
- };
7443
- const list2 = /* @__PURE__ */ jsx("ul", { className: styles$1.list, children: items.map((item2) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
7444
- "a",
7445
- {
7446
- href: item2.locked ? void 0 : `#${item2.id}`,
7447
- className: `${styles$1.item} ${item2.id === activeId ? styles$1.active : ""} ${item2.locked ? styles$1.locked : ""}`,
7448
- style: { paddingLeft: `${(item2.level - minLevel) * 12 + 12}px` },
7449
- "aria-current": item2.id === activeId ? "true" : void 0,
7450
- "aria-disabled": item2.locked ? "true" : void 0,
7451
- onClick: (e2) => {
7452
- e2.preventDefault();
7453
- handleClick(item2);
7454
- },
7455
- children: [
7456
- /* @__PURE__ */ jsx("span", { className: styles$1.itemText, children: item2.text }),
7457
- item2.locked ? /* @__PURE__ */ jsx(LockIcon, { className: styles$1.lockIcon, "aria-hidden": true }) : null
7458
- ]
7459
- }
7460
- ) }, item2.id)) });
7461
- if (isMobile) {
7462
- return /* @__PURE__ */ jsxs("nav", { className: styles$1.mobile, "aria-label": t.title, children: [
7463
- /* @__PURE__ */ jsxs(
7464
- "button",
7465
- {
7466
- type: "button",
7467
- className: styles$1.mobileBar,
7468
- "aria-expanded": mobileOpen,
7469
- onClick: () => setMobileOpen((v) => !v),
7470
- children: [
7471
- /* @__PURE__ */ jsx(MenuIcon, { className: styles$1.mobileBarIcon, "aria-hidden": true }),
7472
- /* @__PURE__ */ jsx("span", { children: t.title }),
7473
- /* @__PURE__ */ jsx(
7474
- "span",
7475
- {
7476
- className: `${styles$1.chevron} ${mobileOpen ? styles$1.chevronUp : ""}`,
7477
- "aria-hidden": true,
7478
- children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
7479
- }
7480
- )
7481
- ]
7482
- }
7483
- ),
7484
- /* @__PURE__ */ jsx(
7485
- "div",
7486
- {
7487
- ref: mobilePanelRef,
7488
- className: `${styles$1.mobilePanel} ${mobileOpen ? styles$1.mobilePanelOpen : ""}`,
7489
- children: list2
7490
- }
7491
- )
7492
- ] });
7493
- }
7494
- if (collapsed) {
7495
- return /* @__PURE__ */ jsx(
7496
- "button",
7497
- {
7498
- type: "button",
7499
- className: styles$1.collapsedRail,
7500
- "aria-label": t.expand,
7501
- title: t.expand,
7502
- onClick: () => setCollapsed(false),
7503
- children: /* @__PURE__ */ jsx(ListUnorderedIcon, {})
7504
- }
7505
- );
7506
- }
7507
- return /* @__PURE__ */ jsxs("nav", { className: styles$1.desktop, "aria-label": t.title, ref: desktopNavRef, children: [
7508
- /* @__PURE__ */ jsxs("div", { className: styles$1.header, children: [
7509
- /* @__PURE__ */ jsx("span", { className: styles$1.headerTitle, children: t.title }),
7510
- /* @__PURE__ */ jsx(
7511
- "button",
7512
- {
7513
- type: "button",
7514
- className: styles$1.collapseBtn,
7515
- "aria-label": t.collapse,
7516
- title: t.collapse,
7517
- onClick: () => setCollapsed(true),
7518
- children: "«"
7519
- }
7520
- )
7521
- ] }),
7522
- list2
7523
- ] });
7524
- }
7525
7605
  function resetImageSize(editor) {
7526
7606
  const pos = findImagePos(editor);
7527
7607
  if (pos == null) return false;
@@ -7566,10 +7646,10 @@ function CommentPopover({
7566
7646
  ] });
7567
7647
  }
7568
7648
  const PROBE_ID = "__anchor-range-probe__";
7569
- function findRangeByAnchor(editor, anchor) {
7570
- if (!anchor || !anchor.exact) return null;
7649
+ function findRangeByAnchor(editor, anchor2) {
7650
+ if (!anchor2 || !anchor2.exact) return null;
7571
7651
  const [result] = mapCommentAnchors(editor.state.doc, [
7572
- { commentId: PROBE_ID, segments: [anchor] }
7652
+ { commentId: PROBE_ID, segments: [anchor2] }
7573
7653
  ]);
7574
7654
  const range = result == null ? void 0 : result.ranges[0];
7575
7655
  if (!range) return null;
@@ -7765,7 +7845,6 @@ export {
7765
7845
  SlashMenu,
7766
7846
  StrikethroughIcon,
7767
7847
  TableDeleteIcon,
7768
- TocPanel,
7769
7848
  TrashIcon,
7770
7849
  UnderlineIcon,
7771
7850
  UndoIcon,
@@ -7825,14 +7904,14 @@ export {
7825
7904
  resetImageSize,
7826
7905
  runFindCommand,
7827
7906
  sanitizeLinkUrl,
7828
- s as scrollToTocHeading,
7907
+ scrollToTocHeading,
7829
7908
  selectionKind,
7830
- s2 as serializeChartPayload,
7909
+ s as serializeChartPayload,
7831
7910
  setImageAlign,
7832
7911
  setImageAlignAt,
7833
7912
  setImageCaption,
7834
7913
  setImageCaptionAtPos,
7835
- s3 as stabilizeMarkdown,
7914
+ s2 as stabilizeMarkdown,
7836
7915
  stripCommentAnchorMarks,
7837
7916
  useIsMobile
7838
7917
  };