@lumir-company/editor 0.4.7 → 0.4.9
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 +1465 -1299
- package/dist/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +22 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -17
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +977 -977
- package/package.json +93 -93
package/dist/index.mjs
CHANGED
|
@@ -2796,7 +2796,7 @@ var ALLOWED_VIDEO_EXTENSIONS = [
|
|
|
2796
2796
|
// src/components/LumirEditor.tsx
|
|
2797
2797
|
import { Fragment as Fragment5, jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2798
2798
|
var DEBUG_LOG = (loc, msg, data) => {
|
|
2799
|
-
fetch("http://127.0.0.1:7686/ingest/1f8ee1c5-0cf0-4ae7-91ed-5ea7ed17130a", {
|
|
2799
|
+
const p = fetch("http://127.0.0.1:7686/ingest/1f8ee1c5-0cf0-4ae7-91ed-5ea7ed17130a", {
|
|
2800
2800
|
method: "POST",
|
|
2801
2801
|
headers: { "Content-Type": "application/json", "X-Debug-Session-Id": "b73262" },
|
|
2802
2802
|
body: JSON.stringify({
|
|
@@ -2806,7 +2806,8 @@ var DEBUG_LOG = (loc, msg, data) => {
|
|
|
2806
2806
|
data,
|
|
2807
2807
|
timestamp: Date.now()
|
|
2808
2808
|
})
|
|
2809
|
-
})
|
|
2809
|
+
});
|
|
2810
|
+
if (p && typeof p.catch === "function") p.catch(() => {
|
|
2810
2811
|
});
|
|
2811
2812
|
};
|
|
2812
2813
|
var ContentUtils = class {
|
|
@@ -2927,8 +2928,9 @@ var EditorConfig = class {
|
|
|
2927
2928
|
return Array.from(set);
|
|
2928
2929
|
}
|
|
2929
2930
|
};
|
|
2930
|
-
var isImageFile = (file) => {
|
|
2931
|
-
|
|
2931
|
+
var isImageFile = (file, maxSize) => {
|
|
2932
|
+
const limit = maxSize !== void 0 ? maxSize : MAX_FILE_SIZE;
|
|
2933
|
+
if (file.size === 0 || file.size > limit) {
|
|
2932
2934
|
return false;
|
|
2933
2935
|
}
|
|
2934
2936
|
const fileName = file.name?.toLowerCase() || "";
|
|
@@ -2937,8 +2939,9 @@ var isImageFile = (file) => {
|
|
|
2937
2939
|
}
|
|
2938
2940
|
return file.type?.startsWith("image/") || !file.type && /\.(png|jpe?g|gif|webp|bmp)$/i.test(fileName);
|
|
2939
2941
|
};
|
|
2940
|
-
var isVideoFile = (file) => {
|
|
2941
|
-
const
|
|
2942
|
+
var isVideoFile = (file, maxSize) => {
|
|
2943
|
+
const limit = maxSize !== void 0 ? maxSize : MAX_VIDEO_FILE_SIZE;
|
|
2944
|
+
const sizeOk = file.size > 0 && file.size <= limit;
|
|
2942
2945
|
const fileName = file.name?.toLowerCase() || "";
|
|
2943
2946
|
const mimeMatch = ALLOWED_VIDEO_MIME_TYPES.has(file.type);
|
|
2944
2947
|
const videoPrefix = typeof file.type === "string" && file.type.startsWith("video/");
|
|
@@ -3079,6 +3082,8 @@ function LumirEditor({
|
|
|
3079
3082
|
allowVideoUpload = false,
|
|
3080
3083
|
allowAudioUpload = false,
|
|
3081
3084
|
allowFileUpload = false,
|
|
3085
|
+
maxImageFileSize,
|
|
3086
|
+
maxVideoFileSize,
|
|
3082
3087
|
// link preview
|
|
3083
3088
|
linkPreview,
|
|
3084
3089
|
// view options
|
|
@@ -3193,8 +3198,8 @@ function LumirEditor({
|
|
|
3193
3198
|
tabBehavior,
|
|
3194
3199
|
trailingBlock,
|
|
3195
3200
|
uploadFile: async (file) => {
|
|
3196
|
-
const allowedImage = isImageFile(file);
|
|
3197
|
-
const allowedVideo = allowVideoUpload && isVideoFile(file);
|
|
3201
|
+
const allowedImage = isImageFile(file, maxImageFileSize);
|
|
3202
|
+
const allowedVideo = allowVideoUpload && isVideoFile(file, maxVideoFileSize);
|
|
3198
3203
|
DEBUG_LOG("uploadFile:step1:entry", "editor uploadFile callback invoked", {
|
|
3199
3204
|
fileName: file.name,
|
|
3200
3205
|
fileType: file.type,
|
|
@@ -3288,7 +3293,7 @@ function LumirEditor({
|
|
|
3288
3293
|
const fileList = event?.clipboardData?.files ?? null;
|
|
3289
3294
|
const files = fileList ? Array.from(fileList) : [];
|
|
3290
3295
|
const acceptedFiles = files.filter(
|
|
3291
|
-
(f) => isImageFile(f) || allowVideoUpload && isVideoFile(f)
|
|
3296
|
+
(f) => isImageFile(f, maxImageFileSize) || allowVideoUpload && isVideoFile(f, maxVideoFileSize)
|
|
3292
3297
|
);
|
|
3293
3298
|
DEBUG_LOG("paste:step1:files", "paste clipboard files", {
|
|
3294
3299
|
filesCount: files.length,
|
|
@@ -3314,11 +3319,11 @@ function LumirEditor({
|
|
|
3314
3319
|
fileType: file.type
|
|
3315
3320
|
});
|
|
3316
3321
|
const url = await editor2.uploadFile(file);
|
|
3317
|
-
if (isImageFile(file)) {
|
|
3322
|
+
if (isImageFile(file, maxImageFileSize)) {
|
|
3318
3323
|
editor2.pasteHTML(
|
|
3319
3324
|
`<img src="${escapeHtml(url)}" alt="image" />`
|
|
3320
3325
|
);
|
|
3321
|
-
} else if (isVideoFile(file)) {
|
|
3326
|
+
} else if (isVideoFile(file, maxVideoFileSize)) {
|
|
3322
3327
|
const currentBlock = editor2.getTextCursorPosition().block;
|
|
3323
3328
|
editor2.insertBlocks(
|
|
3324
3329
|
[{ type: "video", props: { url } }],
|
|
@@ -3411,8 +3416,8 @@ function LumirEditor({
|
|
|
3411
3416
|
e.stopPropagation();
|
|
3412
3417
|
const items = Array.from(e.dataTransfer.items ?? []);
|
|
3413
3418
|
const files = items.filter((it) => it.kind === "file").map((it) => it.getAsFile()).filter((f) => !!f);
|
|
3414
|
-
const imageFiles = files.filter(isImageFile);
|
|
3415
|
-
const videoFiles = allowVideoUpload ? files.filter(isVideoFile) : [];
|
|
3419
|
+
const imageFiles = files.filter((f) => isImageFile(f, maxImageFileSize));
|
|
3420
|
+
const videoFiles = allowVideoUpload ? files.filter((f) => isVideoFile(f, maxVideoFileSize)) : [];
|
|
3416
3421
|
const htmlFiles = files.filter(isHtmlFile);
|
|
3417
3422
|
DEBUG_LOG("drop:step1:files", "drop received", {
|
|
3418
3423
|
filesCount: files.length,
|
|
@@ -3424,8 +3429,8 @@ function LumirEditor({
|
|
|
3424
3429
|
name: files[0].name,
|
|
3425
3430
|
type: files[0].type,
|
|
3426
3431
|
size: files[0].size,
|
|
3427
|
-
isImage: isImageFile(files[0]),
|
|
3428
|
-
isVideo: isVideoFile(files[0])
|
|
3432
|
+
isImage: isImageFile(files[0], maxImageFileSize),
|
|
3433
|
+
isVideo: isVideoFile(files[0], maxVideoFileSize)
|
|
3429
3434
|
} : null
|
|
3430
3435
|
});
|
|
3431
3436
|
if (imageFiles.length === 0 && htmlFiles.length === 0 && videoFiles.length === 0)
|
|
@@ -3560,8 +3565,8 @@ function LumirEditor({
|
|
|
3560
3565
|
});
|
|
3561
3566
|
const blockToInsertAfter = floatingMenuBlockRef.current;
|
|
3562
3567
|
if (file && editor.uploadFile && blockToInsertAfter) {
|
|
3563
|
-
const allowedImage = isImageFile(file);
|
|
3564
|
-
const allowedVideo = allowVideoUpload && isVideoFile(file);
|
|
3568
|
+
const allowedImage = isImageFile(file, maxImageFileSize);
|
|
3569
|
+
const allowedVideo = allowVideoUpload && isVideoFile(file, maxVideoFileSize);
|
|
3565
3570
|
DEBUG_LOG("FloatingMenu:step4:fileCheck", "allowed check", {
|
|
3566
3571
|
fileName: file.name,
|
|
3567
3572
|
allowedImage,
|