tetrons 2.3.100 → 2.4.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.
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorRuntimeProps } from "./types/TetronsEditorProps";
|
|
2
2
|
import "katex/dist/katex.min.css";
|
|
3
|
-
export default function Editor(props:
|
|
3
|
+
export default function Editor(props: EditorRuntimeProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { TetronsConfig } from "./types/TetronsEditorProps";
|
|
1
2
|
import type { ValidationResponse } from "./types/ValidationResponse";
|
|
2
3
|
interface TetronsEditorProps {
|
|
3
4
|
apiKey: string;
|
|
5
|
+
config?: TetronsConfig;
|
|
4
6
|
onError?: (msg: string) => void;
|
|
5
7
|
onSuccess?: (details: ValidationResponse) => void;
|
|
6
8
|
}
|
|
7
|
-
export default function TetronsEditor({ apiKey, onError, onSuccess, }: TetronsEditorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
9
|
+
export default function TetronsEditor({ apiKey, config, onError, onSuccess, }: TetronsEditorProps): import("react/jsx-runtime").JSX.Element | null;
|
|
8
10
|
export {};
|
|
@@ -61,6 +61,32 @@ export interface PlatinumOnlyFeatureFlags {
|
|
|
61
61
|
export type ProFeatureFlags = FreeFeatureFlags;
|
|
62
62
|
export type PremiumFeatureFlags = FreeFeatureFlags & PremiumOnlyFeatureFlags;
|
|
63
63
|
export type PlatinumFeatureFlags = FreeFeatureFlags & PremiumOnlyFeatureFlags & PlatinumOnlyFeatureFlags;
|
|
64
|
+
export interface TetronsConfig {
|
|
65
|
+
version?: ProductVersion;
|
|
66
|
+
features?: FeatureFlags;
|
|
67
|
+
addOns?: PremiumOnlyFeatureFlags & PlatinumOnlyFeatureFlags;
|
|
68
|
+
autoSave?: boolean;
|
|
69
|
+
showVersions?: boolean;
|
|
70
|
+
ui?: {
|
|
71
|
+
topMenu?: boolean;
|
|
72
|
+
paragraphDropdown?: boolean;
|
|
73
|
+
fontDropdown?: boolean;
|
|
74
|
+
fontSizeDropdown?: boolean;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
export interface EditorRuntimeProps {
|
|
78
|
+
version: ProductVersion;
|
|
79
|
+
apiKey: string;
|
|
80
|
+
features?: FeatureFlags;
|
|
81
|
+
addOns?: PremiumOnlyFeatureFlags & PlatinumOnlyFeatureFlags;
|
|
82
|
+
platinumAddOns?: PlatinumOnlyFeatureFlags;
|
|
83
|
+
autoSave?: boolean;
|
|
84
|
+
showVersions?: boolean;
|
|
85
|
+
topMenu?: boolean;
|
|
86
|
+
showParagraphDropdown?: boolean;
|
|
87
|
+
showFontDropdown?: boolean;
|
|
88
|
+
showFontSizeDropdown?: boolean;
|
|
89
|
+
}
|
|
64
90
|
interface BaseProps {
|
|
65
91
|
apiKey: string;
|
|
66
92
|
topMenu?: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -17320,9 +17320,11 @@ Output: ${output}
|
|
|
17320
17320
|
}
|
|
17321
17321
|
function TetronsEditor({
|
|
17322
17322
|
apiKey,
|
|
17323
|
+
config,
|
|
17323
17324
|
onError,
|
|
17324
17325
|
onSuccess
|
|
17325
17326
|
}) {
|
|
17327
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
17326
17328
|
const [loading, setLoading] = useState(true);
|
|
17327
17329
|
const [error, setError] = useState(null);
|
|
17328
17330
|
const [details, setDetails] = useState(null);
|
|
@@ -17335,31 +17337,25 @@ function TetronsEditor({
|
|
|
17335
17337
|
body: JSON.stringify({ apiKey })
|
|
17336
17338
|
});
|
|
17337
17339
|
if (!res.ok) {
|
|
17338
|
-
|
|
17339
|
-
console.error("Server response:", errData);
|
|
17340
|
-
setError("Invalid or expired API key.");
|
|
17341
|
-
if (onError) onError("Invalid or expired API key.");
|
|
17342
|
-
setLoading(false);
|
|
17343
|
-
return;
|
|
17340
|
+
throw new Error("Invalid or expired API key.");
|
|
17344
17341
|
}
|
|
17345
17342
|
const data = await res.json();
|
|
17346
17343
|
setDetails(data);
|
|
17347
|
-
|
|
17344
|
+
onSuccess == null ? void 0 : onSuccess(data);
|
|
17348
17345
|
} catch (err) {
|
|
17349
|
-
console.error("Fetch error:", err);
|
|
17350
17346
|
const msg = err instanceof Error ? err.message : "Failed to validate API key.";
|
|
17351
17347
|
setError(msg);
|
|
17352
|
-
|
|
17348
|
+
onError == null ? void 0 : onError(msg);
|
|
17353
17349
|
} finally {
|
|
17354
17350
|
setLoading(false);
|
|
17355
17351
|
}
|
|
17356
17352
|
}
|
|
17357
17353
|
validateApiKey();
|
|
17358
|
-
}, [apiKey]);
|
|
17354
|
+
}, [apiKey, onError, onSuccess]);
|
|
17359
17355
|
if (loading) return /* @__PURE__ */ jsx("p", { children: "Validating API key..." });
|
|
17360
17356
|
if (error) return /* @__PURE__ */ jsx("p", { className: "error-message", children: error });
|
|
17361
17357
|
if (!details) return null;
|
|
17362
|
-
const
|
|
17358
|
+
const backendVersion = details.version.charAt(0).toUpperCase() + details.version.slice(1).toLowerCase();
|
|
17363
17359
|
const freeFeatures = {
|
|
17364
17360
|
newFile: true,
|
|
17365
17361
|
openFile: true,
|
|
@@ -17367,157 +17363,56 @@ function TetronsEditor({
|
|
|
17367
17363
|
cut: true,
|
|
17368
17364
|
copy: true,
|
|
17369
17365
|
paste: true,
|
|
17370
|
-
formatPainter: true,
|
|
17371
17366
|
undo: true,
|
|
17372
17367
|
redo: true,
|
|
17373
17368
|
bold: true,
|
|
17374
17369
|
italic: true,
|
|
17375
17370
|
underline: true,
|
|
17376
|
-
strikeout: true,
|
|
17377
|
-
subscript: true,
|
|
17378
|
-
superscript: true,
|
|
17379
|
-
fontColor: true,
|
|
17380
|
-
highlightColor: true,
|
|
17381
|
-
clearFormatting: true,
|
|
17382
17371
|
bulletedList: true,
|
|
17383
|
-
numberedList: true
|
|
17384
|
-
lineHeight: true,
|
|
17385
|
-
lineSpacing: true,
|
|
17386
|
-
indentIncrease: true,
|
|
17387
|
-
indentDecrease: true,
|
|
17388
|
-
alignLeft: true,
|
|
17389
|
-
alignCenter: true,
|
|
17390
|
-
alignRight: true,
|
|
17391
|
-
alignJustify: true
|
|
17372
|
+
numberedList: true
|
|
17392
17373
|
};
|
|
17393
|
-
const
|
|
17374
|
+
const premiumFeatures = {
|
|
17394
17375
|
insertTable: true,
|
|
17395
17376
|
insertImage: true,
|
|
17396
17377
|
insertVideo: true,
|
|
17397
17378
|
insertAudio: true,
|
|
17398
|
-
insertCheckboxList: true,
|
|
17399
17379
|
insertLink: true,
|
|
17400
|
-
insertComments: true,
|
|
17401
|
-
insertEmoji: true,
|
|
17402
|
-
insertHorizontalRule: true,
|
|
17403
|
-
insertEmbedVideo: true,
|
|
17404
|
-
zoomIn: true,
|
|
17405
|
-
zoomOut: true,
|
|
17406
17380
|
print: true,
|
|
17407
17381
|
exportFile: true
|
|
17408
17382
|
};
|
|
17409
|
-
const
|
|
17410
|
-
resetFormatting: true,
|
|
17411
|
-
preview: true,
|
|
17412
|
-
codeBlock: true,
|
|
17413
|
-
spellCheck: true,
|
|
17414
|
-
voice: true,
|
|
17383
|
+
const platinumFeatures = {
|
|
17415
17384
|
ai: true,
|
|
17416
|
-
|
|
17417
|
-
|
|
17385
|
+
voice: true,
|
|
17386
|
+
spellCheck: true,
|
|
17418
17387
|
mathEquation: true,
|
|
17419
|
-
|
|
17420
|
-
getContentFromImage: true
|
|
17388
|
+
codeEditor: true
|
|
17421
17389
|
};
|
|
17422
|
-
|
|
17423
|
-
|
|
17424
|
-
|
|
17425
|
-
"insertVideo",
|
|
17426
|
-
"insertAudio",
|
|
17427
|
-
"insertCheckboxList",
|
|
17428
|
-
"insertLink",
|
|
17429
|
-
"insertComments",
|
|
17430
|
-
"insertEmoji",
|
|
17431
|
-
"insertHorizontalRule",
|
|
17432
|
-
"insertEmbedVideo",
|
|
17433
|
-
"zoomIn",
|
|
17434
|
-
"zoomOut",
|
|
17435
|
-
"print",
|
|
17436
|
-
"exportFile"
|
|
17437
|
-
];
|
|
17438
|
-
const platinumAddOnKeys = [
|
|
17439
|
-
"resetFormatting",
|
|
17440
|
-
"preview",
|
|
17441
|
-
"codeBlock",
|
|
17442
|
-
"spellCheck",
|
|
17443
|
-
"voice",
|
|
17444
|
-
"ai",
|
|
17445
|
-
"languageConverter",
|
|
17446
|
-
"codeEditor",
|
|
17447
|
-
"mathEquation",
|
|
17448
|
-
"virtualKeyboard"
|
|
17449
|
-
];
|
|
17450
|
-
const activePremiumAddOns = {};
|
|
17451
|
-
const activePlatinumAddOns = {};
|
|
17452
|
-
const isPremiumAddOn = (add) => premiumAddOnKeys.includes(add);
|
|
17453
|
-
const isPlatinumAddOn = (add) => platinumAddOnKeys.includes(add);
|
|
17454
|
-
details.addOn.forEach((add) => {
|
|
17455
|
-
if (isPremiumAddOn(add)) activePremiumAddOns[add] = true;
|
|
17456
|
-
if (isPlatinumAddOn(add)) activePlatinumAddOns[add] = true;
|
|
17457
|
-
});
|
|
17458
|
-
switch (normalizedVersion) {
|
|
17459
|
-
case "Free":
|
|
17460
|
-
return /* @__PURE__ */ jsx(
|
|
17461
|
-
Editor2,
|
|
17462
|
-
{
|
|
17463
|
-
version: "Free",
|
|
17464
|
-
apiKey,
|
|
17465
|
-
topMenu: true,
|
|
17466
|
-
showParagraphDropdown: true,
|
|
17467
|
-
showFontDropdown: true,
|
|
17468
|
-
showFontSizeDropdown: true,
|
|
17469
|
-
features: freeFeatures
|
|
17470
|
-
}
|
|
17471
|
-
);
|
|
17472
|
-
case "Pro":
|
|
17473
|
-
return /* @__PURE__ */ jsx(
|
|
17474
|
-
Editor2,
|
|
17475
|
-
{
|
|
17476
|
-
version: "Pro",
|
|
17477
|
-
apiKey,
|
|
17478
|
-
topMenu: true,
|
|
17479
|
-
showParagraphDropdown: true,
|
|
17480
|
-
showFontDropdown: true,
|
|
17481
|
-
showFontSizeDropdown: true,
|
|
17482
|
-
autoSave: true,
|
|
17483
|
-
showVersions: true,
|
|
17484
|
-
features: freeFeatures,
|
|
17485
|
-
addOns: __spreadValues(__spreadValues({}, activePremiumAddOns), activePlatinumAddOns)
|
|
17486
|
-
}
|
|
17487
|
-
);
|
|
17488
|
-
case "Premium":
|
|
17489
|
-
return /* @__PURE__ */ jsx(
|
|
17490
|
-
Editor2,
|
|
17491
|
-
{
|
|
17492
|
-
version: "Premium",
|
|
17493
|
-
apiKey,
|
|
17494
|
-
topMenu: true,
|
|
17495
|
-
showParagraphDropdown: true,
|
|
17496
|
-
showFontDropdown: true,
|
|
17497
|
-
showFontSizeDropdown: true,
|
|
17498
|
-
autoSave: true,
|
|
17499
|
-
showVersions: true,
|
|
17500
|
-
features: __spreadValues(__spreadValues({}, freeFeatures), allPremiumFeatures),
|
|
17501
|
-
platinumAddOns: activePlatinumAddOns
|
|
17502
|
-
}
|
|
17503
|
-
);
|
|
17504
|
-
case "Platinum":
|
|
17505
|
-
return /* @__PURE__ */ jsx(
|
|
17506
|
-
Editor2,
|
|
17507
|
-
{
|
|
17508
|
-
version: "Platinum",
|
|
17509
|
-
apiKey,
|
|
17510
|
-
topMenu: true,
|
|
17511
|
-
showParagraphDropdown: true,
|
|
17512
|
-
showFontDropdown: true,
|
|
17513
|
-
showFontSizeDropdown: true,
|
|
17514
|
-
autoSave: true,
|
|
17515
|
-
showVersions: true,
|
|
17516
|
-
features: __spreadValues(__spreadValues(__spreadValues({}, freeFeatures), allPremiumFeatures), allPlatinumFeatures),
|
|
17517
|
-
platinumAddOns: activePlatinumAddOns
|
|
17518
|
-
}
|
|
17519
|
-
);
|
|
17390
|
+
let entitledFeatures = __spreadValues({}, freeFeatures);
|
|
17391
|
+
if (backendVersion === "Premium" || backendVersion === "Platinum") {
|
|
17392
|
+
entitledFeatures = __spreadValues(__spreadValues({}, entitledFeatures), premiumFeatures);
|
|
17520
17393
|
}
|
|
17394
|
+
if (backendVersion === "Platinum") {
|
|
17395
|
+
entitledFeatures = __spreadValues(__spreadValues({}, entitledFeatures), platinumFeatures);
|
|
17396
|
+
}
|
|
17397
|
+
const effectiveVersion = (_a = config == null ? void 0 : config.version) != null ? _a : backendVersion;
|
|
17398
|
+
const effectiveFeatures = (_b = config == null ? void 0 : config.features) != null ? _b : entitledFeatures;
|
|
17399
|
+
const effectiveAddOns = config == null ? void 0 : config.addOns;
|
|
17400
|
+
return /* @__PURE__ */ jsx(
|
|
17401
|
+
Editor2,
|
|
17402
|
+
{
|
|
17403
|
+
version: effectiveVersion,
|
|
17404
|
+
apiKey,
|
|
17405
|
+
features: effectiveFeatures,
|
|
17406
|
+
addOns: effectiveAddOns,
|
|
17407
|
+
platinumAddOns: effectiveAddOns,
|
|
17408
|
+
autoSave: config == null ? void 0 : config.autoSave,
|
|
17409
|
+
showVersions: config == null ? void 0 : config.showVersions,
|
|
17410
|
+
topMenu: (_d = (_c = config == null ? void 0 : config.ui) == null ? void 0 : _c.topMenu) != null ? _d : true,
|
|
17411
|
+
showParagraphDropdown: (_f = (_e = config == null ? void 0 : config.ui) == null ? void 0 : _e.paragraphDropdown) != null ? _f : true,
|
|
17412
|
+
showFontDropdown: (_h = (_g = config == null ? void 0 : config.ui) == null ? void 0 : _g.fontDropdown) != null ? _h : true,
|
|
17413
|
+
showFontSizeDropdown: (_j = (_i = config == null ? void 0 : config.ui) == null ? void 0 : _i.fontSizeDropdown) != null ? _j : true
|
|
17414
|
+
}
|
|
17415
|
+
);
|
|
17521
17416
|
}
|
|
17522
17417
|
|
|
17523
17418
|
// src/index.ts
|