@moontra/moonui-pro 2.8.6 → 2.8.8
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/index.mjs +76 -25
- package/package.json +1 -1
- package/src/components/rich-text-editor/index.tsx +98 -28
package/dist/index.mjs
CHANGED
|
@@ -50238,6 +50238,22 @@ styleInject(".slash-commands-menu {\n border-radius: var(--radius);\n border-w
|
|
|
50238
50238
|
// src/components/rich-text-editor/table-styles.css
|
|
50239
50239
|
styleInject('.ProseMirror table {\n border-collapse: collapse;\n margin: 0;\n overflow: hidden;\n table-layout: fixed;\n width: 100%;\n border: 1px solid #d1d5db;\n}\n.ProseMirror table td,\n.ProseMirror table th {\n border: 1px solid #d1d5db;\n box-sizing: border-box;\n min-width: 1em;\n padding: 6px 8px;\n position: relative;\n vertical-align: top;\n}\n.ProseMirror table th {\n background-color: #f9fafb;\n font-weight: 600;\n text-align: left;\n}\n.ProseMirror table .selectedCell:after {\n background-color: rgba(59, 130, 246, 0.1);\n content: "";\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n pointer-events: none;\n position: absolute;\n z-index: 2;\n}\n.ProseMirror table .column-resize-handle {\n background-color: #3b82f6;\n bottom: -2px;\n position: absolute;\n right: -2px;\n top: 0;\n width: 4px;\n pointer-events: none;\n}\n.dark .ProseMirror table {\n border: 1px solid #374151;\n}\n.dark .ProseMirror table td,\n.dark .ProseMirror table th {\n border: 1px solid #374151;\n}\n.dark .ProseMirror table th {\n background-color: #111827;\n}\n.dark .ProseMirror table .selectedCell:after {\n background-color: rgba(59, 130, 246, 0.2);\n}\n');
|
|
50240
50240
|
var lowlight = createLowlight(grammars);
|
|
50241
|
+
var SUPPORTED_LANGUAGES = [
|
|
50242
|
+
{ code: "en", name: "English", nativeName: "English" },
|
|
50243
|
+
{ code: "tr", name: "Turkish", nativeName: "T\xFCrk\xE7e" },
|
|
50244
|
+
{ code: "es", name: "Spanish", nativeName: "Espa\xF1ol" },
|
|
50245
|
+
{ code: "fr", name: "French", nativeName: "Fran\xE7ais" },
|
|
50246
|
+
{ code: "de", name: "German", nativeName: "Deutsch" },
|
|
50247
|
+
{ code: "it", name: "Italian", nativeName: "Italiano" },
|
|
50248
|
+
{ code: "pt", name: "Portuguese", nativeName: "Portugu\xEAs" },
|
|
50249
|
+
{ code: "ru", name: "Russian", nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439" },
|
|
50250
|
+
{ code: "zh", name: "Chinese", nativeName: "\u4E2D\u6587" },
|
|
50251
|
+
{ code: "ja", name: "Japanese", nativeName: "\u65E5\u672C\u8A9E" },
|
|
50252
|
+
{ code: "ko", name: "Korean", nativeName: "\uD55C\uAD6D\uC5B4" },
|
|
50253
|
+
{ code: "ar", name: "Arabic", nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629" },
|
|
50254
|
+
{ code: "hi", name: "Hindi", nativeName: "\u0939\u093F\u0928\u094D\u0926\u0940" },
|
|
50255
|
+
{ code: "nl", name: "Dutch", nativeName: "Nederlands" }
|
|
50256
|
+
];
|
|
50241
50257
|
var getAIProvider = (settings) => {
|
|
50242
50258
|
if (!settings.apiKey)
|
|
50243
50259
|
return null;
|
|
@@ -50387,7 +50403,7 @@ function RichTextEditor({
|
|
|
50387
50403
|
] }) }) });
|
|
50388
50404
|
}
|
|
50389
50405
|
const [aiSettings, setAiSettings] = useState(() => {
|
|
50390
|
-
if (persistAISettings) {
|
|
50406
|
+
if (persistAISettings && typeof window !== "undefined") {
|
|
50391
50407
|
try {
|
|
50392
50408
|
const stored = localStorage.getItem("moonui-ai-settings");
|
|
50393
50409
|
if (stored) {
|
|
@@ -50418,6 +50434,12 @@ function RichTextEditor({
|
|
|
50418
50434
|
const [sourceContent, setSourceContent] = useState("");
|
|
50419
50435
|
const [currentTextColor, setCurrentTextColor] = useState("#000000");
|
|
50420
50436
|
const [currentBgColor, setCurrentBgColor] = useState("#ffffff");
|
|
50437
|
+
const [lastTranslateLanguage, setLastTranslateLanguage] = useState(() => {
|
|
50438
|
+
if (typeof window !== "undefined") {
|
|
50439
|
+
return localStorage.getItem("moonui-last-translate-language") || "en";
|
|
50440
|
+
}
|
|
50441
|
+
return "en";
|
|
50442
|
+
});
|
|
50421
50443
|
const slashCommands = [
|
|
50422
50444
|
{
|
|
50423
50445
|
id: "rewrite",
|
|
@@ -50606,7 +50628,7 @@ function RichTextEditor({
|
|
|
50606
50628
|
},
|
|
50607
50629
|
immediatelyRender: false
|
|
50608
50630
|
});
|
|
50609
|
-
const callAI = async (action, text) => {
|
|
50631
|
+
const callAI = async (action, text, targetLanguage) => {
|
|
50610
50632
|
if (!aiSettings.apiKey) {
|
|
50611
50633
|
toast({
|
|
50612
50634
|
title: "API Key Required",
|
|
@@ -50637,7 +50659,7 @@ function RichTextEditor({
|
|
|
50637
50659
|
response = await provider.fixGrammar(text);
|
|
50638
50660
|
break;
|
|
50639
50661
|
case "translate":
|
|
50640
|
-
response = await provider.translate(text, "
|
|
50662
|
+
response = await provider.translate(text, targetLanguage || "English");
|
|
50641
50663
|
break;
|
|
50642
50664
|
case "tone_professional":
|
|
50643
50665
|
response = await provider.changeTone(text, "professional");
|
|
@@ -50675,7 +50697,7 @@ function RichTextEditor({
|
|
|
50675
50697
|
setIsProcessing(false);
|
|
50676
50698
|
}
|
|
50677
50699
|
};
|
|
50678
|
-
const handleAIAction = async (action) => {
|
|
50700
|
+
const handleAIAction = async (action, targetLanguage) => {
|
|
50679
50701
|
if (!editor)
|
|
50680
50702
|
return;
|
|
50681
50703
|
const selection = editor.state.selection;
|
|
@@ -50690,11 +50712,11 @@ function RichTextEditor({
|
|
|
50690
50712
|
}
|
|
50691
50713
|
const processingToast = toast({
|
|
50692
50714
|
title: "Processing with AI...",
|
|
50693
|
-
description: getActionDescription(action),
|
|
50715
|
+
description: getActionDescription(action, targetLanguage),
|
|
50694
50716
|
duration: 6e4
|
|
50695
50717
|
// Long duration
|
|
50696
50718
|
});
|
|
50697
|
-
const result = await callAI(action, selectedText || editor.getText());
|
|
50719
|
+
const result = await callAI(action, selectedText || editor.getText(), targetLanguage);
|
|
50698
50720
|
processingToast.dismiss();
|
|
50699
50721
|
if (result) {
|
|
50700
50722
|
if (selectedText) {
|
|
@@ -50708,14 +50730,14 @@ function RichTextEditor({
|
|
|
50708
50730
|
});
|
|
50709
50731
|
}
|
|
50710
50732
|
};
|
|
50711
|
-
const getActionDescription = (action) => {
|
|
50733
|
+
const getActionDescription = (action, targetLanguage) => {
|
|
50712
50734
|
const descriptions = {
|
|
50713
50735
|
rewrite: "Rewriting your text...",
|
|
50714
50736
|
improve: "Improving your writing...",
|
|
50715
50737
|
expand: "Expanding your text...",
|
|
50716
50738
|
summarize: "Creating a summary...",
|
|
50717
50739
|
fix: "Fixing grammar and spelling...",
|
|
50718
|
-
translate:
|
|
50740
|
+
translate: targetLanguage ? `Translating to ${SUPPORTED_LANGUAGES.find((l) => l.name === targetLanguage)?.nativeName || targetLanguage}...` : "Translating...",
|
|
50719
50741
|
tone_professional: "Making text professional...",
|
|
50720
50742
|
tone_casual: "Making text casual...",
|
|
50721
50743
|
tone_friendly: "Making text friendly...",
|
|
@@ -51379,17 +51401,30 @@ function RichTextEditor({
|
|
|
51379
51401
|
]
|
|
51380
51402
|
}
|
|
51381
51403
|
),
|
|
51382
|
-
/* @__PURE__ */ jsxs(
|
|
51383
|
-
|
|
51384
|
-
|
|
51385
|
-
|
|
51386
|
-
|
|
51387
|
-
|
|
51388
|
-
|
|
51389
|
-
|
|
51390
|
-
|
|
51391
|
-
|
|
51392
|
-
|
|
51404
|
+
/* @__PURE__ */ jsxs(MoonUIDropdownMenuSubPro, { children: [
|
|
51405
|
+
/* @__PURE__ */ jsxs(MoonUIDropdownMenuSubTriggerPro, { disabled: isProcessing, children: [
|
|
51406
|
+
/* @__PURE__ */ jsx(Languages, { className: "w-4 h-4 mr-2" }),
|
|
51407
|
+
"Translate",
|
|
51408
|
+
lastTranslateLanguage && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: SUPPORTED_LANGUAGES.find((l) => l.code === lastTranslateLanguage)?.nativeName || "English" })
|
|
51409
|
+
] }),
|
|
51410
|
+
/* @__PURE__ */ jsx(MoonUIDropdownMenuSubContentPro, { className: "w-56", children: SUPPORTED_LANGUAGES.map((language) => /* @__PURE__ */ jsxs(
|
|
51411
|
+
MoonUIDropdownMenuItemPro,
|
|
51412
|
+
{
|
|
51413
|
+
onClick: () => {
|
|
51414
|
+
setLastTranslateLanguage(language.code);
|
|
51415
|
+
localStorage.setItem("moonui-last-translate-language", language.code);
|
|
51416
|
+
handleAIAction("translate", language.name);
|
|
51417
|
+
},
|
|
51418
|
+
disabled: isProcessing,
|
|
51419
|
+
children: [
|
|
51420
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: language.nativeName }),
|
|
51421
|
+
/* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: language.name }),
|
|
51422
|
+
lastTranslateLanguage === language.code && /* @__PURE__ */ jsx(Check, { className: "w-4 h-4 ml-2 text-primary" })
|
|
51423
|
+
]
|
|
51424
|
+
},
|
|
51425
|
+
language.code
|
|
51426
|
+
)) })
|
|
51427
|
+
] }),
|
|
51393
51428
|
/* @__PURE__ */ jsxs(
|
|
51394
51429
|
MoonUIDropdownMenuItemPro,
|
|
51395
51430
|
{
|
|
@@ -51450,11 +51485,15 @@ function RichTextEditor({
|
|
|
51450
51485
|
gemini: "gemini-2.0-flash",
|
|
51451
51486
|
cohere: "command"
|
|
51452
51487
|
};
|
|
51453
|
-
|
|
51488
|
+
const newSettings = {
|
|
51454
51489
|
...aiSettings,
|
|
51455
51490
|
provider: value,
|
|
51456
51491
|
model: defaultModels[value] || "gpt-3.5-turbo"
|
|
51457
|
-
}
|
|
51492
|
+
};
|
|
51493
|
+
setAiSettings(newSettings);
|
|
51494
|
+
if (persistAISettings) {
|
|
51495
|
+
localStorage.setItem("moonui-ai-settings", JSON.stringify(newSettings));
|
|
51496
|
+
}
|
|
51458
51497
|
},
|
|
51459
51498
|
children: [
|
|
51460
51499
|
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
@@ -51476,7 +51515,10 @@ function RichTextEditor({
|
|
|
51476
51515
|
id: "apiKey",
|
|
51477
51516
|
type: "password",
|
|
51478
51517
|
value: aiSettings.apiKey,
|
|
51479
|
-
onChange: (e) =>
|
|
51518
|
+
onChange: (e) => {
|
|
51519
|
+
const newSettings = { ...aiSettings, apiKey: e.target.value };
|
|
51520
|
+
setAiSettings(newSettings);
|
|
51521
|
+
},
|
|
51480
51522
|
placeholder: "sk-..."
|
|
51481
51523
|
}
|
|
51482
51524
|
)
|
|
@@ -51487,7 +51529,10 @@ function RichTextEditor({
|
|
|
51487
51529
|
MoonUISelectPro,
|
|
51488
51530
|
{
|
|
51489
51531
|
value: aiSettings.model,
|
|
51490
|
-
onValueChange: (value) =>
|
|
51532
|
+
onValueChange: (value) => {
|
|
51533
|
+
const newSettings = { ...aiSettings, model: value };
|
|
51534
|
+
setAiSettings(newSettings);
|
|
51535
|
+
},
|
|
51491
51536
|
children: [
|
|
51492
51537
|
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
51493
51538
|
/* @__PURE__ */ jsxs(MoonUISelectContentPro, { children: [
|
|
@@ -51526,7 +51571,10 @@ function RichTextEditor({
|
|
|
51526
51571
|
max: "2",
|
|
51527
51572
|
step: "0.1",
|
|
51528
51573
|
value: aiSettings.temperature,
|
|
51529
|
-
onChange: (e) =>
|
|
51574
|
+
onChange: (e) => {
|
|
51575
|
+
const newSettings = { ...aiSettings, temperature: parseFloat(e.target.value) };
|
|
51576
|
+
setAiSettings(newSettings);
|
|
51577
|
+
}
|
|
51530
51578
|
}
|
|
51531
51579
|
)
|
|
51532
51580
|
] }),
|
|
@@ -51540,7 +51588,10 @@ function RichTextEditor({
|
|
|
51540
51588
|
min: "1",
|
|
51541
51589
|
max: "4000",
|
|
51542
51590
|
value: aiSettings.maxTokens,
|
|
51543
|
-
onChange: (e) =>
|
|
51591
|
+
onChange: (e) => {
|
|
51592
|
+
const newSettings = { ...aiSettings, maxTokens: parseInt(e.target.value) };
|
|
51593
|
+
setAiSettings(newSettings);
|
|
51594
|
+
}
|
|
51544
51595
|
}
|
|
51545
51596
|
)
|
|
51546
51597
|
] })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.8",
|
|
4
4
|
"description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -83,6 +83,9 @@ import {
|
|
|
83
83
|
DropdownMenuItem,
|
|
84
84
|
DropdownMenuSeparator,
|
|
85
85
|
DropdownMenuTrigger,
|
|
86
|
+
DropdownMenuSub,
|
|
87
|
+
DropdownMenuSubContent,
|
|
88
|
+
DropdownMenuSubTrigger,
|
|
86
89
|
} from '../ui/dropdown-menu';
|
|
87
90
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip';
|
|
88
91
|
import {
|
|
@@ -108,13 +111,31 @@ import { createAIProvider, type AIProvider as AIProviderInterface } from '../../
|
|
|
108
111
|
type AIProvider = 'openai' | 'anthropic' | 'gemini' | 'claude' | 'cohere'
|
|
109
112
|
|
|
110
113
|
interface AISettingsType {
|
|
111
|
-
provider:
|
|
112
|
-
apiKey
|
|
113
|
-
model
|
|
114
|
-
temperature
|
|
115
|
-
maxTokens
|
|
114
|
+
provider: 'openai' | 'claude' | 'gemini' | 'cohere'
|
|
115
|
+
apiKey: string
|
|
116
|
+
model: string
|
|
117
|
+
temperature: number
|
|
118
|
+
maxTokens: number
|
|
116
119
|
}
|
|
117
120
|
|
|
121
|
+
// Supported languages for translation
|
|
122
|
+
const SUPPORTED_LANGUAGES = [
|
|
123
|
+
{ code: 'en', name: 'English', nativeName: 'English' },
|
|
124
|
+
{ code: 'tr', name: 'Turkish', nativeName: 'Türkçe' },
|
|
125
|
+
{ code: 'es', name: 'Spanish', nativeName: 'Español' },
|
|
126
|
+
{ code: 'fr', name: 'French', nativeName: 'Français' },
|
|
127
|
+
{ code: 'de', name: 'German', nativeName: 'Deutsch' },
|
|
128
|
+
{ code: 'it', name: 'Italian', nativeName: 'Italiano' },
|
|
129
|
+
{ code: 'pt', name: 'Portuguese', nativeName: 'Português' },
|
|
130
|
+
{ code: 'ru', name: 'Russian', nativeName: 'Русский' },
|
|
131
|
+
{ code: 'zh', name: 'Chinese', nativeName: '中文' },
|
|
132
|
+
{ code: 'ja', name: 'Japanese', nativeName: '日本語' },
|
|
133
|
+
{ code: 'ko', name: 'Korean', nativeName: '한국어' },
|
|
134
|
+
{ code: 'ar', name: 'Arabic', nativeName: 'العربية' },
|
|
135
|
+
{ code: 'hi', name: 'Hindi', nativeName: 'हिन्दी' },
|
|
136
|
+
{ code: 'nl', name: 'Dutch', nativeName: 'Nederlands' },
|
|
137
|
+
];
|
|
138
|
+
|
|
118
139
|
interface SlashCommand {
|
|
119
140
|
id?: string
|
|
120
141
|
title?: string
|
|
@@ -324,14 +345,14 @@ export function RichTextEditor({
|
|
|
324
345
|
|
|
325
346
|
const [aiSettings, setAiSettings] = useState<AISettingsType>(() => {
|
|
326
347
|
// Öncelik sırası: Props > LocalStorage > Varsayılan
|
|
327
|
-
if (persistAISettings) {
|
|
348
|
+
if (persistAISettings && typeof window !== 'undefined') {
|
|
328
349
|
try {
|
|
329
350
|
const stored = localStorage.getItem('moonui-ai-settings');
|
|
330
351
|
if (stored) {
|
|
331
352
|
const parsed = JSON.parse(stored);
|
|
332
353
|
// Props'tan gelen değerler her zaman öncelikli
|
|
333
354
|
return {
|
|
334
|
-
provider: aiConfig.provider || parsed.provider || 'openai',
|
|
355
|
+
provider: (aiConfig.provider || parsed.provider || 'openai') as 'openai' | 'claude' | 'gemini' | 'cohere',
|
|
335
356
|
apiKey: aiConfig.apiKey || parsed.apiKey || '',
|
|
336
357
|
model: aiConfig.model || parsed.model || 'gpt-3.5-turbo',
|
|
337
358
|
temperature: aiConfig.temperature ?? parsed.temperature ?? 0.7,
|
|
@@ -345,7 +366,7 @@ export function RichTextEditor({
|
|
|
345
366
|
|
|
346
367
|
// LocalStorage yoksa veya persist kapalıysa props/varsayılan değerleri kullan
|
|
347
368
|
return {
|
|
348
|
-
provider: aiConfig.provider || 'openai',
|
|
369
|
+
provider: (aiConfig.provider || 'openai') as 'openai' | 'claude' | 'gemini' | 'cohere',
|
|
349
370
|
apiKey: aiConfig.apiKey || '',
|
|
350
371
|
model: aiConfig.model || 'gpt-3.5-turbo',
|
|
351
372
|
temperature: aiConfig.temperature ?? 0.7,
|
|
@@ -358,6 +379,13 @@ export function RichTextEditor({
|
|
|
358
379
|
const [sourceContent, setSourceContent] = useState('');
|
|
359
380
|
const [currentTextColor, setCurrentTextColor] = useState('#000000');
|
|
360
381
|
const [currentBgColor, setCurrentBgColor] = useState('#ffffff');
|
|
382
|
+
const [lastTranslateLanguage, setLastTranslateLanguage] = useState<string>(() => {
|
|
383
|
+
// Son kullanılan dili localStorage'dan al
|
|
384
|
+
if (typeof window !== 'undefined') {
|
|
385
|
+
return localStorage.getItem('moonui-last-translate-language') || 'en';
|
|
386
|
+
}
|
|
387
|
+
return 'en';
|
|
388
|
+
});
|
|
361
389
|
|
|
362
390
|
// Slash commands tanımları
|
|
363
391
|
const slashCommands: SlashCommand[] = [
|
|
@@ -551,7 +579,7 @@ export function RichTextEditor({
|
|
|
551
579
|
});
|
|
552
580
|
|
|
553
581
|
// AI işlevleri
|
|
554
|
-
const callAI = async (action: string, text: string) => {
|
|
582
|
+
const callAI = async (action: string, text: string, targetLanguage?: string) => {
|
|
555
583
|
if (!aiSettings.apiKey) {
|
|
556
584
|
toast({
|
|
557
585
|
title: "API Key Required",
|
|
@@ -585,7 +613,7 @@ export function RichTextEditor({
|
|
|
585
613
|
response = await provider.fixGrammar(text);
|
|
586
614
|
break;
|
|
587
615
|
case 'translate':
|
|
588
|
-
response = await provider.translate(text, '
|
|
616
|
+
response = await provider.translate(text, targetLanguage || 'English');
|
|
589
617
|
break;
|
|
590
618
|
case 'tone_professional':
|
|
591
619
|
response = await provider.changeTone(text, 'professional');
|
|
@@ -625,7 +653,7 @@ export function RichTextEditor({
|
|
|
625
653
|
}
|
|
626
654
|
};
|
|
627
655
|
|
|
628
|
-
const handleAIAction = async (action: string) => {
|
|
656
|
+
const handleAIAction = async (action: string, targetLanguage?: string) => {
|
|
629
657
|
if (!editor) return;
|
|
630
658
|
|
|
631
659
|
const selection = editor.state.selection;
|
|
@@ -643,11 +671,11 @@ export function RichTextEditor({
|
|
|
643
671
|
// Show processing toast
|
|
644
672
|
const processingToast = toast({
|
|
645
673
|
title: "Processing with AI...",
|
|
646
|
-
description: getActionDescription(action),
|
|
674
|
+
description: getActionDescription(action, targetLanguage),
|
|
647
675
|
duration: 60000, // Long duration
|
|
648
676
|
});
|
|
649
677
|
|
|
650
|
-
const result = await callAI(action, selectedText || editor.getText());
|
|
678
|
+
const result = await callAI(action, selectedText || editor.getText(), targetLanguage);
|
|
651
679
|
|
|
652
680
|
// Dismiss processing toast
|
|
653
681
|
processingToast.dismiss();
|
|
@@ -667,14 +695,14 @@ export function RichTextEditor({
|
|
|
667
695
|
}
|
|
668
696
|
};
|
|
669
697
|
|
|
670
|
-
const getActionDescription = (action: string): string => {
|
|
698
|
+
const getActionDescription = (action: string, targetLanguage?: string): string => {
|
|
671
699
|
const descriptions: Record<string, string> = {
|
|
672
700
|
rewrite: "Rewriting your text...",
|
|
673
701
|
improve: "Improving your writing...",
|
|
674
702
|
expand: "Expanding your text...",
|
|
675
703
|
summarize: "Creating a summary...",
|
|
676
704
|
fix: "Fixing grammar and spelling...",
|
|
677
|
-
translate:
|
|
705
|
+
translate: targetLanguage ? `Translating to ${SUPPORTED_LANGUAGES.find(l => l.name === targetLanguage)?.nativeName || targetLanguage}...` : "Translating...",
|
|
678
706
|
tone_professional: "Making text professional...",
|
|
679
707
|
tone_casual: "Making text casual...",
|
|
680
708
|
tone_friendly: "Making text friendly...",
|
|
@@ -1387,13 +1415,38 @@ export function RichTextEditor({
|
|
|
1387
1415
|
Fix Grammar & Spelling
|
|
1388
1416
|
<span className="ml-auto text-xs text-muted-foreground">F7</span>
|
|
1389
1417
|
</DropdownMenuItem>
|
|
1390
|
-
<
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1418
|
+
<DropdownMenuSub>
|
|
1419
|
+
<DropdownMenuSubTrigger disabled={isProcessing}>
|
|
1420
|
+
<Languages className="w-4 h-4 mr-2" />
|
|
1421
|
+
Translate
|
|
1422
|
+
{lastTranslateLanguage && (
|
|
1423
|
+
<span className="ml-auto text-xs text-muted-foreground">
|
|
1424
|
+
{SUPPORTED_LANGUAGES.find(l => l.code === lastTranslateLanguage)?.nativeName || 'English'}
|
|
1425
|
+
</span>
|
|
1426
|
+
)}
|
|
1427
|
+
</DropdownMenuSubTrigger>
|
|
1428
|
+
<DropdownMenuSubContent className="w-56">
|
|
1429
|
+
{SUPPORTED_LANGUAGES.map((language) => (
|
|
1430
|
+
<DropdownMenuItem
|
|
1431
|
+
key={language.code}
|
|
1432
|
+
onClick={() => {
|
|
1433
|
+
// Dili kaydet
|
|
1434
|
+
setLastTranslateLanguage(language.code);
|
|
1435
|
+
localStorage.setItem('moonui-last-translate-language', language.code);
|
|
1436
|
+
// Çeviriyi yap
|
|
1437
|
+
handleAIAction('translate', language.name);
|
|
1438
|
+
}}
|
|
1439
|
+
disabled={isProcessing}
|
|
1440
|
+
>
|
|
1441
|
+
<span className="text-sm">{language.nativeName}</span>
|
|
1442
|
+
<span className="ml-auto text-xs text-muted-foreground">{language.name}</span>
|
|
1443
|
+
{lastTranslateLanguage === language.code && (
|
|
1444
|
+
<Check className="w-4 h-4 ml-2 text-primary" />
|
|
1445
|
+
)}
|
|
1446
|
+
</DropdownMenuItem>
|
|
1447
|
+
))}
|
|
1448
|
+
</DropdownMenuSubContent>
|
|
1449
|
+
</DropdownMenuSub>
|
|
1397
1450
|
<DropdownMenuItem
|
|
1398
1451
|
onClick={() => handleAIAction('ideas')}
|
|
1399
1452
|
disabled={isProcessing}
|
|
@@ -1459,11 +1512,16 @@ export function RichTextEditor({
|
|
|
1459
1512
|
gemini: 'gemini-2.0-flash',
|
|
1460
1513
|
cohere: 'command'
|
|
1461
1514
|
};
|
|
1462
|
-
|
|
1515
|
+
const newSettings = {
|
|
1463
1516
|
...aiSettings,
|
|
1464
1517
|
provider: value,
|
|
1465
1518
|
model: defaultModels[value] || 'gpt-3.5-turbo'
|
|
1466
|
-
}
|
|
1519
|
+
};
|
|
1520
|
+
setAiSettings(newSettings);
|
|
1521
|
+
// LocalStorage'a hemen kaydet
|
|
1522
|
+
if (persistAISettings) {
|
|
1523
|
+
localStorage.setItem('moonui-ai-settings', JSON.stringify(newSettings));
|
|
1524
|
+
}
|
|
1467
1525
|
}}
|
|
1468
1526
|
>
|
|
1469
1527
|
<SelectTrigger>
|
|
@@ -1483,7 +1541,10 @@ export function RichTextEditor({
|
|
|
1483
1541
|
id="apiKey"
|
|
1484
1542
|
type="password"
|
|
1485
1543
|
value={aiSettings.apiKey}
|
|
1486
|
-
onChange={(e) =>
|
|
1544
|
+
onChange={(e) => {
|
|
1545
|
+
const newSettings = { ...aiSettings, apiKey: e.target.value };
|
|
1546
|
+
setAiSettings(newSettings);
|
|
1547
|
+
}}
|
|
1487
1548
|
placeholder="sk-..."
|
|
1488
1549
|
/>
|
|
1489
1550
|
</div>
|
|
@@ -1491,7 +1552,10 @@ export function RichTextEditor({
|
|
|
1491
1552
|
<Label htmlFor="model">Model</Label>
|
|
1492
1553
|
<Select
|
|
1493
1554
|
value={aiSettings.model}
|
|
1494
|
-
onValueChange={(value) =>
|
|
1555
|
+
onValueChange={(value) => {
|
|
1556
|
+
const newSettings = { ...aiSettings, model: value };
|
|
1557
|
+
setAiSettings(newSettings);
|
|
1558
|
+
}}
|
|
1495
1559
|
>
|
|
1496
1560
|
<SelectTrigger>
|
|
1497
1561
|
<SelectValue />
|
|
@@ -1536,7 +1600,10 @@ export function RichTextEditor({
|
|
|
1536
1600
|
max="2"
|
|
1537
1601
|
step="0.1"
|
|
1538
1602
|
value={aiSettings.temperature}
|
|
1539
|
-
onChange={(e) =>
|
|
1603
|
+
onChange={(e) => {
|
|
1604
|
+
const newSettings = { ...aiSettings, temperature: parseFloat(e.target.value) };
|
|
1605
|
+
setAiSettings(newSettings);
|
|
1606
|
+
}}
|
|
1540
1607
|
/>
|
|
1541
1608
|
</div>
|
|
1542
1609
|
<div className="grid gap-2">
|
|
@@ -1547,7 +1614,10 @@ export function RichTextEditor({
|
|
|
1547
1614
|
min="1"
|
|
1548
1615
|
max="4000"
|
|
1549
1616
|
value={aiSettings.maxTokens}
|
|
1550
|
-
onChange={(e) =>
|
|
1617
|
+
onChange={(e) => {
|
|
1618
|
+
const newSettings = { ...aiSettings, maxTokens: parseInt(e.target.value) };
|
|
1619
|
+
setAiSettings(newSettings);
|
|
1620
|
+
}}
|
|
1551
1621
|
/>
|
|
1552
1622
|
</div>
|
|
1553
1623
|
</div>
|