magic-editor-x 1.4.0 → 1.5.1
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/_chunks/{App-ByYQ99dO.js → App-DImBvISP.js} +59 -59
- package/dist/_chunks/{App-C8q91Ico.mjs → App-iNfbV7cz.mjs} +32 -32
- package/dist/_chunks/{CustomBlocksPage-rLRB05j0.mjs → CustomBlocksPage-COPOZ2-_.mjs} +2 -1
- package/dist/_chunks/{CustomBlocksPage-BkmF2iOQ.js → CustomBlocksPage-Cj-0TTUs.js} +14 -13
- package/dist/_chunks/{LicensePage-Bdn7zWU2.js → LicensePage-CmvILX9m.js} +43 -43
- package/dist/_chunks/{LicensePage-DR_Cwyfw.mjs → LicensePage-gLRoo8WJ.mjs} +38 -38
- package/dist/_chunks/{LiveCollaborationPanel-BUHIq0CQ.js → LiveCollaborationPanel-BFybu8h0.js} +7 -7
- package/dist/_chunks/{LiveCollaborationPanel-0tplv17N.mjs → LiveCollaborationPanel-CVgl4IyR.mjs} +3 -3
- package/dist/_chunks/{Settings-FfpVHlpw.mjs → Settings-ButYcfrm.mjs} +82 -82
- package/dist/_chunks/Settings-BzGqgrxD.js +440 -0
- package/dist/_chunks/{getTranslation-DOJ3x1SL.js → getTranslation-BADoesEn.js} +19120 -12315
- package/dist/_chunks/{getTranslation-Bk8tKbUs.mjs → getTranslation-D3h3Z3gU.mjs} +18708 -11903
- package/dist/_chunks/index-BXBnwuRw.js +2158 -0
- package/dist/_chunks/index-BvEdg518.mjs +2159 -0
- package/dist/_chunks/{index-DzixAi6O.js → index-DDFAuQNT.js} +360 -180
- package/dist/_chunks/{index-zOiCW1bZ.mjs → index-DEi6nwfM.mjs} +215 -35
- package/dist/_chunks/{tools-uudZx91W.mjs → tools-BXzd0lx5.mjs} +3 -3
- package/dist/_chunks/{tools-BSMn5LLQ.js → tools-Q0uwDS9E.js} +10 -10
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/server/index.js +142 -135
- package/dist/server/index.mjs +142 -135
- package/package.json +7 -7
- package/dist/_chunks/Settings-B5mffA2O.js +0 -440
- package/dist/_chunks/index-C5DuaTDl.js +0 -2550
- package/dist/_chunks/index-DkpTkVe7.mjs +0 -2551
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { u as useIntl,
|
|
2
|
+
import m__default, { useState, useEffect, useCallback, useRef, useMemo, forwardRef } from "react";
|
|
3
|
+
import { u as useIntl, T, I, z as zn, b as bl, R, g as getTranslation, H as Hm, V as Vd } from "./getTranslation-D3h3Z3gU.mjs";
|
|
4
4
|
import styled, { createGlobalStyle, css } from "styled-components";
|
|
5
5
|
import { ClockIcon, ExclamationTriangleIcon, SparklesIcon as SparklesIcon$1, Bars3BottomLeftIcon, ListBulletIcon, CheckCircleIcon, PhotoIcon, LinkIcon, CodeBracketIcon, TableCellsIcon, ChatBubbleBottomCenterTextIcon, MinusIcon, DocumentDuplicateIcon, TrashIcon, ArrowsPointingInIcon, ArrowsPointingOutIcon, EyeIcon, PencilSquareIcon } from "@heroicons/react/24/outline";
|
|
6
6
|
import EditorJS from "@editorjs/editorjs";
|
|
7
|
-
import { M as MagicEditorAPI, t as toastManager, g as getTools, i as initUndoRedo, a as initDragDrop, A as AIToast, b as AIInlineToolbar } from "./tools-
|
|
7
|
+
import { M as MagicEditorAPI, t as toastManager, g as getTools, i as initUndoRedo, a as initDragDrop, A as AIToast, b as AIInlineToolbar } from "./tools-BXzd0lx5.mjs";
|
|
8
8
|
import { useStrapiApp, useFetchClient, useAuth } from "@strapi/strapi/admin";
|
|
9
|
-
import { P as PLUGIN_ID } from "./index-
|
|
9
|
+
import { P as PLUGIN_ID } from "./index-BvEdg518.mjs";
|
|
10
10
|
import { io } from "socket.io-client";
|
|
11
11
|
import * as Y from "yjs";
|
|
12
12
|
import { IndexeddbPersistence } from "y-indexeddb";
|
|
@@ -970,7 +970,7 @@ const MediaLibComponent = ({
|
|
|
970
970
|
}
|
|
971
971
|
) });
|
|
972
972
|
};
|
|
973
|
-
class MediaLibErrorBoundary extends
|
|
973
|
+
class MediaLibErrorBoundary extends m__default.Component {
|
|
974
974
|
constructor(props) {
|
|
975
975
|
super(props);
|
|
976
976
|
this.state = { hasError: false, error: null };
|
|
@@ -1763,8 +1763,8 @@ const useLicense = () => {
|
|
|
1763
1763
|
};
|
|
1764
1764
|
};
|
|
1765
1765
|
const useAIActions = ({ licenseKey, editorInstanceRef, isReady, onNoCredits }) => {
|
|
1766
|
-
const apiClientRef =
|
|
1767
|
-
|
|
1766
|
+
const apiClientRef = m__default.useRef(null);
|
|
1767
|
+
m__default.useEffect(() => {
|
|
1768
1768
|
if (licenseKey && !apiClientRef.current) {
|
|
1769
1769
|
apiClientRef.current = new MagicEditorAPI(licenseKey);
|
|
1770
1770
|
}
|
|
@@ -2319,6 +2319,9 @@ function createSimpleBlock(config) {
|
|
|
2319
2319
|
this.data[field.name] = input.value;
|
|
2320
2320
|
});
|
|
2321
2321
|
break;
|
|
2322
|
+
case "image":
|
|
2323
|
+
input = this._createImageField(field);
|
|
2324
|
+
break;
|
|
2322
2325
|
default:
|
|
2323
2326
|
input = document.createElement("input");
|
|
2324
2327
|
input.type = field.type || "text";
|
|
@@ -2341,6 +2344,146 @@ function createSimpleBlock(config) {
|
|
|
2341
2344
|
container.appendChild(input);
|
|
2342
2345
|
return container;
|
|
2343
2346
|
}
|
|
2347
|
+
/**
|
|
2348
|
+
* Create image field with Media Library integration
|
|
2349
|
+
* @param {object} field - Field configuration
|
|
2350
|
+
* @returns {HTMLElement}
|
|
2351
|
+
*/
|
|
2352
|
+
_createImageField(field) {
|
|
2353
|
+
const wrapper = document.createElement("div");
|
|
2354
|
+
wrapper.style.cssText = `
|
|
2355
|
+
border: 2px dashed #e2e8f0;
|
|
2356
|
+
border-radius: 8px;
|
|
2357
|
+
padding: 16px;
|
|
2358
|
+
text-align: center;
|
|
2359
|
+
background: #fafbfc;
|
|
2360
|
+
transition: all 0.2s ease;
|
|
2361
|
+
`;
|
|
2362
|
+
const preview = document.createElement("div");
|
|
2363
|
+
preview.className = "image-preview";
|
|
2364
|
+
preview.style.cssText = `
|
|
2365
|
+
margin-bottom: 12px;
|
|
2366
|
+
min-height: 60px;
|
|
2367
|
+
display: flex;
|
|
2368
|
+
align-items: center;
|
|
2369
|
+
justify-content: center;
|
|
2370
|
+
`;
|
|
2371
|
+
const img = document.createElement("img");
|
|
2372
|
+
img.style.cssText = `
|
|
2373
|
+
max-width: 100%;
|
|
2374
|
+
max-height: 150px;
|
|
2375
|
+
border-radius: 6px;
|
|
2376
|
+
display: none;
|
|
2377
|
+
`;
|
|
2378
|
+
const placeholder = document.createElement("div");
|
|
2379
|
+
placeholder.innerHTML = `
|
|
2380
|
+
<svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="#94a3b8" stroke-width="1.5">
|
|
2381
|
+
<rect x="3" y="3" width="18" height="18" rx="2"/>
|
|
2382
|
+
<circle cx="8.5" cy="8.5" r="1.5"/>
|
|
2383
|
+
<path d="M21 15l-5-5L5 21"/>
|
|
2384
|
+
</svg>
|
|
2385
|
+
<p style="margin: 8px 0 0; color: #94a3b8; font-size: 13px;">No image selected</p>
|
|
2386
|
+
`;
|
|
2387
|
+
placeholder.style.cssText = "text-align: center;";
|
|
2388
|
+
preview.appendChild(img);
|
|
2389
|
+
preview.appendChild(placeholder);
|
|
2390
|
+
const updatePreview = (url) => {
|
|
2391
|
+
if (url) {
|
|
2392
|
+
img.src = url;
|
|
2393
|
+
img.style.display = "block";
|
|
2394
|
+
placeholder.style.display = "none";
|
|
2395
|
+
wrapper.style.borderStyle = "solid";
|
|
2396
|
+
wrapper.style.borderColor = "#c4b5fd";
|
|
2397
|
+
} else {
|
|
2398
|
+
img.style.display = "none";
|
|
2399
|
+
placeholder.style.display = "block";
|
|
2400
|
+
wrapper.style.borderStyle = "dashed";
|
|
2401
|
+
wrapper.style.borderColor = "#e2e8f0";
|
|
2402
|
+
}
|
|
2403
|
+
};
|
|
2404
|
+
const currentValue = this.data[field.name];
|
|
2405
|
+
if (currentValue && typeof currentValue === "object") {
|
|
2406
|
+
updatePreview(currentValue.url);
|
|
2407
|
+
} else if (typeof currentValue === "string" && currentValue) {
|
|
2408
|
+
updatePreview(currentValue);
|
|
2409
|
+
}
|
|
2410
|
+
const buttons = document.createElement("div");
|
|
2411
|
+
buttons.style.cssText = "display: flex; gap: 8px; justify-content: center;";
|
|
2412
|
+
const selectBtn = document.createElement("button");
|
|
2413
|
+
selectBtn.type = "button";
|
|
2414
|
+
selectBtn.textContent = "Select Image";
|
|
2415
|
+
selectBtn.style.cssText = `
|
|
2416
|
+
padding: 8px 16px;
|
|
2417
|
+
background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
|
|
2418
|
+
color: white;
|
|
2419
|
+
border: none;
|
|
2420
|
+
border-radius: 6px;
|
|
2421
|
+
font-size: 13px;
|
|
2422
|
+
font-weight: 600;
|
|
2423
|
+
cursor: pointer;
|
|
2424
|
+
transition: all 0.2s ease;
|
|
2425
|
+
`;
|
|
2426
|
+
selectBtn.addEventListener("mouseenter", () => {
|
|
2427
|
+
selectBtn.style.transform = "translateY(-1px)";
|
|
2428
|
+
selectBtn.style.boxShadow = "0 4px 12px rgba(124, 58, 237, 0.35)";
|
|
2429
|
+
});
|
|
2430
|
+
selectBtn.addEventListener("mouseleave", () => {
|
|
2431
|
+
selectBtn.style.transform = "translateY(0)";
|
|
2432
|
+
selectBtn.style.boxShadow = "none";
|
|
2433
|
+
});
|
|
2434
|
+
const removeBtn = document.createElement("button");
|
|
2435
|
+
removeBtn.type = "button";
|
|
2436
|
+
removeBtn.textContent = "Remove";
|
|
2437
|
+
removeBtn.style.cssText = `
|
|
2438
|
+
padding: 8px 16px;
|
|
2439
|
+
background: transparent;
|
|
2440
|
+
color: #ef4444;
|
|
2441
|
+
border: 1px solid #fecaca;
|
|
2442
|
+
border-radius: 6px;
|
|
2443
|
+
font-size: 13px;
|
|
2444
|
+
font-weight: 600;
|
|
2445
|
+
cursor: pointer;
|
|
2446
|
+
transition: all 0.2s ease;
|
|
2447
|
+
display: ${this.data[field.name] ? "inline-block" : "none"};
|
|
2448
|
+
`;
|
|
2449
|
+
removeBtn.addEventListener("click", () => {
|
|
2450
|
+
this.data[field.name] = null;
|
|
2451
|
+
updatePreview(null);
|
|
2452
|
+
removeBtn.style.display = "none";
|
|
2453
|
+
});
|
|
2454
|
+
selectBtn.addEventListener("click", () => {
|
|
2455
|
+
if (this.readOnly) return;
|
|
2456
|
+
const callbackId = `image_field_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
2457
|
+
window.__MAGIC_EDITOR_IMAGE_CALLBACKS__ = window.__MAGIC_EDITOR_IMAGE_CALLBACKS__ || {};
|
|
2458
|
+
window.__MAGIC_EDITOR_IMAGE_CALLBACKS__[callbackId] = (files) => {
|
|
2459
|
+
if (files && files.length > 0) {
|
|
2460
|
+
const file = files[0];
|
|
2461
|
+
const imageData = {
|
|
2462
|
+
url: file.url,
|
|
2463
|
+
alt: file.alt || file.name || "",
|
|
2464
|
+
width: file.width,
|
|
2465
|
+
height: file.height,
|
|
2466
|
+
id: file.id,
|
|
2467
|
+
documentId: file.documentId
|
|
2468
|
+
};
|
|
2469
|
+
this.data[field.name] = imageData;
|
|
2470
|
+
updatePreview(imageData.url);
|
|
2471
|
+
removeBtn.style.display = "inline-block";
|
|
2472
|
+
}
|
|
2473
|
+
delete window.__MAGIC_EDITOR_IMAGE_CALLBACKS__[callbackId];
|
|
2474
|
+
};
|
|
2475
|
+
window.dispatchEvent(new CustomEvent("magic-editor-open-media-lib", {
|
|
2476
|
+
detail: { callbackId, fieldName: field.name, allowedTypes: ["images"] }
|
|
2477
|
+
}));
|
|
2478
|
+
});
|
|
2479
|
+
buttons.appendChild(selectBtn);
|
|
2480
|
+
buttons.appendChild(removeBtn);
|
|
2481
|
+
wrapper.appendChild(preview);
|
|
2482
|
+
if (!this.readOnly) {
|
|
2483
|
+
wrapper.appendChild(buttons);
|
|
2484
|
+
}
|
|
2485
|
+
return wrapper;
|
|
2486
|
+
}
|
|
2344
2487
|
/**
|
|
2345
2488
|
* Escape HTML special characters
|
|
2346
2489
|
* @param {string} text - Text to escape
|
|
@@ -2840,7 +2983,7 @@ const AIAssistantPopup = ({ selectedText, licenseKey, onClose, onApply }) => {
|
|
|
2840
2983
|
] })
|
|
2841
2984
|
] }) });
|
|
2842
2985
|
};
|
|
2843
|
-
const PanelWrapper = styled(
|
|
2986
|
+
const PanelWrapper = styled(R)`
|
|
2844
2987
|
width: 320px;
|
|
2845
2988
|
background: ${({ theme }) => theme.colors.neutral0};
|
|
2846
2989
|
border: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
@@ -2850,25 +2993,25 @@ const PanelWrapper = styled(Box)`
|
|
|
2850
2993
|
flex-direction: column;
|
|
2851
2994
|
max-height: 70vh;
|
|
2852
2995
|
`;
|
|
2853
|
-
const Header$1 = styled(
|
|
2996
|
+
const Header$1 = styled(T)`
|
|
2854
2997
|
padding: 12px 16px;
|
|
2855
2998
|
border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
2856
2999
|
`;
|
|
2857
|
-
const Content$1 = styled(
|
|
3000
|
+
const Content$1 = styled(R)`
|
|
2858
3001
|
padding: 12px 16px;
|
|
2859
3002
|
overflow-y: auto;
|
|
2860
3003
|
`;
|
|
2861
|
-
const Item = styled(
|
|
3004
|
+
const Item = styled(R)`
|
|
2862
3005
|
padding: 10px 12px;
|
|
2863
3006
|
border: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
2864
3007
|
border-radius: 6px;
|
|
2865
3008
|
margin-bottom: 10px;
|
|
2866
3009
|
`;
|
|
2867
|
-
const Meta = styled(
|
|
3010
|
+
const Meta = styled(I)`
|
|
2868
3011
|
color: ${({ theme }) => theme.colors.neutral500};
|
|
2869
3012
|
font-size: 12px;
|
|
2870
3013
|
`;
|
|
2871
|
-
const PremiumBadge = styled(
|
|
3014
|
+
const PremiumBadge = styled(R)`
|
|
2872
3015
|
background: ${({ theme }) => theme.colors.primary100};
|
|
2873
3016
|
color: ${({ theme }) => theme.colors.primary600};
|
|
2874
3017
|
border-radius: 6px;
|
|
@@ -2917,33 +3060,33 @@ const VersionHistoryPanel = ({
|
|
|
2917
3060
|
);
|
|
2918
3061
|
return /* @__PURE__ */ jsxs(PanelWrapper, { "data-testid": "version-history-panel", children: [
|
|
2919
3062
|
/* @__PURE__ */ jsxs(Header$1, { justifyContent: "space-between", alignItems: "center", children: [
|
|
2920
|
-
/* @__PURE__ */ jsxs(
|
|
3063
|
+
/* @__PURE__ */ jsxs(T, { gap: 8, alignItems: "center", children: [
|
|
2921
3064
|
/* @__PURE__ */ jsx(ClockIcon, { width: 18 }),
|
|
2922
|
-
/* @__PURE__ */ jsx(
|
|
3065
|
+
/* @__PURE__ */ jsx(I, { fontWeight: "bold", children: t("versionHistory.title", "Version History") })
|
|
2923
3066
|
] }),
|
|
2924
|
-
/* @__PURE__ */ jsx(
|
|
3067
|
+
/* @__PURE__ */ jsx(zn, { size: "S", variant: "tertiary", onClick: onClose, children: t("versionHistory.close", "Close") })
|
|
2925
3068
|
] }),
|
|
2926
3069
|
/* @__PURE__ */ jsxs(Content$1, { children: [
|
|
2927
|
-
loading && /* @__PURE__ */ jsx(
|
|
2928
|
-
error && /* @__PURE__ */ jsx(
|
|
2929
|
-
!loading && !error && snapshots.length === 0 && /* @__PURE__ */ jsx(
|
|
3070
|
+
loading && /* @__PURE__ */ jsx(I, { children: t("versionHistory.loading", "Loading versions...") }),
|
|
3071
|
+
error && /* @__PURE__ */ jsx(I, { textColor: "danger600", children: error }),
|
|
3072
|
+
!loading && !error && snapshots.length === 0 && /* @__PURE__ */ jsx(I, { children: t("versionHistory.noSnapshots", "No versions saved yet") }),
|
|
2930
3073
|
!loading && !error && snapshots.map((snap) => /* @__PURE__ */ jsxs(Item, { children: [
|
|
2931
|
-
/* @__PURE__ */ jsxs(
|
|
2932
|
-
/* @__PURE__ */ jsxs(
|
|
3074
|
+
/* @__PURE__ */ jsxs(T, { justifyContent: "space-between", alignItems: "center", children: [
|
|
3075
|
+
/* @__PURE__ */ jsxs(I, { fontWeight: "bold", children: [
|
|
2933
3076
|
t("versionHistory.version", "Version"),
|
|
2934
3077
|
" ",
|
|
2935
3078
|
snap.version
|
|
2936
3079
|
] }),
|
|
2937
|
-
/* @__PURE__ */ jsx(
|
|
3080
|
+
/* @__PURE__ */ jsx(I, { variant: "pi", children: formatDate(snap.createdAt) })
|
|
2938
3081
|
] }),
|
|
2939
3082
|
/* @__PURE__ */ jsxs(Meta, { children: [
|
|
2940
3083
|
t("versionHistory.createdBy", "By"),
|
|
2941
3084
|
" ",
|
|
2942
3085
|
snap.createdBy?.firstname ? `${snap.createdBy.firstname} ${snap.createdBy.lastname || ""}`.trim() : "—"
|
|
2943
3086
|
] }),
|
|
2944
|
-
/* @__PURE__ */ jsx(
|
|
2945
|
-
canRestore ? /* @__PURE__ */ jsx(
|
|
2946
|
-
|
|
3087
|
+
/* @__PURE__ */ jsx(bl, { marginTop: 2, marginBottom: 2 }),
|
|
3088
|
+
canRestore ? /* @__PURE__ */ jsx(T, { gap: 8, children: /* @__PURE__ */ jsx(
|
|
3089
|
+
zn,
|
|
2947
3090
|
{
|
|
2948
3091
|
size: "S",
|
|
2949
3092
|
variant: "secondary",
|
|
@@ -2955,9 +3098,9 @@ const VersionHistoryPanel = ({
|
|
|
2955
3098
|
t("versionHistory.premiumOnly", "Premium feature")
|
|
2956
3099
|
] })
|
|
2957
3100
|
] }, snap.documentId || snap.id)),
|
|
2958
|
-
/* @__PURE__ */ jsx(
|
|
2959
|
-
canRestore ? /* @__PURE__ */ jsx(
|
|
2960
|
-
/* @__PURE__ */ jsx(
|
|
3101
|
+
/* @__PURE__ */ jsx(bl, { marginTop: 4, marginBottom: 4 }),
|
|
3102
|
+
canRestore ? /* @__PURE__ */ jsx(zn, { size: "S", fullWidth: true, variant: "default", onClick: onCreate, disabled: loading, children: t("versionHistory.create", "Create Snapshot") }) : /* @__PURE__ */ jsxs(R, { children: [
|
|
3103
|
+
/* @__PURE__ */ jsx(zn, { size: "S", fullWidth: true, variant: "default", disabled: true, children: t("versionHistory.create", "Create Snapshot") }),
|
|
2961
3104
|
/* @__PURE__ */ jsxs(PremiumBadge, { style: { marginTop: "8px", width: "100%", justifyContent: "center" }, children: [
|
|
2962
3105
|
/* @__PURE__ */ jsx(ExclamationTriangleIcon, { width: 16 }),
|
|
2963
3106
|
t("versionHistory.premiumOnly", "Premium feature")
|
|
@@ -5995,6 +6138,37 @@ const Editor = forwardRef(({
|
|
|
5995
6138
|
},
|
|
5996
6139
|
[mediaLibBlockIndex, mediaLibToggleFunc]
|
|
5997
6140
|
);
|
|
6141
|
+
const [customBlockImageCallback, setCustomBlockImageCallback] = useState(null);
|
|
6142
|
+
const handleCustomBlockMediaLibChange = useCallback((data) => {
|
|
6143
|
+
if (customBlockImageCallback && window.__MAGIC_EDITOR_IMAGE_CALLBACKS__) {
|
|
6144
|
+
const callback = window.__MAGIC_EDITOR_IMAGE_CALLBACKS__[customBlockImageCallback];
|
|
6145
|
+
if (callback) {
|
|
6146
|
+
const formattedData = data.map((file) => ({
|
|
6147
|
+
url: file.url,
|
|
6148
|
+
alt: file.alt || file.name || "",
|
|
6149
|
+
width: file.width,
|
|
6150
|
+
height: file.height,
|
|
6151
|
+
id: file.id,
|
|
6152
|
+
documentId: file.documentId,
|
|
6153
|
+
name: file.name
|
|
6154
|
+
}));
|
|
6155
|
+
callback(formattedData);
|
|
6156
|
+
}
|
|
6157
|
+
}
|
|
6158
|
+
setCustomBlockImageCallback(null);
|
|
6159
|
+
setIsMediaLibOpen(false);
|
|
6160
|
+
}, [customBlockImageCallback]);
|
|
6161
|
+
useEffect(() => {
|
|
6162
|
+
const handleOpenMediaLib = (event) => {
|
|
6163
|
+
const { callbackId, allowedTypes } = event.detail || {};
|
|
6164
|
+
if (callbackId) {
|
|
6165
|
+
setCustomBlockImageCallback(callbackId);
|
|
6166
|
+
setIsMediaLibOpen(true);
|
|
6167
|
+
}
|
|
6168
|
+
};
|
|
6169
|
+
window.addEventListener("magic-editor-open-media-lib", handleOpenMediaLib);
|
|
6170
|
+
return () => window.removeEventListener("magic-editor-open-media-lib", handleOpenMediaLib);
|
|
6171
|
+
}, []);
|
|
5998
6172
|
const toggleFullscreen = useCallback(() => {
|
|
5999
6173
|
setIsFullscreen((prev) => {
|
|
6000
6174
|
if (!prev) {
|
|
@@ -6331,11 +6505,11 @@ const Editor = forwardRef(({
|
|
|
6331
6505
|
{ icon: ExclamationTriangleIcon, label: "Warning", block: "warning" },
|
|
6332
6506
|
{ icon: MinusIcon, label: "Divider", block: "delimiter" }
|
|
6333
6507
|
];
|
|
6334
|
-
return /* @__PURE__ */ jsxs(
|
|
6508
|
+
return /* @__PURE__ */ jsxs(Hm.Root, { name, id: name, error, required, hint, children: [
|
|
6335
6509
|
/* @__PURE__ */ jsx(FullscreenGlobalStyle, {}),
|
|
6336
6510
|
/* @__PURE__ */ jsx(EditorJSGlobalStyles, {}),
|
|
6337
6511
|
/* @__PURE__ */ jsx(AIToast, {}),
|
|
6338
|
-
label && !isFullscreen && /* @__PURE__ */ jsx(
|
|
6512
|
+
label && !isFullscreen && /* @__PURE__ */ jsx(Hm.Label, { action: labelAction, children: label }),
|
|
6339
6513
|
/* @__PURE__ */ jsx(
|
|
6340
6514
|
EditorContainer,
|
|
6341
6515
|
{
|
|
@@ -6549,7 +6723,7 @@ const Editor = forwardRef(({
|
|
|
6549
6723
|
onBlur: () => setIsFocused(false),
|
|
6550
6724
|
children: [
|
|
6551
6725
|
!isReady && /* @__PURE__ */ jsxs(LoadingOverlay, { children: [
|
|
6552
|
-
/* @__PURE__ */ jsx(
|
|
6726
|
+
/* @__PURE__ */ jsx(Vd, { small: true }),
|
|
6553
6727
|
/* @__PURE__ */ jsx(LoadingText, { children: "Initializing editor..." })
|
|
6554
6728
|
] }),
|
|
6555
6729
|
/* @__PURE__ */ jsx(
|
|
@@ -6634,15 +6808,21 @@ const Editor = forwardRef(({
|
|
|
6634
6808
|
}
|
|
6635
6809
|
),
|
|
6636
6810
|
!isFullscreen && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6637
|
-
/* @__PURE__ */ jsx(
|
|
6638
|
-
/* @__PURE__ */ jsx(
|
|
6811
|
+
/* @__PURE__ */ jsx(Hm.Hint, {}),
|
|
6812
|
+
/* @__PURE__ */ jsx(Hm.Error, {})
|
|
6639
6813
|
] }),
|
|
6640
6814
|
/* @__PURE__ */ jsx(
|
|
6641
6815
|
MediaLibComponent,
|
|
6642
6816
|
{
|
|
6643
6817
|
isOpen: isMediaLibOpen,
|
|
6644
|
-
onChange: handleMediaLibChange,
|
|
6645
|
-
onToggle:
|
|
6818
|
+
onChange: customBlockImageCallback ? handleCustomBlockMediaLibChange : handleMediaLibChange,
|
|
6819
|
+
onToggle: () => {
|
|
6820
|
+
if (customBlockImageCallback) {
|
|
6821
|
+
setCustomBlockImageCallback(null);
|
|
6822
|
+
}
|
|
6823
|
+
mediaLibToggleFunc();
|
|
6824
|
+
},
|
|
6825
|
+
multiple: !customBlockImageCallback
|
|
6646
6826
|
}
|
|
6647
6827
|
),
|
|
6648
6828
|
showAIToolbar && /* @__PURE__ */ jsx(
|
|
@@ -17,7 +17,7 @@ import Personality from "@editorjs/personality";
|
|
|
17
17
|
import Alert from "editorjs-alert";
|
|
18
18
|
import ToggleBlock from "editorjs-toggle-block";
|
|
19
19
|
import CodeFlask from "@calumk/editorjs-codeflask";
|
|
20
|
-
import
|
|
20
|
+
import m__default, { useState, useRef, useEffect } from "react";
|
|
21
21
|
import { createRoot } from "react-dom/client";
|
|
22
22
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
23
23
|
import styled, { keyframes } from "styled-components";
|
|
@@ -1436,7 +1436,7 @@ class AIAssistantTool {
|
|
|
1436
1436
|
document.body.appendChild(this.toolbar);
|
|
1437
1437
|
this.toolbarRoot = createRoot(this.toolbar);
|
|
1438
1438
|
this.toolbarRoot.render(
|
|
1439
|
-
|
|
1439
|
+
m__default.createElement(AIInlineToolbar, {
|
|
1440
1440
|
position,
|
|
1441
1441
|
onAction: this._handleAction.bind(this),
|
|
1442
1442
|
loading: this.isLoading,
|
|
@@ -1574,7 +1574,7 @@ class AIAssistantTool {
|
|
|
1574
1574
|
top: rect.bottom + 8
|
|
1575
1575
|
};
|
|
1576
1576
|
this.toolbarRoot.render(
|
|
1577
|
-
|
|
1577
|
+
m__default.createElement(AIInlineToolbar, {
|
|
1578
1578
|
position,
|
|
1579
1579
|
onAction: this._handleAction.bind(this),
|
|
1580
1580
|
loading: this.isLoading,
|
|
@@ -18,7 +18,7 @@ const Personality = require("@editorjs/personality");
|
|
|
18
18
|
const Alert = require("editorjs-alert");
|
|
19
19
|
const ToggleBlock = require("editorjs-toggle-block");
|
|
20
20
|
const CodeFlask = require("@calumk/editorjs-codeflask");
|
|
21
|
-
const
|
|
21
|
+
const m = require("react");
|
|
22
22
|
const client = require("react-dom/client");
|
|
23
23
|
const jsxRuntime = require("react/jsx-runtime");
|
|
24
24
|
const styled = require("styled-components");
|
|
@@ -52,7 +52,7 @@ const Personality__default = /* @__PURE__ */ _interopDefault(Personality);
|
|
|
52
52
|
const Alert__default = /* @__PURE__ */ _interopDefault(Alert);
|
|
53
53
|
const ToggleBlock__default = /* @__PURE__ */ _interopDefault(ToggleBlock);
|
|
54
54
|
const CodeFlask__default = /* @__PURE__ */ _interopDefault(CodeFlask);
|
|
55
|
-
const
|
|
55
|
+
const m__default = /* @__PURE__ */ _interopDefault(m);
|
|
56
56
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
57
57
|
const Marker__default = /* @__PURE__ */ _interopDefault(Marker);
|
|
58
58
|
const InlineCode__default = /* @__PURE__ */ _interopDefault(InlineCode);
|
|
@@ -948,9 +948,9 @@ const AIInlineToolbar = ({
|
|
|
948
948
|
disabled = false,
|
|
949
949
|
onClose
|
|
950
950
|
}) => {
|
|
951
|
-
const [activeSubmenu, setActiveSubmenu] =
|
|
952
|
-
const toolbarRef =
|
|
953
|
-
|
|
951
|
+
const [activeSubmenu, setActiveSubmenu] = m.useState(null);
|
|
952
|
+
const toolbarRef = m.useRef(null);
|
|
953
|
+
m.useEffect(() => {
|
|
954
954
|
const handleClickOutside = (e) => {
|
|
955
955
|
if (toolbarRef.current && !toolbarRef.current.contains(e.target)) {
|
|
956
956
|
onClose?.();
|
|
@@ -1310,7 +1310,7 @@ class ToastManager {
|
|
|
1310
1310
|
}
|
|
1311
1311
|
const toastManager = new ToastManager();
|
|
1312
1312
|
const Toast = ({ toast, onClose }) => {
|
|
1313
|
-
const [closing, setClosing] =
|
|
1313
|
+
const [closing, setClosing] = m.useState(false);
|
|
1314
1314
|
const handleClose = () => {
|
|
1315
1315
|
setClosing(true);
|
|
1316
1316
|
setTimeout(() => {
|
|
@@ -1335,8 +1335,8 @@ const Toast = ({ toast, onClose }) => {
|
|
|
1335
1335
|
] });
|
|
1336
1336
|
};
|
|
1337
1337
|
const AIToast = () => {
|
|
1338
|
-
const [toasts, setToasts] =
|
|
1339
|
-
|
|
1338
|
+
const [toasts, setToasts] = m.useState([]);
|
|
1339
|
+
m.useEffect(() => {
|
|
1340
1340
|
const unsubscribe = toastManager.subscribe(setToasts);
|
|
1341
1341
|
return unsubscribe;
|
|
1342
1342
|
}, []);
|
|
@@ -1469,7 +1469,7 @@ class AIAssistantTool {
|
|
|
1469
1469
|
document.body.appendChild(this.toolbar);
|
|
1470
1470
|
this.toolbarRoot = client.createRoot(this.toolbar);
|
|
1471
1471
|
this.toolbarRoot.render(
|
|
1472
|
-
|
|
1472
|
+
m__default.default.createElement(AIInlineToolbar, {
|
|
1473
1473
|
position,
|
|
1474
1474
|
onAction: this._handleAction.bind(this),
|
|
1475
1475
|
loading: this.isLoading,
|
|
@@ -1607,7 +1607,7 @@ class AIAssistantTool {
|
|
|
1607
1607
|
top: rect.bottom + 8
|
|
1608
1608
|
};
|
|
1609
1609
|
this.toolbarRoot.render(
|
|
1610
|
-
|
|
1610
|
+
m__default.default.createElement(AIInlineToolbar, {
|
|
1611
1611
|
position,
|
|
1612
1612
|
onAction: this._handleAction.bind(this),
|
|
1613
1613
|
loading: this.isLoading,
|
package/dist/admin/index.js
CHANGED
package/dist/admin/index.mjs
CHANGED