import{d as e,s as t,t as n}from"./hooks.module-BrXTvcfS.js";import{U as r,a as i}from"./i18n-BaLR3UdQ.js";import{t as a}from"./server-BXh06Wz_.js";import{i as o}from"./toast-C6WyPqyA.js";import{t as s}from"./jsxRuntime.module-Cao1NCKs.js";import{J as c}from"./hooks-ClTXKdUl.js";import{t as l}from"./Modal-hBkTa-Ee.js";import{t as u}from"./Button-Du0dYm4Z.js";e();function d(){let e=n(null),a=n(null),[o,d]=t(``),[p,m]=t(!1);c(`showPasteMarkdownDialog`,async({editorApi:e})=>{r.isElectron()?f(await window.electronApi?.clipboard.readText()??``,e):(a.current=e,m(!0))});function h(){m(!1),a.current&&o&&f(o,a.current)}return s(l,{className:`markdown-import-dialog`,title:i(`markdown_import.dialog_title`),size:`lg`,footer:s(u,{className:`markdown-import-button`,text:i(`markdown_import.import_button`),keyboardShortcut:`Ctrl+Enter`,onClick:h}),onShown:()=>e.current?.focus(),onHidden:()=>{m(!1),d(``)},show:p,children:[s(`p`,{children:i(`markdown_import.modal_body_text`)}),s(`textarea`,{ref:e,value:o,onInput:e=>d(e.currentTarget.value),style:{height:340,width:`100%`},onKeyDown:e=>{e.key===`Enter`&&e.ctrlKey&&(e.preventDefault(),h())}})]})}async function f(e,t){let{htmlContent:n}=await a.post(`other/render-markdown`,{markdownContent:e});t.addHtmlToEditor(n),o.showMessage(i(`markdown_import.import_success`))}export{d as default};