fuma 1.0.16 → 1.0.18

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.
Files changed (128) hide show
  1. package/dist/private/Meta.svelte +27 -32
  2. package/dist/private/Meta.svelte.d.ts +0 -1
  3. package/dist/private/api.d.ts +1 -1
  4. package/dist/ui/badge/Badge.svelte +3 -4
  5. package/dist/ui/button/ButtonCopy.svelte +31 -37
  6. package/dist/ui/button/ButtonDelete.svelte +21 -23
  7. package/dist/ui/button/ButtonDelete.svelte.d.ts +0 -1
  8. package/dist/ui/card/Card.svelte +10 -13
  9. package/dist/ui/card/Card.svelte.d.ts +0 -1
  10. package/dist/ui/card/CardBasic.svelte +4 -5
  11. package/dist/ui/card/CardBasic.svelte.d.ts +0 -1
  12. package/dist/ui/card/CardCollapse.svelte +31 -35
  13. package/dist/ui/card/CardCollapse.svelte.d.ts +0 -1
  14. package/dist/ui/card/CardFullScreen.svelte +6 -8
  15. package/dist/ui/card/CardFullScreen.svelte.d.ts +0 -3
  16. package/dist/ui/card/CardLink.svelte +4 -5
  17. package/dist/ui/card/CardLink.svelte.d.ts +0 -1
  18. package/dist/ui/dialog/Dialog.svelte +34 -41
  19. package/dist/ui/dialog/Dialog.svelte.d.ts +0 -1
  20. package/dist/ui/dialog/DialogConfirm.svelte +4 -6
  21. package/dist/ui/dialog/DialogConfirm.svelte.d.ts +0 -1
  22. package/dist/ui/drawer/Drawer.svelte +37 -46
  23. package/dist/ui/drawer/Drawer.svelte.d.ts +0 -16
  24. package/dist/ui/form/Form.svelte +82 -100
  25. package/dist/ui/form/Form.svelte.d.ts +0 -1
  26. package/dist/ui/form/FormInput.svelte +6 -12
  27. package/dist/ui/form/FormInput.svelte.d.ts +0 -18
  28. package/dist/ui/form/FormSection.svelte +16 -23
  29. package/dist/ui/form/formInput.d.ts +0 -1
  30. package/dist/ui/icon/Icon.svelte +32 -35
  31. package/dist/ui/input/FormControl.svelte +32 -38
  32. package/dist/ui/input/FormControl.svelte.d.ts +0 -3
  33. package/dist/ui/input/InputBoolean.svelte +8 -13
  34. package/dist/ui/input/InputBoolean.svelte.d.ts +0 -3
  35. package/dist/ui/input/InputCheckboxs.svelte +20 -22
  36. package/dist/ui/input/InputCheckboxs.svelte.d.ts +0 -3
  37. package/dist/ui/input/InputCheckboxsMenu.svelte +35 -51
  38. package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +0 -3
  39. package/dist/ui/input/InputCheckboxsTree.svelte +6 -9
  40. package/dist/ui/input/InputCheckboxsTreeNodes.svelte +27 -35
  41. package/dist/ui/input/InputCombo.svelte +34 -43
  42. package/dist/ui/input/InputCombo.svelte.d.ts +0 -3
  43. package/dist/ui/input/InputDate.svelte +17 -22
  44. package/dist/ui/input/InputDateTime.svelte +18 -23
  45. package/dist/ui/input/InputImage.svelte +45 -52
  46. package/dist/ui/input/InputImage.svelte.d.ts +0 -1
  47. package/dist/ui/input/InputImagePreview.svelte +20 -24
  48. package/dist/ui/input/InputNumber.svelte +5 -10
  49. package/dist/ui/input/InputOptionInParam.svelte +10 -12
  50. package/dist/ui/input/InputOptions.svelte +34 -40
  51. package/dist/ui/input/InputPassword.svelte +5 -7
  52. package/dist/ui/input/InputPassword.svelte.d.ts +0 -3
  53. package/dist/ui/input/InputRadio.svelte +32 -36
  54. package/dist/ui/input/InputRadio.svelte.d.ts +0 -3
  55. package/dist/ui/input/InputRelation.svelte +67 -83
  56. package/dist/ui/input/InputRelation.svelte.d.ts +0 -1
  57. package/dist/ui/input/InputRelations.svelte +79 -92
  58. package/dist/ui/input/InputSearch.svelte +10 -13
  59. package/dist/ui/input/InputSelect.svelte +28 -39
  60. package/dist/ui/input/InputText.svelte +7 -8
  61. package/dist/ui/input/InputTextarea.svelte +6 -6
  62. package/dist/ui/input/InputTime.svelte +23 -29
  63. package/dist/ui/input/RelationAfter.svelte +9 -13
  64. package/dist/ui/input/SelectorList.svelte +12 -16
  65. package/dist/ui/input/SelectorList.svelte.d.ts +0 -4
  66. package/dist/ui/input/textRich/InputTextRich.svelte +50 -57
  67. package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +0 -3
  68. package/dist/ui/input/textRich/SuggesionList.svelte +9 -13
  69. package/dist/ui/input/textRich/ToolMark.svelte +9 -12
  70. package/dist/ui/input/textRich/ToolMarkColor.svelte +11 -15
  71. package/dist/ui/input/textRich/ToolMarkLink.svelte +38 -46
  72. package/dist/ui/input/textRich/ToolMenu.svelte +19 -34
  73. package/dist/ui/input/textRich/ToolMenuAlign.svelte +9 -13
  74. package/dist/ui/input/textRich/ToolMenuInsert.svelte +7 -12
  75. package/dist/ui/input/textRich/ToolMenuNode.svelte +10 -14
  76. package/dist/ui/input/textRich/ToolsBar.svelte +11 -15
  77. package/dist/ui/login/Login.svelte +30 -36
  78. package/dist/ui/menu/ContextMenu.svelte +31 -37
  79. package/dist/ui/menu/ContextMenu.svelte.d.ts +0 -1
  80. package/dist/ui/menu/DropDown.svelte +83 -92
  81. package/dist/ui/menu/DropDown.svelte.d.ts +0 -1
  82. package/dist/ui/menu/DropDownMenu.svelte +18 -25
  83. package/dist/ui/menu/DropDownMenu.svelte.d.ts +0 -1
  84. package/dist/ui/mode/ToggleMode.svelte +14 -15
  85. package/dist/ui/mode/ToggleMode.svelte.d.ts +1 -6
  86. package/dist/ui/pagination/Pagination.svelte +8 -9
  87. package/dist/ui/placeholder/Placeholder.svelte +3 -4
  88. package/dist/ui/placeholder/Placeholder.svelte.d.ts +0 -1
  89. package/dist/ui/placeholder/PlaceholderImage.svelte +4 -6
  90. package/dist/ui/placeholder/PlaceholderImage.svelte.d.ts +0 -1
  91. package/dist/ui/range/RangePicker.svelte +62 -75
  92. package/dist/ui/range/RangePicker.svelte.d.ts +2 -2
  93. package/dist/ui/range/RangePickerButton.svelte +35 -43
  94. package/dist/ui/slot/Slot.svelte +25 -42
  95. package/dist/ui/slot/Span.svelte +1 -2
  96. package/dist/ui/table/Table.svelte +28 -35
  97. package/dist/ui/table/TableBody.svelte +12 -18
  98. package/dist/ui/table/TableCell.svelte +10 -13
  99. package/dist/ui/table/TableFieldsEdition.svelte +52 -58
  100. package/dist/ui/table/TableHead.svelte +21 -20
  101. package/dist/ui/table/TableViewSelect.svelte +37 -50
  102. package/dist/ui/table/cell/TableCellArray.svelte +3 -5
  103. package/dist/ui/table/cell/TableCellBoolean.svelte +3 -4
  104. package/dist/ui/table/cell/TableCellNumber.svelte +1 -2
  105. package/dist/ui/table/cell/TableCellString.svelte +2 -5
  106. package/dist/ui/table/cell/TableCellString.svelte.d.ts +20 -10
  107. package/dist/ui/table/field.d.ts +25 -17
  108. package/dist/ui/table/field.js +1 -1
  109. package/dist/ui/table/head/OrderButtons.svelte +37 -0
  110. package/dist/ui/table/head/OrderButtons.svelte.d.ts +20 -0
  111. package/dist/ui/table/head/TableHeadBoolean.svelte +3 -6
  112. package/dist/ui/table/head/TableHeadBoolean.svelte.d.ts +20 -10
  113. package/dist/ui/table/head/TableHeadDate.svelte +113 -61
  114. package/dist/ui/table/head/TableHeadDate.svelte.d.ts +20 -10
  115. package/dist/ui/table/head/TableHeadDefault.svelte +2 -5
  116. package/dist/ui/table/head/TableHeadDefault.svelte.d.ts +20 -10
  117. package/dist/ui/table/head/TableHeadNumber.svelte +76 -67
  118. package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +20 -10
  119. package/dist/ui/table/head/TableHeadSelect.svelte +41 -47
  120. package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +20 -10
  121. package/dist/ui/table/head/TableHeadString.svelte +8 -14
  122. package/dist/ui/table/head/TableHeadString.svelte.d.ts +20 -10
  123. package/dist/ui/table/head/index.d.ts +2 -2
  124. package/dist/ui/tabs/Tabs.svelte +5 -8
  125. package/dist/ui/tabs/TabsIcon.svelte +28 -31
  126. package/dist/validation/zod.d.ts +12 -0
  127. package/dist/validation/zod.js +4 -2
  128. package/package.json +1 -1
@@ -1,11 +1,10 @@
1
- <script lang="ts">
2
- import { FormControl, bindValueWithParams, type InputProps } from './index.js'
3
-
4
- type $$Props = InputProps
5
- $: ({ input, value: _value, classWrapper, bindWithParams, ...props } = $$props as $$Props)
6
- $: ({ class: inputClass, ...inputProps } = input || {})
7
- export let value = _value
8
- export let inputElement: HTMLInputElement | undefined = undefined
1
+ <script>import { FormControl, bindValueWithParams } from "./index.js";
2
+ $:
3
+ ({ input, value: _value, classWrapper, bindWithParams, ...props } = $$props);
4
+ $:
5
+ ({ class: inputClass, ...inputProps } = input || {});
6
+ export let value = _value;
7
+ export let inputElement = void 0;
9
8
  </script>
10
9
 
11
10
  <FormControl {...props} enhanceDisabled={props.enhanceDisabled || bindWithParams} let:key>
@@ -1,9 +1,9 @@
1
- <script lang="ts">
2
- import { FormControl, type TextareaProps } from './index.js'
3
- type $$Props = TextareaProps
4
- $: ({ textarea, value: _value, ...props } = $$props as $$Props)
5
- $: ({ class: inputClass, ...inputProps } = textarea || {})
6
- export let value = _value
1
+ <script>import { FormControl } from "./index.js";
2
+ $:
3
+ ({ textarea, value: _value, ...props } = $$props);
4
+ $:
5
+ ({ class: inputClass, ...inputProps } = textarea || {});
6
+ export let value = _value;
7
7
  </script>
8
8
 
9
9
  <FormControl {...props} let:key>
@@ -1,32 +1,26 @@
1
- <script lang="ts">
2
- import { createEventDispatcher } from 'svelte'
3
- import type { HTMLInputAttributes, FormEventHandler } from 'svelte/elements'
4
- import { FormControl, type InputProps } from './index.js'
5
- import dayjs from 'dayjs'
6
- type $$Props = InputProps<Date>
7
-
8
- export let value: Date | null | undefined = undefined
9
- export let input: HTMLInputAttributes = {}
10
-
11
- $: ({ class: inputClass = '', ...inputProps } = input)
12
-
13
- const dispatch = createEventDispatcher<{ input: Date | null }>()
14
-
15
- const onInput: FormEventHandler<HTMLInputElement> = ({ currentTarget }) => {
16
- value = getDateTime(currentTarget.value)
17
- dispatch('input', value)
18
- }
19
-
20
- function getDateTime(v: string | null | undefined): Date | null | undefined {
21
- if (!v) return value
22
- const date = new Date(value || 0)
23
- const dateString = [
24
- date.getFullYear().toString(),
25
- (date.getMonth() + 1).toString().padStart(2, '0'),
26
- date.getDate().toString().padStart(2, '0')
27
- ].join('-')
28
- return new Date(`${dateString}T${v}`)
29
- }
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import { FormControl } from "./index.js";
3
+ import dayjs from "dayjs";
4
+ export let value = void 0;
5
+ export let input = {};
6
+ $:
7
+ ({ class: inputClass = "", ...inputProps } = input);
8
+ const dispatch = createEventDispatcher();
9
+ const onInput = ({ currentTarget }) => {
10
+ value = getDateTime(currentTarget.value);
11
+ dispatch("input", value);
12
+ };
13
+ function getDateTime(v) {
14
+ if (!v)
15
+ return value;
16
+ const date = new Date(value || 0);
17
+ const dateString = [
18
+ date.getFullYear().toString(),
19
+ (date.getMonth() + 1).toString().padStart(2, "0"),
20
+ date.getDate().toString().padStart(2, "0")
21
+ ].join("-");
22
+ return /* @__PURE__ */ new Date(`${dateString}T${v}`);
23
+ }
30
24
  </script>
31
25
 
32
26
  <FormControl {...$$restProps} let:key>
@@ -1,16 +1,12 @@
1
- <script lang="ts">
2
- import { fade } from 'svelte/transition'
3
- import { createEventDispatcher } from 'svelte'
4
- import { mdiLoading, mdiPlus } from '@mdi/js'
5
-
6
- import Icon from '../icon/Icon.svelte'
7
-
8
- export let isLoading: boolean
9
- export let createUrl = ''
10
- export let createTitle = ''
11
- export let createIcon = mdiPlus
12
-
13
- const dispatch = createEventDispatcher<{ unselect: void; create: void }>()
1
+ <script>import { fade } from "svelte/transition";
2
+ import { createEventDispatcher } from "svelte";
3
+ import { mdiLoading, mdiPlus } from "@mdi/js";
4
+ import Icon from "../icon/Icon.svelte";
5
+ export let isLoading;
6
+ export let createUrl = "";
7
+ export let createTitle = "";
8
+ export let createIcon = mdiPlus;
9
+ const dispatch = createEventDispatcher();
14
10
  </script>
15
11
 
16
12
  {#if isLoading}
@@ -1,19 +1,15 @@
1
- <script lang="ts" generics="Item extends {id: string}">
2
- import { createEventDispatcher } from 'svelte'
3
- import { selector } from '../../action/selector.js'
4
-
5
- let klass = ''
6
- export { klass as class }
7
-
8
- export let items: Item[]
9
- export let isError = false
10
- export let isLoading = false
11
- export let focusIndex = 0
12
- export let trigger: HTMLElement | undefined = undefined
13
- export let keyDownEvent: KeyboardEvent | undefined = undefined
14
- export let keyDownPreventDefault = true
15
-
16
- const dispatch = createEventDispatcher<{ select: number }>()
1
+ <script generics="Item extends {id: string}">import { createEventDispatcher } from "svelte";
2
+ import { selector } from "../../action/selector.js";
3
+ let klass = "";
4
+ export { klass as class };
5
+ export let items;
6
+ export let isError = false;
7
+ export let isLoading = false;
8
+ export let focusIndex = 0;
9
+ export let trigger = void 0;
10
+ export let keyDownEvent = void 0;
11
+ export let keyDownPreventDefault = true;
12
+ const dispatch = createEventDispatcher();
17
13
  </script>
18
14
 
19
15
  <ul
@@ -11,10 +11,6 @@ declare class __sveltets_Render<Item extends {
11
11
  trigger?: HTMLElement | undefined;
12
12
  keyDownEvent?: KeyboardEvent | undefined;
13
13
  keyDownPreventDefault?: boolean | undefined;
14
- children?: import("svelte").Snippet<[{
15
- item: Item;
16
- index: any;
17
- }]> | undefined;
18
14
  };
19
15
  events(): {
20
16
  select: CustomEvent<number>;
@@ -1,60 +1,53 @@
1
- <script lang="ts">
2
- import { createEventDispatcher, onMount, type ComponentProps } from 'svelte'
3
- import { Editor } from '@tiptap/core'
4
- import debounce from 'debounce'
5
-
6
- import { jsonParse } from '../../../utils/jsonParse.js'
7
- import { FormControl } from '../index.js'
8
- import ToolsBar from './ToolsBar.svelte'
9
- import { extensions } from './extensions.js'
10
-
11
- type $$Props = ComponentProps<FormControl> & { value?: string; classToolbar?: string }
12
-
13
- export let value = ''
14
- export let classToolbar = ''
15
-
16
- let element: HTMLDivElement
17
- let editor: Editor | null = null
18
-
19
- const dispatch = createEventDispatcher<{ change: void }>()
20
-
21
- onMount(() => {
22
- initEditor()
23
- return () => {
24
- if (editor) editor.destroy()
25
- }
26
- })
27
-
28
- export function setImage(image: { src: string; alt: string }) {
29
- if (!editor) return false
30
- return editor.commands.setImage(image)
31
- }
32
-
33
- function initEditor() {
34
- const valueAsHtml = !value.startsWith('{') && value !== 'null'
35
- editor = new Editor({
36
- element,
37
- content: valueAsHtml ? value : jsonParse(value, undefined),
38
- editorProps: {
39
- attributes: {
40
- class: 'prose max-w-[210mm] mx-auto focus:outline-none'
41
- }
42
- },
43
- extensions,
44
- onTransaction() {
45
- editor = editor
46
- updateValue()
47
- }
48
- })
49
- }
50
-
51
- const updateValue = debounce(() => {
52
- if (!editor) return
53
- const newValue = JSON.stringify(editor.getJSON())
54
- if (newValue === value) return
55
- value = newValue
56
- dispatch('change')
57
- }, 120)
1
+ <script>import { createEventDispatcher, onMount } from "svelte";
2
+ import { Editor } from "@tiptap/core";
3
+ import debounce from "debounce";
4
+ import { jsonParse } from "../../../utils/jsonParse.js";
5
+ import { FormControl } from "../index.js";
6
+ import ToolsBar from "./ToolsBar.svelte";
7
+ import { extensions } from "./extensions.js";
8
+ export let value = "";
9
+ export let classToolbar = "";
10
+ let element;
11
+ let editor = null;
12
+ const dispatch = createEventDispatcher();
13
+ onMount(() => {
14
+ initEditor();
15
+ return () => {
16
+ if (editor)
17
+ editor.destroy();
18
+ };
19
+ });
20
+ export function setImage(image) {
21
+ if (!editor)
22
+ return false;
23
+ return editor.commands.setImage(image);
24
+ }
25
+ function initEditor() {
26
+ const valueAsHtml = !value.startsWith("{") && value !== "null";
27
+ editor = new Editor({
28
+ element,
29
+ content: valueAsHtml ? value : jsonParse(value, void 0),
30
+ editorProps: {
31
+ attributes: {
32
+ class: "prose max-w-[210mm] mx-auto focus:outline-none"
33
+ }
34
+ },
35
+ extensions,
36
+ onTransaction() {
37
+ editor = editor;
38
+ updateValue();
39
+ }
40
+ });
41
+ }
42
+ const updateValue = debounce(() => {
43
+ if (!editor)
44
+ return;
45
+ const newValue = JSON.stringify(editor.getJSON());
46
+ if (newValue === value)
47
+ return;
48
+ value = newValue;
49
+ dispatch("change");
50
+ }, 120);
58
51
  </script>
59
52
 
60
53
  <FormControl {...$$restProps} let:key>
@@ -16,9 +16,6 @@ declare const __propDef: {
16
16
  prefixFor?: string | number | undefined;
17
17
  enhanceDisabled?: boolean | undefined;
18
18
  labelPosition?: ("top" | "left" | "right") | undefined;
19
- children?: import("svelte").Snippet<[{
20
- key: string;
21
- }]> | undefined;
22
19
  } & {
23
20
  value?: string | undefined;
24
21
  classToolbar?: string | undefined;
@@ -1,16 +1,12 @@
1
- <script lang="ts">
2
- import type { SuggestionProps } from '@tiptap/suggestion'
3
- import { SelectorList } from '../index.js'
4
- import type { SuggestionItem } from './suggestion.js'
5
-
6
- export let props: SuggestionProps<SuggestionItem>
7
- export let keyDownEvent: KeyboardEvent | undefined = undefined
8
-
9
- function handleSelect(index: number) {
10
- const item = props.items[index]
11
- if (!item) return
12
- props.command(item)
13
- }
1
+ <script>import { SelectorList } from "../index.js";
2
+ export let props;
3
+ export let keyDownEvent = void 0;
4
+ function handleSelect(index) {
5
+ const item = props.items[index];
6
+ if (!item)
7
+ return;
8
+ props.command(item);
9
+ }
14
10
  </script>
15
11
 
16
12
  <SelectorList
@@ -1,15 +1,12 @@
1
- <script lang="ts">
2
- import type { Editor } from '@tiptap/core'
3
- import { Icon } from '../../icon/index.js'
4
- import { tip } from '../../../action/tip.js'
5
-
6
- export let editor: Editor
7
- export let key: string
8
- export let label: string
9
- export let icon: string
10
- export let action: () => void
11
-
12
- $: isActive = editor.isActive(key)
1
+ <script>import { Icon } from "../../icon/index.js";
2
+ import { tip } from "../../../action/tip.js";
3
+ export let editor;
4
+ export let key;
5
+ export let label;
6
+ export let icon;
7
+ export let action;
8
+ $:
9
+ isActive = editor.isActive(key);
13
10
  </script>
14
11
 
15
12
  <button
@@ -1,18 +1,14 @@
1
- <script lang="ts">
2
- import { Icon } from '../../icon/index.js'
3
- import { tip } from '../../../action/tip.js'
4
-
5
- export let icon: string
6
- export let label: string
7
- export let color: string
8
- export let setColor: (color: string) => void
9
-
10
- let inputColor: HTMLInputElement
11
-
12
- function handleClick() {
13
- inputColor.click()
14
- setColor(color)
15
- }
1
+ <script>import { Icon } from "../../icon/index.js";
2
+ import { tip } from "../../../action/tip.js";
3
+ export let icon;
4
+ export let label;
5
+ export let color;
6
+ export let setColor;
7
+ let inputColor;
8
+ function handleClick() {
9
+ inputColor.click();
10
+ setColor(color);
11
+ }
16
12
  </script>
17
13
 
18
14
  <div class="flex align-bottom">
@@ -1,49 +1,41 @@
1
- <script lang="ts">
2
- import type { Editor } from '@tiptap/core'
3
- import { mdiLinkVariant } from '@mdi/js'
4
-
5
- import { Dialog } from '../../dialog/index.js'
6
- import { InputText } from '../index.js'
7
- import { z } from '../../../validation/zod.js'
8
- import ToolMark from './ToolMark.svelte'
9
-
10
- export let editor: Editor
11
- let dialogLink: HTMLDialogElement
12
- let linkHref = ''
13
- let linkError = ''
14
-
15
- async function handleNewLink() {
16
- if (!linkHref) {
17
- linkError = 'URL requis'
18
- return
19
- }
20
-
21
- const isEmail = z.string().email().safeParse(linkHref)
22
- if (isEmail.success) linkHref = 'mailto:' + linkHref
23
- else if (!linkHref.match(/^http(s)?:\/\//)) {
24
- linkHref = 'https://' + linkHref
25
- }
26
-
27
- const isUrl = z.string().url().safeParse(linkHref)
28
- if (!isUrl.success) {
29
- linkError = 'URL invalide'
30
- return
31
- }
32
-
33
- editor.chain().focus().setLink({ href: linkHref }).run()
34
- dialogLink.close()
35
- }
36
-
37
- function handleRemoveLink() {
38
- editor.chain().focus().unsetLink().run()
39
- dialogLink.close()
40
- }
41
-
42
- function handleKeyDown(event: KeyboardEvent) {
43
- if (event.key !== 'Enter') return
44
- event.preventDefault()
45
- handleNewLink()
46
- }
1
+ <script>import { mdiLinkVariant } from "@mdi/js";
2
+ import { Dialog } from "../../dialog/index.js";
3
+ import { InputText } from "../index.js";
4
+ import { z } from "../../../validation/zod.js";
5
+ import ToolMark from "./ToolMark.svelte";
6
+ export let editor;
7
+ let dialogLink;
8
+ let linkHref = "";
9
+ let linkError = "";
10
+ async function handleNewLink() {
11
+ if (!linkHref) {
12
+ linkError = "URL requis";
13
+ return;
14
+ }
15
+ const isEmail = z.string().email().safeParse(linkHref);
16
+ if (isEmail.success)
17
+ linkHref = "mailto:" + linkHref;
18
+ else if (!linkHref.match(/^http(s)?:\/\//)) {
19
+ linkHref = "https://" + linkHref;
20
+ }
21
+ const isUrl = z.string().url().safeParse(linkHref);
22
+ if (!isUrl.success) {
23
+ linkError = "URL invalide";
24
+ return;
25
+ }
26
+ editor.chain().focus().setLink({ href: linkHref }).run();
27
+ dialogLink.close();
28
+ }
29
+ function handleRemoveLink() {
30
+ editor.chain().focus().unsetLink().run();
31
+ dialogLink.close();
32
+ }
33
+ function handleKeyDown(event) {
34
+ if (event.key !== "Enter")
35
+ return;
36
+ event.preventDefault();
37
+ handleNewLink();
38
+ }
47
39
  </script>
48
40
 
49
41
  <ToolMark
@@ -1,37 +1,22 @@
1
- <script lang="ts">
2
- import type { Editor } from '@tiptap/core'
3
- import { mdiChevronDown } from '@mdi/js'
4
-
5
- import { Icon } from '../../icon/index.js'
6
- import { DropDown } from '../../menu/index.js'
7
-
8
- type Tool = {
9
- key?: string
10
- attributes?: {}
11
- label: string
12
- icon: string
13
- action: () => unknown
14
- newSection?: true
15
- disable?: boolean
16
- }
17
-
18
- export let editor: Editor
19
- export let tools: Tool[]
20
- export let hideLabel = false
21
-
22
- let dropdown: DropDown
23
-
24
- function handleClick(tool: Tool) {
25
- tool.action()
26
- dropdown.hide()
27
- }
28
-
29
- $: toolSelected =
30
- tools.find((t) => {
31
- if (t.key) return editor.isActive(t.key, t.attributes)
32
- if (t.attributes) return editor.isActive(t.attributes)
33
- return false
34
- }) || tools[0]
1
+ <script>import { mdiChevronDown } from "@mdi/js";
2
+ import { Icon } from "../../icon/index.js";
3
+ import { DropDown } from "../../menu/index.js";
4
+ export let editor;
5
+ export let tools;
6
+ export let hideLabel = false;
7
+ let dropdown;
8
+ function handleClick(tool) {
9
+ tool.action();
10
+ dropdown.hide();
11
+ }
12
+ $:
13
+ toolSelected = tools.find((t) => {
14
+ if (t.key)
15
+ return editor.isActive(t.key, t.attributes);
16
+ if (t.attributes)
17
+ return editor.isActive(t.attributes);
18
+ return false;
19
+ }) || tools[0];
35
20
  </script>
36
21
 
37
22
  <DropDown hideOnBlur bind:this={dropdown}>
@@ -1,16 +1,12 @@
1
- <script lang="ts">
2
- import type { Editor } from '@tiptap/core'
3
- import {
4
- mdiAlignHorizontalLeft,
5
- mdiAlignHorizontalCenter,
6
- mdiAlignHorizontalRight,
7
- mdiFormatIndentIncrease,
8
- mdiFormatIndentDecrease,
9
- } from '@mdi/js'
10
-
11
- import ToolMenu from './ToolMenu.svelte'
12
-
13
- export let editor: Editor
1
+ <script>import {
2
+ mdiAlignHorizontalLeft,
3
+ mdiAlignHorizontalCenter,
4
+ mdiAlignHorizontalRight,
5
+ mdiFormatIndentIncrease,
6
+ mdiFormatIndentDecrease
7
+ } from "@mdi/js";
8
+ import ToolMenu from "./ToolMenu.svelte";
9
+ export let editor;
14
10
  </script>
15
11
 
16
12
  <ToolMenu
@@ -1,15 +1,10 @@
1
- <script lang="ts">
2
- import { createEventDispatcher } from 'svelte'
3
- import type { Editor } from '@tiptap/core'
4
- import { mdiPlus, mdiMinus, mdiImageOutline, mdiYoutube, mdiAt } from '@mdi/js'
5
-
6
- import { Icon } from '../../icon/index.js'
7
- import ToolMenu from './ToolMenu.svelte'
8
- import { suggestionItems } from './suggestion.js'
9
-
10
- export let editor: Editor
11
-
12
- const dispatch = createEventDispatcher<{ insertMedia: void }>()
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import { mdiPlus, mdiMinus, mdiImageOutline, mdiYoutube, mdiAt } from "@mdi/js";
3
+ import { Icon } from "../../icon/index.js";
4
+ import ToolMenu from "./ToolMenu.svelte";
5
+ import { suggestionItems } from "./suggestion.js";
6
+ export let editor;
7
+ const dispatch = createEventDispatcher();
13
8
  </script>
14
9
 
15
10
  <ToolMenu
@@ -1,17 +1,13 @@
1
- <script lang="ts">
2
- import type { Editor } from '@tiptap/core'
3
- import {
4
- mdiText,
5
- mdiFormatListBulleted,
6
- mdiFormatListNumbered,
7
- mdiFormatHeader1,
8
- mdiFormatHeader3,
9
- mdiFormatHeader2,
10
- } from '@mdi/js'
11
-
12
- import ToolMenu from './ToolMenu.svelte'
13
-
14
- export let editor: Editor
1
+ <script>import {
2
+ mdiText,
3
+ mdiFormatListBulleted,
4
+ mdiFormatListNumbered,
5
+ mdiFormatHeader1,
6
+ mdiFormatHeader3,
7
+ mdiFormatHeader2
8
+ } from "@mdi/js";
9
+ import ToolMenu from "./ToolMenu.svelte";
10
+ export let editor;
15
11
  </script>
16
12
 
17
13
  <ToolMenu
@@ -1,18 +1,14 @@
1
- <script lang="ts">
2
- import type { Editor } from '@tiptap/core'
3
- import { mdiFormatBold, mdiFormatColorFill, mdiFormatColorText, mdiFormatItalic } from '@mdi/js'
4
- import { toast } from 'svelte-sonner'
5
-
6
- import ToolMenuNode from './ToolMenuNode.svelte'
7
- import ToolMark from './ToolMark.svelte'
8
- import ToolMarkColor from './ToolMarkColor.svelte'
9
- import ToolMarkLink from './ToolMarkLink.svelte'
10
- import ToolMenuAlign from './ToolMenuAlign.svelte'
11
- import ToolMenuInsert from './ToolMenuInsert.svelte'
12
-
13
- export let editor: Editor
14
- let klass = ''
15
- export { klass as class }
1
+ <script>import { mdiFormatBold, mdiFormatColorFill, mdiFormatColorText, mdiFormatItalic } from "@mdi/js";
2
+ import { toast } from "svelte-sonner";
3
+ import ToolMenuNode from "./ToolMenuNode.svelte";
4
+ import ToolMark from "./ToolMark.svelte";
5
+ import ToolMarkColor from "./ToolMarkColor.svelte";
6
+ import ToolMarkLink from "./ToolMarkLink.svelte";
7
+ import ToolMenuAlign from "./ToolMenuAlign.svelte";
8
+ import ToolMenuInsert from "./ToolMenuInsert.svelte";
9
+ export let editor;
10
+ let klass = "";
11
+ export { klass as class };
16
12
  </script>
17
13
 
18
14
  <div