1export class CkeditorConfigurator{constructor(){this.initialized=!1}initialize(){if(this.initialized)return;const e=window.CKEDITOR;if(e===0[0])return;this.initialized=!0,e.config.uploadImage_supportedTypes=/image\/(jpeg|pjpeg|png|x-png|gif|bmp|webp|svg\+xml|svg)/i,e.on("dialogDefinition",e=>{e.data.name==="image"&&this.configureImageDialog(e),e.data.name==="link"&&this.configureLinkDialogEvents(e.editor)}),e.on("instanceReady",t=>{const n=t.editor;["justifyleft","justifycenter","justifyright"].forEach(e=>{const t=n.getCommand(e);if(!t)return;["exec","refresh"].forEach(e=>{t.on(e,e=>{const t=n.getSelection()?.getSelectedElement();t&&t.is("img")&&e.stop()},null,null,0)})});const s=n.getCommand("unlink");s&&(s.on("refresh",t=>{this.getAttributeLinkHolder(n)&&(s.setState(e.TRISTATE_OFF),t.cancel())},null,null,0),s.on("exec",e=>{const t=this.getAttributeLinkHolder(n);if(!t)return;t.removeAttribute("data-image-link"),t.removeAttribute("data-image-link-target"),n.fire("saveSnapshot"),e.cancel()},null,null,0)),n.on("afterCommandExec",e=>{const o=e.data?.name;if(!["justifyleft","justifycenter","justifyright","justifyblock"].includes(o))return;const i=n.getSelection()?.getSelectedElement(),t=i?.getAscendant?.("picture");if(!t)return;const a=t.getAscendant({p:1,div:1,li:1,td:1,figure:1}),s=a?.getStyle("text-align")||"";["left","center","right"].includes(s)?t.setAttribute("data-image-align",s):t.removeAttribute("data-image-align")}),n.on("afterInsertHtml",()=>{const e=n.document.getElementsByTag("img").$;for(const t of e)t.setAttribute("loading","lazy")}),n.on("fileUploadResponse",function(e){let t;try{t=JSON.parse(e.data.fileLoader.xhr.responseText)}catch{return}if(!t.mediaId)return;const s=t.mediaId,o=t.url;n.once("change",function(){const e=n.document.getElementsByTag("img");for(let t=0;t<e.count();t++){const n=e.getItem(t);if(n.getAttribute("src")===o){n.setAttribute("data-media-id",s);break}}})})})}configureImageDialog(e){const o=e.data.name,t=e.data.definition,n=e.editor,s=n.config.uploadMode??"admin";this.extendInfoTab(t),this.configureAlignField(t),this.configureLinkTab(t),this.overrideTxtUrlCommit(t),this.configureDialogEvents(n,s),this.extendUploadTab(t,s)}configureAlignField(e){const n=e.getContents("info"),t=n.get("cmbAlign");if(!t)return;t.items=[["Brak",""],["Do lewej","left"],["WyÅrodkowany","center"],["Do prawej","right"]],t.default="",t.setup=function(e,t){const s=1;if(e!==s)return;const n=t.getAscendant?t.getAscendant("picture"):null,o=n&&n.getAttribute("data-image-align")||t.getAttribute("data-image-align")||"";this.setValue(o)},t.commit=function(){},delete t.onChange}configureLinkTab(e){const t=e.getContents("Link");if(!t)return;const n=t.get("txtUrl"),s=t.get("cmbTarget");n&&(n.commit=function(){}),s&&(s.commit=function(){})}configureLinkDialogEvents(e){if(e._publisherLinkDialogEventsBound)return;e._publisherLinkDialogEventsBound=!0,e.on("dialogShow",t=>{if(t.data.getName()!=="link")return;const n=t.data,s=e.getSelection().getSelectedElement();if(!s||!s.is("img")||!s.getAttribute("data-media-id"))return;if(s.getAscendant("a"))return;const o=s.getAscendant("picture")??s,c=n.on("ok",()=>{this.normalizeLinkOnImage(o)});n.on("hide",()=>c.removeListener());const i=o.getAttribute("data-image-link");if(!i)return;n.getContentElement("info","linkType")&&n.setValueOf("info","linkType","url");const a=i.match(/^(https?|ftp|news):\/\/(.*)$/i);a?(n.setValueOf("info","protocol",a[1].toLowerCase()+"://"),n.setValueOf("info","url",a[2])):(n.setValueOf("info","protocol",""),n.setValueOf("info","url",i));const r=o.getAttribute("data-image-link-target");r&&n.getContentElement("target","linkTargetType")&&n.setValueOf("target","linkTargetType",r)})}getAttributeLinkHolder(e){const t=e.getSelection()?.getSelectedElement();if(!t||!t.is("img")||!t.getAttribute("data-media-id"))return null;if(t.getAscendant("a"))return null;const n=t.getAscendant("picture")??t;return n.getAttribute("data-image-link")?n:null}normalizeLinkOnImage(e){const t=e.findOne?.("a")??(e.getParent()?.is?.("a")?e.getParent():null);if(!t)return;const n=t.getAttribute("data-cke-saved-href")||t.getAttribute("href")||"";if(n){e.setAttribute("data-image-link",n);const s=t.getAttribute("target");s?e.setAttribute("data-image-link-target",s):e.removeAttribute("data-image-link-target")}for(;t.getChildCount()>0;)t.getChild(0).insertBefore(t);t.remove()}extendInfoTab(e){const t=e.getContents("info");t.get("browse").label="Przeszukaj bibliotekÄ",t.add({id:"burda_image_show_copyright",type:"checkbox",label:"Pokaż prawa autorskie"}),t.add({id:"burda_image_show_description",type:"checkbox",label:"Pokaż opis zdjÄcia"}),t.add({id:"burda_image_show_original",type:"checkbox",label:"Pokaż oryginalne zdjÄcie"}),t.add({id:"burda_image_copyright",type:"text",label:"Prawa autorskie"}),t.add({id:"burda_image_description",type:"text",label:"Opis"}),t.add({id:"burda_data_media_id",type:"text",label:"Media ID"})}overrideTxtUrlCommit(e){const s=e.getContents("info"),t=s.get("txtUrl"),o=t.commit,n=1;t.commit=function(e,t){const s=this.getDialog(),a=this.getValue(),i=s.getValueOf("info","burda_data_media_id"),r=s.getValueOf("info","burda_image_copyright"),c=s.getValueOf("info","burda_image_description"),l=s.getValueOf("info","burda_image_show_copyright"),d=s.getValueOf("info","burda_image_show_description"),u=s.getValueOf("info","burda_image_show_original"),m=s.getParentEditor(),h=m.getSelection().getSelectedElement();if(h&&e==n){const e=s.imageElement.getParent(),t=e&&e.is("picture")?e.findOne("img"):s.imageElement;t&&(t.setAttribute("src",a),t.setAttribute("data-cke-saved-src",a),i&&t.setAttribute("data-media-id",i)),e&&e.is("picture")&&(i&&e.setAttribute("data-media-id",i),e.setAttribute("data-image-copyright",r??""),e.setAttribute("data-image-description",c??""),e.setAttribute("data-image-show-copyright",l),e.setAttribute("data-image-show-description",d),e.setAttribute("data-image-show-original",u))}if(e==n&&!h){const e=new CKEDITOR.dom.element("picture");e.setAttributes({"data-media-id":i,"data-image-copyright":r??"","data-image-description":c??"","data-image-show-copyright":l,"data-image-show-description":d,"data-image-show-original":u}),s.imageElement.setAttribute("loading","lazy"),s.imageElement.setAttribute("data-media-id",i),e.append(s.imageElement),s.imageElement=e}o?.call(this,e,t)}}configureDialogEvents(e,t){e.on("dialogShow",n=>{if(n.data.getName()!=="image")return;const s=n.data,o=e.getSelection().getSelectedElement();if(o&&o.is("img")){const t=o,n=t.getParent(),a=n&&n.is("picture"),e=a?n:t,r=e.getAttribute("data-media-id"),c=e.getAttribute("data-image-copyright")??"",l=e.getAttribute("data-image-description")??"",d=e.getAttribute("data-image-show-description"),u=e.getAttribute("data-image-show-copyright"),h=e.getAttribute("data-image-show-original"),i=[!0,"true",1];if(s.setValueOf("info","burda_image_show_description",i.includes(d)?1:0),s.setValueOf("info","burda_image_show_copyright",i.includes(u)?1:0),s.setValueOf("info","burda_image_show_original",i.includes(h)?1:0),s.setValueOf("info","burda_image_copyright",c),s.setValueOf("info","burda_image_description",l),s.setValueOf("info","burda_data_media_id",r),s.getContentElement("Link","txtUrl")){const n=e.getAttribute("data-image-link"),o=!!t.getAscendant("a");(n!==null||!o)&&(s.setValueOf("Link","txtUrl",n??""),s.setValueOf("Link","cmbTarget",e.getAttribute("data-image-link-target")??""))}s.getContentElement("info","cmbAlign")&&s.setValueOf("info","cmbAlign",e.getAttribute("data-image-align")??"")}this.registerUploadCallback(s),this.markInfoFieldsReadOnly(s),t==="user"&&($(".cke_dialog_ui_button_ok").hide(),s.selectPage("Upload"),s.hidePage("info"));const i=s.on("ok",()=>{this.applyLinkFromDialog(s),this.applyAlignFromDialog(s),this.handleCaption(s,n)});s.on("hide",()=>{i.removeListener()})})}markInfoFieldsReadOnly(e){["burda_image_copyright","burda_image_description","burda_data_media_id"].forEach(t=>{const s=e.getContentElement("info",t),n=s?.getInputElement?.();if(!n||!n.$)return;n.addClass("form-control"),n.$.setAttribute("readonly","readonly")})}registerUploadCallback(e){const t=CKEDITOR.tools.addFunction(function(e,t,n,s,o){this.setValueOf("info","txtUrl",t),this.setValueOf("info","burda_image_copyright",s),this.setValueOf("info","burda_image_description",n),this.setValueOf("info","burda_data_media_id",o),CKEDITOR.tools.callFunction(e,t,"")},e);CKEDITOR.tools.CKEditorUpdateMediaDialogFunc=t}applyLinkFromDialog(e){if(!e.getContentElement("Link","txtUrl"))return;const n=e.imageElement;if(!n)return;const r=n.is("picture")?n:n.getAscendant("picture"),t=r??n,i=(e.getValueOf("Link","txtUrl")||"").trim(),a=e.getValueOf("Link","cmbTarget")||"";
1i?(t.setAttribute("data-image-link",i),a?t.setAttribute("data-image-link-target",a):t.removeAttribute("data-image-link-target")):(t.removeAttribute("data-image-link"),t.removeAttribute("data-image-link-target"));const s=t.findOne?.("a");if(s){for(;s.getChildCount()>0;)s.getChild(0).insertBefore(s);s.remove()}const o=t.getParent();o&&o.is?.("a")&&t.replace(o)}applyAlignFromDialog(e){if(!e.getContentElement("info","cmbAlign"))return;const n=e.imageElement;if(!n)return;const t=n.is("picture")?n:n.getAscendant("picture")??n,s=e.getValueOf("info","cmbAlign")||"";t.removeStyle("float");const o=t.is("img")?t:t.findOne("img");o&&(o.removeStyle("float"),o.removeAttribute("align")),s?t.setAttribute("data-image-align",s):t.removeAttribute("data-image-align");const i=t.getAscendant({p:1,div:1,li:1,td:1,figure:1});i&&(s?i.setStyle("text-align",s):i.removeStyle("text-align"))}handleCaption(e,t){const s=t.data.definition.dialog.imageElement.getParent();s.findOne(".burda-caption")?.remove();const i=e.getValueOf("info","burda_image_show_description"),l=e.getValueOf("info","burda_image_show_original"),a=e.getValueOf("info","burda_image_show_copyright"),r=e.getValueOf("info","burda_image_description"),c=e.getValueOf("info","burda_image_copyright");s.is("picture")&&s.setAttributes({"data-image-show-copyright":a,"data-image-show-description":i,"data-image-show-original":l});let n="";if(i&&r&&(n+=r),a&&c&&(n+=n?" / ":"",n+=c),!n)return;const o=new CKEDITOR.dom.element("span");o.setAttribute("class","burda-caption"),o.setText(n),t.data.definition.dialog.imageElement.append(o),s.is("picture")&&s.append(o)}extendUploadTab(e,t){const o=e.getContents("Upload"),n=o.get("uploadButton"),i=e.dialog;this.addCustomUploadFields(e),t==="user"&&(n.filebrowser.onSelect=e=>{i.setValueOf("info","txtUrl",e),$(".cke_dialog_ui_button_ok span").click()});const s=n.onClick;n.onClick=function(e){const i=this.getDialog(),a=this.for[0],r=this.for[1],t=i.getContentElement(a,r);var n=[],o=!1;return $("#burda_custom_field_wrapper").length===0&&$(t.getInputElement().getParent().$).append('<div id="burda_custom_field_wrapper"></div>'),$(".burda_upload_custom_form_field").each(function(e,t){var s,a,r,i=$(t).find("input");$(t).hasClass("is-required")&&(i.val()==""?(i.css({"border-color":"red"}),o=!0):i.css({"border-color":"#c9cccf"})),s="",$(t).hasClass("burda_file_name")?s="name":$(t).hasClass("burda_file_description")?s="description":$(t).hasClass("burda_file_copyright")&&(s="copyright"),a=i.prop("type")=="checkbox"?i.prop("checked"):i.val(),n.push('<input type="hidden" id="upload_burda_image_'+s+'" name="'+s+'" value="'+a+'">'),r="burda_image_"+s}),$(t.getInputElement().getParent().$).find("#burda_custom_field_wrapper").html(n.join()),!o&&(!s||s.call(e.sender,e)!==!1)}}addCustomUploadFields(e){const t=e.contents.find(e=>e.id==="Upload");if(!t)return;const n=t.elements.length-1;t.elements.splice(n,0,{type:"text",id:"burda_file_name",name:"name",label:"Nazwa *",className:"burda_file_name burda_upload_custom_form_field is-required"},{type:"text",id:"burda_file_description",name:"description",label:"Opis",className:"burda_file_description burda_upload_custom_form_field"},{type:"text",id:"burda_file_copyright",name:"copyright",label:"Prawa autorskie *",className:"burda_file_copyright burda_upload_custom_form_field is-required"})}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.