@meowdown/react 0.67.0 → 0.67.1
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 +105 -87
- package/dist/style.css +14 -0
- package/package.json +2 -2
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,130 @@ 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
|
|
815
|
+
const [link, setLink] = useState();
|
|
816
|
+
const [edit, setEdit] = useState();
|
|
817
|
+
const isPointerOverPopupRef = useRef(false);
|
|
818
818
|
const linkHoverExtension = useMemo(() => defineLinkHoverHandler((nextHit) => {
|
|
819
|
-
|
|
820
|
-
if (nextHit)
|
|
821
|
-
}, { canLeave: () => !
|
|
819
|
+
setInfoOpen(nextHit != null);
|
|
820
|
+
if (nextHit) setLink(nextHit.payload);
|
|
821
|
+
}, { canLeave: () => !isPointerOverPopupRef.current }), []);
|
|
822
822
|
useExtension$1(linkHoverExtension);
|
|
823
823
|
const linkEditExtension = useMemo(() => readOnly ? null : defineLinkEditKeymap((options) => {
|
|
824
824
|
setEdit(options);
|
|
825
825
|
setEditOpen(true);
|
|
826
|
-
|
|
826
|
+
setInfoOpen(false);
|
|
827
827
|
}), [readOnly]);
|
|
828
828
|
useExtension$1(linkEditExtension);
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
|
|
829
|
+
const handlePointerHover = useCallback((over) => {
|
|
830
|
+
isPointerOverPopupRef.current = over;
|
|
831
|
+
}, []);
|
|
832
|
+
const closeInfo = useCallback(() => {
|
|
833
|
+
isPointerOverPopupRef.current = false;
|
|
834
|
+
setInfoOpen(false);
|
|
832
835
|
}, []);
|
|
833
836
|
const closeEdit = useCallback(() => {
|
|
834
837
|
setEditOpen(false);
|
|
835
|
-
|
|
836
|
-
}, [
|
|
837
|
-
const
|
|
838
|
-
|
|
839
|
-
|
|
838
|
+
closeInfo();
|
|
839
|
+
}, [closeInfo]);
|
|
840
|
+
const handleEditRemove = useCallback(() => {
|
|
841
|
+
editor.commands.removeLink();
|
|
842
|
+
closeEdit();
|
|
843
|
+
}, [editor, closeEdit]);
|
|
844
|
+
const handleEditSubmit = useCallback((text, href) => {
|
|
845
|
+
if (!edit) return;
|
|
846
|
+
if (edit.link) editor.commands.updateLink({
|
|
847
|
+
text: text === edit.text ? void 0 : text,
|
|
848
|
+
href,
|
|
849
|
+
title: edit.link.title
|
|
850
|
+
});
|
|
851
|
+
else editor.commands.insertLink({
|
|
852
|
+
text,
|
|
853
|
+
href
|
|
854
|
+
});
|
|
855
|
+
closeEdit();
|
|
856
|
+
}, [
|
|
857
|
+
edit,
|
|
858
|
+
editor,
|
|
859
|
+
closeEdit
|
|
860
|
+
]);
|
|
861
|
+
const mutable = link != null && !readOnly && link.form !== "reference";
|
|
862
|
+
const linkText = useMemo(() => link ? getLinkText(link) : "", [link]);
|
|
863
|
+
const editLink = useCallback(() => {
|
|
864
|
+
if (!link) return;
|
|
865
|
+
selectLinkUnit(editor, link);
|
|
866
|
+
setEdit({
|
|
867
|
+
from: link.unit.from,
|
|
868
|
+
to: link.unit.to,
|
|
869
|
+
link,
|
|
870
|
+
text: linkText
|
|
871
|
+
});
|
|
872
|
+
setEditOpen(true);
|
|
873
|
+
closeInfo();
|
|
874
|
+
}, [
|
|
875
|
+
link,
|
|
876
|
+
editor,
|
|
877
|
+
linkText,
|
|
878
|
+
closeInfo
|
|
879
|
+
]);
|
|
880
|
+
const removeLink = useCallback(() => {
|
|
881
|
+
if (!link) return;
|
|
882
|
+
selectLinkUnit(editor, link);
|
|
883
|
+
editor.commands.removeLink();
|
|
884
|
+
closeInfo();
|
|
885
|
+
}, [
|
|
886
|
+
link,
|
|
887
|
+
editor,
|
|
888
|
+
closeInfo
|
|
889
|
+
]);
|
|
890
|
+
const handleUseTitle = useMemo(() => {
|
|
891
|
+
if (!link || !mutable || !isLinkTextForHref(linkText, link.href)) return;
|
|
892
|
+
return (title) => {
|
|
893
|
+
selectLinkUnit(editor, link);
|
|
894
|
+
editor.commands.updateLink({ text: title });
|
|
895
|
+
closeInfo();
|
|
896
|
+
};
|
|
897
|
+
}, [
|
|
898
|
+
link,
|
|
899
|
+
editor,
|
|
900
|
+
closeInfo,
|
|
901
|
+
linkText,
|
|
902
|
+
mutable
|
|
903
|
+
]);
|
|
904
|
+
const previewState = useLinkPreview(link?.href, resolveLinkPreview);
|
|
905
|
+
const range = edit ? edit.link?.text ?? edit : link?.text;
|
|
840
906
|
const anchor = useMemo(() => {
|
|
841
907
|
if (!range) return;
|
|
842
908
|
return getVirtualElementFromRange(editor.view, range);
|
|
843
909
|
}, [range, editor]);
|
|
844
|
-
|
|
910
|
+
const editing = edit != null && !readOnly;
|
|
911
|
+
return /* @__PURE__ */ jsx(LinkPopover, {
|
|
845
912
|
anchor,
|
|
846
|
-
open: editOpen,
|
|
847
|
-
onClose: closeEdit,
|
|
913
|
+
open: editing ? editOpen : infoOpen,
|
|
914
|
+
onClose: editing ? closeEdit : closeInfo,
|
|
848
915
|
onCloseComplete: () => {
|
|
849
|
-
|
|
850
|
-
|
|
916
|
+
if (editing) {
|
|
917
|
+
setEdit(void 0);
|
|
918
|
+
editor.focus();
|
|
919
|
+
} else if (!infoOpen) setLink(void 0);
|
|
851
920
|
},
|
|
852
|
-
|
|
921
|
+
onPopupHover: handlePointerHover,
|
|
922
|
+
children: editing ? /* @__PURE__ */ jsx(LinkEditContent, {
|
|
853
923
|
edit,
|
|
854
924
|
resolveLinkPreview,
|
|
855
|
-
onRemove:
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
text,
|
|
867
|
-
href
|
|
868
|
-
});
|
|
869
|
-
closeEdit();
|
|
870
|
-
}
|
|
871
|
-
})
|
|
925
|
+
onRemove: handleEditRemove,
|
|
926
|
+
onSubmit: handleEditSubmit
|
|
927
|
+
}) : link ? /* @__PURE__ */ jsx(LinkInfoContent, {
|
|
928
|
+
href: link.href,
|
|
929
|
+
previewState,
|
|
930
|
+
onLinkClick,
|
|
931
|
+
onLinkCopy,
|
|
932
|
+
onEdit: mutable ? editLink : void 0,
|
|
933
|
+
onRemove: mutable ? removeLink : void 0,
|
|
934
|
+
onUseTitle: handleUseTitle
|
|
935
|
+
}) : void 0
|
|
872
936
|
});
|
|
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
937
|
}
|
|
920
938
|
|
|
921
939
|
//#endregion
|
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.1",
|
|
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.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"react": "^19.0.0",
|