@editorcn/editor 0.3.1 → 0.3.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.cjs +784 -348
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +803 -367
- package/dist/index.js.map +1 -1
- package/dist/style.css +1249 -1079
- package/package.json +65 -65
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/rte-text-editor.tsx
|
|
2
|
-
import { useMemo as useMemo2, useEffect as
|
|
2
|
+
import { useMemo as useMemo2, useEffect as useEffect6 } from "react";
|
|
3
3
|
|
|
4
4
|
// src/bubble-menu/index.tsx
|
|
5
5
|
import { isTextSelection } from "@tiptap/core";
|
|
@@ -23,7 +23,7 @@ var useRichTextEditorContext = () => {
|
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
// src/bubble-menu/utils.ts
|
|
26
|
-
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
26
|
+
import { useCallback, useEffect, useRef, useSyncExternalStore } from "react";
|
|
27
27
|
var defaultEqual = (a, b) => a === b;
|
|
28
28
|
var shallowEqual = (a, b) => {
|
|
29
29
|
if (a === b) {
|
|
@@ -41,9 +41,11 @@ var shallowEqual = (a, b) => {
|
|
|
41
41
|
};
|
|
42
42
|
var useEditorState = (editor, selector, isEqual = defaultEqual) => {
|
|
43
43
|
const selectorRef = useRef(selector);
|
|
44
|
-
selectorRef.current = selector;
|
|
45
44
|
const isEqualRef = useRef(isEqual);
|
|
46
|
-
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
selectorRef.current = selector;
|
|
47
|
+
isEqualRef.current = isEqual;
|
|
48
|
+
});
|
|
47
49
|
const snapshotRef = useRef({
|
|
48
50
|
value: editor ? selector(editor) : void 0
|
|
49
51
|
});
|
|
@@ -658,6 +660,7 @@ var H6Control = createControl({
|
|
|
658
660
|
});
|
|
659
661
|
var AlignLeftControl = createControl({
|
|
660
662
|
iconKey: "alignLeftControlIcon",
|
|
663
|
+
isActive: { attrs: { textAlign: "left" } },
|
|
661
664
|
label: "alignLeftControlLabel",
|
|
662
665
|
operation: { attributes: "left", name: "setTextAlign" }
|
|
663
666
|
});
|
|
@@ -899,32 +902,453 @@ var LinkControl = () => {
|
|
|
899
902
|
// src/controls/rte-twitter-control.tsx
|
|
900
903
|
import { Node, nodeInputRule } from "@tiptap/core";
|
|
901
904
|
import { ReactNodeViewRenderer, useEditorState as useEditorState4 } from "@tiptap/react";
|
|
902
|
-
import { useState as
|
|
905
|
+
import { useState as useState4, useCallback as useCallback6, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
903
906
|
|
|
904
907
|
// src/extensions/resizable-node-view.tsx
|
|
905
908
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
906
|
-
import { useCallback as useCallback5, useRef as useRef2,
|
|
909
|
+
import { useCallback as useCallback5, useEffect as useEffect3, useRef as useRef2, useState as useState3 } from "react";
|
|
910
|
+
|
|
911
|
+
// src/icons.tsx
|
|
912
|
+
import {
|
|
913
|
+
Bold,
|
|
914
|
+
Code,
|
|
915
|
+
Heading1,
|
|
916
|
+
Heading2,
|
|
917
|
+
Heading3,
|
|
918
|
+
Heading4,
|
|
919
|
+
Heading5,
|
|
920
|
+
Heading6,
|
|
921
|
+
Highlighter,
|
|
922
|
+
Italic,
|
|
923
|
+
Link,
|
|
924
|
+
Link2Off,
|
|
925
|
+
List,
|
|
926
|
+
ListOrdered,
|
|
927
|
+
Minus,
|
|
928
|
+
Redo2,
|
|
929
|
+
RemoveFormatting,
|
|
930
|
+
SquareCode,
|
|
931
|
+
Strikethrough,
|
|
932
|
+
Subscript,
|
|
933
|
+
Superscript,
|
|
934
|
+
TextAlignCenter,
|
|
935
|
+
TextAlignEnd,
|
|
936
|
+
TextAlignJustify,
|
|
937
|
+
TextAlignStart,
|
|
938
|
+
TextQuote,
|
|
939
|
+
Underline,
|
|
940
|
+
Undo2
|
|
941
|
+
} from "lucide-react";
|
|
942
|
+
import "react";
|
|
907
943
|
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
944
|
+
var ALIGN_PATHS = {
|
|
945
|
+
center: /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
946
|
+
/* @__PURE__ */ jsx10("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
947
|
+
/* @__PURE__ */ jsx10("line", { x1: "17", y1: "12", x2: "7", y2: "12" }),
|
|
948
|
+
/* @__PURE__ */ jsx10("line", { x1: "19", y1: "18", x2: "5", y2: "18" })
|
|
949
|
+
] }),
|
|
950
|
+
left: /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
951
|
+
/* @__PURE__ */ jsx10("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
952
|
+
/* @__PURE__ */ jsx10("line", { x1: "15", y1: "12", x2: "3", y2: "12" }),
|
|
953
|
+
/* @__PURE__ */ jsx10("line", { x1: "17", y1: "18", x2: "3", y2: "18" })
|
|
954
|
+
] }),
|
|
955
|
+
right: /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
956
|
+
/* @__PURE__ */ jsx10("line", { x1: "21", y1: "6", x2: "3", y2: "6" }),
|
|
957
|
+
/* @__PURE__ */ jsx10("line", { x1: "21", y1: "12", x2: "9", y2: "12" }),
|
|
958
|
+
/* @__PURE__ */ jsx10("line", { x1: "21", y1: "18", x2: "7", y2: "18" })
|
|
959
|
+
] })
|
|
960
|
+
};
|
|
961
|
+
var AlignIcon = ({ dir }) => /* @__PURE__ */ jsx10(
|
|
962
|
+
"svg",
|
|
963
|
+
{
|
|
964
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
965
|
+
viewBox: "0 0 24 24",
|
|
966
|
+
fill: "none",
|
|
967
|
+
stroke: "currentColor",
|
|
968
|
+
strokeWidth: "2",
|
|
969
|
+
strokeLinecap: "round",
|
|
970
|
+
strokeLinejoin: "round",
|
|
971
|
+
className: "rte-editor-icon",
|
|
972
|
+
children: ALIGN_PATHS[dir]
|
|
973
|
+
}
|
|
974
|
+
);
|
|
975
|
+
var EditUrlIcon = () => /* @__PURE__ */ jsxs4(
|
|
976
|
+
"svg",
|
|
977
|
+
{
|
|
978
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
979
|
+
viewBox: "0 0 24 24",
|
|
980
|
+
fill: "none",
|
|
981
|
+
stroke: "currentColor",
|
|
982
|
+
strokeWidth: "2",
|
|
983
|
+
strokeLinecap: "round",
|
|
984
|
+
strokeLinejoin: "round",
|
|
985
|
+
className: "rte-editor-icon",
|
|
986
|
+
children: [
|
|
987
|
+
/* @__PURE__ */ jsx10("path", { d: "M12 20h9" }),
|
|
988
|
+
/* @__PURE__ */ jsx10("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
|
|
989
|
+
]
|
|
990
|
+
}
|
|
991
|
+
);
|
|
992
|
+
var OpenInYouTubeIcon = () => /* @__PURE__ */ jsxs4(
|
|
993
|
+
"svg",
|
|
994
|
+
{
|
|
995
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
996
|
+
viewBox: "0 0 24 24",
|
|
997
|
+
fill: "none",
|
|
998
|
+
stroke: "currentColor",
|
|
999
|
+
strokeWidth: "2",
|
|
1000
|
+
strokeLinecap: "round",
|
|
1001
|
+
strokeLinejoin: "round",
|
|
1002
|
+
className: "rte-editor-icon",
|
|
1003
|
+
children: [
|
|
1004
|
+
/* @__PURE__ */ jsx10("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" }),
|
|
1005
|
+
/* @__PURE__ */ jsx10("polyline", { points: "15 3 21 3 21 9" }),
|
|
1006
|
+
/* @__PURE__ */ jsx10("line", { x1: "10", y1: "14", x2: "21", y2: "3" })
|
|
1007
|
+
]
|
|
1008
|
+
}
|
|
1009
|
+
);
|
|
1010
|
+
var DeleteEmbedIcon = () => /* @__PURE__ */ jsxs4(
|
|
1011
|
+
"svg",
|
|
1012
|
+
{
|
|
1013
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1014
|
+
viewBox: "0 0 24 24",
|
|
1015
|
+
fill: "none",
|
|
1016
|
+
stroke: "currentColor",
|
|
1017
|
+
strokeWidth: "2",
|
|
1018
|
+
strokeLinecap: "round",
|
|
1019
|
+
strokeLinejoin: "round",
|
|
1020
|
+
className: "rte-editor-icon",
|
|
1021
|
+
children: [
|
|
1022
|
+
/* @__PURE__ */ jsx10("polyline", { points: "3 6 5 6 21 6" }),
|
|
1023
|
+
/* @__PURE__ */ jsx10("path", { d: "M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" })
|
|
1024
|
+
]
|
|
1025
|
+
}
|
|
1026
|
+
);
|
|
1027
|
+
var iconProps = { className: "rte-editor-icon" };
|
|
1028
|
+
var LangIcon = ({
|
|
1029
|
+
children,
|
|
1030
|
+
className
|
|
1031
|
+
}) => /* @__PURE__ */ jsx10(
|
|
1032
|
+
"svg",
|
|
1033
|
+
{
|
|
1034
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1035
|
+
viewBox: "0 0 24 24",
|
|
1036
|
+
fill: "none",
|
|
1037
|
+
stroke: "currentColor",
|
|
1038
|
+
strokeWidth: 1.5,
|
|
1039
|
+
strokeLinecap: "round",
|
|
1040
|
+
strokeLinejoin: "round",
|
|
1041
|
+
className,
|
|
1042
|
+
children
|
|
1043
|
+
}
|
|
1044
|
+
);
|
|
1045
|
+
var DEFAULT_LANGUAGE_ICONS = {
|
|
1046
|
+
bash: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1047
|
+
/* @__PURE__ */ jsx10("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
|
|
1048
|
+
/* @__PURE__ */ jsx10("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
|
|
1049
|
+
/* @__PURE__ */ jsx10("path", { d: "M12 15.5h5.5" })
|
|
1050
|
+
] }),
|
|
1051
|
+
c: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1052
|
+
/* @__PURE__ */ jsx10("circle", { cx: "12", cy: "12", r: "8.5" }),
|
|
1053
|
+
/* @__PURE__ */ jsx10("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
|
|
1054
|
+
] }),
|
|
1055
|
+
cpp: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1056
|
+
/* @__PURE__ */ jsx10("circle", { cx: "9.5", cy: "12", r: "6.5" }),
|
|
1057
|
+
/* @__PURE__ */ jsx10("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
|
|
1058
|
+
/* @__PURE__ */ jsx10("path", { d: "M15.7 10.5v3M14.2 12h3" }),
|
|
1059
|
+
/* @__PURE__ */ jsx10("path", { d: "M19.3 10.5v3M17.8 12h3" })
|
|
1060
|
+
] }),
|
|
1061
|
+
css: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1062
|
+
/* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1063
|
+
/* @__PURE__ */ jsx10("path", { d: "M9.7 7.5l-1 9" }),
|
|
1064
|
+
/* @__PURE__ */ jsx10("path", { d: "M15.3 7.5l-1 9" }),
|
|
1065
|
+
/* @__PURE__ */ jsx10("path", { d: "M7 10.3h11" }),
|
|
1066
|
+
/* @__PURE__ */ jsx10("path", { d: "M6.5 14.3h11" })
|
|
1067
|
+
] }),
|
|
1068
|
+
go: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1069
|
+
/* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1070
|
+
/* @__PURE__ */ jsx10("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
|
|
1071
|
+
/* @__PURE__ */ jsx10("path", { d: "M12.6 12h-1.9" }),
|
|
1072
|
+
/* @__PURE__ */ jsx10("circle", { cx: "17", cy: "12", r: "2.9" })
|
|
1073
|
+
] }),
|
|
1074
|
+
html: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1075
|
+
/* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1076
|
+
/* @__PURE__ */ jsx10("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
|
|
1077
|
+
/* @__PURE__ */ jsx10("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
|
|
1078
|
+
/* @__PURE__ */ jsx10("path", { d: "M13 7.3l-2 9.4" })
|
|
1079
|
+
] }),
|
|
1080
|
+
java: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1081
|
+
/* @__PURE__ */ jsx10("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
|
|
1082
|
+
/* @__PURE__ */ jsx10("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
|
|
1083
|
+
/* @__PURE__ */ jsx10("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
|
|
1084
|
+
/* @__PURE__ */ jsx10("path", { d: "M6 19.3h10" })
|
|
1085
|
+
] }),
|
|
1086
|
+
javascript: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1087
|
+
/* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1088
|
+
/* @__PURE__ */ jsx10("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
|
|
1089
|
+
/* @__PURE__ */ jsx10("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1090
|
+
] }),
|
|
1091
|
+
json: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1092
|
+
/* @__PURE__ */ jsx10("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
|
|
1093
|
+
/* @__PURE__ */ jsx10("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
|
|
1094
|
+
] }),
|
|
1095
|
+
kotlin: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1096
|
+
/* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1097
|
+
/* @__PURE__ */ jsx10("path", { d: "M9 7.5v9" }),
|
|
1098
|
+
/* @__PURE__ */ jsx10("path", { d: "M9 12l6-4.5" }),
|
|
1099
|
+
/* @__PURE__ */ jsx10("path", { d: "M9 12l6 4.5" })
|
|
1100
|
+
] }),
|
|
1101
|
+
markdown: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1102
|
+
/* @__PURE__ */ jsx10("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
|
|
1103
|
+
/* @__PURE__ */ jsx10("path", { d: "M6 15V9l3 4 3-4v6" }),
|
|
1104
|
+
/* @__PURE__ */ jsx10("path", { d: "M16.5 9v6" }),
|
|
1105
|
+
/* @__PURE__ */ jsx10("path", { d: "M14.5 13l2 2 2-2" })
|
|
1106
|
+
] }),
|
|
1107
|
+
php: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1108
|
+
/* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1109
|
+
/* @__PURE__ */ jsx10("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
|
|
1110
|
+
/* @__PURE__ */ jsx10("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
|
|
1111
|
+
/* @__PURE__ */ jsx10("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
|
|
1112
|
+
] }),
|
|
1113
|
+
plaintext: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1114
|
+
/* @__PURE__ */ jsx10("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
|
|
1115
|
+
/* @__PURE__ */ jsx10("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
|
|
1116
|
+
/* @__PURE__ */ jsx10("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
|
|
1117
|
+
/* @__PURE__ */ jsx10("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
|
|
1118
|
+
] }),
|
|
1119
|
+
python: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1120
|
+
/* @__PURE__ */ jsx10("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
|
|
1121
|
+
/* @__PURE__ */ jsx10("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
|
|
1122
|
+
/* @__PURE__ */ jsx10("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
|
|
1123
|
+
/* @__PURE__ */ jsx10("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
|
|
1124
|
+
] }),
|
|
1125
|
+
ruby: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1126
|
+
/* @__PURE__ */ jsx10("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
|
|
1127
|
+
/* @__PURE__ */ jsx10("path", { d: "M4.5 8h15" }),
|
|
1128
|
+
/* @__PURE__ */ jsx10("path", { d: "M12 2.5v19" })
|
|
1129
|
+
] }),
|
|
1130
|
+
rust: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1131
|
+
/* @__PURE__ */ jsx10("circle", { cx: "12", cy: "12", r: "7" }),
|
|
1132
|
+
/* @__PURE__ */ jsx10("circle", { cx: "12", cy: "12", r: "2.3" }),
|
|
1133
|
+
/* @__PURE__ */ jsx10("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
|
|
1134
|
+
/* @__PURE__ */ jsx10("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
|
|
1135
|
+
] }),
|
|
1136
|
+
sql: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1137
|
+
/* @__PURE__ */ jsx10("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
|
|
1138
|
+
/* @__PURE__ */ jsx10("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
|
|
1139
|
+
/* @__PURE__ */ jsx10("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
|
|
1140
|
+
] }),
|
|
1141
|
+
swift: /* @__PURE__ */ jsx10(LangIcon, { children: /* @__PURE__ */ jsx10("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
|
|
1142
|
+
typescript: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1143
|
+
/* @__PURE__ */ jsx10("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1144
|
+
/* @__PURE__ */ jsx10("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
|
|
1145
|
+
/* @__PURE__ */ jsx10("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1146
|
+
] }),
|
|
1147
|
+
xml: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1148
|
+
/* @__PURE__ */ jsx10("path", { d: "M8 7l-4.5 5 4.5 5" }),
|
|
1149
|
+
/* @__PURE__ */ jsx10("path", { d: "M16 7l4.5 5-4.5 5" }),
|
|
1150
|
+
/* @__PURE__ */ jsx10("path", { d: "M12 8v8" })
|
|
1151
|
+
] }),
|
|
1152
|
+
yaml: /* @__PURE__ */ jsxs4(LangIcon, { children: [
|
|
1153
|
+
/* @__PURE__ */ jsx10("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
|
|
1154
|
+
/* @__PURE__ */ jsx10("path", { d: "M6.5 8h2M9.5 8h8" }),
|
|
1155
|
+
/* @__PURE__ */ jsx10("path", { d: "M6.5 12h2M9.5 12h6" }),
|
|
1156
|
+
/* @__PURE__ */ jsx10("path", { d: "M6.5 16h2M9.5 16h7" })
|
|
1157
|
+
] })
|
|
1158
|
+
};
|
|
1159
|
+
var DEFAULT_ICONS = {
|
|
1160
|
+
alignCenterControlIcon: /* @__PURE__ */ jsx10(TextAlignCenter, { ...iconProps }),
|
|
1161
|
+
alignJustifyControlIcon: /* @__PURE__ */ jsx10(TextAlignJustify, { ...iconProps }),
|
|
1162
|
+
alignLeftControlIcon: /* @__PURE__ */ jsx10(TextAlignStart, { ...iconProps }),
|
|
1163
|
+
alignRightControlIcon: /* @__PURE__ */ jsx10(TextAlignEnd, { ...iconProps }),
|
|
1164
|
+
blockquoteControlIcon: /* @__PURE__ */ jsx10(TextQuote, { ...iconProps }),
|
|
1165
|
+
boldControlIcon: /* @__PURE__ */ jsx10(Bold, { ...iconProps }),
|
|
1166
|
+
bulletListControlIcon: /* @__PURE__ */ jsx10(List, { ...iconProps }),
|
|
1167
|
+
clearFormattingControlIcon: /* @__PURE__ */ jsx10(RemoveFormatting, { ...iconProps }),
|
|
1168
|
+
codeBlockControlIcon: /* @__PURE__ */ jsx10(SquareCode, { ...iconProps }),
|
|
1169
|
+
codeControlIcon: /* @__PURE__ */ jsx10(Code, { ...iconProps }),
|
|
1170
|
+
h1ControlIcon: /* @__PURE__ */ jsx10(Heading1, { ...iconProps }),
|
|
1171
|
+
h2ControlIcon: /* @__PURE__ */ jsx10(Heading2, { ...iconProps }),
|
|
1172
|
+
h3ControlIcon: /* @__PURE__ */ jsx10(Heading3, { ...iconProps }),
|
|
1173
|
+
h4ControlIcon: /* @__PURE__ */ jsx10(Heading4, { ...iconProps }),
|
|
1174
|
+
h5ControlIcon: /* @__PURE__ */ jsx10(Heading5, { ...iconProps }),
|
|
1175
|
+
h6ControlIcon: /* @__PURE__ */ jsx10(Heading6, { ...iconProps }),
|
|
1176
|
+
highlightControlIcon: /* @__PURE__ */ jsx10(Highlighter, { ...iconProps }),
|
|
1177
|
+
hrControlIcon: /* @__PURE__ */ jsx10(Minus, { ...iconProps }),
|
|
1178
|
+
italicControlIcon: /* @__PURE__ */ jsx10(Italic, { ...iconProps }),
|
|
1179
|
+
languageIcons: DEFAULT_LANGUAGE_ICONS,
|
|
1180
|
+
linkControlIcon: /* @__PURE__ */ jsx10(Link, { ...iconProps }),
|
|
1181
|
+
orderedListControlIcon: /* @__PURE__ */ jsx10(ListOrdered, { ...iconProps }),
|
|
1182
|
+
redoControlIcon: /* @__PURE__ */ jsx10(Redo2, { ...iconProps }),
|
|
1183
|
+
strikeControlIcon: /* @__PURE__ */ jsx10(Strikethrough, { ...iconProps }),
|
|
1184
|
+
subscriptControlIcon: /* @__PURE__ */ jsx10(Subscript, { ...iconProps }),
|
|
1185
|
+
superscriptControlIcon: /* @__PURE__ */ jsx10(Superscript, { ...iconProps }),
|
|
1186
|
+
underlineControlIcon: /* @__PURE__ */ jsx10(Underline, { ...iconProps }),
|
|
1187
|
+
undoControlIcon: /* @__PURE__ */ jsx10(Undo2, { ...iconProps }),
|
|
1188
|
+
unlinkControlIcon: /* @__PURE__ */ jsx10(Link2Off, { ...iconProps })
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
// src/extensions/resizable-node-view.tsx
|
|
1192
|
+
import { Fragment as Fragment3, jsx as jsx11, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1193
|
+
var EmbedToolbar = ({
|
|
1194
|
+
align,
|
|
1195
|
+
videoSrc,
|
|
1196
|
+
watchUrl,
|
|
1197
|
+
deleteNode,
|
|
1198
|
+
inputRef,
|
|
1199
|
+
isEditingUrl,
|
|
1200
|
+
urlInput,
|
|
1201
|
+
setUrlInput,
|
|
1202
|
+
setIsEditingUrl,
|
|
1203
|
+
handleSaveUrl,
|
|
1204
|
+
handleApplyPreset,
|
|
1205
|
+
updateAttributes,
|
|
1206
|
+
nodeSrc
|
|
1207
|
+
}) => {
|
|
1208
|
+
if (isEditingUrl) {
|
|
1209
|
+
return /* @__PURE__ */ jsxs5("div", { className: "rte-embed-selector-edit-form", children: [
|
|
1210
|
+
/* @__PURE__ */ jsx11(
|
|
1211
|
+
"input",
|
|
1212
|
+
{
|
|
1213
|
+
ref: inputRef,
|
|
1214
|
+
type: "text",
|
|
1215
|
+
value: urlInput,
|
|
1216
|
+
onChange: (e) => setUrlInput(e.target.value),
|
|
1217
|
+
placeholder: "Paste YouTube URL or video ID...",
|
|
1218
|
+
className: "rte-embed-selector-input",
|
|
1219
|
+
onKeyDown: (e) => {
|
|
1220
|
+
if (e.key === "Enter") {
|
|
1221
|
+
handleSaveUrl();
|
|
1222
|
+
} else if (e.key === "Escape") {
|
|
1223
|
+
setIsEditingUrl(false);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
),
|
|
1228
|
+
/* @__PURE__ */ jsx11(
|
|
1229
|
+
"button",
|
|
1230
|
+
{
|
|
1231
|
+
type: "button",
|
|
1232
|
+
onClick: handleSaveUrl,
|
|
1233
|
+
className: "rte-embed-selector-btn rte-embed-selector-btn--save",
|
|
1234
|
+
children: "Save"
|
|
1235
|
+
}
|
|
1236
|
+
),
|
|
1237
|
+
/* @__PURE__ */ jsx11(
|
|
1238
|
+
"button",
|
|
1239
|
+
{
|
|
1240
|
+
type: "button",
|
|
1241
|
+
onClick: () => setIsEditingUrl(false),
|
|
1242
|
+
className: "rte-embed-selector-btn",
|
|
1243
|
+
children: "Cancel"
|
|
1244
|
+
}
|
|
1245
|
+
)
|
|
1246
|
+
] });
|
|
1247
|
+
}
|
|
1248
|
+
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
1249
|
+
/* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-group", children: ["left", "center", "right"].map((dir) => /* @__PURE__ */ jsx11(
|
|
1250
|
+
"button",
|
|
1251
|
+
{
|
|
1252
|
+
type: "button",
|
|
1253
|
+
title: `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
|
|
1254
|
+
"aria-label": `Align ${dir.charAt(0).toUpperCase()}${dir.slice(1)}`,
|
|
1255
|
+
className: `rte-embed-selector-btn ${align === dir ? "rte-embed-selector-btn--active" : ""}`,
|
|
1256
|
+
onClick: () => updateAttributes({ align: dir }),
|
|
1257
|
+
children: /* @__PURE__ */ jsx11(AlignIcon, { dir })
|
|
1258
|
+
},
|
|
1259
|
+
dir
|
|
1260
|
+
)) }),
|
|
1261
|
+
/* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-divider" }),
|
|
1262
|
+
/* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-group", children: [25, 50, 75, 100].map((pct) => /* @__PURE__ */ jsxs5(
|
|
1263
|
+
"button",
|
|
1264
|
+
{
|
|
1265
|
+
type: "button",
|
|
1266
|
+
title: `${pct}%`,
|
|
1267
|
+
className: "rte-embed-selector-btn rte-embed-selector-btn--preset",
|
|
1268
|
+
onClick: () => handleApplyPreset(pct),
|
|
1269
|
+
children: [
|
|
1270
|
+
pct,
|
|
1271
|
+
"%"
|
|
1272
|
+
]
|
|
1273
|
+
},
|
|
1274
|
+
pct
|
|
1275
|
+
)) }),
|
|
1276
|
+
/* @__PURE__ */ jsx11("div", { className: "rte-embed-selector-divider" }),
|
|
1277
|
+
/* @__PURE__ */ jsxs5("div", { className: "rte-embed-selector-group", children: [
|
|
1278
|
+
(videoSrc || nodeSrc) && /* @__PURE__ */ jsx11(
|
|
1279
|
+
"button",
|
|
1280
|
+
{
|
|
1281
|
+
type: "button",
|
|
1282
|
+
title: "Edit URL",
|
|
1283
|
+
"aria-label": "Edit URL",
|
|
1284
|
+
className: "rte-embed-selector-btn",
|
|
1285
|
+
onClick: () => {
|
|
1286
|
+
setUrlInput(videoSrc || nodeSrc || "");
|
|
1287
|
+
setIsEditingUrl(true);
|
|
1288
|
+
},
|
|
1289
|
+
children: /* @__PURE__ */ jsx11(EditUrlIcon, {})
|
|
1290
|
+
}
|
|
1291
|
+
),
|
|
1292
|
+
watchUrl && /* @__PURE__ */ jsx11(
|
|
1293
|
+
"button",
|
|
1294
|
+
{
|
|
1295
|
+
type: "button",
|
|
1296
|
+
title: "Open video in YouTube",
|
|
1297
|
+
"aria-label": "Open video in YouTube",
|
|
1298
|
+
className: "rte-embed-selector-btn",
|
|
1299
|
+
onClick: () => window.open(watchUrl, "_blank"),
|
|
1300
|
+
children: /* @__PURE__ */ jsx11(OpenInYouTubeIcon, {})
|
|
1301
|
+
}
|
|
1302
|
+
),
|
|
1303
|
+
deleteNode && /* @__PURE__ */ jsx11(
|
|
1304
|
+
"button",
|
|
1305
|
+
{
|
|
1306
|
+
type: "button",
|
|
1307
|
+
title: "Delete Embed",
|
|
1308
|
+
"aria-label": "Delete Embed",
|
|
1309
|
+
className: "rte-embed-selector-btn rte-embed-selector-btn--danger",
|
|
1310
|
+
onClick: () => deleteNode(),
|
|
1311
|
+
children: /* @__PURE__ */ jsx11(DeleteEmbedIcon, {})
|
|
1312
|
+
}
|
|
1313
|
+
)
|
|
1314
|
+
] })
|
|
1315
|
+
] });
|
|
1316
|
+
};
|
|
908
1317
|
var ResizableNodeView = ({
|
|
909
1318
|
node,
|
|
910
1319
|
selected,
|
|
911
1320
|
updateAttributes,
|
|
1321
|
+
deleteNode,
|
|
1322
|
+
editor,
|
|
912
1323
|
view,
|
|
913
1324
|
children,
|
|
914
1325
|
lockAspect = false,
|
|
915
1326
|
aspectRatio = 16 / 9,
|
|
916
1327
|
minWidth = 300,
|
|
917
|
-
maxWidth = 1200
|
|
1328
|
+
maxWidth = 1200,
|
|
1329
|
+
videoSrc,
|
|
1330
|
+
watchUrl,
|
|
1331
|
+
onSrcChange
|
|
918
1332
|
}) => {
|
|
919
1333
|
const containerRef = useRef2(null);
|
|
1334
|
+
const [isEditingUrl, setIsEditingUrl] = useState3(false);
|
|
1335
|
+
const [urlInput, setUrlInput] = useState3(videoSrc || "");
|
|
1336
|
+
const [isResizing, setIsResizing] = useState3(false);
|
|
1337
|
+
const [currentDimensions, setCurrentDimensions] = useState3(null);
|
|
920
1338
|
const resizingRef = useRef2(null);
|
|
921
1339
|
const width = node.attrs.width;
|
|
922
1340
|
const height = node.attrs.height;
|
|
923
1341
|
const align = node.attrs.align || "center";
|
|
924
1342
|
const getEditorWidth = useCallback5(
|
|
925
|
-
() => view?.dom?.parentElement?.offsetWidth ??
|
|
1343
|
+
() => view?.dom?.parentElement?.offsetWidth ?? 800,
|
|
926
1344
|
[view]
|
|
927
1345
|
);
|
|
1346
|
+
const inputRef = useRef2(null);
|
|
1347
|
+
useEffect3(() => {
|
|
1348
|
+
if (isEditingUrl) {
|
|
1349
|
+
inputRef.current?.focus();
|
|
1350
|
+
}
|
|
1351
|
+
}, [isEditingUrl]);
|
|
928
1352
|
const handleMouseMove = useCallback5(
|
|
929
1353
|
(e) => {
|
|
930
1354
|
const resize = resizingRef.current;
|
|
@@ -934,7 +1358,7 @@ var ResizableNodeView = ({
|
|
|
934
1358
|
const effectiveMax = Math.min(maxWidth, resize.editorWidth);
|
|
935
1359
|
let newWidth = resize.startWidth;
|
|
936
1360
|
let newHeight = resize.startHeight;
|
|
937
|
-
if (resize.direction === "right" || resize.direction === "corner") {
|
|
1361
|
+
if (resize.direction === "right" || resize.direction === "corner-br") {
|
|
938
1362
|
newWidth = Math.max(
|
|
939
1363
|
minWidth,
|
|
940
1364
|
Math.min(
|
|
@@ -942,8 +1366,16 @@ var ResizableNodeView = ({
|
|
|
942
1366
|
resize.startWidth + (e.clientX - resize.startX)
|
|
943
1367
|
)
|
|
944
1368
|
);
|
|
1369
|
+
} else if (resize.direction === "left" || resize.direction === "corner-bl") {
|
|
1370
|
+
newWidth = Math.max(
|
|
1371
|
+
minWidth,
|
|
1372
|
+
Math.min(
|
|
1373
|
+
effectiveMax,
|
|
1374
|
+
resize.startWidth - (e.clientX - resize.startX)
|
|
1375
|
+
)
|
|
1376
|
+
);
|
|
945
1377
|
}
|
|
946
|
-
if (resize.direction === "bottom" || resize.direction === "corner") {
|
|
1378
|
+
if (resize.direction === "bottom" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
|
|
947
1379
|
newHeight = Math.max(
|
|
948
1380
|
Math.round(minWidth / aspectRatio),
|
|
949
1381
|
Math.min(
|
|
@@ -953,7 +1385,7 @@ var ResizableNodeView = ({
|
|
|
953
1385
|
);
|
|
954
1386
|
}
|
|
955
1387
|
if (lockAspect) {
|
|
956
|
-
if (resize.direction === "right" || resize.direction === "corner") {
|
|
1388
|
+
if (resize.direction === "left" || resize.direction === "right" || resize.direction === "corner-br" || resize.direction === "corner-bl") {
|
|
957
1389
|
newHeight = Math.round(newWidth / aspectRatio);
|
|
958
1390
|
} else {
|
|
959
1391
|
newWidth = Math.round(newHeight * aspectRatio);
|
|
@@ -963,6 +1395,7 @@ var ResizableNodeView = ({
|
|
|
963
1395
|
containerRef.current.style.width = `${newWidth}px`;
|
|
964
1396
|
containerRef.current.style.height = `${newHeight}px`;
|
|
965
1397
|
}
|
|
1398
|
+
setCurrentDimensions({ h: newHeight, w: newWidth });
|
|
966
1399
|
},
|
|
967
1400
|
[lockAspect, aspectRatio, minWidth, maxWidth]
|
|
968
1401
|
);
|
|
@@ -982,6 +1415,8 @@ var ResizableNodeView = ({
|
|
|
982
1415
|
updateAttributes({ height: h, width: w });
|
|
983
1416
|
}
|
|
984
1417
|
resizingRef.current = null;
|
|
1418
|
+
setIsResizing(false);
|
|
1419
|
+
setCurrentDimensions(null);
|
|
985
1420
|
},
|
|
986
1421
|
[handleMouseMove, updateAttributes]
|
|
987
1422
|
);
|
|
@@ -1000,20 +1435,23 @@ var ResizableNodeView = ({
|
|
|
1000
1435
|
startX: e.clientX,
|
|
1001
1436
|
startY: e.clientY
|
|
1002
1437
|
};
|
|
1438
|
+
setIsResizing(true);
|
|
1439
|
+
setCurrentDimensions({ h: startHeight, w: startWidth });
|
|
1003
1440
|
document.addEventListener("mousemove", handleMouseMove);
|
|
1004
1441
|
document.addEventListener("mouseup", handleMouseUp);
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1442
|
+
const cursors = {
|
|
1443
|
+
bottom: "ns-resize",
|
|
1444
|
+
"corner-bl": "nesw-resize",
|
|
1445
|
+
"corner-br": "nwse-resize",
|
|
1446
|
+
left: "ew-resize",
|
|
1447
|
+
right: "ew-resize"
|
|
1448
|
+
};
|
|
1449
|
+
document.body.style.cursor = cursors[direction];
|
|
1012
1450
|
document.body.style.userSelect = "none";
|
|
1013
1451
|
},
|
|
1014
1452
|
[width, height, getEditorWidth, handleMouseMove, handleMouseUp]
|
|
1015
1453
|
);
|
|
1016
|
-
|
|
1454
|
+
useEffect3(
|
|
1017
1455
|
() => () => {
|
|
1018
1456
|
document.removeEventListener("mousemove", handleMouseMove);
|
|
1019
1457
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
@@ -1022,13 +1460,32 @@ var ResizableNodeView = ({
|
|
|
1022
1460
|
},
|
|
1023
1461
|
[handleMouseMove, handleMouseUp]
|
|
1024
1462
|
);
|
|
1025
|
-
|
|
1463
|
+
const handleApplyPreset = (percent) => {
|
|
1464
|
+
const editorW = getEditorWidth() || 800;
|
|
1465
|
+
const targetW = Math.round(
|
|
1466
|
+
Math.max(minWidth, Math.min(maxWidth, editorW * percent / 100))
|
|
1467
|
+
);
|
|
1468
|
+
updateAttributes({
|
|
1469
|
+
height: Math.round(targetW / aspectRatio),
|
|
1470
|
+
width: targetW
|
|
1471
|
+
});
|
|
1472
|
+
};
|
|
1473
|
+
const handleSaveUrl = () => {
|
|
1474
|
+
if (urlInput && onSrcChange) {
|
|
1475
|
+
onSrcChange(urlInput);
|
|
1476
|
+
} else if (urlInput) {
|
|
1477
|
+
updateAttributes({ src: urlInput });
|
|
1478
|
+
}
|
|
1479
|
+
setIsEditingUrl(false);
|
|
1480
|
+
};
|
|
1481
|
+
const isEditable = editor ? editor.isEditable : true;
|
|
1482
|
+
return /* @__PURE__ */ jsx11(
|
|
1026
1483
|
NodeViewWrapper,
|
|
1027
1484
|
{
|
|
1028
1485
|
className: "rte-embed-wrapper",
|
|
1029
1486
|
"data-selected": selected || void 0,
|
|
1030
1487
|
"data-align": align,
|
|
1031
|
-
children: /* @__PURE__ */
|
|
1488
|
+
children: /* @__PURE__ */ jsxs5(
|
|
1032
1489
|
"div",
|
|
1033
1490
|
{
|
|
1034
1491
|
ref: containerRef,
|
|
@@ -1041,8 +1498,40 @@ var ResizableNodeView = ({
|
|
|
1041
1498
|
},
|
|
1042
1499
|
children: [
|
|
1043
1500
|
children,
|
|
1044
|
-
selected && /* @__PURE__ */
|
|
1045
|
-
|
|
1501
|
+
selected && isEditable && /* @__PURE__ */ jsx11("div", { className: "rte-embed-selector", contentEditable: false, children: /* @__PURE__ */ jsx11(
|
|
1502
|
+
EmbedToolbar,
|
|
1503
|
+
{
|
|
1504
|
+
align,
|
|
1505
|
+
videoSrc,
|
|
1506
|
+
watchUrl,
|
|
1507
|
+
deleteNode,
|
|
1508
|
+
inputRef,
|
|
1509
|
+
isEditingUrl,
|
|
1510
|
+
urlInput,
|
|
1511
|
+
setUrlInput,
|
|
1512
|
+
setIsEditingUrl,
|
|
1513
|
+
handleSaveUrl,
|
|
1514
|
+
handleApplyPreset,
|
|
1515
|
+
updateAttributes,
|
|
1516
|
+
nodeSrc: node.attrs.src
|
|
1517
|
+
}
|
|
1518
|
+
) }),
|
|
1519
|
+
isResizing && currentDimensions && /* @__PURE__ */ jsxs5("div", { className: "rte-embed-resize-badge", children: [
|
|
1520
|
+
currentDimensions.w,
|
|
1521
|
+
" \xD7 ",
|
|
1522
|
+
currentDimensions.h,
|
|
1523
|
+
" px"
|
|
1524
|
+
] }),
|
|
1525
|
+
selected && isEditable && /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
1526
|
+
/* @__PURE__ */ jsx11(
|
|
1527
|
+
"div",
|
|
1528
|
+
{
|
|
1529
|
+
className: "rte-resize-handle rte-resize-handle--left",
|
|
1530
|
+
onMouseDown: (e) => handleMouseDown(e, "left"),
|
|
1531
|
+
role: "presentation"
|
|
1532
|
+
}
|
|
1533
|
+
),
|
|
1534
|
+
/* @__PURE__ */ jsx11(
|
|
1046
1535
|
"div",
|
|
1047
1536
|
{
|
|
1048
1537
|
className: "rte-resize-handle rte-resize-handle--right",
|
|
@@ -1050,7 +1539,7 @@ var ResizableNodeView = ({
|
|
|
1050
1539
|
role: "presentation"
|
|
1051
1540
|
}
|
|
1052
1541
|
),
|
|
1053
|
-
/* @__PURE__ */
|
|
1542
|
+
/* @__PURE__ */ jsx11(
|
|
1054
1543
|
"div",
|
|
1055
1544
|
{
|
|
1056
1545
|
className: "rte-resize-handle rte-resize-handle--bottom",
|
|
@@ -1058,11 +1547,19 @@ var ResizableNodeView = ({
|
|
|
1058
1547
|
role: "presentation"
|
|
1059
1548
|
}
|
|
1060
1549
|
),
|
|
1061
|
-
/* @__PURE__ */
|
|
1550
|
+
/* @__PURE__ */ jsx11(
|
|
1062
1551
|
"div",
|
|
1063
1552
|
{
|
|
1064
|
-
className: "rte-resize-handle rte-resize-handle--corner",
|
|
1065
|
-
onMouseDown: (e) => handleMouseDown(e, "corner"),
|
|
1553
|
+
className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-bl",
|
|
1554
|
+
onMouseDown: (e) => handleMouseDown(e, "corner-bl"),
|
|
1555
|
+
role: "presentation"
|
|
1556
|
+
}
|
|
1557
|
+
),
|
|
1558
|
+
/* @__PURE__ */ jsx11(
|
|
1559
|
+
"div",
|
|
1560
|
+
{
|
|
1561
|
+
className: "rte-resize-handle rte-resize-handle--corner rte-resize-handle--corner-br",
|
|
1562
|
+
onMouseDown: (e) => handleMouseDown(e, "corner-br"),
|
|
1066
1563
|
role: "presentation"
|
|
1067
1564
|
}
|
|
1068
1565
|
)
|
|
@@ -1077,15 +1574,15 @@ var ResizableNodeView = ({
|
|
|
1077
1574
|
// src/ui/dialog.tsx
|
|
1078
1575
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
1079
1576
|
import "react";
|
|
1080
|
-
import { jsx as
|
|
1081
|
-
var Dialog = ({ ...props }) => /* @__PURE__ */
|
|
1082
|
-
var DialogTrigger = ({ ...props }) => /* @__PURE__ */
|
|
1083
|
-
var DialogPortal = ({ ...props }) => /* @__PURE__ */
|
|
1084
|
-
var DialogClose = ({ ...props }) => /* @__PURE__ */
|
|
1577
|
+
import { jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1578
|
+
var Dialog = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
1579
|
+
var DialogTrigger = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
|
|
1580
|
+
var DialogPortal = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
|
|
1581
|
+
var DialogClose = ({ ...props }) => /* @__PURE__ */ jsx12(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
|
|
1085
1582
|
var DialogOverlay = ({
|
|
1086
1583
|
className,
|
|
1087
1584
|
...props
|
|
1088
|
-
}) => /* @__PURE__ */
|
|
1585
|
+
}) => /* @__PURE__ */ jsx12(
|
|
1089
1586
|
DialogPrimitive.Backdrop,
|
|
1090
1587
|
{
|
|
1091
1588
|
"data-slot": "dialog-overlay",
|
|
@@ -1101,9 +1598,9 @@ var DialogContent = ({
|
|
|
1101
1598
|
children,
|
|
1102
1599
|
showCloseButton = true,
|
|
1103
1600
|
...props
|
|
1104
|
-
}) => /* @__PURE__ */
|
|
1105
|
-
/* @__PURE__ */
|
|
1106
|
-
/* @__PURE__ */
|
|
1601
|
+
}) => /* @__PURE__ */ jsxs6(DialogPortal, { children: [
|
|
1602
|
+
/* @__PURE__ */ jsx12(DialogOverlay, {}),
|
|
1603
|
+
/* @__PURE__ */ jsxs6(
|
|
1107
1604
|
DialogPrimitive.Popup,
|
|
1108
1605
|
{
|
|
1109
1606
|
"data-slot": "dialog-content",
|
|
@@ -1114,11 +1611,11 @@ var DialogContent = ({
|
|
|
1114
1611
|
...props,
|
|
1115
1612
|
children: [
|
|
1116
1613
|
children,
|
|
1117
|
-
showCloseButton && /* @__PURE__ */
|
|
1614
|
+
showCloseButton && /* @__PURE__ */ jsxs6(
|
|
1118
1615
|
DialogPrimitive.Close,
|
|
1119
1616
|
{
|
|
1120
1617
|
"data-slot": "dialog-close",
|
|
1121
|
-
render: /* @__PURE__ */
|
|
1618
|
+
render: /* @__PURE__ */ jsx12(
|
|
1122
1619
|
Button,
|
|
1123
1620
|
{
|
|
1124
1621
|
variant: "ghost",
|
|
@@ -1128,7 +1625,7 @@ var DialogContent = ({
|
|
|
1128
1625
|
),
|
|
1129
1626
|
children: [
|
|
1130
1627
|
"X",
|
|
1131
|
-
/* @__PURE__ */
|
|
1628
|
+
/* @__PURE__ */ jsx12("span", { className: "sr-only", children: "Close" })
|
|
1132
1629
|
]
|
|
1133
1630
|
}
|
|
1134
1631
|
)
|
|
@@ -1136,7 +1633,7 @@ var DialogContent = ({
|
|
|
1136
1633
|
}
|
|
1137
1634
|
)
|
|
1138
1635
|
] });
|
|
1139
|
-
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */
|
|
1636
|
+
var DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx12(
|
|
1140
1637
|
"div",
|
|
1141
1638
|
{
|
|
1142
1639
|
"data-slot": "dialog-header",
|
|
@@ -1149,7 +1646,7 @@ var DialogFooter = ({
|
|
|
1149
1646
|
showCloseButton = false,
|
|
1150
1647
|
children,
|
|
1151
1648
|
...props
|
|
1152
|
-
}) => /* @__PURE__ */
|
|
1649
|
+
}) => /* @__PURE__ */ jsxs6(
|
|
1153
1650
|
"div",
|
|
1154
1651
|
{
|
|
1155
1652
|
"data-slot": "dialog-footer",
|
|
@@ -1160,11 +1657,11 @@ var DialogFooter = ({
|
|
|
1160
1657
|
...props,
|
|
1161
1658
|
children: [
|
|
1162
1659
|
children,
|
|
1163
|
-
showCloseButton && /* @__PURE__ */
|
|
1660
|
+
showCloseButton && /* @__PURE__ */ jsx12(DialogPrimitive.Close, { render: /* @__PURE__ */ jsx12(Button, { variant: "outline" }), children: "Close" })
|
|
1164
1661
|
]
|
|
1165
1662
|
}
|
|
1166
1663
|
);
|
|
1167
|
-
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */
|
|
1664
|
+
var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx12(
|
|
1168
1665
|
DialogPrimitive.Title,
|
|
1169
1666
|
{
|
|
1170
1667
|
"data-slot": "dialog-title",
|
|
@@ -1175,7 +1672,7 @@ var DialogTitle = ({ className, ...props }) => /* @__PURE__ */ jsx11(
|
|
|
1175
1672
|
var DialogDescription = ({
|
|
1176
1673
|
className,
|
|
1177
1674
|
...props
|
|
1178
|
-
}) => /* @__PURE__ */
|
|
1675
|
+
}) => /* @__PURE__ */ jsx12(
|
|
1179
1676
|
DialogPrimitive.Description,
|
|
1180
1677
|
{
|
|
1181
1678
|
"data-slot": "dialog-description",
|
|
@@ -1188,56 +1685,149 @@ var DialogDescription = ({
|
|
|
1188
1685
|
);
|
|
1189
1686
|
|
|
1190
1687
|
// src/controls/rte-twitter-control.tsx
|
|
1191
|
-
import { jsx as
|
|
1688
|
+
import { jsx as jsx13, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1192
1689
|
var WIDGET_SCRIPT_URL = "https://platform.twitter.com/widgets.js";
|
|
1690
|
+
var SCRIPT_LOAD_TIMEOUT_MS = 8e3;
|
|
1691
|
+
var READY_POLL_INTERVAL_MS = 50;
|
|
1692
|
+
var twitterScriptPromise = null;
|
|
1693
|
+
var loadTwitterScript = () => {
|
|
1694
|
+
if (typeof window === "undefined") {
|
|
1695
|
+
return Promise.resolve();
|
|
1696
|
+
}
|
|
1697
|
+
if (window.twttr?.widgets) {
|
|
1698
|
+
return Promise.resolve();
|
|
1699
|
+
}
|
|
1700
|
+
if (twitterScriptPromise) {
|
|
1701
|
+
return twitterScriptPromise;
|
|
1702
|
+
}
|
|
1703
|
+
twitterScriptPromise = new Promise((resolve, reject) => {
|
|
1704
|
+
let script = document.querySelector(
|
|
1705
|
+
`script[src="${WIDGET_SCRIPT_URL}"]`
|
|
1706
|
+
);
|
|
1707
|
+
const isNewScript = !script;
|
|
1708
|
+
if (!script) {
|
|
1709
|
+
script = document.createElement("script");
|
|
1710
|
+
script.src = WIDGET_SCRIPT_URL;
|
|
1711
|
+
script.async = true;
|
|
1712
|
+
document.body.append(script);
|
|
1713
|
+
}
|
|
1714
|
+
let settled = false;
|
|
1715
|
+
const cleanup = () => {
|
|
1716
|
+
clearInterval(pollId);
|
|
1717
|
+
clearTimeout(timeoutId);
|
|
1718
|
+
};
|
|
1719
|
+
const succeed = () => {
|
|
1720
|
+
if (settled) return;
|
|
1721
|
+
settled = true;
|
|
1722
|
+
cleanup();
|
|
1723
|
+
resolve();
|
|
1724
|
+
};
|
|
1725
|
+
const fail = () => {
|
|
1726
|
+
if (settled) return;
|
|
1727
|
+
settled = true;
|
|
1728
|
+
cleanup();
|
|
1729
|
+
twitterScriptPromise = null;
|
|
1730
|
+
reject(new Error("Failed to load Twitter widgets script"));
|
|
1731
|
+
};
|
|
1732
|
+
if (window.twttr?.widgets) {
|
|
1733
|
+
succeed();
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const pollId = setInterval(() => {
|
|
1737
|
+
if (window.twttr?.widgets) {
|
|
1738
|
+
succeed();
|
|
1739
|
+
}
|
|
1740
|
+
}, READY_POLL_INTERVAL_MS);
|
|
1741
|
+
const timeoutId = setTimeout(fail, SCRIPT_LOAD_TIMEOUT_MS);
|
|
1742
|
+
if (isNewScript) {
|
|
1743
|
+
script.addEventListener(
|
|
1744
|
+
"load",
|
|
1745
|
+
() => {
|
|
1746
|
+
if (window.twttr?.widgets) {
|
|
1747
|
+
succeed();
|
|
1748
|
+
}
|
|
1749
|
+
},
|
|
1750
|
+
{ once: true }
|
|
1751
|
+
);
|
|
1752
|
+
}
|
|
1753
|
+
script.addEventListener("error", fail, { once: true });
|
|
1754
|
+
});
|
|
1755
|
+
return twitterScriptPromise;
|
|
1756
|
+
};
|
|
1193
1757
|
var TwitterNodeView = (props) => {
|
|
1194
1758
|
const { node } = props;
|
|
1195
1759
|
const containerRef = useRef3(null);
|
|
1196
|
-
const [loading, setLoading] =
|
|
1760
|
+
const [loading, setLoading] = useState4(true);
|
|
1761
|
+
const [failed, setFailed] = useState4(false);
|
|
1197
1762
|
const { tweetId } = node.attrs;
|
|
1198
|
-
const
|
|
1199
|
-
const
|
|
1200
|
-
const
|
|
1763
|
+
const renderedTweetIdRef = useRef3(null);
|
|
1764
|
+
const activeRenderIdRef = useRef3(0);
|
|
1765
|
+
const retryToken = useRef3(0);
|
|
1766
|
+
const [retryCount, setRetryCount] = useState4(0);
|
|
1767
|
+
useEffect4(() => {
|
|
1201
1768
|
if (!containerRef.current || !tweetId) {
|
|
1202
1769
|
return;
|
|
1203
1770
|
}
|
|
1204
|
-
containerRef.current.
|
|
1205
|
-
|
|
1206
|
-
const { twttr } = window;
|
|
1207
|
-
if (twttr?.widgets && containerRef.current) {
|
|
1208
|
-
try {
|
|
1209
|
-
await twttr.widgets.createTweet(tweetId, containerRef.current);
|
|
1210
|
-
setLoading(false);
|
|
1211
|
-
} catch {
|
|
1212
|
-
}
|
|
1213
|
-
}
|
|
1214
|
-
}, [tweetId]);
|
|
1215
|
-
useEffect3(() => {
|
|
1216
|
-
if (!containerRef.current || !tweetId) {
|
|
1771
|
+
if (renderedTweetIdRef.current === tweetId && containerRef.current.children.length > 0 && !failed) {
|
|
1772
|
+
setLoading(false);
|
|
1217
1773
|
return;
|
|
1218
1774
|
}
|
|
1219
|
-
|
|
1220
|
-
|
|
1775
|
+
let isCancelled = false;
|
|
1776
|
+
activeRenderIdRef.current += 1;
|
|
1777
|
+
const renderId = activeRenderIdRef.current;
|
|
1778
|
+
setLoading(true);
|
|
1779
|
+
setFailed(false);
|
|
1780
|
+
const render = async () => {
|
|
1781
|
+
try {
|
|
1782
|
+
await loadTwitterScript();
|
|
1783
|
+
if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
|
|
1784
|
+
return;
|
|
1785
|
+
}
|
|
1786
|
+
const { twttr } = window;
|
|
1787
|
+
if (!twttr?.widgets) {
|
|
1788
|
+
throw new Error("Twitter widgets script unavailable");
|
|
1789
|
+
}
|
|
1221
1790
|
containerRef.current.innerHTML = "";
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1791
|
+
const el = await twttr.widgets.createTweet(
|
|
1792
|
+
tweetId,
|
|
1793
|
+
containerRef.current
|
|
1794
|
+
);
|
|
1795
|
+
if (isCancelled || renderId !== activeRenderIdRef.current || !containerRef.current) {
|
|
1796
|
+
if (el && typeof el.remove === "function") {
|
|
1797
|
+
el.remove();
|
|
1798
|
+
} else if (containerRef.current) {
|
|
1799
|
+
containerRef.current.innerHTML = "";
|
|
1800
|
+
}
|
|
1801
|
+
return;
|
|
1802
|
+
}
|
|
1803
|
+
if (!el) {
|
|
1804
|
+
throw new Error("Tweet could not be embedded");
|
|
1805
|
+
}
|
|
1806
|
+
while (containerRef.current.children.length > 1) {
|
|
1807
|
+
containerRef.current.firstElementChild?.remove();
|
|
1808
|
+
}
|
|
1809
|
+
renderedTweetIdRef.current = tweetId;
|
|
1810
|
+
} catch {
|
|
1811
|
+
if (!isCancelled && renderId === activeRenderIdRef.current) {
|
|
1812
|
+
setFailed(true);
|
|
1813
|
+
renderedTweetIdRef.current = null;
|
|
1814
|
+
}
|
|
1815
|
+
} finally {
|
|
1816
|
+
if (!isCancelled && renderId === activeRenderIdRef.current) {
|
|
1225
1817
|
setLoading(false);
|
|
1226
|
-
} catch {
|
|
1227
1818
|
}
|
|
1228
|
-
} else {
|
|
1229
|
-
const script = document.createElement("script");
|
|
1230
|
-
script.src = WIDGET_SCRIPT_URL;
|
|
1231
|
-
script.async = true;
|
|
1232
|
-
script.addEventListener("load", () => {
|
|
1233
|
-
void renderTweet();
|
|
1234
|
-
});
|
|
1235
|
-
document.body.append(script);
|
|
1236
1819
|
}
|
|
1237
1820
|
};
|
|
1238
|
-
void
|
|
1239
|
-
|
|
1240
|
-
|
|
1821
|
+
void render();
|
|
1822
|
+
return () => {
|
|
1823
|
+
isCancelled = true;
|
|
1824
|
+
};
|
|
1825
|
+
}, [tweetId, retryCount, failed]);
|
|
1826
|
+
const handleRetry = useCallback6(() => {
|
|
1827
|
+
retryToken.current += 1;
|
|
1828
|
+
setRetryCount(retryToken.current);
|
|
1829
|
+
}, []);
|
|
1830
|
+
return /* @__PURE__ */ jsxs7(
|
|
1241
1831
|
ResizableNodeView,
|
|
1242
1832
|
{
|
|
1243
1833
|
...props,
|
|
@@ -1245,8 +1835,12 @@ var TwitterNodeView = (props) => {
|
|
|
1245
1835
|
minWidth: 300,
|
|
1246
1836
|
maxWidth: 1200,
|
|
1247
1837
|
children: [
|
|
1248
|
-
loading && /* @__PURE__ */
|
|
1249
|
-
/* @__PURE__ */
|
|
1838
|
+
loading && /* @__PURE__ */ jsx13("div", { className: "rte-embed-loading", children: "Loading tweet..." }),
|
|
1839
|
+
!loading && failed && /* @__PURE__ */ jsxs7("div", { className: "rte-embed-error", children: [
|
|
1840
|
+
/* @__PURE__ */ jsx13("p", { children: "Couldn't load this tweet." }),
|
|
1841
|
+
/* @__PURE__ */ jsx13("button", { type: "button", onClick: handleRetry, children: "Retry" })
|
|
1842
|
+
] }),
|
|
1843
|
+
/* @__PURE__ */ jsx13("div", { ref: containerRef })
|
|
1250
1844
|
]
|
|
1251
1845
|
}
|
|
1252
1846
|
);
|
|
@@ -1336,88 +1930,119 @@ var extractTweetId = (input) => {
|
|
|
1336
1930
|
};
|
|
1337
1931
|
var TwitterEmbedControl = ({ className }) => {
|
|
1338
1932
|
const { editor } = useRichTextEditorContext();
|
|
1339
|
-
const [open, setOpen] =
|
|
1340
|
-
const [url, setUrl] =
|
|
1933
|
+
const [open, setOpen] = useState4(false);
|
|
1934
|
+
const [url, setUrl] = useState4("");
|
|
1935
|
+
const [touched, setTouched] = useState4(false);
|
|
1341
1936
|
const { active } = useEditorState4({
|
|
1342
1937
|
editor: editor ?? null,
|
|
1343
1938
|
selector: (ctx) => ({
|
|
1344
1939
|
active: ctx.editor && !ctx.editor.isDestroyed ? ctx.editor.isActive("twitter") : false
|
|
1345
1940
|
})
|
|
1346
1941
|
}) ?? { active: false };
|
|
1942
|
+
const tweetId = url ? extractTweetId(url) : null;
|
|
1943
|
+
const showError = touched && url.length > 0 && !tweetId;
|
|
1944
|
+
const resetState = useCallback6(() => {
|
|
1945
|
+
setUrl("");
|
|
1946
|
+
setTouched(false);
|
|
1947
|
+
}, []);
|
|
1347
1948
|
const handleInsert = useCallback6(() => {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
editor.chain().focus().setTwitterEmbed(tweetId).run();
|
|
1352
|
-
setUrl("");
|
|
1353
|
-
}
|
|
1949
|
+
setTouched(true);
|
|
1950
|
+
if (!tweetId || !editor) {
|
|
1951
|
+
return false;
|
|
1354
1952
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1953
|
+
editor.chain().focus().setTwitterEmbed(tweetId).run();
|
|
1954
|
+
resetState();
|
|
1955
|
+
return true;
|
|
1956
|
+
}, [tweetId, editor, resetState]);
|
|
1957
|
+
return /* @__PURE__ */ jsxs7(
|
|
1958
|
+
Dialog,
|
|
1959
|
+
{
|
|
1960
|
+
open,
|
|
1961
|
+
onOpenChange: (next) => {
|
|
1962
|
+
setOpen(next);
|
|
1963
|
+
if (!next) {
|
|
1964
|
+
resetState();
|
|
1965
|
+
}
|
|
1966
|
+
},
|
|
1967
|
+
children: [
|
|
1968
|
+
/* @__PURE__ */ jsx13(
|
|
1969
|
+
DialogTrigger,
|
|
1362
1970
|
{
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
title: "Embed Tweet",
|
|
1366
|
-
"aria-label": "Embed Tweet",
|
|
1367
|
-
children: /* @__PURE__ */ jsx12(
|
|
1368
|
-
"svg",
|
|
1971
|
+
render: /* @__PURE__ */ jsx13(
|
|
1972
|
+
RichTextEditorControl,
|
|
1369
1973
|
{
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
children: /* @__PURE__ */
|
|
1974
|
+
active,
|
|
1975
|
+
className,
|
|
1976
|
+
title: "Embed Tweet",
|
|
1977
|
+
"aria-label": "Embed Tweet",
|
|
1978
|
+
children: /* @__PURE__ */ jsx13(
|
|
1979
|
+
"svg",
|
|
1980
|
+
{
|
|
1981
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1982
|
+
viewBox: "0 0 24 24",
|
|
1983
|
+
fill: "currentColor",
|
|
1984
|
+
className: "rte-editor-icon",
|
|
1985
|
+
children: /* @__PURE__ */ jsx13("path", { d: "M18.2 3.2h3.3l-7.2 8.2 8.5 11.2h-6.6l-5.2-6.8-6 6.8H2.7l7.7-8.8L2.3 3.2h6.8l4.7 6.2 5.4-6.2zm-1.2 17.3h1.8L7 4.8H5.1l11.9 15.7z" })
|
|
1986
|
+
}
|
|
1987
|
+
)
|
|
1375
1988
|
}
|
|
1376
1989
|
)
|
|
1377
1990
|
}
|
|
1378
|
-
)
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1991
|
+
),
|
|
1992
|
+
/* @__PURE__ */ jsxs7(DialogContent, { children: [
|
|
1993
|
+
/* @__PURE__ */ jsxs7(DialogHeader, { children: [
|
|
1994
|
+
/* @__PURE__ */ jsx13(DialogTitle, { children: "Embed Tweet" }),
|
|
1995
|
+
/* @__PURE__ */ jsx13(DialogDescription, { children: "Paste a tweet URL or ID." })
|
|
1996
|
+
] }),
|
|
1997
|
+
/* @__PURE__ */ jsx13(
|
|
1998
|
+
Input,
|
|
1999
|
+
{
|
|
2000
|
+
value: url,
|
|
2001
|
+
onChange: (e) => {
|
|
2002
|
+
setUrl(e.target.value);
|
|
2003
|
+
if (touched) setTouched(false);
|
|
2004
|
+
},
|
|
2005
|
+
onBlur: () => setTouched(true),
|
|
2006
|
+
placeholder: "https://x.com/user/status/...",
|
|
2007
|
+
"aria-invalid": showError,
|
|
2008
|
+
onKeyDown: (e) => {
|
|
2009
|
+
if (e.key === "Enter" && url) {
|
|
2010
|
+
if (handleInsert()) {
|
|
2011
|
+
setOpen(false);
|
|
2012
|
+
}
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
1396
2015
|
}
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
2016
|
+
),
|
|
2017
|
+
showError && /* @__PURE__ */ jsx13("p", { className: "rte-input-error", role: "alert", children: "That doesn't look like a valid tweet URL or ID." }),
|
|
2018
|
+
/* @__PURE__ */ jsxs7(DialogFooter, { children: [
|
|
2019
|
+
/* @__PURE__ */ jsx13(DialogClose, { children: "Cancel" }),
|
|
2020
|
+
/* @__PURE__ */ jsx13(
|
|
2021
|
+
"button",
|
|
2022
|
+
{
|
|
2023
|
+
type: "button",
|
|
2024
|
+
disabled: !url,
|
|
2025
|
+
className: "rounded-md bg-primary px-3 py-1.5 text-sm text-primary-foreground transition-opacity hover:opacity-90 disabled:opacity-50",
|
|
2026
|
+
onClick: () => {
|
|
2027
|
+
if (handleInsert()) {
|
|
2028
|
+
setOpen(false);
|
|
2029
|
+
}
|
|
2030
|
+
},
|
|
2031
|
+
children: "Insert"
|
|
2032
|
+
}
|
|
2033
|
+
)
|
|
2034
|
+
] })
|
|
2035
|
+
] })
|
|
2036
|
+
]
|
|
2037
|
+
}
|
|
2038
|
+
);
|
|
1414
2039
|
};
|
|
1415
2040
|
|
|
1416
2041
|
// src/controls/rte-youtube-control.tsx
|
|
1417
2042
|
import { Node as Node2, nodeInputRule as nodeInputRule2 } from "@tiptap/core";
|
|
1418
2043
|
import { ReactNodeViewRenderer as ReactNodeViewRenderer2, useEditorState as useEditorState5 } from "@tiptap/react";
|
|
1419
|
-
import { useState as
|
|
1420
|
-
import { jsx as
|
|
2044
|
+
import { useState as useState5, useCallback as useCallback7 } from "react";
|
|
2045
|
+
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1421
2046
|
var getYouTubeId = (url) => {
|
|
1422
2047
|
const clean = url.trim();
|
|
1423
2048
|
const patterns = [
|
|
@@ -1438,9 +2063,14 @@ var getYouTubeId = (url) => {
|
|
|
1438
2063
|
return /^[a-zA-Z0-9_-]{11}$/.test(clean) ? clean : null;
|
|
1439
2064
|
};
|
|
1440
2065
|
var YouTubeNodeView = (props) => {
|
|
1441
|
-
const { node } = props;
|
|
1442
|
-
const
|
|
1443
|
-
|
|
2066
|
+
const { node, updateAttributes } = props;
|
|
2067
|
+
const rawSrc = node.attrs.src || "";
|
|
2068
|
+
const videoId = getYouTubeId(rawSrc) || rawSrc;
|
|
2069
|
+
let watchUrl;
|
|
2070
|
+
if (videoId) {
|
|
2071
|
+
watchUrl = videoId.startsWith("http") ? videoId : `https://www.youtube.com/watch?v=${videoId}`;
|
|
2072
|
+
}
|
|
2073
|
+
return /* @__PURE__ */ jsx14(
|
|
1444
2074
|
ResizableNodeView,
|
|
1445
2075
|
{
|
|
1446
2076
|
...props,
|
|
@@ -1448,7 +2078,10 @@ var YouTubeNodeView = (props) => {
|
|
|
1448
2078
|
aspectRatio: 16 / 9,
|
|
1449
2079
|
minWidth: 320,
|
|
1450
2080
|
maxWidth: 1200,
|
|
1451
|
-
|
|
2081
|
+
videoSrc: rawSrc,
|
|
2082
|
+
watchUrl,
|
|
2083
|
+
onSrcChange: (newSrc) => updateAttributes({ src: newSrc }),
|
|
2084
|
+
children: /* @__PURE__ */ jsx14(
|
|
1452
2085
|
"iframe",
|
|
1453
2086
|
{
|
|
1454
2087
|
src: `https://www.youtube-nocookie.com/embed/${videoId}`,
|
|
@@ -1536,8 +2169,8 @@ var YouTubeEmbed = Node2.create({
|
|
|
1536
2169
|
});
|
|
1537
2170
|
var YouTubeEmbedControl = ({ className }) => {
|
|
1538
2171
|
const { editor } = useRichTextEditorContext();
|
|
1539
|
-
const [open, setOpen] =
|
|
1540
|
-
const [url, setUrl] =
|
|
2172
|
+
const [open, setOpen] = useState5(false);
|
|
2173
|
+
const [url, setUrl] = useState5("");
|
|
1541
2174
|
const { active } = useEditorState5({
|
|
1542
2175
|
editor: editor ?? null,
|
|
1543
2176
|
selector: (ctx) => ({
|
|
@@ -1550,18 +2183,18 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1550
2183
|
setUrl("");
|
|
1551
2184
|
}
|
|
1552
2185
|
}, [url, editor]);
|
|
1553
|
-
return /* @__PURE__ */
|
|
1554
|
-
/* @__PURE__ */
|
|
2186
|
+
return /* @__PURE__ */ jsxs8(Dialog, { open, onOpenChange: setOpen, children: [
|
|
2187
|
+
/* @__PURE__ */ jsx14(
|
|
1555
2188
|
DialogTrigger,
|
|
1556
2189
|
{
|
|
1557
|
-
render: /* @__PURE__ */
|
|
2190
|
+
render: /* @__PURE__ */ jsx14(
|
|
1558
2191
|
RichTextEditorControl,
|
|
1559
2192
|
{
|
|
1560
2193
|
active,
|
|
1561
2194
|
className,
|
|
1562
2195
|
title: "Embed YouTube video",
|
|
1563
2196
|
"aria-label": "Embed YouTube video",
|
|
1564
|
-
children: /* @__PURE__ */
|
|
2197
|
+
children: /* @__PURE__ */ jsxs8(
|
|
1565
2198
|
"svg",
|
|
1566
2199
|
{
|
|
1567
2200
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1573,8 +2206,8 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1573
2206
|
strokeLinejoin: "round",
|
|
1574
2207
|
className: "rte-editor-icon",
|
|
1575
2208
|
children: [
|
|
1576
|
-
/* @__PURE__ */
|
|
1577
|
-
/* @__PURE__ */
|
|
2209
|
+
/* @__PURE__ */ jsx14("path", { d: "M23.5 6.2a3 3 0 0 0-2.1-2.1C19.5 3.5 12 3.5 12 3.5s-7.5 0-9.4.6a3 3 0 0 0-2.1 2.1C0 8.1 0 12 0 12s0 3.9.5 5.8a3 3 0 0 0 2.1 2.1c1.9.6 9.4.6 9.4.6s7.5 0 9.4-.6a3 3 0 0 0 2.1-2.1c.5-1.9.5-5.8.5-5.8s0-3.9-.5-5.8z" }),
|
|
2210
|
+
/* @__PURE__ */ jsx14("path", { d: "M9.5 15.5V8.5l6.2 3.5z" })
|
|
1578
2211
|
]
|
|
1579
2212
|
}
|
|
1580
2213
|
)
|
|
@@ -1582,12 +2215,12 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1582
2215
|
)
|
|
1583
2216
|
}
|
|
1584
2217
|
),
|
|
1585
|
-
/* @__PURE__ */
|
|
1586
|
-
/* @__PURE__ */
|
|
1587
|
-
/* @__PURE__ */
|
|
1588
|
-
/* @__PURE__ */
|
|
2218
|
+
/* @__PURE__ */ jsxs8(DialogContent, { showCloseButton: false, children: [
|
|
2219
|
+
/* @__PURE__ */ jsxs8(DialogHeader, { children: [
|
|
2220
|
+
/* @__PURE__ */ jsx14(DialogTitle, { children: "Embed YouTube video" }),
|
|
2221
|
+
/* @__PURE__ */ jsx14(DialogDescription, { children: "Paste a YouTube video URL or ID." })
|
|
1589
2222
|
] }),
|
|
1590
|
-
/* @__PURE__ */
|
|
2223
|
+
/* @__PURE__ */ jsx14(
|
|
1591
2224
|
Input,
|
|
1592
2225
|
{
|
|
1593
2226
|
value: url,
|
|
@@ -1601,9 +2234,9 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1601
2234
|
}
|
|
1602
2235
|
}
|
|
1603
2236
|
),
|
|
1604
|
-
/* @__PURE__ */
|
|
1605
|
-
/* @__PURE__ */
|
|
1606
|
-
/* @__PURE__ */
|
|
2237
|
+
/* @__PURE__ */ jsxs8(DialogFooter, { children: [
|
|
2238
|
+
/* @__PURE__ */ jsx14(DialogClose, { children: "Cancel" }),
|
|
2239
|
+
/* @__PURE__ */ jsx14(
|
|
1607
2240
|
DialogClose,
|
|
1608
2241
|
{
|
|
1609
2242
|
disabled: !url,
|
|
@@ -1617,203 +2250,6 @@ var YouTubeEmbedControl = ({ className }) => {
|
|
|
1617
2250
|
] });
|
|
1618
2251
|
};
|
|
1619
2252
|
|
|
1620
|
-
// src/icons.tsx
|
|
1621
|
-
import {
|
|
1622
|
-
Bold,
|
|
1623
|
-
Code,
|
|
1624
|
-
Heading1,
|
|
1625
|
-
Heading2,
|
|
1626
|
-
Heading3,
|
|
1627
|
-
Heading4,
|
|
1628
|
-
Heading5,
|
|
1629
|
-
Heading6,
|
|
1630
|
-
Highlighter,
|
|
1631
|
-
Italic,
|
|
1632
|
-
Link,
|
|
1633
|
-
Link2Off,
|
|
1634
|
-
List,
|
|
1635
|
-
ListOrdered,
|
|
1636
|
-
Minus,
|
|
1637
|
-
Redo2,
|
|
1638
|
-
RemoveFormatting,
|
|
1639
|
-
SquareCode,
|
|
1640
|
-
Strikethrough,
|
|
1641
|
-
Subscript,
|
|
1642
|
-
Superscript,
|
|
1643
|
-
TextAlignCenter,
|
|
1644
|
-
TextAlignEnd,
|
|
1645
|
-
TextAlignJustify,
|
|
1646
|
-
TextAlignStart,
|
|
1647
|
-
TextQuote,
|
|
1648
|
-
Underline,
|
|
1649
|
-
Undo2
|
|
1650
|
-
} from "lucide-react";
|
|
1651
|
-
import "react";
|
|
1652
|
-
import { jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1653
|
-
var iconProps = { className: "rte-editor-icon" };
|
|
1654
|
-
var LangIcon = ({
|
|
1655
|
-
children,
|
|
1656
|
-
className
|
|
1657
|
-
}) => /* @__PURE__ */ jsx14(
|
|
1658
|
-
"svg",
|
|
1659
|
-
{
|
|
1660
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1661
|
-
viewBox: "0 0 24 24",
|
|
1662
|
-
fill: "none",
|
|
1663
|
-
stroke: "currentColor",
|
|
1664
|
-
strokeWidth: 1.5,
|
|
1665
|
-
strokeLinecap: "round",
|
|
1666
|
-
strokeLinejoin: "round",
|
|
1667
|
-
className,
|
|
1668
|
-
children
|
|
1669
|
-
}
|
|
1670
|
-
);
|
|
1671
|
-
var DEFAULT_LANGUAGE_ICONS = {
|
|
1672
|
-
bash: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1673
|
-
/* @__PURE__ */ jsx14("rect", { x: "2.5", y: "4", width: "19", height: "16", rx: "2" }),
|
|
1674
|
-
/* @__PURE__ */ jsx14("path", { d: "M6.5 9.5l3.5 3-3.5 3" }),
|
|
1675
|
-
/* @__PURE__ */ jsx14("path", { d: "M12 15.5h5.5" })
|
|
1676
|
-
] }),
|
|
1677
|
-
c: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1678
|
-
/* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "8.5" }),
|
|
1679
|
-
/* @__PURE__ */ jsx14("path", { d: "M15.6 9.3a4.5 4.5 0 1 0 0 5.4" })
|
|
1680
|
-
] }),
|
|
1681
|
-
cpp: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1682
|
-
/* @__PURE__ */ jsx14("circle", { cx: "9.5", cy: "12", r: "6.5" }),
|
|
1683
|
-
/* @__PURE__ */ jsx14("path", { d: "M12.3 9.7a3.3 3.3 0 1 0 0 4.6" }),
|
|
1684
|
-
/* @__PURE__ */ jsx14("path", { d: "M15.7 10.5v3M14.2 12h3" }),
|
|
1685
|
-
/* @__PURE__ */ jsx14("path", { d: "M19.3 10.5v3M17.8 12h3" })
|
|
1686
|
-
] }),
|
|
1687
|
-
css: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1688
|
-
/* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1689
|
-
/* @__PURE__ */ jsx14("path", { d: "M9.7 7.5l-1 9" }),
|
|
1690
|
-
/* @__PURE__ */ jsx14("path", { d: "M15.3 7.5l-1 9" }),
|
|
1691
|
-
/* @__PURE__ */ jsx14("path", { d: "M7 10.3h11" }),
|
|
1692
|
-
/* @__PURE__ */ jsx14("path", { d: "M6.5 14.3h11" })
|
|
1693
|
-
] }),
|
|
1694
|
-
go: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1695
|
-
/* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1696
|
-
/* @__PURE__ */ jsx14("path", { d: "M12.6 9.7A3.3 3.3 0 1 0 12.6 14.3" }),
|
|
1697
|
-
/* @__PURE__ */ jsx14("path", { d: "M12.6 12h-1.9" }),
|
|
1698
|
-
/* @__PURE__ */ jsx14("circle", { cx: "17", cy: "12", r: "2.9" })
|
|
1699
|
-
] }),
|
|
1700
|
-
html: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1701
|
-
/* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1702
|
-
/* @__PURE__ */ jsx14("path", { d: "M9.5 8.5L6.5 12l3 3.5" }),
|
|
1703
|
-
/* @__PURE__ */ jsx14("path", { d: "M14.5 8.5L17.5 12l-3 3.5" }),
|
|
1704
|
-
/* @__PURE__ */ jsx14("path", { d: "M13 7.3l-2 9.4" })
|
|
1705
|
-
] }),
|
|
1706
|
-
java: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1707
|
-
/* @__PURE__ */ jsx14("path", { d: "M6 10h10v5a3 3 0 0 1-3 3H9a3 3 0 0 1-3-3v-5z" }),
|
|
1708
|
-
/* @__PURE__ */ jsx14("path", { d: "M16 12h1.3a1.8 1.8 0 0 1 0 3.6H16" }),
|
|
1709
|
-
/* @__PURE__ */ jsx14("path", { d: "M9.3 3.8c-.9.8-.9 1.6 0 2.4M13.3 3.8c-.9.8-.9 1.6 0 2.4" }),
|
|
1710
|
-
/* @__PURE__ */ jsx14("path", { d: "M6 19.3h10" })
|
|
1711
|
-
] }),
|
|
1712
|
-
javascript: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1713
|
-
/* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1714
|
-
/* @__PURE__ */ jsx14("path", { d: "M10.5 8v6.5a2 2 0 0 1-3.5 1.3" }),
|
|
1715
|
-
/* @__PURE__ */ jsx14("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1716
|
-
] }),
|
|
1717
|
-
json: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1718
|
-
/* @__PURE__ */ jsx14("path", { d: "M8 3H7a2 2 0 0 0-2 2v4a2 2 0 0 1-2 2 2 2 0 0 1 2 2v4a2 2 0 0 0 2 2" }),
|
|
1719
|
-
/* @__PURE__ */ jsx14("path", { d: "M16 3h1a2 2 0 0 1 2 2v4a2 2 0 0 0 2 2 2 2 0 0 0-2 2v4a2 2 0 0 1-2 2" })
|
|
1720
|
-
] }),
|
|
1721
|
-
kotlin: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1722
|
-
/* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1723
|
-
/* @__PURE__ */ jsx14("path", { d: "M9 7.5v9" }),
|
|
1724
|
-
/* @__PURE__ */ jsx14("path", { d: "M9 12l6-4.5" }),
|
|
1725
|
-
/* @__PURE__ */ jsx14("path", { d: "M9 12l6 4.5" })
|
|
1726
|
-
] }),
|
|
1727
|
-
markdown: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1728
|
-
/* @__PURE__ */ jsx14("rect", { x: "2", y: "5", width: "20", height: "14", rx: "2" }),
|
|
1729
|
-
/* @__PURE__ */ jsx14("path", { d: "M6 15V9l3 4 3-4v6" }),
|
|
1730
|
-
/* @__PURE__ */ jsx14("path", { d: "M16.5 9v6" }),
|
|
1731
|
-
/* @__PURE__ */ jsx14("path", { d: "M14.5 13l2 2 2-2" })
|
|
1732
|
-
] }),
|
|
1733
|
-
php: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1734
|
-
/* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1735
|
-
/* @__PURE__ */ jsx14("path", { d: "M11.5 8.5L7.5 12l4 3.5" }),
|
|
1736
|
-
/* @__PURE__ */ jsx14("path", { d: "M15.2 8.2c1.1 0 1.9.6 1.9 1.6 0 1.1-.9 1.5-1.8 1.8-.6.2-1 .5-1 1.1" }),
|
|
1737
|
-
/* @__PURE__ */ jsx14("circle", { cx: "14.3", cy: "16.2", r: ".5", fill: "currentColor", stroke: "none" })
|
|
1738
|
-
] }),
|
|
1739
|
-
plaintext: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1740
|
-
/* @__PURE__ */ jsx14("rect", { x: "4", y: "2.5", width: "16", height: "19", rx: "2" }),
|
|
1741
|
-
/* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "7.5", x2: "16.5", y2: "7.5" }),
|
|
1742
|
-
/* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "11.5", x2: "16.5", y2: "11.5" }),
|
|
1743
|
-
/* @__PURE__ */ jsx14("line", { x1: "7.5", y1: "15.5", x2: "13.5", y2: "15.5" })
|
|
1744
|
-
] }),
|
|
1745
|
-
python: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1746
|
-
/* @__PURE__ */ jsx14("path", { d: "M4.5 15c0-3 2.5-4.7 5.7-4.7h1.6c2.8 0 5-2 5-4.5" }),
|
|
1747
|
-
/* @__PURE__ */ jsx14("path", { d: "M9.5 3.3c1.3-.3 2.6 0 3.3 1-.7 1-2 1.3-3.3 1" }),
|
|
1748
|
-
/* @__PURE__ */ jsx14("circle", { cx: "15.5", cy: "4.3", r: ".55", fill: "currentColor", stroke: "none" }),
|
|
1749
|
-
/* @__PURE__ */ jsx14("path", { d: "M17.8 4.5l1.4-.6M17.8 4.9l1.4.6" })
|
|
1750
|
-
] }),
|
|
1751
|
-
ruby: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1752
|
-
/* @__PURE__ */ jsx14("polygon", { points: "12 2.5 19.5 8 12 21.5 4.5 8" }),
|
|
1753
|
-
/* @__PURE__ */ jsx14("path", { d: "M4.5 8h15" }),
|
|
1754
|
-
/* @__PURE__ */ jsx14("path", { d: "M12 2.5v19" })
|
|
1755
|
-
] }),
|
|
1756
|
-
rust: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1757
|
-
/* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "7" }),
|
|
1758
|
-
/* @__PURE__ */ jsx14("circle", { cx: "12", cy: "12", r: "2.3" }),
|
|
1759
|
-
/* @__PURE__ */ jsx14("path", { d: "M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3" }),
|
|
1760
|
-
/* @__PURE__ */ jsx14("path", { d: "M5.6 5.6l2.1 2.1M16.3 16.3l2.1 2.1M5.6 18.4l2.1-2.1M16.3 7.7l2.1-2.1" })
|
|
1761
|
-
] }),
|
|
1762
|
-
sql: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1763
|
-
/* @__PURE__ */ jsx14("ellipse", { cx: "12", cy: "6", rx: "8", ry: "3" }),
|
|
1764
|
-
/* @__PURE__ */ jsx14("path", { d: "M4 6v6c0 1.7 3.6 3 8 3s8-1.3 8-3V6" }),
|
|
1765
|
-
/* @__PURE__ */ jsx14("path", { d: "M4 12v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6" })
|
|
1766
|
-
] }),
|
|
1767
|
-
swift: /* @__PURE__ */ jsx14(LangIcon, { children: /* @__PURE__ */ jsx14("path", { d: "M19 4.5c-2.6 4-5.5 7-8.3 9 2-.2 3.7-1 4.8-2.6-.7 2.8-2.8 5-5.3 6.1 3 .5 5.6-.5 7.2-2.4.4 2-.4 3.9-1.9 4.9 3.7-1.3 6-4.2 6.6-7.6-1 2.6-2.8 4.6-4.6 5.8" }) }),
|
|
1768
|
-
typescript: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1769
|
-
/* @__PURE__ */ jsx14("rect", { x: "3", y: "3", width: "18", height: "18", rx: "4" }),
|
|
1770
|
-
/* @__PURE__ */ jsx14("path", { d: "M7.3 8.2h5M9.8 8.2v7.6" }),
|
|
1771
|
-
/* @__PURE__ */ jsx14("path", { d: "M17 8.8a2 2 0 0 0-2-.8c-1.1 0-2.2.6-2.2 1.7 0 1 .9 1.4 2.2 1.7 1.3.3 2.3.7 2.3 1.9 0 1.1-1 1.8-2.3 1.8a2.4 2.4 0 0 1-2.3-1.4" })
|
|
1772
|
-
] }),
|
|
1773
|
-
xml: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1774
|
-
/* @__PURE__ */ jsx14("path", { d: "M8 7l-4.5 5 4.5 5" }),
|
|
1775
|
-
/* @__PURE__ */ jsx14("path", { d: "M16 7l4.5 5-4.5 5" }),
|
|
1776
|
-
/* @__PURE__ */ jsx14("path", { d: "M12 8v8" })
|
|
1777
|
-
] }),
|
|
1778
|
-
yaml: /* @__PURE__ */ jsxs8(LangIcon, { children: [
|
|
1779
|
-
/* @__PURE__ */ jsx14("rect", { x: "2.5", y: "3", width: "19", height: "18", rx: "2" }),
|
|
1780
|
-
/* @__PURE__ */ jsx14("path", { d: "M6.5 8h2M9.5 8h8" }),
|
|
1781
|
-
/* @__PURE__ */ jsx14("path", { d: "M6.5 12h2M9.5 12h6" }),
|
|
1782
|
-
/* @__PURE__ */ jsx14("path", { d: "M6.5 16h2M9.5 16h7" })
|
|
1783
|
-
] })
|
|
1784
|
-
};
|
|
1785
|
-
var DEFAULT_ICONS = {
|
|
1786
|
-
alignCenterControlIcon: /* @__PURE__ */ jsx14(TextAlignCenter, { ...iconProps }),
|
|
1787
|
-
alignJustifyControlIcon: /* @__PURE__ */ jsx14(TextAlignJustify, { ...iconProps }),
|
|
1788
|
-
alignLeftControlIcon: /* @__PURE__ */ jsx14(TextAlignStart, { ...iconProps }),
|
|
1789
|
-
alignRightControlIcon: /* @__PURE__ */ jsx14(TextAlignEnd, { ...iconProps }),
|
|
1790
|
-
blockquoteControlIcon: /* @__PURE__ */ jsx14(TextQuote, { ...iconProps }),
|
|
1791
|
-
boldControlIcon: /* @__PURE__ */ jsx14(Bold, { ...iconProps }),
|
|
1792
|
-
bulletListControlIcon: /* @__PURE__ */ jsx14(List, { ...iconProps }),
|
|
1793
|
-
clearFormattingControlIcon: /* @__PURE__ */ jsx14(RemoveFormatting, { ...iconProps }),
|
|
1794
|
-
codeBlockControlIcon: /* @__PURE__ */ jsx14(SquareCode, { ...iconProps }),
|
|
1795
|
-
codeControlIcon: /* @__PURE__ */ jsx14(Code, { ...iconProps }),
|
|
1796
|
-
h1ControlIcon: /* @__PURE__ */ jsx14(Heading1, { ...iconProps }),
|
|
1797
|
-
h2ControlIcon: /* @__PURE__ */ jsx14(Heading2, { ...iconProps }),
|
|
1798
|
-
h3ControlIcon: /* @__PURE__ */ jsx14(Heading3, { ...iconProps }),
|
|
1799
|
-
h4ControlIcon: /* @__PURE__ */ jsx14(Heading4, { ...iconProps }),
|
|
1800
|
-
h5ControlIcon: /* @__PURE__ */ jsx14(Heading5, { ...iconProps }),
|
|
1801
|
-
h6ControlIcon: /* @__PURE__ */ jsx14(Heading6, { ...iconProps }),
|
|
1802
|
-
highlightControlIcon: /* @__PURE__ */ jsx14(Highlighter, { ...iconProps }),
|
|
1803
|
-
hrControlIcon: /* @__PURE__ */ jsx14(Minus, { ...iconProps }),
|
|
1804
|
-
italicControlIcon: /* @__PURE__ */ jsx14(Italic, { ...iconProps }),
|
|
1805
|
-
languageIcons: DEFAULT_LANGUAGE_ICONS,
|
|
1806
|
-
linkControlIcon: /* @__PURE__ */ jsx14(Link, { ...iconProps }),
|
|
1807
|
-
orderedListControlIcon: /* @__PURE__ */ jsx14(ListOrdered, { ...iconProps }),
|
|
1808
|
-
redoControlIcon: /* @__PURE__ */ jsx14(Redo2, { ...iconProps }),
|
|
1809
|
-
strikeControlIcon: /* @__PURE__ */ jsx14(Strikethrough, { ...iconProps }),
|
|
1810
|
-
subscriptControlIcon: /* @__PURE__ */ jsx14(Subscript, { ...iconProps }),
|
|
1811
|
-
superscriptControlIcon: /* @__PURE__ */ jsx14(Superscript, { ...iconProps }),
|
|
1812
|
-
underlineControlIcon: /* @__PURE__ */ jsx14(Underline, { ...iconProps }),
|
|
1813
|
-
undoControlIcon: /* @__PURE__ */ jsx14(Undo2, { ...iconProps }),
|
|
1814
|
-
unlinkControlIcon: /* @__PURE__ */ jsx14(Link2Off, { ...iconProps })
|
|
1815
|
-
};
|
|
1816
|
-
|
|
1817
2253
|
// src/labels.ts
|
|
1818
2254
|
var DEFAULT_LABELS = {
|
|
1819
2255
|
alignCenterControlLabel: "Align center",
|
|
@@ -1883,8 +2319,8 @@ var ControlsGroup = ({
|
|
|
1883
2319
|
}) => /* @__PURE__ */ jsx16("div", { className: cn("rte-controls-group", className), children });
|
|
1884
2320
|
|
|
1885
2321
|
// src/rte-footer.tsx
|
|
1886
|
-
import { useEffect as
|
|
1887
|
-
import { Fragment as
|
|
2322
|
+
import { useEffect as useEffect5, useMemo, useRef as useRef4, useState as useState6 } from "react";
|
|
2323
|
+
import { Fragment as Fragment4, jsx as jsx17, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1888
2324
|
var Footer = ({
|
|
1889
2325
|
children,
|
|
1890
2326
|
className,
|
|
@@ -1895,9 +2331,9 @@ var Footer = ({
|
|
|
1895
2331
|
wordCountFormatter
|
|
1896
2332
|
}) => {
|
|
1897
2333
|
const { editor, variant } = useRichTextEditorContext();
|
|
1898
|
-
const [, forceUpdate] =
|
|
2334
|
+
const [, forceUpdate] = useState6(0);
|
|
1899
2335
|
const rafRef = useRef4(null);
|
|
1900
|
-
|
|
2336
|
+
useEffect5(() => {
|
|
1901
2337
|
if (!editor || !showWordCount) {
|
|
1902
2338
|
return;
|
|
1903
2339
|
}
|
|
@@ -1955,7 +2391,7 @@ var Footer = ({
|
|
|
1955
2391
|
"data-sticky": sticky ? "" : void 0,
|
|
1956
2392
|
style: sticky ? { bottom: stickyOffset } : void 0,
|
|
1957
2393
|
children: [
|
|
1958
|
-
showWordCount && wordCount && /* @__PURE__ */ jsx17("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs10(
|
|
2394
|
+
showWordCount && wordCount && /* @__PURE__ */ jsx17("span", { className: cn("rte-footer-word-count", wordCountClassName), children: wordCountFormatter ? wordCountFormatter(wordCount) : /* @__PURE__ */ jsxs10(Fragment4, { children: [
|
|
1959
2395
|
/* @__PURE__ */ jsxs10("span", { className: "rte-footer-word-count-stat", children: [
|
|
1960
2396
|
/* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-number", children: wordCount.words }),
|
|
1961
2397
|
/* @__PURE__ */ jsx17("span", { className: "rte-footer-word-count-unit", children: "words" })
|
|
@@ -2022,7 +2458,7 @@ var RichTextEditorRoot = ({
|
|
|
2022
2458
|
[labels]
|
|
2023
2459
|
);
|
|
2024
2460
|
const mergedIcons = useMemo2(() => ({ ...DEFAULT_ICONS, ...icons }), [icons]);
|
|
2025
|
-
|
|
2461
|
+
useEffect6(() => {
|
|
2026
2462
|
if (editor && editor.isEditable !== editable) {
|
|
2027
2463
|
editor.setEditable(editable);
|
|
2028
2464
|
}
|