@humandialog/forms.svelte 1.5.1 → 1.6.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.
@@ -7,6 +7,7 @@ import { FaChevronDown, FaTimes } from "svelte-icons/fa";
7
7
  import Icon from "../icon.svelte";
8
8
  import { reef } from "@humandialog/auth.svelte/dist/index.js";
9
9
  import { showMenu } from "../menu.js";
10
+ import { ext, i18n } from "../../i18n.js";
10
11
  export let label = "";
11
12
  export let self = null;
12
13
  export let a = "";
@@ -229,7 +230,7 @@ function openDropdownAsMenu() {
229
230
  let operations = [];
230
231
  if (hasNone)
231
232
  operations.push({
232
- caption: "<none>",
233
+ caption: `<${i18n({ en: "blank", es: "blanco", pl: "pusty" })}>`,
233
234
  action: (f) => on_choose(null)
234
235
  });
235
236
  if (definition && definition.collection)
@@ -237,12 +238,11 @@ function openDropdownAsMenu() {
237
238
  const _filtered_source = filtered_source ? filtered_source : definition.source;
238
239
  _filtered_source.forEach((i) => {
239
240
  operations.push({
240
- caption: i.Name ?? i.Key,
241
+ caption: i.Name ? ext(i.Name) : i.Key,
241
242
  icon: i.Icon ?? void 0,
242
243
  action: (f) => on_choose(i)
243
244
  });
244
245
  });
245
- console.log("operations", operations);
246
246
  showMenu(rect, operations);
247
247
  }
248
248
  export function hide() {
@@ -295,7 +295,7 @@ function get_combo_text() {
295
295
  if (!is_dropdown_open) {
296
296
  let found = selected_item(item, a);
297
297
  if (found)
298
- return found.Name ?? found.Key;
298
+ return found.Name ? ext(found.Name) : found.Key;
299
299
  else
300
300
  return placeholder;
301
301
  } else
@@ -2,7 +2,16 @@
2
2
  import Icon from "./icon.svelte";
3
3
  import { contextItemsStore, pushToolsActionsOperations, popToolsActionsOperations } from "../stores";
4
4
  import { isDeviceSmallerThan, isOnScreenKeyboardVisible } from "../utils";
5
- import { hideWholeContextMenu, showMenu, showFloatingToolbar, showGridMenu } from "./menu";
5
+ import {
6
+ hideWholeContextMenu,
7
+ showMenu,
8
+ showFloatingToolbar,
9
+ showGridMenu,
10
+ SHOW_MENU_BELOW,
11
+ SHOW_MENU_ABOVE,
12
+ SHOW_MENU_RIGHT,
13
+ SHOW_MENU_LEFT
14
+ } from "./menu";
6
15
  import { FaTimes } from "svelte-icons/fa";
7
16
  export let widthPx = 400;
8
17
  export let menu_items_id_prefix = "__hd_svelte_menuitem_";
@@ -17,11 +26,12 @@ let focused_index = 0;
17
26
  let menu_items = [];
18
27
  let submenus = [];
19
28
  let around_rect;
29
+ let around_preference = 0;
20
30
  let css_position = "";
21
31
  let closeButtonPos = "";
22
32
  $:
23
33
  display = visible ? "block" : "none";
24
- function calculatePosition(x2, y2, around, visible2, fresh) {
34
+ function calculatePosition(x2, y2, visible2, fresh) {
25
35
  let result = "";
26
36
  if (!visible2) {
27
37
  result = "display: none";
@@ -66,36 +76,115 @@ function calculatePosition(x2, y2, around, visible2, fresh) {
66
76
  if (myRect) {
67
77
  const m = 15;
68
78
  let screenRect = new DOMRect(m, 0, window.innerWidth - 2 * m, window.innerHeight);
69
- let xShifted = false;
70
- if (myRect.right > screenRect.right) {
71
- x2 = screenRect.right - myRect.width + m;
72
- xShifted = true;
73
- }
74
- let yShifted = false;
75
- if (myRect.bottom > screenRect.bottom) {
76
- y2 = screenRect.bottom - myRect.height;
77
- if (around) {
78
- if (xShifted)
79
- x2 -= around.width;
80
- else
81
- y2 -= around.height;
79
+ if (around_rect) {
80
+ const menuWidth = myRect.width;
81
+ const menuHeight = myRect.height;
82
+ let topArea;
83
+ let bottomArea;
84
+ let leftArea;
85
+ let rightArea;
86
+ switch (around_preference) {
87
+ case SHOW_MENU_BELOW:
88
+ topArea = around_rect.top - screenRect.top;
89
+ bottomArea = screenRect.bottom - around_rect.bottom;
90
+ leftArea = around_rect.right - screenRect.left;
91
+ rightArea = screenRect.right - around_rect.left;
92
+ if (menuHeight <= bottomArea)
93
+ y2 = around_rect.bottom;
94
+ else if (menuHeight <= topArea)
95
+ y2 = around_rect.top - menuHeight;
96
+ if (menuWidth <= rightArea)
97
+ x2 = around_rect.left;
98
+ else if (menuWidth <= leftArea)
99
+ x2 = around_rect.right - menuWidth;
100
+ break;
101
+ case SHOW_MENU_ABOVE:
102
+ topArea = around_rect.top - screenRect.top;
103
+ bottomArea = screenRect.bottom - around_rect.bottom;
104
+ leftArea = around_rect.right - screenRect.left;
105
+ rightArea = screenRect.right - around_rect.left;
106
+ if (menuHeight <= topArea)
107
+ y2 = around_rect.top - menuHeight;
108
+ else if (menuHeight <= bottomArea)
109
+ y2 = around_rect.bottom;
110
+ if (menuWidth <= rightArea)
111
+ x2 = around_rect.left;
112
+ else if (menuWidth <= leftArea)
113
+ x2 = around_rect.right - menuWidth;
114
+ break;
115
+ case SHOW_MENU_RIGHT:
116
+ topArea = around_rect.bottom - screenRect.top;
117
+ bottomArea = screenRect.bottom - around_rect.top;
118
+ leftArea = around_rect.left - screenRect.left;
119
+ rightArea = screenRect.right - around_rect.right;
120
+ if (menuWidth <= rightArea)
121
+ x2 = around_rect.right;
122
+ else if (menuWidth <= leftArea)
123
+ x2 = around_rect.left - menuWidth;
124
+ if (menuHeight <= bottomArea)
125
+ y2 = around_rect.top;
126
+ else if (menuHeight <= topArea)
127
+ y2 = around_rect.bottom - menuHeight;
128
+ break;
129
+ case SHOW_MENU_LEFT:
130
+ topArea = around_rect.bottom - screenRect.top;
131
+ bottomArea = screenRect.bottom - around_rect.top;
132
+ leftArea = around_rect.left - screenRect.left;
133
+ rightArea = screenRect.right - around_rect.right;
134
+ if (menuWidth <= leftArea)
135
+ x2 = around_rect.left - menuWidth;
136
+ else if (menuWidth <= rightArea)
137
+ x2 = around_rect.right;
138
+ if (menuHeight <= bottomArea)
139
+ y2 = around_rect.top;
140
+ else if (menuHeight <= topArea)
141
+ y2 = around_rect.bottom - menuHeight;
142
+ break;
82
143
  }
83
- yShifted = true;
144
+ } else {
145
+ if (myRect.right > screenRect.right)
146
+ x2 = screenRect.right - myRect.width + m;
147
+ if (myRect.bottom > screenRect.bottom)
148
+ y2 = screenRect.bottom - myRect.height;
149
+ if (myRect.left < screenRect.left)
150
+ x2 = screenRect.left;
151
+ if (myRect.top < screenRect.top)
152
+ y2 = screenRect.top;
84
153
  }
85
- if (myRect.left < screenRect.left)
86
- x2 = screenRect.left;
87
- if (myRect.top < screenRect.top)
88
- y2 = screenRect.top;
89
154
  }
90
155
  result = `left:${x2}px; top:${y2}px; display: block; min-width: 15rem`;
91
156
  closeButtonPos = "";
92
157
  }
93
158
  return result;
94
159
  }
95
- export async function show(around, _operations) {
160
+ function intersects(lpRect1, lpRect2) {
161
+ const left = Math.max(lpRect1.left, lpRect2.left);
162
+ const right = Math.min(lpRect1.right, lpRect2.right);
163
+ const top = Math.max(lpRect1.top, lpRect2.top);
164
+ const bottom = Math.min(lpRect1.bottom, lpRect2.bottom);
165
+ return left <= right && top <= bottom;
166
+ }
167
+ export async function show(around, _operations, preference = 0) {
96
168
  if (around instanceof DOMRect) {
97
- x = around.left;
98
- y = around.bottom;
169
+ switch (preference) {
170
+ case SHOW_MENU_BELOW:
171
+ x = around.left;
172
+ y = around.bottom;
173
+ break;
174
+ case SHOW_MENU_ABOVE:
175
+ x = around.left;
176
+ y = around.top;
177
+ break;
178
+ case SHOW_MENU_RIGHT:
179
+ x = around.right;
180
+ y = around.top;
181
+ break;
182
+ case SHOW_MENU_LEFT:
183
+ x = around.left;
184
+ y = around.top;
185
+ break;
186
+ }
187
+ around_preference = preference;
99
188
  around_rect = around;
100
189
  } else if (around instanceof DOMPoint) {
101
190
  x = around.x;
@@ -103,7 +192,7 @@ export async function show(around, _operations) {
103
192
  around_rect = new DOMRect(x, y, 0, 0);
104
193
  }
105
194
  visible = true;
106
- css_position = calculatePosition(x, y, around_rect, true, true);
195
+ css_position = calculatePosition(x, y, true, true);
107
196
  operations = [..._operations];
108
197
  focused_index = operations.findIndex((o) => !o.disabled);
109
198
  const is_root_menu = owner_menu_item == void 0;
@@ -132,7 +221,7 @@ export async function show(around, _operations) {
132
221
  });
133
222
  }
134
223
  await tick();
135
- css_position = calculatePosition(x, y, around_rect, true, false);
224
+ css_position = calculatePosition(x, y, true, false);
136
225
  if (is_root_menu)
137
226
  menu_root.addEventListener("click", on_before_container_click, true);
138
227
  if (menu_items.length && !isDeviceSmallerThan("sm"))
@@ -145,7 +234,7 @@ export function hide() {
145
234
  if (false)
146
235
  popToolsActionsOperations();
147
236
  visible = false;
148
- css_position = calculatePosition(x, y, around_rect, false, false);
237
+ css_position = calculatePosition(x, y, false, false);
149
238
  window.removeEventListener("click", on_before_window_click, true);
150
239
  menu_root?.removeEventListener("click", on_before_container_click, true);
151
240
  }
@@ -211,7 +300,8 @@ function on_mouse_move(index) {
211
300
  focus_menu_item(index);
212
301
  }
213
302
  function execute_action(e, operation, index) {
214
- if (operation.menu) {
303
+ const mobile = isDeviceSmallerThan("sm");
304
+ if (operation.menu && !mobile) {
215
305
  focus_menu_item(index);
216
306
  return;
217
307
  }
@@ -223,7 +313,6 @@ function execute_action(e, operation, index) {
223
313
  owner = owner.parentElement;
224
314
  if (operation.preAction)
225
315
  operation.preAction(owner);
226
- const mobile = isDeviceSmallerThan("sm");
227
316
  if (operation.action) {
228
317
  operation.action(owner, around_rect);
229
318
  } else {
@@ -239,6 +328,8 @@ function execute_action(e, operation, index) {
239
328
  showMenu(rect, operation.grid);
240
329
  else
241
330
  showGridMenu(rect, operation.grid);
331
+ } else if (operation.menu) {
332
+ showMenu(rect, operation.menu);
242
333
  }
243
334
  }
244
335
  }
@@ -382,6 +473,12 @@ function calculateBackground(is_highlighted, active) {
382
473
  {@const cc = mobile ? 7 : 6}
383
474
  {@const icon_size = icon_placeholder_size - cc}
384
475
  <Icon s="md" component={operation.icon}/>
476
+ {:else if operation.img}
477
+ {@const cc = mobile ? 7 : 6}
478
+ {@const icon_size = icon_placeholder_size - cc}
479
+ <div class="w-4 h-4">
480
+ <img src={operation.img} alt=""/>
481
+ </div>
385
482
  {:else}
386
483
  {@const cc = mobile ? 7 : 6}
387
484
  {@const icon_size = icon_placeholder_size - cc}
@@ -4,7 +4,7 @@ declare const __propDef: {
4
4
  widthPx?: number | undefined;
5
5
  menu_items_id_prefix?: string | undefined;
6
6
  owner_menu_item?: HTMLElement | undefined;
7
- show?: ((around: DOMRect | DOMPoint, _operations: any) => Promise<void>) | undefined;
7
+ show?: ((around: DOMRect | DOMPoint, _operations: any, preference?: number) => Promise<void>) | undefined;
8
8
  isVisible?: (() => boolean) | undefined;
9
9
  hide?: (() => void) | undefined;
10
10
  getRenderedRect?: (() => DOMRect | undefined) | undefined;
@@ -18,7 +18,7 @@ export type ContextmenuProps = typeof __propDef.props;
18
18
  export type ContextmenuEvents = typeof __propDef.events;
19
19
  export type ContextmenuSlots = typeof __propDef.slots;
20
20
  export default class Contextmenu extends SvelteComponentTyped<ContextmenuProps, ContextmenuEvents, ContextmenuSlots> {
21
- get show(): (around: DOMRect | DOMPoint, _operations: any) => Promise<void>;
21
+ get show(): (around: DOMRect | DOMPoint, _operations: any, preference?: number) => Promise<void>;
22
22
  get isVisible(): () => boolean;
23
23
  get hide(): () => void;
24
24
  get getRenderedRect(): () => DOMRect | undefined;
@@ -1,5 +1,5 @@
1
1
  export function getFormattedStringDate(d: any, type?: string): string;
2
2
  export function getNiceStringDateTime(d: any): string;
3
- export function getNiceStringDate(d: any): string;
4
- export function dayName(d: any): "" | "Sun" | "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat";
5
- export function monthName(m: any): "" | "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" | "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec";
3
+ export function getNiceStringDate(d: any): any;
4
+ export function dayName(d: any): any;
5
+ export function monthName(m: any): any;
@@ -1,4 +1,6 @@
1
1
 
2
+ import {getCurrentLanguageKey} from '../i18n.js'
3
+
2
4
  export function getFormattedStringDate(d, type = "datetime")
3
5
  {
4
6
  if(!d)
@@ -86,11 +88,11 @@ export function getNiceStringDate(d)
86
88
 
87
89
  let days_diff = day - current_day;
88
90
  if(days_diff == 0)
89
- return 'Today';
91
+ return today();
90
92
  else if(days_diff == 1)
91
- return 'Tomorrow';
93
+ return tomorrow();
92
94
  else if(days_diff == -1)
93
- return 'Yesterday';
95
+ return yesterday();
94
96
  else if(days_diff > 0 && days_diff <= 7)
95
97
  {
96
98
  if(day_of_week > current_day_of_week)
@@ -122,67 +124,68 @@ export function getNiceStringDate(d)
122
124
  }
123
125
  }
124
126
 
125
- export function dayName(d)
127
+ function today()
126
128
  {
127
- switch(d)
128
- {
129
- case 0:
130
- return 'Sun';
131
-
132
- case 1:
133
- return 'Mon';
134
-
135
- case 2:
136
- return 'Tue';
137
-
138
- case 3:
139
- return 'Wed';
129
+ const lang = getCurrentLanguageKey()
130
+ if(Object.keys(abbrCloseLang).includes(lang))
131
+ return abbrCloseLang[lang][1]
132
+ else
133
+ return abbrCloseLang.en[1]
134
+ }
140
135
 
141
- case 4:
142
- return 'Thu';
136
+ function tomorrow()
137
+ {
138
+ const lang = getCurrentLanguageKey()
139
+ if(Object.keys(abbrCloseLang).includes(lang))
140
+ return abbrCloseLang[lang][2]
141
+ else
142
+ return abbrCloseLang.en[2]
143
+ }
143
144
 
144
- case 5:
145
- return 'Fri';
145
+ function yesterday()
146
+ {
147
+ const lang = getCurrentLanguageKey()
148
+ if(Object.keys(abbrCloseLang).includes(lang))
149
+ return abbrCloseLang[lang][0]
150
+ else
151
+ return abbrCloseLang.en[0]
152
+ }
146
153
 
147
- case 6:
148
- return 'Sat';
149
-
150
- case 7:
151
- return 'Sun';
152
- }
153
154
 
154
- return '';
155
+ export function dayName(d)
156
+ {
157
+ const lang = getCurrentLanguageKey()
158
+ if(Object.keys(abbrDaysLang).includes(lang))
159
+ return abbrDaysLang[lang][d]
160
+ else
161
+ return abbrDaysLang.en[d]
155
162
  }
156
163
 
157
164
  export function monthName(m)
158
165
  {
159
- switch(m)
160
- {
161
- case 0:
162
- return "Jan";
163
- case 1:
164
- return "Feb";
165
- case 2:
166
- return "Mar";
167
- case 3:
168
- return "Apr";
169
- case 4:
170
- return "May";
171
- case 5:
172
- return "Jun";
173
- case 6:
174
- return "Jul";
175
- case 7:
176
- return "Aug";
177
- case 8:
178
- return "Sep";
179
- case 9:
180
- return "Oct";
181
- case 10:
182
- return "Nov";
183
- case 11:
184
- return "Dec";
185
- }
166
+ const lang = getCurrentLanguageKey()
167
+ if(Object.keys(abbrMonthsLang).includes(lang))
168
+ return abbrMonthsLang[lang][m]
169
+ else
170
+ return abbrMonthsLang.en[m]
171
+ }
172
+
173
+ // translations
174
+
175
+ const abbrCloseLang = {
176
+ en: ['yesterday', 'today', 'tomorrow'],
177
+ es: ['ayer', 'hoy', 'mañana'],
178
+ pl: ['wczoraj', 'dziś', 'jutro']
179
+ }
180
+
181
+ const abbrDaysLang = {
182
+ en: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
183
+ es: ['dom', 'lun', 'mar', 'miérc', 'juev', 'vier', 'sáb', 'dom'],
184
+ pl: ['nie', 'pon', 'wto', 'śro', 'czw', 'pią', 'sob', 'nie']
185
+ }
186
186
 
187
- return '';
187
+ const abbrMonthsLang = {
188
+ en: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
189
+ es: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'set', 'oct', 'nov', 'dic'],
190
+ pl: ['sty', 'lut', 'mar', 'kwi', 'maj', 'cze', 'lip', 'sie', 'wrz', 'paź', 'lis', 'gru']
188
191
  }
@@ -55,6 +55,7 @@ import IcH3 from "./internal/h3.icon.svelte";
55
55
  import IcH4 from "./internal/h4.icon.svelte";
56
56
  import { Extension } from "@tiptap/core";
57
57
  import { Suggestion } from "./internal/suggestion";
58
+ import { i18n } from "../../i18n.js";
58
59
  export let value = "";
59
60
  export let placeholder = "";
60
61
  export let self = null;
@@ -100,7 +101,7 @@ export function getFormattingOperations(withCaptions = false) {
100
101
  }
101
102
  export function getMarksOperations(tbr = "A") {
102
103
  let operations = [];
103
- paletteMarksCommands.forEach((c2) => {
104
+ paletteMarksCommands().forEach((c2) => {
104
105
  if (!c2.separator) {
105
106
  operations.push({
106
107
  caption: c2.caption,
@@ -111,7 +112,7 @@ export function getMarksOperations(tbr = "A") {
111
112
  }
112
113
  });
113
114
  return {
114
- caption: "Text",
115
+ caption: i18n({ en: "Text", es: "Texto", pl: "Tekst" }),
115
116
  operations,
116
117
  preAction: (f) => {
117
118
  if (editor.isFocused)
@@ -122,7 +123,7 @@ export function getMarksOperations(tbr = "A") {
122
123
  }
123
124
  export function getStylesOperations(tbr = "A") {
124
125
  let operations = [];
125
- paletteStylesCommands.forEach((c2) => {
126
+ paletteStylesCommands().forEach((c2) => {
126
127
  if (!c2.separator) {
127
128
  operations.push({
128
129
  caption: c2.caption,
@@ -133,7 +134,7 @@ export function getStylesOperations(tbr = "A") {
133
134
  }
134
135
  });
135
136
  return {
136
- caption: "Styles",
137
+ caption: i18n({ en: "Styles", es: "Estilos", pl: "Style" }),
137
138
  operations,
138
139
  preAction: (f) => {
139
140
  if (editor.isFocused)
@@ -149,7 +150,7 @@ export function getInsertOperations(tbr = "A") {
149
150
  operations = [...operations, exc];
150
151
  });
151
152
  }
152
- paletteInsertCommands.forEach((c2) => {
153
+ paletteInsertCommands().forEach((c2) => {
153
154
  if (!c2.separator) {
154
155
  operations.push({
155
156
  caption: c2.caption,
@@ -160,7 +161,7 @@ export function getInsertOperations(tbr = "A") {
160
161
  }
161
162
  });
162
163
  return {
163
- caption: "Insert",
164
+ caption: i18n({ en: "Insert", es: "Insertar", pl: "Wstaw" }),
164
165
  operations,
165
166
  preAction: (f) => {
166
167
  if (editor.isFocused)
@@ -1012,51 +1013,51 @@ export function preventBlur() {
1012
1013
  export function hasChanged() {
1013
1014
  return hasChangedValue;
1014
1015
  }
1015
- const paletteMarksCommands = [
1016
- { caption: "Bold", description: "Marks text as bolded", tags: "strong", icon: FaBold, on_choice: makeBold, is_active: () => editor?.isActive("bold") },
1017
- { caption: "Italic", description: "Marks text as italic", tags: "strong", icon: FaItalic, on_choice: makeItalic, is_active: () => editor?.isActive("italic") },
1018
- { caption: "Underlie", description: "Marks text as underlined", icon: FaUnderline, on_choice: makeUnderline, is_active: () => editor?.isActive("underline") },
1019
- { caption: "Strikethrough", description: "Marks text as strikethrough", icon: FaStrikethrough, on_choice: makeStrikethrough, is_active: () => editor?.isActive("strike") }
1016
+ const paletteMarksCommands = () => [
1017
+ { caption: i18n({ en: "Bold", es: "Negrita", pl: "Pogrubiony" }), description: "Marks text as bolded", tags: "strong", icon: FaBold, on_choice: makeBold, is_active: () => editor?.isActive("bold") },
1018
+ { caption: i18n({ en: "Italic", es: "Cursiva", pl: "Kursywa" }), description: "Marks text as italic", tags: "strong", icon: FaItalic, on_choice: makeItalic, is_active: () => editor?.isActive("italic") },
1019
+ { caption: i18n({ en: "Underline", es: "Subrayar", pl: "Podkre\u015Blenie" }), description: "Marks text as underlined", icon: FaUnderline, on_choice: makeUnderline, is_active: () => editor?.isActive("underline") },
1020
+ { caption: i18n({ en: "Strikethrough", es: "Tachado", pl: "Przekre\u015Blenie" }), description: "Marks text as strikethrough", icon: FaStrikethrough, on_choice: makeStrikethrough, is_active: () => editor?.isActive("strike") }
1020
1021
  ];
1021
- const paletteStylesCommands = [
1022
- { caption: "Normal", description: "This is normal text style", tags: "paragraph,text", icon: FaRemoveFormat, on_choice: (range) => {
1022
+ const paletteStylesCommands = () => [
1023
+ { caption: i18n({ en: "Normal", es: "Normal", pl: "Normalny" }), description: "This is normal text style", tags: "paragraph,text", icon: FaRemoveFormat, on_choice: (range) => {
1023
1024
  if (range)
1024
1025
  editor.chain().focus().deleteRange(range).setParagraph().run();
1025
1026
  else
1026
1027
  editor.chain().focus().setParagraph().run();
1027
1028
  }, is_active: () => editor?.isActive("paragraph") },
1028
- { caption: "Heading 1", description: "Description heading", tags: "h1", icon: IcH1, on_choice: (range) => {
1029
+ { caption: i18n({ en: "Heading 1", es: "T\xEDtulo 1", pl: "Nag\u0142\xF3wek 1" }), description: "Description heading", tags: "h1", icon: IcH1, on_choice: (range) => {
1029
1030
  if (range)
1030
1031
  editor.chain().focus().deleteRange(range).setHeading({ level: 1 }).run();
1031
1032
  else
1032
1033
  editor.chain().focus().setHeading({ level: 1 }).run();
1033
1034
  }, is_active: () => editor?.isActive("heading", { level: 1 }) },
1034
- { caption: "Heading 2", description: "Secondary heading", tags: "h2", icon: IcH2, on_choice: (range) => {
1035
+ { caption: i18n({ en: "Heading 2", es: "T\xEDtulo 2", pl: "Nag\u0142\xF3wek 2" }), description: "Secondary heading", tags: "h2", icon: IcH2, on_choice: (range) => {
1035
1036
  if (range)
1036
1037
  editor.chain().focus().deleteRange(range).setHeading({ level: 2 }).run();
1037
1038
  else
1038
1039
  editor.chain().focus().setHeading({ level: 2 }).run();
1039
1040
  }, is_active: () => editor?.isActive("heading", { level: 2 }) },
1040
- { caption: "Heading 3", description: "Secondary heading", tags: "h3", icon: IcH3, on_choice: (range) => {
1041
+ { caption: i18n({ en: "Heading 3", es: "T\xEDtulo 3", pl: "Nag\u0142\xF3wek 3" }), description: "Secondary heading", tags: "h3", icon: IcH3, on_choice: (range) => {
1041
1042
  if (range)
1042
1043
  editor.chain().focus().deleteRange(range).setHeading({ level: 3 }).run();
1043
1044
  else
1044
1045
  editor.chain().focus().setHeading({ level: 3 }).run();
1045
1046
  }, is_active: () => editor?.isActive("heading", { level: 3 }) },
1046
- { caption: "Heading 4", description: "Secondary heading", tags: "h4", icon: IcH4, on_choice: (range) => {
1047
+ { caption: i18n({ en: "Heading 4", es: "T\xEDtulo 4", pl: "Nag\u0142\xF3wek 4" }), description: "Secondary heading", tags: "h4", icon: IcH4, on_choice: (range) => {
1047
1048
  if (range)
1048
1049
  editor.chain().focus().deleteRange(range).setHeading({ level: 4 }).run();
1049
1050
  else
1050
1051
  editor.chain().focus().setHeading({ level: 4 }).run();
1051
1052
  }, is_active: () => editor?.isActive("heading", { level: 4 }) },
1052
- { caption: "Code", description: "Source code monospace text", icon: FaCode, on_choice: (range) => {
1053
+ { caption: i18n({ en: "Code", es: "C\xF3digo", pl: "Kod" }), description: "Source code monospace text", icon: FaCode, on_choice: (range) => {
1053
1054
  if (range)
1054
1055
  editor.chain().focus().deleteRange(range).setCodeBlock().run();
1055
1056
  else
1056
1057
  editor.chain().focus().setCodeBlock().run();
1057
1058
  }, is_active: () => editor?.isActive("CodeBlock") },
1058
1059
  // { caption: 'Comment', description: 'With this you can comment the above paragraph', icon: FaComment, on_choice: (range) => { if(range) editor.chain().focus().deleteRange(range).setAsComment().run(); else editor.chain().focus().setAsComment().run() }, is_active: () => editor?.isActive('CommentBlock') } ,
1059
- { caption: "Quote", description: "To quote someone", icon: FaQuoteRight, on_choice: (range) => {
1060
+ { caption: i18n({ en: "Quote", es: "Cita", pl: "Cytat" }), description: "To quote someone", icon: FaQuoteRight, on_choice: (range) => {
1060
1061
  if (range)
1061
1062
  editor.chain().focus().deleteRange(range).setAsQuote().run();
1062
1063
  else
@@ -1064,27 +1065,27 @@ const paletteStylesCommands = [
1064
1065
  }, is_active: () => editor?.isActive("QuoteBlock") },
1065
1066
  // { caption: 'Warning', description: 'An important warning to above paragraph', icon: FaExclamationTriangle, on_choice: (range) => { if(range) editor.chain().focus().deleteRange(range).setAsWarning().run(); else editor.chain().focus().setAsWarning().run() }, is_active: () => editor?.isActive('WarningBlock') } ,
1066
1067
  // { caption: 'Info', description: 'An important info about above paragraph', icon: FaInfo, on_choice: (range) => { if(range) editor.chain().focus().deleteRange(range).setAsInfo().run(); else editor.chain().focus().setAsInfo().run() }, is_active: () => editor?.isActive('InfoBlock') },
1067
- { caption: "Bullet list", description: "Unordered list of items", icon: FaListUl, on_choice: (range) => {
1068
+ { caption: i18n({ en: "BulletList", es: "Lista con vi\xF1etas", pl: "Lista punktowana" }), description: "Unordered list of items", icon: FaListUl, on_choice: (range) => {
1068
1069
  if (range)
1069
1070
  editor.chain().focus().deleteRange(range).toggleBulletList().run();
1070
1071
  else
1071
1072
  editor.chain().focus().toggleBulletList().run();
1072
1073
  }, is_active: () => editor?.isActive("bulletList") }
1073
1074
  ];
1074
- const paletteInsertCommands = [
1075
- { caption: "Image", description: "Add image to document", tags: "img,picture", icon: FaImage, on_choice: (range) => {
1075
+ const paletteInsertCommands = () => [
1076
+ { caption: i18n({ en: "Image", es: "Imagen", pl: "Obraz" }), description: "Add image to document", tags: "img,picture", icon: FaImage, on_choice: (range) => {
1076
1077
  if (range)
1077
1078
  editor.chain().focus().deleteRange(range).run();
1078
1079
  if (onAddImage)
1079
1080
  onAddImage(onAddedImageReady);
1080
1081
  } },
1081
- { caption: "Table", description: "Table", icon: FaTable, on_choice: (range) => {
1082
+ { caption: i18n({ en: "Table", es: "Tabla", pl: "Tabela" }), description: "Table", icon: FaTable, on_choice: (range) => {
1082
1083
  if (range)
1083
1084
  editor.chain().focus().deleteRange(range).insertTable().run();
1084
1085
  else
1085
1086
  editor.chain().focus().insertTable().run();
1086
1087
  }, is_active: () => editor?.isActive("table") },
1087
- { caption: "Horizontal rule", description: "Add horizonal role", tags: "hr", icon: FaGripLines, on_choice: (range) => {
1088
+ { caption: i18n({ en: "Horizontal rule", es: "Regla horizontal", pl: "Pozioma linia" }), description: "Add horizonal role", tags: "hr", icon: FaGripLines, on_choice: (range) => {
1088
1089
  if (range)
1089
1090
  editor.chain().focus().deleteRange(range).setHorizontalRule().run();
1090
1091
  else
@@ -1092,12 +1093,21 @@ const paletteInsertCommands = [
1092
1093
  } }
1093
1094
  ];
1094
1095
  const paletteCommands = [
1095
- { caption: "Text", separator: true },
1096
- ...paletteMarksCommands,
1097
- { caption: "Styles", separator: true },
1098
- ...paletteStylesCommands,
1099
- { caption: "Insert", separator: true },
1100
- ...paletteInsertCommands
1096
+ {
1097
+ caption: i18n({ en: "Text", es: "Texto", pl: "Tekst" }),
1098
+ separator: true
1099
+ },
1100
+ ...paletteMarksCommands(),
1101
+ {
1102
+ caption: i18n({ en: "Styles", es: "Estilos", pl: "Style" }),
1103
+ separator: true
1104
+ },
1105
+ ...paletteStylesCommands(),
1106
+ {
1107
+ caption: i18n({ en: "Insert", es: "Insertar", pl: "Wstaw" }),
1108
+ separator: true
1109
+ },
1110
+ ...paletteInsertCommands()
1101
1111
  ];
1102
1112
  function makeBold(range) {
1103
1113
  if (range) {
@@ -1152,11 +1162,11 @@ function getPaletteCommands() {
1152
1162
  });
1153
1163
  commands.push({ separator: true });
1154
1164
  }
1155
- commands = [...commands, { caption: "Text", separator: true }];
1156
- commands = [...commands, ...paletteMarksCommands];
1157
- commands = [...commands, { caption: "Styles", separator: true }];
1158
- commands = [...commands, ...paletteStylesCommands];
1159
- commands = [...commands, { caption: "Insert", separator: true }];
1165
+ commands = [...commands, { caption: i18n({ en: "Text", es: "Texto", pl: "Tekst" }), separator: true }];
1166
+ commands = [...commands, ...paletteMarksCommands()];
1167
+ commands = [...commands, { caption: i18n({ en: "Styles", es: "Estilos", pl: "Style" }), separator: true }];
1168
+ commands = [...commands, ...paletteStylesCommands()];
1169
+ commands = [...commands, { caption: i18n({ en: "Insert", es: "Insertar", pl: "Wstaw" }), separator: true }];
1160
1170
  if (extraInsertPaletteCommands && extraInsertPaletteCommands.length > 0) {
1161
1171
  extraInsertPaletteCommands.forEach((exc) => {
1162
1172
  commands.push({
@@ -1179,7 +1189,7 @@ function getPaletteCommands() {
1179
1189
  });
1180
1190
  });
1181
1191
  }
1182
- commands = [...commands, ...paletteInsertCommands];
1192
+ commands = [...commands, ...paletteInsertCommands()];
1183
1193
  if (extraBackPaletteCommands && extraBackPaletteCommands.length > 0) {
1184
1194
  commands.push({ separator: true });
1185
1195
  extraBackPaletteCommands.forEach((exc) => {