tetrons 2.3.23 ā 2.3.24
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/app/page.d.ts +2 -0
- package/dist/app/page.jsx +51 -0
- package/dist/components/components/tetrons/EditorContent.tsx +60 -62
- package/dist/components/tetrons/EditorContent.d.ts +6 -0
- package/dist/components/tetrons/EditorContent.tsx +60 -62
- package/dist/components/tetrons/extensions/Spellcheck.ts +50 -0
- package/dist/components/tetrons/toolbar/MiscGroup.d.ts +7 -0
- package/dist/components/tetrons/toolbar/MiscGroup.jsx +55 -0
- package/dist/components/tetrons/toolbar/MiscGroup.tsx +33 -0
- package/dist/components/tetrons/toolbar/TetronsToolbar.d.ts +6 -0
- package/dist/index.d.ts +6 -12
- package/dist/index.js +4633 -4521
- package/dist/index.mjs +4705 -4592
- package/dist/styles/styles/tetrons.css +1 -1
- package/dist/styles/tetrons.css +1 -1
- package/dist/utils/checkGrammar.d.ts +25 -0
- package/dist/utils/checkGrammar.js +17 -0
- package/package.json +9 -9
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { MdUndo, MdRedo, MdRefresh, MdVisibility, MdCode, MdSpellcheck, } from "react-icons/md";
|
|
3
|
+
import ToolbarButton from "./ToolbarButton";
|
|
4
|
+
import { checkGrammar } from "../../../utils/checkGrammar";
|
|
5
|
+
export default function MiscGroup({ editor }) {
|
|
6
|
+
const handlePreview = () => {
|
|
7
|
+
const html = editor.getHTML();
|
|
8
|
+
const previewWindow = window.open("", "_blank");
|
|
9
|
+
if (previewWindow) {
|
|
10
|
+
previewWindow.document.open();
|
|
11
|
+
previewWindow.document.write(`
|
|
12
|
+
<html>
|
|
13
|
+
<head>
|
|
14
|
+
<title>Preview</title>
|
|
15
|
+
<style>
|
|
16
|
+
body { font-family: sans-serif; padding: 2rem; line-height: 1.6; }
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>${html}</body>
|
|
20
|
+
</html>
|
|
21
|
+
`);
|
|
22
|
+
previewWindow.document.close();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const handleGrammarCheck = async () => {
|
|
26
|
+
const text = editor.getText();
|
|
27
|
+
try {
|
|
28
|
+
const issues = await checkGrammar(text);
|
|
29
|
+
if (issues.length === 0) {
|
|
30
|
+
alert("ā
No grammar issues found.");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
let message = "š Grammar Suggestions:\n\n";
|
|
34
|
+
issues.forEach((issue, idx) => {
|
|
35
|
+
const replacements = issue.replacements
|
|
36
|
+
.map((r) => r.value)
|
|
37
|
+
.join(", ");
|
|
38
|
+
message += `${idx + 1}. "${issue.context.text}"\nā ${replacements}\nReason: ${issue.message}\n\n`;
|
|
39
|
+
});
|
|
40
|
+
alert(message);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
console.error(err);
|
|
44
|
+
alert("ā Failed to check grammar. Please try again later.");
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
return (<div className="misc-group">
|
|
48
|
+
<ToolbarButton icon={MdUndo} label="Undo" onClick={() => editor.chain().focus().undo().run()} disabled={!editor.can().undo()}/>
|
|
49
|
+
<ToolbarButton icon={MdRedo} label="Redo" onClick={() => editor.chain().focus().redo().run()} disabled={!editor.can().redo()}/>
|
|
50
|
+
<ToolbarButton icon={MdRefresh} label="Reset Formatting" onClick={() => editor.chain().focus().unsetAllMarks().clearNodes().run()}/>
|
|
51
|
+
<ToolbarButton icon={MdCode} label="Toggle Code Block" onClick={() => editor.chain().focus().toggleCodeBlock().run()} isActive={editor.isActive("codeBlock")}/>
|
|
52
|
+
<ToolbarButton icon={MdVisibility} label="Preview" onClick={handlePreview}/>
|
|
53
|
+
<ToolbarButton icon={MdSpellcheck} label="Check Grammar" onClick={handleGrammarCheck}/>
|
|
54
|
+
</div>);
|
|
55
|
+
}
|
|
@@ -5,9 +5,11 @@ import {
|
|
|
5
5
|
MdRefresh,
|
|
6
6
|
MdVisibility,
|
|
7
7
|
MdCode,
|
|
8
|
+
MdSpellcheck,
|
|
8
9
|
} from "react-icons/md";
|
|
9
10
|
import { Editor } from "@tiptap/react";
|
|
10
11
|
import ToolbarButton from "./ToolbarButton";
|
|
12
|
+
import { checkGrammar, GrammarMatch } from "../../../utils/checkGrammar";
|
|
11
13
|
|
|
12
14
|
interface MiscGroupProps {
|
|
13
15
|
editor: Editor;
|
|
@@ -34,6 +36,32 @@ export default function MiscGroup({ editor }: MiscGroupProps) {
|
|
|
34
36
|
}
|
|
35
37
|
};
|
|
36
38
|
|
|
39
|
+
const handleGrammarCheck = async () => {
|
|
40
|
+
const text = editor.getText();
|
|
41
|
+
try {
|
|
42
|
+
const issues: GrammarMatch[] = await checkGrammar(text);
|
|
43
|
+
if (issues.length === 0) {
|
|
44
|
+
alert("ā
No grammar issues found.");
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
let message = "š Grammar Suggestions:\n\n";
|
|
49
|
+
issues.forEach((issue: GrammarMatch, idx: number) => {
|
|
50
|
+
const replacements = issue.replacements
|
|
51
|
+
.map((r: { value: string }) => r.value)
|
|
52
|
+
.join(", ");
|
|
53
|
+
message += `${idx + 1}. "${
|
|
54
|
+
issue.context.text
|
|
55
|
+
}"\nā ${replacements}\nReason: ${issue.message}\n\n`;
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
alert(message);
|
|
59
|
+
} catch (err) {
|
|
60
|
+
console.error(err);
|
|
61
|
+
alert("ā Failed to check grammar. Please try again later.");
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
37
65
|
return (
|
|
38
66
|
<div className="misc-group">
|
|
39
67
|
<ToolbarButton
|
|
@@ -66,6 +94,11 @@ export default function MiscGroup({ editor }: MiscGroupProps) {
|
|
|
66
94
|
label="Preview"
|
|
67
95
|
onClick={handlePreview}
|
|
68
96
|
/>
|
|
97
|
+
<ToolbarButton
|
|
98
|
+
icon={MdSpellcheck}
|
|
99
|
+
label="Check Grammar"
|
|
100
|
+
onClick={handleGrammarCheck}
|
|
101
|
+
/>
|
|
69
102
|
</div>
|
|
70
103
|
);
|
|
71
104
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
declare function initializeTetrons(apiKey: string): Promise<void>;
|
|
9
|
-
declare function getTetronsVersion(): "" | "free" | "pro" | "premium" | "platinum";
|
|
10
|
-
declare function isApiKeyValid(): boolean;
|
|
11
|
-
|
|
12
|
-
export { EditorContent, EditorContent as default, getTetronsVersion, initializeTetrons, isApiKeyValid };
|
|
1
|
+
import EditorContent from "./components/tetrons/EditorContent";
|
|
2
|
+
export declare function initializeTetrons(apiKey: string): Promise<void>;
|
|
3
|
+
export declare function getTetronsVersion(): "" | "platinum" | "free" | "pro" | "premium";
|
|
4
|
+
export declare function isApiKeyValid(): boolean;
|
|
5
|
+
export { EditorContent };
|
|
6
|
+
export default EditorContent;
|