tiptap-markdown-react 0.10.3 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -1
- package/THIRD_PARTY_LICENSES.md +2 -0
- package/dist/{ReportContent-XJE1P0zp.js → ReportContent-By-tSiNn.js} +9 -3
- package/dist/{ReportContent-XJE1P0zp.js.map → ReportContent-By-tSiNn.js.map} +1 -1
- package/dist/components/FindReplaceBar.d.ts +25 -0
- package/dist/components/FindReplaceBar.dom.test.d.ts +1 -0
- package/dist/components/MarkdownWysiwygEditor.d.ts +19 -1
- package/dist/{extractToc-BrN-Lwwy.js → extractToc-CB4RYsMJ.js} +2 -2
- package/dist/{extractToc-BrN-Lwwy.js.map → extractToc-CB4RYsMJ.js.map} +1 -1
- package/dist/findReplace.d.ts +30 -0
- package/dist/findReplace.test.d.ts +1 -0
- package/dist/icons/index.d.ts +5 -2
- package/dist/index.d.ts +5 -1
- package/dist/index.js +741 -365
- package/dist/index.js.map +1 -1
- package/dist/labels.d.ts +21 -0
- package/dist/reader.js +2 -2
- package/dist/{scrollToTocHeading-BnfiGfjk.js → scrollToTocHeading-EkePiWil.js} +2 -2
- package/dist/{scrollToTocHeading-BnfiGfjk.js.map → scrollToTocHeading-EkePiWil.js.map} +1 -1
- package/dist/server.js +4 -4
- package/dist/style.css +242 -49
- package/dist/taskListStyles.test.d.ts +1 -0
- package/package.json +30 -29
package/dist/index.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Markdown, MarkdownManager } from "@tiptap/markdown";
|
|
3
|
-
import { c as renderOrUpdateChart, d as destroyChart } from "./scrollToTocHeading-
|
|
4
|
-
import { C, a, R, b, f, m, r, s } from "./scrollToTocHeading-
|
|
3
|
+
import { c as renderOrUpdateChart, d as destroyChart } from "./scrollToTocHeading-EkePiWil.js";
|
|
4
|
+
import { C, a, R, b, f, m, r, s } from "./scrollToTocHeading-EkePiWil.js";
|
|
5
5
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
6
6
|
import CodeBlockLowlight from "@tiptap/extension-code-block-lowlight";
|
|
7
|
+
import FindAndReplace, { FindAndReplacePluginKey, createSearchRegex } from "@tiptap/extension-find-and-replace";
|
|
8
|
+
import { default as default2 } from "@tiptap/extension-find-and-replace";
|
|
7
9
|
import Image from "@tiptap/extension-image";
|
|
8
10
|
import { TableOfContents } from "@tiptap/extension-table-of-contents";
|
|
9
|
-
import { NodeViewWrapper, ReactNodeViewRenderer, NodeViewContent, useEditor, EditorContent
|
|
10
|
-
import {
|
|
11
|
-
import { e as enrichMarkdownCitations, b as styles$
|
|
12
|
-
import { R as R2, a as a2, s as s2 } from "./ReportContent-
|
|
13
|
-
import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, p as prepareChartMarkdown, j as reportChart, b as baseExtensions, f as CommentMark, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, a as pureCodeBlock, c as pureImage, n as renderMathInto, o as subscribeMathClick, d as pureChart } from "./extractToc-
|
|
14
|
-
import { g, e, s as s3 } from "./extractToc-
|
|
11
|
+
import { NodeViewWrapper, ReactNodeViewRenderer, useEditorState, NodeViewContent, useEditor, EditorContent } from "@tiptap/react";
|
|
12
|
+
import { useState, useRef, useCallback, useEffect, useMemo, forwardRef, useImperativeHandle, useId, useContext, createContext } from "react";
|
|
13
|
+
import { e as enrichMarkdownCitations, b as styles$6 } from "./ReportContent-By-tSiNn.js";
|
|
14
|
+
import { R as R2, a as a2, s as s2 } from "./ReportContent-By-tSiNn.js";
|
|
15
|
+
import { C as CitationRef, i as mergeCommentIntervals, h as mapCommentAnchors, p as prepareChartMarkdown, j as reportChart, b as baseExtensions, f as CommentMark, l as lowlight, m as makeTocGetId, k as parseCodeTokenAsChartOrCodeBlock, a as pureCodeBlock, c as pureImage, n as renderMathInto, o as subscribeMathClick, d as pureChart } from "./extractToc-CB4RYsMJ.js";
|
|
16
|
+
import { g, e, s as s3 } from "./extractToc-CB4RYsMJ.js";
|
|
15
17
|
import { Slice, Fragment } from "@tiptap/pm/model";
|
|
16
18
|
import { Extension, Node as Node$1 } from "@tiptap/core";
|
|
17
19
|
import { PluginKey, Plugin, NodeSelection, TextSelection } from "@tiptap/pm/state";
|
|
@@ -333,6 +335,561 @@ function nextComment(editor, dir = "next") {
|
|
|
333
335
|
focusComment(editor, target);
|
|
334
336
|
return target;
|
|
335
337
|
}
|
|
338
|
+
const FIND_DEBOUNCE_MS = 120;
|
|
339
|
+
const MISMATCH_RE = /Applying a mismatched transaction/;
|
|
340
|
+
function runFindCommand(run) {
|
|
341
|
+
try {
|
|
342
|
+
run();
|
|
343
|
+
} catch (error) {
|
|
344
|
+
if (error instanceof RangeError && MISMATCH_RE.test(error.message)) {
|
|
345
|
+
run();
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
throw error;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function Svg({ size = "1em", children, ...rest }) {
|
|
352
|
+
return /* @__PURE__ */ jsx(
|
|
353
|
+
"svg",
|
|
354
|
+
{
|
|
355
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
356
|
+
width: size,
|
|
357
|
+
height: size,
|
|
358
|
+
viewBox: "0 0 24 24",
|
|
359
|
+
fill: "none",
|
|
360
|
+
stroke: "currentColor",
|
|
361
|
+
strokeWidth: 2,
|
|
362
|
+
strokeLinecap: "round",
|
|
363
|
+
strokeLinejoin: "round",
|
|
364
|
+
"aria-hidden": "true",
|
|
365
|
+
focusable: "false",
|
|
366
|
+
...rest,
|
|
367
|
+
children
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
const BoldIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
372
|
+
/* @__PURE__ */ jsx("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
373
|
+
/* @__PURE__ */ jsx("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
374
|
+
] });
|
|
375
|
+
const ItalicIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
376
|
+
/* @__PURE__ */ jsx("line", { x1: "19", x2: "10", y1: "4", y2: "4" }),
|
|
377
|
+
/* @__PURE__ */ jsx("line", { x1: "14", x2: "5", y1: "20", y2: "20" }),
|
|
378
|
+
/* @__PURE__ */ jsx("line", { x1: "15", x2: "9", y1: "4", y2: "20" })
|
|
379
|
+
] });
|
|
380
|
+
const UnderlineIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
381
|
+
/* @__PURE__ */ jsx("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
|
|
382
|
+
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "20", y2: "20" })
|
|
383
|
+
] });
|
|
384
|
+
const StrikethroughIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
385
|
+
/* @__PURE__ */ jsx("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
386
|
+
/* @__PURE__ */ jsx("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
387
|
+
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" })
|
|
388
|
+
] });
|
|
389
|
+
const CodeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
390
|
+
/* @__PURE__ */ jsx("polyline", { points: "16 18 22 12 16 6" }),
|
|
391
|
+
/* @__PURE__ */ jsx("polyline", { points: "8 6 2 12 8 18" })
|
|
392
|
+
] });
|
|
393
|
+
const LinkIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
394
|
+
/* @__PURE__ */ jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
395
|
+
/* @__PURE__ */ jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
396
|
+
] });
|
|
397
|
+
const ImageIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
398
|
+
/* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2" }),
|
|
399
|
+
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "9", r: "2" }),
|
|
400
|
+
/* @__PURE__ */ jsx("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
|
|
401
|
+
] });
|
|
402
|
+
const ImportIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
403
|
+
/* @__PURE__ */ jsx("path", { d: "M12 3v12" }),
|
|
404
|
+
/* @__PURE__ */ jsx("path", { d: "m8 11 4 4 4-4" }),
|
|
405
|
+
/* @__PURE__ */ jsx("path", { d: "M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4" })
|
|
406
|
+
] });
|
|
407
|
+
const ListUnorderedIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
408
|
+
/* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "6", y2: "6" }),
|
|
409
|
+
/* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "12", y2: "12" }),
|
|
410
|
+
/* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "18", y2: "18" }),
|
|
411
|
+
/* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "6", y2: "6" }),
|
|
412
|
+
/* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "12", y2: "12" }),
|
|
413
|
+
/* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "18", y2: "18" })
|
|
414
|
+
] });
|
|
415
|
+
const ListOrderedIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
416
|
+
/* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "6", y2: "6" }),
|
|
417
|
+
/* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "12", y2: "12" }),
|
|
418
|
+
/* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "18", y2: "18" }),
|
|
419
|
+
/* @__PURE__ */ jsx("path", { d: "M4 6h1v4" }),
|
|
420
|
+
/* @__PURE__ */ jsx("path", { d: "M4 10h2" }),
|
|
421
|
+
/* @__PURE__ */ jsx("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
|
|
422
|
+
] });
|
|
423
|
+
const ListChecksIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
424
|
+
/* @__PURE__ */ jsx("path", { d: "m3 17 2 2 4-4" }),
|
|
425
|
+
/* @__PURE__ */ jsx("path", { d: "m3 7 2 2 4-4" }),
|
|
426
|
+
/* @__PURE__ */ jsx("path", { d: "M13 6h8" }),
|
|
427
|
+
/* @__PURE__ */ jsx("path", { d: "M13 12h8" }),
|
|
428
|
+
/* @__PURE__ */ jsx("path", { d: "M13 18h8" })
|
|
429
|
+
] });
|
|
430
|
+
const UndoIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
431
|
+
/* @__PURE__ */ jsx("path", { d: "M9 14 4 9l5-5" }),
|
|
432
|
+
/* @__PURE__ */ jsx("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5 5.5 5.5 0 0 1-5.5 5.5H11" })
|
|
433
|
+
] });
|
|
434
|
+
const RedoIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
435
|
+
/* @__PURE__ */ jsx("path", { d: "m15 14 5-5-5-5" }),
|
|
436
|
+
/* @__PURE__ */ jsx("path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5 5.5 5.5 0 0 0 9.5 20H13" })
|
|
437
|
+
] });
|
|
438
|
+
const ChevronDownIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }) });
|
|
439
|
+
const CheckIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
|
|
440
|
+
const TrashIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
441
|
+
/* @__PURE__ */ jsx("path", { d: "M3 6h18" }),
|
|
442
|
+
/* @__PURE__ */ jsx("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
|
|
443
|
+
/* @__PURE__ */ jsx("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
|
|
444
|
+
/* @__PURE__ */ jsx("line", { x1: "10", x2: "10", y1: "11", y2: "17" }),
|
|
445
|
+
/* @__PURE__ */ jsx("line", { x1: "14", x2: "14", y1: "11", y2: "17" })
|
|
446
|
+
] });
|
|
447
|
+
const LockIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
448
|
+
/* @__PURE__ */ jsx("rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2" }),
|
|
449
|
+
/* @__PURE__ */ jsx("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
|
|
450
|
+
] });
|
|
451
|
+
const MenuIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
452
|
+
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" }),
|
|
453
|
+
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "6", y2: "6" }),
|
|
454
|
+
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "18", y2: "18" })
|
|
455
|
+
] });
|
|
456
|
+
const SearchIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
457
|
+
/* @__PURE__ */ jsx("circle", { cx: "11", cy: "11", r: "8" }),
|
|
458
|
+
/* @__PURE__ */ jsx("path", { d: "m21 21-4.3-4.3" })
|
|
459
|
+
] });
|
|
460
|
+
const XIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
461
|
+
/* @__PURE__ */ jsx("path", { d: "M18 6 6 18" }),
|
|
462
|
+
/* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
|
|
463
|
+
] });
|
|
464
|
+
const ChevronUpIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }) });
|
|
465
|
+
const ColumnBeforeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
466
|
+
/* @__PURE__ */ jsx("rect", { x: "10", y: "4", width: "11", height: "16", rx: "1" }),
|
|
467
|
+
/* @__PURE__ */ jsx("path", { d: "M14 4v16" }),
|
|
468
|
+
/* @__PURE__ */ jsx("path", { d: "M5 9v6" }),
|
|
469
|
+
/* @__PURE__ */ jsx("path", { d: "M2 12h6" })
|
|
470
|
+
] });
|
|
471
|
+
const ColumnAfterIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
472
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "11", height: "16", rx: "1" }),
|
|
473
|
+
/* @__PURE__ */ jsx("path", { d: "M10 4v16" }),
|
|
474
|
+
/* @__PURE__ */ jsx("path", { d: "M19 9v6" }),
|
|
475
|
+
/* @__PURE__ */ jsx("path", { d: "M16 12h6" })
|
|
476
|
+
] });
|
|
477
|
+
const ColumnDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
478
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "1" }),
|
|
479
|
+
/* @__PURE__ */ jsx("path", { d: "M12 4v16" }),
|
|
480
|
+
/* @__PURE__ */ jsx("path", { d: "m8 9 8 6" }),
|
|
481
|
+
/* @__PURE__ */ jsx("path", { d: "m16 9-8 6" })
|
|
482
|
+
] });
|
|
483
|
+
const RowBeforeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
484
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "10", width: "16", height: "11", rx: "1" }),
|
|
485
|
+
/* @__PURE__ */ jsx("path", { d: "M4 14h16" }),
|
|
486
|
+
/* @__PURE__ */ jsx("path", { d: "M9 5h6" }),
|
|
487
|
+
/* @__PURE__ */ jsx("path", { d: "M12 2v6" })
|
|
488
|
+
] });
|
|
489
|
+
const RowAfterIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
490
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "3", width: "16", height: "11", rx: "1" }),
|
|
491
|
+
/* @__PURE__ */ jsx("path", { d: "M4 10h16" }),
|
|
492
|
+
/* @__PURE__ */ jsx("path", { d: "M9 19h6" }),
|
|
493
|
+
/* @__PURE__ */ jsx("path", { d: "M12 16v6" })
|
|
494
|
+
] });
|
|
495
|
+
const RowDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
496
|
+
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "1" }),
|
|
497
|
+
/* @__PURE__ */ jsx("path", { d: "M4 12h16" }),
|
|
498
|
+
/* @__PURE__ */ jsx("path", { d: "m9 8 6 8" }),
|
|
499
|
+
/* @__PURE__ */ jsx("path", { d: "m15 8-6 8" })
|
|
500
|
+
] });
|
|
501
|
+
const TableDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
502
|
+
/* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "18", height: "14", rx: "1" }),
|
|
503
|
+
/* @__PURE__ */ jsx("path", { d: "M3 9h18" }),
|
|
504
|
+
/* @__PURE__ */ jsx("path", { d: "M9 5v14" }),
|
|
505
|
+
/* @__PURE__ */ jsx("path", { d: "M15 5v14" }),
|
|
506
|
+
/* @__PURE__ */ jsx("path", { d: "m7 2 10 20" })
|
|
507
|
+
] });
|
|
508
|
+
const defaultChartLabels = {
|
|
509
|
+
tabLabel: (chartType, index) => `${chartType} ${index + 1}`,
|
|
510
|
+
done: "Done",
|
|
511
|
+
cancel: "Cancel",
|
|
512
|
+
configLabel: "Chart config (JSON)",
|
|
513
|
+
tableLabel: "Data table (Markdown)",
|
|
514
|
+
editTitle: "Edit chart"
|
|
515
|
+
};
|
|
516
|
+
const defaultToolbarLabels = {
|
|
517
|
+
undo: "Undo",
|
|
518
|
+
redo: "Redo",
|
|
519
|
+
style: "Style",
|
|
520
|
+
normalText: "Normal text",
|
|
521
|
+
headingLabel: (level) => `Heading ${level}`,
|
|
522
|
+
fontSize: "Font size",
|
|
523
|
+
fontSizeDefault: "Default",
|
|
524
|
+
bold: "Bold",
|
|
525
|
+
italic: "Italic",
|
|
526
|
+
underline: "Underline",
|
|
527
|
+
strike: "Strikethrough",
|
|
528
|
+
code: "Inline code",
|
|
529
|
+
textColor: "Text color",
|
|
530
|
+
highlight: "Highlight",
|
|
531
|
+
colorNone: "None",
|
|
532
|
+
colorTheme: "THEME",
|
|
533
|
+
scriptMenu: "Superscript / Subscript",
|
|
534
|
+
scriptNormal: "Normal",
|
|
535
|
+
superscript: "Superscript",
|
|
536
|
+
subscript: "Subscript",
|
|
537
|
+
link: "Link",
|
|
538
|
+
linkPrompt: "Enter URL",
|
|
539
|
+
image: "Image",
|
|
540
|
+
imageUploadFailed: "Image upload failed",
|
|
541
|
+
importMarkdownFailed: "Markdown import failed",
|
|
542
|
+
importDocument: "Import",
|
|
543
|
+
importDocumentHint: "Import a file",
|
|
544
|
+
importDocumentOther: "Document",
|
|
545
|
+
importDocumentBusy: "Importing…",
|
|
546
|
+
importDocumentUploading: (percent) => `Uploading ${percent}%`,
|
|
547
|
+
importDocumentConverting: "Converting…",
|
|
548
|
+
importDocumentFailed: "Import failed",
|
|
549
|
+
blockquote: "Blockquote",
|
|
550
|
+
bulletList: "Bullet list",
|
|
551
|
+
orderedList: "Ordered list",
|
|
552
|
+
taskList: "Task list",
|
|
553
|
+
more: "More",
|
|
554
|
+
codeBlock: "Code block",
|
|
555
|
+
hr: "Divider",
|
|
556
|
+
importMarkdown: "Markdown",
|
|
557
|
+
tableInsert: "Insert table",
|
|
558
|
+
tableSizeSelected: (cols, rows) => `${cols} × ${rows}`,
|
|
559
|
+
tableAddColumnBefore: "Add column before",
|
|
560
|
+
tableAddColumnAfter: "Add column after",
|
|
561
|
+
tableDeleteColumn: "Delete column",
|
|
562
|
+
tableAddRowBefore: "Add row before",
|
|
563
|
+
tableAddRowAfter: "Add row after",
|
|
564
|
+
tableDeleteRow: "Delete row",
|
|
565
|
+
tableAddColumnBeforeN: (n) => `Add ${n} columns before`,
|
|
566
|
+
tableAddColumnAfterN: (n) => `Add ${n} columns after`,
|
|
567
|
+
tableDeleteColumnN: (n) => `Delete ${n} columns`,
|
|
568
|
+
tableAddRowBeforeN: (n) => `Add ${n} rows before`,
|
|
569
|
+
tableAddRowAfterN: (n) => `Add ${n} rows after`,
|
|
570
|
+
tableDeleteRowN: (n) => `Delete ${n} rows`,
|
|
571
|
+
tableDeleteTable: "Delete table",
|
|
572
|
+
inlineMath: "Inline equation",
|
|
573
|
+
blockMath: "Block equation",
|
|
574
|
+
mathPlaceholder: "E = mc^2",
|
|
575
|
+
mathDone: "Done",
|
|
576
|
+
mathCancel: "Cancel",
|
|
577
|
+
mathNewInline: "New equation",
|
|
578
|
+
mathNewBlock: "Add a TeX equation"
|
|
579
|
+
};
|
|
580
|
+
const defaultColorPaletteLabels = {
|
|
581
|
+
none: "None",
|
|
582
|
+
theme: "THEME"
|
|
583
|
+
};
|
|
584
|
+
const defaultTocLabels = {
|
|
585
|
+
title: "Contents",
|
|
586
|
+
expand: "Expand",
|
|
587
|
+
collapse: "Collapse"
|
|
588
|
+
};
|
|
589
|
+
const defaultCodeBlockLabels = {
|
|
590
|
+
autoDetect: "Auto-detect",
|
|
591
|
+
delete: "Delete code block"
|
|
592
|
+
};
|
|
593
|
+
const defaultCommentLabels = {
|
|
594
|
+
open: "Open",
|
|
595
|
+
resolved: "Resolved",
|
|
596
|
+
dismissed: "Dismissed",
|
|
597
|
+
outdated: "Outdated",
|
|
598
|
+
ambiguous: "Ambiguous",
|
|
599
|
+
partial: "Partially matched",
|
|
600
|
+
gutterTitle: "Comment"
|
|
601
|
+
};
|
|
602
|
+
const defaultFindLabels = {
|
|
603
|
+
find: "Find",
|
|
604
|
+
replace: "Replace with",
|
|
605
|
+
next: "Next match",
|
|
606
|
+
previous: "Previous match",
|
|
607
|
+
replaceOne: "Replace",
|
|
608
|
+
replaceAll: "Replace all",
|
|
609
|
+
close: "Close",
|
|
610
|
+
caseSensitive: "Match case",
|
|
611
|
+
wholeWord: "Whole word",
|
|
612
|
+
useRegex: "Use regular expression",
|
|
613
|
+
counter: (current, total) => `${current} / ${total}`,
|
|
614
|
+
invalidRegex: "Invalid pattern",
|
|
615
|
+
readOnly: "Read-only"
|
|
616
|
+
};
|
|
617
|
+
const bar = "_bar_fzqxj_3";
|
|
618
|
+
const row = "_row_fzqxj_25";
|
|
619
|
+
const field = "_field_fzqxj_33";
|
|
620
|
+
const fieldIcon = "_fieldIcon_fzqxj_49";
|
|
621
|
+
const input = "_input_fzqxj_54";
|
|
622
|
+
const counter = "_counter_fzqxj_65";
|
|
623
|
+
const counterInvalid = "_counterInvalid_fzqxj_74";
|
|
624
|
+
const btn$1 = "_btn_fzqxj_78";
|
|
625
|
+
const toggle = "_toggle_fzqxj_106";
|
|
626
|
+
const toggleOn = "_toggleOn_fzqxj_111";
|
|
627
|
+
const textBtn = "_textBtn_fzqxj_121";
|
|
628
|
+
const spacer = "_spacer_fzqxj_126";
|
|
629
|
+
const readOnly = "_readOnly_fzqxj_131";
|
|
630
|
+
const styles$5 = {
|
|
631
|
+
bar,
|
|
632
|
+
row,
|
|
633
|
+
field,
|
|
634
|
+
fieldIcon,
|
|
635
|
+
input,
|
|
636
|
+
counter,
|
|
637
|
+
counterInvalid,
|
|
638
|
+
btn: btn$1,
|
|
639
|
+
toggle,
|
|
640
|
+
toggleOn,
|
|
641
|
+
textBtn,
|
|
642
|
+
spacer,
|
|
643
|
+
readOnly
|
|
644
|
+
};
|
|
645
|
+
function FindReplaceBar({
|
|
646
|
+
editor,
|
|
647
|
+
onClose,
|
|
648
|
+
labels,
|
|
649
|
+
inputRef,
|
|
650
|
+
className
|
|
651
|
+
}) {
|
|
652
|
+
const t = { ...defaultFindLabels, ...labels };
|
|
653
|
+
const [term, setTerm] = useState("");
|
|
654
|
+
const [replaceTerm, setReplaceTerm] = useState("");
|
|
655
|
+
const state = useEditorState({
|
|
656
|
+
editor,
|
|
657
|
+
selector: ({ editor: instance }) => {
|
|
658
|
+
const plugin = FindAndReplacePluginKey.getState(instance.state);
|
|
659
|
+
return {
|
|
660
|
+
currentIndex: (plugin == null ? void 0 : plugin.currentIndex) ?? null,
|
|
661
|
+
total: (plugin == null ? void 0 : plugin.results.length) ?? 0,
|
|
662
|
+
caseSensitive: (plugin == null ? void 0 : plugin.caseSensitive) ?? false,
|
|
663
|
+
wholeWord: (plugin == null ? void 0 : plugin.wholeWord) ?? false,
|
|
664
|
+
useRegex: (plugin == null ? void 0 : plugin.useRegex) ?? false
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
});
|
|
668
|
+
const appliedTermRef = useRef(null);
|
|
669
|
+
const pushTerm = useCallback(
|
|
670
|
+
(value) => {
|
|
671
|
+
appliedTermRef.current = value;
|
|
672
|
+
runFindCommand(() => editor.commands.setSearchTerm(value));
|
|
673
|
+
},
|
|
674
|
+
[editor]
|
|
675
|
+
);
|
|
676
|
+
const flushTerm = useCallback(() => {
|
|
677
|
+
if (appliedTermRef.current !== term) pushTerm(term);
|
|
678
|
+
}, [pushTerm, term]);
|
|
679
|
+
useEffect(() => {
|
|
680
|
+
if (appliedTermRef.current === term) return;
|
|
681
|
+
const timer = setTimeout(() => pushTerm(term), FIND_DEBOUNCE_MS);
|
|
682
|
+
return () => clearTimeout(timer);
|
|
683
|
+
}, [term, pushTerm]);
|
|
684
|
+
useEffect(() => {
|
|
685
|
+
runFindCommand(() => editor.commands.setReplaceTerm(replaceTerm));
|
|
686
|
+
}, [editor, replaceTerm]);
|
|
687
|
+
useEffect(() => {
|
|
688
|
+
return () => {
|
|
689
|
+
if (!editor.isDestroyed) editor.commands.clearSearch();
|
|
690
|
+
};
|
|
691
|
+
}, [editor]);
|
|
692
|
+
const runAction = useCallback(
|
|
693
|
+
(action) => {
|
|
694
|
+
flushTerm();
|
|
695
|
+
runFindCommand(action);
|
|
696
|
+
},
|
|
697
|
+
[flushTerm]
|
|
698
|
+
);
|
|
699
|
+
const invalidPattern = useMemo(
|
|
700
|
+
() => term !== "" && state.useRegex && createSearchRegex(term, {
|
|
701
|
+
caseSensitive: state.caseSensitive,
|
|
702
|
+
useRegex: true,
|
|
703
|
+
wholeWord: false
|
|
704
|
+
}) === null,
|
|
705
|
+
[term, state.useRegex, state.caseSensitive]
|
|
706
|
+
);
|
|
707
|
+
const counter2 = t.counter(
|
|
708
|
+
state.total === 0 ? 0 : (state.currentIndex ?? 0) + 1,
|
|
709
|
+
state.total
|
|
710
|
+
);
|
|
711
|
+
const keepFocus = (e2) => e2.preventDefault();
|
|
712
|
+
const onFindKeyDown = (e2) => {
|
|
713
|
+
if (e2.key === "Enter") {
|
|
714
|
+
e2.preventDefault();
|
|
715
|
+
runAction(() => {
|
|
716
|
+
if (e2.shiftKey) editor.commands.goToPreviousResult();
|
|
717
|
+
else editor.commands.goToNextResult();
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
const onReplaceKeyDown = (e2) => {
|
|
722
|
+
if (e2.key === "Enter") {
|
|
723
|
+
e2.preventDefault();
|
|
724
|
+
runAction(() => editor.commands.replace());
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
const toggle2 = (key, value) => {
|
|
728
|
+
runFindCommand(() => {
|
|
729
|
+
if (key === "caseSensitive") editor.commands.setCaseSensitive(value);
|
|
730
|
+
else if (key === "wholeWord") editor.commands.setWholeWord(value);
|
|
731
|
+
else editor.commands.setUseRegex(value);
|
|
732
|
+
});
|
|
733
|
+
};
|
|
734
|
+
const toggleClass = (on) => `${styles$5.btn} ${styles$5.toggle}${on ? ` ${styles$5.toggleOn}` : ""}`;
|
|
735
|
+
return /* @__PURE__ */ jsxs(
|
|
736
|
+
"div",
|
|
737
|
+
{
|
|
738
|
+
className: className ? `${styles$5.bar} ${className}` : styles$5.bar,
|
|
739
|
+
role: "dialog",
|
|
740
|
+
"aria-label": t.find,
|
|
741
|
+
onKeyDown: (e2) => {
|
|
742
|
+
if (e2.key === "Escape") {
|
|
743
|
+
e2.preventDefault();
|
|
744
|
+
onClose();
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
children: [
|
|
748
|
+
/* @__PURE__ */ jsxs("div", { className: styles$5.row, children: [
|
|
749
|
+
/* @__PURE__ */ jsxs("span", { className: styles$5.field, children: [
|
|
750
|
+
/* @__PURE__ */ jsx(SearchIcon, { size: 14, className: styles$5.fieldIcon }),
|
|
751
|
+
/* @__PURE__ */ jsx(
|
|
752
|
+
"input",
|
|
753
|
+
{
|
|
754
|
+
ref: inputRef,
|
|
755
|
+
className: styles$5.input,
|
|
756
|
+
value: term,
|
|
757
|
+
onChange: (e2) => setTerm(e2.target.value),
|
|
758
|
+
onKeyDown: onFindKeyDown,
|
|
759
|
+
placeholder: t.find,
|
|
760
|
+
"aria-label": t.find,
|
|
761
|
+
autoFocus: true,
|
|
762
|
+
spellCheck: false
|
|
763
|
+
}
|
|
764
|
+
)
|
|
765
|
+
] }),
|
|
766
|
+
/* @__PURE__ */ jsx(
|
|
767
|
+
"span",
|
|
768
|
+
{
|
|
769
|
+
className: `${styles$5.counter}${invalidPattern ? ` ${styles$5.counterInvalid}` : ""}`,
|
|
770
|
+
"aria-live": "polite",
|
|
771
|
+
title: invalidPattern ? t.invalidRegex : void 0,
|
|
772
|
+
children: invalidPattern ? t.invalidRegex : counter2
|
|
773
|
+
}
|
|
774
|
+
),
|
|
775
|
+
/* @__PURE__ */ jsx(
|
|
776
|
+
"button",
|
|
777
|
+
{
|
|
778
|
+
type: "button",
|
|
779
|
+
className: styles$5.btn,
|
|
780
|
+
title: t.previous,
|
|
781
|
+
"aria-label": t.previous,
|
|
782
|
+
disabled: state.total === 0,
|
|
783
|
+
onMouseDown: keepFocus,
|
|
784
|
+
onClick: () => runAction(() => editor.commands.goToPreviousResult()),
|
|
785
|
+
children: /* @__PURE__ */ jsx(ChevronUpIcon, { size: 16 })
|
|
786
|
+
}
|
|
787
|
+
),
|
|
788
|
+
/* @__PURE__ */ jsx(
|
|
789
|
+
"button",
|
|
790
|
+
{
|
|
791
|
+
type: "button",
|
|
792
|
+
className: styles$5.btn,
|
|
793
|
+
title: t.next,
|
|
794
|
+
"aria-label": t.next,
|
|
795
|
+
disabled: state.total === 0,
|
|
796
|
+
onMouseDown: keepFocus,
|
|
797
|
+
onClick: () => runAction(() => editor.commands.goToNextResult()),
|
|
798
|
+
children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
|
|
799
|
+
}
|
|
800
|
+
),
|
|
801
|
+
/* @__PURE__ */ jsx(
|
|
802
|
+
"button",
|
|
803
|
+
{
|
|
804
|
+
type: "button",
|
|
805
|
+
className: styles$5.btn,
|
|
806
|
+
title: t.close,
|
|
807
|
+
"aria-label": t.close,
|
|
808
|
+
onClick: onClose,
|
|
809
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: 16 })
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] }),
|
|
813
|
+
editor.isEditable ? /* @__PURE__ */ jsxs("div", { className: styles$5.row, children: [
|
|
814
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.field, children: /* @__PURE__ */ jsx(
|
|
815
|
+
"input",
|
|
816
|
+
{
|
|
817
|
+
className: styles$5.input,
|
|
818
|
+
value: replaceTerm,
|
|
819
|
+
onChange: (e2) => setReplaceTerm(e2.target.value),
|
|
820
|
+
onKeyDown: onReplaceKeyDown,
|
|
821
|
+
placeholder: t.replace,
|
|
822
|
+
"aria-label": t.replace,
|
|
823
|
+
spellCheck: false
|
|
824
|
+
}
|
|
825
|
+
) }),
|
|
826
|
+
/* @__PURE__ */ jsx(
|
|
827
|
+
"button",
|
|
828
|
+
{
|
|
829
|
+
type: "button",
|
|
830
|
+
className: toggleClass(state.caseSensitive),
|
|
831
|
+
title: t.caseSensitive,
|
|
832
|
+
"aria-label": t.caseSensitive,
|
|
833
|
+
"aria-pressed": state.caseSensitive,
|
|
834
|
+
onMouseDown: keepFocus,
|
|
835
|
+
onClick: () => toggle2("caseSensitive", !state.caseSensitive),
|
|
836
|
+
children: "Aa"
|
|
837
|
+
}
|
|
838
|
+
),
|
|
839
|
+
/* @__PURE__ */ jsx(
|
|
840
|
+
"button",
|
|
841
|
+
{
|
|
842
|
+
type: "button",
|
|
843
|
+
className: toggleClass(state.wholeWord),
|
|
844
|
+
title: t.wholeWord,
|
|
845
|
+
"aria-label": t.wholeWord,
|
|
846
|
+
"aria-pressed": state.wholeWord,
|
|
847
|
+
onMouseDown: keepFocus,
|
|
848
|
+
onClick: () => toggle2("wholeWord", !state.wholeWord),
|
|
849
|
+
children: "ab"
|
|
850
|
+
}
|
|
851
|
+
),
|
|
852
|
+
/* @__PURE__ */ jsx(
|
|
853
|
+
"button",
|
|
854
|
+
{
|
|
855
|
+
type: "button",
|
|
856
|
+
className: toggleClass(state.useRegex),
|
|
857
|
+
title: t.useRegex,
|
|
858
|
+
"aria-label": t.useRegex,
|
|
859
|
+
"aria-pressed": state.useRegex,
|
|
860
|
+
onMouseDown: keepFocus,
|
|
861
|
+
onClick: () => toggle2("useRegex", !state.useRegex),
|
|
862
|
+
children: ".*"
|
|
863
|
+
}
|
|
864
|
+
),
|
|
865
|
+
/* @__PURE__ */ jsx("span", { className: styles$5.spacer }),
|
|
866
|
+
/* @__PURE__ */ jsx(
|
|
867
|
+
"button",
|
|
868
|
+
{
|
|
869
|
+
type: "button",
|
|
870
|
+
className: `${styles$5.btn} ${styles$5.textBtn}`,
|
|
871
|
+
disabled: state.total === 0,
|
|
872
|
+
onMouseDown: keepFocus,
|
|
873
|
+
onClick: () => runAction(() => editor.commands.replace()),
|
|
874
|
+
children: t.replaceOne
|
|
875
|
+
}
|
|
876
|
+
),
|
|
877
|
+
/* @__PURE__ */ jsx(
|
|
878
|
+
"button",
|
|
879
|
+
{
|
|
880
|
+
type: "button",
|
|
881
|
+
className: `${styles$5.btn} ${styles$5.textBtn}`,
|
|
882
|
+
disabled: state.total === 0,
|
|
883
|
+
onMouseDown: keepFocus,
|
|
884
|
+
onClick: () => runAction(() => editor.commands.replaceAll()),
|
|
885
|
+
children: t.replaceAll
|
|
886
|
+
}
|
|
887
|
+
)
|
|
888
|
+
] }) : /* @__PURE__ */ jsx("div", { className: styles$5.row, children: /* @__PURE__ */ jsx("span", { className: styles$5.readOnly, children: t.readOnly }) })
|
|
889
|
+
]
|
|
890
|
+
}
|
|
891
|
+
);
|
|
892
|
+
}
|
|
336
893
|
function findPlaceholderPos(doc) {
|
|
337
894
|
let found = null;
|
|
338
895
|
doc.descendants((node, pos) => {
|
|
@@ -485,186 +1042,92 @@ const pendingAnchorExtension = Extension.create({
|
|
|
485
1042
|
];
|
|
486
1043
|
}
|
|
487
1044
|
});
|
|
488
|
-
function setPendingAnchors(editor, anchors) {
|
|
489
|
-
editor.view.dispatch(
|
|
490
|
-
editor.state.tr.setMeta(PENDING_ANCHOR_META, anchors).setMeta(skipTrailingNodeMeta, true).setMeta("addToHistory", false)
|
|
491
|
-
);
|
|
492
|
-
}
|
|
493
|
-
function buildDecorations(doc, anchors) {
|
|
494
|
-
const bounds = [];
|
|
495
|
-
doc.forEach((child, offset) => {
|
|
496
|
-
bounds.push({ from: offset, to: offset + child.nodeSize });
|
|
497
|
-
});
|
|
498
|
-
const decorations = [];
|
|
499
|
-
for (const anchor of anchors) {
|
|
500
|
-
for (const range of anchor.ranges) {
|
|
501
|
-
const from = Math.max(0, Math.min(range.from, range.to));
|
|
502
|
-
const to = Math.min(doc.content.size, Math.max(range.from, range.to));
|
|
503
|
-
if (from >= to) continue;
|
|
504
|
-
for (const bound of bounds) {
|
|
505
|
-
if (bound.to <= from || bound.from >= to) continue;
|
|
506
|
-
const attrs = {
|
|
507
|
-
class: PENDING_ANCHOR_CLASS,
|
|
508
|
-
"data-pending-id": anchor.id
|
|
509
|
-
};
|
|
510
|
-
if (from <= bound.from && to >= bound.to) {
|
|
511
|
-
decorations.push(Decoration.node(bound.from, bound.to, attrs));
|
|
512
|
-
} else {
|
|
513
|
-
decorations.push(
|
|
514
|
-
Decoration.inline(Math.max(from, bound.from), Math.min(to, bound.to), attrs)
|
|
515
|
-
);
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
return decorations.length ? DecorationSet.create(doc, decorations) : DecorationSet.empty;
|
|
521
|
-
}
|
|
522
|
-
function selectionKind(selection) {
|
|
523
|
-
if (selection instanceof CellSelection) return "cell";
|
|
524
|
-
if (selection instanceof NodeSelection) return "node";
|
|
525
|
-
if (selection instanceof TextSelection) return "text";
|
|
526
|
-
return "text";
|
|
527
|
-
}
|
|
528
|
-
function looksLikeMarkdown(text) {
|
|
529
|
-
return /^#{1,6}\s/m.test(text) || // 标题
|
|
530
|
-
/\*\*[^*\n]+\*\*/.test(text) || // 加粗
|
|
531
|
-
/(^|[^!])\[[^\]\n]+\]\([^)\n]+\)/.test(text) || // 链接
|
|
532
|
-
/!\[[^\]\n]*\]\([^)\n]+\)/.test(text) || // 图片
|
|
533
|
-
/^[-*+]\s+\S/m.test(text) || // 无序列表
|
|
534
|
-
/^\d+\.\s+\S/m.test(text) || // 有序列表
|
|
535
|
-
/^>\s/m.test(text) || // 引用
|
|
536
|
-
/^```/m.test(text) || // 代码围栏
|
|
537
|
-
/^\|.+\|\s*$/m.test(text) || // 表格行
|
|
538
|
-
/^(-{3,}|\*{3,})\s*$/m.test(text) || // 分割线
|
|
539
|
-
/<!--\s*[\[{][\s\S]*?"chartType"[\s\S]*?-->/.test(text);
|
|
540
|
-
}
|
|
541
|
-
const MarkdownPaste = Extension.create({
|
|
542
|
-
name: "markdownPaste",
|
|
543
|
-
addProseMirrorPlugins() {
|
|
544
|
-
const { editor } = this;
|
|
545
|
-
return [
|
|
546
|
-
new Plugin({
|
|
547
|
-
key: new PluginKey("markdownPaste"),
|
|
548
|
-
props: {
|
|
549
|
-
handlePaste(view, event) {
|
|
550
|
-
const clipboard = event.clipboardData;
|
|
551
|
-
if (!clipboard) return false;
|
|
552
|
-
const text = clipboard.getData("text/plain");
|
|
553
|
-
if (!text) return false;
|
|
554
|
-
const
|
|
555
|
-
if (
|
|
556
|
-
if (view.state.selection.$from.parent.type.spec.code) return false;
|
|
557
|
-
if (!looksLikeMarkdown(text)) return false;
|
|
558
|
-
const markdown = editor.markdown;
|
|
559
|
-
if (!markdown) return false;
|
|
560
|
-
try {
|
|
561
|
-
const json = markdown.parse(prepareChartMarkdown(text));
|
|
562
|
-
editor.commands.insertContent(json);
|
|
563
|
-
return true;
|
|
564
|
-
} catch (err) {
|
|
565
|
-
console.error("markdown paste parse failed:", err);
|
|
566
|
-
return false;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
})
|
|
571
|
-
];
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
const defaultChartLabels = {
|
|
575
|
-
tabLabel: (chartType, index) => `${chartType} ${index + 1}`,
|
|
576
|
-
done: "Done",
|
|
577
|
-
cancel: "Cancel",
|
|
578
|
-
configLabel: "Chart config (JSON)",
|
|
579
|
-
tableLabel: "Data table (Markdown)",
|
|
580
|
-
editTitle: "Edit chart"
|
|
581
|
-
};
|
|
582
|
-
const defaultToolbarLabels = {
|
|
583
|
-
undo: "Undo",
|
|
584
|
-
redo: "Redo",
|
|
585
|
-
style: "Style",
|
|
586
|
-
normalText: "Normal text",
|
|
587
|
-
headingLabel: (level) => `Heading ${level}`,
|
|
588
|
-
fontSize: "Font size",
|
|
589
|
-
fontSizeDefault: "Default",
|
|
590
|
-
bold: "Bold",
|
|
591
|
-
italic: "Italic",
|
|
592
|
-
underline: "Underline",
|
|
593
|
-
strike: "Strikethrough",
|
|
594
|
-
code: "Inline code",
|
|
595
|
-
textColor: "Text color",
|
|
596
|
-
highlight: "Highlight",
|
|
597
|
-
colorNone: "None",
|
|
598
|
-
colorTheme: "THEME",
|
|
599
|
-
scriptMenu: "Superscript / Subscript",
|
|
600
|
-
scriptNormal: "Normal",
|
|
601
|
-
superscript: "Superscript",
|
|
602
|
-
subscript: "Subscript",
|
|
603
|
-
link: "Link",
|
|
604
|
-
linkPrompt: "Enter URL",
|
|
605
|
-
image: "Image",
|
|
606
|
-
imageUploadFailed: "Image upload failed",
|
|
607
|
-
importMarkdownFailed: "Markdown import failed",
|
|
608
|
-
importDocument: "Import",
|
|
609
|
-
importDocumentHint: "Import a file",
|
|
610
|
-
importDocumentOther: "Document",
|
|
611
|
-
importDocumentBusy: "Importing…",
|
|
612
|
-
importDocumentUploading: (percent) => `Uploading ${percent}%`,
|
|
613
|
-
importDocumentConverting: "Converting…",
|
|
614
|
-
importDocumentFailed: "Import failed",
|
|
615
|
-
blockquote: "Blockquote",
|
|
616
|
-
bulletList: "Bullet list",
|
|
617
|
-
orderedList: "Ordered list",
|
|
618
|
-
taskList: "Task list",
|
|
619
|
-
more: "More",
|
|
620
|
-
codeBlock: "Code block",
|
|
621
|
-
hr: "Divider",
|
|
622
|
-
importMarkdown: "Markdown",
|
|
623
|
-
tableInsert: "Insert table",
|
|
624
|
-
tableSizeSelected: (cols, rows) => `${cols} × ${rows}`,
|
|
625
|
-
tableAddColumnBefore: "Add column before",
|
|
626
|
-
tableAddColumnAfter: "Add column after",
|
|
627
|
-
tableDeleteColumn: "Delete column",
|
|
628
|
-
tableAddRowBefore: "Add row before",
|
|
629
|
-
tableAddRowAfter: "Add row after",
|
|
630
|
-
tableDeleteRow: "Delete row",
|
|
631
|
-
tableAddColumnBeforeN: (n) => `Add ${n} columns before`,
|
|
632
|
-
tableAddColumnAfterN: (n) => `Add ${n} columns after`,
|
|
633
|
-
tableDeleteColumnN: (n) => `Delete ${n} columns`,
|
|
634
|
-
tableAddRowBeforeN: (n) => `Add ${n} rows before`,
|
|
635
|
-
tableAddRowAfterN: (n) => `Add ${n} rows after`,
|
|
636
|
-
tableDeleteRowN: (n) => `Delete ${n} rows`,
|
|
637
|
-
tableDeleteTable: "Delete table",
|
|
638
|
-
inlineMath: "Inline equation",
|
|
639
|
-
blockMath: "Block equation",
|
|
640
|
-
mathPlaceholder: "E = mc^2",
|
|
641
|
-
mathDone: "Done",
|
|
642
|
-
mathCancel: "Cancel",
|
|
643
|
-
mathNewInline: "New equation",
|
|
644
|
-
mathNewBlock: "Add a TeX equation"
|
|
645
|
-
};
|
|
646
|
-
const defaultColorPaletteLabels = {
|
|
647
|
-
none: "None",
|
|
648
|
-
theme: "THEME"
|
|
649
|
-
};
|
|
650
|
-
const defaultTocLabels = {
|
|
651
|
-
title: "Contents",
|
|
652
|
-
expand: "Expand",
|
|
653
|
-
collapse: "Collapse"
|
|
654
|
-
};
|
|
655
|
-
const defaultCodeBlockLabels = {
|
|
656
|
-
autoDetect: "Auto-detect",
|
|
657
|
-
delete: "Delete code block"
|
|
658
|
-
};
|
|
659
|
-
const defaultCommentLabels = {
|
|
660
|
-
open: "Open",
|
|
661
|
-
resolved: "Resolved",
|
|
662
|
-
dismissed: "Dismissed",
|
|
663
|
-
outdated: "Outdated",
|
|
664
|
-
ambiguous: "Ambiguous",
|
|
665
|
-
partial: "Partially matched",
|
|
666
|
-
gutterTitle: "Comment"
|
|
667
|
-
};
|
|
1045
|
+
function setPendingAnchors(editor, anchors) {
|
|
1046
|
+
editor.view.dispatch(
|
|
1047
|
+
editor.state.tr.setMeta(PENDING_ANCHOR_META, anchors).setMeta(skipTrailingNodeMeta, true).setMeta("addToHistory", false)
|
|
1048
|
+
);
|
|
1049
|
+
}
|
|
1050
|
+
function buildDecorations(doc, anchors) {
|
|
1051
|
+
const bounds = [];
|
|
1052
|
+
doc.forEach((child, offset) => {
|
|
1053
|
+
bounds.push({ from: offset, to: offset + child.nodeSize });
|
|
1054
|
+
});
|
|
1055
|
+
const decorations = [];
|
|
1056
|
+
for (const anchor of anchors) {
|
|
1057
|
+
for (const range of anchor.ranges) {
|
|
1058
|
+
const from = Math.max(0, Math.min(range.from, range.to));
|
|
1059
|
+
const to = Math.min(doc.content.size, Math.max(range.from, range.to));
|
|
1060
|
+
if (from >= to) continue;
|
|
1061
|
+
for (const bound of bounds) {
|
|
1062
|
+
if (bound.to <= from || bound.from >= to) continue;
|
|
1063
|
+
const attrs = {
|
|
1064
|
+
class: PENDING_ANCHOR_CLASS,
|
|
1065
|
+
"data-pending-id": anchor.id
|
|
1066
|
+
};
|
|
1067
|
+
if (from <= bound.from && to >= bound.to) {
|
|
1068
|
+
decorations.push(Decoration.node(bound.from, bound.to, attrs));
|
|
1069
|
+
} else {
|
|
1070
|
+
decorations.push(
|
|
1071
|
+
Decoration.inline(Math.max(from, bound.from), Math.min(to, bound.to), attrs)
|
|
1072
|
+
);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
return decorations.length ? DecorationSet.create(doc, decorations) : DecorationSet.empty;
|
|
1078
|
+
}
|
|
1079
|
+
function selectionKind(selection) {
|
|
1080
|
+
if (selection instanceof CellSelection) return "cell";
|
|
1081
|
+
if (selection instanceof NodeSelection) return "node";
|
|
1082
|
+
if (selection instanceof TextSelection) return "text";
|
|
1083
|
+
return "text";
|
|
1084
|
+
}
|
|
1085
|
+
function looksLikeMarkdown(text) {
|
|
1086
|
+
return /^#{1,6}\s/m.test(text) || // 标题
|
|
1087
|
+
/\*\*[^*\n]+\*\*/.test(text) || // 加粗
|
|
1088
|
+
/(^|[^!])\[[^\]\n]+\]\([^)\n]+\)/.test(text) || // 链接
|
|
1089
|
+
/!\[[^\]\n]*\]\([^)\n]+\)/.test(text) || // 图片
|
|
1090
|
+
/^[-*+]\s+\S/m.test(text) || // 无序列表
|
|
1091
|
+
/^\d+\.\s+\S/m.test(text) || // 有序列表
|
|
1092
|
+
/^>\s/m.test(text) || // 引用
|
|
1093
|
+
/^```/m.test(text) || // 代码围栏
|
|
1094
|
+
/^\|.+\|\s*$/m.test(text) || // 表格行
|
|
1095
|
+
/^(-{3,}|\*{3,})\s*$/m.test(text) || // 分割线
|
|
1096
|
+
/<!--\s*[\[{][\s\S]*?"chartType"[\s\S]*?-->/.test(text);
|
|
1097
|
+
}
|
|
1098
|
+
const MarkdownPaste = Extension.create({
|
|
1099
|
+
name: "markdownPaste",
|
|
1100
|
+
addProseMirrorPlugins() {
|
|
1101
|
+
const { editor } = this;
|
|
1102
|
+
return [
|
|
1103
|
+
new Plugin({
|
|
1104
|
+
key: new PluginKey("markdownPaste"),
|
|
1105
|
+
props: {
|
|
1106
|
+
handlePaste(view, event) {
|
|
1107
|
+
const clipboard = event.clipboardData;
|
|
1108
|
+
if (!clipboard) return false;
|
|
1109
|
+
const text = clipboard.getData("text/plain");
|
|
1110
|
+
if (!text) return false;
|
|
1111
|
+
const input2 = view.input;
|
|
1112
|
+
if (input2 == null ? void 0 : input2.shiftKey) return false;
|
|
1113
|
+
if (view.state.selection.$from.parent.type.spec.code) return false;
|
|
1114
|
+
if (!looksLikeMarkdown(text)) return false;
|
|
1115
|
+
const markdown = editor.markdown;
|
|
1116
|
+
if (!markdown) return false;
|
|
1117
|
+
try {
|
|
1118
|
+
const json = markdown.parse(prepareChartMarkdown(text));
|
|
1119
|
+
editor.commands.insertContent(json);
|
|
1120
|
+
return true;
|
|
1121
|
+
} catch (err) {
|
|
1122
|
+
console.error("markdown paste parse failed:", err);
|
|
1123
|
+
return false;
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1127
|
+
})
|
|
1128
|
+
];
|
|
1129
|
+
}
|
|
1130
|
+
});
|
|
668
1131
|
function tabLabel(chartType, title, index, fallback) {
|
|
669
1132
|
if (title == null ? void 0 : title.trim()) return title;
|
|
670
1133
|
return fallback(chartType, index);
|
|
@@ -787,154 +1250,6 @@ function createChart(options = {}) {
|
|
|
787
1250
|
}
|
|
788
1251
|
});
|
|
789
1252
|
}
|
|
790
|
-
function Svg({ size = "1em", children, ...rest }) {
|
|
791
|
-
return /* @__PURE__ */ jsx(
|
|
792
|
-
"svg",
|
|
793
|
-
{
|
|
794
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
795
|
-
width: size,
|
|
796
|
-
height: size,
|
|
797
|
-
viewBox: "0 0 24 24",
|
|
798
|
-
fill: "none",
|
|
799
|
-
stroke: "currentColor",
|
|
800
|
-
strokeWidth: 2,
|
|
801
|
-
strokeLinecap: "round",
|
|
802
|
-
strokeLinejoin: "round",
|
|
803
|
-
"aria-hidden": "true",
|
|
804
|
-
focusable: "false",
|
|
805
|
-
...rest,
|
|
806
|
-
children
|
|
807
|
-
}
|
|
808
|
-
);
|
|
809
|
-
}
|
|
810
|
-
const BoldIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
811
|
-
/* @__PURE__ */ jsx("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
812
|
-
/* @__PURE__ */ jsx("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
813
|
-
] });
|
|
814
|
-
const ItalicIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
815
|
-
/* @__PURE__ */ jsx("line", { x1: "19", x2: "10", y1: "4", y2: "4" }),
|
|
816
|
-
/* @__PURE__ */ jsx("line", { x1: "14", x2: "5", y1: "20", y2: "20" }),
|
|
817
|
-
/* @__PURE__ */ jsx("line", { x1: "15", x2: "9", y1: "4", y2: "20" })
|
|
818
|
-
] });
|
|
819
|
-
const UnderlineIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
820
|
-
/* @__PURE__ */ jsx("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
|
|
821
|
-
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "20", y2: "20" })
|
|
822
|
-
] });
|
|
823
|
-
const StrikethroughIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
824
|
-
/* @__PURE__ */ jsx("path", { d: "M16 4H9a3 3 0 0 0-2.83 4" }),
|
|
825
|
-
/* @__PURE__ */ jsx("path", { d: "M14 12a4 4 0 0 1 0 8H6" }),
|
|
826
|
-
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" })
|
|
827
|
-
] });
|
|
828
|
-
const CodeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
829
|
-
/* @__PURE__ */ jsx("polyline", { points: "16 18 22 12 16 6" }),
|
|
830
|
-
/* @__PURE__ */ jsx("polyline", { points: "8 6 2 12 8 18" })
|
|
831
|
-
] });
|
|
832
|
-
const LinkIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
833
|
-
/* @__PURE__ */ jsx("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }),
|
|
834
|
-
/* @__PURE__ */ jsx("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })
|
|
835
|
-
] });
|
|
836
|
-
const ImageIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
837
|
-
/* @__PURE__ */ jsx("rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2" }),
|
|
838
|
-
/* @__PURE__ */ jsx("circle", { cx: "9", cy: "9", r: "2" }),
|
|
839
|
-
/* @__PURE__ */ jsx("path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" })
|
|
840
|
-
] });
|
|
841
|
-
const ImportIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
842
|
-
/* @__PURE__ */ jsx("path", { d: "M12 3v12" }),
|
|
843
|
-
/* @__PURE__ */ jsx("path", { d: "m8 11 4 4 4-4" }),
|
|
844
|
-
/* @__PURE__ */ jsx("path", { d: "M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4" })
|
|
845
|
-
] });
|
|
846
|
-
const ListUnorderedIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
847
|
-
/* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "6", y2: "6" }),
|
|
848
|
-
/* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "12", y2: "12" }),
|
|
849
|
-
/* @__PURE__ */ jsx("line", { x1: "8", x2: "21", y1: "18", y2: "18" }),
|
|
850
|
-
/* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "6", y2: "6" }),
|
|
851
|
-
/* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "12", y2: "12" }),
|
|
852
|
-
/* @__PURE__ */ jsx("line", { x1: "3", x2: "3.01", y1: "18", y2: "18" })
|
|
853
|
-
] });
|
|
854
|
-
const ListOrderedIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
855
|
-
/* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "6", y2: "6" }),
|
|
856
|
-
/* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "12", y2: "12" }),
|
|
857
|
-
/* @__PURE__ */ jsx("line", { x1: "10", x2: "21", y1: "18", y2: "18" }),
|
|
858
|
-
/* @__PURE__ */ jsx("path", { d: "M4 6h1v4" }),
|
|
859
|
-
/* @__PURE__ */ jsx("path", { d: "M4 10h2" }),
|
|
860
|
-
/* @__PURE__ */ jsx("path", { d: "M6 18H4c0-1 2-2 2-3s-1-1.5-2-1" })
|
|
861
|
-
] });
|
|
862
|
-
const ListChecksIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
863
|
-
/* @__PURE__ */ jsx("path", { d: "m3 17 2 2 4-4" }),
|
|
864
|
-
/* @__PURE__ */ jsx("path", { d: "m3 7 2 2 4-4" }),
|
|
865
|
-
/* @__PURE__ */ jsx("path", { d: "M13 6h8" }),
|
|
866
|
-
/* @__PURE__ */ jsx("path", { d: "M13 12h8" }),
|
|
867
|
-
/* @__PURE__ */ jsx("path", { d: "M13 18h8" })
|
|
868
|
-
] });
|
|
869
|
-
const UndoIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
870
|
-
/* @__PURE__ */ jsx("path", { d: "M9 14 4 9l5-5" }),
|
|
871
|
-
/* @__PURE__ */ jsx("path", { d: "M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5 5.5 5.5 0 0 1-5.5 5.5H11" })
|
|
872
|
-
] });
|
|
873
|
-
const RedoIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
874
|
-
/* @__PURE__ */ jsx("path", { d: "m15 14 5-5-5-5" }),
|
|
875
|
-
/* @__PURE__ */ jsx("path", { d: "M20 9H9.5A5.5 5.5 0 0 0 4 14.5 5.5 5.5 0 0 0 9.5 20H13" })
|
|
876
|
-
] });
|
|
877
|
-
const ChevronDownIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m6 9 6 6 6-6" }) });
|
|
878
|
-
const CheckIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "M20 6 9 17l-5-5" }) });
|
|
879
|
-
const TrashIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
880
|
-
/* @__PURE__ */ jsx("path", { d: "M3 6h18" }),
|
|
881
|
-
/* @__PURE__ */ jsx("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" }),
|
|
882
|
-
/* @__PURE__ */ jsx("path", { d: "M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" }),
|
|
883
|
-
/* @__PURE__ */ jsx("line", { x1: "10", x2: "10", y1: "11", y2: "17" }),
|
|
884
|
-
/* @__PURE__ */ jsx("line", { x1: "14", x2: "14", y1: "11", y2: "17" })
|
|
885
|
-
] });
|
|
886
|
-
const LockIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
887
|
-
/* @__PURE__ */ jsx("rect", { width: "18", height: "11", x: "3", y: "11", rx: "2", ry: "2" }),
|
|
888
|
-
/* @__PURE__ */ jsx("path", { d: "M7 11V7a5 5 0 0 1 10 0v4" })
|
|
889
|
-
] });
|
|
890
|
-
const MenuIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
891
|
-
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "12", y2: "12" }),
|
|
892
|
-
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "6", y2: "6" }),
|
|
893
|
-
/* @__PURE__ */ jsx("line", { x1: "4", x2: "20", y1: "18", y2: "18" })
|
|
894
|
-
] });
|
|
895
|
-
const ColumnBeforeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
896
|
-
/* @__PURE__ */ jsx("rect", { x: "10", y: "4", width: "11", height: "16", rx: "1" }),
|
|
897
|
-
/* @__PURE__ */ jsx("path", { d: "M14 4v16" }),
|
|
898
|
-
/* @__PURE__ */ jsx("path", { d: "M5 9v6" }),
|
|
899
|
-
/* @__PURE__ */ jsx("path", { d: "M2 12h6" })
|
|
900
|
-
] });
|
|
901
|
-
const ColumnAfterIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
902
|
-
/* @__PURE__ */ jsx("rect", { x: "3", y: "4", width: "11", height: "16", rx: "1" }),
|
|
903
|
-
/* @__PURE__ */ jsx("path", { d: "M10 4v16" }),
|
|
904
|
-
/* @__PURE__ */ jsx("path", { d: "M19 9v6" }),
|
|
905
|
-
/* @__PURE__ */ jsx("path", { d: "M16 12h6" })
|
|
906
|
-
] });
|
|
907
|
-
const ColumnDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
908
|
-
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "1" }),
|
|
909
|
-
/* @__PURE__ */ jsx("path", { d: "M12 4v16" }),
|
|
910
|
-
/* @__PURE__ */ jsx("path", { d: "m8 9 8 6" }),
|
|
911
|
-
/* @__PURE__ */ jsx("path", { d: "m16 9-8 6" })
|
|
912
|
-
] });
|
|
913
|
-
const RowBeforeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
914
|
-
/* @__PURE__ */ jsx("rect", { x: "4", y: "10", width: "16", height: "11", rx: "1" }),
|
|
915
|
-
/* @__PURE__ */ jsx("path", { d: "M4 14h16" }),
|
|
916
|
-
/* @__PURE__ */ jsx("path", { d: "M9 5h6" }),
|
|
917
|
-
/* @__PURE__ */ jsx("path", { d: "M12 2v6" })
|
|
918
|
-
] });
|
|
919
|
-
const RowAfterIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
920
|
-
/* @__PURE__ */ jsx("rect", { x: "4", y: "3", width: "16", height: "11", rx: "1" }),
|
|
921
|
-
/* @__PURE__ */ jsx("path", { d: "M4 10h16" }),
|
|
922
|
-
/* @__PURE__ */ jsx("path", { d: "M9 19h6" }),
|
|
923
|
-
/* @__PURE__ */ jsx("path", { d: "M12 16v6" })
|
|
924
|
-
] });
|
|
925
|
-
const RowDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
926
|
-
/* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "16", height: "16", rx: "1" }),
|
|
927
|
-
/* @__PURE__ */ jsx("path", { d: "M4 12h16" }),
|
|
928
|
-
/* @__PURE__ */ jsx("path", { d: "m9 8 6 8" }),
|
|
929
|
-
/* @__PURE__ */ jsx("path", { d: "m15 8-6 8" })
|
|
930
|
-
] });
|
|
931
|
-
const TableDeleteIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
|
|
932
|
-
/* @__PURE__ */ jsx("rect", { x: "3", y: "5", width: "18", height: "14", rx: "1" }),
|
|
933
|
-
/* @__PURE__ */ jsx("path", { d: "M3 9h18" }),
|
|
934
|
-
/* @__PURE__ */ jsx("path", { d: "M9 5v14" }),
|
|
935
|
-
/* @__PURE__ */ jsx("path", { d: "M15 5v14" }),
|
|
936
|
-
/* @__PURE__ */ jsx("path", { d: "m7 2 10 20" })
|
|
937
|
-
] });
|
|
938
1253
|
const wrapper = "_wrapper_5i2vi_2";
|
|
939
1254
|
const header$1 = "_header_5i2vi_18";
|
|
940
1255
|
const langTrigger = "_langTrigger_5i2vi_28";
|
|
@@ -1131,11 +1446,16 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1131
1446
|
commentInteractive = true,
|
|
1132
1447
|
pendingAnchors,
|
|
1133
1448
|
onAnchorClick,
|
|
1134
|
-
onSelectionChange
|
|
1449
|
+
onSelectionChange,
|
|
1450
|
+
findReplace = true,
|
|
1451
|
+
findShortcut = true,
|
|
1452
|
+
findLabels
|
|
1135
1453
|
}, ref) {
|
|
1136
1454
|
const preparedInitial = prepareChartMarkdown(
|
|
1137
1455
|
enrichMarkdownCitations(initialMarkdown, sources ?? [])
|
|
1138
1456
|
);
|
|
1457
|
+
const [findOpen, setFindOpen] = useState(false);
|
|
1458
|
+
const findInputRef = useRef(null);
|
|
1139
1459
|
const editor = useEditor({
|
|
1140
1460
|
extensions: [
|
|
1141
1461
|
...baseExtensions,
|
|
@@ -1151,6 +1471,12 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1151
1471
|
}),
|
|
1152
1472
|
Markdown,
|
|
1153
1473
|
pendingAnchorExtension,
|
|
1474
|
+
// 官方查找替换:只出命令 / storage / 装饰,UI 自绘(见 FindReplaceBar)。
|
|
1475
|
+
// - injectCSS 关掉:它默认会往页面插一个 <style>,绕开宿主的 --tmr-* 主题与 style.css,
|
|
1476
|
+
// 命中样式改由 src/styles/find.css 承担。
|
|
1477
|
+
// - searchDebounceMs 关掉:官方防抖走 setTimeout,抛错会落在异步回调里兜不住;
|
|
1478
|
+
// 防抖改由浮动条自己做(见 findReplace.ts)。
|
|
1479
|
+
...findReplace ? [FindAndReplace.configure({ injectCSS: false, searchDebounceMs: 0 })] : [],
|
|
1154
1480
|
TableOfContents.configure({
|
|
1155
1481
|
getId: makeTocGetId(),
|
|
1156
1482
|
onUpdate: (anchors) => {
|
|
@@ -1170,7 +1496,7 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1170
1496
|
immediatelyRender: false,
|
|
1171
1497
|
editorProps: {
|
|
1172
1498
|
attributes: {
|
|
1173
|
-
class: styles$
|
|
1499
|
+
class: styles$6.editorContent,
|
|
1174
1500
|
"data-placeholder": placeholder ?? ""
|
|
1175
1501
|
}
|
|
1176
1502
|
}
|
|
@@ -1182,6 +1508,34 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1182
1508
|
useEffect(() => {
|
|
1183
1509
|
editor == null ? void 0 : editor.setEditable(editable);
|
|
1184
1510
|
}, [editor, editable]);
|
|
1511
|
+
const closeFind = useCallback(() => {
|
|
1512
|
+
setFindOpen(false);
|
|
1513
|
+
editor == null ? void 0 : editor.commands.focus();
|
|
1514
|
+
}, [editor]);
|
|
1515
|
+
useEffect(() => {
|
|
1516
|
+
if (!editor || !findReplace || !findShortcut) return;
|
|
1517
|
+
const onKeyDown = (event) => {
|
|
1518
|
+
if (!(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey) {
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
1521
|
+
if (event.key !== "f" && event.key !== "F") return;
|
|
1522
|
+
const active2 = document.activeElement;
|
|
1523
|
+
const inEditor = !!active2 && editor.view.dom.contains(active2);
|
|
1524
|
+
const nothingFocused = active2 === null || active2 === document.body;
|
|
1525
|
+
const soleEditor = document.querySelectorAll(".ProseMirror").length <= 1;
|
|
1526
|
+
if (!inEditor && !editor.isFocused && !(nothingFocused && soleEditor)) {
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
event.preventDefault();
|
|
1530
|
+
setFindOpen(true);
|
|
1531
|
+
requestAnimationFrame(() => {
|
|
1532
|
+
var _a;
|
|
1533
|
+
return (_a = findInputRef.current) == null ? void 0 : _a.select();
|
|
1534
|
+
});
|
|
1535
|
+
};
|
|
1536
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
1537
|
+
return () => document.removeEventListener("keydown", onKeyDown, true);
|
|
1538
|
+
}, [editor, findReplace, findShortcut]);
|
|
1185
1539
|
const commentsSignatureRef = useRef("");
|
|
1186
1540
|
useEffect(() => {
|
|
1187
1541
|
if (!editor || !editable) return;
|
|
@@ -1288,17 +1642,31 @@ const MarkdownWysiwygEditor = forwardRef(function MarkdownWysiwygEditor2({
|
|
|
1288
1642
|
getEditor: () => editor ?? null,
|
|
1289
1643
|
focusComment: (commentId) => editor ? focusComment(editor, commentId) : false,
|
|
1290
1644
|
nextComment: (dir) => editor ? nextComment(editor, dir ?? "next") : null,
|
|
1291
|
-
getCommentIds: () => editor ? collectCommentIds(editor) : []
|
|
1645
|
+
getCommentIds: () => editor ? collectCommentIds(editor) : [],
|
|
1646
|
+
openFind: () => setFindOpen(true),
|
|
1647
|
+
closeFind
|
|
1292
1648
|
}),
|
|
1293
|
-
[editor]
|
|
1294
|
-
);
|
|
1295
|
-
return /* @__PURE__ */ jsx(
|
|
1296
|
-
EditorContent,
|
|
1297
|
-
{
|
|
1298
|
-
editor,
|
|
1299
|
-
className: className ? `${styles$5.editorScroll} ${className}` : styles$5.editorScroll
|
|
1300
|
-
}
|
|
1649
|
+
[editor, closeFind]
|
|
1301
1650
|
);
|
|
1651
|
+
return /* @__PURE__ */ jsxs("div", { className: styles$6.editorHost, children: [
|
|
1652
|
+
editor && findReplace && findOpen ? /* @__PURE__ */ jsx("div", { className: styles$6.findBarAnchor, children: /* @__PURE__ */ jsx(
|
|
1653
|
+
FindReplaceBar,
|
|
1654
|
+
{
|
|
1655
|
+
editor,
|
|
1656
|
+
labels: findLabels,
|
|
1657
|
+
onClose: closeFind,
|
|
1658
|
+
inputRef: findInputRef,
|
|
1659
|
+
className: styles$6.findBar
|
|
1660
|
+
}
|
|
1661
|
+
) }) : null,
|
|
1662
|
+
/* @__PURE__ */ jsx(
|
|
1663
|
+
EditorContent,
|
|
1664
|
+
{
|
|
1665
|
+
editor,
|
|
1666
|
+
className: className ? `${styles$6.editorScroll} ${className}` : styles$6.editorScroll
|
|
1667
|
+
}
|
|
1668
|
+
)
|
|
1669
|
+
] });
|
|
1302
1670
|
});
|
|
1303
1671
|
function MarkdownPreview({
|
|
1304
1672
|
markdown,
|
|
@@ -1331,7 +1699,7 @@ function MarkdownPreview({
|
|
|
1331
1699
|
editable: false,
|
|
1332
1700
|
immediatelyRender: false,
|
|
1333
1701
|
editorProps: {
|
|
1334
|
-
attributes: { class: styles$
|
|
1702
|
+
attributes: { class: styles$6.editorContent }
|
|
1335
1703
|
}
|
|
1336
1704
|
},
|
|
1337
1705
|
[extensions]
|
|
@@ -1344,7 +1712,7 @@ function MarkdownPreview({
|
|
|
1344
1712
|
EditorContent,
|
|
1345
1713
|
{
|
|
1346
1714
|
editor,
|
|
1347
|
-
className: className ?? styles$
|
|
1715
|
+
className: className ?? styles$6.editorScroll
|
|
1348
1716
|
}
|
|
1349
1717
|
);
|
|
1350
1718
|
}
|
|
@@ -1422,8 +1790,8 @@ function getTableSelectionInfo(state) {
|
|
|
1422
1790
|
const rowCount = Math.max(1, rect.bottom - rect.top);
|
|
1423
1791
|
const colCount = Math.max(1, rect.right - rect.left);
|
|
1424
1792
|
let includesHeaderRow = false;
|
|
1425
|
-
for (let
|
|
1426
|
-
if (rowIsHeader(rect.map, rect.table,
|
|
1793
|
+
for (let row2 = rect.top; row2 < rect.bottom; row2++) {
|
|
1794
|
+
if (rowIsHeader(rect.map, rect.table, row2)) {
|
|
1427
1795
|
includesHeaderRow = true;
|
|
1428
1796
|
break;
|
|
1429
1797
|
}
|
|
@@ -1804,7 +2172,7 @@ function MathEditorPopover({
|
|
|
1804
2172
|
e2.preventDefault();
|
|
1805
2173
|
submit();
|
|
1806
2174
|
};
|
|
1807
|
-
const
|
|
2175
|
+
const field2 = isBlock ? /* @__PURE__ */ jsx(
|
|
1808
2176
|
"textarea",
|
|
1809
2177
|
{
|
|
1810
2178
|
ref: inputRef,
|
|
@@ -1861,7 +2229,7 @@ function MathEditorPopover({
|
|
|
1861
2229
|
id: showHint ? void 0 : titleId,
|
|
1862
2230
|
className: isBlock ? `${styles$3.mathField} ${styles$3.mathFieldBlock}` : styles$3.mathField,
|
|
1863
2231
|
children: [
|
|
1864
|
-
|
|
2232
|
+
field2,
|
|
1865
2233
|
/* @__PURE__ */ jsxs(
|
|
1866
2234
|
"button",
|
|
1867
2235
|
{
|
|
@@ -2039,18 +2407,18 @@ function TableInsertItem({
|
|
|
2039
2407
|
onMouseLeave: resetHover,
|
|
2040
2408
|
children: Array.from({ length: TABLE_PICKER_ROWS * TABLE_PICKER_COLS }, (_, i) => {
|
|
2041
2409
|
const col = i % TABLE_PICKER_COLS + 1;
|
|
2042
|
-
const
|
|
2043
|
-
const active2 = hover.cols > 0 && col <= hover.cols &&
|
|
2410
|
+
const row2 = Math.floor(i / TABLE_PICKER_COLS) + 1;
|
|
2411
|
+
const active2 = hover.cols > 0 && col <= hover.cols && row2 <= hover.rows;
|
|
2044
2412
|
return /* @__PURE__ */ jsx(
|
|
2045
2413
|
"button",
|
|
2046
2414
|
{
|
|
2047
2415
|
type: "button",
|
|
2048
|
-
"aria-label": labels.tableSizeSelected(col,
|
|
2416
|
+
"aria-label": labels.tableSizeSelected(col, row2),
|
|
2049
2417
|
className: `${styles$3.tableSizeCell} ${active2 ? styles$3.tableSizeCellActive : ""}`,
|
|
2050
2418
|
onMouseDown: (e2) => e2.preventDefault(),
|
|
2051
|
-
onMouseEnter: () => setHover({ cols: col, rows:
|
|
2419
|
+
onMouseEnter: () => setHover({ cols: col, rows: row2 }),
|
|
2052
2420
|
onClick: () => {
|
|
2053
|
-
onInsert(
|
|
2421
|
+
onInsert(row2, col);
|
|
2054
2422
|
setOpen(false);
|
|
2055
2423
|
resetHover();
|
|
2056
2424
|
closeMenu();
|
|
@@ -2072,7 +2440,7 @@ function TableInsertItem({
|
|
|
2072
2440
|
function ColorPopover({
|
|
2073
2441
|
title,
|
|
2074
2442
|
glyph,
|
|
2075
|
-
bar,
|
|
2443
|
+
bar: bar2,
|
|
2076
2444
|
value,
|
|
2077
2445
|
onPick,
|
|
2078
2446
|
paletteLabels
|
|
@@ -2089,7 +2457,7 @@ function ColorPopover({
|
|
|
2089
2457
|
onMouseDown: (e2) => e2.preventDefault(),
|
|
2090
2458
|
children: /* @__PURE__ */ jsxs("span", { className: styles$3.colorIcon, children: [
|
|
2091
2459
|
/* @__PURE__ */ jsx("span", { className: styles$3.colorIconGlyph, children: glyph }),
|
|
2092
|
-
/* @__PURE__ */ jsx("span", { className: styles$3.colorIconBar, style: { background:
|
|
2460
|
+
/* @__PURE__ */ jsx("span", { className: styles$3.colorIconBar, style: { background: bar2 } })
|
|
2093
2461
|
] })
|
|
2094
2462
|
}
|
|
2095
2463
|
) }),
|
|
@@ -2306,11 +2674,11 @@ function EditorToolbar({
|
|
|
2306
2674
|
importMenuItems
|
|
2307
2675
|
});
|
|
2308
2676
|
const pickImport = (accept) => {
|
|
2309
|
-
const
|
|
2310
|
-
if (!
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2677
|
+
const input2 = importInputRef.current;
|
|
2678
|
+
if (!input2) return;
|
|
2679
|
+
input2.accept = accept;
|
|
2680
|
+
input2.value = "";
|
|
2681
|
+
input2.click();
|
|
2314
2682
|
};
|
|
2315
2683
|
const importTitle = importing ? t.importDocumentBusy : t.importDocumentHint;
|
|
2316
2684
|
const applyTextColor = (color) => {
|
|
@@ -3226,6 +3594,7 @@ export {
|
|
|
3226
3594
|
C as ChartMount,
|
|
3227
3595
|
CheckIcon,
|
|
3228
3596
|
ChevronDownIcon,
|
|
3597
|
+
ChevronUpIcon,
|
|
3229
3598
|
a as CitationInteractive,
|
|
3230
3599
|
CitationRef,
|
|
3231
3600
|
CodeBlockView,
|
|
@@ -3237,6 +3606,9 @@ export {
|
|
|
3237
3606
|
CommentMark,
|
|
3238
3607
|
CommentPopover,
|
|
3239
3608
|
EditorToolbar,
|
|
3609
|
+
FIND_DEBOUNCE_MS,
|
|
3610
|
+
default2 as FindAndReplace,
|
|
3611
|
+
FindReplaceBar,
|
|
3240
3612
|
ImageIcon,
|
|
3241
3613
|
ImportIcon,
|
|
3242
3614
|
ImportPlaceholder,
|
|
@@ -3259,12 +3631,14 @@ export {
|
|
|
3259
3631
|
RowAfterIcon,
|
|
3260
3632
|
RowBeforeIcon,
|
|
3261
3633
|
RowDeleteIcon,
|
|
3634
|
+
SearchIcon,
|
|
3262
3635
|
StrikethroughIcon,
|
|
3263
3636
|
TableDeleteIcon,
|
|
3264
3637
|
TocPanel,
|
|
3265
3638
|
TrashIcon,
|
|
3266
3639
|
UnderlineIcon,
|
|
3267
3640
|
UndoIcon,
|
|
3641
|
+
XIcon,
|
|
3268
3642
|
a2 as applyCitationSources,
|
|
3269
3643
|
applyCommentAnchorsToEditor,
|
|
3270
3644
|
baseExtensions,
|
|
@@ -3280,6 +3654,7 @@ export {
|
|
|
3280
3654
|
defaultCodeBlockLabels,
|
|
3281
3655
|
defaultColorPaletteLabels,
|
|
3282
3656
|
defaultCommentLabels,
|
|
3657
|
+
defaultFindLabels,
|
|
3283
3658
|
defaultTocLabels,
|
|
3284
3659
|
defaultToolbarLabels,
|
|
3285
3660
|
enrichMarkdownCitations,
|
|
@@ -3304,6 +3679,7 @@ export {
|
|
|
3304
3679
|
r as readCitationAttrs,
|
|
3305
3680
|
replaceRangeWithMarkdown,
|
|
3306
3681
|
reportChart,
|
|
3682
|
+
runFindCommand,
|
|
3307
3683
|
s as scrollToTocHeading,
|
|
3308
3684
|
selectionKind,
|
|
3309
3685
|
s2 as serializeChartPayload,
|