@fluxfiles/tinymce 0.2.1 → 0.2.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
@@ -2,6 +2,11 @@
2
2
 
3
3
  Adds a **FluxFiles** toolbar button to TinyMCE 4.x / 5.x for browsing and inserting files.
4
4
 
5
+ ## Requirements
6
+
7
+ - TinyMCE 4.x or 5.x
8
+ - A running **FluxFiles core** server (the PHP backend / standalone app in `packages/core`). This plugin is only the editor button — it loads the FluxFiles SDK (`fluxfiles.js`) from that server and `fluxfiles_endpoint` must point at it.
9
+
5
10
  ## Installation
6
11
 
7
12
  ```bash
@@ -43,9 +48,15 @@ tinymce.init({
43
48
 
44
49
  - Click the **FluxFiles** toolbar button (folder/browse icon).
45
50
  - The FluxFiles picker opens as a modal overlay.
46
- - Select a file — images are inserted as `<img>`, other files as `<a>` links.
51
+ - Select a file — images are inserted as `<img>` (with `alt` from the file's
52
+ metadata and `width`/`height` when known), other files as `<a>` links.
47
53
  - The modal closes automatically after selection.
48
54
 
55
+ > **Embedding & expiring URLs.** On a **private** disk the file URL is a
56
+ > *presigned* URL that expires (≤ 24h) — embedding it in saved content will break
57
+ > once it expires (the plugin logs a `console.warn`). For editor embeds use a
58
+ > **public** disk or a `public_url` so the inserted URL is permanent.
59
+
49
60
  ## Configuration
50
61
 
51
62
  | Option | Type | Default | Description |
@@ -62,6 +73,10 @@ tinymce.init({
62
73
  - **TinyMCE 5.x** — Uses `ui.registry.addButton` / `ui.registry.addMenuItem` API
63
74
  - Auto-detects version at load time.
64
75
 
76
+ ## License
77
+
78
+ MIT — see [LICENSE](LICENSE) for details.
79
+
65
80
  ## Links
66
81
 
67
82
  - Main repository: `https://github.com/thai-pc/fluxfiles`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluxfiles/tinymce",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "TinyMCE plugin for FluxFiles",
5
5
  "license": "MIT",
6
6
  "main": "plugin.js",
package/plugin.js CHANGED
@@ -52,19 +52,34 @@
52
52
  maxFiles: maxFiles,
53
53
  locale: locale,
54
54
  onSelect: function (payload) {
55
- var files = Array.isArray(payload) ? payload : (payload && payload.files ? payload.files : [payload]);
55
+ var files = Array.isArray(payload) ? payload : [payload];
56
56
 
57
57
  for (var i = 0; i < files.length; i++) {
58
58
  var file = files[i];
59
- if (!file) continue;
59
+ if (!file || file.is_dir) continue;
60
60
 
61
- var url = file.url || '';
62
- var name = file.basename || file.name || file.path || '';
61
+ // Prefer a permanent URL (public disk / public_url) so saved
62
+ // content doesn't embed an expiring presigned URL.
63
+ var url = file.permanent_url || file.url || '';
64
+ var name = file.name || file.basename || file.path || '';
65
+ var meta = file.meta || {};
63
66
 
64
- if (/\.(jpe?g|png|gif|webp|svg|bmp|ico)$/i.test(name)) {
65
- editor.insertContent('<img src="' + escHtml(url) + '" alt="' + escHtml(name) + '" />');
67
+ // Still presigned (private disk, no public_url)? Warn — it will
68
+ // expire and break the saved link/image.
69
+ if (/[?&](X-Amz-|Signature=)/.test(url)) {
70
+ console.warn('[FluxFiles] Inserting a presigned (expiring) URL — it will break when the URL expires. Use a public disk or public_url for embeds.');
71
+ }
72
+
73
+ var isImage = (file.mime && file.mime.indexOf('image/') === 0)
74
+ || /\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(name);
75
+
76
+ if (isImage) {
77
+ var dim = '';
78
+ if (file.width) { dim += ' width="' + parseInt(file.width, 10) + '"'; }
79
+ if (file.height) { dim += ' height="' + parseInt(file.height, 10) + '"'; }
80
+ editor.insertContent('<img src="' + escHtml(url) + '" alt="' + escHtml(meta.alt_text || name) + '"' + dim + ' />');
66
81
  } else {
67
- editor.insertContent('<a href="' + escHtml(url) + '">' + escHtml(name) + '</a>');
82
+ editor.insertContent('<a href="' + escHtml(url) + '">' + escHtml(meta.title || name) + '</a>');
68
83
  }
69
84
  }
70
85
  }
package/plugin.min.js CHANGED
@@ -1 +1 @@
1
- (function(){"use strict";function t(e){var l=document.createElement("div");return l.appendChild(document.createTextNode(e||"")),l.innerHTML}function s(e){if(typeof FluxFiles>"u"){console.error("[FluxFiles] SDK (fluxfiles.js) is not loaded.");return}var l=e.getParam("fluxfiles_endpoint",""),f=e.getParam("fluxfiles_token",""),c=e.getParam("fluxfiles_disk","local"),x=e.getParam("fluxfiles_locale",null),m=e.getParam("fluxfiles_multiple",!1),g=e.getParam("fluxfiles_max_upload_mb",null),p=e.getParam("fluxfiles_max_files",null);FluxFiles.open({endpoint:l,token:f,disk:c,mode:"picker",multiple:!!m,maxUploadMb:g,maxFiles:p,locale:x,onSelect:function(n){for(var o=Array.isArray(n)?n:n&&n.files?n.files:[n],a=0;a<o.length;a++){var i=o[a];if(i){var r=i.url||"",u=i.basename||i.name||i.path||"";/\.(jpe?g|png|gif|webp|svg|bmp|ico)$/i.test(u)?e.insertContent('<img src="'+t(r)+'" alt="'+t(u)+'" />'):e.insertContent('<a href="'+t(r)+'">'+t(u)+"</a>")}}}})}tinymce.PluginManager.add("fluxfiles",function(e){var l=parseInt(tinymce.majorVersion,10);if(l>=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(){s(e)}}),e.ui.registry.addMenuItem("fluxfiles",{icon:"fluxfiles",text:"FluxFiles",onAction:function(){s(e)}}),{getMetadata:function(){return{name:"FluxFiles",url:"https://github.com/thai-pc/fluxfiles"}}};e.addButton("fluxfiles",{icon:"browse",tooltip:"FluxFiles",onclick:function(){s(e)}}),e.addMenuItem("fluxfiles",{icon:"browse",text:"FluxFiles",onclick:function(){s(e)},context:"insert"})})})();
1
+ (function(){"use strict";function i(e){var t=document.createElement("div");return t.appendChild(document.createTextNode(e||"")),t.innerHTML}function l(e){if(typeof FluxFiles>"u"){console.error("[FluxFiles] SDK (fluxfiles.js) is not loaded.");return}var t=e.getParam("fluxfiles_endpoint",""),x=e.getParam("fluxfiles_token",""),m=e.getParam("fluxfiles_disk","local"),p=e.getParam("fluxfiles_locale",null),g=e.getParam("fluxfiles_multiple",!1),d=e.getParam("fluxfiles_max_upload_mb",null),h=e.getParam("fluxfiles_max_files",null);FluxFiles.open({endpoint:t,token:x,disk:m,mode:"picker",multiple:!!g,maxUploadMb:d,maxFiles:h,locale:p,onSelect:function(a){for(var f=Array.isArray(a)?a:[a],s=0;s<f.length;s++){var n=f[s];if(!(!n||n.is_dir)){var r=n.permanent_url||n.url||"",u=n.name||n.basename||n.path||"",c=n.meta||{};/[?&](X-Amz-|Signature=)/.test(r)&&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 v=n.mime&&n.mime.indexOf("image/")===0||/\.(jpe?g|png|gif|webp|svg|bmp|ico|avif)$/i.test(u);if(v){var o="";n.width&&(o+=' width="'+parseInt(n.width,10)+'"'),n.height&&(o+=' height="'+parseInt(n.height,10)+'"'),e.insertContent('<img src="'+i(r)+'" alt="'+i(c.alt_text||u)+'"'+o+" />")}else e.insertContent('<a href="'+i(r)+'">'+i(c.title||u)+"</a>")}}}})}tinymce.PluginManager.add("fluxfiles",function(e){var t=parseInt(tinymce.majorVersion,10);if(t>=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(){l(e)}}),e.ui.registry.addMenuItem("fluxfiles",{icon:"fluxfiles",text:"FluxFiles",onAction:function(){l(e)}}),{getMetadata:function(){return{name:"FluxFiles",url:"https://github.com/thai-pc/fluxfiles"}}};e.addButton("fluxfiles",{icon:"browse",tooltip:"FluxFiles",onclick:function(){l(e)}}),e.addMenuItem("fluxfiles",{icon:"browse",text:"FluxFiles",onclick:function(){l(e)},context:"insert"})})})();