tetrons 2.3.79 → 2.3.81
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/components/tetrons/EditorContent.tsx +8 -34
- package/dist/index.cjs +18 -33
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +17 -33
- package/package.json +1 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { MathInline } from "./extensions/MathExtension";
|
|
3
|
-
|
|
4
3
|
import React, { useEffect, useRef, useState } from "react";
|
|
5
4
|
import { useEditor, EditorContent as TiptapEditorContent } from "@tiptap/react";
|
|
6
5
|
import type { AddOn } from "./toolbar/TetronsToolbar";
|
|
@@ -57,7 +56,6 @@ lowlight.register("ts", ts);
|
|
|
57
56
|
|
|
58
57
|
type EditorContentProps = {
|
|
59
58
|
apiKey: string;
|
|
60
|
-
addOns?: string[];
|
|
61
59
|
};
|
|
62
60
|
|
|
63
61
|
export default function EditorContent({ apiKey }: EditorContentProps) {
|
|
@@ -72,6 +70,7 @@ export default function EditorContent({ apiKey }: EditorContentProps) {
|
|
|
72
70
|
const [currentVersionIndex, setCurrentVersionIndex] = useState<number | null>(
|
|
73
71
|
null
|
|
74
72
|
);
|
|
73
|
+
const [addOns, setAddOns] = useState<AddOn[]>([]);
|
|
75
74
|
|
|
76
75
|
const wrapperRef = useRef<HTMLDivElement>(null);
|
|
77
76
|
|
|
@@ -81,28 +80,23 @@ export default function EditorContent({ apiKey }: EditorContentProps) {
|
|
|
81
80
|
: "https://staging.tetrons.com";
|
|
82
81
|
|
|
83
82
|
useEffect(() => {
|
|
84
|
-
const
|
|
83
|
+
const fetchKeyData = async () => {
|
|
85
84
|
try {
|
|
86
|
-
const res = await fetch(`${API_BASE_URL}/api/
|
|
87
|
-
method: "POST",
|
|
88
|
-
headers: {
|
|
89
|
-
"Content-Type": "application/json",
|
|
90
|
-
},
|
|
91
|
-
body: JSON.stringify({ apiKey }),
|
|
92
|
-
});
|
|
93
|
-
|
|
85
|
+
const res = await fetch(`${API_BASE_URL}/api/api-key?apiKey=${apiKey}`);
|
|
94
86
|
const data = await res.json();
|
|
87
|
+
|
|
95
88
|
if (!res.ok) throw new Error(data.error || "Invalid API Key");
|
|
96
89
|
|
|
97
90
|
setIsValid(true);
|
|
98
91
|
setUserVersion(data.version);
|
|
92
|
+
setAddOns(data.addOn || []);
|
|
99
93
|
} catch (err: unknown) {
|
|
100
94
|
setError(err instanceof Error ? err.message : "Invalid API Key");
|
|
101
95
|
setIsValid(false);
|
|
102
96
|
}
|
|
103
97
|
};
|
|
104
98
|
|
|
105
|
-
|
|
99
|
+
fetchKeyData();
|
|
106
100
|
}, [apiKey, API_BASE_URL]);
|
|
107
101
|
|
|
108
102
|
const editor = useEditor({
|
|
@@ -210,20 +204,6 @@ export default function EditorContent({ apiKey }: EditorContentProps) {
|
|
|
210
204
|
return <div className="editor-loading">📖 Loading dictionary...</div>;
|
|
211
205
|
}
|
|
212
206
|
|
|
213
|
-
const versionAddOnsMap: Record<
|
|
214
|
-
"free" | "pro" | "premium" | "platinum",
|
|
215
|
-
AddOn[]
|
|
216
|
-
> = {
|
|
217
|
-
free: [],
|
|
218
|
-
pro: ["code"],
|
|
219
|
-
premium: ["code", "math"],
|
|
220
|
-
platinum: ["code", "math"],
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
const enabledAddOns = (
|
|
224
|
-
userVersion ? versionAddOnsMap[userVersion] || [] : []
|
|
225
|
-
) as AddOn[];
|
|
226
|
-
|
|
227
207
|
return (
|
|
228
208
|
<div className="editor-container">
|
|
229
209
|
{userVersion !== "free" && (
|
|
@@ -246,9 +226,7 @@ export default function EditorContent({ apiKey }: EditorContentProps) {
|
|
|
246
226
|
key={idx}
|
|
247
227
|
type="button"
|
|
248
228
|
onClick={() => restoreVersion(idx)}
|
|
249
|
-
className={`editor-version-btn ${
|
|
250
|
-
idx === currentVersionIndex ? "active" : ""
|
|
251
|
-
}`}
|
|
229
|
+
className={`editor-version-btn ${idx === currentVersionIndex ? "active" : ""}`}
|
|
252
230
|
title={`Restore Version ${idx + 1}`}
|
|
253
231
|
>
|
|
254
232
|
{`V${idx + 1}`}
|
|
@@ -260,11 +238,7 @@ export default function EditorContent({ apiKey }: EditorContentProps) {
|
|
|
260
238
|
)}
|
|
261
239
|
|
|
262
240
|
{editor && userVersion && (
|
|
263
|
-
<TetronsToolbar
|
|
264
|
-
editor={editor}
|
|
265
|
-
version={userVersion}
|
|
266
|
-
addOns={enabledAddOns}
|
|
267
|
-
/>
|
|
241
|
+
<TetronsToolbar editor={editor} version={userVersion} addOns={addOns} />
|
|
268
242
|
)}
|
|
269
243
|
|
|
270
244
|
<div
|
package/dist/index.cjs
CHANGED
|
@@ -195,6 +195,7 @@ var index_exports = {};
|
|
|
195
195
|
__export(index_exports, {
|
|
196
196
|
EditorContent: () => EditorContent,
|
|
197
197
|
default: () => index_default,
|
|
198
|
+
getTetronsAddOns: () => getTetronsAddOns,
|
|
198
199
|
getTetronsVersion: () => getTetronsVersion,
|
|
199
200
|
initializeTetrons: () => initializeTetrons,
|
|
200
201
|
isApiKeyValid: () => isApiKeyValid,
|
|
@@ -17130,28 +17131,24 @@ function EditorContent({ apiKey }) {
|
|
|
17130
17131
|
const [currentVersionIndex, setCurrentVersionIndex] = (0, import_react24.useState)(
|
|
17131
17132
|
null
|
|
17132
17133
|
);
|
|
17134
|
+
const [addOns, setAddOns] = (0, import_react24.useState)([]);
|
|
17133
17135
|
const wrapperRef = (0, import_react24.useRef)(null);
|
|
17134
17136
|
const API_BASE_URL = typeof process !== "undefined" && process.env?.NEXT_PUBLIC_TETRONS_API_URL ? process.env.NEXT_PUBLIC_TETRONS_API_URL : "https://staging.tetrons.com";
|
|
17135
17137
|
(0, import_react24.useEffect)(() => {
|
|
17136
|
-
const
|
|
17138
|
+
const fetchKeyData = async () => {
|
|
17137
17139
|
try {
|
|
17138
|
-
const res = await fetch(`${API_BASE_URL}/api/
|
|
17139
|
-
method: "POST",
|
|
17140
|
-
headers: {
|
|
17141
|
-
"Content-Type": "application/json"
|
|
17142
|
-
},
|
|
17143
|
-
body: JSON.stringify({ apiKey })
|
|
17144
|
-
});
|
|
17140
|
+
const res = await fetch(`${API_BASE_URL}/api/api-key?apiKey=${apiKey}`);
|
|
17145
17141
|
const data = await res.json();
|
|
17146
17142
|
if (!res.ok) throw new Error(data.error || "Invalid API Key");
|
|
17147
17143
|
setIsValid(true);
|
|
17148
17144
|
setUserVersion(data.version);
|
|
17145
|
+
setAddOns(data.addOn || []);
|
|
17149
17146
|
} catch (err) {
|
|
17150
17147
|
setError(err instanceof Error ? err.message : "Invalid API Key");
|
|
17151
17148
|
setIsValid(false);
|
|
17152
17149
|
}
|
|
17153
17150
|
};
|
|
17154
|
-
|
|
17151
|
+
fetchKeyData();
|
|
17155
17152
|
}, [apiKey, API_BASE_URL]);
|
|
17156
17153
|
const editor = (0, import_react25.useEditor)({
|
|
17157
17154
|
extensions: [
|
|
@@ -17248,13 +17245,6 @@ function EditorContent({ apiKey }) {
|
|
|
17248
17245
|
if (!typo) {
|
|
17249
17246
|
return /* @__PURE__ */ import_react24.default.createElement("div", { className: "editor-loading" }, "\u{1F4D6} Loading dictionary...");
|
|
17250
17247
|
}
|
|
17251
|
-
const versionAddOnsMap = {
|
|
17252
|
-
free: [],
|
|
17253
|
-
pro: ["code"],
|
|
17254
|
-
premium: ["code", "math"],
|
|
17255
|
-
platinum: ["code", "math"]
|
|
17256
|
-
};
|
|
17257
|
-
const enabledAddOns = userVersion ? versionAddOnsMap[userVersion] || [] : [];
|
|
17258
17248
|
return /* @__PURE__ */ import_react24.default.createElement("div", { className: "editor-container" }, userVersion !== "free" && /* @__PURE__ */ import_react24.default.createElement("div", { className: "editor-toolbar" }, /* @__PURE__ */ import_react24.default.createElement(
|
|
17259
17249
|
"button",
|
|
17260
17250
|
{
|
|
@@ -17274,14 +17264,7 @@ function EditorContent({ apiKey }) {
|
|
|
17274
17264
|
title: `Restore Version ${idx + 1}`
|
|
17275
17265
|
},
|
|
17276
17266
|
`V${idx + 1}`
|
|
17277
|
-
)))), editor && userVersion && /* @__PURE__ */ import_react24.default.createElement(
|
|
17278
|
-
TetronsToolbar,
|
|
17279
|
-
{
|
|
17280
|
-
editor,
|
|
17281
|
-
version: userVersion,
|
|
17282
|
-
addOns: enabledAddOns
|
|
17283
|
-
}
|
|
17284
|
-
), /* @__PURE__ */ import_react24.default.createElement(
|
|
17267
|
+
)))), editor && userVersion && /* @__PURE__ */ import_react24.default.createElement(TetronsToolbar, { editor, version: userVersion, addOns }), /* @__PURE__ */ import_react24.default.createElement(
|
|
17285
17268
|
"div",
|
|
17286
17269
|
{
|
|
17287
17270
|
ref: wrapperRef,
|
|
@@ -17324,28 +17307,29 @@ function isLicenseValid(plan) {
|
|
|
17324
17307
|
// src/index.ts
|
|
17325
17308
|
var API_VALID = false;
|
|
17326
17309
|
var API_VERSION = "";
|
|
17310
|
+
var API_ADDONS = [];
|
|
17327
17311
|
async function initializeTetrons(apiKey) {
|
|
17328
|
-
const res = await fetch(
|
|
17329
|
-
|
|
17330
|
-
|
|
17331
|
-
"Content-Type": "application/json"
|
|
17332
|
-
},
|
|
17333
|
-
body: JSON.stringify({ apiKey })
|
|
17334
|
-
});
|
|
17312
|
+
const res = await fetch(
|
|
17313
|
+
`${process.env.NEXT_PUBLIC_TETRONS_API_URL || "https://staging.tetrons.com"}/api/api-key?apiKey=${apiKey}`
|
|
17314
|
+
);
|
|
17335
17315
|
if (!res.ok) {
|
|
17336
17316
|
const error = await res.json();
|
|
17337
17317
|
throw new Error(`API Key validation failed: ${error.error}`);
|
|
17338
17318
|
}
|
|
17339
17319
|
const data = await res.json();
|
|
17340
|
-
API_VALID =
|
|
17320
|
+
API_VALID = true;
|
|
17341
17321
|
API_VERSION = data.version;
|
|
17342
|
-
|
|
17322
|
+
API_ADDONS = data.addOn || [];
|
|
17323
|
+
if (typeof window !== "undefined") {
|
|
17343
17324
|
initLicenseTracking(API_VERSION);
|
|
17344
17325
|
}
|
|
17345
17326
|
}
|
|
17346
17327
|
function getTetronsVersion() {
|
|
17347
17328
|
return API_VERSION;
|
|
17348
17329
|
}
|
|
17330
|
+
function getTetronsAddOns() {
|
|
17331
|
+
return API_ADDONS;
|
|
17332
|
+
}
|
|
17349
17333
|
function isApiKeyValid() {
|
|
17350
17334
|
return API_VALID;
|
|
17351
17335
|
}
|
|
@@ -17357,6 +17341,7 @@ var index_default = EditorContent;
|
|
|
17357
17341
|
// Annotate the CommonJS export names for ESM import in node:
|
|
17358
17342
|
0 && (module.exports = {
|
|
17359
17343
|
EditorContent,
|
|
17344
|
+
getTetronsAddOns,
|
|
17360
17345
|
getTetronsVersion,
|
|
17361
17346
|
initializeTetrons,
|
|
17362
17347
|
isApiKeyValid,
|
package/dist/index.d.mts
CHANGED
|
@@ -2,13 +2,13 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
type EditorContentProps = {
|
|
4
4
|
apiKey: string;
|
|
5
|
-
addOns?: string[];
|
|
6
5
|
};
|
|
7
6
|
declare function EditorContent({ apiKey }: EditorContentProps): React.JSX.Element;
|
|
8
7
|
|
|
9
8
|
declare function initializeTetrons(apiKey: string): Promise<void>;
|
|
10
9
|
declare function getTetronsVersion(): "" | "free" | "pro" | "premium" | "platinum";
|
|
10
|
+
declare function getTetronsAddOns(): string[];
|
|
11
11
|
declare function isApiKeyValid(): boolean;
|
|
12
12
|
declare function isTetronsLicenseValid(): boolean;
|
|
13
13
|
|
|
14
|
-
export { EditorContent, EditorContent as default, getTetronsVersion, initializeTetrons, isApiKeyValid, isTetronsLicenseValid };
|
|
14
|
+
export { EditorContent, EditorContent as default, getTetronsAddOns, getTetronsVersion, initializeTetrons, isApiKeyValid, isTetronsLicenseValid };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
type EditorContentProps = {
|
|
4
4
|
apiKey: string;
|
|
5
|
-
addOns?: string[];
|
|
6
5
|
};
|
|
7
6
|
declare function EditorContent({ apiKey }: EditorContentProps): React.JSX.Element;
|
|
8
7
|
|
|
9
8
|
declare function initializeTetrons(apiKey: string): Promise<void>;
|
|
10
9
|
declare function getTetronsVersion(): "" | "free" | "pro" | "premium" | "platinum";
|
|
10
|
+
declare function getTetronsAddOns(): string[];
|
|
11
11
|
declare function isApiKeyValid(): boolean;
|
|
12
12
|
declare function isTetronsLicenseValid(): boolean;
|
|
13
13
|
|
|
14
|
-
export { EditorContent, EditorContent as default, getTetronsVersion, initializeTetrons, isApiKeyValid, isTetronsLicenseValid };
|
|
14
|
+
export { EditorContent, EditorContent as default, getTetronsAddOns, getTetronsVersion, initializeTetrons, isApiKeyValid, isTetronsLicenseValid };
|
package/dist/index.mjs
CHANGED
|
@@ -17140,28 +17140,24 @@ function EditorContent({ apiKey }) {
|
|
|
17140
17140
|
const [currentVersionIndex, setCurrentVersionIndex] = useState11(
|
|
17141
17141
|
null
|
|
17142
17142
|
);
|
|
17143
|
+
const [addOns, setAddOns] = useState11([]);
|
|
17143
17144
|
const wrapperRef = useRef7(null);
|
|
17144
17145
|
const API_BASE_URL = typeof process !== "undefined" && process.env?.NEXT_PUBLIC_TETRONS_API_URL ? process.env.NEXT_PUBLIC_TETRONS_API_URL : "https://staging.tetrons.com";
|
|
17145
17146
|
useEffect9(() => {
|
|
17146
|
-
const
|
|
17147
|
+
const fetchKeyData = async () => {
|
|
17147
17148
|
try {
|
|
17148
|
-
const res = await fetch(`${API_BASE_URL}/api/
|
|
17149
|
-
method: "POST",
|
|
17150
|
-
headers: {
|
|
17151
|
-
"Content-Type": "application/json"
|
|
17152
|
-
},
|
|
17153
|
-
body: JSON.stringify({ apiKey })
|
|
17154
|
-
});
|
|
17149
|
+
const res = await fetch(`${API_BASE_URL}/api/api-key?apiKey=${apiKey}`);
|
|
17155
17150
|
const data = await res.json();
|
|
17156
17151
|
if (!res.ok) throw new Error(data.error || "Invalid API Key");
|
|
17157
17152
|
setIsValid(true);
|
|
17158
17153
|
setUserVersion(data.version);
|
|
17154
|
+
setAddOns(data.addOn || []);
|
|
17159
17155
|
} catch (err) {
|
|
17160
17156
|
setError(err instanceof Error ? err.message : "Invalid API Key");
|
|
17161
17157
|
setIsValid(false);
|
|
17162
17158
|
}
|
|
17163
17159
|
};
|
|
17164
|
-
|
|
17160
|
+
fetchKeyData();
|
|
17165
17161
|
}, [apiKey, API_BASE_URL]);
|
|
17166
17162
|
const editor = useEditor({
|
|
17167
17163
|
extensions: [
|
|
@@ -17258,13 +17254,6 @@ function EditorContent({ apiKey }) {
|
|
|
17258
17254
|
if (!typo) {
|
|
17259
17255
|
return /* @__PURE__ */ React17.createElement("div", { className: "editor-loading" }, "\u{1F4D6} Loading dictionary...");
|
|
17260
17256
|
}
|
|
17261
|
-
const versionAddOnsMap = {
|
|
17262
|
-
free: [],
|
|
17263
|
-
pro: ["code"],
|
|
17264
|
-
premium: ["code", "math"],
|
|
17265
|
-
platinum: ["code", "math"]
|
|
17266
|
-
};
|
|
17267
|
-
const enabledAddOns = userVersion ? versionAddOnsMap[userVersion] || [] : [];
|
|
17268
17257
|
return /* @__PURE__ */ React17.createElement("div", { className: "editor-container" }, userVersion !== "free" && /* @__PURE__ */ React17.createElement("div", { className: "editor-toolbar" }, /* @__PURE__ */ React17.createElement(
|
|
17269
17258
|
"button",
|
|
17270
17259
|
{
|
|
@@ -17284,14 +17273,7 @@ function EditorContent({ apiKey }) {
|
|
|
17284
17273
|
title: `Restore Version ${idx + 1}`
|
|
17285
17274
|
},
|
|
17286
17275
|
`V${idx + 1}`
|
|
17287
|
-
)))), editor && userVersion && /* @__PURE__ */ React17.createElement(
|
|
17288
|
-
TetronsToolbar,
|
|
17289
|
-
{
|
|
17290
|
-
editor,
|
|
17291
|
-
version: userVersion,
|
|
17292
|
-
addOns: enabledAddOns
|
|
17293
|
-
}
|
|
17294
|
-
), /* @__PURE__ */ React17.createElement(
|
|
17276
|
+
)))), editor && userVersion && /* @__PURE__ */ React17.createElement(TetronsToolbar, { editor, version: userVersion, addOns }), /* @__PURE__ */ React17.createElement(
|
|
17295
17277
|
"div",
|
|
17296
17278
|
{
|
|
17297
17279
|
ref: wrapperRef,
|
|
@@ -17334,28 +17316,29 @@ function isLicenseValid(plan) {
|
|
|
17334
17316
|
// src/index.ts
|
|
17335
17317
|
var API_VALID = false;
|
|
17336
17318
|
var API_VERSION = "";
|
|
17319
|
+
var API_ADDONS = [];
|
|
17337
17320
|
async function initializeTetrons(apiKey) {
|
|
17338
|
-
const res = await fetch(
|
|
17339
|
-
|
|
17340
|
-
|
|
17341
|
-
"Content-Type": "application/json"
|
|
17342
|
-
},
|
|
17343
|
-
body: JSON.stringify({ apiKey })
|
|
17344
|
-
});
|
|
17321
|
+
const res = await fetch(
|
|
17322
|
+
`${process.env.NEXT_PUBLIC_TETRONS_API_URL || "https://staging.tetrons.com"}/api/api-key?apiKey=${apiKey}`
|
|
17323
|
+
);
|
|
17345
17324
|
if (!res.ok) {
|
|
17346
17325
|
const error = await res.json();
|
|
17347
17326
|
throw new Error(`API Key validation failed: ${error.error}`);
|
|
17348
17327
|
}
|
|
17349
17328
|
const data = await res.json();
|
|
17350
|
-
API_VALID =
|
|
17329
|
+
API_VALID = true;
|
|
17351
17330
|
API_VERSION = data.version;
|
|
17352
|
-
|
|
17331
|
+
API_ADDONS = data.addOn || [];
|
|
17332
|
+
if (typeof window !== "undefined") {
|
|
17353
17333
|
initLicenseTracking(API_VERSION);
|
|
17354
17334
|
}
|
|
17355
17335
|
}
|
|
17356
17336
|
function getTetronsVersion() {
|
|
17357
17337
|
return API_VERSION;
|
|
17358
17338
|
}
|
|
17339
|
+
function getTetronsAddOns() {
|
|
17340
|
+
return API_ADDONS;
|
|
17341
|
+
}
|
|
17359
17342
|
function isApiKeyValid() {
|
|
17360
17343
|
return API_VALID;
|
|
17361
17344
|
}
|
|
@@ -17367,6 +17350,7 @@ var index_default = EditorContent;
|
|
|
17367
17350
|
export {
|
|
17368
17351
|
EditorContent,
|
|
17369
17352
|
index_default as default,
|
|
17353
|
+
getTetronsAddOns,
|
|
17370
17354
|
getTetronsVersion,
|
|
17371
17355
|
initializeTetrons,
|
|
17372
17356
|
isApiKeyValid,
|