@humandialog/forms.svelte 1.6.9 → 1.7.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/document/editor.svelte +69 -20
- package/components/document/editor.svelte.d.ts +5 -0
- package/components/document/internal/palette.svelte +6 -4
- package/components/list/List.d.ts +2 -0
- package/components/list/List.js +2 -0
- package/components/list/internal/list.element.svelte +31 -6
- package/components/list/list.svelte +18 -12
- package/components/list/list.svelte.d.ts +2 -0
- package/components/list/list.title.svelte +4 -0
- package/components/list/list.title.svelte.d.ts +2 -0
- package/package.json +1 -1
|
@@ -26,6 +26,8 @@ import Underline from "@tiptap/extension-underline";
|
|
|
26
26
|
import Dropcursor from "@tiptap/extension-dropcursor";
|
|
27
27
|
import Gapcursor from "@tiptap/extension-gapcursor";
|
|
28
28
|
import History from "@tiptap/extension-history";
|
|
29
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
30
|
+
import { getAttributes } from "@tiptap/core";
|
|
29
31
|
import { data_tick_store, contextItemsStore, contextTypesStore, onErrorShowAlert, pushToolsActionsOperations, popToolsActionsOperations } from "../../stores.js";
|
|
30
32
|
import { informModification, pushChanges } from "../../updates.js";
|
|
31
33
|
import { isDeviceSmallerThan, parseWidthDirective, refreshToolbarOperations, UI } from "../../utils.js";
|
|
@@ -69,6 +71,7 @@ export let onFocusCb = void 0;
|
|
|
69
71
|
export let onBlurCb = void 0;
|
|
70
72
|
export let onAddImage = void 0;
|
|
71
73
|
export let onRemoveImage = void 0;
|
|
74
|
+
export let onLinkClick = void 0;
|
|
72
75
|
export let c = "";
|
|
73
76
|
export let pushChangesImmediately = true;
|
|
74
77
|
export let chat = void 0;
|
|
@@ -555,6 +558,45 @@ const additionalShortcuts = Extension.create({
|
|
|
555
558
|
};
|
|
556
559
|
}
|
|
557
560
|
});
|
|
561
|
+
export const CustomLink = Link.extend({
|
|
562
|
+
addOptions() {
|
|
563
|
+
return {
|
|
564
|
+
...this.parent?.(),
|
|
565
|
+
openOnClick: false
|
|
566
|
+
//showMap: () => {},
|
|
567
|
+
//setMapQuery: () => {},
|
|
568
|
+
};
|
|
569
|
+
},
|
|
570
|
+
addProseMirrorPlugins() {
|
|
571
|
+
const plugins = this.parent?.() || [];
|
|
572
|
+
const extensionOptions = this.options;
|
|
573
|
+
const clickHandler = new Plugin({
|
|
574
|
+
key: new PluginKey("handleControlClick"),
|
|
575
|
+
props: {
|
|
576
|
+
handleClick(view, pos, event) {
|
|
577
|
+
if (event.button !== 0) {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
if (!view.editable) {
|
|
581
|
+
return false;
|
|
582
|
+
}
|
|
583
|
+
const attrs = getAttributes(view.state, "link");
|
|
584
|
+
const link = event.target?.closest("a");
|
|
585
|
+
if (link && attrs.href) {
|
|
586
|
+
event.preventDefault();
|
|
587
|
+
event.stopPropagation();
|
|
588
|
+
if (onLinkClick)
|
|
589
|
+
onLinkClick(attrs.href, attrs.target);
|
|
590
|
+
return true;
|
|
591
|
+
}
|
|
592
|
+
return false;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
plugins.push(clickHandler);
|
|
597
|
+
return plugins;
|
|
598
|
+
}
|
|
599
|
+
});
|
|
558
600
|
onMount(() => {
|
|
559
601
|
editor = new Editor({
|
|
560
602
|
editable: !readOnly,
|
|
@@ -598,7 +640,11 @@ onMount(() => {
|
|
|
598
640
|
Italic,
|
|
599
641
|
Strike,
|
|
600
642
|
Underline,
|
|
601
|
-
|
|
643
|
+
...onLinkClick ? [
|
|
644
|
+
CustomLink.configure({
|
|
645
|
+
//showMap: () => { showMap(true); },
|
|
646
|
+
})
|
|
647
|
+
] : [Link],
|
|
602
648
|
Dropcursor,
|
|
603
649
|
Gapcursor,
|
|
604
650
|
History,
|
|
@@ -834,6 +880,9 @@ export function removeTemporaryImage(temporarySrc) {
|
|
|
834
880
|
return;
|
|
835
881
|
editor.commands.deleteRange(image.range);
|
|
836
882
|
}
|
|
883
|
+
export function addLink(title, href) {
|
|
884
|
+
editor.chain().setLink({ href }).insertContent(title).unsetMark("link").insertContent(" ").focus().run();
|
|
885
|
+
}
|
|
837
886
|
export function getInnerHtml() {
|
|
838
887
|
return editor.getHTML();
|
|
839
888
|
}
|
|
@@ -1014,50 +1063,50 @@ export function hasChanged() {
|
|
|
1014
1063
|
return hasChangedValue;
|
|
1015
1064
|
}
|
|
1016
1065
|
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: "
|
|
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") }
|
|
1066
|
+
{ caption: i18n({ en: "Bold", es: "Negrita", pl: "Pogrubiony" }), description: "Marks text as bolded", tags: "strong,bold", icon: FaBold, on_choice: makeBold, is_active: () => editor?.isActive("bold") },
|
|
1067
|
+
{ caption: i18n({ en: "Italic", es: "Cursiva", pl: "Kursywa" }), description: "Marks text as italic", tags: "italic,em", icon: FaItalic, on_choice: makeItalic, is_active: () => editor?.isActive("italic") },
|
|
1068
|
+
{ caption: i18n({ en: "Underline", es: "Subrayar", pl: "Podkre\u015Blenie" }), description: "Marks text as underlined", tags: "under", icon: FaUnderline, on_choice: makeUnderline, is_active: () => editor?.isActive("underline") },
|
|
1069
|
+
{ caption: i18n({ en: "Strikethrough", es: "Tachado", pl: "Przekre\u015Blenie" }), description: "Marks text as strikethrough", tags: "strike", icon: FaStrikethrough, on_choice: makeStrikethrough, is_active: () => editor?.isActive("strike") }
|
|
1021
1070
|
];
|
|
1022
1071
|
const paletteStylesCommands = () => [
|
|
1023
|
-
{ caption: i18n({ en: "
|
|
1024
|
-
if (range)
|
|
1025
|
-
editor.chain().focus().deleteRange(range).setParagraph().run();
|
|
1026
|
-
else
|
|
1027
|
-
editor.chain().focus().setParagraph().run();
|
|
1028
|
-
}, is_active: () => editor?.isActive("paragraph") },
|
|
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) => {
|
|
1072
|
+
{ caption: i18n({ en: "Heading 1", es: "T\xEDtulo 1", pl: "Nag\u0142\xF3wek 1" }), description: "Description heading", tags: "h1,head", icon: IcH1, on_choice: (range) => {
|
|
1030
1073
|
if (range)
|
|
1031
1074
|
editor.chain().focus().deleteRange(range).setHeading({ level: 1 }).run();
|
|
1032
1075
|
else
|
|
1033
1076
|
editor.chain().focus().setHeading({ level: 1 }).run();
|
|
1034
1077
|
}, is_active: () => editor?.isActive("heading", { level: 1 }) },
|
|
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) => {
|
|
1078
|
+
{ caption: i18n({ en: "Heading 2", es: "T\xEDtulo 2", pl: "Nag\u0142\xF3wek 2" }), description: "Secondary heading", tags: "h2,head", icon: IcH2, on_choice: (range) => {
|
|
1036
1079
|
if (range)
|
|
1037
1080
|
editor.chain().focus().deleteRange(range).setHeading({ level: 2 }).run();
|
|
1038
1081
|
else
|
|
1039
1082
|
editor.chain().focus().setHeading({ level: 2 }).run();
|
|
1040
1083
|
}, is_active: () => editor?.isActive("heading", { level: 2 }) },
|
|
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) => {
|
|
1084
|
+
{ caption: i18n({ en: "Heading 3", es: "T\xEDtulo 3", pl: "Nag\u0142\xF3wek 3" }), description: "Secondary heading", tags: "h3,head", icon: IcH3, on_choice: (range) => {
|
|
1042
1085
|
if (range)
|
|
1043
1086
|
editor.chain().focus().deleteRange(range).setHeading({ level: 3 }).run();
|
|
1044
1087
|
else
|
|
1045
1088
|
editor.chain().focus().setHeading({ level: 3 }).run();
|
|
1046
1089
|
}, is_active: () => editor?.isActive("heading", { level: 3 }) },
|
|
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) => {
|
|
1090
|
+
{ caption: i18n({ en: "Heading 4", es: "T\xEDtulo 4", pl: "Nag\u0142\xF3wek 4" }), description: "Secondary heading", tags: "h4,head", icon: IcH4, on_choice: (range) => {
|
|
1048
1091
|
if (range)
|
|
1049
1092
|
editor.chain().focus().deleteRange(range).setHeading({ level: 4 }).run();
|
|
1050
1093
|
else
|
|
1051
1094
|
editor.chain().focus().setHeading({ level: 4 }).run();
|
|
1052
1095
|
}, is_active: () => editor?.isActive("heading", { level: 4 }) },
|
|
1053
|
-
{ caption: i18n({ en: "
|
|
1096
|
+
{ caption: i18n({ en: "Normal", es: "Normal", pl: "Normalny" }), description: "This is normal text style", tags: "paragraph,text,normal", icon: FaRemoveFormat, on_choice: (range) => {
|
|
1097
|
+
if (range)
|
|
1098
|
+
editor.chain().focus().deleteRange(range).setParagraph().run();
|
|
1099
|
+
else
|
|
1100
|
+
editor.chain().focus().setParagraph().run();
|
|
1101
|
+
}, is_active: () => editor?.isActive("paragraph") },
|
|
1102
|
+
{ caption: i18n({ en: "Code", es: "C\xF3digo", pl: "Kod" }), description: "Source code monospace text", tags: "code", icon: FaCode, on_choice: (range) => {
|
|
1054
1103
|
if (range)
|
|
1055
1104
|
editor.chain().focus().deleteRange(range).setCodeBlock().run();
|
|
1056
1105
|
else
|
|
1057
1106
|
editor.chain().focus().setCodeBlock().run();
|
|
1058
1107
|
}, is_active: () => editor?.isActive("CodeBlock") },
|
|
1059
1108
|
// { 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') } ,
|
|
1060
|
-
{ caption: i18n({ en: "Quote", es: "Cita", pl: "Cytat" }), description: "To quote someone", icon: FaQuoteRight, on_choice: (range) => {
|
|
1109
|
+
{ caption: i18n({ en: "Quote", es: "Cita", pl: "Cytat" }), description: "To quote someone", tags: "quote", icon: FaQuoteRight, on_choice: (range) => {
|
|
1061
1110
|
if (range)
|
|
1062
1111
|
editor.chain().focus().deleteRange(range).setAsQuote().run();
|
|
1063
1112
|
else
|
|
@@ -1065,7 +1114,7 @@ const paletteStylesCommands = () => [
|
|
|
1065
1114
|
}, is_active: () => editor?.isActive("QuoteBlock") },
|
|
1066
1115
|
// { 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') } ,
|
|
1067
1116
|
// { 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') },
|
|
1068
|
-
{ caption: i18n({ en: "BulletList", es: "Lista con vi\xF1etas", pl: "Lista punktowana" }), description: "Unordered list of items", icon: FaListUl, on_choice: (range) => {
|
|
1117
|
+
{ caption: i18n({ en: "BulletList", es: "Lista con vi\xF1etas", pl: "Lista punktowana" }), description: "Unordered list of items", tags: "bullet", icon: FaListUl, on_choice: (range) => {
|
|
1069
1118
|
if (range)
|
|
1070
1119
|
editor.chain().focus().deleteRange(range).toggleBulletList().run();
|
|
1071
1120
|
else
|
|
@@ -1079,13 +1128,13 @@ const paletteInsertCommands = () => [
|
|
|
1079
1128
|
if (onAddImage)
|
|
1080
1129
|
onAddImage(onAddedImageReady);
|
|
1081
1130
|
} },
|
|
1082
|
-
{ caption: i18n({ en: "Table", es: "Tabla", pl: "Tabela" }), description: "Table", icon: FaTable, on_choice: (range) => {
|
|
1131
|
+
{ caption: i18n({ en: "Table", es: "Tabla", pl: "Tabela" }), description: "Table", tags: "table", icon: FaTable, on_choice: (range) => {
|
|
1083
1132
|
if (range)
|
|
1084
1133
|
editor.chain().focus().deleteRange(range).insertTable().run();
|
|
1085
1134
|
else
|
|
1086
1135
|
editor.chain().focus().insertTable().run();
|
|
1087
1136
|
}, is_active: () => editor?.isActive("table") },
|
|
1088
|
-
{ caption: i18n({ en: "Horizontal rule", es: "Regla horizontal", pl: "Pozioma linia" }), description: "Add horizonal role", tags: "hr", icon: FaGripLines, on_choice: (range) => {
|
|
1137
|
+
{ caption: i18n({ en: "Horizontal rule", es: "Regla horizontal", pl: "Pozioma linia" }), description: "Add horizonal role", tags: "hr,line", icon: FaGripLines, on_choice: (range) => {
|
|
1089
1138
|
if (range)
|
|
1090
1139
|
editor.chain().focus().deleteRange(range).setHorizontalRule().run();
|
|
1091
1140
|
else
|
|
@@ -15,6 +15,7 @@ declare const __propDef: {
|
|
|
15
15
|
onBlurCb?: undefined;
|
|
16
16
|
onAddImage?: undefined;
|
|
17
17
|
onRemoveImage?: undefined;
|
|
18
|
+
onLinkClick?: Function | undefined;
|
|
18
19
|
c?: string | undefined;
|
|
19
20
|
pushChangesImmediately?: boolean | undefined;
|
|
20
21
|
chat?: object | undefined;
|
|
@@ -43,10 +44,12 @@ declare const __propDef: {
|
|
|
43
44
|
tbr: string;
|
|
44
45
|
}) | undefined;
|
|
45
46
|
scrollIntoView?: ((param: any) => void) | undefined;
|
|
47
|
+
CustomLink?: import("@tiptap/core").Mark<{}, any> | undefined;
|
|
46
48
|
save?: (() => Promise<void>) | undefined;
|
|
47
49
|
addTemporaryImage?: ((src: any) => void) | undefined;
|
|
48
50
|
replaceTemporaryImage?: ((temporarySrc: any, dataPath: any) => void) | undefined;
|
|
49
51
|
removeTemporaryImage?: ((temporarySrc: any) => void) | undefined;
|
|
52
|
+
addLink?: ((title: any, href: any) => void) | undefined;
|
|
50
53
|
getInnerHtml?: (() => any) | undefined;
|
|
51
54
|
setInnerHtml?: ((content: any) => void) | undefined;
|
|
52
55
|
setBold?: (() => void) | undefined;
|
|
@@ -116,10 +119,12 @@ export default class Editor extends SvelteComponentTyped<EditorProps, EditorEven
|
|
|
116
119
|
tbr: string;
|
|
117
120
|
};
|
|
118
121
|
get scrollIntoView(): (param: any) => void;
|
|
122
|
+
get CustomLink(): import("@tiptap/core").Mark<{}, any>;
|
|
119
123
|
get save(): () => Promise<void>;
|
|
120
124
|
get addTemporaryImage(): (src: any) => void;
|
|
121
125
|
get replaceTemporaryImage(): (temporarySrc: any, dataPath: any) => void;
|
|
122
126
|
get removeTemporaryImage(): (temporarySrc: any) => void;
|
|
127
|
+
get addLink(): (title: any, href: any) => void;
|
|
123
128
|
get getInnerHtml(): () => any;
|
|
124
129
|
get setInnerHtml(): (content: any) => void;
|
|
125
130
|
get setBold(): () => void;
|
|
@@ -57,10 +57,12 @@ export function show(x, y, up = false) {
|
|
|
57
57
|
visible = true;
|
|
58
58
|
dispatch("palette_shown");
|
|
59
59
|
closeButtonPos = "";
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
if (isDeviceSmallerThan("sm")) {
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
const rect = paletteElement.getBoundingClientRect();
|
|
63
|
+
closeButtonPos = `right: ${15}px; top: calc(${rect.y}px - 1.75rem)`;
|
|
64
|
+
}, 0);
|
|
65
|
+
}
|
|
64
66
|
}
|
|
65
67
|
export function show_fullscreen(_width_px, _height_px) {
|
|
66
68
|
isToolbox = false;
|
|
@@ -48,6 +48,8 @@ export declare class rList_definition {
|
|
|
48
48
|
onInsert: Function | undefined;
|
|
49
49
|
inserter_icon: boolean;
|
|
50
50
|
onOpen: Function | undefined;
|
|
51
|
+
downloadable: boolean;
|
|
52
|
+
downloadableFunc: Function | undefined;
|
|
51
53
|
properties: rList_property[];
|
|
52
54
|
tags: rList_property_tags | null;
|
|
53
55
|
}
|
package/components/list/List.js
CHANGED
|
@@ -16,6 +16,7 @@ import Summary from "./list.element.summary.svelte";
|
|
|
16
16
|
import Properties from "./list.element.props.svelte";
|
|
17
17
|
import { isDeviceSmallerThan } from "../../../utils";
|
|
18
18
|
import Icon from "../../icon.svelte";
|
|
19
|
+
import Spinner from "../../delayed.spinner.svelte";
|
|
19
20
|
import { rList_definition, rList_property_type } from "../List";
|
|
20
21
|
import { push, link } from "svelte-spa-router";
|
|
21
22
|
import { FaExternalLinkAlt, FaRegSquare, FaRegCheckSquare } from "svelte-icons/fa/";
|
|
@@ -44,7 +45,9 @@ $:
|
|
|
44
45
|
$:
|
|
45
46
|
focused_class = is_row_active ? "bg-stone-200 dark:bg-stone-700" : "";
|
|
46
47
|
$:
|
|
47
|
-
|
|
48
|
+
download = is_row_active && (definition.downloadable || (definition.downloadableFunc ? definition.downloadableFunc(item) : false));
|
|
49
|
+
$:
|
|
50
|
+
is_link_like = is_row_active && (!!definition.title_href || !!definition.title_href_func || download);
|
|
48
51
|
if (!typename) {
|
|
49
52
|
if (item.$type)
|
|
50
53
|
typename = item.$type;
|
|
@@ -272,6 +275,15 @@ function onToggleMultiSelect(e) {
|
|
|
272
275
|
if (e)
|
|
273
276
|
e.stopPropagation();
|
|
274
277
|
}
|
|
278
|
+
let isDownloading = false;
|
|
279
|
+
async function onDownloadFile(e) {
|
|
280
|
+
isDownloading = true;
|
|
281
|
+
e.preventDefault();
|
|
282
|
+
e.stopPropagation();
|
|
283
|
+
if (definition.onOpen)
|
|
284
|
+
await definition.onOpen(item);
|
|
285
|
+
isDownloading = false;
|
|
286
|
+
}
|
|
275
287
|
</script>
|
|
276
288
|
|
|
277
289
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
@@ -290,7 +302,11 @@ function onToggleMultiSelect(e) {
|
|
|
290
302
|
on:click={onToggleMultiSelect}/>
|
|
291
303
|
{/if}
|
|
292
304
|
|
|
293
|
-
|
|
305
|
+
{#if isDownloading}
|
|
306
|
+
<Spinner class="mt-0.5 ml-2 mr-1" size={5} delay={0}/>
|
|
307
|
+
{:else}
|
|
308
|
+
<slot name="left" element={item}/>
|
|
309
|
+
{/if}
|
|
294
310
|
|
|
295
311
|
<i class="hidden sm:w-1/2 sm:w-2/3 sm:w-1/3"></i> <!-- just to force tailwind classes including -->
|
|
296
312
|
|
|
@@ -315,10 +331,19 @@ function onToggleMultiSelect(e) {
|
|
|
315
331
|
onSoftEnter: (text) => {change_name(text); editProperty('Summary')}
|
|
316
332
|
}}
|
|
317
333
|
> <!--on:click|stopPropagation={followDefinedHRef}-->
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
334
|
+
{#if download}
|
|
335
|
+
<a class="sm:hover:cursor-pointer underline"
|
|
336
|
+
download
|
|
337
|
+
href={getHRef()}
|
|
338
|
+
on:click={onDownloadFile}>
|
|
339
|
+
{element_title}
|
|
340
|
+
</a>
|
|
341
|
+
{:else}
|
|
342
|
+
<a class="sm:hover:cursor-pointer underline"
|
|
343
|
+
href={getHRef()} use:link>
|
|
344
|
+
{element_title}
|
|
345
|
+
</a>
|
|
346
|
+
{/if}
|
|
322
347
|
</p>
|
|
323
348
|
{:else}
|
|
324
349
|
<p class=" text-base font-semibold
|
|
@@ -252,34 +252,40 @@ function reorderElements(items2, from = null) {
|
|
|
252
252
|
}
|
|
253
253
|
pushChanges();
|
|
254
254
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
};
|
|
260
|
-
if (after && orderAttrib) {
|
|
255
|
+
export function assignOrder(after) {
|
|
256
|
+
if (!orderAttrib)
|
|
257
|
+
return 0;
|
|
258
|
+
if (after) {
|
|
261
259
|
const leftElement = after;
|
|
262
260
|
const leftOrder = leftElement[orderAttrib];
|
|
263
261
|
const rightElement = getNext(items, leftElement);
|
|
264
262
|
if (rightElement) {
|
|
265
263
|
let rightOrder = rightElement[orderAttrib];
|
|
266
264
|
if (rightOrder - leftOrder >= 2)
|
|
267
|
-
|
|
265
|
+
return leftOrder + Math.floor((rightOrder - leftOrder) / 2);
|
|
268
266
|
else {
|
|
269
267
|
reorderElements(items, leftElement);
|
|
270
268
|
rightOrder = rightElement[orderAttrib];
|
|
271
|
-
|
|
269
|
+
return leftOrder + Math.floor((rightOrder - leftOrder) / 2);
|
|
272
270
|
}
|
|
273
271
|
} else
|
|
274
|
-
|
|
275
|
-
} else
|
|
272
|
+
return leftOrder + ORDER_STEP;
|
|
273
|
+
} else {
|
|
276
274
|
const lastElement = getLast(items);
|
|
277
275
|
if (lastElement) {
|
|
278
276
|
const lastOrder = lastElement[orderAttrib];
|
|
279
|
-
|
|
277
|
+
return lastOrder + ORDER_STEP;
|
|
280
278
|
} else
|
|
281
|
-
|
|
279
|
+
return MIN_ORDER;
|
|
282
280
|
}
|
|
281
|
+
}
|
|
282
|
+
async function insert(title2, summary, after) {
|
|
283
|
+
let newElement = {
|
|
284
|
+
[definition.title]: title2,
|
|
285
|
+
[definition.summary]: summary
|
|
286
|
+
};
|
|
287
|
+
if (orderAttrib)
|
|
288
|
+
newElement[orderAttrib] = assignOrder(after);
|
|
283
289
|
await definition.onInsert(newElement);
|
|
284
290
|
return;
|
|
285
291
|
let insertedElement = await definition.onInsert(newElement);
|
|
@@ -30,6 +30,7 @@ declare const __propDef: {
|
|
|
30
30
|
remove?: ((element: object) => void) | undefined;
|
|
31
31
|
edit?: ((element: object, property_name: string) => void) | undefined;
|
|
32
32
|
toggleMultiselection?: (() => void) | undefined;
|
|
33
|
+
assignOrder?: ((after: object | null) => number) | undefined;
|
|
33
34
|
};
|
|
34
35
|
events: {
|
|
35
36
|
[evt: string]: CustomEvent<any>;
|
|
@@ -60,5 +61,6 @@ export default class List extends SvelteComponentTyped<ListProps, ListEvents, Li
|
|
|
60
61
|
get remove(): (element: object) => void;
|
|
61
62
|
get edit(): (element: object, property_name: string) => void;
|
|
62
63
|
get toggleMultiselection(): () => void;
|
|
64
|
+
get assignOrder(): (after: object | null) => number;
|
|
63
65
|
}
|
|
64
66
|
export {};
|
|
@@ -6,6 +6,8 @@ export let onOpen = void 0;
|
|
|
6
6
|
export let readonly = false;
|
|
7
7
|
export let href = void 0;
|
|
8
8
|
export let hrefFunc = void 0;
|
|
9
|
+
export let downloadable = false;
|
|
10
|
+
export let downloadableFunc = void 0;
|
|
9
11
|
let definition = getContext("rList-definition");
|
|
10
12
|
definition.title = a;
|
|
11
13
|
definition.title_editable = editable;
|
|
@@ -14,4 +16,6 @@ definition.title_readonly = readonly;
|
|
|
14
16
|
definition.title_href = href;
|
|
15
17
|
definition.title_href_func = hrefFunc;
|
|
16
18
|
definition.onOpen = onOpen;
|
|
19
|
+
definition.downloadable = downloadable;
|
|
20
|
+
definition.downloadableFunc = downloadableFunc;
|
|
17
21
|
</script>
|