import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{useRef}from"react";import{Editor}from"@tinymce/tinymce-react";import config from"../../../../../../nitrogen.config.js";import wysiwygColors from"../../utils/defaultWysiwygColors.js";import useKeyPress from"../../utils/useKeyPress.js";import"./CtrlWysiwyg.scss";let wysiwyg_colors=wysiwygColors;config.wysiwygColors&&(wysiwyg_colors=config.wysiwygColors,wysiwyg_colors=Object.keys(wysiwyg_colors).flatMap((e=>[wysiwyg_colors[e],e])));const WYSIWYG_COLORS=wysiwyg_colors;export default function CtrlWysiwyg({currMod:e,updatePath:r,prop:o,value:s,inheritVal:i,deleteProp:t,updateProps:l,saveShortcut:n}){const a=useRef(null);return useKeyPress(["s"],"ctrl",n,a.current?.editor?.iframeElement?.contentWindow?.document),_jsxs("div",{className:"ctrl-wysiwyg",children:[!1!==o.clearable&&s&&!i&&_jsx("div",{className:"ctrl-wysiwyg__clear-btn",onClick:()=>t(r),children:"Clear"}),_jsx(Editor,{tinymceScriptSrc:"/tinymce/tinymce.min.js",value:i?"":s??"Lorem ipsum dolor sit amet...",onEditorChange:(o,s)=>l(e.id,r,o),ref:a,init:{skin:window.matchMedia("(prefers-color-scheme: dark)").matches?"oxide-dark":void 0,content_css:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0,placeholder:i?s:"",plugins:["advlist","autolink","link","lists","charmap","anchor","searchreplace","wordcount","visualblocks","visualchars","code","fullscreen","insertdatetime","table","emoticons","nonbreaking"],branding:!1,promotion:!1,nonbreaking_wrap:!1,menubar:"edit view insert format",menu:{format:{title:"Format",items:"bold italic underline strikethrough superscript subscript codeformat | align | forecolor backcolor | language | removeformat"}},toolbar:"styles | fullscreen | undo redo | bold italic | bullist numlist | link | alignleft aligncenter alignright alignjustify | outdent indent",paste_as_text:!1,color_map:WYSIWYG_COLORS,...o?.config??{}}})]},e.id+r)}