@moontra/moonui-pro 2.8.6 → 2.8.7

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 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;
@@ -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, "Turkish");
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: "Translating to Turkish...",
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
- MoonUIDropdownMenuItemPro,
51384
- {
51385
- onClick: () => handleAIAction("translate"),
51386
- disabled: isProcessing,
51387
- children: [
51388
- /* @__PURE__ */ jsx(Languages, { className: "w-4 h-4 mr-2" }),
51389
- "Translate to Turkish"
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
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.8.6",
3
+ "version": "2.8.7",
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 {
@@ -115,6 +118,24 @@ interface AISettingsType {
115
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
@@ -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, 'Turkish');
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: "Translating to Turkish...",
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
- <DropdownMenuItem
1391
- onClick={() => handleAIAction('translate')}
1392
- disabled={isProcessing}
1393
- >
1394
- <Languages className="w-4 h-4 mr-2" />
1395
- Translate to Turkish
1396
- </DropdownMenuItem>
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}