diff --git a/dist/filepond-plugin-manage-metadata.esm.js b/dist/filepond-plugin-manage-metadata.esm.js index 7487a73..25d2fb7 100644 --- a/dist/filepond-plugin-manage-metadata.esm.js +++ b/dist/filepond-plugin-manage-metadata.esm.js @@ -63,12 +63,18 @@ const plugin = fpAPI => { ); const onManageMetadata = root.query('GET_ON_MANAGE_METADATA'); - registerManageMetadataComponent( - item, - root.element, - labelButtonManageMetadata, - onManageMetadata - ); + if (onManageMetadata) { + registerManageMetadataComponent( + item, + root.element, + labelButtonManageMetadata, + onManageMetadata + ); + } else { + console.error( + "No 'onManageMetadata' callback method specified for FilePondPluginManageMetadata! See https://github.com/nielsboogaard/filepond-plugin-manage-metadata for more instructions." + ); + } }; // start writing diff --git a/dist/filepond-plugin-manage-metadata.esm.min.js b/dist/filepond-plugin-manage-metadata.esm.min.js index ecb4cfb..b4da821 100644 --- a/dist/filepond-plugin-manage-metadata.esm.min.js +++ b/dist/filepond-plugin-manage-metadata.esm.min.js @@ -6,4 +6,4 @@ /* eslint-disable */ -const e=e=>{let t=document.createElement("span");return t.className="filepond--edit-icon",t.title=e,t},t=t=>{const{addFilter:n,utils:o}=t,{Type:i,createRoute:d}=o;return n("CREATE_VIEW",t=>{const{is:n,view:o,query:i}=t;if(!n("file"))return;o.registerWriter(d({DID_LOAD_ITEM:({root:t,props:n})=>{const{id:o}=n,d=i("GET_ITEM",o);if(!d||d.archived)return;const r=t.query("GET_LABEL_BUTTON_MANAGE_METADATA"),a=t.query("GET_ON_MANAGE_METADATA");((t,n,o,i)=>{const d=n.querySelector(".filepond--file-info-main"),r=e(o);d.prepend(r),r.addEventListener("click",()=>i(t))})(d,t.element,r,a)}},({root:e,props:t})=>{const{id:n}=t;i("GET_ITEM",n);e.rect.element.hidden}))}),{options:{labelButtonManageMetadata:["Edit metadata",i.STRING],onManageMetadata:[null,i.FUNCTION]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t}));export default t; +const e=e=>{let t=document.createElement("span");return t.className="filepond--edit-icon",t.title=e,t},t=t=>{const{addFilter:n,utils:o}=t,{Type:a,createRoute:i}=o;return n("CREATE_VIEW",t=>{const{is:n,view:o,query:a}=t;if(!n("file"))return;o.registerWriter(i({DID_LOAD_ITEM:({root:t,props:n})=>{const{id:o}=n,i=a("GET_ITEM",o);if(!i||i.archived)return;const d=t.query("GET_LABEL_BUTTON_MANAGE_METADATA"),r=t.query("GET_ON_MANAGE_METADATA");r?((t,n,o,a)=>{const i=n.querySelector(".filepond--file-info-main"),d=e(o);i.prepend(d),d.addEventListener("click",()=>a(t))})(i,t.element,d,r):console.error("No 'onManageMetadata' callback method specified for FilePondPluginManageMetadata! See https://github.com/nielsboogaard/filepond-plugin-manage-metadata for more instructions.")}},({root:e,props:t})=>{const{id:n}=t;a("GET_ITEM",n);e.rect.element.hidden}))}),{options:{labelButtonManageMetadata:["Edit metadata",a.STRING],onManageMetadata:[null,a.FUNCTION]}}};"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t}));export default t; diff --git a/dist/filepond-plugin-manage-metadata.js b/dist/filepond-plugin-manage-metadata.js index 0a11952..fcf7f1d 100644 --- a/dist/filepond-plugin-manage-metadata.js +++ b/dist/filepond-plugin-manage-metadata.js @@ -69,12 +69,19 @@ 'GET_LABEL_BUTTON_MANAGE_METADATA' ); const onManageMetadata = root.query('GET_ON_MANAGE_METADATA'); - registerManageMetadataComponent( - item, - root.element, - labelButtonManageMetadata, - onManageMetadata - ); + + if (onManageMetadata) { + registerManageMetadataComponent( + item, + root.element, + labelButtonManageMetadata, + onManageMetadata + ); + } else { + console.error( + "No 'onManageMetadata' callback method specified for FilePondPluginManageMetadata! See https://github.com/nielsboogaard/filepond-plugin-manage-metadata for more instructions." + ); + } }; // start writing view.registerWriter( diff --git a/dist/filepond-plugin-manage-metadata.min.js b/dist/filepond-plugin-manage-metadata.min.js index e331258..6c89235 100644 --- a/dist/filepond-plugin-manage-metadata.min.js +++ b/dist/filepond-plugin-manage-metadata.min.js @@ -6,4 +6,4 @@ /* eslint-disable */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).FilePondPluginManageMetadata=t()}(this,(function(){"use strict";const e=e=>{let t=document.createElement("span");return t.className="filepond--edit-icon",t.title=e,t},t=t=>{const{addFilter:n,utils:o}=t,{Type:i,createRoute:d}=o;return n("CREATE_VIEW",t=>{const{is:n,view:o,query:i}=t;if(!n("file"))return;o.registerWriter(d({DID_LOAD_ITEM:({root:t,props:n})=>{const{id:o}=n,d=i("GET_ITEM",o);if(!d||d.archived)return;const r=t.query("GET_LABEL_BUTTON_MANAGE_METADATA"),a=t.query("GET_ON_MANAGE_METADATA");((t,n,o,i)=>{const d=n.querySelector(".filepond--file-info-main"),r=e(o);d.prepend(r),r.addEventListener("click",()=>i(t))})(d,t.element,r,a)}},({root:e,props:t})=>{const{id:n}=t;i("GET_ITEM",n);e.rect.element.hidden}))}),{options:{labelButtonManageMetadata:["Edit metadata",i.STRING],onManageMetadata:[null,i.FUNCTION]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t})),t})); +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).FilePondPluginManageMetadata=t()}(this,(function(){"use strict";const e=e=>{let t=document.createElement("span");return t.className="filepond--edit-icon",t.title=e,t},t=t=>{const{addFilter:n,utils:o}=t,{Type:i,createRoute:a}=o;return n("CREATE_VIEW",t=>{const{is:n,view:o,query:i}=t;if(!n("file"))return;o.registerWriter(a({DID_LOAD_ITEM:({root:t,props:n})=>{const{id:o}=n,a=i("GET_ITEM",o);if(!a||a.archived)return;const d=t.query("GET_LABEL_BUTTON_MANAGE_METADATA"),r=t.query("GET_ON_MANAGE_METADATA");r?((t,n,o,i)=>{const a=n.querySelector(".filepond--file-info-main"),d=e(o);a.prepend(d),d.addEventListener("click",()=>i(t))})(a,t.element,d,r):console.error("No 'onManageMetadata' callback method specified for FilePondPluginManageMetadata! See https://github.com/nielsboogaard/filepond-plugin-manage-metadata for more instructions.")}},({root:e,props:t})=>{const{id:n}=t;i("GET_ITEM",n);e.rect.element.hidden}))}),{options:{labelButtonManageMetadata:["Edit metadata",i.STRING],onManageMetadata:[null,i.FUNCTION]}}};return"undefined"!=typeof window&&void 0!==window.document&&document.dispatchEvent(new CustomEvent("FilePond:pluginloaded",{detail:t})),t})); diff --git a/index.html b/index.html index eec6ed4..9612d28 100644 --- a/index.html +++ b/index.html @@ -54,11 +54,7 @@