@meowdown/react 0.67.0 → 0.67.2
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 +132 -104
- package/dist/style.css +14 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -663,7 +663,7 @@ function LinkInfoContent({ href, previewState, onLinkClick, onLinkCopy, onEdit,
|
|
|
663
663
|
if (previewState.status === "resolved") {
|
|
664
664
|
const { preview } = previewState;
|
|
665
665
|
return /* @__PURE__ */ jsxs("div", {
|
|
666
|
-
"data-testid": "link-popover-
|
|
666
|
+
"data-testid": "link-popover-info",
|
|
667
667
|
children: [
|
|
668
668
|
/* @__PURE__ */ jsxs("div", {
|
|
669
669
|
className: link_menu_module_default.Preview,
|
|
@@ -714,7 +714,7 @@ function LinkInfoContent({ href, previewState, onLinkClick, onLinkCopy, onEdit,
|
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
716
|
return /* @__PURE__ */ jsxs("div", {
|
|
717
|
-
"data-testid": "link-popover-
|
|
717
|
+
"data-testid": "link-popover-info",
|
|
718
718
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
719
719
|
className: link_menu_module_default.Row,
|
|
720
720
|
children: [/* @__PURE__ */ jsx(LinkAnchor, {
|
|
@@ -810,112 +810,134 @@ function LinkEditContent({ edit, resolveLinkPreview, onSubmit, onRemove }) {
|
|
|
810
810
|
}
|
|
811
811
|
function LinkMenu({ onLinkClick, onLinkCopy, resolveLinkPreview, readOnly = false }) {
|
|
812
812
|
const editor = useEditor$1();
|
|
813
|
-
const [
|
|
814
|
-
const [edit, setEdit] = useState();
|
|
813
|
+
const [infoOpen, setInfoOpen] = useState(false);
|
|
815
814
|
const [editOpen, setEditOpen] = useState(false);
|
|
816
|
-
const [
|
|
817
|
-
const
|
|
818
|
-
const
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
815
|
+
const [link, setLink] = useState();
|
|
816
|
+
const [edit, setEdit] = useState();
|
|
817
|
+
const isPointerOverPopupRef = useRef(false);
|
|
818
|
+
const linkHoverExtension = useMemo(() => {
|
|
819
|
+
return defineLinkHoverHandler((nextHit) => {
|
|
820
|
+
setInfoOpen(nextHit != null);
|
|
821
|
+
if (nextHit) setLink(nextHit.payload);
|
|
822
|
+
}, { canLeave: () => !isPointerOverPopupRef.current });
|
|
823
|
+
}, []);
|
|
822
824
|
useExtension$1(linkHoverExtension);
|
|
823
|
-
const linkEditExtension = useMemo(() =>
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
825
|
+
const linkEditExtension = useMemo(() => {
|
|
826
|
+
return readOnly ? null : defineLinkEditKeymap((options) => {
|
|
827
|
+
setEdit(options);
|
|
828
|
+
setEditOpen(true);
|
|
829
|
+
setInfoOpen(false);
|
|
830
|
+
});
|
|
831
|
+
}, [readOnly]);
|
|
828
832
|
useExtension$1(linkEditExtension);
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
833
|
+
const handlePointerHover = useCallback((over) => {
|
|
834
|
+
isPointerOverPopupRef.current = over;
|
|
835
|
+
}, []);
|
|
836
|
+
const closeInfo = useCallback(() => {
|
|
837
|
+
isPointerOverPopupRef.current = false;
|
|
838
|
+
setInfoOpen(false);
|
|
832
839
|
}, []);
|
|
833
840
|
const closeEdit = useCallback(() => {
|
|
834
841
|
setEditOpen(false);
|
|
835
|
-
|
|
836
|
-
}, [
|
|
837
|
-
const
|
|
838
|
-
|
|
839
|
-
|
|
842
|
+
closeInfo();
|
|
843
|
+
}, [closeInfo]);
|
|
844
|
+
const handleEditRemove = useCallback(() => {
|
|
845
|
+
editor.commands.removeLink();
|
|
846
|
+
closeEdit();
|
|
847
|
+
}, [editor, closeEdit]);
|
|
848
|
+
const handleEditSubmit = useCallback((text, href) => {
|
|
849
|
+
if (!edit) return;
|
|
850
|
+
if (edit.link) editor.commands.updateLink({
|
|
851
|
+
text: text === edit.text ? void 0 : text,
|
|
852
|
+
href,
|
|
853
|
+
title: edit.link.title
|
|
854
|
+
});
|
|
855
|
+
else editor.commands.insertLink({
|
|
856
|
+
text,
|
|
857
|
+
href
|
|
858
|
+
});
|
|
859
|
+
closeEdit();
|
|
860
|
+
}, [
|
|
861
|
+
edit,
|
|
862
|
+
editor,
|
|
863
|
+
closeEdit
|
|
864
|
+
]);
|
|
865
|
+
const mutable = link != null && !readOnly && link.form !== "reference";
|
|
866
|
+
const linkText = useMemo(() => link ? getLinkText(link) : "", [link]);
|
|
867
|
+
const editLink = useCallback(() => {
|
|
868
|
+
if (!link) return;
|
|
869
|
+
selectLinkUnit(editor, link);
|
|
870
|
+
setEdit({
|
|
871
|
+
from: link.unit.from,
|
|
872
|
+
to: link.unit.to,
|
|
873
|
+
link,
|
|
874
|
+
text: linkText
|
|
875
|
+
});
|
|
876
|
+
setEditOpen(true);
|
|
877
|
+
closeInfo();
|
|
878
|
+
}, [
|
|
879
|
+
link,
|
|
880
|
+
editor,
|
|
881
|
+
linkText,
|
|
882
|
+
closeInfo
|
|
883
|
+
]);
|
|
884
|
+
const removeLink = useCallback(() => {
|
|
885
|
+
if (!link) return;
|
|
886
|
+
selectLinkUnit(editor, link);
|
|
887
|
+
editor.commands.removeLink();
|
|
888
|
+
closeInfo();
|
|
889
|
+
}, [
|
|
890
|
+
link,
|
|
891
|
+
editor,
|
|
892
|
+
closeInfo
|
|
893
|
+
]);
|
|
894
|
+
const handleUseTitle = useMemo(() => {
|
|
895
|
+
if (!link || !mutable || !isLinkTextForHref(linkText, link.href)) return;
|
|
896
|
+
return (title) => {
|
|
897
|
+
selectLinkUnit(editor, link);
|
|
898
|
+
editor.commands.updateLink({ text: title });
|
|
899
|
+
closeInfo();
|
|
900
|
+
};
|
|
901
|
+
}, [
|
|
902
|
+
link,
|
|
903
|
+
editor,
|
|
904
|
+
closeInfo,
|
|
905
|
+
linkText,
|
|
906
|
+
mutable
|
|
907
|
+
]);
|
|
908
|
+
const previewState = useLinkPreview(link?.href, resolveLinkPreview);
|
|
909
|
+
const range = edit ? edit.link?.text ?? edit : link?.text;
|
|
840
910
|
const anchor = useMemo(() => {
|
|
841
911
|
if (!range) return;
|
|
842
912
|
return getVirtualElementFromRange(editor.view, range);
|
|
843
913
|
}, [range, editor]);
|
|
844
|
-
|
|
914
|
+
const editing = edit != null && !readOnly;
|
|
915
|
+
return /* @__PURE__ */ jsx(LinkPopover, {
|
|
845
916
|
anchor,
|
|
846
|
-
open: editOpen,
|
|
847
|
-
onClose: closeEdit,
|
|
917
|
+
open: editing ? editOpen : infoOpen,
|
|
918
|
+
onClose: editing ? closeEdit : closeInfo,
|
|
848
919
|
onCloseComplete: () => {
|
|
849
|
-
|
|
850
|
-
|
|
920
|
+
if (editing) {
|
|
921
|
+
setEdit(void 0);
|
|
922
|
+
editor.focus();
|
|
923
|
+
} else if (!infoOpen) setLink(void 0);
|
|
851
924
|
},
|
|
852
|
-
|
|
925
|
+
onPopupHover: handlePointerHover,
|
|
926
|
+
children: editing ? /* @__PURE__ */ jsx(LinkEditContent, {
|
|
853
927
|
edit,
|
|
854
928
|
resolveLinkPreview,
|
|
855
|
-
onRemove:
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
text,
|
|
867
|
-
href
|
|
868
|
-
});
|
|
869
|
-
closeEdit();
|
|
870
|
-
}
|
|
871
|
-
})
|
|
929
|
+
onRemove: handleEditRemove,
|
|
930
|
+
onSubmit: handleEditSubmit
|
|
931
|
+
}) : link ? /* @__PURE__ */ jsx(LinkInfoContent, {
|
|
932
|
+
href: link.href,
|
|
933
|
+
previewState,
|
|
934
|
+
onLinkClick,
|
|
935
|
+
onLinkCopy,
|
|
936
|
+
onEdit: mutable ? editLink : void 0,
|
|
937
|
+
onRemove: mutable ? removeLink : void 0,
|
|
938
|
+
onUseTitle: handleUseTitle
|
|
939
|
+
}) : void 0
|
|
872
940
|
});
|
|
873
|
-
if (displayedRead) {
|
|
874
|
-
const mutable = !readOnly && displayedRead.form !== "reference";
|
|
875
|
-
const text = getLinkText(editor.view.state, displayedRead);
|
|
876
|
-
const canUseTitle = mutable && isLinkTextForHref(text, displayedRead.href);
|
|
877
|
-
const editLink = () => {
|
|
878
|
-
selectLinkUnit(editor, displayedRead);
|
|
879
|
-
setEdit({
|
|
880
|
-
from: displayedRead.unit.from,
|
|
881
|
-
to: displayedRead.unit.to,
|
|
882
|
-
link: displayedRead,
|
|
883
|
-
text
|
|
884
|
-
});
|
|
885
|
-
setEditOpen(true);
|
|
886
|
-
closeRead();
|
|
887
|
-
};
|
|
888
|
-
const removeLink = () => {
|
|
889
|
-
selectLinkUnit(editor, displayedRead);
|
|
890
|
-
editor.commands.removeLink();
|
|
891
|
-
closeRead();
|
|
892
|
-
};
|
|
893
|
-
return /* @__PURE__ */ jsx(LinkPopover, {
|
|
894
|
-
anchor,
|
|
895
|
-
open: requestedRead !== void 0,
|
|
896
|
-
onClose: closeRead,
|
|
897
|
-
onCloseComplete: () => {
|
|
898
|
-
if (!requestedRead) setDisplayedRead(void 0);
|
|
899
|
-
},
|
|
900
|
-
onPopupHover: (over) => {
|
|
901
|
-
overPopupRef.current = over;
|
|
902
|
-
},
|
|
903
|
-
children: /* @__PURE__ */ jsx(LinkInfoContent, {
|
|
904
|
-
href: displayedRead.href,
|
|
905
|
-
previewState,
|
|
906
|
-
onLinkClick,
|
|
907
|
-
onLinkCopy,
|
|
908
|
-
onEdit: mutable ? editLink : void 0,
|
|
909
|
-
onRemove: mutable ? removeLink : void 0,
|
|
910
|
-
onUseTitle: canUseTitle ? (title) => {
|
|
911
|
-
selectLinkUnit(editor, displayedRead);
|
|
912
|
-
editor.commands.updateLink({ text: title });
|
|
913
|
-
closeRead();
|
|
914
|
-
} : void 0
|
|
915
|
-
})
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
return null;
|
|
919
941
|
}
|
|
920
942
|
|
|
921
943
|
//#endregion
|
|
@@ -1528,7 +1550,9 @@ function getTableHandleState(editor) {
|
|
|
1528
1550
|
columnAlign,
|
|
1529
1551
|
setTableColumnAlign: {
|
|
1530
1552
|
canExec: commands.setTableColumnAlign.canExec("left"),
|
|
1531
|
-
command: (align) =>
|
|
1553
|
+
command: (align) => {
|
|
1554
|
+
return commands.setTableColumnAlign(columnAlign === align ? null : align);
|
|
1555
|
+
}
|
|
1532
1556
|
},
|
|
1533
1557
|
addTableColumnBefore: {
|
|
1534
1558
|
canExec: commands.addTableColumnBefore.canExec(),
|
|
@@ -2369,11 +2393,13 @@ function WikilinkChip(props) {
|
|
|
2369
2393
|
className: "md-wikilink-view-preview md-atom-view-preview",
|
|
2370
2394
|
"data-testid": "wikilink",
|
|
2371
2395
|
contentEditable: false,
|
|
2372
|
-
onClick: onWikilinkClick ? (event) =>
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2396
|
+
onClick: onWikilinkClick ? (event) => {
|
|
2397
|
+
return onWikilinkClick({
|
|
2398
|
+
target,
|
|
2399
|
+
event: event.nativeEvent,
|
|
2400
|
+
mod: isModEvent(event)
|
|
2401
|
+
});
|
|
2402
|
+
} : void 0,
|
|
2377
2403
|
children: /* @__PURE__ */ jsx("span", {
|
|
2378
2404
|
className: "md-wikilink-view-label",
|
|
2379
2405
|
contentEditable: false,
|
|
@@ -2433,12 +2459,14 @@ function ImagePreview(props) {
|
|
|
2433
2459
|
src: url,
|
|
2434
2460
|
alt,
|
|
2435
2461
|
draggable: false,
|
|
2436
|
-
onClick: onImageClick ? (event) =>
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2462
|
+
onClick: onImageClick ? (event) => {
|
|
2463
|
+
return onImageClick({
|
|
2464
|
+
src,
|
|
2465
|
+
alt,
|
|
2466
|
+
event: event.nativeEvent,
|
|
2467
|
+
mod: isModEvent(event)
|
|
2468
|
+
});
|
|
2469
|
+
} : void 0,
|
|
2442
2470
|
style: width == null ? void 0 : { width: `${width}px` }
|
|
2443
2471
|
})
|
|
2444
2472
|
});
|
package/dist/style.css
CHANGED
|
@@ -344,6 +344,7 @@
|
|
|
344
344
|
cursor: pointer;
|
|
345
345
|
flex: 1;
|
|
346
346
|
padding: .25rem .375rem;
|
|
347
|
+
text-decoration: none;
|
|
347
348
|
overflow: hidden;
|
|
348
349
|
}
|
|
349
350
|
|
|
@@ -352,6 +353,8 @@
|
|
|
352
353
|
height: 2rem;
|
|
353
354
|
color: var(--meowdown-text);
|
|
354
355
|
cursor: pointer;
|
|
356
|
+
background: none;
|
|
357
|
+
border: 0;
|
|
355
358
|
border-radius: .5rem;
|
|
356
359
|
flex: none;
|
|
357
360
|
justify-content: center;
|
|
@@ -405,6 +408,7 @@
|
|
|
405
408
|
color: var(--meowdown-accent);
|
|
406
409
|
font-weight: 500;
|
|
407
410
|
line-height: 1.3;
|
|
411
|
+
text-decoration: none;
|
|
408
412
|
overflow: hidden;
|
|
409
413
|
}
|
|
410
414
|
|
|
@@ -560,6 +564,8 @@
|
|
|
560
564
|
min-height: 2rem;
|
|
561
565
|
font: inherit;
|
|
562
566
|
cursor: pointer;
|
|
567
|
+
background: none;
|
|
568
|
+
border: 0;
|
|
563
569
|
border-radius: .5rem;
|
|
564
570
|
padding: .375rem .625rem;
|
|
565
571
|
|
|
@@ -621,9 +627,12 @@
|
|
|
621
627
|
}
|
|
622
628
|
|
|
623
629
|
.meow_Button_DPJ5ia {
|
|
630
|
+
font: inherit;
|
|
624
631
|
color: var(--meowdown-text);
|
|
625
632
|
white-space: nowrap;
|
|
626
633
|
cursor: pointer;
|
|
634
|
+
background: none;
|
|
635
|
+
border: 0;
|
|
627
636
|
border-radius: .5rem;
|
|
628
637
|
align-items: center;
|
|
629
638
|
padding: .25rem .625rem;
|
|
@@ -635,10 +644,12 @@
|
|
|
635
644
|
}
|
|
636
645
|
|
|
637
646
|
.meow_AcceptButton_DPJ5ia {
|
|
647
|
+
font: inherit;
|
|
638
648
|
color: var(--meowdown-popover-bg);
|
|
639
649
|
background: var(--meowdown-accent);
|
|
640
650
|
white-space: nowrap;
|
|
641
651
|
cursor: pointer;
|
|
652
|
+
border: 0;
|
|
642
653
|
border-radius: .5rem;
|
|
643
654
|
align-items: center;
|
|
644
655
|
padding: .25rem .625rem;
|
|
@@ -698,8 +709,11 @@
|
|
|
698
709
|
|
|
699
710
|
.meow_Item_2_4Zjq {
|
|
700
711
|
text-align: left;
|
|
712
|
+
font: inherit;
|
|
701
713
|
color: var(--meowdown-text);
|
|
702
714
|
cursor: pointer;
|
|
715
|
+
background: none;
|
|
716
|
+
border: 0;
|
|
703
717
|
border-radius: .5rem;
|
|
704
718
|
align-items: baseline;
|
|
705
719
|
gap: .5rem;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meowdown/react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.67.
|
|
4
|
+
"version": "0.67.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"github-slugger": "^2.0.0",
|
|
32
32
|
"lucide-react": "^1.28.0",
|
|
33
33
|
"react-property": "^2.0.2",
|
|
34
|
-
"@meowdown/core": "0.67.
|
|
34
|
+
"@meowdown/core": "0.67.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^19.0.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"react-dom": "^19.2.8",
|
|
58
58
|
"tsdown": "^0.23.0-beta.2",
|
|
59
59
|
"vitest": "^4.1.11",
|
|
60
|
-
"vitest-browser-commands": "^0.
|
|
60
|
+
"vitest-browser-commands": "^0.4.1",
|
|
61
61
|
"vitest-browser-react": "^2.2.0",
|
|
62
62
|
"@meowdown/vitest": "0.0.0"
|
|
63
63
|
},
|