@react-email/editor 0.0.0-experimental.45 → 0.0.0-experimental.47
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/{event-bus-BFzKTuhV.mjs → columns-DC8gJU2D.mjs} +5 -88
- package/dist/columns-DC8gJU2D.mjs.map +1 -0
- package/dist/{event-bus-D-uahiao.cjs → columns-DFnIRlLe.cjs} +6 -107
- package/dist/core/index.cjs +5 -6
- package/dist/core/index.d.cts +2 -2
- package/dist/core/index.d.mts +2 -3
- package/dist/core/index.mjs +3 -3
- package/dist/core-BxIUuTKo.mjs +156 -0
- package/dist/core-BxIUuTKo.mjs.map +1 -0
- package/dist/core-i3eza_VQ.cjs +173 -0
- package/dist/event-bus-BxVEXi1L.mjs +88 -0
- package/dist/event-bus-BxVEXi1L.mjs.map +1 -0
- package/dist/event-bus-GmFPYJu2.cjs +105 -0
- package/dist/{extension-B_ImOuII.mjs → extension-79zQ_3No.mjs} +11 -10
- package/dist/{extension-B_ImOuII.mjs.map → extension-79zQ_3No.mjs.map} +1 -1
- package/dist/{extension-DHsEsAaO.cjs → extension-ATLgVzTR.cjs} +12 -11
- package/dist/extensions/index.cjs +10 -10
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.mts +1 -2
- package/dist/extensions/index.d.mts.map +1 -1
- package/dist/extensions/index.mjs +3 -3
- package/dist/{extensions-BT49qi4I.mjs → extensions-CGtkbFUL.mjs} +13 -352
- package/dist/extensions-CGtkbFUL.mjs.map +1 -0
- package/dist/{extensions-5sSJryUX.cjs → extensions-DE0L4Pim.cjs} +79 -455
- package/dist/global-content-CaNsyaPw.mjs +78 -0
- package/dist/global-content-CaNsyaPw.mjs.map +1 -0
- package/dist/global-content-Dcc6RTLp.cjs +89 -0
- package/dist/{index-BL2rehV8.d.mts → index-BMsf5s28.d.mts} +3 -34
- package/dist/index-BMsf5s28.d.mts.map +1 -0
- package/dist/{index-DJgMqa5C.d.cts → index-DNriNUPU.d.cts} +3 -34
- package/dist/index-DNriNUPU.d.cts.map +1 -0
- package/dist/index.cjs +140 -11
- package/dist/index.d.cts +9 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +9 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +136 -7
- package/dist/index.mjs.map +1 -1
- package/dist/plugins/index.cjs +1 -1
- package/dist/plugins/index.d.cts +1 -1
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.mjs +1 -1
- package/dist/{root-CJuwiIRn.mjs → root-DCHEkXs2.mjs} +272 -224
- package/dist/root-DCHEkXs2.mjs.map +1 -0
- package/dist/{root-CEAehvsX.cjs → root-DLdCJfdP.cjs} +288 -234
- package/dist/{set-text-alignment-GMXOPMlJ.mjs → set-text-alignment-BDkB4Vfh.mjs} +1 -1
- package/dist/{set-text-alignment-GMXOPMlJ.mjs.map → set-text-alignment-BDkB4Vfh.mjs.map} +1 -1
- package/dist/{global-content-D3TNgSN6.cjs → styles-CYEzPPfZ.cjs} +0 -88
- package/dist/{global-content-6jVh6L0b.mjs → styles-DZ9S92ix.mjs} +2 -78
- package/dist/styles-DZ9S92ix.mjs.map +1 -0
- package/dist/{types-BNEbRz-a.d.cts → types-B-hiUAR9.d.cts} +1 -1
- package/dist/{types-BNEbRz-a.d.cts.map → types-B-hiUAR9.d.cts.map} +1 -1
- package/dist/{types-C8k-blF7.d.mts → types-J7sLqbPy.d.mts} +1 -1
- package/dist/{types-C8k-blF7.d.mts.map → types-J7sLqbPy.d.mts.map} +1 -1
- package/dist/ui/index.cjs +20 -69
- package/dist/ui/index.d.cts +112 -143
- package/dist/ui/index.d.cts.map +1 -1
- package/dist/ui/index.d.mts +111 -142
- package/dist/ui/index.d.mts.map +1 -1
- package/dist/ui/index.mjs +5 -53
- package/dist/ui/index.mjs.map +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +1 -1
- package/readme.md +1 -1
- package/dist/create-paste-handler-B8BtjBk3.d.cts +0 -14
- package/dist/create-paste-handler-B8BtjBk3.d.cts.map +0 -1
- package/dist/create-paste-handler-DsJYKisA.d.mts +0 -14
- package/dist/create-paste-handler-DsJYKisA.d.mts.map +0 -1
- package/dist/event-bus-BFzKTuhV.mjs.map +0 -1
- package/dist/extensions-BT49qi4I.mjs.map +0 -1
- package/dist/global-content-6jVh6L0b.mjs.map +0 -1
- package/dist/index-BL2rehV8.d.mts.map +0 -1
- package/dist/index-DJgMqa5C.d.cts.map +0 -1
- package/dist/root-CJuwiIRn.mjs.map +0 -1
- /package/dist/{set-text-alignment-aNb7Ml9N.cjs → set-text-alignment-BlyZq1GA.cjs} +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { t as editorEventBus } from "./event-bus-BxVEXi1L.mjs";
|
|
2
|
+
import { i as MAX_COLUMNS_DEPTH, s as getColumnsDepth } from "./columns-DC8gJU2D.mjs";
|
|
3
|
+
import { t as setTextAlignment } from "./set-text-alignment-BDkB4Vfh.mjs";
|
|
3
4
|
import { useCurrentEditor, useEditorState } from "@tiptap/react";
|
|
4
5
|
import * as React$1 from "react";
|
|
5
6
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
@@ -737,10 +738,114 @@ function UnlinkIcon({ size, width, height, ...props }) {
|
|
|
737
738
|
const BubbleMenuContext = React$1.createContext(null);
|
|
738
739
|
function useBubbleMenuContext() {
|
|
739
740
|
const context = React$1.useContext(BubbleMenuContext);
|
|
740
|
-
if (!context) throw new Error("BubbleMenu compound components must be used within <BubbleMenu
|
|
741
|
+
if (!context) throw new Error("BubbleMenu compound components must be used within <BubbleMenu>");
|
|
741
742
|
return context;
|
|
742
743
|
}
|
|
743
744
|
|
|
745
|
+
//#endregion
|
|
746
|
+
//#region src/ui/bubble-menu/item.tsx
|
|
747
|
+
function BubbleMenuItem({ name, isActive, onCommand, className, children, ...rest }) {
|
|
748
|
+
return /* @__PURE__ */ jsx("button", {
|
|
749
|
+
type: "button",
|
|
750
|
+
"aria-label": name,
|
|
751
|
+
"aria-pressed": isActive,
|
|
752
|
+
className,
|
|
753
|
+
"data-re-bubble-menu-item": "",
|
|
754
|
+
"data-item": name,
|
|
755
|
+
...isActive ? { "data-active": "" } : {},
|
|
756
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
757
|
+
onClick: onCommand,
|
|
758
|
+
...rest,
|
|
759
|
+
children
|
|
760
|
+
});
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
//#endregion
|
|
764
|
+
//#region src/ui/bubble-menu/align-center.tsx
|
|
765
|
+
function BubbleMenuAlignCenter({ className, children }) {
|
|
766
|
+
const { editor } = useBubbleMenuContext();
|
|
767
|
+
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
768
|
+
name: "align-center",
|
|
769
|
+
isActive: useEditorState({
|
|
770
|
+
editor,
|
|
771
|
+
selector: ({ editor: editor$1 }) => editor$1?.isActive({ alignment: "center" }) ?? false
|
|
772
|
+
}),
|
|
773
|
+
onCommand: () => setTextAlignment(editor, "center"),
|
|
774
|
+
className,
|
|
775
|
+
children: children ?? /* @__PURE__ */ jsx(AlignCenterIcon, {})
|
|
776
|
+
});
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
//#endregion
|
|
780
|
+
//#region src/ui/bubble-menu/align-left.tsx
|
|
781
|
+
function BubbleMenuAlignLeft({ className, children }) {
|
|
782
|
+
const { editor } = useBubbleMenuContext();
|
|
783
|
+
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
784
|
+
name: "align-left",
|
|
785
|
+
isActive: useEditorState({
|
|
786
|
+
editor,
|
|
787
|
+
selector: ({ editor: editor$1 }) => editor$1?.isActive({ alignment: "left" }) ?? false
|
|
788
|
+
}),
|
|
789
|
+
onCommand: () => setTextAlignment(editor, "left"),
|
|
790
|
+
className,
|
|
791
|
+
children: children ?? /* @__PURE__ */ jsx(AlignLeftIcon, {})
|
|
792
|
+
});
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
//#endregion
|
|
796
|
+
//#region src/ui/bubble-menu/align-right.tsx
|
|
797
|
+
function BubbleMenuAlignRight({ className, children }) {
|
|
798
|
+
const { editor } = useBubbleMenuContext();
|
|
799
|
+
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
800
|
+
name: "align-right",
|
|
801
|
+
isActive: useEditorState({
|
|
802
|
+
editor,
|
|
803
|
+
selector: ({ editor: editor$1 }) => editor$1?.isActive({ alignment: "right" }) ?? false
|
|
804
|
+
}),
|
|
805
|
+
onCommand: () => setTextAlignment(editor, "right"),
|
|
806
|
+
className,
|
|
807
|
+
children: children ?? /* @__PURE__ */ jsx(AlignRightIcon, {})
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
//#endregion
|
|
812
|
+
//#region src/ui/bubble-menu/create-mark-bubble-item.tsx
|
|
813
|
+
function createMarkBubbleItem(config) {
|
|
814
|
+
function MarkBubbleItem({ className, children }) {
|
|
815
|
+
const { editor } = useBubbleMenuContext();
|
|
816
|
+
const isActive = useEditorState({
|
|
817
|
+
editor,
|
|
818
|
+
selector: ({ editor: editor$1 }) => {
|
|
819
|
+
if (config.activeParams) return editor$1?.isActive(config.activeName, config.activeParams) ?? false;
|
|
820
|
+
return editor$1?.isActive(config.activeName) ?? false;
|
|
821
|
+
}
|
|
822
|
+
});
|
|
823
|
+
const handleCommand = () => {
|
|
824
|
+
const chain = editor.chain().focus();
|
|
825
|
+
const method = chain[config.command];
|
|
826
|
+
if (method) method.call(chain).run();
|
|
827
|
+
};
|
|
828
|
+
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
829
|
+
name: config.name,
|
|
830
|
+
isActive,
|
|
831
|
+
onCommand: handleCommand,
|
|
832
|
+
className,
|
|
833
|
+
children: children ?? config.icon
|
|
834
|
+
});
|
|
835
|
+
}
|
|
836
|
+
MarkBubbleItem.displayName = `BubbleMenu${config.name.charAt(0).toUpperCase() + config.name.slice(1)}`;
|
|
837
|
+
return MarkBubbleItem;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
//#endregion
|
|
841
|
+
//#region src/ui/bubble-menu/bold.tsx
|
|
842
|
+
const BubbleMenuBold = createMarkBubbleItem({
|
|
843
|
+
name: "bold",
|
|
844
|
+
activeName: "bold",
|
|
845
|
+
command: "toggleBold",
|
|
846
|
+
icon: /* @__PURE__ */ jsx(BoldIcon, {})
|
|
847
|
+
});
|
|
848
|
+
|
|
744
849
|
//#endregion
|
|
745
850
|
//#region src/ui/bubble-menu/button-edit-link.tsx
|
|
746
851
|
function BubbleMenuButtonEditLink({ className, children, onClick, onMouseDown, ...rest }) {
|
|
@@ -951,198 +1056,6 @@ function BubbleMenuButtonUnlink({ className, children, onClick, onMouseDown, onL
|
|
|
951
1056
|
});
|
|
952
1057
|
}
|
|
953
1058
|
|
|
954
|
-
//#endregion
|
|
955
|
-
//#region src/ui/bubble-menu/triggers.ts
|
|
956
|
-
const bubbleMenuTriggers = {
|
|
957
|
-
textSelection(hideWhenActiveNodes = [], hideWhenActiveMarks = []) {
|
|
958
|
-
return ({ editor, state }) => {
|
|
959
|
-
for (const node of hideWhenActiveNodes) {
|
|
960
|
-
if (editor.isActive(node)) return false;
|
|
961
|
-
const { $from } = state.selection;
|
|
962
|
-
for (let d = $from.depth; d > 0; d--) if ($from.node(d).type.name === node) return false;
|
|
963
|
-
}
|
|
964
|
-
for (const mark of hideWhenActiveMarks) if (editor.isActive(mark)) return false;
|
|
965
|
-
return editor.view.state.selection.content().size > 0;
|
|
966
|
-
};
|
|
967
|
-
},
|
|
968
|
-
node(name) {
|
|
969
|
-
return ({ editor }) => editor.isActive(name);
|
|
970
|
-
},
|
|
971
|
-
nodeWithoutSelection(name) {
|
|
972
|
-
return ({ editor }) => editor.isActive(name) && editor.view.state.selection.content().size === 0;
|
|
973
|
-
}
|
|
974
|
-
};
|
|
975
|
-
|
|
976
|
-
//#endregion
|
|
977
|
-
//#region src/ui/bubble-menu/root.tsx
|
|
978
|
-
const defaultPluginKey = new PluginKey("bubbleMenu");
|
|
979
|
-
function BubbleMenuRoot({ trigger, pluginKey: pluginKey$1 = defaultPluginKey, hideWhenActiveNodes = [], hideWhenActiveMarks = [], placement = "bottom", offset: offset$1 = 8, onHide, className, children, ...rest }) {
|
|
980
|
-
const { editor } = useCurrentEditor();
|
|
981
|
-
const [isEditing, setIsEditing] = React$1.useState(false);
|
|
982
|
-
const resolvedTrigger = trigger ?? bubbleMenuTriggers.textSelection(hideWhenActiveNodes, hideWhenActiveMarks);
|
|
983
|
-
if (!editor) return null;
|
|
984
|
-
return /* @__PURE__ */ jsx(BubbleMenu, {
|
|
985
|
-
editor,
|
|
986
|
-
pluginKey: pluginKey$1,
|
|
987
|
-
"data-re-bubble-menu": "",
|
|
988
|
-
shouldShow: resolvedTrigger,
|
|
989
|
-
options: {
|
|
990
|
-
placement,
|
|
991
|
-
offset: offset$1,
|
|
992
|
-
onHide: () => {
|
|
993
|
-
setIsEditing(false);
|
|
994
|
-
onHide?.();
|
|
995
|
-
}
|
|
996
|
-
},
|
|
997
|
-
className,
|
|
998
|
-
...rest,
|
|
999
|
-
children: /* @__PURE__ */ jsx(BubbleMenuContext.Provider, {
|
|
1000
|
-
value: {
|
|
1001
|
-
editor,
|
|
1002
|
-
isEditing,
|
|
1003
|
-
setIsEditing
|
|
1004
|
-
},
|
|
1005
|
-
children
|
|
1006
|
-
})
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
//#endregion
|
|
1011
|
-
//#region src/ui/bubble-menu/button-default.tsx
|
|
1012
|
-
const buttonPluginKey = new PluginKey("buttonBubbleMenu");
|
|
1013
|
-
function BubbleMenuButtonDefaultInner({ validateUrl, onLinkApply, onLinkRemove }) {
|
|
1014
|
-
const { editor } = useBubbleMenuContext();
|
|
1015
|
-
const buttonHref = useEditorState({
|
|
1016
|
-
editor,
|
|
1017
|
-
selector: ({ editor: e }) => e?.getAttributes("button").href ?? ""
|
|
1018
|
-
});
|
|
1019
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(BubbleMenuButtonToolbar, { children: [/* @__PURE__ */ jsx(BubbleMenuButtonEditLink, {}), (buttonHref ?? "") !== "" && buttonHref !== "#" && /* @__PURE__ */ jsx(BubbleMenuButtonUnlink, { onLinkRemove })] }), /* @__PURE__ */ jsx(BubbleMenuButtonForm, {
|
|
1020
|
-
validateUrl,
|
|
1021
|
-
onLinkApply,
|
|
1022
|
-
onLinkRemove
|
|
1023
|
-
})] });
|
|
1024
|
-
}
|
|
1025
|
-
function BubbleMenuButtonDefault({ placement = "top", offset: offset$1, onHide, className, validateUrl, onLinkApply, onLinkRemove, ...rest }) {
|
|
1026
|
-
return /* @__PURE__ */ jsx(BubbleMenuRoot, {
|
|
1027
|
-
trigger: bubbleMenuTriggers.node("button"),
|
|
1028
|
-
pluginKey: buttonPluginKey,
|
|
1029
|
-
placement,
|
|
1030
|
-
offset: offset$1,
|
|
1031
|
-
onHide,
|
|
1032
|
-
className,
|
|
1033
|
-
...rest,
|
|
1034
|
-
children: /* @__PURE__ */ jsx(BubbleMenuButtonDefaultInner, {
|
|
1035
|
-
validateUrl,
|
|
1036
|
-
onLinkApply,
|
|
1037
|
-
onLinkRemove
|
|
1038
|
-
})
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
|
|
1042
|
-
//#endregion
|
|
1043
|
-
//#region src/ui/bubble-menu/item.tsx
|
|
1044
|
-
function BubbleMenuItem({ name, isActive, onCommand, className, children, ...rest }) {
|
|
1045
|
-
return /* @__PURE__ */ jsx("button", {
|
|
1046
|
-
type: "button",
|
|
1047
|
-
"aria-label": name,
|
|
1048
|
-
"aria-pressed": isActive,
|
|
1049
|
-
className,
|
|
1050
|
-
"data-re-bubble-menu-item": "",
|
|
1051
|
-
"data-item": name,
|
|
1052
|
-
...isActive ? { "data-active": "" } : {},
|
|
1053
|
-
onMouseDown: (e) => e.preventDefault(),
|
|
1054
|
-
onClick: onCommand,
|
|
1055
|
-
...rest,
|
|
1056
|
-
children
|
|
1057
|
-
});
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
//#endregion
|
|
1061
|
-
//#region src/ui/bubble-menu/align-center.tsx
|
|
1062
|
-
function BubbleMenuAlignCenter({ className, children }) {
|
|
1063
|
-
const { editor } = useBubbleMenuContext();
|
|
1064
|
-
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
1065
|
-
name: "align-center",
|
|
1066
|
-
isActive: useEditorState({
|
|
1067
|
-
editor,
|
|
1068
|
-
selector: ({ editor: editor$1 }) => editor$1?.isActive({ alignment: "center" }) ?? false
|
|
1069
|
-
}),
|
|
1070
|
-
onCommand: () => setTextAlignment(editor, "center"),
|
|
1071
|
-
className,
|
|
1072
|
-
children: children ?? /* @__PURE__ */ jsx(AlignCenterIcon, {})
|
|
1073
|
-
});
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
//#endregion
|
|
1077
|
-
//#region src/ui/bubble-menu/align-left.tsx
|
|
1078
|
-
function BubbleMenuAlignLeft({ className, children }) {
|
|
1079
|
-
const { editor } = useBubbleMenuContext();
|
|
1080
|
-
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
1081
|
-
name: "align-left",
|
|
1082
|
-
isActive: useEditorState({
|
|
1083
|
-
editor,
|
|
1084
|
-
selector: ({ editor: editor$1 }) => editor$1?.isActive({ alignment: "left" }) ?? false
|
|
1085
|
-
}),
|
|
1086
|
-
onCommand: () => setTextAlignment(editor, "left"),
|
|
1087
|
-
className,
|
|
1088
|
-
children: children ?? /* @__PURE__ */ jsx(AlignLeftIcon, {})
|
|
1089
|
-
});
|
|
1090
|
-
}
|
|
1091
|
-
|
|
1092
|
-
//#endregion
|
|
1093
|
-
//#region src/ui/bubble-menu/align-right.tsx
|
|
1094
|
-
function BubbleMenuAlignRight({ className, children }) {
|
|
1095
|
-
const { editor } = useBubbleMenuContext();
|
|
1096
|
-
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
1097
|
-
name: "align-right",
|
|
1098
|
-
isActive: useEditorState({
|
|
1099
|
-
editor,
|
|
1100
|
-
selector: ({ editor: editor$1 }) => editor$1?.isActive({ alignment: "right" }) ?? false
|
|
1101
|
-
}),
|
|
1102
|
-
onCommand: () => setTextAlignment(editor, "right"),
|
|
1103
|
-
className,
|
|
1104
|
-
children: children ?? /* @__PURE__ */ jsx(AlignRightIcon, {})
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
//#endregion
|
|
1109
|
-
//#region src/ui/bubble-menu/create-mark-bubble-item.tsx
|
|
1110
|
-
function createMarkBubbleItem(config) {
|
|
1111
|
-
function MarkBubbleItem({ className, children }) {
|
|
1112
|
-
const { editor } = useBubbleMenuContext();
|
|
1113
|
-
const isActive = useEditorState({
|
|
1114
|
-
editor,
|
|
1115
|
-
selector: ({ editor: editor$1 }) => {
|
|
1116
|
-
if (config.activeParams) return editor$1?.isActive(config.activeName, config.activeParams) ?? false;
|
|
1117
|
-
return editor$1?.isActive(config.activeName) ?? false;
|
|
1118
|
-
}
|
|
1119
|
-
});
|
|
1120
|
-
const handleCommand = () => {
|
|
1121
|
-
const chain = editor.chain().focus();
|
|
1122
|
-
const method = chain[config.command];
|
|
1123
|
-
if (method) method.call(chain).run();
|
|
1124
|
-
};
|
|
1125
|
-
return /* @__PURE__ */ jsx(BubbleMenuItem, {
|
|
1126
|
-
name: config.name,
|
|
1127
|
-
isActive,
|
|
1128
|
-
onCommand: handleCommand,
|
|
1129
|
-
className,
|
|
1130
|
-
children: children ?? config.icon
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
MarkBubbleItem.displayName = `BubbleMenu${config.name.charAt(0).toUpperCase() + config.name.slice(1)}`;
|
|
1134
|
-
return MarkBubbleItem;
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
//#endregion
|
|
1138
|
-
//#region src/ui/bubble-menu/bold.tsx
|
|
1139
|
-
const BubbleMenuBold = createMarkBubbleItem({
|
|
1140
|
-
name: "bold",
|
|
1141
|
-
activeName: "bold",
|
|
1142
|
-
command: "toggleBold",
|
|
1143
|
-
icon: /* @__PURE__ */ jsx(BoldIcon, {})
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
1059
|
//#endregion
|
|
1147
1060
|
//#region src/ui/bubble-menu/code.tsx
|
|
1148
1061
|
const BubbleMenuCode = createMarkBubbleItem({
|
|
@@ -1492,6 +1405,28 @@ const BubbleMenuStrike = createMarkBubbleItem({
|
|
|
1492
1405
|
icon: /* @__PURE__ */ jsx(StrikethroughIcon, {})
|
|
1493
1406
|
});
|
|
1494
1407
|
|
|
1408
|
+
//#endregion
|
|
1409
|
+
//#region src/ui/bubble-menu/triggers.ts
|
|
1410
|
+
const bubbleMenuTriggers = {
|
|
1411
|
+
textSelection(hideWhenActiveNodes = [], hideWhenActiveMarks = []) {
|
|
1412
|
+
return ({ editor, state }) => {
|
|
1413
|
+
for (const node of hideWhenActiveNodes) {
|
|
1414
|
+
if (editor.isActive(node)) return false;
|
|
1415
|
+
const { $from } = state.selection;
|
|
1416
|
+
for (let d = $from.depth; d > 0; d--) if ($from.node(d).type.name === node) return false;
|
|
1417
|
+
}
|
|
1418
|
+
for (const mark of hideWhenActiveMarks) if (editor.isActive(mark)) return false;
|
|
1419
|
+
return editor.view.state.selection.content().size > 0;
|
|
1420
|
+
};
|
|
1421
|
+
},
|
|
1422
|
+
node(name) {
|
|
1423
|
+
return ({ editor }) => editor.isActive(name);
|
|
1424
|
+
},
|
|
1425
|
+
nodeWithoutSelection(name) {
|
|
1426
|
+
return ({ editor }) => editor.isActive(name) && editor.view.state.selection.content().size === 0;
|
|
1427
|
+
}
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1495
1430
|
//#endregion
|
|
1496
1431
|
//#region src/ui/bubble-menu/underline.tsx
|
|
1497
1432
|
const BubbleMenuUnderline = createMarkBubbleItem({
|
|
@@ -1511,12 +1446,42 @@ const BubbleMenuUppercase = createMarkBubbleItem({
|
|
|
1511
1446
|
});
|
|
1512
1447
|
|
|
1513
1448
|
//#endregion
|
|
1514
|
-
//#region src/ui/bubble-menu/
|
|
1449
|
+
//#region src/ui/bubble-menu/root.tsx
|
|
1450
|
+
const defaultPluginKey = new PluginKey("bubbleMenu");
|
|
1451
|
+
function Root({ trigger, pluginKey: pluginKey$1 = defaultPluginKey, hideWhenActiveNodes = [], hideWhenActiveMarks = [], placement = "bottom", offset: offset$1 = 8, onHide, className, children, ...rest }) {
|
|
1452
|
+
const { editor } = useCurrentEditor();
|
|
1453
|
+
const [isEditing, setIsEditing] = React$1.useState(false);
|
|
1454
|
+
const resolvedTrigger = trigger ?? bubbleMenuTriggers.textSelection(hideWhenActiveNodes, hideWhenActiveMarks);
|
|
1455
|
+
if (!editor) return null;
|
|
1456
|
+
return /* @__PURE__ */ jsx(BubbleMenu, {
|
|
1457
|
+
editor,
|
|
1458
|
+
pluginKey: pluginKey$1,
|
|
1459
|
+
"data-re-bubble-menu": "",
|
|
1460
|
+
shouldShow: resolvedTrigger,
|
|
1461
|
+
options: {
|
|
1462
|
+
placement,
|
|
1463
|
+
offset: offset$1,
|
|
1464
|
+
onHide: () => {
|
|
1465
|
+
setIsEditing(false);
|
|
1466
|
+
onHide?.();
|
|
1467
|
+
}
|
|
1468
|
+
},
|
|
1469
|
+
className,
|
|
1470
|
+
...rest,
|
|
1471
|
+
children: /* @__PURE__ */ jsx(BubbleMenuContext.Provider, {
|
|
1472
|
+
value: {
|
|
1473
|
+
editor,
|
|
1474
|
+
isEditing,
|
|
1475
|
+
setIsEditing
|
|
1476
|
+
},
|
|
1477
|
+
children
|
|
1478
|
+
})
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1515
1481
|
const textPluginKey = new PluginKey("textBubbleMenu");
|
|
1516
|
-
function
|
|
1482
|
+
function Default({ hideWhenActiveNodes, hideWhenActiveMarks, placement, offset: offset$1, onHide, className, ...rest }) {
|
|
1517
1483
|
const [isNodeSelectorOpen, setIsNodeSelectorOpen] = React$1.useState(false);
|
|
1518
1484
|
const [isLinkSelectorOpen, setIsLinkSelectorOpen] = React$1.useState(false);
|
|
1519
|
-
const has = (item) => !excludeItems.includes(item);
|
|
1520
1485
|
const handleNodeSelectorOpenChange = React$1.useCallback((open) => {
|
|
1521
1486
|
setIsNodeSelectorOpen(open);
|
|
1522
1487
|
if (open) setIsLinkSelectorOpen(false);
|
|
@@ -1525,47 +1490,83 @@ function BubbleMenuDefault({ excludeItems = [], hideWhenActiveNodes, hideWhenAct
|
|
|
1525
1490
|
setIsLinkSelectorOpen(open);
|
|
1526
1491
|
if (open) setIsNodeSelectorOpen(false);
|
|
1527
1492
|
}, []);
|
|
1528
|
-
|
|
1529
|
-
setIsNodeSelectorOpen(false);
|
|
1530
|
-
setIsLinkSelectorOpen(false);
|
|
1531
|
-
onHide?.();
|
|
1532
|
-
}, [onHide]);
|
|
1533
|
-
const hasFormattingItems = has("bold") || has("italic") || has("underline") || has("strike") || has("code") || has("uppercase");
|
|
1534
|
-
const hasAlignmentItems = has("align-left") || has("align-center") || has("align-right");
|
|
1535
|
-
return /* @__PURE__ */ jsxs(BubbleMenuRoot, {
|
|
1493
|
+
return /* @__PURE__ */ jsxs(Root, {
|
|
1536
1494
|
pluginKey: textPluginKey,
|
|
1537
1495
|
hideWhenActiveNodes,
|
|
1538
1496
|
hideWhenActiveMarks,
|
|
1539
1497
|
placement,
|
|
1540
1498
|
offset: offset$1,
|
|
1541
|
-
onHide:
|
|
1499
|
+
onHide: React$1.useCallback(() => {
|
|
1500
|
+
setIsNodeSelectorOpen(false);
|
|
1501
|
+
setIsLinkSelectorOpen(false);
|
|
1502
|
+
onHide?.();
|
|
1503
|
+
}, [onHide]),
|
|
1542
1504
|
className,
|
|
1543
1505
|
...rest,
|
|
1544
1506
|
children: [
|
|
1545
|
-
|
|
1507
|
+
/* @__PURE__ */ jsx(BubbleMenuNodeSelector, {
|
|
1546
1508
|
open: isNodeSelectorOpen,
|
|
1547
1509
|
onOpenChange: handleNodeSelectorOpenChange
|
|
1548
1510
|
}),
|
|
1549
|
-
|
|
1511
|
+
/* @__PURE__ */ jsx(BubbleMenuLinkSelector, {
|
|
1550
1512
|
open: isLinkSelectorOpen,
|
|
1551
1513
|
onOpenChange: handleLinkSelectorOpenChange
|
|
1552
1514
|
}),
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1515
|
+
/* @__PURE__ */ jsxs(BubbleMenuItemGroup, { children: [
|
|
1516
|
+
/* @__PURE__ */ jsx(BubbleMenuBold, {}),
|
|
1517
|
+
/* @__PURE__ */ jsx(BubbleMenuItalic, {}),
|
|
1518
|
+
/* @__PURE__ */ jsx(BubbleMenuUnderline, {}),
|
|
1519
|
+
/* @__PURE__ */ jsx(BubbleMenuStrike, {}),
|
|
1520
|
+
/* @__PURE__ */ jsx(BubbleMenuCode, {}),
|
|
1521
|
+
/* @__PURE__ */ jsx(BubbleMenuUppercase, {})
|
|
1560
1522
|
] }),
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1523
|
+
/* @__PURE__ */ jsxs(BubbleMenuItemGroup, { children: [
|
|
1524
|
+
/* @__PURE__ */ jsx(BubbleMenuAlignLeft, {}),
|
|
1525
|
+
/* @__PURE__ */ jsx(BubbleMenuAlignCenter, {}),
|
|
1526
|
+
/* @__PURE__ */ jsx(BubbleMenuAlignRight, {})
|
|
1565
1527
|
] })
|
|
1566
1528
|
]
|
|
1567
1529
|
});
|
|
1568
1530
|
}
|
|
1531
|
+
function RootWithDefault({ children, ...rest }) {
|
|
1532
|
+
if (children) return /* @__PURE__ */ jsx(Root, {
|
|
1533
|
+
...rest,
|
|
1534
|
+
children
|
|
1535
|
+
});
|
|
1536
|
+
return /* @__PURE__ */ jsx(Default, { ...rest });
|
|
1537
|
+
}
|
|
1538
|
+
|
|
1539
|
+
//#endregion
|
|
1540
|
+
//#region src/ui/bubble-menu/button-default.tsx
|
|
1541
|
+
const buttonPluginKey = new PluginKey("buttonBubbleMenu");
|
|
1542
|
+
function BubbleMenuButtonDefaultInner({ validateUrl, onLinkApply, onLinkRemove }) {
|
|
1543
|
+
const { editor } = useBubbleMenuContext();
|
|
1544
|
+
const buttonHref = useEditorState({
|
|
1545
|
+
editor,
|
|
1546
|
+
selector: ({ editor: e }) => e?.getAttributes("button").href ?? ""
|
|
1547
|
+
});
|
|
1548
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(BubbleMenuButtonToolbar, { children: [/* @__PURE__ */ jsx(BubbleMenuButtonEditLink, {}), (buttonHref ?? "") !== "" && buttonHref !== "#" && /* @__PURE__ */ jsx(BubbleMenuButtonUnlink, { onLinkRemove })] }), /* @__PURE__ */ jsx(BubbleMenuButtonForm, {
|
|
1549
|
+
validateUrl,
|
|
1550
|
+
onLinkApply,
|
|
1551
|
+
onLinkRemove
|
|
1552
|
+
})] });
|
|
1553
|
+
}
|
|
1554
|
+
function BubbleMenuButtonDefault({ placement = "top", offset: offset$1, onHide, className, validateUrl, onLinkApply, onLinkRemove, ...rest }) {
|
|
1555
|
+
return /* @__PURE__ */ jsx(RootWithDefault, {
|
|
1556
|
+
trigger: bubbleMenuTriggers.node("button"),
|
|
1557
|
+
pluginKey: buttonPluginKey,
|
|
1558
|
+
placement,
|
|
1559
|
+
offset: offset$1,
|
|
1560
|
+
onHide,
|
|
1561
|
+
className,
|
|
1562
|
+
...rest,
|
|
1563
|
+
children: /* @__PURE__ */ jsx(BubbleMenuButtonDefaultInner, {
|
|
1564
|
+
validateUrl,
|
|
1565
|
+
onLinkApply,
|
|
1566
|
+
onLinkRemove
|
|
1567
|
+
})
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1569
1570
|
|
|
1570
1571
|
//#endregion
|
|
1571
1572
|
//#region src/ui/bubble-menu/image-edit-link.tsx
|
|
@@ -1607,7 +1608,7 @@ function BubbleMenuImageToolbar({ children, ...rest }) {
|
|
|
1607
1608
|
const imagePluginKey = new PluginKey("imageBubbleMenu");
|
|
1608
1609
|
function BubbleMenuImageDefault({ excludeItems = [], placement = "top", offset: offset$1, onHide, className, ...rest }) {
|
|
1609
1610
|
const hasEditLink = !excludeItems.includes("edit-link");
|
|
1610
|
-
return /* @__PURE__ */ jsx(
|
|
1611
|
+
return /* @__PURE__ */ jsx(RootWithDefault, {
|
|
1611
1612
|
trigger: bubbleMenuTriggers.node("image"),
|
|
1612
1613
|
pluginKey: imagePluginKey,
|
|
1613
1614
|
placement,
|
|
@@ -1814,7 +1815,7 @@ const linkPluginKey = new PluginKey("linkBubbleMenu");
|
|
|
1814
1815
|
function BubbleMenuLinkDefault({ excludeItems = [], placement = "top", offset: offset$1, onHide, className, validateUrl, onLinkApply, onLinkRemove, ...rest }) {
|
|
1815
1816
|
const has = (item) => !excludeItems.includes(item);
|
|
1816
1817
|
const hasToolbarItems = has("edit-link") || has("open-link") || has("unlink");
|
|
1817
|
-
return /* @__PURE__ */ jsxs(
|
|
1818
|
+
return /* @__PURE__ */ jsxs(RootWithDefault, {
|
|
1818
1819
|
trigger: bubbleMenuTriggers.nodeWithoutSelection("link"),
|
|
1819
1820
|
pluginKey: linkPluginKey,
|
|
1820
1821
|
placement,
|
|
@@ -1834,6 +1835,53 @@ function BubbleMenuLinkDefault({ excludeItems = [], placement = "top", offset: o
|
|
|
1834
1835
|
});
|
|
1835
1836
|
}
|
|
1836
1837
|
|
|
1838
|
+
//#endregion
|
|
1839
|
+
//#region src/ui/bubble-menu/separator.tsx
|
|
1840
|
+
function BubbleMenuSeparator({ className }) {
|
|
1841
|
+
return /* @__PURE__ */ jsx("hr", {
|
|
1842
|
+
className,
|
|
1843
|
+
"data-re-bubble-menu-separator": ""
|
|
1844
|
+
});
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
//#endregion
|
|
1848
|
+
//#region src/ui/bubble-menu/index.ts
|
|
1849
|
+
const BubbleMenu$1 = Object.assign(RootWithDefault, {
|
|
1850
|
+
Root: RootWithDefault,
|
|
1851
|
+
ItemGroup: BubbleMenuItemGroup,
|
|
1852
|
+
Separator: BubbleMenuSeparator,
|
|
1853
|
+
Item: BubbleMenuItem,
|
|
1854
|
+
Bold: BubbleMenuBold,
|
|
1855
|
+
Italic: BubbleMenuItalic,
|
|
1856
|
+
Underline: BubbleMenuUnderline,
|
|
1857
|
+
Strike: BubbleMenuStrike,
|
|
1858
|
+
Code: BubbleMenuCode,
|
|
1859
|
+
Uppercase: BubbleMenuUppercase,
|
|
1860
|
+
AlignLeft: BubbleMenuAlignLeft,
|
|
1861
|
+
AlignCenter: BubbleMenuAlignCenter,
|
|
1862
|
+
AlignRight: BubbleMenuAlignRight,
|
|
1863
|
+
NodeSelector: Object.assign(BubbleMenuNodeSelector, {
|
|
1864
|
+
Root: NodeSelectorRoot,
|
|
1865
|
+
Trigger: NodeSelectorTrigger,
|
|
1866
|
+
Content: NodeSelectorContent
|
|
1867
|
+
}),
|
|
1868
|
+
LinkSelector: BubbleMenuLinkSelector,
|
|
1869
|
+
ButtonToolbar: BubbleMenuButtonToolbar,
|
|
1870
|
+
ButtonEditLink: BubbleMenuButtonEditLink,
|
|
1871
|
+
ButtonUnlink: BubbleMenuButtonUnlink,
|
|
1872
|
+
ButtonForm: BubbleMenuButtonForm,
|
|
1873
|
+
ButtonDefault: BubbleMenuButtonDefault,
|
|
1874
|
+
LinkToolbar: BubbleMenuLinkToolbar,
|
|
1875
|
+
LinkEditLink: BubbleMenuLinkEditLink,
|
|
1876
|
+
LinkUnlink: BubbleMenuLinkUnlink,
|
|
1877
|
+
LinkOpenLink: BubbleMenuLinkOpenLink,
|
|
1878
|
+
LinkForm: BubbleMenuLinkForm,
|
|
1879
|
+
LinkDefault: BubbleMenuLinkDefault,
|
|
1880
|
+
ImageToolbar: BubbleMenuImageToolbar,
|
|
1881
|
+
ImageEditLink: BubbleMenuImageEditLink,
|
|
1882
|
+
ImageDefault: BubbleMenuImageDefault
|
|
1883
|
+
});
|
|
1884
|
+
|
|
1837
1885
|
//#endregion
|
|
1838
1886
|
//#region src/ui/slash-command/utils.ts
|
|
1839
1887
|
function isInsideNode(editor, type) {
|
|
@@ -2311,5 +2359,5 @@ function SlashCommandRoot({ items: itemsProp, filterItems: filterItemsProp, char
|
|
|
2311
2359
|
}
|
|
2312
2360
|
|
|
2313
2361
|
//#endregion
|
|
2314
|
-
export {
|
|
2315
|
-
//# sourceMappingURL=root-
|
|
2362
|
+
export { BubbleMenuAlignLeft as $, BubbleMenuImageDefault as A, AlignLeftIcon as At, NodeSelectorContent as B, BubbleMenuSeparator as C, Columns2Icon as Ct, BubbleMenuLinkOpenLink as D, CaseUpperIcon as Dt, BubbleMenuLinkToolbar as E, CheckIcon as Et, BubbleMenuUppercase as F, BubbleMenuItemGroup as G, NodeSelectorTrigger as H, BubbleMenuUnderline as I, BubbleMenuButtonToolbar as J, BubbleMenuCode as K, bubbleMenuTriggers as L, BubbleMenuImageEditLink as M, BubbleMenuButtonDefault as N, BubbleMenuLinkForm as O, BoldIcon as Ot, RootWithDefault as P, BubbleMenuAlignRight as Q, BubbleMenuStrike as R, BubbleMenu$1 as S, Columns3Icon as St, BubbleMenuLinkUnlink as T, ChevronDownIcon as Tt, BubbleMenuLinkSelector as U, NodeSelectorRoot as V, BubbleMenuItalic as W, BubbleMenuButtonEditLink as X, BubbleMenuButtonForm as Y, BubbleMenuBold as Z, TWO_COLUMNS as _, Heading3Icon as _t, BUTTON as a, TextQuoteIcon as at, isAtMaxColumnsDepth as b, ExternalLinkIcon as bt, FOUR_COLUMNS as c, SquareCodeIcon as ct, H3 as d, PencilIcon as dt, BubbleMenuAlignCenter as et, NUMBERED_LIST as f, MousePointerIcon as ft, THREE_COLUMNS as g, ItalicIcon as gt, TEXT as h, LinkIcon as ht, BULLET_LIST as i, UnderlineIcon as it, BubbleMenuImageToolbar as j, AlignCenterIcon as jt, BubbleMenuLinkEditLink as k, AlignRightIcon as kt, H1 as l, SplitSquareVerticalIcon as lt, SECTION as m, ListIcon as mt, filterAndRankItems as n, useBubbleMenuContext as nt, CODE as o, TextIcon as ot, QUOTE as p, ListOrderedIcon as pt, BubbleMenuButtonUnlink as q, scoreItem as r, UnlinkIcon as rt, DIVIDER as s, StrikethroughIcon as st, SlashCommandRoot as t, BubbleMenuItem as tt, H2 as u, Rows2Icon as ut, defaultSlashCommands as v, Heading2Icon as vt, BubbleMenuLinkDefault as w, CodeIcon as wt, isInsideNode as x, Columns4Icon as xt, CommandList as y, Heading1Icon as yt, BubbleMenuNodeSelector as z };
|
|
2363
|
+
//# sourceMappingURL=root-DCHEkXs2.mjs.map
|