@humandialog/forms.svelte 1.5.1 → 1.6.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.
@@ -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;
@@ -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) => {
@@ -25,19 +25,19 @@ declare const __propDef: {
25
25
  run?: ((onStop?: undefined) => void) | undefined;
26
26
  getFormattingOperations?: ((withCaptions?: boolean) => any[]) | undefined;
27
27
  getMarksOperations?: ((tbr?: string) => {
28
- caption: string;
28
+ caption: any;
29
29
  operations: any[];
30
30
  preAction: (f: any) => void;
31
31
  tbr: string;
32
32
  }) | undefined;
33
33
  getStylesOperations?: ((tbr?: string) => {
34
- caption: string;
34
+ caption: any;
35
35
  operations: any[];
36
36
  preAction: (f: any) => void;
37
37
  tbr: string;
38
38
  }) | undefined;
39
39
  getInsertOperations?: ((tbr?: string) => {
40
- caption: string;
40
+ caption: any;
41
41
  operations: any[];
42
42
  preAction: (f: any) => void;
43
43
  tbr: string;
@@ -98,19 +98,19 @@ export default class Editor extends SvelteComponentTyped<EditorProps, EditorEven
98
98
  get run(): (onStop?: undefined) => void;
99
99
  get getFormattingOperations(): (withCaptions?: boolean) => any[];
100
100
  get getMarksOperations(): (tbr?: string) => {
101
- caption: string;
101
+ caption: any;
102
102
  operations: any[];
103
103
  preAction: (f: any) => void;
104
104
  tbr: string;
105
105
  };
106
106
  get getStylesOperations(): (tbr?: string) => {
107
- caption: string;
107
+ caption: any;
108
108
  operations: any[];
109
109
  preAction: (f: any) => void;
110
110
  tbr: string;
111
111
  };
112
112
  get getInsertOperations(): (tbr?: string) => {
113
- caption: string;
113
+ caption: any;
114
114
  operations: any[];
115
115
  preAction: (f: any) => void;
116
116
  tbr: string;
@@ -1,5 +1,9 @@
1
1
  import Floating_container from './Floating_container.svelte';
2
- export declare function showMenu(around: DOMRect | DOMPoint, operations: any): void;
2
+ export declare const SHOW_MENU_BELOW = 0;
3
+ export declare const SHOW_MENU_ABOVE = 1;
4
+ export declare const SHOW_MENU_RIGHT = 2;
5
+ export declare const SHOW_MENU_LEFT = 3;
6
+ export declare function showMenu(around: DOMRect | DOMPoint, operations: any, preference?: number): void;
3
7
  export declare function hideWholeContextMenu(): void;
4
8
  export declare function showFloatingToolbar(around: DOMRect | DOMPoint, toolbar: any, props?: {}): Floating_container | null;
5
9
  export declare function hideFloatingToolbar(): void;
@@ -3,7 +3,11 @@ import Floating_container from './Floating_container.svelte';
3
3
  import Grid from './Grid.menu.svelte';
4
4
  let menu_comopnent = null;
5
5
  let toolbar_component = null;
6
- export function showMenu(around, operations) {
6
+ export const SHOW_MENU_BELOW = 0;
7
+ export const SHOW_MENU_ABOVE = 1;
8
+ export const SHOW_MENU_RIGHT = 2;
9
+ export const SHOW_MENU_LEFT = 3;
10
+ export function showMenu(around, operations, preference = SHOW_MENU_BELOW) {
7
11
  let menu_element = document.getElementById("__hd_svelte_contextmenu");
8
12
  if (!menu_element) {
9
13
  let app_div = document.getElementById("__hd_svelte_layout_root");
@@ -13,13 +17,13 @@ export function showMenu(around, operations) {
13
17
  target: app_div,
14
18
  props: {}
15
19
  });
16
- menu_comopnent.show(around, operations);
20
+ menu_comopnent.show(around, operations, preference);
17
21
  }
18
22
  else if (menu_comopnent) {
19
23
  if (menu_comopnent.isVisible())
20
24
  menu_comopnent.hide();
21
25
  else
22
- menu_comopnent.show(around, operations);
26
+ menu_comopnent.show(around, operations, preference);
23
27
  }
24
28
  else
25
29
  console.error('what now?');
@@ -1,8 +1,9 @@
1
1
  <script>import { getContext, tick } from "svelte";
2
2
  import Icon from "../icon.svelte";
3
- import { contextItemsStore, auto_hide_sidebar, contextToolbarOperations } from "../../stores";
3
+ import { contextItemsStore, contextToolbarOperations } from "../../stores";
4
4
  import { FaBars, FaEllipsisV } from "svelte-icons/fa";
5
5
  import { link, push } from "svelte-spa-router";
6
+ import { i18n } from "../../i18n";
6
7
  import {
7
8
  selectable as _selectable,
8
9
  isSelected,
@@ -11,8 +12,7 @@ import {
11
12
  activateItem,
12
13
  startEditing,
13
14
  getActive,
14
- isOnNavigationPage,
15
- UI
15
+ navAutoHide
16
16
  } from "../../utils";
17
17
  import { showMenu } from "../menu";
18
18
  export let href;
@@ -126,7 +126,7 @@ function on_link_clicked(e) {
126
126
  redirect_to(href2);
127
127
  }
128
128
  } else {
129
- auto_hide_sidebar();
129
+ navAutoHide();
130
130
  redirect_to(href2);
131
131
  }
132
132
  }
@@ -185,7 +185,7 @@ function activateRow(e) {
185
185
  opver: 1,
186
186
  operations: [
187
187
  {
188
- caption: "View",
188
+ caption: i18n({ en: "View", es: "Ver", pl: "Widok" }),
189
189
  operations: [
190
190
  {
191
191
  icon: FaEllipsisV,
package/desk.svelte CHANGED
@@ -9,7 +9,6 @@
9
9
  import {main_sidebar_visible_store,
10
10
  tools_visible_store,
11
11
  bottom_bar_visible_store,
12
- auto_hide_sidebar,
13
12
  hasSelectedItem,
14
13
  dark_mode_store,
15
14
  data_tick_store,
@@ -20,7 +19,7 @@
20
19
  alerts, removeAlert, showFABAlways} from './stores.js'
21
20
 
22
21
  //import { AuthorizedView} from '@humandialog/auth.svelte'
23
- import { handleSelect, isDeviceSmallerThan, isOnNavigationPage, isOnScreenKeyboardVisible, removeAt, UI } from './utils'
22
+ import { handleSelect, isDeviceSmallerThan, isOnScreenKeyboardVisible, navGetMode, removeAt, UI, NAV_MODE_SIDEBAR, navAutoHide, navIsVisible } from './utils'
24
23
  import { afterUpdate, onMount } from 'svelte';
25
24
  import {location} from 'svelte-spa-router'
26
25
  import {FaCopy, FaTimes} from 'svelte-icons/fa'
@@ -76,8 +75,8 @@
76
75
  //let autoRedirectToSignIn = layout.autoRedirectToSignIn ?? true
77
76
 
78
77
  $: { visible_sidebar = $main_sidebar_visible_store
79
-
80
- if(!is_small)
78
+ const navMode = navGetMode()
79
+ if(navMode == NAV_MODE_SIDEBAR)
81
80
  {
82
81
  if(visible_sidebar == "*")
83
82
  {
@@ -190,10 +189,11 @@
190
189
  }
191
190
 
192
191
 
193
- $: navigationPageVisible = navigationPageSetup($location);
192
+ $: navigationPageSetup($location);
194
193
  function navigationPageSetup(...args)
195
194
  {
196
- if(!is_small)
195
+ const navMode = navGetMode()
196
+ if(navMode == NAV_MODE_SIDEBAR)
197
197
  {
198
198
  vertical_toolbar_visibility = "hidden sm:block"
199
199
  content_left = "left-0 sm:left-[40px]";
@@ -202,7 +202,7 @@
202
202
  }
203
203
  else
204
204
  {
205
- if(isOnNavigationPage())
205
+ if(navIsVisible())
206
206
  {
207
207
  vertical_toolbar_visibility = "block"
208
208
  content_left = "left-[50px]";
@@ -254,7 +254,7 @@
254
254
 
255
255
  function on_resize()
256
256
  {
257
- auto_hide_sidebar();
257
+ navAutoHide()
258
258
  }
259
259
 
260
260
  let minViewportHeight = 0;
@@ -278,6 +278,7 @@
278
278
 
279
279
  function onViewportResize(e)
280
280
  {
281
+ console.log('onViewportResize')
281
282
  const vp = window.visualViewport;
282
283
  setViewportHeight(vp)
283
284
 
@@ -411,7 +412,7 @@
411
412
  behaviour is the content expand vertically, and only vertical scrollbar can be visible.
412
413
  When content on the main page needs to be expanded horizontally (like kanban chart for example) then
413
414
  that component should define overflow-x-* itself -->
414
- <section on:click|capture={() => { if(!navigationPageVisible) auto_hide_sidebar()} } class="">
415
+ <section on:click|capture={() => navAutoHide() } class="">
415
416
 
416
417
  <!--###########################################################-->
417
418
  <!--## HORIZONTAL TOOLS ######################-->