@fluxfiles/ckeditor4 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugin.js +11 -2
- package/plugin.min.js +1 -1
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -39,12 +39,19 @@
|
|
|
39
39
|
var url = file.permanent_url || file.url || '';
|
|
40
40
|
var name = file.name || file.basename || file.path || '';
|
|
41
41
|
var meta = file.meta || {};
|
|
42
|
-
|
|
42
|
+
// Preview-only selection (no permanent_url/url) — e.g. a watermark OVERLAY
|
|
43
|
+
// with allow_download=false. Its only view is img_base, a short-lived token
|
|
44
|
+
// URL unsafe to save into content. To embed a *watermarked* image, burn the
|
|
45
|
+
// watermark into the file first (Watermark editor → Apply). Refuse here.
|
|
46
|
+
var embeddable = url !== '';
|
|
47
|
+
if (!embeddable) {
|
|
48
|
+
console.warn('[FluxFiles] "' + name + '" is preview-only (no embeddable URL — e.g. a watermark overlay with allow_download=false), so it was not inserted. Burn in the watermark (Watermark editor → Apply) or issue a downloadable token to embed it.');
|
|
49
|
+
} else if (/[?&](X-Amz-|Signature=)/.test(url)) {
|
|
43
50
|
console.warn('[FluxFiles] Inserting a presigned (expiring) URL — it will break when the URL expires. Use a public disk or public_url for embeds.');
|
|
44
51
|
}
|
|
45
52
|
var isImage = (file.mime && file.mime.indexOf('image/') === 0)
|
|
46
53
|
|| /\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(name);
|
|
47
|
-
return { url: url, name: name, meta: meta, isImage: isImage, width: file.width || null, height: file.height || null };
|
|
54
|
+
return { url: url, name: name, meta: meta, isImage: isImage, embeddable: embeddable, width: file.width || null, height: file.height || null };
|
|
48
55
|
}
|
|
49
56
|
|
|
50
57
|
function open(cfg, multiple, onSelect) {
|
|
@@ -92,6 +99,7 @@
|
|
|
92
99
|
var file = firstFile(payload);
|
|
93
100
|
if (!file) return;
|
|
94
101
|
var info = fileInfo(file);
|
|
102
|
+
if (!info.embeddable) return; // preview-only → already warned
|
|
95
103
|
var set = function (id, val) {
|
|
96
104
|
var el = dialog.getContentElement('info', id);
|
|
97
105
|
if (el && val != null && val !== '') el.setValue(String(val));
|
|
@@ -123,6 +131,7 @@
|
|
|
123
131
|
var file = files[i];
|
|
124
132
|
if (!file || file.is_dir) continue;
|
|
125
133
|
var info = fileInfo(file);
|
|
134
|
+
if (!info.embeddable) continue; // preview-only → already warned
|
|
126
135
|
|
|
127
136
|
if (info.isImage) {
|
|
128
137
|
var dim = '';
|
package/plugin.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(){"use strict";var x='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" stroke="#575757" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',c="data:image/svg+xml,"+encodeURIComponent(x);function
|
|
1
|
+
(function(){"use strict";var x='<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z" stroke="#575757" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',c="data:image/svg+xml,"+encodeURIComponent(x);function f(e){var t=e.permanent_url||e.url||"",n=e.name||e.basename||e.path||"",o=e.meta||{},a=t!=="";a?/[?&](X-Amz-|Signature=)/.test(t)&&console.warn("[FluxFiles] Inserting a presigned (expiring) URL \u2014 it will break when the URL expires. Use a public disk or public_url for embeds."):console.warn('[FluxFiles] "'+n+'" is preview-only (no embeddable URL \u2014 e.g. a watermark overlay with allow_download=false), so it was not inserted. Burn in the watermark (Watermark editor \u2192 Apply) or issue a downloadable token to embed it.');var r=e.mime&&e.mime.indexOf("image/")===0||/\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(n);return{url:t,name:n,meta:o,isImage:r,embeddable:a,width:e.width||null,height:e.height||null}}function g(e,t,n){if(typeof FluxFiles>"u"){console.error("[FluxFiles] SDK (fluxfiles.js) is not loaded.");return}FluxFiles.open({endpoint:e.endpoint||"",token:e.token||"",disk:e.disk||"local",mode:"picker",multiple:!!t,maxUploadMb:e.maxUploadMb||null,maxFiles:e.maxFiles||null,locale:e.locale||null,theme:e.theme||null,disks:e.disks||null,onSelect:n})}function p(e){var t=Array.isArray(e)?e[0]:e;return t&&!t.is_dir?t:null}CKEDITOR.fluxfilesDialogHook||(CKEDITOR.fluxfilesDialogHook=!0,CKEDITOR.on("dialogDefinition",function(e){if(!(e.data.name!=="image"&&e.data.name!=="image2")){var t=e.editor,n=t&&t.config&&t.config.fluxfiles;if(!(!n||n.imageDialog===!1)){var o=e.data.definition,a=o.getContents("info")||o.getContents("Upload");a&&a.add({type:"button",id:"fluxfilesBrowse",label:"Browse FluxFiles",title:"Browse FluxFiles",onClick:function(){var r=this.getDialog();g(n,!1,function(s){var i=p(s);if(i){var l=f(i);if(l.embeddable){var u=function(v,m){var h=r.getContentElement("info",v);h&&m!=null&&m!==""&&h.setValue(String(m))};u("txtUrl",l.url),u("txtAlt",l.meta.alt_text||l.name),l.width&&u("txtWidth",l.width),l.height&&u("txtHeight",l.height);var d=r.getContentElement("info","txtUrl");d&&typeof d.onChange=="function"&&d.onChange()}}})}})}}})),CKEDITOR.plugins.add("fluxfiles",{init:function(e){var t=e.config.fluxfiles||{};e.addCommand("openFluxFiles",{exec:function(){g(t,t.multiple,function(n){for(var o=Array.isArray(n)?n:[n],a=CKEDITOR.tools.htmlEncode,r=0;r<o.length;r++){var s=o[r];if(!(!s||s.is_dir)){var i=f(s);if(i.embeddable)if(i.isImage){var l="";i.width&&(l+=' width="'+parseInt(i.width,10)+'"'),i.height&&(l+=' height="'+parseInt(i.height,10)+'"'),e.insertHtml('<img src="'+a(i.url)+'" alt="'+a(i.meta.alt_text||i.name)+'"'+l+" />")}else e.insertHtml('<a href="'+a(i.url)+'">'+a(i.meta.title||i.name)+"</a>")}}})}}),e.ui.addButton("FluxFiles",{label:"FluxFiles",command:"openFluxFiles",toolbar:"insert",icon:c})}})})();
|