UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 935 B
var c=Object.defineProperty;var a=(i,t)=>c(i,"name",{value:t,configurable:!0});import{IS_PROD as l}from"jodit/esm/core/constants.js";import{assert as m}from"jodit/esm/core/helpers/utils/assert.js";import{languages as d}from"../languages.js";const s=class s{constructor(t){this.jodit=t}__fetch(t,r={}){const e=this.jodit.o.translate.googleProviderOptions;return m(e,"Set googleProviderOptions"),this.jodit.fetch(e.url+"?key="+e.key,{method:"POST",data:{...r,ui:this.jodit.o.language},contentType:"application/json; charset=utf-8",withCredentials:!1}).then(o=>o.json()).catch(o=>{try{this.jodit.message.error(o.json().message)}catch(h){l||console.error(h)}})}translate(t,r,e){return this.__fetch("translate",{q:t,source:r,target:e,format:"html"}).then(o=>({text:o.data.translations[0].translatedText}))}supportedLanguages(){return Promise.resolve({langs:d})}};a(s,"GoogleTranslateProvider");let n=s;export{n as GoogleTranslateProvider};