@editorcn/editor 0.4.0 → 0.4.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/README.md +87 -87
- package/dist/index.cjs +29 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -16
- package/dist/index.js.map +1 -1
- package/dist/style.css +229 -199
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -95,7 +95,7 @@ var DialogContent = ({
|
|
|
95
95
|
{
|
|
96
96
|
"data-slot": "dialog-content",
|
|
97
97
|
className: cn(
|
|
98
|
-
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-
|
|
98
|
+
"fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-5 text-xs/relaxed text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
99
99
|
className
|
|
100
100
|
),
|
|
101
101
|
...props,
|
|
@@ -221,7 +221,7 @@ var PopoverContent = ({
|
|
|
221
221
|
{
|
|
222
222
|
"data-slot": "popover-content",
|
|
223
223
|
className: cn(
|
|
224
|
-
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-
|
|
224
|
+
"z-50 flex w-72 origin-(--transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-xs text-popover-foreground shadow-[0_8px_30px_-12px_rgb(0_0_0/0.15)] ring-1 ring-border/60 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
225
225
|
className
|
|
226
226
|
),
|
|
227
227
|
...props
|
|
@@ -504,7 +504,7 @@ import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
|
504
504
|
import { cva as cva2 } from "class-variance-authority";
|
|
505
505
|
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
506
506
|
var toggleVariants = cva2(
|
|
507
|
-
"group/toggle inline-flex items-center justify-center gap-1 rounded-
|
|
507
|
+
"group/toggle inline-flex items-center justify-center gap-1 rounded-md text-xs font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
508
508
|
{
|
|
509
509
|
defaultVariants: {
|
|
510
510
|
size: "default",
|
|
@@ -514,7 +514,7 @@ var toggleVariants = cva2(
|
|
|
514
514
|
size: {
|
|
515
515
|
default: "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
516
516
|
lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
517
|
-
sm: "h-7 min-w-7
|
|
517
|
+
sm: "h-7 min-w-7 px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5"
|
|
518
518
|
},
|
|
519
519
|
variant: {
|
|
520
520
|
default: "bg-transparent",
|
|
@@ -574,13 +574,13 @@ var TooltipContent = ({
|
|
|
574
574
|
{
|
|
575
575
|
"data-slot": "tooltip-content",
|
|
576
576
|
className: cn(
|
|
577
|
-
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-
|
|
577
|
+
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-2 py-1 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
578
578
|
className
|
|
579
579
|
),
|
|
580
580
|
...props,
|
|
581
581
|
children: [
|
|
582
582
|
children,
|
|
583
|
-
/* @__PURE__ */ jsx16(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-
|
|
583
|
+
/* @__PURE__ */ jsx16(TooltipPrimitive.Arrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })
|
|
584
584
|
]
|
|
585
585
|
}
|
|
586
586
|
)
|
|
@@ -866,7 +866,8 @@ var textItems = [
|
|
|
866
866
|
/* @__PURE__ */ jsx18("path", { d: "M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" }),
|
|
867
867
|
/* @__PURE__ */ jsx18("path", { d: "M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" })
|
|
868
868
|
] }) }),
|
|
869
|
-
isActive: (s) => s.isBold
|
|
869
|
+
isActive: (s) => s.isBold,
|
|
870
|
+
mark: "bold"
|
|
870
871
|
},
|
|
871
872
|
{
|
|
872
873
|
command: (e) => e.chain().focus().toggleItalic().run(),
|
|
@@ -875,7 +876,8 @@ var textItems = [
|
|
|
875
876
|
/* @__PURE__ */ jsx18("line", { x1: "14", y1: "20", x2: "5", y2: "20" }),
|
|
876
877
|
/* @__PURE__ */ jsx18("line", { x1: "15", y1: "4", x2: "9", y2: "20" })
|
|
877
878
|
] }) }),
|
|
878
|
-
isActive: (s) => s.isItalic
|
|
879
|
+
isActive: (s) => s.isItalic,
|
|
880
|
+
mark: "italic"
|
|
879
881
|
},
|
|
880
882
|
{
|
|
881
883
|
command: (e) => e.chain().focus().toggleUnderline().run(),
|
|
@@ -883,7 +885,8 @@ var textItems = [
|
|
|
883
885
|
/* @__PURE__ */ jsx18("path", { d: "M6 4v6a6 6 0 0 0 12 0V4" }),
|
|
884
886
|
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "20", x2: "20", y2: "20" })
|
|
885
887
|
] }) }),
|
|
886
|
-
isActive: (s) => s.isUnderline
|
|
888
|
+
isActive: (s) => s.isUnderline,
|
|
889
|
+
mark: "underline"
|
|
887
890
|
},
|
|
888
891
|
{
|
|
889
892
|
command: (e) => e.chain().focus().toggleStrike().run(),
|
|
@@ -892,7 +895,8 @@ var textItems = [
|
|
|
892
895
|
/* @__PURE__ */ jsx18("path", { d: "M14.5 14.6a3.5 3.5 0 0 1-2.9 5.4H8" }),
|
|
893
896
|
/* @__PURE__ */ jsx18("line", { x1: "4", y1: "12", x2: "20", y2: "12" })
|
|
894
897
|
] }) }),
|
|
895
|
-
isActive: (s) => s.isStrike
|
|
898
|
+
isActive: (s) => s.isStrike,
|
|
899
|
+
mark: "strike"
|
|
896
900
|
},
|
|
897
901
|
{
|
|
898
902
|
command: (e) => e.chain().focus().toggleCode().run(),
|
|
@@ -900,9 +904,11 @@ var textItems = [
|
|
|
900
904
|
/* @__PURE__ */ jsx18("polyline", { points: "16 18 22 12 16 6" }),
|
|
901
905
|
/* @__PURE__ */ jsx18("polyline", { points: "8 6 2 12 8 18" })
|
|
902
906
|
] }) }),
|
|
903
|
-
isActive: (s) => s.isCode
|
|
907
|
+
isActive: (s) => s.isCode,
|
|
908
|
+
mark: "code"
|
|
904
909
|
}
|
|
905
910
|
];
|
|
911
|
+
var getTextItems = (editor) => textItems.filter((item) => Boolean(editor.schema.marks[item.mark]));
|
|
906
912
|
var TextButtons = ({ editor }) => {
|
|
907
913
|
const editorState = useEditorState(
|
|
908
914
|
editor,
|
|
@@ -915,7 +921,7 @@ var TextButtons = ({ editor }) => {
|
|
|
915
921
|
}),
|
|
916
922
|
shallowEqual
|
|
917
923
|
);
|
|
918
|
-
return /* @__PURE__ */ jsx18(RteButtonGroup, { children:
|
|
924
|
+
return /* @__PURE__ */ jsx18(RteButtonGroup, { children: getTextItems(editor).map((item) => /* @__PURE__ */ jsx18(
|
|
919
925
|
RteButton,
|
|
920
926
|
{
|
|
921
927
|
active: item.isActive(editorState),
|
|
@@ -923,7 +929,7 @@ var TextButtons = ({ editor }) => {
|
|
|
923
929
|
onClick: () => item.command(editor),
|
|
924
930
|
children: item.icon
|
|
925
931
|
},
|
|
926
|
-
|
|
932
|
+
item.mark
|
|
927
933
|
)) });
|
|
928
934
|
};
|
|
929
935
|
|
|
@@ -952,6 +958,13 @@ var BubbleMenu = ({ editor }) => {
|
|
|
952
958
|
if (!editor) {
|
|
953
959
|
return null;
|
|
954
960
|
}
|
|
961
|
+
const hasText = getTextItems(editor).length > 0;
|
|
962
|
+
const hasColor = editor.extensionManager.extensions.some(
|
|
963
|
+
(ext) => ext.name === "color" || ext.name === "highlight"
|
|
964
|
+
);
|
|
965
|
+
if (!(hasText || hasColor)) {
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
955
968
|
return /* @__PURE__ */ jsx19(
|
|
956
969
|
TiptapBubbleMenu,
|
|
957
970
|
{
|
|
@@ -959,9 +972,9 @@ var BubbleMenu = ({ editor }) => {
|
|
|
959
972
|
options: { offset: 8, placement: "top" },
|
|
960
973
|
shouldShow,
|
|
961
974
|
children: /* @__PURE__ */ jsxs7("div", { className: "rte-bubble-menu", children: [
|
|
962
|
-
/* @__PURE__ */ jsx19(TextButtons, { editor }),
|
|
963
|
-
/* @__PURE__ */ jsx19(RteSeparator, {}),
|
|
964
|
-
/* @__PURE__ */ jsx19(ColorSelector, { editor })
|
|
975
|
+
hasText && /* @__PURE__ */ jsx19(TextButtons, { editor }),
|
|
976
|
+
hasText && hasColor && /* @__PURE__ */ jsx19(RteSeparator, {}),
|
|
977
|
+
hasColor && /* @__PURE__ */ jsx19(ColorSelector, { editor })
|
|
965
978
|
] })
|
|
966
979
|
}
|
|
967
980
|
);
|