@cyberyozh/text-editor 0.1.6 → 0.1.7
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/editor.css +46 -20
- package/dist/editor.css.map +1 -1
- package/dist/editor.js +495 -432
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +495 -432
- package/dist/editor.mjs.map +1 -1
- package/dist/render.js +62 -29
- package/dist/render.js.map +1 -1
- package/dist/render.mjs +62 -29
- package/dist/render.mjs.map +1 -1
- package/dist/styles/index.css +46 -20
- package/package.json +5 -1
- package/src/editor/commands/items.ts +1 -1
- package/src/editor/components/common-modal/common-modal.css +2 -1
- package/src/editor/context/dialog-command.tsx +0 -2
- package/src/editor/controls/bubble-menu-content.tsx +6 -2
- package/src/editor/controls/commands-list.tsx +7 -0
- package/src/editor/dialogs/add-video-dialog/add-video-dialog.tsx +2 -5
- package/src/editor/editor.tsx +56 -43
- package/src/editor/handlers/dialog-handlers.ts +118 -36
- package/src/extensions/views/components/index.ts +1 -0
- package/src/extensions/views/components/table.tsx +29 -0
- package/src/render/static-renderer-config.tsx +32 -2
- package/src/styles/editor/base.css +7 -5
- package/src/styles/editor/states.css +4 -3
- package/src/styles/editor/typography.css +10 -2
- package/src/styles/editor/variables.css +1 -0
- package/src/styles/extensions/callout.css +5 -2
- package/src/styles/extensions/code-block.css +2 -1
- package/src/styles/extensions/commands-list.css +5 -1
- package/src/styles/extensions/custom-quote.css +5 -0
- package/src/styles/extensions/details.css +4 -4
- package/src/styles/extensions/myth-reality.css +3 -1
- package/src/styles/extensions/prompt.css +4 -1
package/dist/editor.mjs
CHANGED
|
@@ -749,7 +749,6 @@ var BubbleMenuContent = ({ editor, onLinkClick }) => {
|
|
|
749
749
|
} = useEditorState({
|
|
750
750
|
editor,
|
|
751
751
|
selector: (ctx) => {
|
|
752
|
-
if (!editor) return {};
|
|
753
752
|
return {
|
|
754
753
|
canUndo: ctx.editor.can().undo(),
|
|
755
754
|
canRedo: ctx.editor.can().redo(),
|
|
@@ -789,320 +788,329 @@ var BubbleMenuContent = ({ editor, onLinkClick }) => {
|
|
|
789
788
|
onLinkClick?.(selectedText, linkUrl);
|
|
790
789
|
openDialogCommand("link");
|
|
791
790
|
};
|
|
792
|
-
return /* @__PURE__ */ jsxs10(
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
791
|
+
return /* @__PURE__ */ jsxs10(
|
|
792
|
+
"div",
|
|
793
|
+
{
|
|
794
|
+
className: `bubble-menu ${textColor || highlightColor ? "hide-text-selection" : ""}`,
|
|
795
|
+
onMouseDown: (e) => {
|
|
796
|
+
e.preventDefault();
|
|
797
|
+
},
|
|
798
|
+
children: [
|
|
799
|
+
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
800
|
+
/* @__PURE__ */ jsx58(
|
|
801
|
+
"button",
|
|
802
|
+
{
|
|
803
|
+
className: "tiptap-control-button",
|
|
804
|
+
onClick: () => editor.chain().focus().undo().run(),
|
|
805
|
+
disabled: !canUndo,
|
|
806
|
+
title: translations2.history.undo,
|
|
807
|
+
type: "button",
|
|
808
|
+
children: /* @__PURE__ */ jsx58(Undo_default, {})
|
|
809
|
+
}
|
|
810
|
+
),
|
|
811
|
+
/* @__PURE__ */ jsx58(
|
|
812
|
+
"button",
|
|
813
|
+
{
|
|
814
|
+
className: "tiptap-control-button",
|
|
815
|
+
onClick: () => editor.chain().focus().redo().run(),
|
|
816
|
+
disabled: !canRedo,
|
|
817
|
+
type: "button",
|
|
818
|
+
title: translations2.history.redo,
|
|
819
|
+
children: /* @__PURE__ */ jsx58(Redo_default, {})
|
|
820
|
+
}
|
|
821
|
+
)
|
|
822
|
+
] }),
|
|
823
|
+
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
824
|
+
/* @__PURE__ */ jsx58(
|
|
825
|
+
"button",
|
|
826
|
+
{
|
|
827
|
+
type: "button",
|
|
828
|
+
title: translations2.headings.h2,
|
|
829
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
830
|
+
className: `tiptap-control-button ${isHeading2 ? "is-active" : ""}`,
|
|
831
|
+
children: /* @__PURE__ */ jsx58(H2_default, {})
|
|
832
|
+
}
|
|
833
|
+
),
|
|
834
|
+
/* @__PURE__ */ jsx58(
|
|
835
|
+
"button",
|
|
836
|
+
{
|
|
837
|
+
type: "button",
|
|
838
|
+
title: translations2.headings.h3,
|
|
839
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
840
|
+
className: `tiptap-control-button ${isHeading3 ? "is-active" : ""}`,
|
|
841
|
+
children: /* @__PURE__ */ jsx58(H3_default, {})
|
|
842
|
+
}
|
|
843
|
+
),
|
|
844
|
+
/* @__PURE__ */ jsx58(
|
|
845
|
+
"button",
|
|
846
|
+
{
|
|
847
|
+
type: "button",
|
|
848
|
+
title: translations2.headings.h4,
|
|
849
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 4 }).run(),
|
|
850
|
+
className: `tiptap-control-button ${isHeading4 ? "is-active" : ""}`,
|
|
851
|
+
children: /* @__PURE__ */ jsx58(H4_default, {})
|
|
852
|
+
}
|
|
853
|
+
),
|
|
854
|
+
/* @__PURE__ */ jsx58(
|
|
855
|
+
"button",
|
|
856
|
+
{
|
|
857
|
+
type: "button",
|
|
858
|
+
title: translations2.headings.h5,
|
|
859
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 5 }).run(),
|
|
860
|
+
className: `tiptap-control-button ${isHeading5 ? "is-active" : ""}`,
|
|
861
|
+
children: /* @__PURE__ */ jsx58(H5_default, {})
|
|
862
|
+
}
|
|
863
|
+
),
|
|
864
|
+
/* @__PURE__ */ jsx58(
|
|
865
|
+
"button",
|
|
866
|
+
{
|
|
867
|
+
type: "button",
|
|
868
|
+
title: translations2.headings.h6,
|
|
869
|
+
onClick: () => editor.chain().focus().toggleHeading({ level: 6 }).run(),
|
|
870
|
+
className: `tiptap-control-button ${isHeading6 ? "is-active" : ""}`,
|
|
871
|
+
children: /* @__PURE__ */ jsx58(H6_default, {})
|
|
872
|
+
}
|
|
873
|
+
)
|
|
874
|
+
] }),
|
|
875
|
+
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
876
|
+
/* @__PURE__ */ jsx58(
|
|
877
|
+
"button",
|
|
878
|
+
{
|
|
879
|
+
onClick: () => editor.chain().focus().toggleBold().run(),
|
|
880
|
+
className: `${isBold ? "is-active" : ""} tiptap-control-button`,
|
|
881
|
+
title: translations2.textFormatting.bold,
|
|
882
|
+
type: "button",
|
|
883
|
+
children: /* @__PURE__ */ jsx58(Bold_default, {})
|
|
884
|
+
}
|
|
885
|
+
),
|
|
886
|
+
/* @__PURE__ */ jsx58(
|
|
887
|
+
"button",
|
|
888
|
+
{
|
|
889
|
+
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
890
|
+
className: `${isItalic ? "is-active" : ""} tiptap-control-button`,
|
|
891
|
+
title: translations2.textFormatting.italic,
|
|
892
|
+
type: "button",
|
|
893
|
+
children: /* @__PURE__ */ jsx58(Italic_default, {})
|
|
894
|
+
}
|
|
895
|
+
),
|
|
896
|
+
/* @__PURE__ */ jsx58(
|
|
897
|
+
"button",
|
|
898
|
+
{
|
|
899
|
+
onClick: () => editor.chain().focus().toggleUnderline().run(),
|
|
900
|
+
className: `${isUnderline ? "is-active" : ""} tiptap-control-button`,
|
|
901
|
+
title: translations2.textFormatting.underline,
|
|
902
|
+
type: "button",
|
|
903
|
+
children: /* @__PURE__ */ jsx58(Underline_default, {})
|
|
904
|
+
}
|
|
905
|
+
),
|
|
906
|
+
/* @__PURE__ */ jsx58(
|
|
907
|
+
"button",
|
|
908
|
+
{
|
|
909
|
+
onClick: () => editor.chain().focus().toggleStrike().run(),
|
|
910
|
+
className: `${isStrikethrough ? "is-active" : ""} tiptap-control-button`,
|
|
911
|
+
title: translations2.textFormatting.strikethrough,
|
|
912
|
+
type: "button",
|
|
913
|
+
children: /* @__PURE__ */ jsx58(Strikethrough_default, {})
|
|
914
|
+
}
|
|
915
|
+
)
|
|
916
|
+
] }),
|
|
917
|
+
isTable && /* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
918
|
+
/* @__PURE__ */ jsx58(
|
|
919
|
+
"button",
|
|
920
|
+
{
|
|
921
|
+
className: "tiptap-control-button",
|
|
922
|
+
type: "button",
|
|
923
|
+
title: translations2.table.mergeCells,
|
|
924
|
+
onClick: () => editor.chain().focus().mergeCells().run(),
|
|
925
|
+
children: /* @__PURE__ */ jsx58(MergeCells_default, {})
|
|
926
|
+
}
|
|
927
|
+
),
|
|
928
|
+
/* @__PURE__ */ jsx58(
|
|
929
|
+
"button",
|
|
930
|
+
{
|
|
931
|
+
className: "tiptap-control-button",
|
|
932
|
+
type: "button",
|
|
933
|
+
title: translations2.table.splitCell,
|
|
934
|
+
onClick: () => editor.chain().focus().splitCell().run(),
|
|
935
|
+
children: /* @__PURE__ */ jsx58(SplitCells_default, {})
|
|
936
|
+
}
|
|
937
|
+
)
|
|
938
|
+
] }),
|
|
939
|
+
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
940
|
+
/* @__PURE__ */ jsxs10("div", { style: { position: "relative" }, children: [
|
|
941
|
+
/* @__PURE__ */ jsx58(
|
|
942
|
+
"button",
|
|
943
|
+
{
|
|
944
|
+
onClick: () => {
|
|
945
|
+
textColorInputRef.current?.click();
|
|
946
|
+
},
|
|
947
|
+
className: "tiptap-control-button",
|
|
948
|
+
type: "button",
|
|
949
|
+
title: translations2.textFormatting.textColor,
|
|
950
|
+
style: { color: textColor },
|
|
951
|
+
children: /* @__PURE__ */ jsx58(TextColor_default, {})
|
|
952
|
+
}
|
|
953
|
+
),
|
|
954
|
+
/* @__PURE__ */ jsx58(
|
|
955
|
+
"input",
|
|
956
|
+
{
|
|
957
|
+
ref: textColorInputRef,
|
|
958
|
+
type: "color",
|
|
959
|
+
value: textColor,
|
|
960
|
+
onChange: (e) => {
|
|
961
|
+
editor.chain().focus().setColor(e.target.value).run();
|
|
962
|
+
},
|
|
963
|
+
style: {
|
|
964
|
+
position: "absolute",
|
|
965
|
+
top: 0,
|
|
966
|
+
left: 0,
|
|
967
|
+
width: "100%",
|
|
968
|
+
height: "100%",
|
|
969
|
+
opacity: 0,
|
|
970
|
+
pointerEvents: "none"
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
)
|
|
974
|
+
] }),
|
|
975
|
+
/* @__PURE__ */ jsxs10("div", { style: { position: "relative" }, children: [
|
|
976
|
+
/* @__PURE__ */ jsx58(
|
|
977
|
+
"button",
|
|
978
|
+
{
|
|
979
|
+
onClick: () => {
|
|
980
|
+
highlightColorInputRef.current?.click();
|
|
981
|
+
},
|
|
982
|
+
className: "tiptap-control-button",
|
|
983
|
+
type: "button",
|
|
984
|
+
title: translations2.textFormatting.highlightColor,
|
|
985
|
+
style: { color: highlightColor },
|
|
986
|
+
children: /* @__PURE__ */ jsx58(Highlight_default, {})
|
|
987
|
+
}
|
|
988
|
+
),
|
|
989
|
+
/* @__PURE__ */ jsx58(
|
|
990
|
+
"input",
|
|
991
|
+
{
|
|
992
|
+
ref: highlightColorInputRef,
|
|
993
|
+
type: "color",
|
|
994
|
+
value: highlightColor,
|
|
995
|
+
onChange: (e) => {
|
|
996
|
+
editor.chain().focus().setHighlight({ color: e.target.value }).run();
|
|
997
|
+
},
|
|
998
|
+
style: {
|
|
999
|
+
position: "absolute",
|
|
1000
|
+
top: 0,
|
|
1001
|
+
left: 0,
|
|
1002
|
+
width: "100%",
|
|
1003
|
+
height: "100%",
|
|
1004
|
+
opacity: 0,
|
|
1005
|
+
pointerEvents: "none"
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
)
|
|
1009
|
+
] })
|
|
1010
|
+
] }),
|
|
1011
|
+
/* @__PURE__ */ jsx58("div", { className: "tiptap-controls-group", children: /* @__PURE__ */ jsx58(
|
|
936
1012
|
"button",
|
|
937
1013
|
{
|
|
938
|
-
onClick: () => {
|
|
939
|
-
textColorInputRef.current?.click();
|
|
940
|
-
},
|
|
941
|
-
className: "tiptap-control-button",
|
|
942
1014
|
type: "button",
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1015
|
+
onClick: () => editor.chain().focus().toggleCopyable().run(),
|
|
1016
|
+
className: `${isCopyable ? "is-active" : ""} tiptap-control-button`,
|
|
1017
|
+
title: translations2.textFormatting.copyableText,
|
|
1018
|
+
children: /* @__PURE__ */ jsx58(Copyable_default, {})
|
|
946
1019
|
}
|
|
947
|
-
),
|
|
948
|
-
/* @__PURE__ */
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
style: {
|
|
958
|
-
position: "absolute",
|
|
959
|
-
top: 0,
|
|
960
|
-
left: 0,
|
|
961
|
-
width: "100%",
|
|
962
|
-
height: "100%",
|
|
963
|
-
opacity: 0,
|
|
964
|
-
pointerEvents: "none"
|
|
1020
|
+
) }),
|
|
1021
|
+
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
1022
|
+
/* @__PURE__ */ jsx58(
|
|
1023
|
+
"button",
|
|
1024
|
+
{
|
|
1025
|
+
title: isLink ? translations2.link.editLink : translations2.link.addLinkTitle,
|
|
1026
|
+
onClick: handleLinkClick,
|
|
1027
|
+
className: `${isLink ? "is-active" : ""} tiptap-control-button`,
|
|
1028
|
+
type: "button",
|
|
1029
|
+
children: /* @__PURE__ */ jsx58(Link_default, {})
|
|
965
1030
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
1031
|
+
),
|
|
1032
|
+
isLink && /* @__PURE__ */ jsx58(
|
|
1033
|
+
"button",
|
|
1034
|
+
{
|
|
1035
|
+
onClick: () => editor.chain().focus().unsetLink().run(),
|
|
1036
|
+
className: "tiptap-control-button tiptap-control-button--delete",
|
|
1037
|
+
type: "button",
|
|
1038
|
+
title: translations2.link.removeLinkTitle,
|
|
1039
|
+
children: /* @__PURE__ */ jsx58(LinkOff_default, {})
|
|
1040
|
+
}
|
|
1041
|
+
)
|
|
1042
|
+
] }),
|
|
1043
|
+
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
1044
|
+
/* @__PURE__ */ jsx58(
|
|
1045
|
+
"button",
|
|
1046
|
+
{
|
|
1047
|
+
onClick: () => editor.chain().focus().setTextAlign("left").run(),
|
|
1048
|
+
className: `${isTextAlignLeft ? "is-active" : ""} tiptap-control-button`,
|
|
1049
|
+
title: translations2.alignment.alignLeft,
|
|
1050
|
+
type: "button",
|
|
1051
|
+
children: /* @__PURE__ */ jsx58(AlignLeft_default, {})
|
|
1052
|
+
}
|
|
1053
|
+
),
|
|
1054
|
+
/* @__PURE__ */ jsx58(
|
|
1055
|
+
"button",
|
|
1056
|
+
{
|
|
1057
|
+
onClick: () => editor.chain().focus().setTextAlign("center").run(),
|
|
1058
|
+
className: `${isTextAlignCenter ? "is-active" : ""} tiptap-control-button`,
|
|
1059
|
+
title: translations2.alignment.alignCenter,
|
|
1060
|
+
type: "button",
|
|
1061
|
+
children: /* @__PURE__ */ jsx58(AlignCenter_default, {})
|
|
1062
|
+
}
|
|
1063
|
+
),
|
|
1064
|
+
/* @__PURE__ */ jsx58(
|
|
1065
|
+
"button",
|
|
1066
|
+
{
|
|
1067
|
+
onClick: () => editor.chain().focus().setTextAlign("right").run(),
|
|
1068
|
+
className: `${isTextAlignRight ? "is-active" : ""} tiptap-control-button`,
|
|
1069
|
+
title: translations2.alignment.alignRight,
|
|
1070
|
+
type: "button",
|
|
1071
|
+
children: /* @__PURE__ */ jsx58(AlignRight_default, {})
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
] }),
|
|
1075
|
+
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
1076
|
+
/* @__PURE__ */ jsx58(
|
|
1077
|
+
"button",
|
|
1078
|
+
{
|
|
1079
|
+
type: "button",
|
|
1080
|
+
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
1081
|
+
className: `${isSuperscript ? "is-active" : ""} tiptap-control-button`,
|
|
1082
|
+
title: translations2.textFormatting.superscript,
|
|
1083
|
+
children: /* @__PURE__ */ jsx58(Superscript_default, {})
|
|
1084
|
+
}
|
|
1085
|
+
),
|
|
1086
|
+
/* @__PURE__ */ jsx58(
|
|
1087
|
+
"button",
|
|
1088
|
+
{
|
|
1089
|
+
type: "button",
|
|
1090
|
+
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
1091
|
+
className: `${isSubscript ? "is-active" : ""} tiptap-control-button`,
|
|
1092
|
+
title: translations2.textFormatting.subscript,
|
|
1093
|
+
children: /* @__PURE__ */ jsx58(Subscript_default, {})
|
|
1094
|
+
}
|
|
1095
|
+
)
|
|
1096
|
+
] }),
|
|
1097
|
+
/* @__PURE__ */ jsx58("div", { className: "tiptap-controls-group", children: /* @__PURE__ */ jsx58(
|
|
971
1098
|
"button",
|
|
972
1099
|
{
|
|
1100
|
+
type: "button",
|
|
973
1101
|
onClick: () => {
|
|
974
|
-
|
|
1102
|
+
editor.chain().focus().clearNodes().run();
|
|
1103
|
+
editor.chain().focus().unsetAllMarks().run();
|
|
975
1104
|
},
|
|
1105
|
+
disabled: !canClearMarks,
|
|
976
1106
|
className: "tiptap-control-button",
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
style: { color: highlightColor },
|
|
980
|
-
children: /* @__PURE__ */ jsx58(Highlight_default, {})
|
|
1107
|
+
title: translations2.textFormatting.clearFormatting,
|
|
1108
|
+
children: /* @__PURE__ */ jsx58(ClearFormatting_default, {})
|
|
981
1109
|
}
|
|
982
|
-
)
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
ref: highlightColorInputRef,
|
|
987
|
-
type: "color",
|
|
988
|
-
value: highlightColor,
|
|
989
|
-
onChange: (e) => {
|
|
990
|
-
editor.chain().focus().setHighlight({ color: e.target.value }).run();
|
|
991
|
-
},
|
|
992
|
-
style: {
|
|
993
|
-
position: "absolute",
|
|
994
|
-
top: 0,
|
|
995
|
-
left: 0,
|
|
996
|
-
width: "100%",
|
|
997
|
-
height: "100%",
|
|
998
|
-
opacity: 0,
|
|
999
|
-
pointerEvents: "none"
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
)
|
|
1003
|
-
] })
|
|
1004
|
-
] }),
|
|
1005
|
-
/* @__PURE__ */ jsx58("div", { className: "tiptap-controls-group", children: /* @__PURE__ */ jsx58(
|
|
1006
|
-
"button",
|
|
1007
|
-
{
|
|
1008
|
-
type: "button",
|
|
1009
|
-
onClick: () => editor.chain().focus().toggleCopyable().run(),
|
|
1010
|
-
className: `${isCopyable ? "is-active" : ""} tiptap-control-button`,
|
|
1011
|
-
title: translations2.textFormatting.copyableText,
|
|
1012
|
-
children: /* @__PURE__ */ jsx58(Copyable_default, {})
|
|
1013
|
-
}
|
|
1014
|
-
) }),
|
|
1015
|
-
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
1016
|
-
/* @__PURE__ */ jsx58(
|
|
1017
|
-
"button",
|
|
1018
|
-
{
|
|
1019
|
-
title: isLink ? translations2.link.editLink : translations2.link.addLinkTitle,
|
|
1020
|
-
onClick: handleLinkClick,
|
|
1021
|
-
className: `${isLink ? "is-active" : ""} tiptap-control-button`,
|
|
1022
|
-
type: "button",
|
|
1023
|
-
children: /* @__PURE__ */ jsx58(Link_default, {})
|
|
1024
|
-
}
|
|
1025
|
-
),
|
|
1026
|
-
isLink && /* @__PURE__ */ jsx58(
|
|
1027
|
-
"button",
|
|
1028
|
-
{
|
|
1029
|
-
onClick: () => editor.chain().focus().unsetLink().run(),
|
|
1030
|
-
className: "tiptap-control-button tiptap-control-button--delete",
|
|
1031
|
-
type: "button",
|
|
1032
|
-
title: translations2.link.removeLinkTitle,
|
|
1033
|
-
children: /* @__PURE__ */ jsx58(LinkOff_default, {})
|
|
1034
|
-
}
|
|
1035
|
-
)
|
|
1036
|
-
] }),
|
|
1037
|
-
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
1038
|
-
/* @__PURE__ */ jsx58(
|
|
1039
|
-
"button",
|
|
1040
|
-
{
|
|
1041
|
-
onClick: () => editor.chain().focus().setTextAlign("left").run(),
|
|
1042
|
-
className: `${isTextAlignLeft ? "is-active" : ""} tiptap-control-button`,
|
|
1043
|
-
title: translations2.alignment.alignLeft,
|
|
1044
|
-
type: "button",
|
|
1045
|
-
children: /* @__PURE__ */ jsx58(AlignLeft_default, {})
|
|
1046
|
-
}
|
|
1047
|
-
),
|
|
1048
|
-
/* @__PURE__ */ jsx58(
|
|
1049
|
-
"button",
|
|
1050
|
-
{
|
|
1051
|
-
onClick: () => editor.chain().focus().setTextAlign("center").run(),
|
|
1052
|
-
className: `${isTextAlignCenter ? "is-active" : ""} tiptap-control-button`,
|
|
1053
|
-
title: translations2.alignment.alignCenter,
|
|
1054
|
-
type: "button",
|
|
1055
|
-
children: /* @__PURE__ */ jsx58(AlignCenter_default, {})
|
|
1056
|
-
}
|
|
1057
|
-
),
|
|
1058
|
-
/* @__PURE__ */ jsx58(
|
|
1059
|
-
"button",
|
|
1060
|
-
{
|
|
1061
|
-
onClick: () => editor.chain().focus().setTextAlign("right").run(),
|
|
1062
|
-
className: `${isTextAlignRight ? "is-active" : ""} tiptap-control-button`,
|
|
1063
|
-
title: translations2.alignment.alignRight,
|
|
1064
|
-
type: "button",
|
|
1065
|
-
children: /* @__PURE__ */ jsx58(AlignRight_default, {})
|
|
1066
|
-
}
|
|
1067
|
-
)
|
|
1068
|
-
] }),
|
|
1069
|
-
/* @__PURE__ */ jsxs10("div", { className: "tiptap-controls-group", children: [
|
|
1070
|
-
/* @__PURE__ */ jsx58(
|
|
1071
|
-
"button",
|
|
1072
|
-
{
|
|
1073
|
-
type: "button",
|
|
1074
|
-
onClick: () => editor.chain().focus().toggleSuperscript().run(),
|
|
1075
|
-
className: `${isSuperscript ? "is-active" : ""} tiptap-control-button`,
|
|
1076
|
-
title: translations2.textFormatting.superscript,
|
|
1077
|
-
children: /* @__PURE__ */ jsx58(Superscript_default, {})
|
|
1078
|
-
}
|
|
1079
|
-
),
|
|
1080
|
-
/* @__PURE__ */ jsx58(
|
|
1081
|
-
"button",
|
|
1082
|
-
{
|
|
1083
|
-
type: "button",
|
|
1084
|
-
onClick: () => editor.chain().focus().toggleSubscript().run(),
|
|
1085
|
-
className: `${isSubscript ? "is-active" : ""} tiptap-control-button`,
|
|
1086
|
-
title: translations2.textFormatting.subscript,
|
|
1087
|
-
children: /* @__PURE__ */ jsx58(Subscript_default, {})
|
|
1088
|
-
}
|
|
1089
|
-
)
|
|
1090
|
-
] }),
|
|
1091
|
-
/* @__PURE__ */ jsx58("div", { className: "tiptap-controls-group", children: /* @__PURE__ */ jsx58(
|
|
1092
|
-
"button",
|
|
1093
|
-
{
|
|
1094
|
-
type: "button",
|
|
1095
|
-
onClick: () => {
|
|
1096
|
-
editor.chain().focus().clearNodes().run();
|
|
1097
|
-
editor.chain().focus().unsetAllMarks().run();
|
|
1098
|
-
},
|
|
1099
|
-
disabled: !canClearMarks,
|
|
1100
|
-
className: "tiptap-control-button",
|
|
1101
|
-
title: translations2.textFormatting.clearFormatting,
|
|
1102
|
-
children: /* @__PURE__ */ jsx58(ClearFormatting_default, {})
|
|
1103
|
-
}
|
|
1104
|
-
) })
|
|
1105
|
-
] });
|
|
1110
|
+
) })
|
|
1111
|
+
]
|
|
1112
|
+
}
|
|
1113
|
+
);
|
|
1106
1114
|
};
|
|
1107
1115
|
|
|
1108
1116
|
// src/editor/controls/drag-handle.tsx
|
|
@@ -1379,7 +1387,9 @@ var CommandsList = forwardRef(({ items, command }, ref) => {
|
|
|
1379
1387
|
if (item) {
|
|
1380
1388
|
if (item.dialogCommand) {
|
|
1381
1389
|
openDialogCommand(item.dialogCommand);
|
|
1390
|
+
command(item);
|
|
1382
1391
|
} else {
|
|
1392
|
+
console.log("open video");
|
|
1383
1393
|
command(item);
|
|
1384
1394
|
}
|
|
1385
1395
|
}
|
|
@@ -1392,6 +1402,10 @@ var CommandsList = forwardRef(({ items, command }, ref) => {
|
|
|
1392
1402
|
{
|
|
1393
1403
|
ref: listRef,
|
|
1394
1404
|
className: "commands-list-container",
|
|
1405
|
+
onMouseDown: (e) => {
|
|
1406
|
+
e.preventDefault();
|
|
1407
|
+
e.stopPropagation();
|
|
1408
|
+
},
|
|
1395
1409
|
children: items.map((item, index) => /* @__PURE__ */ jsxs13(
|
|
1396
1410
|
"button",
|
|
1397
1411
|
{
|
|
@@ -2442,11 +2456,7 @@ var SUPPORTED_PLATFORMS = {
|
|
|
2442
2456
|
["rutube" /* Rutube */]: "Rutube",
|
|
2443
2457
|
["vk" /* VK */]: "VK"
|
|
2444
2458
|
};
|
|
2445
|
-
var AddVideoDialog = ({
|
|
2446
|
-
open,
|
|
2447
|
-
onClose,
|
|
2448
|
-
onVideoAdd
|
|
2449
|
-
}) => {
|
|
2459
|
+
var AddVideoDialog = ({ open, onClose, onVideoAdd }) => {
|
|
2450
2460
|
const translations2 = useTiptapTranslations();
|
|
2451
2461
|
const [url, setUrl] = useState9("");
|
|
2452
2462
|
const [error, setError] = useState9("");
|
|
@@ -2529,6 +2539,7 @@ var AddVideoDialog = ({
|
|
|
2529
2539
|
{
|
|
2530
2540
|
ref: urlInputRef,
|
|
2531
2541
|
id: "video-url",
|
|
2542
|
+
autoComplete: "off",
|
|
2532
2543
|
type: "text",
|
|
2533
2544
|
className: "video-dialog-input",
|
|
2534
2545
|
placeholder: translations2.videoUpload.urlPlaceholder,
|
|
@@ -4243,23 +4254,26 @@ var PromptContent = ({ children, isEmpty, placeholder }) => /* @__PURE__ */ jsx8
|
|
|
4243
4254
|
}
|
|
4244
4255
|
) });
|
|
4245
4256
|
|
|
4246
|
-
// src/extensions/views/components/
|
|
4257
|
+
// src/extensions/views/components/table.tsx
|
|
4247
4258
|
import { jsx as jsx82, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
4259
|
+
|
|
4260
|
+
// src/extensions/views/components/video.tsx
|
|
4261
|
+
import { jsx as jsx83, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
4248
4262
|
var Video = ({ src, children }) => {
|
|
4249
4263
|
const videoInfo = detectVideoHosting(src);
|
|
4250
4264
|
if (!videoInfo?.embedUrl) {
|
|
4251
|
-
return /* @__PURE__ */
|
|
4252
|
-
/* @__PURE__ */
|
|
4265
|
+
return /* @__PURE__ */ jsxs34("div", { className: "video-node", children: [
|
|
4266
|
+
/* @__PURE__ */ jsx83("div", { className: "video-error", children: /* @__PURE__ */ jsx83("span", { children: "Unsupported or invalid video URL" }) }),
|
|
4253
4267
|
children
|
|
4254
4268
|
] });
|
|
4255
4269
|
}
|
|
4256
|
-
return /* @__PURE__ */
|
|
4270
|
+
return /* @__PURE__ */ jsxs34(
|
|
4257
4271
|
"div",
|
|
4258
4272
|
{
|
|
4259
4273
|
className: "video-node",
|
|
4260
4274
|
"data-video": "",
|
|
4261
4275
|
children: [
|
|
4262
|
-
/* @__PURE__ */
|
|
4276
|
+
/* @__PURE__ */ jsx83("div", { className: "video-player-wrapper", children: /* @__PURE__ */ jsx83(
|
|
4263
4277
|
"iframe",
|
|
4264
4278
|
{
|
|
4265
4279
|
className: "video-iframe",
|
|
@@ -4278,7 +4292,7 @@ var Video = ({ src, children }) => {
|
|
|
4278
4292
|
// src/editor/controls/emoji-picker.tsx
|
|
4279
4293
|
import { useEffect as useEffect8, useRef as useRef10 } from "react";
|
|
4280
4294
|
import EmojiPicker from "emoji-picker-react";
|
|
4281
|
-
import { jsx as
|
|
4295
|
+
import { jsx as jsx84 } from "react/jsx-runtime";
|
|
4282
4296
|
var EmojiPickerComponent = ({ isOpen, onClose, onEmojiSelect }) => {
|
|
4283
4297
|
const pickerRef = useRef10(null);
|
|
4284
4298
|
const translations2 = useTiptapTranslations();
|
|
@@ -4296,12 +4310,12 @@ var EmojiPickerComponent = ({ isOpen, onClose, onEmojiSelect }) => {
|
|
|
4296
4310
|
};
|
|
4297
4311
|
}, [isOpen, onClose]);
|
|
4298
4312
|
if (!isOpen) return null;
|
|
4299
|
-
return /* @__PURE__ */
|
|
4313
|
+
return /* @__PURE__ */ jsx84(
|
|
4300
4314
|
"div",
|
|
4301
4315
|
{
|
|
4302
4316
|
ref: pickerRef,
|
|
4303
4317
|
className: "tiptap__emoji-picker-wrapper",
|
|
4304
|
-
children: /* @__PURE__ */
|
|
4318
|
+
children: /* @__PURE__ */ jsx84(
|
|
4305
4319
|
EmojiPicker,
|
|
4306
4320
|
{
|
|
4307
4321
|
skinTonesDisabled: true,
|
|
@@ -4326,7 +4340,7 @@ var EmojiPickerComponent = ({ isOpen, onClose, onEmojiSelect }) => {
|
|
|
4326
4340
|
};
|
|
4327
4341
|
|
|
4328
4342
|
// src/extensions/views/node-views/callout.tsx
|
|
4329
|
-
import { jsx as
|
|
4343
|
+
import { jsx as jsx85, jsxs as jsxs35 } from "react/jsx-runtime";
|
|
4330
4344
|
var CalloutView = (props) => {
|
|
4331
4345
|
const type = props.node.attrs.type || "info";
|
|
4332
4346
|
const bgColor = props.node.attrs.bgColor;
|
|
@@ -4341,23 +4355,23 @@ var CalloutView = (props) => {
|
|
|
4341
4355
|
props.updateAttributes({ emoji: newEmoji });
|
|
4342
4356
|
setShowEmojiPicker(false);
|
|
4343
4357
|
};
|
|
4344
|
-
return /* @__PURE__ */
|
|
4358
|
+
return /* @__PURE__ */ jsx85(NodeViewWrapper, { children: /* @__PURE__ */ jsx85(
|
|
4345
4359
|
Callout,
|
|
4346
4360
|
{
|
|
4347
4361
|
type,
|
|
4348
4362
|
bgColor,
|
|
4349
4363
|
emoji,
|
|
4350
|
-
iconWrapper: (icon) => /* @__PURE__ */
|
|
4351
|
-
/* @__PURE__ */
|
|
4364
|
+
iconWrapper: (icon) => /* @__PURE__ */ jsxs35("div", { className: "callout-icon-wrapper", children: [
|
|
4365
|
+
/* @__PURE__ */ jsx85(
|
|
4352
4366
|
"button",
|
|
4353
4367
|
{
|
|
4354
4368
|
className: "callout-icon-button",
|
|
4355
4369
|
onClick: handleIconClick,
|
|
4356
4370
|
type: "button",
|
|
4357
|
-
children: /* @__PURE__ */
|
|
4371
|
+
children: /* @__PURE__ */ jsx85("div", { className: "callout-icon", children: icon })
|
|
4358
4372
|
}
|
|
4359
4373
|
),
|
|
4360
|
-
/* @__PURE__ */
|
|
4374
|
+
/* @__PURE__ */ jsx85(
|
|
4361
4375
|
EmojiPickerComponent,
|
|
4362
4376
|
{
|
|
4363
4377
|
isOpen: showEmojiPicker,
|
|
@@ -4366,7 +4380,7 @@ var CalloutView = (props) => {
|
|
|
4366
4380
|
}
|
|
4367
4381
|
)
|
|
4368
4382
|
] }),
|
|
4369
|
-
children: /* @__PURE__ */
|
|
4383
|
+
children: /* @__PURE__ */ jsx85(NodeViewContent, { as: "div" })
|
|
4370
4384
|
}
|
|
4371
4385
|
) });
|
|
4372
4386
|
};
|
|
@@ -4374,7 +4388,7 @@ var CalloutView = (props) => {
|
|
|
4374
4388
|
// src/extensions/views/node-views/code-block.tsx
|
|
4375
4389
|
import { useState as useState11 } from "react";
|
|
4376
4390
|
import { NodeViewContent as NodeViewContent2, NodeViewWrapper as NodeViewWrapper2 } from "@tiptap/react";
|
|
4377
|
-
import { jsx as
|
|
4391
|
+
import { jsx as jsx86 } from "react/jsx-runtime";
|
|
4378
4392
|
var CodeBlockView = (props) => {
|
|
4379
4393
|
const [selectedLanguage, setSelectedLanguage] = useState11(props.node.attrs.language ?? "");
|
|
4380
4394
|
const translations2 = useTiptapTranslations();
|
|
@@ -4382,71 +4396,71 @@ var CodeBlockView = (props) => {
|
|
|
4382
4396
|
props.updateAttributes({ language });
|
|
4383
4397
|
setSelectedLanguage(language);
|
|
4384
4398
|
};
|
|
4385
|
-
return /* @__PURE__ */
|
|
4399
|
+
return /* @__PURE__ */ jsx86(NodeViewWrapper2, { children: /* @__PURE__ */ jsx86(
|
|
4386
4400
|
CodeBlock,
|
|
4387
4401
|
{
|
|
4388
4402
|
language: selectedLanguage,
|
|
4389
4403
|
isEditable: props.editor.isEditable,
|
|
4390
4404
|
onLanguageChange: handleLanguageChange,
|
|
4391
4405
|
translations: translations2,
|
|
4392
|
-
children: /* @__PURE__ */
|
|
4406
|
+
children: /* @__PURE__ */ jsx86(NodeViewContent2, {})
|
|
4393
4407
|
}
|
|
4394
4408
|
) });
|
|
4395
4409
|
};
|
|
4396
4410
|
|
|
4397
4411
|
// src/extensions/views/node-views/copyable-text.tsx
|
|
4398
4412
|
import { MarkViewContent } from "@tiptap/react";
|
|
4399
|
-
import { jsx as
|
|
4413
|
+
import { jsx as jsx87 } from "react/jsx-runtime";
|
|
4400
4414
|
var CopyableTextView = () => {
|
|
4401
|
-
return /* @__PURE__ */
|
|
4415
|
+
return /* @__PURE__ */ jsx87(CopyableText2, { children: /* @__PURE__ */ jsx87(MarkViewContent, {}) });
|
|
4402
4416
|
};
|
|
4403
4417
|
|
|
4404
4418
|
// src/extensions/views/node-views/custom-quote.tsx
|
|
4405
4419
|
import { NodeViewContent as NodeViewContent3, NodeViewWrapper as NodeViewWrapper3 } from "@tiptap/react";
|
|
4406
|
-
import { jsx as
|
|
4420
|
+
import { jsx as jsx88 } from "react/jsx-runtime";
|
|
4407
4421
|
var CustomQuoteView = () => {
|
|
4408
|
-
return /* @__PURE__ */
|
|
4422
|
+
return /* @__PURE__ */ jsx88(NodeViewWrapper3, { children: /* @__PURE__ */ jsx88(CustomQuote, { children: /* @__PURE__ */ jsx88(NodeViewContent3, {}) }) });
|
|
4409
4423
|
};
|
|
4410
4424
|
var CustomQuoteTextView = (props) => {
|
|
4411
4425
|
const isEmpty = !props.node.content.size;
|
|
4412
4426
|
const translations2 = useTiptapTranslations();
|
|
4413
|
-
return /* @__PURE__ */
|
|
4427
|
+
return /* @__PURE__ */ jsx88(NodeViewWrapper3, { children: /* @__PURE__ */ jsx88(
|
|
4414
4428
|
CustomQuoteText,
|
|
4415
4429
|
{
|
|
4416
4430
|
isEmpty,
|
|
4417
4431
|
placeholder: translations2.customQuote.textPlaceholder,
|
|
4418
|
-
children: /* @__PURE__ */
|
|
4432
|
+
children: /* @__PURE__ */ jsx88(NodeViewContent3, { className: isEmpty ? "is-empty" : "" })
|
|
4419
4433
|
}
|
|
4420
4434
|
) });
|
|
4421
4435
|
};
|
|
4422
4436
|
var CustomQuoteAuthorView = (props) => {
|
|
4423
4437
|
const isEmpty = !props.node.content.size;
|
|
4424
4438
|
const translations2 = useTiptapTranslations();
|
|
4425
|
-
return /* @__PURE__ */
|
|
4439
|
+
return /* @__PURE__ */ jsx88(NodeViewWrapper3, { children: /* @__PURE__ */ jsx88(
|
|
4426
4440
|
CustomQuoteAuthor,
|
|
4427
4441
|
{
|
|
4428
4442
|
isEmpty,
|
|
4429
4443
|
placeholder: translations2.customQuote.authorPlaceholder,
|
|
4430
|
-
children: /* @__PURE__ */
|
|
4444
|
+
children: /* @__PURE__ */ jsx88(NodeViewContent3, { className: isEmpty ? "is-empty" : "" })
|
|
4431
4445
|
}
|
|
4432
4446
|
) });
|
|
4433
4447
|
};
|
|
4434
4448
|
var CustomQuoteSignView = (props) => {
|
|
4435
4449
|
const isEmpty = !props.node.content.size;
|
|
4436
4450
|
const translations2 = useTiptapTranslations();
|
|
4437
|
-
return /* @__PURE__ */
|
|
4451
|
+
return /* @__PURE__ */ jsx88(NodeViewWrapper3, { children: /* @__PURE__ */ jsx88(
|
|
4438
4452
|
CustomQuoteSign,
|
|
4439
4453
|
{
|
|
4440
4454
|
isEmpty,
|
|
4441
4455
|
placeholder: translations2.customQuote.signPlaceholder,
|
|
4442
|
-
children: /* @__PURE__ */
|
|
4456
|
+
children: /* @__PURE__ */ jsx88(NodeViewContent3, { className: isEmpty ? "is-empty" : "" })
|
|
4443
4457
|
}
|
|
4444
4458
|
) });
|
|
4445
4459
|
};
|
|
4446
4460
|
|
|
4447
4461
|
// src/extensions/views/node-views/figure.tsx
|
|
4448
4462
|
import { NodeViewWrapper as NodeViewWrapper4 } from "@tiptap/react";
|
|
4449
|
-
import { jsx as
|
|
4463
|
+
import { jsx as jsx89 } from "react/jsx-runtime";
|
|
4450
4464
|
var FigureView = ({ node, getPos, editor }) => {
|
|
4451
4465
|
const { fileId, src, alt, title, caption, width, height } = node.attrs;
|
|
4452
4466
|
const imageExtension = editor.extensionManager.extensions.find((ext) => ext.name === "image");
|
|
@@ -4455,12 +4469,12 @@ var FigureView = ({ node, getPos, editor }) => {
|
|
|
4455
4469
|
const handleEditClick = () => {
|
|
4456
4470
|
onFigureClick?.(node.attrs, getPos());
|
|
4457
4471
|
};
|
|
4458
|
-
return /* @__PURE__ */
|
|
4472
|
+
return /* @__PURE__ */ jsx89(
|
|
4459
4473
|
NodeViewWrapper4,
|
|
4460
4474
|
{
|
|
4461
4475
|
className: "figure-node-view",
|
|
4462
4476
|
"data-drag-handle": true,
|
|
4463
|
-
children: /* @__PURE__ */
|
|
4477
|
+
children: /* @__PURE__ */ jsx89(
|
|
4464
4478
|
Figure,
|
|
4465
4479
|
{
|
|
4466
4480
|
fileId,
|
|
@@ -4481,38 +4495,38 @@ var FigureView = ({ node, getPos, editor }) => {
|
|
|
4481
4495
|
|
|
4482
4496
|
// src/extensions/views/node-views/prompt.tsx
|
|
4483
4497
|
import { NodeViewContent as NodeViewContent4, NodeViewWrapper as NodeViewWrapper5 } from "@tiptap/react";
|
|
4484
|
-
import { jsx as
|
|
4498
|
+
import { jsx as jsx90 } from "react/jsx-runtime";
|
|
4485
4499
|
var PromptHeaderView = (props) => {
|
|
4486
4500
|
const isEmpty = !props.node.content.size;
|
|
4487
4501
|
const translations2 = useTiptapTranslations();
|
|
4488
|
-
return /* @__PURE__ */
|
|
4502
|
+
return /* @__PURE__ */ jsx90(NodeViewWrapper5, { children: /* @__PURE__ */ jsx90(
|
|
4489
4503
|
PromptHeader,
|
|
4490
4504
|
{
|
|
4491
4505
|
isEmpty,
|
|
4492
4506
|
placeholder: translations2.prompt.headerPlaceholder,
|
|
4493
|
-
children: /* @__PURE__ */
|
|
4507
|
+
children: /* @__PURE__ */ jsx90(NodeViewContent4, { className: isEmpty ? "is-empty" : "" })
|
|
4494
4508
|
}
|
|
4495
4509
|
) });
|
|
4496
4510
|
};
|
|
4497
4511
|
var PromptContentView = (props) => {
|
|
4498
4512
|
const isEmpty = !props.node.content.size;
|
|
4499
4513
|
const translations2 = useTiptapTranslations();
|
|
4500
|
-
return /* @__PURE__ */
|
|
4514
|
+
return /* @__PURE__ */ jsx90(NodeViewWrapper5, { children: /* @__PURE__ */ jsx90(
|
|
4501
4515
|
PromptContent,
|
|
4502
4516
|
{
|
|
4503
4517
|
isEmpty,
|
|
4504
4518
|
placeholder: translations2.prompt.contentPlaceholder,
|
|
4505
|
-
children: /* @__PURE__ */
|
|
4519
|
+
children: /* @__PURE__ */ jsx90(NodeViewContent4, { className: isEmpty ? "is-empty" : "" })
|
|
4506
4520
|
}
|
|
4507
4521
|
) });
|
|
4508
4522
|
};
|
|
4509
4523
|
|
|
4510
4524
|
// src/extensions/views/node-views/video.tsx
|
|
4511
4525
|
import { NodeViewContent as NodeViewContent5, NodeViewWrapper as NodeViewWrapper6 } from "@tiptap/react";
|
|
4512
|
-
import { jsx as
|
|
4526
|
+
import { jsx as jsx91 } from "react/jsx-runtime";
|
|
4513
4527
|
var VideoView = (props) => {
|
|
4514
4528
|
const { src } = props.node.attrs;
|
|
4515
|
-
return /* @__PURE__ */
|
|
4529
|
+
return /* @__PURE__ */ jsx91(NodeViewWrapper6, { children: /* @__PURE__ */ jsx91(Video, { src, children: /* @__PURE__ */ jsx91(
|
|
4516
4530
|
NodeViewContent5,
|
|
4517
4531
|
{
|
|
4518
4532
|
as: "div",
|
|
@@ -5115,7 +5129,7 @@ function getEditorExtensions(options) {
|
|
|
5115
5129
|
}
|
|
5116
5130
|
|
|
5117
5131
|
// src/editor/handlers/dialog-handlers.ts
|
|
5118
|
-
var createHandleImageAdd = (editor, closeDialogCommand) => {
|
|
5132
|
+
var createHandleImageAdd = (editor, closeDialogCommand, savedPos) => {
|
|
5119
5133
|
return (attrs) => {
|
|
5120
5134
|
if (!editor) return;
|
|
5121
5135
|
const { state } = editor;
|
|
@@ -5126,9 +5140,19 @@ var createHandleImageAdd = (editor, closeDialogCommand) => {
|
|
|
5126
5140
|
const node = editor.schema.nodes.image.create({ ...attrs });
|
|
5127
5141
|
tr.replaceWith($from.before(), $from.after(), node);
|
|
5128
5142
|
return true;
|
|
5129
|
-
}).run();
|
|
5143
|
+
}).scrollIntoView().run();
|
|
5130
5144
|
} else {
|
|
5131
|
-
|
|
5145
|
+
const insertPos = savedPos ?? state.selection.from;
|
|
5146
|
+
editor.chain().focus().command(({ tr, state: state2 }) => {
|
|
5147
|
+
const $pos = state2.doc.resolve(insertPos);
|
|
5148
|
+
const figureNode = state2.schema.nodes.figure.create({ ...attrs });
|
|
5149
|
+
if ($pos.parent.type.name === "paragraph" && $pos.parent.textContent === "") {
|
|
5150
|
+
tr.replaceWith($pos.before(), $pos.after(), figureNode);
|
|
5151
|
+
} else {
|
|
5152
|
+
tr.insert(insertPos, figureNode);
|
|
5153
|
+
}
|
|
5154
|
+
return true;
|
|
5155
|
+
}).scrollIntoView().run();
|
|
5132
5156
|
}
|
|
5133
5157
|
closeDialogCommand();
|
|
5134
5158
|
};
|
|
@@ -5140,23 +5164,38 @@ var createHandleImageEdit = (editor, closeDialogCommand, pos) => {
|
|
|
5140
5164
|
closeDialogCommand();
|
|
5141
5165
|
};
|
|
5142
5166
|
};
|
|
5143
|
-
var createHandleVideoAdd = (editor, closeDialogCommand) => {
|
|
5167
|
+
var createHandleVideoAdd = (editor, closeDialogCommand, savedPos) => {
|
|
5144
5168
|
return (url) => {
|
|
5145
5169
|
if (!editor) return;
|
|
5146
5170
|
const { state } = editor;
|
|
5147
5171
|
const { $from } = state.selection;
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5172
|
+
const text = $from.parent.textContent;
|
|
5173
|
+
if (text.lastIndexOf("/") !== -1) {
|
|
5174
|
+
editor.chain().focus().command(({ tr }) => {
|
|
5175
|
+
tr.replaceWith(
|
|
5176
|
+
$from.before(),
|
|
5177
|
+
$from.after(),
|
|
5178
|
+
editor.schema.nodes.video.create({ src: url })
|
|
5179
|
+
);
|
|
5180
|
+
return true;
|
|
5181
|
+
}).scrollIntoView().run();
|
|
5182
|
+
} else {
|
|
5183
|
+
const insertPos = savedPos ?? state.selection.from;
|
|
5184
|
+
editor.chain().focus().command(({ tr, state: state2 }) => {
|
|
5185
|
+
const $pos = state2.doc.resolve(insertPos);
|
|
5186
|
+
const videoNode = state2.schema.nodes.video.create({ src: url });
|
|
5187
|
+
if ($pos.parent.type.name === "paragraph" && $pos.parent.textContent === "") {
|
|
5188
|
+
tr.replaceWith($pos.before(), $pos.after(), videoNode);
|
|
5189
|
+
} else {
|
|
5190
|
+
tr.insert(insertPos, videoNode);
|
|
5191
|
+
}
|
|
5192
|
+
return true;
|
|
5193
|
+
}).scrollIntoView().run();
|
|
5194
|
+
}
|
|
5156
5195
|
closeDialogCommand();
|
|
5157
5196
|
};
|
|
5158
5197
|
};
|
|
5159
|
-
var createHandleLinkAdd = (editor, closeDialogCommand) => {
|
|
5198
|
+
var createHandleLinkAdd = (editor, closeDialogCommand, savedPos) => {
|
|
5160
5199
|
return (title, url) => {
|
|
5161
5200
|
if (!editor) return;
|
|
5162
5201
|
const hasSelection = !editor.state.selection.empty;
|
|
@@ -5168,22 +5207,31 @@ var createHandleLinkAdd = (editor, closeDialogCommand) => {
|
|
|
5168
5207
|
return true;
|
|
5169
5208
|
}).run();
|
|
5170
5209
|
} else {
|
|
5171
|
-
|
|
5172
|
-
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5210
|
+
const { state } = editor;
|
|
5211
|
+
const { $from } = state.selection;
|
|
5212
|
+
const text = $from.parent.textContent;
|
|
5213
|
+
const nodeStart = $from.start();
|
|
5214
|
+
const beforeCursor = text.substring(0, $from.pos - nodeStart);
|
|
5215
|
+
const slashIndex = beforeCursor.lastIndexOf("/");
|
|
5216
|
+
if (slashIndex !== -1) {
|
|
5217
|
+
editor.chain().focus().command(({ tr }) => {
|
|
5178
5218
|
tr.delete(nodeStart + slashIndex, $from.pos);
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
}
|
|
5219
|
+
return true;
|
|
5220
|
+
}).extendMarkRange("link").setLink({ href: url }).insertContent(title).scrollIntoView().run();
|
|
5221
|
+
} else {
|
|
5222
|
+
const insertPos = savedPos ?? state.selection.from;
|
|
5223
|
+
editor.chain().focus().command(({ tr }) => {
|
|
5224
|
+
const linkMark = editor.schema.marks.link.create({ href: url });
|
|
5225
|
+
const textNode = editor.schema.text(title, [linkMark]);
|
|
5226
|
+
tr.insert(insertPos, textNode);
|
|
5227
|
+
return true;
|
|
5228
|
+
}).scrollIntoView().run();
|
|
5229
|
+
}
|
|
5182
5230
|
}
|
|
5183
5231
|
closeDialogCommand();
|
|
5184
5232
|
};
|
|
5185
5233
|
};
|
|
5186
|
-
var createHandleKatexAdd = (editor, closeDialogCommand) => {
|
|
5234
|
+
var createHandleKatexAdd = (editor, closeDialogCommand, savedPos) => {
|
|
5187
5235
|
return (latex, pos) => {
|
|
5188
5236
|
if (!editor) return;
|
|
5189
5237
|
if (pos !== void 0) {
|
|
@@ -5202,9 +5250,14 @@ var createHandleKatexAdd = (editor, closeDialogCommand) => {
|
|
|
5202
5250
|
const inlineMathNode = state2.schema.nodes.inlineMath.create({ latex });
|
|
5203
5251
|
tr.replaceRangeWith(deleteFrom, deleteTo, inlineMathNode);
|
|
5204
5252
|
return true;
|
|
5205
|
-
}).run();
|
|
5253
|
+
}).scrollIntoView().run();
|
|
5206
5254
|
} else {
|
|
5207
|
-
|
|
5255
|
+
const insertPos = savedPos ?? state.selection.from;
|
|
5256
|
+
editor.chain().focus().command(({ tr, state: state2 }) => {
|
|
5257
|
+
const inlineMathNode = state2.schema.nodes.inlineMath.create({ latex });
|
|
5258
|
+
tr.insert(insertPos, inlineMathNode);
|
|
5259
|
+
return true;
|
|
5260
|
+
}).scrollIntoView().run();
|
|
5208
5261
|
}
|
|
5209
5262
|
}
|
|
5210
5263
|
closeDialogCommand();
|
|
@@ -5349,7 +5402,7 @@ var getCommandItems = (translations2, hasImageHandlers) => [
|
|
|
5349
5402
|
onClick: (editor) => {
|
|
5350
5403
|
editor.chain().focus().insertContent({
|
|
5351
5404
|
type: "callout",
|
|
5352
|
-
attrs: { type: "", bgColor: "#F7F7F8" },
|
|
5405
|
+
attrs: { type: "", bgColor: "#F7F7F8", emoji: "callout-info" },
|
|
5353
5406
|
content: [
|
|
5354
5407
|
{
|
|
5355
5408
|
type: "paragraph",
|
|
@@ -5515,7 +5568,7 @@ var filterCommandItems = (items, query) => {
|
|
|
5515
5568
|
};
|
|
5516
5569
|
|
|
5517
5570
|
// src/editor/commands/suggestion.tsx
|
|
5518
|
-
import { jsx as
|
|
5571
|
+
import { jsx as jsx92 } from "react/jsx-runtime";
|
|
5519
5572
|
var component = null;
|
|
5520
5573
|
var closeMenu = () => {
|
|
5521
5574
|
if (component) {
|
|
@@ -5529,7 +5582,7 @@ var mapCommandMenuItemToCommandItem = (item) => {
|
|
|
5529
5582
|
const IconComponent = item.icon;
|
|
5530
5583
|
return {
|
|
5531
5584
|
title: item.title,
|
|
5532
|
-
icon: /* @__PURE__ */
|
|
5585
|
+
icon: /* @__PURE__ */ jsx92(IconComponent, {}),
|
|
5533
5586
|
command: ({ editor, range }) => {
|
|
5534
5587
|
editor.chain().focus().deleteRange(range).run();
|
|
5535
5588
|
item.onClick(editor);
|
|
@@ -5952,7 +6005,7 @@ function getTranslations(lang) {
|
|
|
5952
6005
|
}
|
|
5953
6006
|
|
|
5954
6007
|
// src/editor/editor.tsx
|
|
5955
|
-
import { Fragment as Fragment3, jsx as
|
|
6008
|
+
import { Fragment as Fragment3, jsx as jsx93, jsxs as jsxs36 } from "react/jsx-runtime";
|
|
5956
6009
|
function TiptapContent({
|
|
5957
6010
|
content,
|
|
5958
6011
|
handleChange,
|
|
@@ -5967,6 +6020,7 @@ function TiptapContent({
|
|
|
5967
6020
|
null
|
|
5968
6021
|
);
|
|
5969
6022
|
const [editFigureContext, setEditFigureContext] = useState12(null);
|
|
6023
|
+
const [savedDialogCursorPos, setSavedDialogCursorPos] = useState12(void 0);
|
|
5970
6024
|
const { activeDialog, closeDialogCommand, openDialogCommand } = useDialogCommand();
|
|
5971
6025
|
const translations2 = useTiptapTranslations();
|
|
5972
6026
|
let safeContent;
|
|
@@ -6016,18 +6070,25 @@ function TiptapContent({
|
|
|
6016
6070
|
},
|
|
6017
6071
|
[lang]
|
|
6018
6072
|
);
|
|
6073
|
+
useEffect9(() => {
|
|
6074
|
+
if (activeDialog && editor && !editor.isDestroyed) {
|
|
6075
|
+
const pos = editor.state.selection.from;
|
|
6076
|
+
setSavedDialogCursorPos(pos);
|
|
6077
|
+
}
|
|
6078
|
+
}, [activeDialog, editor]);
|
|
6019
6079
|
const handleCloseDialog = () => {
|
|
6020
6080
|
setLinkDialogContext(null);
|
|
6021
6081
|
setKatexDialogContext(null);
|
|
6022
6082
|
setEditFigureContext(null);
|
|
6083
|
+
setSavedDialogCursorPos(void 0);
|
|
6023
6084
|
closeDialogCommand();
|
|
6024
6085
|
};
|
|
6025
|
-
const handleImageAdd = createHandleImageAdd(editor, handleCloseDialog);
|
|
6086
|
+
const handleImageAdd = createHandleImageAdd(editor, handleCloseDialog, savedDialogCursorPos);
|
|
6026
6087
|
const handleImageEdit = createHandleImageEdit(editor, handleCloseDialog, editFigureContext?.pos);
|
|
6027
|
-
const handleVideoAdd = createHandleVideoAdd(editor, handleCloseDialog);
|
|
6028
|
-
const handleLinkAdd = createHandleLinkAdd(editor, handleCloseDialog);
|
|
6088
|
+
const handleVideoAdd = createHandleVideoAdd(editor, handleCloseDialog, savedDialogCursorPos);
|
|
6089
|
+
const handleLinkAdd = createHandleLinkAdd(editor, handleCloseDialog, savedDialogCursorPos);
|
|
6029
6090
|
const handleKatexAdd = (latex) => {
|
|
6030
|
-
const katexHandler = createHandleKatexAdd(editor, handleCloseDialog);
|
|
6091
|
+
const katexHandler = createHandleKatexAdd(editor, handleCloseDialog, savedDialogCursorPos);
|
|
6031
6092
|
katexHandler(latex, katexDialogContext?.pos);
|
|
6032
6093
|
};
|
|
6033
6094
|
useEffect9(() => {
|
|
@@ -6036,7 +6097,6 @@ function TiptapContent({
|
|
|
6036
6097
|
emitUpdate: false
|
|
6037
6098
|
});
|
|
6038
6099
|
}, [content, editor]);
|
|
6039
|
-
if (!editor) return null;
|
|
6040
6100
|
const shouldBubbleMenuShow = ({ state }) => {
|
|
6041
6101
|
if (state.selection instanceof NodeSelection) {
|
|
6042
6102
|
return false;
|
|
@@ -6049,16 +6109,17 @@ function TiptapContent({
|
|
|
6049
6109
|
}
|
|
6050
6110
|
return true;
|
|
6051
6111
|
};
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
!isDisabled && /* @__PURE__ */
|
|
6112
|
+
if (!editor) return null;
|
|
6113
|
+
return /* @__PURE__ */ jsxs36(Fragment3, { children: [
|
|
6114
|
+
/* @__PURE__ */ jsx93(DragHandle, { editor }),
|
|
6115
|
+
isEditable && !isDisabled && /* @__PURE__ */ jsx93(TableMenu, { editor }),
|
|
6116
|
+
isEditable && !isDisabled && /* @__PURE__ */ jsx93(
|
|
6056
6117
|
BubbleMenu,
|
|
6057
6118
|
{
|
|
6058
6119
|
shouldShow: shouldBubbleMenuShow,
|
|
6059
6120
|
editor,
|
|
6060
6121
|
options: { placement: "bottom", offset: 8, flip: true },
|
|
6061
|
-
children: /* @__PURE__ */
|
|
6122
|
+
children: /* @__PURE__ */ jsx93(
|
|
6062
6123
|
BubbleMenuContent,
|
|
6063
6124
|
{
|
|
6064
6125
|
editor,
|
|
@@ -6067,63 +6128,65 @@ function TiptapContent({
|
|
|
6067
6128
|
)
|
|
6068
6129
|
}
|
|
6069
6130
|
),
|
|
6070
|
-
/* @__PURE__ */
|
|
6131
|
+
/* @__PURE__ */ jsxs36(
|
|
6071
6132
|
"div",
|
|
6072
6133
|
{
|
|
6073
6134
|
className: `tiptap-content-wrapper ${!!error ? "has-error" : ""} ${isDisabled ? "is-disabled" : ""}`,
|
|
6074
6135
|
children: [
|
|
6075
|
-
/* @__PURE__ */
|
|
6076
|
-
isEditable && !isDisabled && /* @__PURE__ */
|
|
6136
|
+
/* @__PURE__ */ jsx93(EditorContent, { editor }),
|
|
6137
|
+
isEditable && !isDisabled && /* @__PURE__ */ jsx93(CharacterCount, { editor })
|
|
6077
6138
|
]
|
|
6078
6139
|
}
|
|
6079
6140
|
),
|
|
6080
|
-
!!error && /* @__PURE__ */
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6141
|
+
!!error && /* @__PURE__ */ jsx93("p", { className: "tiptap-error-message", children: error }),
|
|
6142
|
+
isEditable && /* @__PURE__ */ jsxs36(Fragment3, { children: [
|
|
6143
|
+
activeDialog === "image" && /* @__PURE__ */ jsx93(
|
|
6144
|
+
ImageDialog,
|
|
6145
|
+
{
|
|
6146
|
+
open: true,
|
|
6147
|
+
onClose: handleCloseDialog,
|
|
6148
|
+
onImageAdd: handleImageAdd,
|
|
6149
|
+
onImageEdit: handleImageEdit,
|
|
6150
|
+
uploadHandler: imageHandlers?.upload,
|
|
6151
|
+
getImageById: imageHandlers?.getImage,
|
|
6152
|
+
initialAttrs: editFigureContext?.attrs || void 0,
|
|
6153
|
+
mode: editFigureContext ? "edit" : "add"
|
|
6154
|
+
}
|
|
6155
|
+
),
|
|
6156
|
+
activeDialog === "link" && /* @__PURE__ */ jsx93(
|
|
6157
|
+
AddLinkDialog,
|
|
6158
|
+
{
|
|
6159
|
+
open: true,
|
|
6160
|
+
onClose: handleCloseDialog,
|
|
6161
|
+
onLinkAdd: handleLinkAdd,
|
|
6162
|
+
initialTitle: linkDialogContext?.selectedText || "",
|
|
6163
|
+
initialUrl: linkDialogContext?.url || ""
|
|
6164
|
+
}
|
|
6165
|
+
),
|
|
6166
|
+
activeDialog === "video" && /* @__PURE__ */ jsx93(
|
|
6167
|
+
AddVideoDialog,
|
|
6168
|
+
{
|
|
6169
|
+
open: true,
|
|
6170
|
+
onClose: handleCloseDialog,
|
|
6171
|
+
onVideoAdd: handleVideoAdd
|
|
6172
|
+
}
|
|
6173
|
+
),
|
|
6174
|
+
activeDialog === "katex" && /* @__PURE__ */ jsx93(
|
|
6175
|
+
AddKatexDialog,
|
|
6176
|
+
{
|
|
6177
|
+
open: true,
|
|
6178
|
+
onClose: handleCloseDialog,
|
|
6179
|
+
onKatexAdd: handleKatexAdd,
|
|
6180
|
+
initialContent: katexDialogContext?.latex || ""
|
|
6181
|
+
}
|
|
6182
|
+
)
|
|
6183
|
+
] })
|
|
6121
6184
|
] });
|
|
6122
6185
|
}
|
|
6123
6186
|
var Tiptap = (props) => {
|
|
6124
6187
|
const { lang = "ru" } = props;
|
|
6125
6188
|
const translations2 = getTranslations(lang);
|
|
6126
|
-
return /* @__PURE__ */
|
|
6189
|
+
return /* @__PURE__ */ jsx93(TiptapTranslationsProvider, { translations: translations2, children: /* @__PURE__ */ jsx93(DialogCommandProvider, { children: /* @__PURE__ */ jsx93(TiptapContent, { ...props }) }) });
|
|
6127
6190
|
};
|
|
6128
6191
|
export {
|
|
6129
6192
|
Tiptap
|