@monolith-forensics/monolith-ui 1.9.1-dev.1 → 1.9.1-dev.11
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/DropDownMenu/components/MenuItemList.js +32 -12
- package/dist/DropDownMenu/components/StyledInnerItemContainer.js +1 -0
- package/dist/MonolithUIProvider/MonolithUIProvider.d.ts +23 -0
- package/dist/RichTextEditor/Components/BubbleMenu.d.ts +8 -8
- package/dist/RichTextEditor/Components/BubbleMenu.js +195 -93
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.d.ts +18 -0
- package/dist/RichTextEditor/Components/CodeBlockBaseButton.js +6 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockCopyButton.js +42 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockFormatButton.js +60 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.d.ts +9 -0
- package/dist/RichTextEditor/Components/CodeBlockLanguageSelect.js +30 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.d.ts +3 -0
- package/dist/RichTextEditor/Components/CodeBlockNodeView.js +28 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.d.ts +10 -0
- package/dist/RichTextEditor/Components/CodeBlockWrapButton.js +17 -0
- package/dist/RichTextEditor/Components/LinkEditor.d.ts +8 -0
- package/dist/RichTextEditor/Components/LinkEditor.js +94 -0
- package/dist/RichTextEditor/Enums/Controls.d.ts +5 -1
- package/dist/RichTextEditor/Enums/Controls.js +4 -0
- package/dist/RichTextEditor/Enums/Extensions.d.ts +4 -0
- package/dist/RichTextEditor/Enums/Extensions.js +4 -0
- package/dist/RichTextEditor/Enums/HighlightColors.d.ts +9 -0
- package/dist/RichTextEditor/Enums/HighlightColors.js +10 -0
- package/dist/RichTextEditor/Enums/SlashCommands.d.ts +2 -0
- package/dist/RichTextEditor/Enums/SlashCommands.js +2 -0
- package/dist/RichTextEditor/Extensions/SlashCommandList.js +0 -1
- package/dist/RichTextEditor/Extensions/getSlashCommand.js +25 -1
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.d.ts +10 -2
- package/dist/RichTextEditor/Extensions/getTiptapExtensions.js +158 -31
- package/dist/RichTextEditor/Plugins/ImageActionsPlugin.js +6 -109
- package/dist/RichTextEditor/Plugins/UploadImagesPlugin.js +1 -0
- package/dist/RichTextEditor/RichTextEditor.d.ts +4 -2
- package/dist/RichTextEditor/RichTextEditor.js +323 -13
- package/dist/RichTextEditor/Toolbar/Control.d.ts +6 -2
- package/dist/RichTextEditor/Toolbar/Control.js +13 -6
- package/dist/RichTextEditor/Toolbar/Controls.d.ts +2 -0
- package/dist/RichTextEditor/Toolbar/Controls.js +14 -0
- package/dist/RichTextEditor/Toolbar/ControlsGroup.js +1 -0
- package/dist/RichTextEditor/Toolbar/Toolbar.js +61 -9
- package/dist/RichTextEditor/Utils/codeBlockUtils.d.ts +20 -0
- package/dist/RichTextEditor/Utils/codeBlockUtils.js +137 -0
- package/dist/RichTextEditor/Utils/codeUtils.d.ts +3 -0
- package/dist/RichTextEditor/Utils/codeUtils.js +12 -0
- package/dist/RichTextEditor/Utils/linkUtils.d.ts +19 -0
- package/dist/RichTextEditor/Utils/linkUtils.js +57 -0
- package/dist/theme/variants.js +46 -0
- package/package.json +8 -1
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.d.ts +0 -7
- package/dist/RichTextEditor/Extensions/BubbleMenuExtension.js +0 -157
|
@@ -1,22 +1,45 @@
|
|
|
1
1
|
import TiptapImage from "@tiptap/extension-image";
|
|
2
2
|
import StarterKit from "@tiptap/starter-kit";
|
|
3
|
+
import { CodeBlockLowlight } from "@tiptap/extension-code-block-lowlight";
|
|
3
4
|
import HorizontalRule from "@tiptap/extension-horizontal-rule";
|
|
4
5
|
import TextAlign from "@tiptap/extension-text-align";
|
|
5
|
-
import { Table, TableCell, TableHeader, TableRow } from "@tiptap/extension-table";
|
|
6
|
+
import { Table, TableCell, TableHeader, TableRow, } from "@tiptap/extension-table";
|
|
6
7
|
import { Focus, Placeholder } from "@tiptap/extensions";
|
|
7
8
|
import { Color } from "@tiptap/extension-color";
|
|
9
|
+
import { Highlight } from "@tiptap/extension-highlight";
|
|
10
|
+
import { Link } from "@tiptap/extension-link";
|
|
8
11
|
import { TextStyle } from "@tiptap/extension-text-style";
|
|
9
12
|
import { InputRule, Extension } from "@tiptap/core";
|
|
13
|
+
import { ReactNodeViewRenderer } from "@tiptap/react";
|
|
14
|
+
import { common, createLowlight } from "lowlight";
|
|
10
15
|
import { ImageActionsPlugin, UploadImagesPlugin, } from "../Plugins";
|
|
11
16
|
import getSlashCommand from "./getSlashCommand";
|
|
12
17
|
import { Extensions } from "../Enums";
|
|
13
|
-
import
|
|
18
|
+
import { LINK_REL, LINK_TARGET, normalizeLinkUrl } from "../Utils/linkUtils";
|
|
19
|
+
import CodeBlockNodeView from "../Components/CodeBlockNodeView";
|
|
20
|
+
import { DEFAULT_CODE_BLOCK_LANGUAGE } from "../Utils/codeBlockUtils";
|
|
21
|
+
const lowlight = createLowlight(common);
|
|
22
|
+
const CustomCodeBlockLowlight = CodeBlockLowlight.extend({
|
|
23
|
+
addAttributes() {
|
|
24
|
+
var _a;
|
|
25
|
+
return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { wrap: {
|
|
26
|
+
default: false,
|
|
27
|
+
parseHTML: (element) => element.getAttribute("data-wrap") === "true",
|
|
28
|
+
renderHTML: (attributes) => attributes.wrap ? { "data-wrap": "true" } : {},
|
|
29
|
+
} });
|
|
30
|
+
},
|
|
31
|
+
addNodeView() {
|
|
32
|
+
return ReactNodeViewRenderer(CodeBlockNodeView);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
14
35
|
const CustomImage = TiptapImage.extend({
|
|
15
36
|
// Add data-uuid attribute to image
|
|
16
37
|
addAttributes() {
|
|
17
38
|
var _a;
|
|
18
39
|
return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { "data-uuid": {
|
|
19
40
|
default: null,
|
|
41
|
+
}, crossorigin: {
|
|
42
|
+
default: "anonymous",
|
|
20
43
|
} });
|
|
21
44
|
},
|
|
22
45
|
addProseMirrorPlugins() {
|
|
@@ -40,27 +63,107 @@ const CustomStorage = Extension.create({
|
|
|
40
63
|
};
|
|
41
64
|
},
|
|
42
65
|
});
|
|
43
|
-
const
|
|
66
|
+
export const BASIC_EXTENSIONS = [
|
|
67
|
+
Extensions.Bold,
|
|
68
|
+
Extensions.Italic,
|
|
69
|
+
Extensions.Underline,
|
|
70
|
+
Extensions.Strike,
|
|
71
|
+
Extensions.Code,
|
|
72
|
+
Extensions.BulletList,
|
|
73
|
+
Extensions.OrderedList,
|
|
74
|
+
Extensions.TextStyle,
|
|
75
|
+
Extensions.Color,
|
|
76
|
+
Extensions.Highlight,
|
|
77
|
+
Extensions.Link,
|
|
78
|
+
Extensions.TextAlign,
|
|
79
|
+
Extensions.Focus,
|
|
80
|
+
Extensions.CustomStorage,
|
|
81
|
+
];
|
|
82
|
+
export const MINIMAL_EXTENSIONS = [
|
|
83
|
+
Extensions.Focus,
|
|
84
|
+
Extensions.CustomStorage,
|
|
85
|
+
];
|
|
86
|
+
export const FULL_EXTENSIONS = [
|
|
87
|
+
...BASIC_EXTENSIONS,
|
|
88
|
+
Extensions.CodeBlock,
|
|
89
|
+
Extensions.HorizontalRule,
|
|
90
|
+
Extensions.Table,
|
|
91
|
+
Extensions.TableCell,
|
|
92
|
+
Extensions.TableHeader,
|
|
93
|
+
Extensions.TableRow,
|
|
94
|
+
Extensions.Placeholder,
|
|
95
|
+
Extensions.SlashCommand,
|
|
96
|
+
Extensions.BubbleMenu,
|
|
97
|
+
];
|
|
98
|
+
const EXTENSION_PRESETS = {
|
|
99
|
+
minimal: MINIMAL_EXTENSIONS,
|
|
100
|
+
basic: BASIC_EXTENSIONS,
|
|
101
|
+
full: FULL_EXTENSIONS,
|
|
102
|
+
};
|
|
103
|
+
export const resolveExtensions = ({ disabledExtensions = [], extensionPreset = "basic", extensions = [], }) => {
|
|
104
|
+
const disabled = new Set(disabledExtensions);
|
|
105
|
+
const resolved = new Set([
|
|
106
|
+
...(EXTENSION_PRESETS[extensionPreset] || BASIC_EXTENSIONS),
|
|
107
|
+
...extensions,
|
|
108
|
+
]);
|
|
109
|
+
if (resolved.has(Extensions.Color)) {
|
|
110
|
+
resolved.add(Extensions.TextStyle);
|
|
111
|
+
}
|
|
112
|
+
if (resolved.has(Extensions.Table)) {
|
|
113
|
+
resolved.add(Extensions.TableRow);
|
|
114
|
+
resolved.add(Extensions.TableCell);
|
|
115
|
+
resolved.add(Extensions.TableHeader);
|
|
116
|
+
}
|
|
117
|
+
disabled.forEach((extension) => resolved.delete(extension));
|
|
118
|
+
return Array.from(resolved);
|
|
119
|
+
};
|
|
120
|
+
const getTipTapExtensions = ({ disabledExtensions = [], extensions = [], slashCommands = [], handleImageUpload, }) => {
|
|
121
|
+
const disabled = new Set(disabledExtensions);
|
|
122
|
+
const enabled = new Set(extensions);
|
|
123
|
+
const isEnabled = (extension) => enabled.has(extension) && !disabled.has(extension);
|
|
44
124
|
return [
|
|
45
125
|
{
|
|
46
126
|
name: "starterKit",
|
|
47
|
-
category: "default",
|
|
48
127
|
extension: StarterKit.configure({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
128
|
+
bold: isEnabled(Extensions.Bold) ? {} : false,
|
|
129
|
+
italic: isEnabled(Extensions.Italic) ? {} : false,
|
|
130
|
+
underline: isEnabled(Extensions.Underline) ? {} : false,
|
|
131
|
+
strike: isEnabled(Extensions.Strike) ? {} : false,
|
|
132
|
+
bulletList: isEnabled(Extensions.BulletList)
|
|
133
|
+
? {
|
|
134
|
+
HTMLAttributes: {
|
|
135
|
+
class: "",
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
: false,
|
|
139
|
+
orderedList: isEnabled(Extensions.OrderedList)
|
|
140
|
+
? {
|
|
141
|
+
HTMLAttributes: {
|
|
142
|
+
class: "",
|
|
143
|
+
},
|
|
144
|
+
}
|
|
145
|
+
: false,
|
|
146
|
+
listItem: isEnabled(Extensions.BulletList) ||
|
|
147
|
+
isEnabled(Extensions.OrderedList)
|
|
148
|
+
? {
|
|
149
|
+
HTMLAttributes: {
|
|
150
|
+
class: "",
|
|
151
|
+
},
|
|
152
|
+
}
|
|
153
|
+
: false,
|
|
154
|
+
listKeymap: isEnabled(Extensions.BulletList) ||
|
|
155
|
+
isEnabled(Extensions.OrderedList)
|
|
156
|
+
? {}
|
|
157
|
+
: false,
|
|
158
|
+
link: false,
|
|
159
|
+
code: isEnabled(Extensions.Code)
|
|
160
|
+
? {
|
|
161
|
+
HTMLAttributes: {
|
|
162
|
+
class: "editor-inline-code",
|
|
163
|
+
},
|
|
164
|
+
}
|
|
165
|
+
: false,
|
|
166
|
+
codeBlock: false,
|
|
64
167
|
horizontalRule: false,
|
|
65
168
|
dropcursor: {
|
|
66
169
|
color: "#DBEAFE",
|
|
@@ -69,24 +172,53 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
|
|
|
69
172
|
gapcursor: false,
|
|
70
173
|
}),
|
|
71
174
|
},
|
|
175
|
+
{
|
|
176
|
+
name: Extensions.CodeBlock,
|
|
177
|
+
extension: CustomCodeBlockLowlight.configure({
|
|
178
|
+
lowlight,
|
|
179
|
+
defaultLanguage: DEFAULT_CODE_BLOCK_LANGUAGE,
|
|
180
|
+
enableTabIndentation: true,
|
|
181
|
+
HTMLAttributes: {
|
|
182
|
+
class: "editor-code-block",
|
|
183
|
+
},
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
72
186
|
{
|
|
73
187
|
name: Extensions.TextStyle,
|
|
74
|
-
category: "default",
|
|
75
188
|
extension: TextStyle,
|
|
76
189
|
},
|
|
77
190
|
{
|
|
78
191
|
name: Extensions.Color,
|
|
79
|
-
category: "default",
|
|
80
192
|
extension: Color,
|
|
81
193
|
},
|
|
194
|
+
{
|
|
195
|
+
name: Extensions.Highlight,
|
|
196
|
+
extension: Highlight.configure({ multicolor: true }),
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: Extensions.Link,
|
|
200
|
+
extension: Link.configure({
|
|
201
|
+
autolink: true,
|
|
202
|
+
linkOnPaste: true,
|
|
203
|
+
openOnClick: false,
|
|
204
|
+
enableClickSelection: false,
|
|
205
|
+
defaultProtocol: "https",
|
|
206
|
+
protocols: ["http", "https"],
|
|
207
|
+
isAllowedUri: (url) => normalizeLinkUrl(url).isValid,
|
|
208
|
+
shouldAutoLink: (url) => normalizeLinkUrl(url).isValid,
|
|
209
|
+
HTMLAttributes: {
|
|
210
|
+
class: "editor-link",
|
|
211
|
+
target: LINK_TARGET,
|
|
212
|
+
rel: LINK_REL,
|
|
213
|
+
},
|
|
214
|
+
}),
|
|
215
|
+
},
|
|
82
216
|
{
|
|
83
217
|
name: Extensions.TextAlign,
|
|
84
|
-
category: "default",
|
|
85
218
|
extension: TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
86
219
|
},
|
|
87
220
|
{
|
|
88
221
|
name: Extensions.Focus,
|
|
89
|
-
category: "default",
|
|
90
222
|
extension: Focus.configure({ className: "has-focus", mode: "all" }),
|
|
91
223
|
},
|
|
92
224
|
// patch to fix horizontal rule bug: https://github.com/ueberdosis/tiptap/pull/3859#issuecomment-1536799740
|
|
@@ -157,14 +289,8 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
|
|
|
157
289
|
},
|
|
158
290
|
{
|
|
159
291
|
name: Extensions.CustomStorage,
|
|
160
|
-
category: "default",
|
|
161
292
|
extension: CustomStorage,
|
|
162
293
|
},
|
|
163
|
-
{
|
|
164
|
-
name: Extensions.BubbleMenu,
|
|
165
|
-
category: "default",
|
|
166
|
-
extension: BubbleMenu.configure(bubbleMenuOptions),
|
|
167
|
-
},
|
|
168
294
|
{
|
|
169
295
|
name: Extensions.SlashCommand,
|
|
170
296
|
extension: getSlashCommand({
|
|
@@ -174,8 +300,9 @@ const getTipTapExtensions = ({ extensions = [], slashCommands = [], bubbleMenuOp
|
|
|
174
300
|
},
|
|
175
301
|
]
|
|
176
302
|
.filter((ext) => {
|
|
177
|
-
|
|
178
|
-
|
|
303
|
+
if (ext.name === "starterKit")
|
|
304
|
+
return true;
|
|
305
|
+
return isEnabled(ext.name);
|
|
179
306
|
})
|
|
180
307
|
.map((ext) => ext.extension);
|
|
181
308
|
};
|
|
@@ -60,123 +60,20 @@ const getImageFilename = (image) => {
|
|
|
60
60
|
return "image.png";
|
|
61
61
|
};
|
|
62
62
|
const getImageBlob = (src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
const response = yield fetch(src
|
|
64
|
-
mode: "cors",
|
|
65
|
-
credentials: "omit",
|
|
66
|
-
});
|
|
63
|
+
const response = yield fetch(src);
|
|
67
64
|
if (!response.ok) {
|
|
68
65
|
throw new Error("Unable to load image.");
|
|
69
66
|
}
|
|
70
|
-
return
|
|
71
|
-
blob: yield response.blob(),
|
|
72
|
-
contentType: response.headers.get("content-type") || "",
|
|
73
|
-
};
|
|
74
|
-
});
|
|
75
|
-
const clipboardPngType = "image/png";
|
|
76
|
-
const imageMimeTypesByExtension = {
|
|
77
|
-
gif: "image/gif",
|
|
78
|
-
jpg: "image/jpeg",
|
|
79
|
-
jpeg: "image/jpeg",
|
|
80
|
-
png: clipboardPngType,
|
|
81
|
-
svg: "image/svg+xml",
|
|
82
|
-
webp: "image/webp",
|
|
83
|
-
};
|
|
84
|
-
const normalizeMimeType = (type) => type.toLowerCase().split(";")[0].trim();
|
|
85
|
-
const getImageMimeTypeFromSource = (src) => {
|
|
86
|
-
var _a;
|
|
87
|
-
try {
|
|
88
|
-
const url = new URL(src);
|
|
89
|
-
const filename = url.pathname.split("/").filter(Boolean).pop();
|
|
90
|
-
const extension = (_a = filename === null || filename === void 0 ? void 0 : filename.split(".").pop()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
91
|
-
return extension ? imageMimeTypesByExtension[extension] || "" : "";
|
|
92
|
-
}
|
|
93
|
-
catch (_b) {
|
|
94
|
-
const dataUrlMatch = src.match(/^data:([^;,]+)/);
|
|
95
|
-
return (dataUrlMatch === null || dataUrlMatch === void 0 ? void 0 : dataUrlMatch[1]) || "";
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const canWriteClipboardType = (ClipboardItemCtor, type) => {
|
|
99
|
-
if (!type)
|
|
100
|
-
return false;
|
|
101
|
-
if (typeof ClipboardItemCtor.supports === "function") {
|
|
102
|
-
return ClipboardItemCtor.supports(type);
|
|
103
|
-
}
|
|
104
|
-
return type === clipboardPngType;
|
|
105
|
-
};
|
|
106
|
-
const loadImageSource = (src) => new Promise((resolve, reject) => {
|
|
107
|
-
const image = new Image();
|
|
108
|
-
image.crossOrigin = "anonymous";
|
|
109
|
-
image.onload = () => resolve(image);
|
|
110
|
-
image.onerror = () => {
|
|
111
|
-
reject(new Error("Unable to prepare image for clipboard."));
|
|
112
|
-
};
|
|
113
|
-
image.src = src;
|
|
114
|
-
});
|
|
115
|
-
const renderImageSourceToPngBlob = (src) => __awaiter(void 0, void 0, void 0, function* () {
|
|
116
|
-
const image = yield loadImageSource(src);
|
|
117
|
-
const width = image.naturalWidth || image.width;
|
|
118
|
-
const height = image.naturalHeight || image.height;
|
|
119
|
-
if (!width || !height) {
|
|
120
|
-
throw new Error("Unable to prepare image for clipboard.");
|
|
121
|
-
}
|
|
122
|
-
const canvas = document.createElement("canvas");
|
|
123
|
-
canvas.width = width;
|
|
124
|
-
canvas.height = height;
|
|
125
|
-
const context = canvas.getContext("2d");
|
|
126
|
-
if (!context) {
|
|
127
|
-
throw new Error("Unable to prepare image for clipboard.");
|
|
128
|
-
}
|
|
129
|
-
context.drawImage(image, 0, 0, width, height);
|
|
130
|
-
return new Promise((resolve, reject) => {
|
|
131
|
-
canvas.toBlob((blob) => {
|
|
132
|
-
if (blob) {
|
|
133
|
-
resolve(blob);
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
reject(new Error("Unable to prepare image for clipboard."));
|
|
137
|
-
}
|
|
138
|
-
}, clipboardPngType);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
const convertBlobToClipboardPng = (blob, fallbackSrc) => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
-
const objectUrl = URL.createObjectURL(blob);
|
|
143
|
-
try {
|
|
144
|
-
return yield renderImageSourceToPngBlob(objectUrl);
|
|
145
|
-
}
|
|
146
|
-
catch (error) {
|
|
147
|
-
if (!fallbackSrc || fallbackSrc === objectUrl)
|
|
148
|
-
throw error;
|
|
149
|
-
return renderImageSourceToPngBlob(fallbackSrc);
|
|
150
|
-
}
|
|
151
|
-
finally {
|
|
152
|
-
URL.revokeObjectURL(objectUrl);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
const getClipboardImageBlob = (image, ClipboardItemCtor) => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
-
const src = image.currentSrc || image.src;
|
|
157
|
-
const { blob, contentType } = yield getImageBlob(src);
|
|
158
|
-
const type = normalizeMimeType(blob.type) ||
|
|
159
|
-
normalizeMimeType(contentType) ||
|
|
160
|
-
getImageMimeTypeFromSource(src);
|
|
161
|
-
if (canWriteClipboardType(ClipboardItemCtor, type)) {
|
|
162
|
-
return {
|
|
163
|
-
blob: blob.type === type ? blob : new Blob([blob], { type }),
|
|
164
|
-
type,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
blob: yield convertBlobToClipboardPng(blob, src),
|
|
169
|
-
type: clipboardPngType,
|
|
170
|
-
};
|
|
67
|
+
return response.blob();
|
|
171
68
|
});
|
|
172
69
|
const copyImage = (image) => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
70
|
var _a;
|
|
174
|
-
const ClipboardItemCtor = window
|
|
175
|
-
.ClipboardItem;
|
|
71
|
+
const ClipboardItemCtor = window.ClipboardItem;
|
|
176
72
|
if (!((_a = navigator.clipboard) === null || _a === void 0 ? void 0 : _a.write) || !ClipboardItemCtor) {
|
|
177
73
|
throw new Error("Image copying is not supported by this browser.");
|
|
178
74
|
}
|
|
179
|
-
const
|
|
75
|
+
const blob = yield getImageBlob(image.src);
|
|
76
|
+
const type = blob.type || "image/png";
|
|
180
77
|
yield navigator.clipboard.write([
|
|
181
78
|
new ClipboardItemCtor({
|
|
182
79
|
[type]: blob,
|
|
@@ -188,7 +85,7 @@ const downloadImage = (image) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
188
85
|
let href = image.src;
|
|
189
86
|
let objectUrl = null;
|
|
190
87
|
try {
|
|
191
|
-
const
|
|
88
|
+
const blob = yield getImageBlob(image.src);
|
|
192
89
|
objectUrl = URL.createObjectURL(blob);
|
|
193
90
|
href = objectUrl;
|
|
194
91
|
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { Editor } from "@tiptap/react";
|
|
2
|
-
import { ExtensionType } from "./Extensions/getTiptapExtensions";
|
|
2
|
+
import { ExtensionPreset, ExtensionType } from "./Extensions/getTiptapExtensions";
|
|
3
3
|
import { HandleImageUrlUpload, HandleImageUpload } from "./Plugins/UploadImagesPlugin";
|
|
4
|
-
import { BubbleMenuOptions } from "./
|
|
4
|
+
import { BubbleMenuOptions } from "./Components/BubbleMenu";
|
|
5
5
|
import { ToolbarOptions } from "./Toolbar/Toolbar";
|
|
6
6
|
type RichTextEditorProps = {
|
|
7
7
|
className?: string;
|
|
8
8
|
editorInstanceRef?: React.RefObject<Editor | null>;
|
|
9
9
|
extensions?: ExtensionType[];
|
|
10
|
+
disabledExtensions?: ExtensionType[];
|
|
11
|
+
extensionPreset?: ExtensionPreset;
|
|
10
12
|
slashCommands?: any[];
|
|
11
13
|
defaultValue?: string;
|
|
12
14
|
value?: string;
|