tiptap-markdown-react 0.12.0 → 0.13.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-DVdii3VR.js";
4
- import { C, a, R, b, f, m, r, s } from "./scrollToTocHeading-DVdii3VR.js";
3
+ import { c as renderOrUpdateChart, d as destroyChart } from "./scrollToTocHeading-DKL19FQG.js";
4
+ import { C, a, R, b, f, m, r, s } from "./scrollToTocHeading-DKL19FQG.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
7
  import FindAndReplace, { FindAndReplacePluginKey, createSearchRegex } from "@tiptap/extension-find-and-replace";
@@ -11,10 +11,10 @@ import { TableOfContents } from "@tiptap/extension-table-of-contents";
11
11
  import { NodeViewWrapper, ReactNodeViewRenderer, useEditorState, NodeViewContent, useEditor, EditorContent } from "@tiptap/react";
12
12
  import { createPortal } from "react-dom";
13
13
  import { useState, useEffect, useCallback, useRef, useMemo, forwardRef, useImperativeHandle, useId, useContext, createContext } from "react";
14
- import { e as enrichMarkdownCitations, b as styles$6 } from "./ReportContent-CfvE4CYH.js";
15
- import { R as R2, a as a2, s as s2 } from "./ReportContent-CfvE4CYH.js";
16
- 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-BT3OquOq.js";
17
- import { g, e, s as s3 } from "./extractToc-BT3OquOq.js";
14
+ import { e as enrichMarkdownCitations, c as styles$6 } from "./ReportContent-DxldXfpO.js";
15
+ import { R as R2, a as a2, b as b2, s as s2 } from "./ReportContent-DxldXfpO.js";
16
+ 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-C2zqDjSP.js";
17
+ import { g, e, s as s3 } from "./extractToc-C2zqDjSP.js";
18
18
  import { Slice, Fragment } from "@tiptap/pm/model";
19
19
  import { Extension, Node as Node$1 } from "@tiptap/core";
20
20
  import { PluginKey, Plugin, NodeSelection, TextSelection } from "@tiptap/pm/state";
@@ -184,19 +184,19 @@ function commentAnchorPlugin(options = {}) {
184
184
  const decos = [];
185
185
  const bounds = blockBounds(state.doc);
186
186
  if (showGutter) {
187
- for (const b2 of bounds) {
187
+ for (const b3 of bounds) {
188
188
  const idsInBlock = [];
189
189
  for (const [id, ranges] of byId) {
190
- if (rangesIntersectBlock(ranges, b2.start, b2.end)) {
190
+ if (rangesIntersectBlock(ranges, b3.start, b3.end)) {
191
191
  idsInBlock.push(id);
192
192
  }
193
193
  }
194
194
  if (idsInBlock.length > 0) {
195
195
  decos.push(
196
196
  Decoration.widget(
197
- b2.start,
198
- (view) => gutterDom(idsInBlock, view, b2.start),
199
- { side: -1, key: `tmr-gutter:${b2.start}` }
197
+ b3.start,
198
+ (view) => gutterDom(idsInBlock, view, b3.start),
199
+ { side: -1, key: `tmr-gutter:${b3.start}` }
200
200
  )
201
201
  );
202
202
  }
@@ -210,10 +210,10 @@ function commentAnchorPlugin(options = {}) {
210
210
  Decoration.inline(r2.from, r2.to, { class: "tmr-comment-active" })
211
211
  );
212
212
  }
213
- for (const b2 of bounds) {
214
- if (rangesIntersectBlock(ranges, b2.start, b2.end)) {
213
+ for (const b3 of bounds) {
214
+ if (rangesIntersectBlock(ranges, b3.start, b3.end)) {
215
215
  decos.push(
216
- Decoration.node(b2.start, b2.end, {
216
+ Decoration.node(b3.start, b3.end, {
217
217
  class: "tmr-comment-block-active"
218
218
  })
219
219
  );
@@ -462,6 +462,26 @@ const XIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
462
462
  /* @__PURE__ */ jsx("path", { d: "m6 6 12 12" })
463
463
  ] });
464
464
  const ChevronUpIcon = (p) => /* @__PURE__ */ jsx(Svg, { ...p, children: /* @__PURE__ */ jsx("path", { d: "m18 15-6-6-6 6" }) });
465
+ const ReplaceIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
466
+ /* @__PURE__ */ jsx("path", { d: "M14 4a1 1 0 0 1 1-1" }),
467
+ /* @__PURE__ */ jsx("path", { d: "M15 10a1 1 0 0 1-1-1" }),
468
+ /* @__PURE__ */ jsx("path", { d: "M21 4a1 1 0 0 0-1-1" }),
469
+ /* @__PURE__ */ jsx("path", { d: "M21 9a1 1 0 0 1-1 1" }),
470
+ /* @__PURE__ */ jsx("path", { d: "m3 7 3 3 3-3" }),
471
+ /* @__PURE__ */ jsx("path", { d: "M6 10V5a2 2 0 0 1 2-2h2" }),
472
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" })
473
+ ] });
474
+ const ReplaceAllIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
475
+ /* @__PURE__ */ jsx("path", { d: "M14 14a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1" }),
476
+ /* @__PURE__ */ jsx("path", { d: "M14 4a1 1 0 0 1 1-1" }),
477
+ /* @__PURE__ */ jsx("path", { d: "M15 10a1 1 0 0 1-1-1" }),
478
+ /* @__PURE__ */ jsx("path", { d: "M19 14a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1" }),
479
+ /* @__PURE__ */ jsx("path", { d: "M21 4a1 1 0 0 0-1-1" }),
480
+ /* @__PURE__ */ jsx("path", { d: "M21 9a1 1 0 0 1-1 1" }),
481
+ /* @__PURE__ */ jsx("path", { d: "m3 7 3 3 3-3" }),
482
+ /* @__PURE__ */ jsx("path", { d: "M6 10V5a2 2 0 0 1 2-2h2" }),
483
+ /* @__PURE__ */ jsx("rect", { x: "3", y: "14", width: "7", height: "7", rx: "1" })
484
+ ] });
465
485
  const ColumnBeforeIcon = (p) => /* @__PURE__ */ jsxs(Svg, { ...p, children: [
466
486
  /* @__PURE__ */ jsx("rect", { x: "10", y: "4", width: "11", height: "16", rx: "1" }),
467
487
  /* @__PURE__ */ jsx("path", { d: "M14 4v16" }),
@@ -614,20 +634,19 @@ const defaultFindLabels = {
614
634
  invalidRegex: "Invalid pattern",
615
635
  readOnly: "Read-only"
616
636
  };
617
- const bar = "_bar_1lvby_3";
618
- const row = "_row_1lvby_25";
619
- const field = "_field_1lvby_40";
620
- const fieldIcon = "_fieldIcon_1lvby_59";
621
- const input = "_input_1lvby_64";
622
- const counter = "_counter_1lvby_75";
623
- const counterInvalid = "_counterInvalid_1lvby_84";
624
- const btn$1 = "_btn_1lvby_88";
625
- const toggle = "_toggle_1lvby_116";
626
- const toggleOn = "_toggleOn_1lvby_128";
627
- const closeBtn = "_closeBtn_1lvby_136";
628
- const textBtn = "_textBtn_1lvby_140";
629
- const spacer = "_spacer_1lvby_145";
630
- const readOnly = "_readOnly_1lvby_150";
637
+ const bar = "_bar_1h61e_3";
638
+ const row = "_row_1h61e_25";
639
+ const field = "_field_1h61e_43";
640
+ const fieldIcon = "_fieldIcon_1h61e_62";
641
+ const input = "_input_1h61e_67";
642
+ const counter = "_counter_1h61e_79";
643
+ const counterInvalid = "_counterInvalid_1h61e_89";
644
+ const btn$1 = "_btn_1h61e_93";
645
+ const toggle = "_toggle_1h61e_29";
646
+ const toggleOn = "_toggleOn_1h61e_135";
647
+ const iconGroup = "_iconGroup_1h61e_29";
648
+ const spacer = "_spacer_1h61e_150";
649
+ const readOnly = "_readOnly_1h61e_155";
631
650
  const styles$5 = {
632
651
  bar,
633
652
  row,
@@ -639,8 +658,7 @@ const styles$5 = {
639
658
  btn: btn$1,
640
659
  toggle,
641
660
  toggleOn,
642
- closeBtn,
643
- textBtn,
661
+ iconGroup,
644
662
  spacer,
645
663
  readOnly
646
664
  };
@@ -745,8 +763,7 @@ function FindReplaceBar({
745
763
  const toggle2 = (key, value) => {
746
764
  runCommand(() => {
747
765
  if (key === "caseSensitive") editor.commands.setCaseSensitive(value);
748
- else if (key === "wholeWord") editor.commands.setWholeWord(value);
749
- else editor.commands.setUseRegex(value);
766
+ else editor.commands.setWholeWord(value);
750
767
  });
751
768
  };
752
769
  if (!hasExtension) return null;
@@ -781,6 +798,15 @@ function FindReplaceBar({
781
798
  autoFocus: true,
782
799
  spellCheck: false
783
800
  }
801
+ ),
802
+ /* @__PURE__ */ jsx(
803
+ "span",
804
+ {
805
+ className: `${styles$5.counter}${invalidPattern ? ` ${styles$5.counterInvalid}` : ""}`,
806
+ "aria-live": "polite",
807
+ title: invalidPattern ? t.invalidRegex : void 0,
808
+ children: invalidPattern ? t.invalidRegex : counter2
809
+ }
784
810
  )
785
811
  ] }),
786
812
  /* @__PURE__ */ jsx(
@@ -809,66 +835,46 @@ function FindReplaceBar({
809
835
  children: "ab"
810
836
  }
811
837
  ),
812
- /* @__PURE__ */ jsx(
813
- "button",
814
- {
815
- type: "button",
816
- className: toggleClass(state.useRegex),
817
- title: t.useRegex,
818
- "aria-label": t.useRegex,
819
- "aria-pressed": state.useRegex,
820
- onMouseDown: keepFocus,
821
- onClick: () => toggle2("useRegex", !state.useRegex),
822
- children: ".*"
823
- }
824
- ),
825
838
  /* @__PURE__ */ jsx("span", { className: styles$5.spacer }),
826
- /* @__PURE__ */ jsx(
827
- "span",
828
- {
829
- className: `${styles$5.counter}${invalidPattern ? ` ${styles$5.counterInvalid}` : ""}`,
830
- "aria-live": "polite",
831
- title: invalidPattern ? t.invalidRegex : void 0,
832
- children: invalidPattern ? t.invalidRegex : counter2
833
- }
834
- ),
835
- /* @__PURE__ */ jsx(
836
- "button",
837
- {
838
- type: "button",
839
- className: styles$5.btn,
840
- title: t.previous,
841
- "aria-label": t.previous,
842
- disabled: state.total === 0,
843
- onMouseDown: keepFocus,
844
- onClick: () => runAction(() => editor.commands.goToPreviousResult()),
845
- children: /* @__PURE__ */ jsx(ChevronUpIcon, { size: 16 })
846
- }
847
- ),
848
- /* @__PURE__ */ jsx(
849
- "button",
850
- {
851
- type: "button",
852
- className: styles$5.btn,
853
- title: t.next,
854
- "aria-label": t.next,
855
- disabled: state.total === 0,
856
- onMouseDown: keepFocus,
857
- onClick: () => runAction(() => editor.commands.goToNextResult()),
858
- children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
859
- }
860
- ),
861
- /* @__PURE__ */ jsx(
862
- "button",
863
- {
864
- type: "button",
865
- className: `${styles$5.btn} ${styles$5.closeBtn}`,
866
- title: t.close,
867
- "aria-label": t.close,
868
- onClick: onClose,
869
- children: /* @__PURE__ */ jsx(XIcon, { size: 16 })
870
- }
871
- )
839
+ /* @__PURE__ */ jsxs("span", { className: styles$5.iconGroup, children: [
840
+ /* @__PURE__ */ jsx(
841
+ "button",
842
+ {
843
+ type: "button",
844
+ className: styles$5.btn,
845
+ title: t.previous,
846
+ "aria-label": t.previous,
847
+ disabled: state.total === 0,
848
+ onMouseDown: keepFocus,
849
+ onClick: () => runAction(() => editor.commands.goToPreviousResult()),
850
+ children: /* @__PURE__ */ jsx(ChevronUpIcon, { size: 16 })
851
+ }
852
+ ),
853
+ /* @__PURE__ */ jsx(
854
+ "button",
855
+ {
856
+ type: "button",
857
+ className: styles$5.btn,
858
+ title: t.next,
859
+ "aria-label": t.next,
860
+ disabled: state.total === 0,
861
+ onMouseDown: keepFocus,
862
+ onClick: () => runAction(() => editor.commands.goToNextResult()),
863
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, { size: 16 })
864
+ }
865
+ ),
866
+ /* @__PURE__ */ jsx(
867
+ "button",
868
+ {
869
+ type: "button",
870
+ className: styles$5.btn,
871
+ title: t.close,
872
+ "aria-label": t.close,
873
+ onClick: onClose,
874
+ children: /* @__PURE__ */ jsx(XIcon, { size: 16 })
875
+ }
876
+ )
877
+ ] })
872
878
  ] }),
873
879
  editor.isEditable ? /* @__PURE__ */ jsxs("div", { className: styles$5.row, children: [
874
880
  /* @__PURE__ */ jsx("span", { className: styles$5.field, children: /* @__PURE__ */ jsx(
@@ -888,22 +894,26 @@ function FindReplaceBar({
888
894
  "button",
889
895
  {
890
896
  type: "button",
891
- className: `${styles$5.btn} ${styles$5.textBtn}`,
897
+ className: styles$5.btn,
898
+ title: t.replaceOne,
899
+ "aria-label": t.replaceOne,
892
900
  disabled: state.total === 0,
893
901
  onMouseDown: keepFocus,
894
902
  onClick: () => runAction(() => editor.commands.replace()),
895
- children: t.replaceOne
903
+ children: /* @__PURE__ */ jsx(ReplaceIcon, { size: 16 })
896
904
  }
897
905
  ),
898
906
  /* @__PURE__ */ jsx(
899
907
  "button",
900
908
  {
901
909
  type: "button",
902
- className: `${styles$5.btn} ${styles$5.textBtn}`,
910
+ className: styles$5.btn,
911
+ title: t.replaceAll,
912
+ "aria-label": t.replaceAll,
903
913
  disabled: state.total === 0,
904
914
  onMouseDown: keepFocus,
905
915
  onClick: () => runAction(() => editor.commands.replaceAll()),
906
- children: t.replaceAll
916
+ children: /* @__PURE__ */ jsx(ReplaceAllIcon, { size: 16 })
907
917
  }
908
918
  )
909
919
  ] }) : /* @__PURE__ */ jsx("div", { className: styles$5.row, children: /* @__PURE__ */ jsx("span", { className: styles$5.readOnly, children: t.readOnly }) })
@@ -3556,7 +3566,7 @@ function getMarkdownForRange(editor, from, to, options = {}) {
3556
3566
  let first = 0;
3557
3567
  let last = blocks.length - 1;
3558
3568
  if (expand) {
3559
- first = blocks.findIndex((b2) => b2.to > start);
3569
+ first = blocks.findIndex((b3) => b3.to > start);
3560
3570
  if (first < 0) return null;
3561
3571
  for (let i = blocks.length - 1; i >= first; i -= 1) {
3562
3572
  if (blocks[i].from < end) {
@@ -3567,7 +3577,7 @@ function getMarkdownForRange(editor, from, to, options = {}) {
3567
3577
  start = blocks[first].from;
3568
3578
  end = blocks[last].to;
3569
3579
  }
3570
- const parts = blocks.map((b2) => manager.serialize({ type: "doc", content: [b2.json] }));
3580
+ const parts = blocks.map((b3) => manager.serialize({ type: "doc", content: [b3.json] }));
3571
3581
  const full = editor.getMarkdown();
3572
3582
  if (expand && parts.join(BLOCK_SEPARATOR) === full) {
3573
3583
  const markdown2 = parts.slice(first, last + 1).join(BLOCK_SEPARATOR);
@@ -3670,6 +3680,8 @@ export {
3670
3680
  MenuIcon,
3671
3681
  PENDING_ANCHOR_CLASS,
3672
3682
  RedoIcon,
3683
+ ReplaceAllIcon,
3684
+ ReplaceIcon,
3673
3685
  R2 as ReportContent,
3674
3686
  R as ReportContentInteractive,
3675
3687
  b as ReportContentWithCharts,
@@ -3703,6 +3715,7 @@ export {
3703
3715
  defaultTocLabels,
3704
3716
  defaultToolbarLabels,
3705
3717
  enrichMarkdownCitations,
3718
+ b2 as extractFootnoteSources,
3706
3719
  e as extractToc,
3707
3720
  f as findCitationRefElement,
3708
3721
  findRangeByAnchor,