@humandialog/forms.svelte 1.5.0 → 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.
- package/components/breadcrumb.svelte +34 -18
- package/components/breadcrumb.svelte.d.ts +2 -0
- package/components/contextmenu.svelte +125 -28
- package/components/contextmenu.svelte.d.ts +2 -2
- package/components/document/editor.svelte +46 -36
- package/components/document/editor.svelte.d.ts +6 -6
- package/components/menu.d.ts +5 -1
- package/components/menu.js +7 -3
- package/components/sidebar/sidebar.item.svelte +5 -5
- package/desk.svelte +10 -9
- package/horizontal.toolbar.svelte +57 -65
- package/i18n-preprocess.d.ts +39 -0
- package/i18n-preprocess.js +100 -0
- package/i18n.d.ts +30 -0
- package/i18n.js +162 -0
- package/index.d.ts +5 -3
- package/index.js +5 -3
- package/modal.svelte +2 -1
- package/package.json +3 -1
- package/stores.d.ts +1 -0
- package/stores.js +4 -3
- package/tenant.members.svelte +46 -40
- package/utils.d.ts +14 -4
- package/utils.js +178 -18
- package/vertical.toolbar.svelte +65 -42
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import { breadcrumbParse, breadcrumbStringify } from './breadcrumb_utils';
|
|
4
4
|
|
|
5
5
|
export let path;
|
|
6
|
+
export let collapseLonger = false
|
|
6
7
|
|
|
7
8
|
let segments = []
|
|
8
9
|
let userClass = $$props.class ?? ''
|
|
@@ -34,24 +35,39 @@
|
|
|
34
35
|
{#each segments as segment, idx (segment.href)}
|
|
35
36
|
{@const isFirst = idx == 0}
|
|
36
37
|
{@const isLast = idx == segments.length-1}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
38
|
+
{@const collapsable = collapseLonger && segments.length > 5}
|
|
39
|
+
{@const isCollapsed = collapsable && idx > 0 && idx < segments.length-3}
|
|
40
|
+
{@const isFirstCollapsed = isCollapsed && idx == 1}
|
|
41
|
+
|
|
42
|
+
{#if isCollapsed}
|
|
43
|
+
{#if isFirstCollapsed}
|
|
44
|
+
<svg class="rtl:rotate-180 w-3 h-3 text-stone-400 mx-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
45
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
|
|
46
|
+
</svg>
|
|
47
|
+
<span class="ms-1 text-sm md:ms-2 font-semibold text-stone-900 dark:text-stone-100 whitespace-nowrap">
|
|
48
|
+
...
|
|
49
|
+
</span>
|
|
50
|
+
{/if}
|
|
51
|
+
{:else}
|
|
52
|
+
<li>
|
|
53
|
+
<div class="flex items-center">
|
|
54
|
+
{#if !isFirst}
|
|
55
|
+
<svg class="rtl:rotate-180 w-3 h-3 text-stone-400 mx-1" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 6 10">
|
|
56
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 9 4-4-4-4"/>
|
|
57
|
+
</svg>
|
|
58
|
+
{/if}
|
|
59
|
+
{#if isLast}
|
|
60
|
+
<span class="ms-1 text-sm md:ms-2 font-semibold text-stone-900 dark:text-stone-100 whitespace-nowrap">
|
|
61
|
+
{segment.name}
|
|
62
|
+
</span>
|
|
63
|
+
{:else}
|
|
64
|
+
<a href={getSegmentHRef(segment.href, idx)} use:link class="ms-1 text-sm font-medium md:ms-2 text-stone-700 hover:text-stone-900 dark:text-stone-400 dark:hover:text-white whitespace-nowrap">
|
|
65
|
+
{segment.name}
|
|
66
|
+
</a>
|
|
67
|
+
{/if}
|
|
68
|
+
</div>
|
|
69
|
+
</li>
|
|
70
|
+
{/if}
|
|
55
71
|
{/each}
|
|
56
72
|
{/if}
|
|
57
73
|
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export default class Breadcrumb extends SvelteComponentTyped<{
|
|
5
5
|
[x: string]: any;
|
|
6
6
|
path: any;
|
|
7
|
+
collapseLonger?: boolean | undefined;
|
|
7
8
|
}, {
|
|
8
9
|
[evt: string]: CustomEvent<any>;
|
|
9
10
|
}, {}> {
|
|
@@ -16,6 +17,7 @@ declare const __propDef: {
|
|
|
16
17
|
props: {
|
|
17
18
|
[x: string]: any;
|
|
18
19
|
path: any;
|
|
20
|
+
collapseLonger?: boolean | undefined;
|
|
19
21
|
};
|
|
20
22
|
events: {
|
|
21
23
|
[evt: string]: CustomEvent<any>;
|
|
@@ -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 {
|
|
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,
|
|
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
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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
|
-
|
|
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: "
|
|
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: "
|
|
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
|
-
{
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
113
|
+
caption: any;
|
|
114
114
|
operations: any[];
|
|
115
115
|
preAction: (f: any) => void;
|
|
116
116
|
tbr: string;
|
package/components/menu.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import Floating_container from './Floating_container.svelte';
|
|
2
|
-
export declare
|
|
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;
|
package/components/menu.js
CHANGED
|
@@ -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
|
|
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?');
|