neiki-editor 2.2.1 → 2.3.0
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/LICENSE +1 -1
- package/README.md +41 -5
- package/dist/neiki-editor.js +19 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<img src="https://img.shields.io/badge/css-%23663399.svg?style=for-the-badge&logo=css&logoColor=white" alt="CSS">
|
|
12
12
|
<br>
|
|
13
13
|
<img src="https://img.shields.io/badge/License-MIT-2563EB?style=for-the-badge&logo=open-source-initiative&logoColor=white&labelColor=000F15&logoWidth=20" alt="License">
|
|
14
|
-
<img src="https://img.shields.io/badge/Version-2.
|
|
14
|
+
<img src="https://img.shields.io/badge/Version-2.3.0-2563EB?style=for-the-badge&logo=semantic-release&logoColor=white&labelColor=000F15&logoWidth=20" alt="Version">
|
|
15
15
|
</p>
|
|
16
16
|
|
|
17
17
|
<p align="center">
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
### CDN (Recommended)
|
|
40
40
|
|
|
41
41
|
```html
|
|
42
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/neikiri/neiki-editor@2.
|
|
43
|
-
<script src="https://cdn.jsdelivr.net/gh/neikiri/neiki-editor@2.
|
|
42
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/neikiri/neiki-editor@2.3.0/dist/neiki-editor.css">
|
|
43
|
+
<script src="https://cdn.jsdelivr.net/gh/neikiri/neiki-editor@2.3.0/dist/neiki-editor.js"></script>
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
### Self-hosted
|
|
@@ -234,7 +234,7 @@ The selected theme persists across page reloads via `localStorage`.
|
|
|
234
234
|
|
|
235
235
|
## 🌍 Localization (i18n)
|
|
236
236
|
|
|
237
|
-
Neiki Editor supports multiple UI languages.
|
|
237
|
+
Neiki Editor supports multiple UI languages. Built-in:
|
|
238
238
|
|
|
239
239
|
- **English** (`en`) — default
|
|
240
240
|
- **Czech** (`cs`)
|
|
@@ -247,7 +247,37 @@ const editor = new NeikiEditor('#editor', {
|
|
|
247
247
|
});
|
|
248
248
|
```
|
|
249
249
|
|
|
250
|
-
|
|
250
|
+
### Custom translations
|
|
251
|
+
|
|
252
|
+
Add your own language or override existing translations using the static method:
|
|
253
|
+
|
|
254
|
+
```javascript
|
|
255
|
+
NeikiEditor.addTranslation('de', {
|
|
256
|
+
'toolbar.bold': 'Fett (Strg+B)',
|
|
257
|
+
'toolbar.italic': 'Kursiv (Strg+I)',
|
|
258
|
+
'toolbar.undo': 'Rückgängig (Strg+Z)',
|
|
259
|
+
// only override what you need — English is the fallback
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
const editor = new NeikiEditor('#editor', { language: 'de' });
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
Or pass translations directly in config:
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
const editor = new NeikiEditor('#editor', {
|
|
269
|
+
language: 'de',
|
|
270
|
+
translations: {
|
|
271
|
+
de: {
|
|
272
|
+
'toolbar.bold': 'Fett (Strg+B)',
|
|
273
|
+
'toolbar.italic': 'Kursiv (Strg+I)',
|
|
274
|
+
// ...
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
All toolbar tooltips, modal dialogs, status bar texts, and system messages are translatable.
|
|
251
281
|
|
|
252
282
|
---
|
|
253
283
|
|
|
@@ -297,6 +327,12 @@ editor.downloadContent(); // Download content as HTML file
|
|
|
297
327
|
editor.clearAll(); // Clear all content
|
|
298
328
|
```
|
|
299
329
|
|
|
330
|
+
### Localization
|
|
331
|
+
|
|
332
|
+
```javascript
|
|
333
|
+
NeikiEditor.addTranslation('de', { ... }); // Add/override translations (static)
|
|
334
|
+
```
|
|
335
|
+
|
|
300
336
|
### Command Execution
|
|
301
337
|
|
|
302
338
|
```javascript
|
package/dist/neiki-editor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NeikiEditor - A Modern WYSIWYG Editor
|
|
3
|
-
* Version: 2.
|
|
3
|
+
* Version: 2.3.0
|
|
4
4
|
*
|
|
5
5
|
* A lightweight, feature-rich text editor with support for:
|
|
6
6
|
* - Rich text formatting (bold, italic, underline, etc.)
|
|
@@ -301,6 +301,13 @@
|
|
|
301
301
|
// Current language (will be set per editor instance)
|
|
302
302
|
let _currentLanguage = 'en';
|
|
303
303
|
|
|
304
|
+
// Register a custom translation (static method — available before init)
|
|
305
|
+
function addTranslation(lang, keys) {
|
|
306
|
+
if (!lang || typeof keys !== 'object') return;
|
|
307
|
+
if (!TRANSLATIONS[lang]) TRANSLATIONS[lang] = {};
|
|
308
|
+
Object.assign(TRANSLATIONS[lang], keys);
|
|
309
|
+
}
|
|
310
|
+
|
|
304
311
|
// Translation helper function
|
|
305
312
|
function t(key, params = {}) {
|
|
306
313
|
const lang = _currentLanguage || 'en';
|
|
@@ -334,6 +341,7 @@
|
|
|
334
341
|
readonly: false,
|
|
335
342
|
theme: 'light',
|
|
336
343
|
language: 'en',
|
|
344
|
+
translations: null,
|
|
337
345
|
plugins: [],
|
|
338
346
|
onChange: null,
|
|
339
347
|
onSave: null,
|
|
@@ -1780,6 +1788,13 @@
|
|
|
1780
1788
|
// Set language for translations
|
|
1781
1789
|
_currentLanguage = this.config.language || 'en';
|
|
1782
1790
|
|
|
1791
|
+
// Merge custom translations from config
|
|
1792
|
+
if (this.config.translations && typeof this.config.translations === 'object') {
|
|
1793
|
+
Object.keys(this.config.translations).forEach(lang => {
|
|
1794
|
+
addTranslation(lang, this.config.translations[lang]);
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
|
|
1783
1798
|
// Load theme preference
|
|
1784
1799
|
const savedTheme = StorageManager.getGlobal('theme', this.config.theme);
|
|
1785
1800
|
this.config.theme = savedTheme;
|
|
@@ -3516,6 +3531,9 @@
|
|
|
3516
3531
|
};
|
|
3517
3532
|
}
|
|
3518
3533
|
|
|
3534
|
+
// Static methods
|
|
3535
|
+
NeikiEditor.addTranslation = addTranslation;
|
|
3536
|
+
|
|
3519
3537
|
// Export
|
|
3520
3538
|
global.NeikiEditor = NeikiEditor;
|
|
3521
3539
|
global.createNeikiEditor = createEditor;
|