@humandialog/forms.svelte 0.4.44 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Fab.svelte +60 -48
- package/components/Floating_container.svelte +5 -4
- package/components/Floating_container.svelte.d.ts +2 -2
- package/components/Grid.menu.svelte +13 -9
- package/components/Grid.menu.svelte.d.ts +2 -2
- package/components/button.svelte +4 -4
- package/components/checkbox.svelte +12 -10
- package/components/checkbox.svelte.d.ts +1 -0
- package/components/combo/combo.d.ts +1 -1
- package/components/combo/combo.js +1 -1
- package/components/combo/combo.source.svelte +2 -2
- package/components/combo/combo.source.svelte.d.ts +1 -1
- package/components/combo/combo.svelte +94 -62
- package/components/combo/combo.svelte.d.ts +7 -4
- package/components/contextmenu.svelte +20 -19
- package/components/contextmenu.svelte.d.ts +5 -5
- package/components/date.svelte +165 -25
- package/components/date.svelte.d.ts +3 -2
- package/components/delayed.spinner.svelte +2 -2
- package/components/document/internal/palette.row.svelte +3 -3
- package/components/document/internal/palette.svelte +2 -2
- package/components/document/internal/palette.svelte.d.ts +1 -1
- package/components/document/rich.edit.svelte +307 -35
- package/components/document/rich.edit.svelte.d.ts +9 -0
- package/components/edit.field.svelte +17 -15
- package/components/edit.field.svelte.d.ts +2 -1
- package/components/file.loader.svelte +6 -6
- package/components/file.loader.svelte.d.ts +10 -10
- package/components/icon.svelte +2 -2
- package/components/icon.svelte.d.ts +3 -3
- package/components/input.text.svelte +3 -3
- package/components/inputbox.ltop.svelte +19 -17
- package/components/inputbox.ltop.svelte.d.ts +4 -2
- package/components/kanban/Kanban.d.ts +23 -0
- package/components/kanban/Kanban.js +23 -0
- package/components/kanban/internal/kanban.card.svelte +158 -0
- package/components/kanban/internal/kanban.card.svelte.d.ts +35 -0
- package/components/kanban/internal/kanban.column.svelte +181 -0
- package/components/kanban/internal/kanban.column.svelte.d.ts +51 -0
- package/components/kanban/internal/kanban.inserter.svelte +24 -0
- package/components/kanban/internal/kanban.inserter.svelte.d.ts +18 -0
- package/components/kanban/internal/kanban.move.menu.svelte +146 -0
- package/components/kanban/internal/kanban.move.menu.svelte.d.ts +19 -0
- package/components/kanban/kanban.callbacks.svelte +15 -0
- package/components/kanban/kanban.callbacks.svelte.d.ts +21 -0
- package/components/kanban/kanban.column.svelte +20 -0
- package/components/kanban/kanban.column.svelte.d.ts +21 -0
- package/components/kanban/kanban.summary.svelte +5 -0
- package/components/kanban/kanban.summary.svelte.d.ts +16 -0
- package/components/kanban/kanban.svelte +156 -0
- package/components/kanban/kanban.svelte.d.ts +43 -0
- package/components/kanban/kanban.title.svelte +8 -0
- package/components/kanban/kanban.title.svelte.d.ts +17 -0
- package/components/list/List.d.ts +4 -2
- package/components/list/List.js +4 -2
- package/components/list/internal/list.element.props.svelte +134 -0
- package/components/list/internal/list.element.props.svelte.d.ts +21 -0
- package/components/list/internal/list.element.summary.svelte +40 -0
- package/components/list/internal/list.element.summary.svelte.d.ts +24 -0
- package/components/list/internal/list.element.svelte +100 -173
- package/components/list/internal/list.element.svelte.d.ts +4 -4
- package/components/list/internal/list.inserter.svelte +9 -6
- package/components/list/internal/list.inserter.svelte.d.ts +1 -1
- package/components/list/list.combo.svelte +2 -2
- package/components/list/list.combo.svelte.d.ts +1 -1
- package/components/list/list.date.svelte +3 -3
- package/components/list/list.date.svelte.d.ts +1 -1
- package/components/list/list.inserter.svelte +1 -1
- package/components/list/list.summary.svelte +2 -2
- package/components/list/list.summary.svelte.d.ts +1 -1
- package/components/list/list.svelte +175 -37
- package/components/list/list.svelte.d.ts +27 -10
- package/components/list/list.title.svelte +6 -2
- package/components/list/list.title.svelte.d.ts +3 -1
- package/components/menu.d.ts +4 -4
- package/components/menu.js +15 -13
- package/components/radio.svelte +12 -10
- package/components/radio.svelte.d.ts +1 -0
- package/components/sidebar/sidebar.group.svelte +1 -13
- package/components/sidebar/sidebar.group.svelte.d.ts +0 -4
- package/components/sidebar/sidebar.item.svelte +13 -13
- package/components/sidebar/sidebar.list.svelte +68 -0
- package/components/sidebar/sidebar.list.svelte.d.ts +33 -0
- package/components/sidebar/sidebar.svelte +1 -1
- package/components/simple.table.svelte +15 -15
- package/components/simple.table.svelte.d.ts +2 -2
- package/components/table/_template.table.svelte +17 -17
- package/components/table/_template.table.svelte.d.ts +2 -2
- package/components/table/table.svelte +31 -31
- package/components/table/table.svelte.d.ts +8 -8
- package/components/textarea.ltop.svelte +4 -4
- package/components/tile.title.svelte +6 -6
- package/desk.svelte +13 -13
- package/form.box.svelte +2 -2
- package/horizontal.toolbar.svelte +25 -16
- package/horizontal.toolbar.svelte.d.ts +2 -2
- package/index.d.ts +14 -5
- package/index.js +14 -5
- package/modal.svelte +17 -17
- package/modal.svelte.d.ts +4 -4
- package/operations.svelte +42 -27
- package/package.json +14 -1
- package/page.svelte +115 -124
- package/page.svelte.d.ts +4 -4
- package/stores.d.ts +9 -7
- package/stores.js +17 -9
- package/tenant.members.svelte +44 -44
- package/tenant.members.svelte.d.ts +10 -10
- package/tile.svelte +3 -3
- package/tiles.vertical.row.svelte +1 -1
- package/updates.d.ts +3 -3
- package/updates.js +35 -3
- package/utils.d.ts +22 -13
- package/utils.js +201 -51
- package/vertical.toolbar.svelte +22 -13
- package/vertical.toolbar.svelte.d.ts +2 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script>import { Selection_helper } from "./internal/Selection_helper";
|
|
2
2
|
import { getContext, onDestroy, onMount } from "svelte";
|
|
3
3
|
import { Selection_range, Selection_edge } from "./internal/Selection_range";
|
|
4
|
-
import { data_tick_store,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { data_tick_store, contextItemsStore, contextTypesStore } from "../../stores.js";
|
|
5
|
+
import { informModification, pushChanges } from "../../updates.js";
|
|
6
|
+
import { parseWidthDirective } from "../../utils.js";
|
|
7
7
|
import Palette from "./internal/palette.svelte";
|
|
8
8
|
import FaFont from "svelte-icons/fa/FaFont.svelte";
|
|
9
9
|
import FaHead from "svelte-icons/fa/FaHeading.svelte";
|
|
@@ -18,7 +18,26 @@ export let self = null;
|
|
|
18
18
|
export let a = "";
|
|
19
19
|
export let context = "";
|
|
20
20
|
export let typename = "";
|
|
21
|
+
export let compact = false;
|
|
21
22
|
export let c = "";
|
|
23
|
+
export let pushChangesImmediately = true;
|
|
24
|
+
let onBlur = void 0;
|
|
25
|
+
export function run(onStop = void 0) {
|
|
26
|
+
onBlur = onStop;
|
|
27
|
+
editable_div?.focus();
|
|
28
|
+
}
|
|
29
|
+
export function get_formatting_operations() {
|
|
30
|
+
let result = [];
|
|
31
|
+
commands.forEach((c2) => {
|
|
32
|
+
result.push({
|
|
33
|
+
caption: "",
|
|
34
|
+
//c.caption,
|
|
35
|
+
icon: c2.icon,
|
|
36
|
+
action: c2.on_choice
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
22
41
|
let item = null;
|
|
23
42
|
let changed_value;
|
|
24
43
|
let has_changed_value = false;
|
|
@@ -33,7 +52,14 @@ let palette_focused_selection_pos;
|
|
|
33
52
|
let palette_focused_string_start;
|
|
34
53
|
let palette_focused_string_end;
|
|
35
54
|
let ctx = context ? context : getContext("ctx");
|
|
36
|
-
let cs =
|
|
55
|
+
let cs = parseWidthDirective(c);
|
|
56
|
+
let appearance_class;
|
|
57
|
+
if (compact)
|
|
58
|
+
appearance_class = "";
|
|
59
|
+
else
|
|
60
|
+
appearance_class = `bg-stone-50 border border-stone-300 rounded-md
|
|
61
|
+
dark:bg-stone-700 dark:border-stone-600
|
|
62
|
+
px-2.5`;
|
|
37
63
|
let last_tick = -1;
|
|
38
64
|
$: {
|
|
39
65
|
if (last_tick < $data_tick_store)
|
|
@@ -45,14 +71,14 @@ function setup_source() {
|
|
|
45
71
|
if (self)
|
|
46
72
|
item = self;
|
|
47
73
|
else
|
|
48
|
-
item = $
|
|
74
|
+
item = $contextItemsStore[ctx];
|
|
49
75
|
if (!typename)
|
|
50
|
-
typename = $
|
|
76
|
+
typename = $contextTypesStore[ctx];
|
|
51
77
|
if (item != null)
|
|
52
78
|
value = item[a];
|
|
53
79
|
}
|
|
54
80
|
if (!value)
|
|
55
|
-
value = "<
|
|
81
|
+
value = "<p>\u200B</p>";
|
|
56
82
|
has_changed_value = false;
|
|
57
83
|
}
|
|
58
84
|
onMount(() => {
|
|
@@ -139,9 +165,29 @@ const on_keydown = (event) => {
|
|
|
139
165
|
break;
|
|
140
166
|
case "Backspace":
|
|
141
167
|
if (is_range_selected()) {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
168
|
+
if (is_multi_range_selection()) {
|
|
169
|
+
event.cancelBubble = true;
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
console.log("Unsupported");
|
|
172
|
+
} else {
|
|
173
|
+
event.cancelBubble = true;
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
if (is_selection_within_single_paragraph()) {
|
|
176
|
+
if (is_whole_parapraph_selected()) {
|
|
177
|
+
if (is_focused_paragraph_last_in_document()) {
|
|
178
|
+
make_focused_paragraph_empty(true);
|
|
179
|
+
} else {
|
|
180
|
+
let next_paragraph;
|
|
181
|
+
next_paragraph = remove_focused_paragraph(true);
|
|
182
|
+
set_caret_at_begin_of_paragraph(next_paragraph);
|
|
183
|
+
}
|
|
184
|
+
} else {
|
|
185
|
+
cut_selected_text_in_focused_paragraph();
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
cut_selected_paragraphs();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
145
191
|
} else {
|
|
146
192
|
let hide_commands_palette = false;
|
|
147
193
|
if (is_command_palette_visible)
|
|
@@ -154,9 +200,17 @@ const on_keydown = (event) => {
|
|
|
154
200
|
let prev_paragraph;
|
|
155
201
|
prev_paragraph = remove_focused_paragraph(false);
|
|
156
202
|
set_caret_at_end_of_paragraph(prev_paragraph);
|
|
157
|
-
}
|
|
203
|
+
} else
|
|
204
|
+
;
|
|
158
205
|
} else
|
|
159
206
|
make_focused_paragraph_empty(true);
|
|
207
|
+
} else if (is_caret_at_beginning_of_paragraph()) {
|
|
208
|
+
event.cancelBubble = true;
|
|
209
|
+
event.preventDefault();
|
|
210
|
+
if (!is_focused_paragraph_first_in_document()) {
|
|
211
|
+
merge_focused_paragraph_with_previous();
|
|
212
|
+
} else
|
|
213
|
+
;
|
|
160
214
|
}
|
|
161
215
|
if (hide_commands_palette)
|
|
162
216
|
hide_command_palette();
|
|
@@ -164,9 +218,29 @@ const on_keydown = (event) => {
|
|
|
164
218
|
break;
|
|
165
219
|
case "Delete":
|
|
166
220
|
if (is_range_selected()) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
221
|
+
if (is_multi_range_selection()) {
|
|
222
|
+
event.cancelBubble = true;
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
console.log("Unsupported");
|
|
225
|
+
} else {
|
|
226
|
+
event.cancelBubble = true;
|
|
227
|
+
event.preventDefault();
|
|
228
|
+
if (is_selection_within_single_paragraph()) {
|
|
229
|
+
if (is_whole_parapraph_selected()) {
|
|
230
|
+
if (is_focused_paragraph_last_in_document()) {
|
|
231
|
+
make_focused_paragraph_empty(true);
|
|
232
|
+
} else {
|
|
233
|
+
let next_paragraph;
|
|
234
|
+
next_paragraph = remove_focused_paragraph(true);
|
|
235
|
+
set_caret_at_begin_of_paragraph(next_paragraph);
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
cut_selected_text_in_focused_paragraph();
|
|
239
|
+
}
|
|
240
|
+
} else {
|
|
241
|
+
cut_selected_paragraphs();
|
|
242
|
+
}
|
|
243
|
+
}
|
|
170
244
|
} else if (is_last_character_after_caret()) {
|
|
171
245
|
event.cancelBubble = true;
|
|
172
246
|
event.preventDefault();
|
|
@@ -178,7 +252,15 @@ const on_keydown = (event) => {
|
|
|
178
252
|
let next_paragraph;
|
|
179
253
|
next_paragraph = remove_focused_paragraph(true);
|
|
180
254
|
set_caret_at_begin_of_paragraph(next_paragraph);
|
|
181
|
-
}
|
|
255
|
+
} else
|
|
256
|
+
;
|
|
257
|
+
} else if (is_caret_at_ending_of_paragraph()) {
|
|
258
|
+
event.cancelBubble = true;
|
|
259
|
+
event.preventDefault();
|
|
260
|
+
if (!is_focused_paragraph_last_in_document()) {
|
|
261
|
+
merge_focused_paragraph_with_next();
|
|
262
|
+
} else
|
|
263
|
+
;
|
|
182
264
|
}
|
|
183
265
|
break;
|
|
184
266
|
case "Esc":
|
|
@@ -277,6 +359,180 @@ function is_last_character_after_caret() {
|
|
|
277
359
|
}
|
|
278
360
|
return false;
|
|
279
361
|
}
|
|
362
|
+
function is_caret_at_beginning_of_paragraph() {
|
|
363
|
+
let sel;
|
|
364
|
+
sel = window.getSelection();
|
|
365
|
+
if (sel.focusNode.textContent && sel.focusNode.nodeType !== sel.focusNode.COMMENT_NODE) {
|
|
366
|
+
if (sel.focusOffset == 0)
|
|
367
|
+
return true;
|
|
368
|
+
}
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
function is_caret_at_ending_of_paragraph() {
|
|
372
|
+
let sel;
|
|
373
|
+
sel = window.getSelection();
|
|
374
|
+
if (sel.focusNode.textContent && sel.focusNode.nodeType !== sel.focusNode.COMMENT_NODE) {
|
|
375
|
+
if (sel.focusOffset == sel.focusNode.textContent.length)
|
|
376
|
+
return true;
|
|
377
|
+
}
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
function merge_focused_paragraph_with_previous() {
|
|
381
|
+
let sel;
|
|
382
|
+
sel = window.getSelection();
|
|
383
|
+
let merged_text = sel.focusNode.textContent;
|
|
384
|
+
let prev_paragraph = remove_focused_paragraph(false);
|
|
385
|
+
let text_node = prev_paragraph.childNodes[0];
|
|
386
|
+
let merging_text = text_node.textContent;
|
|
387
|
+
text_node.textContent = merging_text + merged_text;
|
|
388
|
+
let pos = merging_text.length + 0;
|
|
389
|
+
let range = new Range();
|
|
390
|
+
range.collapse(true);
|
|
391
|
+
range.setStart(text_node, pos);
|
|
392
|
+
range.setEnd(text_node, pos);
|
|
393
|
+
set_selection(range);
|
|
394
|
+
}
|
|
395
|
+
function merge_focused_paragraph_with_next() {
|
|
396
|
+
let sel;
|
|
397
|
+
sel = window.getSelection();
|
|
398
|
+
let focus_node = sel.focusNode;
|
|
399
|
+
let merging_text = focus_node.textContent;
|
|
400
|
+
let focused_paragraph = focus_node.parentNode;
|
|
401
|
+
let next_paragraph = focused_paragraph.nextSibling;
|
|
402
|
+
while (next_paragraph.nodeType != Node.ELEMENT_NODE)
|
|
403
|
+
next_paragraph = next_paragraph.nextSibling;
|
|
404
|
+
let text_node = next_paragraph.childNodes[0];
|
|
405
|
+
let merged_text = text_node.textContent;
|
|
406
|
+
let root = focused_paragraph.parentNode;
|
|
407
|
+
root.removeChild(next_paragraph);
|
|
408
|
+
focus_node.textContent = merging_text + merged_text;
|
|
409
|
+
let pos = merging_text.length;
|
|
410
|
+
let range = new Range();
|
|
411
|
+
range.collapse(true);
|
|
412
|
+
range.setStart(focus_node, pos);
|
|
413
|
+
range.setEnd(focus_node, pos);
|
|
414
|
+
set_selection(range);
|
|
415
|
+
}
|
|
416
|
+
function cut_selected_text_in_focused_paragraph() {
|
|
417
|
+
let sel;
|
|
418
|
+
sel = window.getSelection();
|
|
419
|
+
const focus_node = sel.focusNode;
|
|
420
|
+
const whole_text = focus_node.textContent;
|
|
421
|
+
const left_idx = Math.min(sel.focusOffset, sel.anchorOffset);
|
|
422
|
+
const right_idx = Math.max(sel.focusOffset, sel.anchorOffset);
|
|
423
|
+
let left_part = whole_text.substring(0, left_idx);
|
|
424
|
+
let right_part = whole_text.substring(right_idx);
|
|
425
|
+
focus_node.textContent = left_part + right_part;
|
|
426
|
+
let pos = left_part.length;
|
|
427
|
+
let range = new Range();
|
|
428
|
+
range.collapse(true);
|
|
429
|
+
range.setStart(focus_node, pos);
|
|
430
|
+
range.setEnd(focus_node, pos);
|
|
431
|
+
set_selection(range);
|
|
432
|
+
}
|
|
433
|
+
function cut_selected_paragraphs() {
|
|
434
|
+
let sel = window.getSelection();
|
|
435
|
+
let first_paragraph;
|
|
436
|
+
let first_offset;
|
|
437
|
+
let last_paragraph;
|
|
438
|
+
let last_offset;
|
|
439
|
+
let cmp = sel.anchorNode?.compareDocumentPosition(sel.focusNode);
|
|
440
|
+
switch (cmp) {
|
|
441
|
+
case Node.DOCUMENT_POSITION_PRECEDING:
|
|
442
|
+
case Node.DOCUMENT_POSITION_CONTAINS:
|
|
443
|
+
first_paragraph = sel.focusNode.parentNode;
|
|
444
|
+
first_offset = sel.focusOffset;
|
|
445
|
+
last_paragraph = sel.anchorNode.parentNode;
|
|
446
|
+
last_offset = sel.anchorOffset;
|
|
447
|
+
break;
|
|
448
|
+
case Node.DOCUMENT_POSITION_FOLLOWING:
|
|
449
|
+
case Node.DOCUMENT_POSITION_CONTAINED_BY:
|
|
450
|
+
first_paragraph = sel.anchorNode.parentNode;
|
|
451
|
+
first_offset = sel.anchorOffset;
|
|
452
|
+
last_paragraph = sel.focusNode.parentNode;
|
|
453
|
+
last_offset = sel.focusOffset;
|
|
454
|
+
break;
|
|
455
|
+
default:
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
let in_selection = false;
|
|
459
|
+
let paragraphs_to_remove = [];
|
|
460
|
+
let root = first_paragraph.parentNode;
|
|
461
|
+
const siblings_no = root.childNodes.length;
|
|
462
|
+
for (let i = 0; i < siblings_no; i++) {
|
|
463
|
+
let n = root.childNodes[i];
|
|
464
|
+
if (in_selection) {
|
|
465
|
+
if (n == last_paragraph) {
|
|
466
|
+
let text_node = n.childNodes[0];
|
|
467
|
+
let text_in_node = text_node.textContent;
|
|
468
|
+
text_in_node = text_in_node.substring(last_offset);
|
|
469
|
+
if (text_in_node) {
|
|
470
|
+
text_node.textContent = text_in_node;
|
|
471
|
+
} else {
|
|
472
|
+
text_node.textContent = "\u200B";
|
|
473
|
+
}
|
|
474
|
+
in_selection = false;
|
|
475
|
+
break;
|
|
476
|
+
} else {
|
|
477
|
+
paragraphs_to_remove.push(n);
|
|
478
|
+
}
|
|
479
|
+
} else if (n == first_paragraph) {
|
|
480
|
+
let text_node = n.childNodes[0];
|
|
481
|
+
let text_in_node = text_node.textContent;
|
|
482
|
+
text_in_node = text_in_node.substring(0, first_offset);
|
|
483
|
+
if (text_in_node) {
|
|
484
|
+
text_node.textContent = text_in_node;
|
|
485
|
+
} else {
|
|
486
|
+
if (n == last_paragraph)
|
|
487
|
+
text_node.textContent = "\u200B";
|
|
488
|
+
else {
|
|
489
|
+
paragraphs_to_remove.push(n);
|
|
490
|
+
first_paragraph = null;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
in_selection = true;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
if (first_paragraph) {
|
|
497
|
+
let last_node = last_paragraph.childNodes[0];
|
|
498
|
+
let merged_text = last_node.textContent;
|
|
499
|
+
let text_node = first_paragraph.childNodes[0];
|
|
500
|
+
let merging_text = text_node.textContent;
|
|
501
|
+
text_node.textContent = merging_text + merged_text;
|
|
502
|
+
paragraphs_to_remove.push(last_paragraph);
|
|
503
|
+
let pos = merging_text.length;
|
|
504
|
+
let range = new Range();
|
|
505
|
+
range.collapse(true);
|
|
506
|
+
range.setStart(text_node, pos);
|
|
507
|
+
range.setEnd(text_node, pos);
|
|
508
|
+
set_selection(range);
|
|
509
|
+
} else {
|
|
510
|
+
let text_node = last_paragraph.childNodes[0];
|
|
511
|
+
let range = new Range();
|
|
512
|
+
range.collapse(true);
|
|
513
|
+
range.setStart(text_node, 0);
|
|
514
|
+
range.setEnd(text_node, 0);
|
|
515
|
+
set_selection(range);
|
|
516
|
+
}
|
|
517
|
+
paragraphs_to_remove.forEach((c2) => {
|
|
518
|
+
root.removeChild(c2);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
function is_selection_within_single_paragraph() {
|
|
522
|
+
let sel;
|
|
523
|
+
sel = window.getSelection();
|
|
524
|
+
return sel.focusNode == sel.anchorNode;
|
|
525
|
+
}
|
|
526
|
+
function is_whole_parapraph_selected() {
|
|
527
|
+
let sel = window.getSelection();
|
|
528
|
+
const selected_chanacters_no = Math.abs(sel.focusOffset - sel.anchorOffset);
|
|
529
|
+
const node_characters_no = sel.focusNode?.textContent?.length;
|
|
530
|
+
return selected_chanacters_no == node_characters_no;
|
|
531
|
+
}
|
|
532
|
+
function is_multi_range_selection() {
|
|
533
|
+
let sel = window.getSelection();
|
|
534
|
+
return sel.rangeCount > 1;
|
|
535
|
+
}
|
|
280
536
|
function is_range_selected() {
|
|
281
537
|
let sel;
|
|
282
538
|
sel = window.getSelection();
|
|
@@ -334,10 +590,15 @@ function remove_focused_paragraph(return_next_sibling = false) {
|
|
|
334
590
|
let text_node = window.getSelection().focusNode;
|
|
335
591
|
let focused_div = text_node.parentNode;
|
|
336
592
|
let result;
|
|
337
|
-
if (!return_next_sibling)
|
|
593
|
+
if (!return_next_sibling) {
|
|
338
594
|
result = focused_div.previousSibling;
|
|
339
|
-
|
|
595
|
+
while (result && result.nodeType != Node.ELEMENT_NODE)
|
|
596
|
+
result = result.previousSibling;
|
|
597
|
+
} else {
|
|
340
598
|
result = focused_div.nextSibling;
|
|
599
|
+
while (result && result.nodeType != Node.ELEMENT_NODE)
|
|
600
|
+
result = result.nextSibling;
|
|
601
|
+
}
|
|
341
602
|
let root = focused_div.parentNode;
|
|
342
603
|
root.removeChild(focused_div);
|
|
343
604
|
return result;
|
|
@@ -495,7 +756,7 @@ function do_format(tag, css_class) {
|
|
|
495
756
|
function insert_new_line() {
|
|
496
757
|
const elem = editable_div;
|
|
497
758
|
const editableElem = editable_div;
|
|
498
|
-
const tag = "
|
|
759
|
+
const tag = "p";
|
|
499
760
|
let inTheMiddle;
|
|
500
761
|
if (editableElem) {
|
|
501
762
|
let active_range = Selection_helper.get_selection(editable_div);
|
|
@@ -593,6 +854,12 @@ function show_command_palette() {
|
|
|
593
854
|
else if (top_space >= preferred_palette_height) {
|
|
594
855
|
y = rect.y;
|
|
595
856
|
show_above = true;
|
|
857
|
+
} else if (rect.x > preferred_palette_width) {
|
|
858
|
+
x = rect.x - preferred_palette_width - 5;
|
|
859
|
+
y = rect.y - (preferred_palette_height - bottom_space);
|
|
860
|
+
} else if (rect.x + preferred_palette_width < client_rect.width) {
|
|
861
|
+
x = rect.x + 5;
|
|
862
|
+
y = rect.y - (preferred_palette_height - bottom_space);
|
|
596
863
|
} else
|
|
597
864
|
show_fullscreen = true;
|
|
598
865
|
if (show_fullscreen)
|
|
@@ -619,12 +886,17 @@ function on_selection_changed() {
|
|
|
619
886
|
}
|
|
620
887
|
function on_blur() {
|
|
621
888
|
let active_range = Selection_helper.get_selection(editable_div);
|
|
889
|
+
if (onBlur) {
|
|
890
|
+
onBlur();
|
|
891
|
+
onBlur = void 0;
|
|
892
|
+
}
|
|
622
893
|
if (item && a && has_changed_value) {
|
|
623
894
|
item[a] = changed_value;
|
|
624
895
|
has_changed_value = false;
|
|
625
896
|
if (typename) {
|
|
626
|
-
|
|
627
|
-
|
|
897
|
+
informModification(item, a, typename);
|
|
898
|
+
if (pushChangesImmediately)
|
|
899
|
+
pushChanges();
|
|
628
900
|
}
|
|
629
901
|
last_tick = $data_tick_store + 1;
|
|
630
902
|
$data_tick_store = last_tick;
|
|
@@ -632,31 +904,30 @@ function on_blur() {
|
|
|
632
904
|
}
|
|
633
905
|
let commands = [
|
|
634
906
|
{ caption: "Normal", description: "This is normal text style", tags: "text", icon: FaFont, on_choice: () => {
|
|
635
|
-
do_format("
|
|
907
|
+
do_format("p", "");
|
|
636
908
|
} },
|
|
637
|
-
{
|
|
909
|
+
// { caption: 'Heading 1', description: 'Big section heading', tags: 'h1', icon: FaHead, icon_size: 6, on_choice: () => { do_format('h2', '') } } ,
|
|
910
|
+
// { caption: 'Heading 2', description: 'Medium section heading', tags: 'h2', icon: FaHead, icon_size: 5, on_choice: () => { do_format('h3', '') } } ,
|
|
911
|
+
// { caption: 'Heading 3', description: 'Small section heading', tags: 'h3', icon: FaHead, icon_size: 4, on_choice: () => { do_format('h4', '') } } ,
|
|
912
|
+
{ caption: "Heading", description: "Description heading", tags: "h2", icon: FaHead, icon_size: 6, on_choice: () => {
|
|
638
913
|
do_format("h2", "");
|
|
639
914
|
} },
|
|
640
|
-
{
|
|
641
|
-
do_format(
|
|
642
|
-
} },
|
|
643
|
-
{ caption: "Heading 3", description: "Small section heading", tags: "h3", icon: FaHead, icon_size: 4, on_choice: () => {
|
|
644
|
-
do_format("h4", "");
|
|
645
|
-
} },
|
|
915
|
+
// { caption: 'Heading 2', description: 'Medium description heading', tags: 'h3', icon: FaHead, icon_size: 5, on_choice: () => { do_format('h3', '') } } ,
|
|
916
|
+
// { caption: 'Heading 3', description: 'Small description heading', tags: 'h4', icon: FaHead, icon_size: 4, on_choice: () => { do_format('h4', '') } } ,
|
|
646
917
|
{ caption: "Code", description: "Source code monospace text", icon: FaCode, on_choice: () => {
|
|
647
|
-
do_format("
|
|
918
|
+
do_format("p", "ml-6 text-sm font-mono break-normal text-pink-700 dark:text-pink-600");
|
|
648
919
|
} },
|
|
649
920
|
{ caption: "Comment", description: "With this you can comment the above paragraph", icon: FaComments, on_choice: () => {
|
|
650
|
-
do_format("
|
|
921
|
+
do_format("p", "ml-6 text-sm italic text-lime-700 dark:text-lime-600");
|
|
651
922
|
} },
|
|
652
923
|
{ caption: "Quote", description: "To quote someone", icon: FaQuote, on_choice: () => {
|
|
653
924
|
do_format("blockquote", "");
|
|
654
925
|
} },
|
|
655
926
|
{ caption: "Warning", description: "An important warning to above paragraph", icon: FaWarn, on_choice: () => {
|
|
656
|
-
do_format("
|
|
927
|
+
do_format("p", "ml-6 px-3 py-1 border-l-2 rounded-md border-orange-500 bg-orange-100 dark:bg-orange-900");
|
|
657
928
|
} },
|
|
658
929
|
{ caption: "Info", description: "An important info about above paragraph", icon: FaInfo, on_choice: () => {
|
|
659
|
-
do_format("
|
|
930
|
+
do_format("p", "ml-6 px-3 py-1 border-l-2 rounded-md border-blue-500 bg-blue-100 dark:bg-blue-900");
|
|
660
931
|
} }
|
|
661
932
|
];
|
|
662
933
|
</script>
|
|
@@ -666,10 +937,11 @@ let commands = [
|
|
|
666
937
|
on:keyup={on_keyup}
|
|
667
938
|
on:keydown={on_keydown}
|
|
668
939
|
on:mouseup={on_mouseup}
|
|
669
|
-
class="{cs}
|
|
670
|
-
|
|
671
|
-
prose prose-sm sm:prose-base dark:prose-invert {additional_class} overflow-y-auto"
|
|
940
|
+
class="{cs} {appearance_class}
|
|
941
|
+
prose prose-base sm:prose-base dark:prose-invert {additional_class} overflow-y-auto"
|
|
672
942
|
on:blur={on_blur}
|
|
943
|
+
on:focus
|
|
944
|
+
on:blur
|
|
673
945
|
>
|
|
674
946
|
{@html value}
|
|
675
947
|
</div>
|
|
@@ -8,9 +8,16 @@ declare const __propDef: {
|
|
|
8
8
|
a?: string | undefined;
|
|
9
9
|
context?: string | undefined;
|
|
10
10
|
typename?: string | undefined;
|
|
11
|
+
compact?: boolean | undefined;
|
|
11
12
|
c?: string | undefined;
|
|
13
|
+
pushChangesImmediately?: boolean | undefined;
|
|
14
|
+
run?: ((onStop?: undefined) => void) | undefined;
|
|
15
|
+
get_formatting_operations?: (() => any[]) | undefined;
|
|
12
16
|
};
|
|
13
17
|
events: {
|
|
18
|
+
focus: FocusEvent;
|
|
19
|
+
blur: FocusEvent;
|
|
20
|
+
} & {
|
|
14
21
|
[evt: string]: CustomEvent<any>;
|
|
15
22
|
};
|
|
16
23
|
slots: {};
|
|
@@ -19,5 +26,7 @@ export type RichProps = typeof __propDef.props;
|
|
|
19
26
|
export type RichEvents = typeof __propDef.events;
|
|
20
27
|
export type RichSlots = typeof __propDef.slots;
|
|
21
28
|
export default class Rich extends SvelteComponentTyped<RichProps, RichEvents, RichSlots> {
|
|
29
|
+
get run(): (onStop?: undefined) => void;
|
|
30
|
+
get get_formatting_operations(): () => any[];
|
|
22
31
|
}
|
|
23
32
|
export {};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
<script>import { afterUpdate, getContext } from "svelte";
|
|
2
|
-
import { data_tick_store,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { data_tick_store, contextItemsStore, contextTypesStore } from "../stores.js";
|
|
3
|
+
import { informModification, pushChanges } from "../updates.js";
|
|
4
|
+
import { parseWidthDirective, shouldBeComapact } from "../utils.js";
|
|
5
5
|
export let value = "";
|
|
6
6
|
export let placeholder = "";
|
|
7
|
-
export let
|
|
7
|
+
export let onEnter = null;
|
|
8
8
|
export let self = null;
|
|
9
9
|
export let a = "";
|
|
10
10
|
export let context = "";
|
|
11
11
|
export let typename = "";
|
|
12
12
|
export let inserter = false;
|
|
13
13
|
export let c = "";
|
|
14
|
+
export let pushChangesImmediately = true;
|
|
14
15
|
let is_table_component = getContext("rIs-table-component");
|
|
15
16
|
let item = null;
|
|
16
17
|
let input_box_is_active = false;
|
|
@@ -27,7 +28,7 @@ afterUpdate(() => {
|
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
let ctx = context ? context : getContext("ctx");
|
|
30
|
-
let cs =
|
|
31
|
+
let cs = parseWidthDirective(c);
|
|
31
32
|
let last_tick = -1;
|
|
32
33
|
$:
|
|
33
34
|
setup($data_tick_store);
|
|
@@ -35,9 +36,9 @@ function setup(data_tick_store2) {
|
|
|
35
36
|
if (data_tick_store2 <= last_tick)
|
|
36
37
|
return;
|
|
37
38
|
last_tick = data_tick_store2;
|
|
38
|
-
item = self ?? $
|
|
39
|
+
item = self ?? $contextItemsStore[ctx];
|
|
39
40
|
if (!typename)
|
|
40
|
-
typename = $
|
|
41
|
+
typename = $contextTypesStore[ctx];
|
|
41
42
|
if (a) {
|
|
42
43
|
if (item != null)
|
|
43
44
|
value = item[a];
|
|
@@ -46,7 +47,7 @@ function setup(data_tick_store2) {
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
function on_activate_input_box(event) {
|
|
49
|
-
if (!input_box_is_active && (is_table_component && $
|
|
50
|
+
if (!input_box_is_active && (is_table_component && $contextItemsStore["sel"] == self || !is_table_component)) {
|
|
50
51
|
input_box_is_active = true;
|
|
51
52
|
focus_input_box = true;
|
|
52
53
|
org_value = value;
|
|
@@ -62,8 +63,8 @@ async function on_key_down(event) {
|
|
|
62
63
|
}
|
|
63
64
|
try {
|
|
64
65
|
let success = false;
|
|
65
|
-
if (
|
|
66
|
-
success =
|
|
66
|
+
if (onEnter)
|
|
67
|
+
success = onEnter(value);
|
|
67
68
|
else {
|
|
68
69
|
success = value_changed();
|
|
69
70
|
accept_change();
|
|
@@ -100,13 +101,14 @@ function value_changed() {
|
|
|
100
101
|
if (item && a) {
|
|
101
102
|
item[a] = value;
|
|
102
103
|
if (typename)
|
|
103
|
-
|
|
104
|
+
informModification(item, a, typename);
|
|
104
105
|
}
|
|
105
106
|
return true;
|
|
106
107
|
}
|
|
107
108
|
function accept_change() {
|
|
108
109
|
$data_tick_store = $data_tick_store + 1;
|
|
109
|
-
|
|
110
|
+
if (pushChangesImmediately)
|
|
111
|
+
pushChanges();
|
|
110
112
|
}
|
|
111
113
|
</script>
|
|
112
114
|
|
|
@@ -115,15 +117,15 @@ function accept_change() {
|
|
|
115
117
|
<slot></slot>
|
|
116
118
|
|
|
117
119
|
{#if input_box_is_active}
|
|
118
|
-
<input bind:this={inputbox} bind:value={value} on:keydown={on_key_down} on:blur={on_blur} class="w-full border-0 bg-transparent text-
|
|
120
|
+
<input bind:this={inputbox} bind:value={value} on:keydown={on_key_down} on:blur={on_blur} class="w-full border-0 bg-transparent text-stone-900 dark:text-stone-300"/>
|
|
119
121
|
{:else if value}
|
|
120
122
|
{#if is_table_component}
|
|
121
123
|
<span>{value}</span>
|
|
122
124
|
{:else}
|
|
123
|
-
<span class="w-full text-
|
|
125
|
+
<span class="w-full text-stone-600 dark:text-stone-400 hover:text-stone-900 dark:hover:text-stone-300 cursor-text">{value}</span>
|
|
124
126
|
{/if}
|
|
125
127
|
{:else if !is_table_component}
|
|
126
|
-
<span class="w-full text-
|
|
128
|
+
<span class="w-full text-stone-500 hover:text-stone-700 dark:text-stone-500 dark:hover:text-stone-400 cursor-text">{placeholder}</span>
|
|
127
129
|
{/if}
|
|
128
130
|
</div>
|
|
129
131
|
|
|
@@ -4,13 +4,14 @@ declare const __propDef: {
|
|
|
4
4
|
[x: string]: any;
|
|
5
5
|
value?: string | undefined;
|
|
6
6
|
placeholder?: string | undefined;
|
|
7
|
-
|
|
7
|
+
onEnter?: null | undefined;
|
|
8
8
|
self?: null | undefined;
|
|
9
9
|
a?: string | undefined;
|
|
10
10
|
context?: string | undefined;
|
|
11
11
|
typename?: string | undefined;
|
|
12
12
|
inserter?: boolean | undefined;
|
|
13
13
|
c?: string | undefined;
|
|
14
|
+
pushChangesImmediately?: boolean | undefined;
|
|
14
15
|
};
|
|
15
16
|
events: {
|
|
16
17
|
[evt: string]: CustomEvent<any>;
|
|
@@ -47,28 +47,28 @@ function clear() {
|
|
|
47
47
|
file = void 0;
|
|
48
48
|
data = null;
|
|
49
49
|
}
|
|
50
|
-
export function
|
|
50
|
+
export function getName() {
|
|
51
51
|
if (file)
|
|
52
52
|
return file.name;
|
|
53
53
|
else
|
|
54
54
|
return "";
|
|
55
55
|
}
|
|
56
|
-
export function
|
|
56
|
+
export function getSize() {
|
|
57
57
|
if (file)
|
|
58
58
|
return file.size;
|
|
59
59
|
else
|
|
60
60
|
return -1;
|
|
61
61
|
}
|
|
62
|
-
export function
|
|
62
|
+
export function getType() {
|
|
63
63
|
if (file)
|
|
64
64
|
return file.type;
|
|
65
65
|
else
|
|
66
66
|
return "";
|
|
67
67
|
}
|
|
68
|
-
export function
|
|
68
|
+
export function getData() {
|
|
69
69
|
return data;
|
|
70
70
|
}
|
|
71
|
-
export function
|
|
71
|
+
export function isSelected() {
|
|
72
72
|
if (state == Success && data != null)
|
|
73
73
|
return true;
|
|
74
74
|
else
|
|
@@ -86,5 +86,5 @@ export function is_selected() {
|
|
|
86
86
|
{/if}
|
|
87
87
|
|
|
88
88
|
{#if state!=Empty}
|
|
89
|
-
<span class="h-4 w-4 text-
|
|
89
|
+
<span class="h-4 w-4 text-stone-700"><FaTimes on:click={clear}/></span>
|
|
90
90
|
{/if}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SvelteComponentTyped } from "svelte";
|
|
2
2
|
declare const __propDef: {
|
|
3
3
|
props: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
getName?: (() => string) | undefined;
|
|
5
|
+
getSize?: (() => number) | undefined;
|
|
6
|
+
getType?: (() => string) | undefined;
|
|
7
|
+
getData?: (() => ArrayBuffer) | undefined;
|
|
8
|
+
isSelected?: (() => boolean) | undefined;
|
|
9
9
|
};
|
|
10
10
|
events: {
|
|
11
11
|
[evt: string]: CustomEvent<any>;
|
|
@@ -16,10 +16,10 @@ export type FileProps = typeof __propDef.props;
|
|
|
16
16
|
export type FileEvents = typeof __propDef.events;
|
|
17
17
|
export type FileSlots = typeof __propDef.slots;
|
|
18
18
|
export default class File extends SvelteComponentTyped<FileProps, FileEvents, FileSlots> {
|
|
19
|
-
get
|
|
20
|
-
get
|
|
21
|
-
get
|
|
22
|
-
get
|
|
23
|
-
get
|
|
19
|
+
get getName(): () => string;
|
|
20
|
+
get getSize(): () => number;
|
|
21
|
+
get getType(): () => string;
|
|
22
|
+
get getData(): () => ArrayBuffer;
|
|
23
|
+
get isSelected(): () => boolean;
|
|
24
24
|
}
|
|
25
25
|
export {};
|