@fluxfiles/tinymce 0.3.0 → 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/README.md CHANGED
@@ -75,7 +75,9 @@ The modal closes automatically after selection.
75
75
  | `fluxfiles_endpoint` | string | `''` | FluxFiles server URL |
76
76
  | `fluxfiles_token` | string | `''` | JWT authentication token |
77
77
  | `fluxfiles_disk` | string | `'local'` | Storage disk |
78
+ | `fluxfiles_disks` | string[] | `null` | Disks shown in the picker sidebar |
78
79
  | `fluxfiles_locale` | string | `null` | UI language code |
80
+ | `fluxfiles_theme` | string | `null` | Picker theme: `light` / `dark` / `auto` |
79
81
  | `fluxfiles_multiple` | boolean | `false` | Allow multi-file selection |
80
82
  | `fluxfiles_image_dialog` | boolean | `true` | Wire `file_picker_callback` into the native image/link/media dialogs |
81
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxfiles/tinymce",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "TinyMCE plugin for FluxFiles",
5
5
  "license": "MIT",
6
6
  "main": "plugin.js",
package/plugin.js CHANGED
@@ -20,6 +20,7 @@
20
20
  * fluxfiles_token: 'JWT_TOKEN',
21
21
  * fluxfiles_disk: 'local',
22
22
  * fluxfiles_locale: 'en',
23
+ * fluxfiles_theme: 'dark', // optional — light | dark | auto
23
24
  * fluxfiles_multiple: false
24
25
  * });
25
26
  *
@@ -41,6 +42,8 @@
41
42
  token: editor.getParam('fluxfiles_token', ''),
42
43
  disk: editor.getParam('fluxfiles_disk', 'local'),
43
44
  locale: editor.getParam('fluxfiles_locale', null),
45
+ theme: editor.getParam('fluxfiles_theme', null),
46
+ disks: editor.getParam('fluxfiles_disks', null),
44
47
  multiple: editor.getParam('fluxfiles_multiple', false),
45
48
  maxUploadMb: editor.getParam('fluxfiles_max_upload_mb', null),
46
49
  maxFiles: editor.getParam('fluxfiles_max_files', null)
@@ -55,9 +58,19 @@
55
58
  var name = file.name || file.basename || file.path || '';
56
59
  var meta = file.meta || {};
57
60
 
58
- // Still presigned (private disk, no public_url)? Warn — it will expire and
59
- // break the saved link/image.
60
- if (/[?&](X-Amz-|Signature=)/.test(url)) {
61
+ // Preview-only selection (no permanent_url and no url) — e.g. a watermark
62
+ // OVERLAY image with allow_download=false. Its only view is img_base, a
63
+ // short-lived token URL that must NOT be saved into content (it expires →
64
+ // broken image), and inserting the empty string would yield <img src="">.
65
+ // To embed a *watermarked* image, burn the watermark into the file first
66
+ // (Watermark editor → Apply) — that yields a stable, watermarked
67
+ // permanent_url. So we refuse here rather than insert a clean/broken image.
68
+ var embeddable = url !== '';
69
+ if (!embeddable) {
70
+ 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.');
71
+ } else if (/[?&](X-Amz-|Signature=)/.test(url)) {
72
+ // Still presigned (private disk, no public_url)? Warn — it will expire
73
+ // and break the saved link/image.
61
74
  console.warn('[FluxFiles] Inserting a presigned (expiring) URL — it will break when the URL expires. Use a public disk or public_url for embeds.');
62
75
  }
63
76
 
@@ -65,7 +78,7 @@
65
78
  || /\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(name);
66
79
 
67
80
  return {
68
- url: url, name: name, meta: meta, isImage: isImage,
81
+ url: url, name: name, meta: meta, isImage: isImage, embeddable: embeddable,
69
82
  width: file.width || null, height: file.height || null
70
83
  };
71
84
  }
@@ -80,6 +93,7 @@
80
93
  endpoint: c.endpoint, token: c.token, disk: c.disk,
81
94
  mode: 'picker', multiple: !!multiple,
82
95
  maxUploadMb: c.maxUploadMb, maxFiles: c.maxFiles, locale: c.locale,
96
+ theme: c.theme, disks: c.disks,
83
97
  onSelect: onSelect
84
98
  });
85
99
  }
@@ -92,6 +106,7 @@
92
106
  var file = files[i];
93
107
  if (!file || file.is_dir) continue;
94
108
  var info = fileInfo(file);
109
+ if (!info.embeddable) continue; // preview-only → already warned
95
110
 
96
111
  if (info.isImage) {
97
112
  var dim = '';
@@ -114,6 +129,7 @@
114
129
  var file = Array.isArray(payload) ? payload[0] : payload;
115
130
  if (!file || file.is_dir) return;
116
131
  var info = fileInfo(file);
132
+ if (!info.embeddable) return; // preview-only → already warned
117
133
  var data = {};
118
134
 
119
135
  if (meta && meta.filetype === 'image') {
package/plugin.min.js CHANGED
@@ -1 +1 @@
1
- (function(){"use strict";function u(e){var i=document.createElement("div");return i.appendChild(document.createTextNode(e||"")),i.innerHTML}function c(e){return{endpoint:e.getParam("fluxfiles_endpoint",""),token:e.getParam("fluxfiles_token",""),disk:e.getParam("fluxfiles_disk","local"),locale:e.getParam("fluxfiles_locale",null),multiple:e.getParam("fluxfiles_multiple",!1),maxUploadMb:e.getParam("fluxfiles_max_upload_mb",null),maxFiles:e.getParam("fluxfiles_max_files",null)}}function m(e){var i=e.permanent_url||e.url||"",a=e.name||e.basename||e.path||"",t=e.meta||{};/[?&](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.");var s=e.mime&&e.mime.indexOf("image/")===0||/\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(a);return{url:i,name:a,meta:t,isImage:s,width:e.width||null,height:e.height||null}}function o(e,i,a){if(typeof FluxFiles>"u"){console.error("[FluxFiles] SDK (fluxfiles.js) is not loaded.");return}var t=c(e);FluxFiles.open({endpoint:t.endpoint,token:t.token,disk:t.disk,mode:"picker",multiple:!!i,maxUploadMb:t.maxUploadMb,maxFiles:t.maxFiles,locale:t.locale,onSelect:a})}function f(e){o(e,c(e).multiple,function(i){for(var a=Array.isArray(i)?i:[i],t=0;t<a.length;t++){var s=a[t];if(!(!s||s.is_dir)){var n=m(s);if(n.isImage){var l="";n.width&&(l+=' width="'+parseInt(n.width,10)+'"'),n.height&&(l+=' height="'+parseInt(n.height,10)+'"'),e.insertContent('<img src="'+u(n.url)+'" alt="'+u(n.meta.alt_text||n.name)+'"'+l+" />")}else e.insertContent('<a href="'+u(n.url)+'">'+u(n.meta.title||n.name)+"</a>")}}})}function p(e){return function(i,a,t){o(e,!1,function(s){var n=Array.isArray(s)?s[0]:s;if(!(!n||n.is_dir)){var l=m(n),r={};t&&t.filetype==="image"?(r.alt=l.meta.alt_text||l.name,l.width&&(r.width=String(l.width)),l.height&&(r.height=String(l.height))):t&&t.filetype==="media"||(r.text=l.meta.title||l.name,r.title=l.meta.title||l.name),i(l.url,r)}})}}function g(e){if(e.getParam("fluxfiles_image_dialog",!0)!==!1&&typeof e.getParam("file_picker_callback")!="function"){var i=p(e);e.settings&&(e.settings.file_picker_callback=i,e.settings.file_picker_types||(e.settings.file_picker_types="file image media"));try{e.options&&typeof e.options.set=="function"&&(e.options.set("file_picker_callback",i),e.options.get("file_picker_types")||e.options.set("file_picker_types","file image media"))}catch{}}}tinymce.PluginManager.add("fluxfiles",function(e){g(e);var i=parseInt(tinymce.majorVersion,10);if(i>=5)return e.ui.registry.addIcon("fluxfiles",'<svg width="24" height="24" 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="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'),e.ui.registry.addButton("fluxfiles",{icon:"fluxfiles",tooltip:"FluxFiles",onAction:function(){f(e)}}),e.ui.registry.addMenuItem("fluxfiles",{icon:"fluxfiles",text:"FluxFiles",onAction:function(){f(e)}}),{getMetadata:function(){return{name:"FluxFiles",url:"https://github.com/thai-pc/fluxfiles"}}};e.addButton("fluxfiles",{icon:"browse",tooltip:"FluxFiles",onclick:function(){f(e)}}),e.addMenuItem("fluxfiles",{icon:"browse",text:"FluxFiles",onclick:function(){f(e)},context:"insert"})})})();
1
+ (function(){"use strict";function u(e){var i=document.createElement("div");return i.appendChild(document.createTextNode(e||"")),i.innerHTML}function m(e){return{endpoint:e.getParam("fluxfiles_endpoint",""),token:e.getParam("fluxfiles_token",""),disk:e.getParam("fluxfiles_disk","local"),locale:e.getParam("fluxfiles_locale",null),theme:e.getParam("fluxfiles_theme",null),disks:e.getParam("fluxfiles_disks",null),multiple:e.getParam("fluxfiles_multiple",!1),maxUploadMb:e.getParam("fluxfiles_max_upload_mb",null),maxFiles:e.getParam("fluxfiles_max_files",null)}}function o(e){var i=e.permanent_url||e.url||"",a=e.name||e.basename||e.path||"",t=e.meta||{},s=i!=="";s?/[?&](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] "'+a+'" 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 l=e.mime&&e.mime.indexOf("image/")===0||/\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(a);return{url:i,name:a,meta:t,isImage:l,embeddable:s,width:e.width||null,height:e.height||null}}function c(e,i,a){if(typeof FluxFiles>"u"){console.error("[FluxFiles] SDK (fluxfiles.js) is not loaded.");return}var t=m(e);FluxFiles.open({endpoint:t.endpoint,token:t.token,disk:t.disk,mode:"picker",multiple:!!i,maxUploadMb:t.maxUploadMb,maxFiles:t.maxFiles,locale:t.locale,theme:t.theme,disks:t.disks,onSelect:a})}function f(e){c(e,m(e).multiple,function(i){for(var a=Array.isArray(i)?i:[i],t=0;t<a.length;t++){var s=a[t];if(!(!s||s.is_dir)){var l=o(s);if(l.embeddable)if(l.isImage){var n="";l.width&&(n+=' width="'+parseInt(l.width,10)+'"'),l.height&&(n+=' height="'+parseInt(l.height,10)+'"'),e.insertContent('<img src="'+u(l.url)+'" alt="'+u(l.meta.alt_text||l.name)+'"'+n+" />")}else e.insertContent('<a href="'+u(l.url)+'">'+u(l.meta.title||l.name)+"</a>")}}})}function p(e){return function(i,a,t){c(e,!1,function(s){var l=Array.isArray(s)?s[0]:s;if(!(!l||l.is_dir)){var n=o(l);if(n.embeddable){var r={};t&&t.filetype==="image"?(r.alt=n.meta.alt_text||n.name,n.width&&(r.width=String(n.width)),n.height&&(r.height=String(n.height))):t&&t.filetype==="media"||(r.text=n.meta.title||n.name,r.title=n.meta.title||n.name),i(n.url,r)}}})}}function g(e){if(e.getParam("fluxfiles_image_dialog",!0)!==!1&&typeof e.getParam("file_picker_callback")!="function"){var i=p(e);e.settings&&(e.settings.file_picker_callback=i,e.settings.file_picker_types||(e.settings.file_picker_types="file image media"));try{e.options&&typeof e.options.set=="function"&&(e.options.set("file_picker_callback",i),e.options.get("file_picker_types")||e.options.set("file_picker_types","file image media"))}catch{}}}tinymce.PluginManager.add("fluxfiles",function(e){g(e);var i=parseInt(tinymce.majorVersion,10);if(i>=5)return e.ui.registry.addIcon("fluxfiles",'<svg width="24" height="24" 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="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'),e.ui.registry.addButton("fluxfiles",{icon:"fluxfiles",tooltip:"FluxFiles",onAction:function(){f(e)}}),e.ui.registry.addMenuItem("fluxfiles",{icon:"fluxfiles",text:"FluxFiles",onAction:function(){f(e)}}),{getMetadata:function(){return{name:"FluxFiles",url:"https://github.com/thai-pc/fluxfiles"}}};e.addButton("fluxfiles",{icon:"browse",tooltip:"FluxFiles",onclick:function(){f(e)}}),e.addMenuItem("fluxfiles",{icon:"browse",text:"FluxFiles",onclick:function(){f(e)},context:"insert"})})})();