fuma 0.0.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.
Files changed (242) hide show
  1. package/README.md +58 -0
  2. package/dist/Meta.svelte +55 -0
  3. package/dist/Meta.svelte.d.ts +20 -0
  4. package/dist/action/index.d.ts +4 -0
  5. package/dist/action/index.js +4 -0
  6. package/dist/action/list/handlers.d.ts +16 -0
  7. package/dist/action/list/handlers.js +92 -0
  8. package/dist/action/list/index.css +40 -0
  9. package/dist/action/list/index.d.ts +23 -0
  10. package/dist/action/list/index.js +44 -0
  11. package/dist/action/list/store.d.ts +3 -0
  12. package/dist/action/list/store.js +1 -0
  13. package/dist/action/list/style.d.ts +2 -0
  14. package/dist/action/list/style.js +14 -0
  15. package/dist/action/list/trigger.d.ts +12 -0
  16. package/dist/action/list/trigger.js +124 -0
  17. package/dist/action/list/utils.d.ts +18 -0
  18. package/dist/action/list/utils.js +68 -0
  19. package/dist/action/portal.d.ts +3 -0
  20. package/dist/action/portal.js +9 -0
  21. package/dist/action/selector.d.ts +15 -0
  22. package/dist/action/selector.js +71 -0
  23. package/dist/action/tip.d.ts +6 -0
  24. package/dist/action/tip.js +12 -0
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +3 -0
  27. package/dist/server/index.d.ts +5 -0
  28. package/dist/server/index.js +5 -0
  29. package/dist/server/json.d.ts +1 -0
  30. package/dist/server/json.js +16 -0
  31. package/dist/server/parseFormData.d.ts +20 -0
  32. package/dist/server/parseFormData.js +63 -0
  33. package/dist/server/parseQuery.d.ts +11 -0
  34. package/dist/server/parseQuery.js +15 -0
  35. package/dist/server/sse.d.ts +6 -0
  36. package/dist/server/sse.js +35 -0
  37. package/dist/server/try.d.ts +6 -0
  38. package/dist/server/try.js +31 -0
  39. package/dist/store/index.d.ts +2 -0
  40. package/dist/store/index.js +2 -0
  41. package/dist/store/isSmallScreen.d.ts +2 -0
  42. package/dist/store/isSmallScreen.js +14 -0
  43. package/dist/store/param.d.ts +24 -0
  44. package/dist/store/param.js +61 -0
  45. package/dist/store/session.d.ts +2 -0
  46. package/dist/store/session.js +13 -0
  47. package/dist/ui/ButtonCopy.svelte +18 -0
  48. package/dist/ui/ButtonCopy.svelte.d.ts +18 -0
  49. package/dist/ui/ButtonDelete.svelte +43 -0
  50. package/dist/ui/ButtonDelete.svelte.d.ts +22 -0
  51. package/dist/ui/Dialog.svelte +58 -0
  52. package/dist/ui/Dialog.svelte.d.ts +25 -0
  53. package/dist/ui/DialogConfirm.svelte +22 -0
  54. package/dist/ui/DialogConfirm.svelte.d.ts +21 -0
  55. package/dist/ui/Icon.svelte +46 -0
  56. package/dist/ui/Icon.svelte.d.ts +24 -0
  57. package/dist/ui/Pagination.svelte +28 -0
  58. package/dist/ui/Pagination.svelte.d.ts +16 -0
  59. package/dist/ui/Placeholder.svelte +11 -0
  60. package/dist/ui/Placeholder.svelte.d.ts +19 -0
  61. package/dist/ui/PlaceholderImage.svelte +14 -0
  62. package/dist/ui/PlaceholderImage.svelte.d.ts +19 -0
  63. package/dist/ui/card/Card.svelte +38 -0
  64. package/dist/ui/card/Card.svelte.d.ts +26 -0
  65. package/dist/ui/card/CardBasic.svelte +14 -0
  66. package/dist/ui/card/CardBasic.svelte.d.ts +20 -0
  67. package/dist/ui/card/CardCollapse.svelte +61 -0
  68. package/dist/ui/card/CardCollapse.svelte.d.ts +22 -0
  69. package/dist/ui/card/CardFullScreen.svelte +28 -0
  70. package/dist/ui/card/CardFullScreen.svelte.d.ts +23 -0
  71. package/dist/ui/card/CardLink.svelte +21 -0
  72. package/dist/ui/card/CardLink.svelte.d.ts +20 -0
  73. package/dist/ui/card/index.d.ts +5 -0
  74. package/dist/ui/card/index.js +5 -0
  75. package/dist/ui/index.d.ts +14 -0
  76. package/dist/ui/index.js +14 -0
  77. package/dist/ui/input/FormControl.svelte +53 -0
  78. package/dist/ui/input/FormControl.svelte.d.ts +30 -0
  79. package/dist/ui/input/InputBoolean.svelte +29 -0
  80. package/dist/ui/input/InputBoolean.svelte.d.ts +21 -0
  81. package/dist/ui/input/InputCheckboxs.svelte +68 -0
  82. package/dist/ui/input/InputCheckboxs.svelte.d.ts +41 -0
  83. package/dist/ui/input/InputCheckboxsMenu.svelte +93 -0
  84. package/dist/ui/input/InputCheckboxsMenu.svelte.d.ts +43 -0
  85. package/dist/ui/input/InputCheckboxsTree.svelte +15 -0
  86. package/dist/ui/input/InputCheckboxsTree.svelte.d.ts +21 -0
  87. package/dist/ui/input/InputCheckboxsTreeNodes.svelte +60 -0
  88. package/dist/ui/input/InputCheckboxsTreeNodes.svelte.d.ts +23 -0
  89. package/dist/ui/input/InputDate.svelte +26 -0
  90. package/dist/ui/input/InputDate.svelte.d.ts +19 -0
  91. package/dist/ui/input/InputDatetime.svelte +21 -0
  92. package/dist/ui/input/InputDatetime.svelte.d.ts +19 -0
  93. package/dist/ui/input/InputImage.svelte +107 -0
  94. package/dist/ui/input/InputImage.svelte.d.ts +35 -0
  95. package/dist/ui/input/InputImagePreview.svelte +56 -0
  96. package/dist/ui/input/InputImagePreview.svelte.d.ts +23 -0
  97. package/dist/ui/input/InputNumber.svelte +22 -0
  98. package/dist/ui/input/InputNumber.svelte.d.ts +23 -0
  99. package/dist/ui/input/InputOptionInParam.svelte +34 -0
  100. package/dist/ui/input/InputOptionInParam.svelte.d.ts +20 -0
  101. package/dist/ui/input/InputOptions.svelte +79 -0
  102. package/dist/ui/input/InputOptions.svelte.d.ts +17 -0
  103. package/dist/ui/input/InputPassword.svelte +21 -0
  104. package/dist/ui/input/InputPassword.svelte.d.ts +36 -0
  105. package/dist/ui/input/InputRadio.svelte +79 -0
  106. package/dist/ui/input/InputRadio.svelte.d.ts +40 -0
  107. package/dist/ui/input/InputRelation.svelte +114 -0
  108. package/dist/ui/input/InputRelation.svelte.d.ts +52 -0
  109. package/dist/ui/input/InputRelations.svelte +138 -0
  110. package/dist/ui/input/InputRelations.svelte.d.ts +49 -0
  111. package/dist/ui/input/InputSearch.svelte +43 -0
  112. package/dist/ui/input/InputSearch.svelte.d.ts +23 -0
  113. package/dist/ui/input/InputSelect.svelte +59 -0
  114. package/dist/ui/input/InputSelect.svelte.d.ts +26 -0
  115. package/dist/ui/input/InputText.svelte +32 -0
  116. package/dist/ui/input/InputText.svelte.d.ts +31 -0
  117. package/dist/ui/input/InputTextarea.svelte +20 -0
  118. package/dist/ui/input/InputTextarea.svelte.d.ts +23 -0
  119. package/dist/ui/input/InputTime.svelte +19 -0
  120. package/dist/ui/input/InputTime.svelte.d.ts +19 -0
  121. package/dist/ui/input/RelationAfter.svelte +42 -0
  122. package/dist/ui/input/RelationAfter.svelte.d.ts +22 -0
  123. package/dist/ui/input/SelectorList.svelte +46 -0
  124. package/dist/ui/input/SelectorList.svelte.d.ts +40 -0
  125. package/dist/ui/input/action.d.ts +13 -0
  126. package/dist/ui/input/action.js +56 -0
  127. package/dist/ui/input/index.d.ts +25 -0
  128. package/dist/ui/input/index.js +25 -0
  129. package/dist/ui/input/textRich/InputTextRich.svelte +58 -0
  130. package/dist/ui/input/textRich/InputTextRich.svelte.d.ts +20 -0
  131. package/dist/ui/input/textRich/SuggesionList.svelte +21 -0
  132. package/dist/ui/input/textRich/SuggesionList.svelte.d.ts +19 -0
  133. package/dist/ui/input/textRich/ToolMark.svelte +19 -0
  134. package/dist/ui/input/textRich/ToolMark.svelte.d.ts +21 -0
  135. package/dist/ui/input/textRich/ToolMarkColor.svelte +32 -0
  136. package/dist/ui/input/textRich/ToolMarkColor.svelte.d.ts +19 -0
  137. package/dist/ui/input/textRich/ToolMarkLink.svelte +63 -0
  138. package/dist/ui/input/textRich/ToolMarkLink.svelte.d.ts +17 -0
  139. package/dist/ui/input/textRich/ToolMenu.svelte +50 -0
  140. package/dist/ui/input/textRich/ToolMenu.svelte.d.ts +29 -0
  141. package/dist/ui/input/textRich/ToolMenuAlign.svelte +46 -0
  142. package/dist/ui/input/textRich/ToolMenuAlign.svelte.d.ts +17 -0
  143. package/dist/ui/input/textRich/ToolMenuInsert.svelte +49 -0
  144. package/dist/ui/input/textRich/ToolMenuInsert.svelte.d.ts +19 -0
  145. package/dist/ui/input/textRich/ToolMenuNode.svelte +56 -0
  146. package/dist/ui/input/textRich/ToolMenuNode.svelte.d.ts +17 -0
  147. package/dist/ui/input/textRich/ToolsBar.svelte +60 -0
  148. package/dist/ui/input/textRich/ToolsBar.svelte.d.ts +18 -0
  149. package/dist/ui/input/textRich/extensions.d.ts +2 -0
  150. package/dist/ui/input/textRich/extensions.js +62 -0
  151. package/dist/ui/input/textRich/indent.d.ts +13 -0
  152. package/dist/ui/input/textRich/indent.js +112 -0
  153. package/dist/ui/input/textRich/suggestion.d.ts +9 -0
  154. package/dist/ui/input/textRich/suggestion.js +56 -0
  155. package/dist/ui/input/types.d.ts +15 -0
  156. package/dist/ui/input/types.js +1 -0
  157. package/dist/ui/menu/ContextMenu.svelte +47 -0
  158. package/dist/ui/menu/ContextMenu.svelte.d.ts +28 -0
  159. package/dist/ui/menu/DropDown.svelte +110 -0
  160. package/dist/ui/menu/DropDown.svelte.d.ts +38 -0
  161. package/dist/ui/menu/dropdown.css +33 -0
  162. package/dist/ui/menu/index.d.ts +2 -0
  163. package/dist/ui/menu/index.js +2 -0
  164. package/dist/ui/period/PeriodPicker.svelte +53 -0
  165. package/dist/ui/period/PeriodPicker.svelte.d.ts +22 -0
  166. package/dist/ui/period/PeriodPickerButton.svelte +73 -0
  167. package/dist/ui/period/PeriodPickerButton.svelte.d.ts +14 -0
  168. package/dist/ui/period/index.d.ts +6 -0
  169. package/dist/ui/period/index.js +2 -0
  170. package/dist/ui/table/Table.svelte +42 -0
  171. package/dist/ui/table/Table.svelte.d.ts +39 -0
  172. package/dist/ui/table/TableBody.svelte +29 -0
  173. package/dist/ui/table/TableBody.svelte.d.ts +33 -0
  174. package/dist/ui/table/TableCell.svelte +27 -0
  175. package/dist/ui/table/TableCell.svelte.d.ts +28 -0
  176. package/dist/ui/table/TableFieldsEdition.svelte +122 -0
  177. package/dist/ui/table/TableFieldsEdition.svelte.d.ts +31 -0
  178. package/dist/ui/table/TableHead.svelte +31 -0
  179. package/dist/ui/table/TableHead.svelte.d.ts +29 -0
  180. package/dist/ui/table/TableViewSelect.svelte +127 -0
  181. package/dist/ui/table/TableViewSelect.svelte.d.ts +24 -0
  182. package/dist/ui/table/cell/TableCellArray.svelte +10 -0
  183. package/dist/ui/table/cell/TableCellArray.svelte.d.ts +16 -0
  184. package/dist/ui/table/cell/TableCellBoolean.svelte +12 -0
  185. package/dist/ui/table/cell/TableCellBoolean.svelte.d.ts +16 -0
  186. package/dist/ui/table/cell/TableCellNumber.svelte +6 -0
  187. package/dist/ui/table/cell/TableCellNumber.svelte.d.ts +16 -0
  188. package/dist/ui/table/cell/TableCellString.svelte +7 -0
  189. package/dist/ui/table/cell/TableCellString.svelte.d.ts +18 -0
  190. package/dist/ui/table/cell/index.d.ts +4 -0
  191. package/dist/ui/table/cell/index.js +4 -0
  192. package/dist/ui/table/context.d.ts +14 -0
  193. package/dist/ui/table/context.js +10 -0
  194. package/dist/ui/table/field.d.ts +79 -0
  195. package/dist/ui/table/field.js +29 -0
  196. package/dist/ui/table/head/TableHeadBoolean.svelte +12 -0
  197. package/dist/ui/table/head/TableHeadBoolean.svelte.d.ts +17 -0
  198. package/dist/ui/table/head/TableHeadDate.svelte +100 -0
  199. package/dist/ui/table/head/TableHeadDate.svelte.d.ts +17 -0
  200. package/dist/ui/table/head/TableHeadDefault.svelte +7 -0
  201. package/dist/ui/table/head/TableHeadDefault.svelte.d.ts +17 -0
  202. package/dist/ui/table/head/TableHeadNumber.svelte +80 -0
  203. package/dist/ui/table/head/TableHeadNumber.svelte.d.ts +17 -0
  204. package/dist/ui/table/head/TableHeadSelect.svelte +75 -0
  205. package/dist/ui/table/head/TableHeadSelect.svelte.d.ts +20 -0
  206. package/dist/ui/table/head/TableHeadString.svelte +35 -0
  207. package/dist/ui/table/head/TableHeadString.svelte.d.ts +17 -0
  208. package/dist/ui/table/head/index.d.ts +19 -0
  209. package/dist/ui/table/head/index.js +22 -0
  210. package/dist/ui/table/index.d.ts +10 -0
  211. package/dist/ui/table/index.js +10 -0
  212. package/dist/ui/table/server.d.ts +1 -0
  213. package/dist/ui/table/server.js +32 -0
  214. package/dist/ui/tabs/Tabs.svelte +28 -0
  215. package/dist/ui/tabs/Tabs.svelte.d.ts +18 -0
  216. package/dist/ui/tabs/TabsIcon.svelte +56 -0
  217. package/dist/ui/tabs/TabsIcon.svelte.d.ts +20 -0
  218. package/dist/ui/tabs/index.d.ts +8 -0
  219. package/dist/ui/tabs/index.js +2 -0
  220. package/dist/utils/avatar.d.ts +1 -0
  221. package/dist/utils/avatar.js +5 -0
  222. package/dist/utils/component.d.ts +7 -0
  223. package/dist/utils/component.js +3 -0
  224. package/dist/utils/formatRange.d.ts +8 -0
  225. package/dist/utils/formatRange.js +25 -0
  226. package/dist/utils/index.d.ts +7 -0
  227. package/dist/utils/index.js +7 -0
  228. package/dist/utils/jsonParse.d.ts +1 -0
  229. package/dist/utils/jsonParse.js +10 -0
  230. package/dist/utils/normalizePath.d.ts +1 -0
  231. package/dist/utils/normalizePath.js +11 -0
  232. package/dist/utils/options.d.ts +7 -0
  233. package/dist/utils/options.js +20 -0
  234. package/dist/utils/tippy.d.ts +5 -0
  235. package/dist/utils/tippy.js +4 -0
  236. package/dist/validation/form.d.ts +31 -0
  237. package/dist/validation/form.js +94 -0
  238. package/dist/validation/index.d.ts +2 -0
  239. package/dist/validation/index.js +2 -0
  240. package/dist/validation/zod.d.ts +338 -0
  241. package/dist/validation/zod.js +100 -0
  242. package/package.json +86 -0
@@ -0,0 +1,56 @@
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;
11
+ </script>
12
+
13
+ <ToolMenu
14
+ {editor}
15
+ tools={[
16
+ {
17
+ key: 'paragraph',
18
+ label: 'Texte',
19
+ icon: mdiText,
20
+ action: () => editor.commands.setParagraph(),
21
+ },
22
+ {
23
+ key: 'heading',
24
+ attributes: { level: 1 },
25
+ label: 'Titre 1',
26
+ icon: mdiFormatHeader1,
27
+ action: () => editor.commands.setHeading({ level: 1 }),
28
+ },
29
+ {
30
+ key: 'heading',
31
+ attributes: { level: 2 },
32
+ label: 'Titre 2',
33
+ icon: mdiFormatHeader2,
34
+ action: () => editor.commands.setHeading({ level: 2 }),
35
+ },
36
+ {
37
+ key: 'heading',
38
+ attributes: { level: 3 },
39
+ label: 'Titre 3',
40
+ icon: mdiFormatHeader3,
41
+ action: () => editor.commands.setHeading({ level: 3 }),
42
+ },
43
+ {
44
+ key: 'orderedList',
45
+ label: 'Liste numéroter',
46
+ icon: mdiFormatListNumbered,
47
+ action: () => editor.commands.toggleOrderedList(),
48
+ },
49
+ {
50
+ key: 'bulletList',
51
+ label: 'Liste à puces',
52
+ icon: mdiFormatListBulleted,
53
+ action: () => editor.commands.toggleBulletList(),
54
+ },
55
+ ]}
56
+ />
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Editor } from '@tiptap/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ editor: Editor;
6
+ };
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ export type ToolMenuNodeProps = typeof __propDef.props;
13
+ export type ToolMenuNodeEvents = typeof __propDef.events;
14
+ export type ToolMenuNodeSlots = typeof __propDef.slots;
15
+ export default class ToolMenuNode extends SvelteComponent<ToolMenuNodeProps, ToolMenuNodeEvents, ToolMenuNodeSlots> {
16
+ }
17
+ export {};
@@ -0,0 +1,60 @@
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 };
12
+ </script>
13
+
14
+ <div
15
+ class="
16
+ sticky top-0 z-10 overflow-y-visible rounded-t-xl border-b bg-base-100
17
+ {klass}
18
+ "
19
+ >
20
+ <div class="flex overflow-x-auto p-2">
21
+ <ToolMenuNode {editor} />
22
+ <ToolMenuAlign {editor} />
23
+ <div class="mx-1 my-auto h-6 border border-y-0 border-l-0" />
24
+
25
+ <ToolMark
26
+ {editor}
27
+ key="bold"
28
+ label="Gras (Ctrl+B)"
29
+ icon={mdiFormatBold}
30
+ action={() => editor.chain().focus().toggleBold().run()}
31
+ />
32
+ <ToolMark
33
+ {editor}
34
+ key="italic"
35
+ label="Italic (Ctrl+C)"
36
+ icon={mdiFormatItalic}
37
+ action={() => editor.chain().focus().toggleItalic().run()}
38
+ />
39
+ <ToolMarkLink {editor} />
40
+ <ToolMarkColor
41
+ icon={mdiFormatColorText}
42
+ label="Couleur du text"
43
+ color={editor.getAttributes('textStyle').color || '#000000'}
44
+ setColor={editor.commands.setColor}
45
+ />
46
+ <ToolMarkColor
47
+ icon={mdiFormatColorFill}
48
+ label="Couleur du fond"
49
+ color={editor.getAttributes('highlight').color || '#e51f68'}
50
+ setColor={(color) => editor.commands.setHighlight({ color })}
51
+ />
52
+
53
+ <div class="mx-1 my-auto h-6 border border-y-0 border-l-0" />
54
+
55
+ <ToolMenuInsert
56
+ {editor}
57
+ on:insertMedia={() => toast.warning('TODO: import SelectMedia like benev.io')}
58
+ />
59
+ </div>
60
+ </div>
@@ -0,0 +1,18 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { Editor } from '@tiptap/core';
3
+ declare const __propDef: {
4
+ props: {
5
+ editor: Editor;
6
+ class?: string | undefined;
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
13
+ export type ToolsBarProps = typeof __propDef.props;
14
+ export type ToolsBarEvents = typeof __propDef.events;
15
+ export type ToolsBarSlots = typeof __propDef.slots;
16
+ export default class ToolsBar extends SvelteComponent<ToolsBarProps, ToolsBarEvents, ToolsBarSlots> {
17
+ }
18
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Extensions } from '@tiptap/core';
2
+ export declare const extensions: Extensions;
@@ -0,0 +1,62 @@
1
+ import StarterKit from '@tiptap/starter-kit';
2
+ import Link from '@tiptap/extension-link';
3
+ import TextStyle from '@tiptap/extension-text-style';
4
+ import Color from '@tiptap/extension-color';
5
+ import Highlight from '@tiptap/extension-highlight';
6
+ import TextAlign from '@tiptap/extension-text-align';
7
+ import Placeholder from '@tiptap/extension-placeholder';
8
+ import Image from '@tiptap/extension-image';
9
+ import Youtube from '@tiptap/extension-youtube';
10
+ import Mention from '@tiptap/extension-mention';
11
+ import { Indent } from './indent.js';
12
+ import { suggestion } from './suggestion.js';
13
+ export const extensions = [
14
+ StarterKit.configure({
15
+ heading: { levels: [1, 2, 3] }
16
+ }),
17
+ Link.configure({
18
+ protocols: ['tel', 'mailto']
19
+ }),
20
+ TextStyle,
21
+ Color,
22
+ Highlight.configure({
23
+ multicolor: true
24
+ }),
25
+ TextAlign.configure({
26
+ types: ['heading', 'paragraph', 'image'],
27
+ alignments: ['left', 'center', 'right']
28
+ }),
29
+ Placeholder.configure({
30
+ placeholder: 'Rédige ta page ici ...'
31
+ }),
32
+ Indent,
33
+ Image.configure({
34
+ HTMLAttributes: {
35
+ class: 'mx-auto'
36
+ }
37
+ }),
38
+ Youtube.configure({
39
+ // @ts-ignore
40
+ width: '100%',
41
+ height: 360,
42
+ nocookie: true,
43
+ origin: 'benev.io',
44
+ modestBranding: true,
45
+ HTMLAttributes: {
46
+ class: 'mx-auto rounded'
47
+ }
48
+ }),
49
+ Mention.configure({
50
+ suggestion,
51
+ renderHTML({ node }) {
52
+ return [
53
+ 'span',
54
+ {
55
+ class: 'suggestion',
56
+ 'data-key': node.attrs.id
57
+ },
58
+ node.attrs.label ?? node.attrs.id
59
+ ];
60
+ }
61
+ })
62
+ ];
@@ -0,0 +1,13 @@
1
+ import { Extension } from '@tiptap/core';
2
+ declare module '@tiptap/core' {
3
+ interface Commands<ReturnType> {
4
+ indent: {
5
+ indent: () => ReturnType;
6
+ outdent: () => ReturnType;
7
+ };
8
+ }
9
+ }
10
+ export declare const Indent: Extension<{
11
+ types: string[];
12
+ defaultIndentLevel: number;
13
+ }, any>;
@@ -0,0 +1,112 @@
1
+ import { Extension } from '@tiptap/core';
2
+ import { TextSelection, AllSelection, Transaction } from '@tiptap/pm/state';
3
+ const clamp = (val, min, max) => {
4
+ if (val < min)
5
+ return min;
6
+ if (val > max)
7
+ return max;
8
+ return val;
9
+ };
10
+ const INDENT_OPTIONS = {
11
+ min: 0,
12
+ max: 150,
13
+ more: 10,
14
+ less: -10,
15
+ };
16
+ const nodeNameList = ['bullet_list', 'order_list', 'todo_list'];
17
+ const nodeNameText = ['paragraph', 'heading'];
18
+ function setNodeIndentMarkup(tr, pos, delta) {
19
+ if (!tr.doc)
20
+ return tr;
21
+ const node = tr.doc.nodeAt(pos);
22
+ if (!node)
23
+ return tr;
24
+ const minIndent = INDENT_OPTIONS.min;
25
+ const maxIndent = INDENT_OPTIONS.max;
26
+ const indent = clamp((node.attrs.indent || 0) + delta, minIndent, maxIndent);
27
+ if (indent === node.attrs.indent)
28
+ return tr;
29
+ const nodeAttrs = {
30
+ ...node.attrs,
31
+ indent,
32
+ };
33
+ return tr.setNodeMarkup(pos, node.type, nodeAttrs, node.marks);
34
+ }
35
+ const updateIndentLevel = (tr, delta) => {
36
+ const { doc, selection } = tr;
37
+ if (!doc || !selection)
38
+ return tr;
39
+ if (!(selection instanceof TextSelection || selection instanceof AllSelection)) {
40
+ return tr;
41
+ }
42
+ const { from, to } = selection;
43
+ doc.nodesBetween(from, to, (node, pos) => {
44
+ const nodeName = node.type.name;
45
+ if (nodeNameList.includes(nodeName))
46
+ return false;
47
+ if (nodeNameText.includes(nodeName)) {
48
+ tr = setNodeIndentMarkup(tr, pos, delta);
49
+ return false;
50
+ }
51
+ return true;
52
+ });
53
+ return tr;
54
+ };
55
+ export const Indent = Extension.create({
56
+ name: 'indent',
57
+ addOptions: () => ({
58
+ types: ['heading', 'paragraph'],
59
+ defaultIndentLevel: 0,
60
+ }),
61
+ addGlobalAttributes() {
62
+ return [
63
+ {
64
+ types: this.options.types,
65
+ attributes: {
66
+ indent: {
67
+ default: this.options.defaultIndentLevel,
68
+ renderHTML: (attributes) => {
69
+ if (attributes.indent === 0)
70
+ return {};
71
+ return {
72
+ style: `margin-left: ${attributes.indent}mm;`,
73
+ };
74
+ },
75
+ parseHTML: (element) => parseInt(element.style.marginLeft) || this.options.defaultIndentLevel,
76
+ },
77
+ },
78
+ },
79
+ ];
80
+ },
81
+ addCommands() {
82
+ const createCommand = (transaction) => ({ tr, dispatch, editor, state, chain }) => {
83
+ tr = tr.setSelection(state.selection);
84
+ tr = transaction(tr);
85
+ if (tr.docChanged) {
86
+ if (dispatch)
87
+ dispatch(tr);
88
+ return true;
89
+ }
90
+ editor.chain().focus().run();
91
+ return false;
92
+ };
93
+ return {
94
+ indent: () => createCommand((tr) => updateIndentLevel(tr, INDENT_OPTIONS.more)),
95
+ outdent: () => createCommand((tr) => updateIndentLevel(tr, INDENT_OPTIONS.less)),
96
+ };
97
+ },
98
+ addKeyboardShortcuts() {
99
+ const createShortcuts = (fn) => () => {
100
+ if (this.editor.isActive('bulletList'))
101
+ return false;
102
+ if (this.editor.isActive('orderedList'))
103
+ return false;
104
+ return fn();
105
+ };
106
+ return {
107
+ Tab: createShortcuts(() => this.editor.commands.indent()),
108
+ 'Ctrl-q': createShortcuts(() => this.editor.commands.indent()),
109
+ 'Shift-Tab': createShortcuts(() => this.editor.commands.outdent()),
110
+ };
111
+ },
112
+ });
@@ -0,0 +1,9 @@
1
+ /// <reference types="svelte" />
2
+ import type { SuggestionOptions } from '@tiptap/suggestion';
3
+ import '$lib/ui/menu/dropdown.css';
4
+ export type SuggestionItem = {
5
+ id: string;
6
+ label: string;
7
+ };
8
+ export declare let suggestionItems: import("svelte/store").Writable<SuggestionItem[]>;
9
+ export declare const suggestion: Omit<SuggestionOptions<SuggestionItem>, 'editor'>;
@@ -0,0 +1,56 @@
1
+ import { writable, get } from 'svelte/store';
2
+ import { tippy } from '../../../utils/tippy.js';
3
+ import SuggesionList from './SuggesionList.svelte';
4
+ import '$lib/ui/menu/dropdown.css';
5
+ export let suggestionItems = writable([]);
6
+ export const suggestion = {
7
+ items: ({ query }) => {
8
+ const items = get(suggestionItems);
9
+ return items.filter((item) => item.label.toLowerCase().includes(query.toLowerCase()));
10
+ },
11
+ render: () => {
12
+ let popup;
13
+ let target = document.createElement('div');
14
+ let component;
15
+ return {
16
+ onStart: (props) => {
17
+ component = new SuggesionList({ target, props: { props } });
18
+ if (!props.clientRect)
19
+ return;
20
+ popup = tippy(document.body, {
21
+ getReferenceClientRect: props.clientRect,
22
+ appendTo: () => document.body,
23
+ content: target,
24
+ showOnCreate: true,
25
+ interactive: true,
26
+ trigger: 'manual',
27
+ placement: 'bottom-start',
28
+ theme: 'dropdown-border'
29
+ });
30
+ },
31
+ onUpdate(props) {
32
+ component.$set({ props });
33
+ if (!props.clientRect)
34
+ return;
35
+ popup.setProps({
36
+ getReferenceClientRect: props.clientRect
37
+ });
38
+ },
39
+ onKeyDown(props) {
40
+ if (props.event.key === 'Escape') {
41
+ popup.hide();
42
+ return true;
43
+ }
44
+ if (['Enter', 'ArrowUp', 'ArrowDown'].includes(props.event.key)) {
45
+ component.$set({ keyDownEvent: props.event });
46
+ return true;
47
+ }
48
+ return false;
49
+ },
50
+ onExit() {
51
+ popup?.destroy();
52
+ component?.$destroy();
53
+ }
54
+ };
55
+ }
56
+ };
@@ -0,0 +1,15 @@
1
+ import type { ComponentProps } from 'svelte';
2
+ import type { HTMLInputAttributes, HTMLTextareaAttributes } from 'svelte/elements';
3
+ import { default as FormControl } from './FormControl.svelte';
4
+ export type InputProps<T = string> = ComponentProps<FormControl> & {
5
+ input?: HTMLInputAttributes;
6
+ inputElement?: HTMLInputElement;
7
+ wrapperClass?: string;
8
+ value?: T;
9
+ bindWithParams?: boolean;
10
+ };
11
+ export type TextareaProps = ComponentProps<FormControl> & {
12
+ textarea?: HTMLTextareaAttributes;
13
+ value?: string;
14
+ bindWithParams?: boolean;
15
+ };
@@ -0,0 +1 @@
1
+ import { default as FormControl } from './FormControl.svelte';
@@ -0,0 +1,47 @@
1
+ <script>import { createEventDispatcher } from "svelte";
2
+ import { Dialog, DropDown } from "../../index.js";
3
+ import { isSmallScreen } from "../../store/index.js";
4
+ export let tippyProps = {};
5
+ let klass = "";
6
+ export { klass as class };
7
+ const dispatch = createEventDispatcher();
8
+ let dropdown;
9
+ let dialog;
10
+ export function show(event) {
11
+ if ($isSmallScreen) {
12
+ dialog?.showModal();
13
+ } else {
14
+ const target = event.target;
15
+ if (!target || !(target instanceof HTMLElement))
16
+ return;
17
+ dropdown?.setTippyProps({
18
+ getReferenceClientRect: () => new DOMRect(event.clientX, event.clientY)
19
+ });
20
+ dropdown?.show();
21
+ }
22
+ dispatch("show");
23
+ }
24
+ export function hide() {
25
+ if ($isSmallScreen)
26
+ dialog?.close();
27
+ else
28
+ dropdown?.hide();
29
+ dispatch("hide");
30
+ }
31
+ </script>
32
+
33
+ {#if $isSmallScreen}
34
+ <Dialog bind:dialog class={klass}>
35
+ <div slot="header" class="contents">
36
+ <slot name="header" />
37
+ </div>
38
+ <slot />
39
+ </Dialog>
40
+ {:else}
41
+ <DropDown class={klass} bind:this={dropdown} tippyProps={{ offset: [0, -5], ...tippyProps }}>
42
+ <div class="flex flex-col gap-2 p-1">
43
+ <slot name="header" />
44
+ <slot />
45
+ </div>
46
+ </DropDown>
47
+ {/if}
@@ -0,0 +1,28 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { TippyProps } from '../../utils/tippy.js';
3
+ declare const __propDef: {
4
+ props: {
5
+ tippyProps?: Partial<TippyProps> | undefined;
6
+ class?: string | undefined;
7
+ show?: ((event: MouseEvent) => void) | undefined;
8
+ hide?: (() => void) | undefined;
9
+ };
10
+ events: {
11
+ show: CustomEvent<void>;
12
+ hide: CustomEvent<void>;
13
+ } & {
14
+ [evt: string]: CustomEvent<any>;
15
+ };
16
+ slots: {
17
+ header: {};
18
+ default: {};
19
+ };
20
+ };
21
+ export type ContextMenuProps = typeof __propDef.props;
22
+ export type ContextMenuEvents = typeof __propDef.events;
23
+ export type ContextMenuSlots = typeof __propDef.slots;
24
+ export default class ContextMenu extends SvelteComponent<ContextMenuProps, ContextMenuEvents, ContextMenuSlots> {
25
+ get show(): (event: MouseEvent) => void;
26
+ get hide(): () => void;
27
+ }
28
+ export {};
@@ -0,0 +1,110 @@
1
+ <script context="module">import { createSingleton } from "../../utils/tippy.js";
2
+ const sigleton = browser ? createSingleton([], {
3
+ theme: "dropdown",
4
+ arrow: false,
5
+ moveTransition: "transform 0.1s ease-out",
6
+ interactive: true,
7
+ interactiveDebounce: 50
8
+ }) : null;
9
+ const tips = [];
10
+ </script>
11
+
12
+ <script>import { tippy } from "../../utils/tippy.js";
13
+ import { onMount } from "svelte";
14
+ import { browser } from "$app/environment";
15
+ import { beforeNavigate } from "$app/navigation";
16
+ import "./dropdown.css";
17
+ export let tippyProps = {};
18
+ let klass = "";
19
+ export { klass as class };
20
+ export let wrapperClass = "";
21
+ export let classActivator = "";
22
+ export let useSingleton = false;
23
+ export let autofocus = false;
24
+ export let hideOnBlur = false;
25
+ export let hideOnNav = true;
26
+ export let tip = void 0;
27
+ export let disable = false;
28
+ export let content = void 0;
29
+ let activator;
30
+ beforeNavigate(() => hideOnNav && hide());
31
+ onMount(() => {
32
+ if (disable)
33
+ return;
34
+ const triggerTarget = activator.querySelector("button, input") || activator;
35
+ const focusables = Array.from(
36
+ content.querySelectorAll(
37
+ "a[href], button, input, textarea, select, details, [tabindex]"
38
+ )
39
+ );
40
+ tip = tippy(activator, {
41
+ content,
42
+ placement: "bottom-start",
43
+ theme: "dropdown",
44
+ arrow: false,
45
+ triggerTarget,
46
+ trigger: "click focus",
47
+ interactive: true,
48
+ interactiveDebounce: 50,
49
+ appendTo: "parent",
50
+ onShown() {
51
+ if (autofocus)
52
+ focusables[0]?.select();
53
+ },
54
+ ...tippyProps
55
+ });
56
+ if (useSingleton && tip) {
57
+ tips.push(tip);
58
+ sigleton?.setInstances(tips);
59
+ }
60
+ const lastFocusable = focusables.at(-1);
61
+ if (hideOnBlur)
62
+ lastFocusable?.addEventListener("blur", hide);
63
+ return () => {
64
+ if (hideOnBlur)
65
+ lastFocusable?.removeEventListener("blur", hide);
66
+ if (useSingleton && tip) {
67
+ tips.splice(tips.indexOf(tip), 1);
68
+ tip.destroy();
69
+ }
70
+ };
71
+ });
72
+ export function hide() {
73
+ if (!tip)
74
+ return;
75
+ if (useSingleton)
76
+ sigleton?.hide();
77
+ else
78
+ tip.hide();
79
+ }
80
+ export function show() {
81
+ tip?.show();
82
+ }
83
+ export function setTippyProps(props) {
84
+ tip?.setProps(props);
85
+ }
86
+ </script>
87
+
88
+ {#if !disable}
89
+ <div class={wrapperClass}>
90
+ <div class={classActivator} bind:this={activator}>
91
+ <slot name="activator" />
92
+ </div>
93
+
94
+ <div class="hidden">
95
+ <div
96
+ class="{klass} max-h-80 overflow-auto rounded-lg border bg-base-100 p-1 shadow-lg"
97
+ bind:this={content}
98
+ >
99
+ <slot />
100
+ </div>
101
+ </div>
102
+ </div>
103
+ {:else}
104
+ <div class={wrapperClass}>
105
+ <slot name="activator" />
106
+ <div class="{klass} mt-2">
107
+ <slot />
108
+ </div>
109
+ </div>
110
+ {/if}
@@ -0,0 +1,38 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { type TippyInstance } from '../../utils/tippy.js';
3
+ import { type TippyProps } from '../../utils/tippy.js';
4
+ import './dropdown.css';
5
+ declare const __propDef: {
6
+ props: {
7
+ tippyProps?: Partial<TippyProps> | undefined;
8
+ class?: string | undefined;
9
+ wrapperClass?: string | undefined;
10
+ classActivator?: string | undefined;
11
+ useSingleton?: boolean | undefined;
12
+ autofocus?: boolean | undefined;
13
+ hideOnBlur?: boolean | undefined;
14
+ hideOnNav?: boolean | undefined;
15
+ tip?: TippyInstance | undefined;
16
+ disable?: boolean | undefined;
17
+ content?: HTMLDivElement | undefined;
18
+ hide?: (() => void) | undefined;
19
+ show?: (() => void) | undefined;
20
+ setTippyProps?: ((props: Partial<TippyProps>) => void) | undefined;
21
+ };
22
+ events: {
23
+ [evt: string]: CustomEvent<any>;
24
+ };
25
+ slots: {
26
+ activator: {};
27
+ default: {};
28
+ };
29
+ };
30
+ export type DropDownProps = typeof __propDef.props;
31
+ export type DropDownEvents = typeof __propDef.events;
32
+ export type DropDownSlots = typeof __propDef.slots;
33
+ export default class DropDown extends SvelteComponent<DropDownProps, DropDownEvents, DropDownSlots> {
34
+ get hide(): () => void;
35
+ get show(): () => void;
36
+ get setTippyProps(): (props: Partial<TippyProps>) => void;
37
+ }
38
+ export {};