inital commit

This commit is contained in:
2026-01-01 15:25:19 +05:30
commit f0ae49465a
36361 changed files with 4894111 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* [[include:plugins/ai-assistant/README.md]]
* @packageDocumentation
* @module plugins/ai-assistant
*/
import type { IJodit } from "../../types/index";
import { Plugin } from "../../core/plugin/plugin";
import "./config";
/**
* The plugin inserts content generated by AI into the editor.
*/
export declare class aiAssistant extends Plugin {
/** @override */
buttons: Plugin['buttons'];
private get __dialog();
private get __container();
constructor(jodit: IJodit);
/** @override */
afterInit(): void;
protected onGenerateAiAssistantForm(prompt: string): void;
protected onInvokeAiAssistant(prompt: string): void;
/** @override */
protected beforeDestruct(_: IJodit): void;
}

View File

@@ -0,0 +1,120 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { cache, cached } from "../../core/decorators/cache/cache.js";
import { watch } from "../../core/decorators/watch/watch.js";
import { extendLang, pluginSystem } from "../../core/global.js";
import { isAbortError } from "../../core/helpers/checker/is-abort-error.js";
import { Plugin } from "../../core/plugin/plugin.js";
import "./config.js";
import { UiAiAssistant } from "./ui/ui-ai-assistant.js";
import * as lang from "./langs/index.js";
/**
* The plugin inserts content generated by AI into the editor.
*/
export class aiAssistant extends Plugin {
get __dialog() {
return this.jodit.dlg({
buttons: ['fullsize', 'dialog.close'],
closeOnClickOverlay: true,
closeOnEsc: true,
resizable: false,
draggable: true,
minHeight: 160
});
}
get __container() {
const { jodit, __dialog } = this;
return new UiAiAssistant(jodit, {
onInsertAfter(html) {
jodit.s.focus();
jodit.s.setCursorAfter(jodit.s.current());
jodit.s.insertHTML(html);
__dialog.close();
},
onInsert(html) {
jodit.s.focus();
jodit.s.insertHTML(html);
__dialog.close();
}
});
}
constructor(jodit) {
super(jodit);
/** @override */
this.buttons = [
{
name: 'ai-commands',
group: 'insert'
},
{
name: 'ai-assistant',
group: 'insert'
}
];
extendLang(lang);
}
/** @override */
afterInit() { }
onGenerateAiAssistantForm(prompt) {
this.__dialog.open(this.__container, 'AI Assistant');
this.__container.setPrompt(prompt);
}
onInvokeAiAssistant(prompt) {
const { jodit } = this;
jodit.s.focus();
const selectedText = jodit.s.html;
jodit.async
.promise(async (resolve, reject) => {
try {
const result = await jodit.o.aiAssistant
.aiAssistantCallback(prompt, selectedText);
resolve(result);
}
catch (error) {
reject(error);
}
})
.then((htmlFragment) => {
jodit.e.fire('ai-assistant-response', htmlFragment);
})
.catch(error => {
if (isAbortError(error)) {
return;
}
jodit.message.error(error.message);
jodit.e.fire('ai-assistant-error', error.message);
});
}
/** @override */
beforeDestruct(_) {
var _a, _b;
(_a = cached(this, '__container')) === null || _a === void 0 ? void 0 : _a.destruct();
(_b = cached(this, '__dialog')) === null || _b === void 0 ? void 0 : _b.destruct();
}
}
__decorate([
cache
], aiAssistant.prototype, "__dialog", null);
__decorate([
cache
], aiAssistant.prototype, "__container", null);
__decorate([
watch(':generateAiAssistantForm.ai-assistant')
], aiAssistant.prototype, "onGenerateAiAssistantForm", null);
__decorate([
watch(':invokeAiAssistant')
], aiAssistant.prototype, "onInvokeAiAssistant", null);
pluginSystem.add('ai-assistant', aiAssistant);

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 270 270\"> <path d=\"M 255.9537,58.150081 237.69527,40.997278 c -1.49414,-1.375593 -3.43653,-2.077427 -5.37891,-2.077427 -1.94239,0 -3.88478,0.701834 -5.37892,2.077427 L 29.919751,226.1128 c -2.988286,2.77926 -2.988286,7.32714 0,10.13447 L 48.148295,253.372 c 1.46426,1.37559 3.406646,2.1055 5.378915,2.1055 1.972268,0 3.884771,-0.72991 5.378914,-2.1055 L 221.34935,100.73732 255.9537,68.284552 c 2.9584,-2.807333 2.9584,-7.355212 0,-10.134471 z M 251.17244,63.79282 221.34935,91.781927 201.89561,73.506191 231.68882,45.48901 c 0.20918,-0.140367 0.38847,-0.224587 0.62754,-0.224587 0.23906,0 0.44824,0.08422 0.59765,0.224587 l 18.25843,17.152803 c 0,0 0.23906,0.33688 0.23906,0.561467 0,0.224586 -0.0896,0.4211 -0.23906,0.58954 z\" style=\"stroke-width:2.8964;stroke-opacity:1\" /> <path d=\"m 48.626421,116.87948 10.578532,23.10435 c 0.83672,1.82477 3.615826,1.85284 4.452546,0 l 10.937126,-23.52545 c 2.629692,-5.69888 7.470715,-10.24676 13.536935,-12.71722 l 25.07172,-10.274833 c 1.94239,-0.786053 1.94239,-3.396873 0,-4.182926 L 88.13156,79.008563 C 82.06534,76.53811 77.224317,71.990231 74.594625,66.291346 L 63.657499,42.737824 c -0.83672,-1.824766 -3.615826,-1.824766 -4.452546,0 L 48.267826,66.291346 C 45.638135,71.990231 40.797112,76.53811 34.730891,79.008563 L 9.6292894,89.311474 c -1.9423859,0.786054 -1.9423859,3.3688 0,4.182926 l 25.5498446,10.61172 c 6.036338,2.49852 10.847478,7.07448 13.477169,12.77336 z\" style=\"stroke-width:2.8964;fill-opacity:1;stroke-opacity:1\" /> <path d=\"m 111.79878,33.136746 13.56682,5.642739 c 3.19747,1.319446 5.76739,3.761826 7.14201,6.793745 l 5.61797,12.268044 c 0.44825,0.982567 1.91251,0.982567 2.36075,0 l 5.79727,-12.492631 c 1.4045,-3.031919 3.97442,-5.446225 7.20177,-6.765672 l 13.29788,-5.446225 c 1.0459,-0.4211 1.0459,-1.796693 0,-2.217793 l -13.29788,-5.446225 c -3.22735,-1.319447 -5.79727,-3.733753 -7.20177,-6.765672 L 140.48633,6.2144248 c -0.44824,-0.9825664 -1.9125,-0.9825664 -2.36075,0 l -5.79727,12.4926312 c -1.4045,3.031919 -3.97442,5.446225 -7.20177,6.765672 l -13.32776,5.474298 c -1.01601,0.4211 -1.0459,1.796693 0,2.217793 z\" style=\"stroke-width:2.8964;fill-opacity:1\" /> <path d=\"m 233.09331,192.98627 -14.13459,-5.7831 c -3.40665,-1.40367 -6.12599,-3.95834 -7.62013,-7.1587 l -6.15587,-13.27868 c -0.47813,-1.03872 -2.03203,-1.03872 -2.51016,0 l -6.15587,13.27868 c -1.49414,3.20036 -4.21348,5.75503 -7.62013,7.1587 l -14.13459,5.81118 c -1.10567,0.44917 -1.10567,1.90898 0,2.35816 l 14.40354,5.97961 c 3.40664,1.40367 6.12598,3.98642 7.59024,7.21485 l 5.97658,13.02602 c 0.47812,1.03872 2.03203,1.03872 2.51016,0 l 6.15586,-13.25061 c 1.49415,-3.20036 4.21349,-5.75503 7.62013,-7.1587 l 14.1346,-5.7831 c 1.10566,-0.44917 1.10566,-1.90899 0,-2.35816 z\" style=\"stroke-width:2.8964;stroke-opacity:1\" /> </svg> ";

View File

@@ -0,0 +1 @@
export default "<svg xmlns='http://www.w3.org/2000/svg' viewBox=\"0 0 24 24\"> <g transform=\"scale(1.2 1.2) translate(-2 -0.5)\"> <path d=\"M 22,12.5 A 1.49995,1.49995 0 0 0 20.50006,11 H 20 V 10 A 3,3 0 0 0 17,7 H 13 V 5.7226 a 2,2 0 1 0 -2,0 V 7 H 7 a 3,3 0 0 0 -3,3 v 1 H 3.49994 a 1.5,1.5 0 0 0 0,3 H 4 v 1 A 3.00128,3.00128 0 0 0 6.20251,17.89282 1.03113,1.03113 0 0 1 7,18.86975 v 0.716 a 0.99928,0.99928 0 0 0 1.00726,1.002 0.9792,0.9792 0 0 0 0.69983,-0.29486 l 2,-2 A 1,1 0 0 1 11.41425,18 H 17 a 3,3 0 0 0 3,-3 v -1 h 0.50006 A 1.49995,1.49995 0 0 0 22,12.5 Z M 19,15 a 2.00226,2.00226 0 0 1 -2,2 H 11.41425 A 1.987,1.987 0 0 0 10,17.58575 l -2,2 v -0.716 A 2.02082,2.02082 0 0 0 6.46771,16.92865 2.00439,2.00439 0 0 1 5,15 V 10 A 2.00226,2.00226 0 0 1 7,8 h 10 a 2.00222,2.00222 0 0 1 2,2 z M 10,12.5 A 1.5,1.5 0 1 1 8.5,11 1.5,1.5 0 0 1 10,12.5 Z m 7,0 A 1.5,1.5 0 1 1 15.5,11 1.5,1.5 0 0 1 17,12.5 Z\"/> </g> </svg> ";

View File

@@ -0,0 +1,11 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import type { AiAssistantSettings } from "./interface";
declare module 'jodit/config' {
interface Config {
aiAssistant: AiAssistantSettings;
}
}

91
node_modules/jodit/esm/plugins/ai-assistant/config.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
import { Icon } from "../../core/ui/icon.js";
import { Config } from "../../config.js";
import magicWandIcon from "./ai-assistant.svg.js";
import chatBotIcon from "./chat-bot.svg.js";
const aiAssistantDefaults = {
aiCommonPrefixPrompt: '',
aiCommonSuffixPrompt: '',
aiImproveWritingPrompt: 'It needs to be refined for better clarity, coherence, and overall quality. Please enhance the writing style while keeping the original meaning and language intact.',
aiMakeShorterPrompt: 'Please condense this content to make it more concise, while preserving the key messages, language and information.',
aiMakeLongerPrompt: 'Expand on this content to provide more detail, depth, and richness, without diverging from the original message and language.',
aiSimplifyLanguagePrompt: 'The language used here needs to be simplified for easier understanding, without altering the core information and the original language.',
aiSummarizePrompt: 'Provide a brief summary of this content, capturing the essential points in a concise manner. Preserve the original language and meaning.',
aiContinuePrompt: 'Continue the narrative or discussion from this content seamlessly, maintaining the same language, tone and style.',
aiChangeToneProfessionalPrompt: 'Adjust the tone to be professional, suitable for a formal business or academic setting, while retaining the original message and language.',
aiChangeToneFriendlyPrompt: 'It needs to be rewritten in a friendly tone while maintaining the original message and language. Please modify this content to be warm, approachable, and engaging.',
aiChangeToneFormalPrompt: 'Transform this content to have a formal tone, appropriate for official or serious contexts, without changing the main points and language.',
aiChangeToneCasualPrompt: 'Revise this content to have a casual, relaxed tone, making it feel more personal and less formal, without changing the original meaning and language.',
aiChangeToneDirectPrompt: 'Make the tone more direct, with straightforward language and a clear, assertive approach, without changing the original meaning and language.',
aiChangeToneConfidentPrompt: 'Infuse this content with a confident tone, showcasing assurance and decisiveness, without changing the original meaning and language.',
aiChangeStyleBusinessPrompt: 'Rewrite this content with a business-oriented style, focusing on clarity, efficiency, and professionalism, without changing the original meaning and language.',
aiChangeStyleLegalPrompt: 'Adapt this content to a legal style, incorporating appropriate terminology and formality typical of legal documents, without changing the original meaning and language.',
aiChangeStyleJournalismPrompt: 'Convert this content into a journalistic style, emphasizing factual accuracy, objectivity, and informative reporting, without changing the original meaning and language.',
aiChangeStylePoeticPrompt: 'Recreate this content with a poetic style, using expressive language, rhythm, and imagery to convey the message, without changing the original meaning and language.',
aiTranslateToSpanishPrompt: 'Translate this content into Spanish, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToFrenchPrompt: 'Translate this content into French, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToGermanPrompt: 'Translate this content into German, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToItalianPrompt: 'Translate this content into Italian, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToPortuguesePrompt: 'Translate this content into Portuguese, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToEnglishPrompt: 'Translate this content into English, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToChinesePrompt: 'Translate this content into Chinese, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToJapanesePrompt: 'Translate this content into Japanese, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToKoreanPrompt: 'Translate this content into Korean, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToRussianPrompt: 'Translate this content into Russian, ensuring the translation is accurate and maintains the original meaning.',
aiTranslateToArabicPrompt: 'Translate this content into Arabic, ensuring the translation is accurate and maintains the original meaning.'
};
Config.prototype.aiAssistant = aiAssistantDefaults;
Icon.set('ai-assistant', chatBotIcon);
Icon.set('ai-commands', magicWandIcon);
Config.prototype.controls['ai-commands'] = {
isDisabled(editor) {
return !editor.o.aiAssistant.aiAssistantCallback;
},
tooltip: 'AI Commands',
list: {
aiImproveWritingPrompt: 'Improve writing',
aiMakeShorterPrompt: 'Make shorter',
aiMakeLongerPrompt: 'Make longer',
aiSimplifyLanguagePrompt: 'Simplify language',
aiSummarizePrompt: 'Summarize',
aiContinuePrompt: 'Continue',
aiChangeToneProfessionalPrompt: 'Change tone to professional',
aiChangeToneFriendlyPrompt: 'Change tone to friendly',
aiChangeToneFormalPrompt: 'Change tone to formal',
aiChangeToneCasualPrompt: 'Change tone to casual',
aiChangeToneDirectPrompt: 'Change tone to direct',
aiChangeToneConfidentPrompt: 'Change tone to confident',
aiChangeStyleBusinessPrompt: 'Change style to business',
aiChangeStyleLegalPrompt: 'Change style to legal',
aiChangeStyleJournalismPrompt: 'Change style of journalism',
aiChangeStylePoeticPrompt: 'Change style to poetic',
aiTranslateToSpanishPrompt: 'Translate to Spanish',
aiTranslateToFrenchPrompt: 'Translate to French',
aiTranslateToGermanPrompt: 'Translate to German',
aiTranslateToItalianPrompt: 'Translate to Italian',
aiTranslateToPortuguesePrompt: 'Translate to Portuguese',
aiTranslateToEnglishPrompt: 'Translate to English',
aiTranslateToChinesePrompt: 'Translate to Chinese',
aiTranslateToJapanesePrompt: 'Translate to Japanese',
aiTranslateToKoreanPrompt: 'Translate to Korean',
aiTranslateToRussianPrompt: 'Translate to Russian',
aiTranslateToArabicPrompt: 'Translate to Arabic'
},
exec: (editor, event, { control }) => {
editor.e.fire('generateAiAssistantForm.ai-assistant', control.name);
}
};
Config.prototype.controls['ai-assistant'] = {
isDisabled(editor) {
return !editor.o.aiAssistant.aiAssistantCallback;
},
hotkeys: ['ctrl+a+i', 'cmd+a+i'],
tooltip: 'AI Assistant',
exec: (editor, current, close) => {
editor.e.fire('generateAiAssistantForm.ai-assistant');
}
};

View File

@@ -0,0 +1,70 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/ai-assistant
*/
export interface AiAssistantSettings {
/** Callback function for AI assistant to process and return the result */
aiAssistantCallback?: (prompt: string, htmlFragment: string) => Promise<string>;
/** Prompt for common prefix */
aiCommonPrefixPrompt: string;
/** Prompt for common suffix */
aiCommonSuffixPrompt: string;
/** Prompt for improving writing quality */
aiImproveWritingPrompt: string;
/** Prompt for making text shorter */
aiMakeShorterPrompt: string;
/** Prompt for making text longer */
aiMakeLongerPrompt: string;
/** Prompt for simplifying language */
aiSimplifyLanguagePrompt: string;
/** Prompt for summarizing text */
aiSummarizePrompt: string;
/** Prompt for continuing text */
aiContinuePrompt: string;
/** Prompt for changing tone to professional */
aiChangeToneProfessionalPrompt: string;
/** Prompt for changing tone to friendly */
aiChangeToneFriendlyPrompt: string;
/** Prompt for changing tone to formal */
aiChangeToneFormalPrompt: string;
/** Prompt for changing tone to casual */
aiChangeToneCasualPrompt: string;
/** Prompt for changing tone to direct */
aiChangeToneDirectPrompt: string;
/** Prompt for changing tone to confident */
aiChangeToneConfidentPrompt: string;
/** Prompt for changing style to business */
aiChangeStyleBusinessPrompt: string;
/** Prompt for changing style to legal */
aiChangeStyleLegalPrompt: string;
/** Prompt for changing style to journalism */
aiChangeStyleJournalismPrompt: string;
/** Prompt for changing style to poetic */
aiChangeStylePoeticPrompt: string;
/** Prompt for translating text to Spanish */
aiTranslateToSpanishPrompt: string;
/** Prompt for translating text to French */
aiTranslateToFrenchPrompt: string;
/** Prompt for translating text to German */
aiTranslateToGermanPrompt: string;
/** Prompt for translating text to Italian */
aiTranslateToItalianPrompt: string;
/** Prompt for translating text to Portuguese */
aiTranslateToPortuguesePrompt: string;
/** Prompt for translating text to English */
aiTranslateToEnglishPrompt: string;
/** Prompt for translating text to Chinese */
aiTranslateToChinesePrompt: string;
/** Prompt for translating text to Japanese */
aiTranslateToJapanesePrompt: string;
/** Prompt for translating text to Korean */
aiTranslateToKoreanPrompt: string;
/** Prompt for translating text to Russian */
aiTranslateToRussianPrompt: string;
/** Prompt for translating text to Arabic */
aiTranslateToArabicPrompt: string;
}

View File

@@ -0,0 +1,6 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
export {};

View File

@@ -0,0 +1,9 @@
declare const _exports: {
aiAssistant: string;
aiCommands: string;
'AI Assistant': string;
Prompt: string;
'Ask AI to improve generated text': string;
Submit: string;
};
export = _exports;

View File

@@ -0,0 +1,14 @@
"use strict";
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
export default {
aiAssistant: 'AI Assistant',
aiCommands: 'AI Commands',
'AI Assistant': 'AI Assistant',
Prompt: 'Prompt',
'Ask AI to improve generated text': 'Ask AI to improve generated text',
Submit: 'Submit'
};

View File

@@ -0,0 +1,40 @@
declare const _exports: {
aiAssistant: string;
aiCommands: string;
'AI Assistant': string;
'AI Commands': string;
'Improve writing': string;
'Make shorter': string;
'Make longer': string;
'Simplify language': string;
Summarize: string;
Continue: string;
Prompt: string;
Insert: string;
'Insert After': string;
'Try Again': string;
'Ask AI to improve generated text': string;
'Change tone to professional': string;
'Change tone to friendly': string;
'Change tone to formal': string;
'Change tone to casual': string;
'Change tone to direct': string;
'Change tone to confident': string;
'Change tone to business': string;
'Change style to legal': string;
'Change style to journalism': string;
'Change style to poetic': string;
'Translate to Spanish': string;
'Translate to French': string;
'Translate to German': string;
'Translate to Italian': string;
'Translate to Portuguese': string;
'Translate to English': string;
'Translate to Chinese': string;
'Translate to Japanese': string;
'Translate to Korean': string;
'Translate to Russian': string;
'Translate to Arabic': string;
Submit: string;
};
export = _exports;

View File

@@ -0,0 +1,45 @@
"use strict";
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
export default {
aiAssistant: 'Asistente de IA',
aiCommands: 'Comandos de IA',
'AI Assistant': 'Asistente de IA',
'AI Commands': 'Comandos de IA',
'Improve writing': 'Mejorar escritura',
'Make shorter': 'Hacer más corto',
'Make longer': 'Hacer más largo',
'Simplify language': 'Simplificar lenguaje',
Summarize: 'Resumir',
Continue: 'Continuar',
Prompt: 'Solicitud',
Insert: 'Insertar',
'Insert After': 'Insertar después',
'Try Again': 'Intentar de nuevo',
'Ask AI to improve generated text': 'Pida a la IA que mejore el texto generado',
'Change tone to professional': 'Cambiar tono a profesional',
'Change tone to friendly': 'Cambiar tono a amigable',
'Change tone to formal': 'Cambiar tono a formal',
'Change tone to casual': 'Cambiar tono a casual',
'Change tone to direct': 'Cambiar tono a directo',
'Change tone to confident': 'Cambiar tono a confiado',
'Change tone to business': 'Cambiar tono a empresarial',
'Change style to legal': 'Cambiar estilo a legal',
'Change style to journalism': 'Cambiar estilo a periodístico',
'Change style to poetic': 'Cambiar estilo a poético',
'Translate to Spanish': 'Traducir al español',
'Translate to French': 'Traducir al francés',
'Translate to German': 'Traducir al alemán',
'Translate to Italian': 'Traducir al italiano',
'Translate to Portuguese': 'Traducir al portugués',
'Translate to English': 'Traducir al inglés',
'Translate to Chinese': 'Traducir al chino',
'Translate to Japanese': 'Traducid al japonés',
'Translate to Korean': 'Traducir al coreano',
'Translate to Russian': 'Traducir al ruso',
'Translate to Arabic': 'Traducir al árabe',
Submit: 'Enviar'
};

View File

@@ -0,0 +1,11 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/ai-assistant
*/
import * as en from "./en";
import * as es from "./es";
export { en, es };

View File

@@ -0,0 +1,11 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/ai-assistant
*/
import * as en from "./en.js";
import * as es from "./es.js";
export { en, es };

View File

@@ -0,0 +1,37 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
/**
* @module plugins/ai-assistant
*/
import type { IJodit } from "../../../types/index";
import { UITextArea } from "../../../core/ui/index";
import { UIElement } from "../../../core/ui/element";
export declare class UiAiAssistant extends UIElement<IJodit> {
private __body;
private __buttons;
private __results;
private __spinner;
private __error;
promptInput: UITextArea;
private __insertAfterButton;
private __submitButton;
private __tryAgainButton;
private __insertButton;
private __formAiAssistant;
className(): string;
constructor(jodit: IJodit, { onInsert, onInsertAfter }: {
onInsert: (html: string) => void;
onInsertAfter: (html: string) => void;
});
protected render(): string;
setPrompt(prompt: string): void;
private __aiResult;
protected onAiAssistentResponse(result: string): void;
protected onAiAssistentError(error: string): void;
protected onChangePromptValue(): void;
private __toggleSubmitButton;
private __toggleInsertButton;
}

View File

@@ -0,0 +1,152 @@
/*!
* Jodit Editor (https://xdsoft.net/jodit/)
* Released under MIT see LICENSE.txt in the project root for license information.
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
*/
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { component } from "../../../core/decorators/component/component.js";
import { watch } from "../../../core/decorators/watch/watch.js";
import { Dom } from "../../../core/dom/dom.js";
import { isString } from "../../../core/helpers/checker/is-string.js";
import { Button, UIBlock, UIForm, UITextArea } from "../../../core/ui/index.js";
import { UIElement } from "../../../core/ui/element.js";
let UiAiAssistant = class UiAiAssistant extends UIElement {
className() {
return 'UIAiAssistant';
}
constructor(jodit, { onInsert, onInsertAfter }) {
super(jodit);
this.__aiResult = '';
this.__error = this.getElm('error');
this.__body = this.getElm('body');
this.__buttons = this.getElm('buttons');
this.__results = this.getElm('results');
this.__spinner = this.getElm('spinner');
this.__insertButton = Button(jodit, '', 'Insert', 'primary').onAction(() => onInsert(this.__aiResult));
this.__insertAfterButton = Button(jodit, '', 'Insert After', 'initial').onAction(() => onInsertAfter(this.__aiResult));
const onSubmit = () => {
if (this.__formAiAssistant.validate()) {
this.__formAiAssistant.submit();
this.__toggleInsertButton(true);
this.__toggleSubmitButton(true);
}
};
this.__submitButton = Button(jodit, 'ai-assistant', '').onAction(onSubmit);
this.__tryAgainButton = Button(jodit, 'update', '', 'initial').onAction(onSubmit);
this.promptInput = new UITextArea(jodit, {
name: 'prompt',
required: true,
label: 'Prompt',
placeholder: 'Ask AI to improve generated text',
className: this.getFullElName('prompt-row-input')
});
const buttonsBLock = new UIBlock(jodit, [
this.__insertButton,
this.__insertAfterButton,
this.__tryAgainButton
], {
className: this.getFullElName('prompt-row')
});
this.__formAiAssistant = new UIForm(jodit, [
new UIBlock(jodit, [this.promptInput, this.__submitButton], {
className: this.getFullElName('prompt-row')
})
]).onSubmit((data) => {
this.__error.textContent = '';
this.setMod('loading', true);
jodit.e.fire('invokeAiAssistant', data.prompt);
const hideMod = this.getFullElName('', 'hide', 'true');
this.__results.classList.remove(hideMod);
this.__buttons.classList.remove(hideMod);
Dom.detach(this.__results);
this.__results.appendChild(this.__spinner);
this.__insertButton.focus();
});
this.__buttons.appendChild(buttonsBLock.container);
this.__body.appendChild(this.__formAiAssistant.container);
this.onChangePromptValue();
}
render() {
return `<div>
<div class="&__container">
<div class="&__error"></div>
<div class="&__body"></div>
<div class="&__buttons &_hide_true"></div>
<div class="&__results &_hide_true">
<div class="&__spinner"></div>
</div>
</div>
</div>`;
}
setPrompt(prompt) {
if (prompt) {
const { jodit } = this;
const promptOpt = jodit.o.aiAssistant[prompt];
const { aiCommonPrefixPrompt, aiCommonSuffixPrompt } = jodit.o.aiAssistant;
this.promptInput.value = [
aiCommonPrefixPrompt,
isString(promptOpt) ? promptOpt : '',
aiCommonSuffixPrompt
]
.filter(Boolean)
.join(' ');
this.__toggleInsertButton(true);
if (this.promptInput.value) {
this.__formAiAssistant.submit();
this.__toggleSubmitButton(true);
}
}
this.promptInput.focus();
}
onAiAssistentResponse(result) {
this.setMod('loading', false);
Dom.detach(this.__results);
this.__aiResult = result;
this.__results.appendChild(this.jodit.c.fromHTML(result));
this.__toggleSubmitButton(false);
this.__toggleInsertButton(false);
}
onAiAssistentError(error) {
this.__aiResult = '';
this.setMod('loading', false);
this.__error.textContent = error;
Dom.detach(this.__results);
this.__toggleSubmitButton(false);
const hideMod = this.getFullElName('', 'hide', 'true');
this.__results.classList.add(hideMod);
this.__toggleInsertButton(true);
}
onChangePromptValue() {
this.__toggleSubmitButton(!this.promptInput.value);
}
__toggleSubmitButton(value) {
this.__submitButton.state.disabled = value;
this.__tryAgainButton.state.disabled = value;
}
__toggleInsertButton(value) {
this.__insertButton.state.disabled = value;
this.__insertAfterButton.state.disabled = value;
}
};
__decorate([
watch(':ai-assistant-response')
], UiAiAssistant.prototype, "onAiAssistentResponse", null);
__decorate([
watch(':ai-assistant-error')
], UiAiAssistant.prototype, "onAiAssistentError", null);
__decorate([
watch('promptInput:change')
], UiAiAssistant.prototype, "onChangePromptValue", null);
UiAiAssistant = __decorate([
component
], UiAiAssistant);
export { UiAiAssistant };