@fluxfiles/ckeditor4 0.3.2 → 0.3.4
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 +7 -2
- package/plugin.min.js +1 -1
package/package.json
CHANGED
package/plugin.js
CHANGED
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
mode: 'picker', multiple: !!multiple,
|
|
65
65
|
maxUploadMb: cfg.maxUploadMb || null, maxFiles: cfg.maxFiles || null, locale: cfg.locale || null,
|
|
66
66
|
theme: cfg.theme || null, disks: cfg.disks || null,
|
|
67
|
+
allowedTypes: cfg.allowedTypes || null, path: cfg.path || '',
|
|
67
68
|
onSelect: onSelect
|
|
68
69
|
});
|
|
69
70
|
}
|
|
@@ -126,6 +127,10 @@
|
|
|
126
127
|
exec: function () {
|
|
127
128
|
open(cfg, cfg.multiple, function (payload) {
|
|
128
129
|
var files = Array.isArray(payload) ? payload : [payload];
|
|
130
|
+
// Attribute-context values (src/href/alt/title) need htmlEncodeAttr, which
|
|
131
|
+
// additionally escapes `"` — plain htmlEncode only does &/</> and lets a
|
|
132
|
+
// quote in e.g. alt_text break out of the attribute (stored XSS).
|
|
133
|
+
var encAttr = CKEDITOR.tools.htmlEncodeAttr;
|
|
129
134
|
var enc = CKEDITOR.tools.htmlEncode;
|
|
130
135
|
for (var i = 0; i < files.length; i++) {
|
|
131
136
|
var file = files[i];
|
|
@@ -137,9 +142,9 @@
|
|
|
137
142
|
var dim = '';
|
|
138
143
|
if (info.width) { dim += ' width="' + parseInt(info.width, 10) + '"'; }
|
|
139
144
|
if (info.height) { dim += ' height="' + parseInt(info.height, 10) + '"'; }
|
|
140
|
-
editor.insertHtml('<img src="' +
|
|
145
|
+
editor.insertHtml('<img src="' + encAttr(info.url) + '" alt="' + encAttr(info.meta.alt_text || info.name) + '"' + dim + ' />');
|
|
141
146
|
} else {
|
|
142
|
-
editor.insertHtml('<a href="' +
|
|
147
|
+
editor.insertHtml('<a href="' + encAttr(info.url) + '">' + enc(info.meta.title || info.name) + '</a>');
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
});
|
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 f(e){var
|
|
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 i=e.permanent_url||e.url||"",n=e.name||e.basename||e.path||"",r=e.meta||{},l=i!=="";l?/[?&](X-Amz-|Signature=)/.test(i)&&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 o=e.mime&&e.mime.indexOf("image/")===0||/\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(n);return{url:i,name:n,meta:r,isImage:o,embeddable:l,width:e.width||null,height:e.height||null}}function g(e,i,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:!!i,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 i=Array.isArray(e)?e[0]:e;return i&&!i.is_dir?i:null}CKEDITOR.fluxfilesDialogHook||(CKEDITOR.fluxfilesDialogHook=!0,CKEDITOR.on("dialogDefinition",function(e){if(!(e.data.name!=="image"&&e.data.name!=="image2")){var i=e.editor,n=i&&i.config&&i.config.fluxfiles;if(!(!n||n.imageDialog===!1)){var r=e.data.definition,l=r.getContents("info")||r.getContents("Upload");l&&l.add({type:"button",id:"fluxfilesBrowse",label:"Browse FluxFiles",title:"Browse FluxFiles",onClick:function(){var o=this.getDialog();g(n,!1,function(u){var s=p(u);if(s){var t=f(s);if(t.embeddable){var a=function(v,m){var h=o.getContentElement("info",v);h&&m!=null&&m!==""&&h.setValue(String(m))};a("txtUrl",t.url),a("txtAlt",t.meta.alt_text||t.name),t.width&&a("txtWidth",t.width),t.height&&a("txtHeight",t.height);var d=o.getContentElement("info","txtUrl");d&&typeof d.onChange=="function"&&d.onChange()}}})}})}}})),CKEDITOR.plugins.add("fluxfiles",{init:function(e){var i=e.config.fluxfiles||{};e.addCommand("openFluxFiles",{exec:function(){g(i,i.multiple,function(n){for(var r=Array.isArray(n)?n:[n],l=CKEDITOR.tools.htmlEncodeAttr,o=CKEDITOR.tools.htmlEncode,u=0;u<r.length;u++){var s=r[u];if(!(!s||s.is_dir)){var t=f(s);if(t.embeddable)if(t.isImage){var a="";t.width&&(a+=' width="'+parseInt(t.width,10)+'"'),t.height&&(a+=' height="'+parseInt(t.height,10)+'"'),e.insertHtml('<img src="'+l(t.url)+'" alt="'+l(t.meta.alt_text||t.name)+'"'+a+" />")}else e.insertHtml('<a href="'+l(t.url)+'">'+o(t.meta.title||t.name)+"</a>")}}})}}),e.ui.addButton("FluxFiles",{label:"FluxFiles",command:"openFluxFiles",toolbar:"insert",icon:c})}})})();
|