@monolith-forensics/monolith-ui 1.1.50 → 1.1.52
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.
|
@@ -240,7 +240,7 @@ const BubbleMenu = ({ editor, rect, open, onOpen, customMenuItems = [], }) => {
|
|
|
240
240
|
}, [open, onOpen, elements.floating]);
|
|
241
241
|
const elementWidth = ((_a = elements.floating) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0;
|
|
242
242
|
const { from, to } = editor.state.selection;
|
|
243
|
-
const selectedText = editor.state.doc.textBetween(from, to);
|
|
243
|
+
const selectedText = editor.state.doc.textBetween(from, to, "\n");
|
|
244
244
|
let top = (rect === null || rect === void 0 ? void 0 : rect.top) ? rect.top - 50 : 0;
|
|
245
245
|
if (top < 10) {
|
|
246
246
|
top = 10; // add some padding
|
|
@@ -5,6 +5,7 @@ import { EditorContent, useEditor } from "@tiptap/react";
|
|
|
5
5
|
import Toolbar from "./Toolbar";
|
|
6
6
|
import getTipTapExtensions from "./Extensions/getTiptapExtensions";
|
|
7
7
|
import Extensions from "./Enums/Extensions";
|
|
8
|
+
import { startImageUpload, } from "./Plugins/UploadImagesPlugin";
|
|
8
9
|
import SaveBadge from "./Components/SaveBadge";
|
|
9
10
|
import Fonts from "./Enums/Fonts";
|
|
10
11
|
import RichTextEditorContext from "./Contexts/RichTextEditorContext";
|
|
@@ -26,6 +27,49 @@ const RichTextEditor = styled(forwardRef(({ className, editorInstanceRef, defaul
|
|
|
26
27
|
bubbleMenuOptions,
|
|
27
28
|
handleImageUpload,
|
|
28
29
|
}),
|
|
30
|
+
editorProps: {
|
|
31
|
+
handlePaste: (view, event) => {
|
|
32
|
+
if (!handleImageUpload)
|
|
33
|
+
return false;
|
|
34
|
+
if (!(event === null || event === void 0 ? void 0 : event.clipboardData))
|
|
35
|
+
return false;
|
|
36
|
+
if (event.clipboardData.types.includes("text/html") ||
|
|
37
|
+
event.clipboardData.types.includes("text/plain") ||
|
|
38
|
+
event.clipboardData.types.includes("text/rtf"))
|
|
39
|
+
return false;
|
|
40
|
+
if (event.clipboardData &&
|
|
41
|
+
event.clipboardData.files &&
|
|
42
|
+
event.clipboardData.files[0]) {
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
const file = event.clipboardData.files[0];
|
|
45
|
+
const pos = view.state.selection.from;
|
|
46
|
+
startImageUpload(file, view, pos, handleImageUpload);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
return false;
|
|
50
|
+
},
|
|
51
|
+
handleDrop: (view, event, _slice, moved) => {
|
|
52
|
+
if (!handleImageUpload)
|
|
53
|
+
return false;
|
|
54
|
+
if (!moved &&
|
|
55
|
+
event.dataTransfer &&
|
|
56
|
+
event.dataTransfer.files &&
|
|
57
|
+
event.dataTransfer.files[0]) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
const file = event.dataTransfer.files[0];
|
|
60
|
+
const coordinates = view.posAtCoords({
|
|
61
|
+
left: event.clientX,
|
|
62
|
+
top: event.clientY,
|
|
63
|
+
});
|
|
64
|
+
if (!coordinates)
|
|
65
|
+
return false;
|
|
66
|
+
// here we deduct 1 from the pos or else the image will create an extra node
|
|
67
|
+
startImageUpload(file, view, coordinates.pos - 1, handleImageUpload);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
return false;
|
|
71
|
+
},
|
|
72
|
+
},
|
|
29
73
|
onUpdate: ({ editor }) => {
|
|
30
74
|
onChange === null || onChange === void 0 ? void 0 : onChange(editor.getHTML());
|
|
31
75
|
},
|