Files
ntspi-app/public/js/amidesfahani/filament-tinyeditor/components/tinyeditor.js
T
2026-03-20 21:47:02 +05:00

2 lines
3.6 KiB
JavaScript
Executable File

function J({state:c,statePath:n,selector:d,plugins:u,external_plugins:m,toolbar:p,language:h="en",language_url:f=null,directionality:g="ltr",max_height:b=0,min_height:_=500,skin:y="oxide",content_css:w="default",toolbar_sticky:k=!1,templates:C="",menubar:v=!1,font_size_formats:E="",fontfamily:a="",relative_urls:x=!0,image_list:T=null,image_advtab:F=!1,image_description:A=!1,image_class_list:$=null,remove_script_host:P=!0,convert_urls:z=!0,custom_configs:D={},setup:r=null,disabled:H=!1,locale:S="en",license_key:V="gpl",placeholder:K=null}){let l=window.filamentTinyEditors||{};return{id:null,state:c,statePath:n,selector:d,language:h,language_url:f,directionality:g,max_height:b,min_height:_,skin:y,content_css:w,plugins:u,external_plugins:m,toolbar:p,toolbar_sticky:k,templates:C,menubar:v,relative_urls:x,remove_script_host:P,convert_urls:z,font_size_formats:E,fontfamily:a,setup:r,image_list:T,image_advtab:F,image_description:A,image_class_list:$,license_key:V,custom_configs:D,updatedAt:Date.now(),disabled:H,locale:S,init(){this.initEditor(c.initialValue),window.filamentTinyEditors=l,this.$watch("state",(e,o)=>{e==="<p></p>"&&e!==this.editor().getContent()&&(l[this.statePath].destroy(),this.initEditor(e)),this.editor().container&&e!==this.editor().getContent()&&(this.editor().resetContent(e||""),this.putCursorToEnd())})},editor(){return tinymce.get(l[this.statePath])},initEditor(e){let o=this,B=this.$wire;tinymce.init({selector:d,language:h,language_url:f,directionality:g,statusbar:!1,promotion:!1,max_height:b,min_height:_,skin:y,content_css:w,plugins:u,external_plugins:m,toolbar:p,toolbar_sticky:k,toolbar_sticky_offset:64,toolbar_mode:"sliding",templates:C,menubar:v,menu:{file:{title:"File",items:"newdocument restoredraft | preview | export print | deleteallconversations"},edit:{title:"Edit",items:"undo redo | cut copy paste pastetext | selectall | searchreplace"},view:{title:"View",items:"code | visualaid visualchars visualblocks | spellchecker | preview fullscreen | showcomments"},insert:{title:"Insert",items:"image link media addcomment pageembed template codesample inserttable | charmap emoticons hr | pagebreak nonbreaking anchor tableofcontents | insertdatetime"},format:{title:"Format",items:"bold italic underline strikethrough superscript subscript codeformat | styles blocks fontfamily fontsize align lineheight | forecolor backcolor | language | removeformat"},tools:{title:"Tools",items:"spellchecker spellcheckerlanguage | a11ycheck code wordcount"},table:{title:"Table",items:"inserttable | cell row column | advtablesort | tableprops deletetable"},help:{title:"Help",items:"help"}},font_size_formats:E,fontfamily:a,font_family_formats:a,relative_urls:x,remove_script_host:P,convert_urls:z,image_list:T,image_advtab:F,image_description:A,image_class_list:$,license_key:V,...D,setup:function(t){window.tinySettingsCopy||(window.tinySettingsCopy=[]),t.settings&&!window.tinySettingsCopy.some(i=>i.id===t.settings.id)&&window.tinySettingsCopy.push(t.settings),t.on("blur",function(i){o.updatedAt=Date.now(),o.state=t.getContent()}),t.on("init",function(i){l[o.statePath]=t.id,e!=null&&t.setContent(e)}),typeof r=="function"&&r(t)},images_upload_handler:(t,i)=>new Promise((U,j)=>{if(!t.blob())return;let q=()=>{B.getFormComponentFileAttachmentUrl(n).then(s=>{if(!s){j("error");return}U(s)})},G=()=>{},I=s=>{i(s.detail.progress)};B.upload(`componentFileAttachments.${n}`,t.blob(),q,G,I)}),automatic_uploads:!0})},updateEditorContent(e){this.editor().setContent(e)},putCursorToEnd(){this.editor().selection.select(this.editor().getBody(),!0),this.editor().selection.collapse(!1)}}}export{J as default};