@fluxfiles/ckeditor4 0.1.1
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 +61 -0
- package/icons/fluxfiles.png +0 -0
- package/package.json +34 -0
- package/plugin.js +72 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# FluxFiles — CKEditor 4 Plugin
|
|
2
|
+
|
|
3
|
+
Adds a **FluxFiles** toolbar button to CKEditor 4 for browsing and inserting files.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @fluxfiles/ckeditor4
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
CKEditor 4 loads plugins from a path, so make the files reachable by your editor —
|
|
12
|
+
either point `CKEDITOR.plugins.addExternal` at `node_modules/@fluxfiles/ckeditor4/`,
|
|
13
|
+
or copy the plugin folder into your CKEditor `plugins/` directory:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
ckeditor/plugins/fluxfiles/
|
|
17
|
+
├── plugin.js
|
|
18
|
+
├── icons/
|
|
19
|
+
│ └── fluxfiles.png
|
|
20
|
+
└── README.md
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
2. Load the FluxFiles SDK (`fluxfiles.js`) on the page.
|
|
24
|
+
|
|
25
|
+
3. Enable the plugin:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
CKEDITOR.replace('editor', {
|
|
29
|
+
extraPlugins: 'fluxfiles',
|
|
30
|
+
fluxfiles: {
|
|
31
|
+
endpoint: 'https://your-fluxfiles-host',
|
|
32
|
+
token: 'JWT_TOKEN',
|
|
33
|
+
disk: 'local',
|
|
34
|
+
locale: 'en',
|
|
35
|
+
multiple: false
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## How It Works
|
|
41
|
+
|
|
42
|
+
- Click the **FluxFiles** toolbar button (folder icon) in the **Insert** toolbar group.
|
|
43
|
+
- The FluxFiles picker opens as a modal overlay.
|
|
44
|
+
- Select a file — images are inserted as `<img>`, other files as `<a>` links.
|
|
45
|
+
- The modal closes automatically after selection.
|
|
46
|
+
|
|
47
|
+
## Configuration
|
|
48
|
+
|
|
49
|
+
| Option | Type | Default | Description |
|
|
50
|
+
|--------|------|---------|-------------|
|
|
51
|
+
| `endpoint` | string | `''` | FluxFiles server URL |
|
|
52
|
+
| `token` | string | `''` | JWT authentication token |
|
|
53
|
+
| `disk` | string | `'local'` | Storage disk |
|
|
54
|
+
| `locale` | string | `null` | UI language code |
|
|
55
|
+
| `multiple` | boolean | `false` | Allow multi-file selection |
|
|
56
|
+
|
|
57
|
+
## Links
|
|
58
|
+
|
|
59
|
+
- Main repository: `https://github.com/thai-pc/fluxfiles`
|
|
60
|
+
- Documentation: `https://github.com/thai-pc/fluxfiles#ckeditor-4`
|
|
61
|
+
- Issues: `https://github.com/thai-pc/fluxfiles/issues`
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluxfiles/ckeditor4",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "CKEditor 4 plugin for FluxFiles",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"main": "plugin.js",
|
|
7
|
+
"files": [
|
|
8
|
+
"plugin.js",
|
|
9
|
+
"icons",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": { "test": "vitest run" },
|
|
13
|
+
"devDependencies": { "jsdom": "^25.0.1", "vitest": "^2.1.8" },
|
|
14
|
+
"publishConfig": { "access": "public" },
|
|
15
|
+
"author": "thai-pc",
|
|
16
|
+
"homepage": "https://github.com/thai-pc/fluxfiles#ckeditor-4",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/thai-pc/fluxfiles.git",
|
|
20
|
+
"directory": "packages/ckeditor4"
|
|
21
|
+
},
|
|
22
|
+
"bugs": { "url": "https://github.com/thai-pc/fluxfiles/issues" },
|
|
23
|
+
"keywords": [
|
|
24
|
+
"fluxfiles",
|
|
25
|
+
"file-manager",
|
|
26
|
+
"ckeditor",
|
|
27
|
+
"ckeditor4",
|
|
28
|
+
"plugin",
|
|
29
|
+
"s3",
|
|
30
|
+
"r2",
|
|
31
|
+
"upload",
|
|
32
|
+
"media"
|
|
33
|
+
]
|
|
34
|
+
}
|
package/plugin.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FluxFiles plugin for CKEditor 4.
|
|
3
|
+
*
|
|
4
|
+
* Adds a toolbar button that opens the FluxFiles picker.
|
|
5
|
+
* Selected images are inserted as <img>, other files as <a>.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* CKEDITOR.replace('editor', {
|
|
9
|
+
* extraPlugins: 'fluxfiles',
|
|
10
|
+
* fluxfiles: {
|
|
11
|
+
* endpoint: 'http://localhost:8080',
|
|
12
|
+
* token: 'JWT_TOKEN',
|
|
13
|
+
* disk: 'local', // optional
|
|
14
|
+
* locale: 'en', // optional
|
|
15
|
+
* multiple: false // optional
|
|
16
|
+
* }
|
|
17
|
+
* });
|
|
18
|
+
*/
|
|
19
|
+
(function () {
|
|
20
|
+
'use strict';
|
|
21
|
+
|
|
22
|
+
CKEDITOR.plugins.add('fluxfiles', {
|
|
23
|
+
icons: 'fluxfiles',
|
|
24
|
+
hidpi: true,
|
|
25
|
+
|
|
26
|
+
init: function (editor) {
|
|
27
|
+
var cfg = editor.config.fluxfiles || {};
|
|
28
|
+
|
|
29
|
+
editor.addCommand('openFluxFiles', {
|
|
30
|
+
exec: function () {
|
|
31
|
+
if (typeof FluxFiles === 'undefined') {
|
|
32
|
+
console.error('[FluxFiles] SDK (fluxfiles.js) is not loaded.');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
FluxFiles.open({
|
|
37
|
+
endpoint: cfg.endpoint || '',
|
|
38
|
+
token: cfg.token || '',
|
|
39
|
+
disk: cfg.disk || 'local',
|
|
40
|
+
mode: 'picker',
|
|
41
|
+
multiple: !!cfg.multiple,
|
|
42
|
+
locale: cfg.locale || null,
|
|
43
|
+
onSelect: function (payload) {
|
|
44
|
+
var files = Array.isArray(payload) ? payload : (payload && payload.files ? payload.files : [payload]);
|
|
45
|
+
|
|
46
|
+
for (var i = 0; i < files.length; i++) {
|
|
47
|
+
var file = files[i];
|
|
48
|
+
if (!file) continue;
|
|
49
|
+
|
|
50
|
+
var url = file.url || '';
|
|
51
|
+
var name = file.basename || file.name || file.path || '';
|
|
52
|
+
|
|
53
|
+
if (/\.(jpe?g|png|gif|webp|svg|bmp|ico)$/i.test(name)) {
|
|
54
|
+
editor.insertHtml('<img src="' + CKEDITOR.tools.htmlEncode(url) + '" alt="' + CKEDITOR.tools.htmlEncode(name) + '" />');
|
|
55
|
+
} else {
|
|
56
|
+
editor.insertHtml('<a href="' + CKEDITOR.tools.htmlEncode(url) + '">' + CKEDITOR.tools.htmlEncode(name) + '</a>');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
editor.ui.addButton('FluxFiles', {
|
|
65
|
+
label: 'FluxFiles',
|
|
66
|
+
command: 'openFluxFiles',
|
|
67
|
+
toolbar: 'insert',
|
|
68
|
+
icon: this.path + 'icons/fluxfiles.png'
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
})();
|