UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 3.75 kB
var d=Object.defineProperty;var n=(e,t)=>d(e,"name",{value:t,configurable:!0});var r;import{base64ToFile as p}from"../ai-assistant-pro/helpers/base64tofile.js";import m from"./icons/add-context.svg.js";import c from"./icons/ai-assistant.svg.js";import f from"./icons/ai-commands.svg.js";import g from"./icons/send.svg.js";import{getToolNames as h}from"./tools/index.js";import{Config as s}from"jodit/esm/config.js";import{Icon as A}from"jodit/esm/core/ui/icon.js";import{aiAssitentCommands as y}from"jodit/esm/plugins/ai-assistant/config.js";import{marked as C}from"marked";A.set("ai-assistant-pro",c).set("ai-commands-pro",f).set("ai-add-context",m).set("send",g),s.prototype.aiAssistantPro={displayMode:"right",panelWidth:400,panelHeight:500,flightPanelHeight:250,dialogFullSize:!1,resizable:!0,apiMode:"incremental",apiRequest:null,maxRetries:3,requestTimeout:6e4*5,retryDelay:1e3,maxRecursionToolCallDepth:1e3,enabledTools:h(),customTools:[],toolPermissions:{},autoApproveTools:["readDocument","readBlocks","readSelection","insertHTML"],alwaysDenyTools:[],defaultPermissionScope:"conversation",storage:"indexedDB",maxConversations:50,storageKey:"jodit-ai-assistant-pro",showConversationList:!0,enableMarkdown:!0,enableCodeHighlight:!0,maxMessageHeight:400,placeholderText:"Ask AI assistant...",sendShortcut:"Ctrl+Enter",showTimestamps:!0,formatTimestamp:n((e,t)=>{const o=new Date(e),a=new Date().getTime()-o.getTime();return a<6e4?t("Just now"):a<36e5?t("%dm ago",Math.floor(a/6e4)):a<864e5?t("%dh ago",Math.floor(a/36e5)):o.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})},"formatTimestamp"),formatMessageContent:n((e,t)=>C.parse(e,{breaks:!0,gfm:!0}),"formatMessageContent"),showAvatars:!0,showTypingIndicator:!0,includeSelectionByDefault:!0,maxContextRanges:5,showContextPreview:!0,sendOnEnter:!0,instructions:void 0,includeEditorMetadata:!1,autoOpen:!0,rememberLastConversation:!0,autoFocusInput:!0,closeAfterInsert:!1,enableSoundNotifications:!1,debug:!1,quickCommandsSilentMode:!1,quickCommandsDisplayMode:"flight",showCopyMessageAction:!0,showRestartMessageAction:!0,showEditMessageAction:!0,showDeleteMessageAction:!0,dialogSettings:{},allowEditDialogSettings:!1,allowEditDisplayMode:!0,allowEditPanelWidth:!0,initiallyOpened:!1,allowClose:!0,persistOpenState:!0,theme:"parent",allowEditTheme:!0,async uploadBase64Artifact(e,t){if(e.type==="image"&&e.data&&e.data.kind==="base64")try{const o=p(e.data.base64,e.id,e.mimeType),i=await t.uploader.upload([o]);return{...e,data:{kind:"url",url:i.baseurl+i.files[0]},metadata:{...e.metadata,filename:i.files[0]}}}catch(o){t.e.fire("error",o)}return e}},s.prototype.controls.aiAssistantPro={icon:"ai-assistant-pro",tooltip:"AI Assistant",hotkeys:["ctrl+shift+a","cmd+shift+a"],exec(e){e.e.fire("openAIAssistantPro.ai-assistant-pro")},isDisabled(e){return!e.o.aiAssistantPro.apiRequest},getLabel(e){return e.o.aiAssistantPro.apiRequest?"AI Assistant":"AI Assistant (not configured)"}},s.prototype.controls.aiAddContext={icon:"ai-add-context",tooltip:"Add to AI Context",exec(e){e.e.fire("addContextToAIAssistant")},isDisabled(e){return e.o.aiAssistantPro.apiRequest?e.s.isCollapsed():!0}},s.prototype.controls.aiCommandsPro={icon:"ai-commands-pro",tooltip:"AI Commands",isDisabled(e){return!e.o.aiAssistantPro.apiRequest},list:y,exec(e,t,{control:o}){e.e.fire("executeQuickCommand.ai-assistant-pro",o.name)}};const l=((r=s.prototype.tuneBlock)===null||r===void 0?void 0:r.popup)||{},u={},w=["p","h1","h2","h3","h4","h5","h6","div","section","article","pre","blockquote","ul","ol","li","table","tr","td","th","img","figure"];w.forEach(e=>{const t=l[e]||["tune.up","tune.remove","tune.down"];u[e]=[...t,"|","aiAddContext"]}),s.prototype.tuneBlock&&(s.prototype.tuneBlock.popup={...l,...u});