magic-editor-x 1.5.0 → 1.6.0
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 +6 -110
- package/dist/{_chunks/App-CKlB5p92.mjs → admin/App-BwMEZnS-.mjs} +35 -34
- package/dist/{_chunks/App-3CjSGQyL.js → admin/App-HNr2tizR.js} +65 -64
- package/dist/{_chunks/CustomBlocksPage-CnJxygIw.js → admin/CustomBlocksPage-BjcA7MGz.js} +13 -13
- package/dist/{_chunks/LicensePage-B2STSez2.mjs → admin/LicensePage-D0DMTF41.mjs} +39 -38
- package/dist/{_chunks/LicensePage-vJxKYZGQ.js → admin/LicensePage-D0_9yPkw.js} +45 -44
- package/dist/{_chunks/LiveCollaborationPanel-D70o6EGf.js → admin/LiveCollaborationPanel-CZAbgAVr.js} +9 -8
- package/dist/{_chunks/LiveCollaborationPanel-uLIJs5z_.mjs → admin/LiveCollaborationPanel-D8z72afw.mjs} +4 -3
- package/dist/admin/Settings-DRenvRcG.js +441 -0
- package/dist/{_chunks/Settings-CdGL1OCi.mjs → admin/Settings-DjyNURlS.mjs} +83 -82
- package/dist/{_chunks/getTranslation-bLklCCaI.mjs → admin/getTranslation-2OiEgVGt.mjs} +15204 -16731
- package/dist/{_chunks/getTranslation--JcqVOd5.js → admin/getTranslation-DQ_WJ-7M.js} +15612 -17139
- package/dist/admin/index-Bn2tfJrC.js +2186 -0
- package/dist/{_chunks/index-CRALSDLD.js → admin/index-DAtClhqy.js} +184 -183
- package/dist/admin/index-FVEbTfqO.mjs +2187 -0
- package/dist/{_chunks/index-CdFFlQdx.mjs → admin/index-gjWl-6E2.mjs} +34 -33
- package/dist/admin/index.js +3 -2
- package/dist/admin/index.mjs +2 -2
- package/dist/{_chunks/tools-uudZx91W.mjs → admin/tools-CzHTZaY_.mjs} +42 -39
- package/dist/{_chunks/tools-BSMn5LLQ.js → admin/tools-DALFhvPO.js} +49 -46
- package/dist/server/index.js +63527 -37942
- package/dist/server/index.mjs +63546 -37934
- package/package.json +43 -30
- package/dist/_chunks/Settings-CwSNO4_t.js +0 -440
- package/dist/_chunks/index-CAPc_Y1F.mjs +0 -2551
- package/dist/_chunks/index-CPs6WJDY.js +0 -2550
- /package/dist/{_chunks → admin}/CustomBlocksPage-COPOZ2-_.mjs +0 -0
- /package/dist/{_chunks → admin}/de-C_0Mj-Zo.mjs +0 -0
- /package/dist/{_chunks → admin}/de-DVNVpAt9.js +0 -0
- /package/dist/{_chunks → admin}/en-B7AAf1ie.mjs +0 -0
- /package/dist/{_chunks → admin}/en-C2hv5GsA.js +0 -0
- /package/dist/{_chunks → admin}/es-BzJqcIST.js +0 -0
- /package/dist/{_chunks → admin}/es-zdP8sd-f.mjs +0 -0
- /package/dist/{_chunks → admin}/fr-CtAgOgH1.mjs +0 -0
- /package/dist/{_chunks → admin}/fr-D3GwqAAJ.js +0 -0
- /package/dist/{style.css → admin/magic-editor-x.css} +0 -0
- /package/dist/{_chunks → admin}/pt-BmUw6YMP.mjs +0 -0
- /package/dist/{_chunks → admin}/pt-CFo0nTbj.js +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import s__default, { useState, useEffect, useCallback, useRef, useMemo, forwardRef } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { C, A, a as Ct, y as yn, S, g as getTranslation, D as Dd, k as kt } from "./getTranslation-2OiEgVGt.mjs";
|
|
4
5
|
import styled, { createGlobalStyle, css } from "styled-components";
|
|
5
6
|
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
7
|
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-
|
|
8
|
+
import { M as MagicEditorAPI, t as toastManager, g as getTools, i as initUndoRedo, a as initDragDrop, A as AIToast, b as AIInlineToolbar } from "./tools-CzHTZaY_.mjs";
|
|
8
9
|
import { useStrapiApp, useFetchClient, useAuth } from "@strapi/strapi/admin";
|
|
9
|
-
import { P as PLUGIN_ID } from "./index-
|
|
10
|
+
import { P as PLUGIN_ID } from "./index-FVEbTfqO.mjs";
|
|
10
11
|
import { io } from "socket.io-client";
|
|
11
12
|
import * as Y from "yjs";
|
|
12
13
|
import { IndexeddbPersistence } from "y-indexeddb";
|
|
@@ -970,7 +971,7 @@ const MediaLibComponent = ({
|
|
|
970
971
|
}
|
|
971
972
|
) });
|
|
972
973
|
};
|
|
973
|
-
class MediaLibErrorBoundary extends
|
|
974
|
+
class MediaLibErrorBoundary extends s__default.Component {
|
|
974
975
|
constructor(props) {
|
|
975
976
|
super(props);
|
|
976
977
|
this.state = { hasError: false, error: null };
|
|
@@ -1763,8 +1764,8 @@ const useLicense = () => {
|
|
|
1763
1764
|
};
|
|
1764
1765
|
};
|
|
1765
1766
|
const useAIActions = ({ licenseKey, editorInstanceRef, isReady, onNoCredits }) => {
|
|
1766
|
-
const apiClientRef =
|
|
1767
|
-
|
|
1767
|
+
const apiClientRef = s__default.useRef(null);
|
|
1768
|
+
s__default.useEffect(() => {
|
|
1768
1769
|
if (licenseKey && !apiClientRef.current) {
|
|
1769
1770
|
apiClientRef.current = new MagicEditorAPI(licenseKey);
|
|
1770
1771
|
}
|
|
@@ -2983,7 +2984,7 @@ const AIAssistantPopup = ({ selectedText, licenseKey, onClose, onApply }) => {
|
|
|
2983
2984
|
] })
|
|
2984
2985
|
] }) });
|
|
2985
2986
|
};
|
|
2986
|
-
const PanelWrapper = styled(
|
|
2987
|
+
const PanelWrapper = styled(S)`
|
|
2987
2988
|
width: 320px;
|
|
2988
2989
|
background: ${({ theme }) => theme.colors.neutral0};
|
|
2989
2990
|
border: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
@@ -2993,25 +2994,25 @@ const PanelWrapper = styled(Box)`
|
|
|
2993
2994
|
flex-direction: column;
|
|
2994
2995
|
max-height: 70vh;
|
|
2995
2996
|
`;
|
|
2996
|
-
const Header$1 = styled(
|
|
2997
|
+
const Header$1 = styled(C)`
|
|
2997
2998
|
padding: 12px 16px;
|
|
2998
2999
|
border-bottom: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
2999
3000
|
`;
|
|
3000
|
-
const Content$1 = styled(
|
|
3001
|
+
const Content$1 = styled(S)`
|
|
3001
3002
|
padding: 12px 16px;
|
|
3002
3003
|
overflow-y: auto;
|
|
3003
3004
|
`;
|
|
3004
|
-
const Item = styled(
|
|
3005
|
+
const Item = styled(S)`
|
|
3005
3006
|
padding: 10px 12px;
|
|
3006
3007
|
border: 1px solid ${({ theme }) => theme.colors.neutral150};
|
|
3007
3008
|
border-radius: 6px;
|
|
3008
3009
|
margin-bottom: 10px;
|
|
3009
3010
|
`;
|
|
3010
|
-
const Meta = styled(
|
|
3011
|
+
const Meta = styled(A)`
|
|
3011
3012
|
color: ${({ theme }) => theme.colors.neutral500};
|
|
3012
3013
|
font-size: 12px;
|
|
3013
3014
|
`;
|
|
3014
|
-
const PremiumBadge = styled(
|
|
3015
|
+
const PremiumBadge = styled(S)`
|
|
3015
3016
|
background: ${({ theme }) => theme.colors.primary100};
|
|
3016
3017
|
color: ${({ theme }) => theme.colors.primary600};
|
|
3017
3018
|
border-radius: 6px;
|
|
@@ -3060,33 +3061,33 @@ const VersionHistoryPanel = ({
|
|
|
3060
3061
|
);
|
|
3061
3062
|
return /* @__PURE__ */ jsxs(PanelWrapper, { "data-testid": "version-history-panel", children: [
|
|
3062
3063
|
/* @__PURE__ */ jsxs(Header$1, { justifyContent: "space-between", alignItems: "center", children: [
|
|
3063
|
-
/* @__PURE__ */ jsxs(
|
|
3064
|
+
/* @__PURE__ */ jsxs(C, { gap: 8, alignItems: "center", children: [
|
|
3064
3065
|
/* @__PURE__ */ jsx(ClockIcon, { width: 18 }),
|
|
3065
|
-
/* @__PURE__ */ jsx(
|
|
3066
|
+
/* @__PURE__ */ jsx(A, { fontWeight: "bold", children: t("versionHistory.title", "Version History") })
|
|
3066
3067
|
] }),
|
|
3067
|
-
/* @__PURE__ */ jsx(
|
|
3068
|
+
/* @__PURE__ */ jsx(Ct, { size: "S", variant: "tertiary", onClick: onClose, children: t("versionHistory.close", "Close") })
|
|
3068
3069
|
] }),
|
|
3069
3070
|
/* @__PURE__ */ jsxs(Content$1, { children: [
|
|
3070
|
-
loading && /* @__PURE__ */ jsx(
|
|
3071
|
-
error && /* @__PURE__ */ jsx(
|
|
3072
|
-
!loading && !error && snapshots.length === 0 && /* @__PURE__ */ jsx(
|
|
3071
|
+
loading && /* @__PURE__ */ jsx(A, { children: t("versionHistory.loading", "Loading versions...") }),
|
|
3072
|
+
error && /* @__PURE__ */ jsx(A, { textColor: "danger600", children: error }),
|
|
3073
|
+
!loading && !error && snapshots.length === 0 && /* @__PURE__ */ jsx(A, { children: t("versionHistory.noSnapshots", "No versions saved yet") }),
|
|
3073
3074
|
!loading && !error && snapshots.map((snap) => /* @__PURE__ */ jsxs(Item, { children: [
|
|
3074
|
-
/* @__PURE__ */ jsxs(
|
|
3075
|
-
/* @__PURE__ */ jsxs(
|
|
3075
|
+
/* @__PURE__ */ jsxs(C, { justifyContent: "space-between", alignItems: "center", children: [
|
|
3076
|
+
/* @__PURE__ */ jsxs(A, { fontWeight: "bold", children: [
|
|
3076
3077
|
t("versionHistory.version", "Version"),
|
|
3077
3078
|
" ",
|
|
3078
3079
|
snap.version
|
|
3079
3080
|
] }),
|
|
3080
|
-
/* @__PURE__ */ jsx(
|
|
3081
|
+
/* @__PURE__ */ jsx(A, { variant: "pi", children: formatDate(snap.createdAt) })
|
|
3081
3082
|
] }),
|
|
3082
3083
|
/* @__PURE__ */ jsxs(Meta, { children: [
|
|
3083
3084
|
t("versionHistory.createdBy", "By"),
|
|
3084
3085
|
" ",
|
|
3085
3086
|
snap.createdBy?.firstname ? `${snap.createdBy.firstname} ${snap.createdBy.lastname || ""}`.trim() : "—"
|
|
3086
3087
|
] }),
|
|
3087
|
-
/* @__PURE__ */ jsx(
|
|
3088
|
-
canRestore ? /* @__PURE__ */ jsx(
|
|
3089
|
-
|
|
3088
|
+
/* @__PURE__ */ jsx(yn, { marginTop: 2, marginBottom: 2 }),
|
|
3089
|
+
canRestore ? /* @__PURE__ */ jsx(C, { gap: 8, children: /* @__PURE__ */ jsx(
|
|
3090
|
+
Ct,
|
|
3090
3091
|
{
|
|
3091
3092
|
size: "S",
|
|
3092
3093
|
variant: "secondary",
|
|
@@ -3098,9 +3099,9 @@ const VersionHistoryPanel = ({
|
|
|
3098
3099
|
t("versionHistory.premiumOnly", "Premium feature")
|
|
3099
3100
|
] })
|
|
3100
3101
|
] }, snap.documentId || snap.id)),
|
|
3101
|
-
/* @__PURE__ */ jsx(
|
|
3102
|
-
canRestore ? /* @__PURE__ */ jsx(
|
|
3103
|
-
/* @__PURE__ */ jsx(
|
|
3102
|
+
/* @__PURE__ */ jsx(yn, { marginTop: 4, marginBottom: 4 }),
|
|
3103
|
+
canRestore ? /* @__PURE__ */ jsx(Ct, { size: "S", fullWidth: true, variant: "default", onClick: onCreate, disabled: loading, children: t("versionHistory.create", "Create Snapshot") }) : /* @__PURE__ */ jsxs(S, { children: [
|
|
3104
|
+
/* @__PURE__ */ jsx(Ct, { size: "S", fullWidth: true, variant: "default", disabled: true, children: t("versionHistory.create", "Create Snapshot") }),
|
|
3104
3105
|
/* @__PURE__ */ jsxs(PremiumBadge, { style: { marginTop: "8px", width: "100%", justifyContent: "center" }, children: [
|
|
3105
3106
|
/* @__PURE__ */ jsx(ExclamationTriangleIcon, { width: 16 }),
|
|
3106
3107
|
t("versionHistory.premiumOnly", "Premium feature")
|
|
@@ -6505,11 +6506,11 @@ const Editor = forwardRef(({
|
|
|
6505
6506
|
{ icon: ExclamationTriangleIcon, label: "Warning", block: "warning" },
|
|
6506
6507
|
{ icon: MinusIcon, label: "Divider", block: "delimiter" }
|
|
6507
6508
|
];
|
|
6508
|
-
return /* @__PURE__ */ jsxs(
|
|
6509
|
+
return /* @__PURE__ */ jsxs(Dd.Root, { name, id: name, error, required, hint, children: [
|
|
6509
6510
|
/* @__PURE__ */ jsx(FullscreenGlobalStyle, {}),
|
|
6510
6511
|
/* @__PURE__ */ jsx(EditorJSGlobalStyles, {}),
|
|
6511
6512
|
/* @__PURE__ */ jsx(AIToast, {}),
|
|
6512
|
-
label && !isFullscreen && /* @__PURE__ */ jsx(
|
|
6513
|
+
label && !isFullscreen && /* @__PURE__ */ jsx(Dd.Label, { action: labelAction, children: label }),
|
|
6513
6514
|
/* @__PURE__ */ jsx(
|
|
6514
6515
|
EditorContainer,
|
|
6515
6516
|
{
|
|
@@ -6723,7 +6724,7 @@ const Editor = forwardRef(({
|
|
|
6723
6724
|
onBlur: () => setIsFocused(false),
|
|
6724
6725
|
children: [
|
|
6725
6726
|
!isReady && /* @__PURE__ */ jsxs(LoadingOverlay, { children: [
|
|
6726
|
-
/* @__PURE__ */ jsx(
|
|
6727
|
+
/* @__PURE__ */ jsx(kt, { small: true }),
|
|
6727
6728
|
/* @__PURE__ */ jsx(LoadingText, { children: "Initializing editor..." })
|
|
6728
6729
|
] }),
|
|
6729
6730
|
/* @__PURE__ */ jsx(
|
|
@@ -6808,8 +6809,8 @@ const Editor = forwardRef(({
|
|
|
6808
6809
|
}
|
|
6809
6810
|
),
|
|
6810
6811
|
!isFullscreen && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6811
|
-
/* @__PURE__ */ jsx(
|
|
6812
|
-
/* @__PURE__ */ jsx(
|
|
6812
|
+
/* @__PURE__ */ jsx(Dd.Hint, {}),
|
|
6813
|
+
/* @__PURE__ */ jsx(Dd.Error, {})
|
|
6813
6814
|
] }),
|
|
6814
6815
|
/* @__PURE__ */ jsx(
|
|
6815
6816
|
MediaLibComponent,
|
package/dist/admin/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
3
|
+
const index = require("./index-Bn2tfJrC.js");
|
|
4
|
+
exports.default = index.index;
|
package/dist/admin/index.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1
4
|
import Header from "@editorjs/header";
|
|
2
5
|
import Paragraph from "@editorjs/paragraph";
|
|
3
6
|
import NestedList from "@editorjs/nested-list";
|
|
@@ -17,7 +20,7 @@ import Personality from "@editorjs/personality";
|
|
|
17
20
|
import Alert from "editorjs-alert";
|
|
18
21
|
import ToggleBlock from "editorjs-toggle-block";
|
|
19
22
|
import CodeFlask from "@calumk/editorjs-codeflask";
|
|
20
|
-
import
|
|
23
|
+
import s__default, { useState, useRef, useEffect } from "react";
|
|
21
24
|
import { createRoot } from "react-dom/client";
|
|
22
25
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
23
26
|
import styled, { keyframes } from "styled-components";
|
|
@@ -310,6 +313,34 @@ class ButtonTool {
|
|
|
310
313
|
}
|
|
311
314
|
}
|
|
312
315
|
class HyperlinkTool {
|
|
316
|
+
/**
|
|
317
|
+
* Creates an instance of HyperlinkTool
|
|
318
|
+
* @param {object} params - Constructor params
|
|
319
|
+
* @param {object} params.api - Editor.js API
|
|
320
|
+
* @param {object} params.config - Tool configuration
|
|
321
|
+
*/
|
|
322
|
+
constructor({ api, config }) {
|
|
323
|
+
/**
|
|
324
|
+
* Handles clicks outside the popup
|
|
325
|
+
* @param {Event} e - Click event
|
|
326
|
+
*/
|
|
327
|
+
__publicField(this, "_handleOutsideClick", (e) => {
|
|
328
|
+
if (this.popup && !this.popup.contains(e.target) && !this.button.contains(e.target)) {
|
|
329
|
+
this._closePopup();
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
this.api = api;
|
|
333
|
+
this.config = config || {};
|
|
334
|
+
this.defaultTarget = this.config.target || "_blank";
|
|
335
|
+
this.defaultRel = this.config.rel || "noopener noreferrer";
|
|
336
|
+
this.availableTargets = this.config.availableTargets || ["_blank", "_self", "_parent", "_top"];
|
|
337
|
+
this.availableRels = this.config.availableRels || ["nofollow", "noreferrer", "noopener", "sponsored", "ugc"];
|
|
338
|
+
this.button = null;
|
|
339
|
+
this.popup = null;
|
|
340
|
+
this.state = false;
|
|
341
|
+
this.selectedRange = null;
|
|
342
|
+
this.existingLink = null;
|
|
343
|
+
}
|
|
313
344
|
/**
|
|
314
345
|
* Specifies this is an inline tool
|
|
315
346
|
*/
|
|
@@ -334,25 +365,6 @@ class HyperlinkTool {
|
|
|
334
365
|
}
|
|
335
366
|
};
|
|
336
367
|
}
|
|
337
|
-
/**
|
|
338
|
-
* Creates an instance of HyperlinkTool
|
|
339
|
-
* @param {object} params - Constructor params
|
|
340
|
-
* @param {object} params.api - Editor.js API
|
|
341
|
-
* @param {object} params.config - Tool configuration
|
|
342
|
-
*/
|
|
343
|
-
constructor({ api, config }) {
|
|
344
|
-
this.api = api;
|
|
345
|
-
this.config = config || {};
|
|
346
|
-
this.defaultTarget = this.config.target || "_blank";
|
|
347
|
-
this.defaultRel = this.config.rel || "noopener noreferrer";
|
|
348
|
-
this.availableTargets = this.config.availableTargets || ["_blank", "_self", "_parent", "_top"];
|
|
349
|
-
this.availableRels = this.config.availableRels || ["nofollow", "noreferrer", "noopener", "sponsored", "ugc"];
|
|
350
|
-
this.button = null;
|
|
351
|
-
this.popup = null;
|
|
352
|
-
this.state = false;
|
|
353
|
-
this.selectedRange = null;
|
|
354
|
-
this.existingLink = null;
|
|
355
|
-
}
|
|
356
368
|
/**
|
|
357
369
|
* Renders the toolbar button
|
|
358
370
|
* @returns {HTMLElement} Button element
|
|
@@ -673,15 +685,6 @@ class HyperlinkTool {
|
|
|
673
685
|
}
|
|
674
686
|
document.removeEventListener("click", this._handleOutsideClick);
|
|
675
687
|
}
|
|
676
|
-
/**
|
|
677
|
-
* Handles clicks outside the popup
|
|
678
|
-
* @param {Event} e - Click event
|
|
679
|
-
*/
|
|
680
|
-
_handleOutsideClick = (e) => {
|
|
681
|
-
if (this.popup && !this.popup.contains(e.target) && !this.button.contains(e.target)) {
|
|
682
|
-
this._closePopup();
|
|
683
|
-
}
|
|
684
|
-
};
|
|
685
688
|
/**
|
|
686
689
|
* Checks if current selection is inside a link
|
|
687
690
|
* @param {Selection} selection - Current selection
|
|
@@ -1436,7 +1439,7 @@ class AIAssistantTool {
|
|
|
1436
1439
|
document.body.appendChild(this.toolbar);
|
|
1437
1440
|
this.toolbarRoot = createRoot(this.toolbar);
|
|
1438
1441
|
this.toolbarRoot.render(
|
|
1439
|
-
|
|
1442
|
+
s__default.createElement(AIInlineToolbar, {
|
|
1440
1443
|
position,
|
|
1441
1444
|
onAction: this._handleAction.bind(this),
|
|
1442
1445
|
loading: this.isLoading,
|
|
@@ -1574,7 +1577,7 @@ class AIAssistantTool {
|
|
|
1574
1577
|
top: rect.bottom + 8
|
|
1575
1578
|
};
|
|
1576
1579
|
this.toolbarRoot.render(
|
|
1577
|
-
|
|
1580
|
+
s__default.createElement(AIInlineToolbar, {
|
|
1578
1581
|
position,
|
|
1579
1582
|
onAction: this._handleAction.bind(this),
|
|
1580
1583
|
loading: this.isLoading,
|
|
@@ -1609,8 +1612,6 @@ class AIAssistantTool {
|
|
|
1609
1612
|
}
|
|
1610
1613
|
}
|
|
1611
1614
|
class MediaLibAdapter {
|
|
1612
|
-
// Track if we're currently opening from user action vs restore
|
|
1613
|
-
static _isUserAction = false;
|
|
1614
1615
|
/**
|
|
1615
1616
|
* Toolbox configuration
|
|
1616
1617
|
*/
|
|
@@ -1692,6 +1693,8 @@ class MediaLibAdapter {
|
|
|
1692
1693
|
};
|
|
1693
1694
|
}
|
|
1694
1695
|
}
|
|
1696
|
+
// Track if we're currently opening from user action vs restore
|
|
1697
|
+
__publicField(MediaLibAdapter, "_isUserAction", false);
|
|
1695
1698
|
class BoldInlineTool {
|
|
1696
1699
|
static get isInline() {
|
|
1697
1700
|
return true;
|
|
@@ -1945,7 +1948,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
1945
1948
|
linkTool: {
|
|
1946
1949
|
class: LinkTool,
|
|
1947
1950
|
config: {
|
|
1948
|
-
endpoint:
|
|
1951
|
+
endpoint: `/${pluginId}/link`,
|
|
1949
1952
|
headers: {
|
|
1950
1953
|
Authorization: authHeader
|
|
1951
1954
|
}
|
|
@@ -1966,7 +1969,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
1966
1969
|
Authorization: authHeader
|
|
1967
1970
|
},
|
|
1968
1971
|
endpoints: {
|
|
1969
|
-
byUrl:
|
|
1972
|
+
byUrl: `/${pluginId}/image/byUrl`
|
|
1970
1973
|
},
|
|
1971
1974
|
uploader: {
|
|
1972
1975
|
async uploadByFile(file) {
|
|
@@ -1974,7 +1977,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
1974
1977
|
formData.append("data", JSON.stringify({}));
|
|
1975
1978
|
formData.append("files.image", file);
|
|
1976
1979
|
try {
|
|
1977
|
-
const response = await fetch(
|
|
1980
|
+
const response = await fetch(`/${pluginId}/image/byFile`, {
|
|
1978
1981
|
method: "POST",
|
|
1979
1982
|
headers: {
|
|
1980
1983
|
Authorization: authHeader
|
|
@@ -2006,9 +2009,9 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
2006
2009
|
attaches: {
|
|
2007
2010
|
class: Attaches,
|
|
2008
2011
|
config: {
|
|
2009
|
-
endpoint:
|
|
2012
|
+
endpoint: `/${pluginId}/file/upload`,
|
|
2010
2013
|
field: "file",
|
|
2011
|
-
types: "
|
|
2014
|
+
types: "application/pdf,text/plain,text/csv,application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/zip,audio/mpeg,audio/wav,audio/ogg,video/mp4,video/webm,image/jpeg,image/png,image/gif,image/webp",
|
|
2012
2015
|
buttonText: "Select file to upload",
|
|
2013
2016
|
errorMessage: "File upload failed",
|
|
2014
2017
|
additionalRequestHeaders: {
|
|
@@ -2023,7 +2026,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
2023
2026
|
personality: {
|
|
2024
2027
|
class: Personality,
|
|
2025
2028
|
config: {
|
|
2026
|
-
endpoint:
|
|
2029
|
+
endpoint: `/${pluginId}/image/byFile`,
|
|
2027
2030
|
field: "files.image",
|
|
2028
2031
|
additionalRequestHeaders: {
|
|
2029
2032
|
Authorization: authHeader
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
2
5
|
const Header = require("@editorjs/header");
|
|
3
6
|
const Paragraph = require("@editorjs/paragraph");
|
|
4
7
|
const NestedList = require("@editorjs/nested-list");
|
|
@@ -18,7 +21,7 @@ const Personality = require("@editorjs/personality");
|
|
|
18
21
|
const Alert = require("editorjs-alert");
|
|
19
22
|
const ToggleBlock = require("editorjs-toggle-block");
|
|
20
23
|
const CodeFlask = require("@calumk/editorjs-codeflask");
|
|
21
|
-
const
|
|
24
|
+
const s = require("react");
|
|
22
25
|
const client = require("react-dom/client");
|
|
23
26
|
const jsxRuntime = require("react/jsx-runtime");
|
|
24
27
|
const styled = require("styled-components");
|
|
@@ -52,7 +55,7 @@ const Personality__default = /* @__PURE__ */ _interopDefault(Personality);
|
|
|
52
55
|
const Alert__default = /* @__PURE__ */ _interopDefault(Alert);
|
|
53
56
|
const ToggleBlock__default = /* @__PURE__ */ _interopDefault(ToggleBlock);
|
|
54
57
|
const CodeFlask__default = /* @__PURE__ */ _interopDefault(CodeFlask);
|
|
55
|
-
const
|
|
58
|
+
const s__default = /* @__PURE__ */ _interopDefault(s);
|
|
56
59
|
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
57
60
|
const Marker__default = /* @__PURE__ */ _interopDefault(Marker);
|
|
58
61
|
const InlineCode__default = /* @__PURE__ */ _interopDefault(InlineCode);
|
|
@@ -343,6 +346,34 @@ class ButtonTool {
|
|
|
343
346
|
}
|
|
344
347
|
}
|
|
345
348
|
class HyperlinkTool {
|
|
349
|
+
/**
|
|
350
|
+
* Creates an instance of HyperlinkTool
|
|
351
|
+
* @param {object} params - Constructor params
|
|
352
|
+
* @param {object} params.api - Editor.js API
|
|
353
|
+
* @param {object} params.config - Tool configuration
|
|
354
|
+
*/
|
|
355
|
+
constructor({ api, config }) {
|
|
356
|
+
/**
|
|
357
|
+
* Handles clicks outside the popup
|
|
358
|
+
* @param {Event} e - Click event
|
|
359
|
+
*/
|
|
360
|
+
__publicField(this, "_handleOutsideClick", (e) => {
|
|
361
|
+
if (this.popup && !this.popup.contains(e.target) && !this.button.contains(e.target)) {
|
|
362
|
+
this._closePopup();
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
this.api = api;
|
|
366
|
+
this.config = config || {};
|
|
367
|
+
this.defaultTarget = this.config.target || "_blank";
|
|
368
|
+
this.defaultRel = this.config.rel || "noopener noreferrer";
|
|
369
|
+
this.availableTargets = this.config.availableTargets || ["_blank", "_self", "_parent", "_top"];
|
|
370
|
+
this.availableRels = this.config.availableRels || ["nofollow", "noreferrer", "noopener", "sponsored", "ugc"];
|
|
371
|
+
this.button = null;
|
|
372
|
+
this.popup = null;
|
|
373
|
+
this.state = false;
|
|
374
|
+
this.selectedRange = null;
|
|
375
|
+
this.existingLink = null;
|
|
376
|
+
}
|
|
346
377
|
/**
|
|
347
378
|
* Specifies this is an inline tool
|
|
348
379
|
*/
|
|
@@ -367,25 +398,6 @@ class HyperlinkTool {
|
|
|
367
398
|
}
|
|
368
399
|
};
|
|
369
400
|
}
|
|
370
|
-
/**
|
|
371
|
-
* Creates an instance of HyperlinkTool
|
|
372
|
-
* @param {object} params - Constructor params
|
|
373
|
-
* @param {object} params.api - Editor.js API
|
|
374
|
-
* @param {object} params.config - Tool configuration
|
|
375
|
-
*/
|
|
376
|
-
constructor({ api, config }) {
|
|
377
|
-
this.api = api;
|
|
378
|
-
this.config = config || {};
|
|
379
|
-
this.defaultTarget = this.config.target || "_blank";
|
|
380
|
-
this.defaultRel = this.config.rel || "noopener noreferrer";
|
|
381
|
-
this.availableTargets = this.config.availableTargets || ["_blank", "_self", "_parent", "_top"];
|
|
382
|
-
this.availableRels = this.config.availableRels || ["nofollow", "noreferrer", "noopener", "sponsored", "ugc"];
|
|
383
|
-
this.button = null;
|
|
384
|
-
this.popup = null;
|
|
385
|
-
this.state = false;
|
|
386
|
-
this.selectedRange = null;
|
|
387
|
-
this.existingLink = null;
|
|
388
|
-
}
|
|
389
401
|
/**
|
|
390
402
|
* Renders the toolbar button
|
|
391
403
|
* @returns {HTMLElement} Button element
|
|
@@ -706,15 +718,6 @@ class HyperlinkTool {
|
|
|
706
718
|
}
|
|
707
719
|
document.removeEventListener("click", this._handleOutsideClick);
|
|
708
720
|
}
|
|
709
|
-
/**
|
|
710
|
-
* Handles clicks outside the popup
|
|
711
|
-
* @param {Event} e - Click event
|
|
712
|
-
*/
|
|
713
|
-
_handleOutsideClick = (e) => {
|
|
714
|
-
if (this.popup && !this.popup.contains(e.target) && !this.button.contains(e.target)) {
|
|
715
|
-
this._closePopup();
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
721
|
/**
|
|
719
722
|
* Checks if current selection is inside a link
|
|
720
723
|
* @param {Selection} selection - Current selection
|
|
@@ -948,9 +951,9 @@ const AIInlineToolbar = ({
|
|
|
948
951
|
disabled = false,
|
|
949
952
|
onClose
|
|
950
953
|
}) => {
|
|
951
|
-
const [activeSubmenu, setActiveSubmenu] =
|
|
952
|
-
const toolbarRef =
|
|
953
|
-
|
|
954
|
+
const [activeSubmenu, setActiveSubmenu] = s.useState(null);
|
|
955
|
+
const toolbarRef = s.useRef(null);
|
|
956
|
+
s.useEffect(() => {
|
|
954
957
|
const handleClickOutside = (e) => {
|
|
955
958
|
if (toolbarRef.current && !toolbarRef.current.contains(e.target)) {
|
|
956
959
|
onClose?.();
|
|
@@ -1310,7 +1313,7 @@ class ToastManager {
|
|
|
1310
1313
|
}
|
|
1311
1314
|
const toastManager = new ToastManager();
|
|
1312
1315
|
const Toast = ({ toast, onClose }) => {
|
|
1313
|
-
const [closing, setClosing] =
|
|
1316
|
+
const [closing, setClosing] = s.useState(false);
|
|
1314
1317
|
const handleClose = () => {
|
|
1315
1318
|
setClosing(true);
|
|
1316
1319
|
setTimeout(() => {
|
|
@@ -1335,8 +1338,8 @@ const Toast = ({ toast, onClose }) => {
|
|
|
1335
1338
|
] });
|
|
1336
1339
|
};
|
|
1337
1340
|
const AIToast = () => {
|
|
1338
|
-
const [toasts, setToasts] =
|
|
1339
|
-
|
|
1341
|
+
const [toasts, setToasts] = s.useState([]);
|
|
1342
|
+
s.useEffect(() => {
|
|
1340
1343
|
const unsubscribe = toastManager.subscribe(setToasts);
|
|
1341
1344
|
return unsubscribe;
|
|
1342
1345
|
}, []);
|
|
@@ -1469,7 +1472,7 @@ class AIAssistantTool {
|
|
|
1469
1472
|
document.body.appendChild(this.toolbar);
|
|
1470
1473
|
this.toolbarRoot = client.createRoot(this.toolbar);
|
|
1471
1474
|
this.toolbarRoot.render(
|
|
1472
|
-
|
|
1475
|
+
s__default.default.createElement(AIInlineToolbar, {
|
|
1473
1476
|
position,
|
|
1474
1477
|
onAction: this._handleAction.bind(this),
|
|
1475
1478
|
loading: this.isLoading,
|
|
@@ -1607,7 +1610,7 @@ class AIAssistantTool {
|
|
|
1607
1610
|
top: rect.bottom + 8
|
|
1608
1611
|
};
|
|
1609
1612
|
this.toolbarRoot.render(
|
|
1610
|
-
|
|
1613
|
+
s__default.default.createElement(AIInlineToolbar, {
|
|
1611
1614
|
position,
|
|
1612
1615
|
onAction: this._handleAction.bind(this),
|
|
1613
1616
|
loading: this.isLoading,
|
|
@@ -1642,8 +1645,6 @@ class AIAssistantTool {
|
|
|
1642
1645
|
}
|
|
1643
1646
|
}
|
|
1644
1647
|
class MediaLibAdapter {
|
|
1645
|
-
// Track if we're currently opening from user action vs restore
|
|
1646
|
-
static _isUserAction = false;
|
|
1647
1648
|
/**
|
|
1648
1649
|
* Toolbox configuration
|
|
1649
1650
|
*/
|
|
@@ -1725,6 +1726,8 @@ class MediaLibAdapter {
|
|
|
1725
1726
|
};
|
|
1726
1727
|
}
|
|
1727
1728
|
}
|
|
1729
|
+
// Track if we're currently opening from user action vs restore
|
|
1730
|
+
__publicField(MediaLibAdapter, "_isUserAction", false);
|
|
1728
1731
|
class BoldInlineTool {
|
|
1729
1732
|
static get isInline() {
|
|
1730
1733
|
return true;
|
|
@@ -1978,7 +1981,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
1978
1981
|
linkTool: {
|
|
1979
1982
|
class: LinkTool__default.default,
|
|
1980
1983
|
config: {
|
|
1981
|
-
endpoint:
|
|
1984
|
+
endpoint: `/${pluginId}/link`,
|
|
1982
1985
|
headers: {
|
|
1983
1986
|
Authorization: authHeader
|
|
1984
1987
|
}
|
|
@@ -1999,7 +2002,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
1999
2002
|
Authorization: authHeader
|
|
2000
2003
|
},
|
|
2001
2004
|
endpoints: {
|
|
2002
|
-
byUrl:
|
|
2005
|
+
byUrl: `/${pluginId}/image/byUrl`
|
|
2003
2006
|
},
|
|
2004
2007
|
uploader: {
|
|
2005
2008
|
async uploadByFile(file) {
|
|
@@ -2007,7 +2010,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
2007
2010
|
formData.append("data", JSON.stringify({}));
|
|
2008
2011
|
formData.append("files.image", file);
|
|
2009
2012
|
try {
|
|
2010
|
-
const response = await fetch(
|
|
2013
|
+
const response = await fetch(`/${pluginId}/image/byFile`, {
|
|
2011
2014
|
method: "POST",
|
|
2012
2015
|
headers: {
|
|
2013
2016
|
Authorization: authHeader
|
|
@@ -2039,9 +2042,9 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
2039
2042
|
attaches: {
|
|
2040
2043
|
class: Attaches__default.default,
|
|
2041
2044
|
config: {
|
|
2042
|
-
endpoint:
|
|
2045
|
+
endpoint: `/${pluginId}/file/upload`,
|
|
2043
2046
|
field: "file",
|
|
2044
|
-
types: "
|
|
2047
|
+
types: "application/pdf,text/plain,text/csv,application/json,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/zip,audio/mpeg,audio/wav,audio/ogg,video/mp4,video/webm,image/jpeg,image/png,image/gif,image/webp",
|
|
2045
2048
|
buttonText: "Select file to upload",
|
|
2046
2049
|
errorMessage: "File upload failed",
|
|
2047
2050
|
additionalRequestHeaders: {
|
|
@@ -2056,7 +2059,7 @@ const getTools = ({ mediaLibToggleFunc, pluginId, openLinkPicker, customBlocks =
|
|
|
2056
2059
|
personality: {
|
|
2057
2060
|
class: Personality__default.default,
|
|
2058
2061
|
config: {
|
|
2059
|
-
endpoint:
|
|
2062
|
+
endpoint: `/${pluginId}/image/byFile`,
|
|
2060
2063
|
field: "files.image",
|
|
2061
2064
|
additionalRequestHeaders: {
|
|
2062
2065
|
Authorization: authHeader
|