@use-kona/editor 0.1.2 → 0.1.4

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 (226) hide show
  1. package/README.md +28 -17
  2. package/dist/index.d.ts +0 -1
  3. package/dist/index.js +1 -2
  4. package/dist/plugins/CodeBlockPlugin/CodeBlockPlugin.js +38 -37
  5. package/dist/plugins/CodeBlockPlugin/index.d.ts +1 -0
  6. package/dist/plugins/EmojiPlugin/EmojiPlugin.d.ts +28 -0
  7. package/dist/plugins/EmojiPlugin/EmojiPlugin.js +83 -0
  8. package/dist/plugins/EmojiPlugin/Menu.d.ts +7 -0
  9. package/dist/plugins/EmojiPlugin/Menu.js +51 -0
  10. package/dist/plugins/EmojiPlugin/index.d.ts +1 -0
  11. package/dist/plugins/EmojiPlugin/index.js +2 -0
  12. package/dist/plugins/EmojiPlugin/styles.module.js +7 -0
  13. package/dist/plugins/EmojiPlugin/styles_module.css +11 -0
  14. package/dist/plugins/EmojiPlugin/types.d.ts +7 -0
  15. package/dist/plugins/FloatingMenuPlugin/FloatingMenu.js +15 -28
  16. package/dist/plugins/FloatingMenuPlugin/types.d.ts +4 -1
  17. package/dist/plugins/HighlightsPlugin/HighlightsPlugin.d.ts +1 -0
  18. package/dist/plugins/HighlightsPlugin/HighlightsPlugin.js +3 -0
  19. package/dist/plugins/ListsPlugin/styles_module.css +4 -0
  20. package/dist/plugins/PlaceholderPlugin/PlaceholderPlugin.js +6 -3
  21. package/dist/plugins/PlaceholderPlugin/styles.module.js +1 -0
  22. package/dist/plugins/PlaceholderPlugin/styles_module.css +4 -0
  23. package/dist/plugins/index.d.ts +2 -1
  24. package/dist/plugins/index.js +2 -1
  25. package/package.json +12 -8
  26. package/src/index.ts +0 -1
  27. package/src/plugins/CodeBlockPlugin/CodeBlockPlugin.tsx +51 -48
  28. package/src/plugins/CodeBlockPlugin/index.ts +1 -0
  29. package/src/plugins/EmojiPlugin/EmojiPlugin.tsx +116 -0
  30. package/src/plugins/EmojiPlugin/Menu.tsx +74 -0
  31. package/src/plugins/EmojiPlugin/index.ts +1 -0
  32. package/src/plugins/EmojiPlugin/styles.module.css +10 -0
  33. package/src/plugins/EmojiPlugin/types.ts +5 -0
  34. package/src/plugins/FloatingMenuPlugin/FloatingMenu.tsx +13 -22
  35. package/src/plugins/FloatingMenuPlugin/types.ts +4 -1
  36. package/src/plugins/HighlightsPlugin/HighlightsPlugin.tsx +4 -0
  37. package/src/plugins/ListsPlugin/styles.module.css +4 -0
  38. package/src/plugins/PlaceholderPlugin/PlaceholderPlugin.tsx +13 -3
  39. package/src/plugins/PlaceholderPlugin/styles.module.css +2 -2
  40. package/src/plugins/index.ts +2 -1
  41. package/dist/examples/Backdrop.d.ts +0 -5
  42. package/dist/examples/Backdrop.js +0 -13
  43. package/dist/examples/Backdrop.module.js +0 -5
  44. package/dist/examples/Backdrop_module.css +0 -6
  45. package/dist/examples/CodeBlock.d.ts +0 -12
  46. package/dist/examples/CodeBlock.js +0 -163
  47. package/dist/examples/CodeBlock.module.js +0 -9
  48. package/dist/examples/CodeBlock_module.css +0 -66
  49. package/dist/examples/DragBlock.d.ts +0 -11
  50. package/dist/examples/DragBlock.js +0 -38
  51. package/dist/examples/DragBlock.module.js +0 -9
  52. package/dist/examples/DragBlock_module.css +0 -43
  53. package/dist/examples/DragHandler.d.ts +0 -2
  54. package/dist/examples/DragHandler.js +0 -44
  55. package/dist/examples/DragHandler.module.js +0 -8
  56. package/dist/examples/DragHandler_module.css +0 -18
  57. package/dist/examples/Editor.d.ts +0 -8
  58. package/dist/examples/Editor.js +0 -44
  59. package/dist/examples/Editor.module.js +0 -12
  60. package/dist/examples/Editor_module.css +0 -127
  61. package/dist/examples/FloatingMenu.d.ts +0 -17
  62. package/dist/examples/FloatingMenu.js +0 -244
  63. package/dist/examples/FloatingMenu.module.js +0 -9
  64. package/dist/examples/FloatingMenu_module.css +0 -75
  65. package/dist/examples/LinksHint.d.ts +0 -7
  66. package/dist/examples/LinksHint.js +0 -50
  67. package/dist/examples/LinksHint.module.js +0 -6
  68. package/dist/examples/LinksHint_module.css +0 -28
  69. package/dist/examples/Menu.d.ts +0 -6
  70. package/dist/examples/Menu.js +0 -79
  71. package/dist/examples/Menu.module.js +0 -8
  72. package/dist/examples/Menu_module.css +0 -38
  73. package/dist/examples/colors.d.ts +0 -10
  74. package/dist/examples/colors.js +0 -12
  75. package/dist/examples/getCommands.d.ts +0 -2
  76. package/dist/examples/getCommands.js +0 -87
  77. package/dist/examples/getPlugins.d.ts +0 -2
  78. package/dist/examples/getPlugins.js +0 -127
  79. package/dist/examples/getShortcuts.d.ts +0 -2
  80. package/dist/examples/getShortcuts.js +0 -90
  81. package/dist/examples/icons/bold.d.ts +0 -2
  82. package/dist/examples/icons/bold.js +0 -27
  83. package/dist/examples/icons/check.d.ts +0 -2
  84. package/dist/examples/icons/check.js +0 -24
  85. package/dist/examples/icons/chevronRight.d.ts +0 -2
  86. package/dist/examples/icons/chevronRight.js +0 -24
  87. package/dist/examples/icons/color.d.ts +0 -2
  88. package/dist/examples/icons/color.js +0 -30
  89. package/dist/examples/icons/copy.d.ts +0 -2
  90. package/dist/examples/icons/copy.js +0 -27
  91. package/dist/examples/icons/cross.d.ts +0 -2
  92. package/dist/examples/icons/cross.js +0 -27
  93. package/dist/examples/icons/drag.d.ts +0 -2
  94. package/dist/examples/icons/drag.js +0 -39
  95. package/dist/examples/icons/edit.d.ts +0 -2
  96. package/dist/examples/icons/edit.js +0 -30
  97. package/dist/examples/icons/external.d.ts +0 -2
  98. package/dist/examples/icons/external.js +0 -30
  99. package/dist/examples/icons/heading1.d.ts +0 -2
  100. package/dist/examples/icons/heading1.js +0 -45
  101. package/dist/examples/icons/heading2.d.ts +0 -2
  102. package/dist/examples/icons/heading2.js +0 -45
  103. package/dist/examples/icons/heading3.d.ts +0 -2
  104. package/dist/examples/icons/heading3.js +0 -48
  105. package/dist/examples/icons/italic.d.ts +0 -2
  106. package/dist/examples/icons/italic.js +0 -30
  107. package/dist/examples/icons/link.d.ts +0 -2
  108. package/dist/examples/icons/link.js +0 -30
  109. package/dist/examples/icons/ol.d.ts +0 -2
  110. package/dist/examples/icons/ol.js +0 -36
  111. package/dist/examples/icons/strikethrough.d.ts +0 -2
  112. package/dist/examples/icons/strikethrough.js +0 -27
  113. package/dist/examples/icons/text.d.ts +0 -2
  114. package/dist/examples/icons/text.js +0 -22
  115. package/dist/examples/icons/types.d.ts +0 -3
  116. package/dist/examples/icons/ul.d.ts +0 -2
  117. package/dist/examples/icons/ul.js +0 -39
  118. package/dist/examples/icons/underline.d.ts +0 -2
  119. package/dist/examples/icons/underline.js +0 -27
  120. package/dist/examples/store.d.ts +0 -8
  121. package/dist/examples/store.js +0 -6
  122. package/dist/examples/styles.module.js +0 -11
  123. package/dist/examples/styles_module.css +0 -78
  124. package/dist/examples/text.d.ts +0 -3
  125. package/dist/examples/text.js +0 -60
  126. package/dist/examples/ui/Button/Button.d.ts +0 -8
  127. package/dist/examples/ui/Button/Button.js +0 -15
  128. package/dist/examples/ui/Button/ButtonWrapper.d.ts +0 -4
  129. package/dist/examples/ui/Button/ButtonWrapper.js +0 -14
  130. package/dist/examples/ui/Button/index.d.ts +0 -2
  131. package/dist/examples/ui/Button/index.js +0 -3
  132. package/dist/examples/ui/Button/styles.module.js +0 -10
  133. package/dist/examples/ui/Button/styles_module.css +0 -72
  134. package/dist/examples/ui/Button/types.d.ts +0 -1
  135. package/dist/examples/ui/Button/types.js +0 -0
  136. package/dist/examples/ui/Dropdown/Dropdown.d.ts +0 -16
  137. package/dist/examples/ui/Dropdown/Dropdown.js +0 -75
  138. package/dist/examples/ui/Dropdown/index.d.ts +0 -1
  139. package/dist/examples/ui/Dropdown/index.js +0 -2
  140. package/dist/examples/ui/Menu/Menu.d.ts +0 -41
  141. package/dist/examples/ui/Menu/Menu.js +0 -404
  142. package/dist/examples/ui/Menu/MenuDelimiter.d.ts +0 -1
  143. package/dist/examples/ui/Menu/MenuDelimiter.js +0 -6
  144. package/dist/examples/ui/Menu/MenuHotkey.d.ts +0 -6
  145. package/dist/examples/ui/Menu/MenuHotkey.js +0 -12
  146. package/dist/examples/ui/Menu/MenuIcon.d.ts +0 -6
  147. package/dist/examples/ui/Menu/MenuIcon.js +0 -12
  148. package/dist/examples/ui/Menu/MenuItem.d.ts +0 -6
  149. package/dist/examples/ui/Menu/MenuItem.js +0 -17
  150. package/dist/examples/ui/Menu/MenuTitle.d.ts +0 -6
  151. package/dist/examples/ui/Menu/MenuTitle.js +0 -12
  152. package/dist/examples/ui/Menu/SafeSpace.d.ts +0 -6
  153. package/dist/examples/ui/Menu/SafeSpace.js +0 -65
  154. package/dist/examples/ui/Menu/index.d.ts +0 -2
  155. package/dist/examples/ui/Menu/index.js +0 -2
  156. package/dist/examples/ui/Menu/styles.module.js +0 -21
  157. package/dist/examples/ui/Menu/styles_module.css +0 -140
  158. package/dist/examples/ui/Menu/types.d.ts +0 -16
  159. package/dist/examples/ui/Menu/types.js +0 -0
  160. package/dist/examples/ui/useMenuPosition.d.ts +0 -18
  161. package/dist/examples/ui/useMenuPosition.js +0 -51
  162. package/dist/examples/ui/useMergeRefs.d.ts +0 -23
  163. package/dist/examples/ui/useMergeRefs.js +0 -11
  164. package/src/examples/Backdrop.module.css +0 -8
  165. package/src/examples/Backdrop.tsx +0 -16
  166. package/src/examples/CodeBlock.module.css +0 -65
  167. package/src/examples/CodeBlock.tsx +0 -109
  168. package/src/examples/DragBlock.module.css +0 -42
  169. package/src/examples/DragBlock.tsx +0 -57
  170. package/src/examples/DragHandler.module.css +0 -17
  171. package/src/examples/DragHandler.tsx +0 -39
  172. package/src/examples/Editor.module.css +0 -129
  173. package/src/examples/Editor.tsx +0 -68
  174. package/src/examples/FloatingMenu.module.css +0 -74
  175. package/src/examples/FloatingMenu.tsx +0 -274
  176. package/src/examples/LinksHint.module.css +0 -27
  177. package/src/examples/LinksHint.tsx +0 -58
  178. package/src/examples/Menu.module.css +0 -37
  179. package/src/examples/Menu.tsx +0 -80
  180. package/src/examples/colors.ts +0 -11
  181. package/src/examples/getCommands.tsx +0 -76
  182. package/src/examples/getPlugins.tsx +0 -143
  183. package/src/examples/getShortcuts.ts +0 -107
  184. package/src/examples/icons/bold.tsx +0 -20
  185. package/src/examples/icons/check.tsx +0 -19
  186. package/src/examples/icons/chevronRight.tsx +0 -19
  187. package/src/examples/icons/color.tsx +0 -23
  188. package/src/examples/icons/copy.tsx +0 -20
  189. package/src/examples/icons/cross.tsx +0 -20
  190. package/src/examples/icons/drag.tsx +0 -24
  191. package/src/examples/icons/edit.tsx +0 -21
  192. package/src/examples/icons/external.tsx +0 -21
  193. package/src/examples/icons/heading1.tsx +0 -26
  194. package/src/examples/icons/heading2.tsx +0 -26
  195. package/src/examples/icons/heading3.tsx +0 -27
  196. package/src/examples/icons/italic.tsx +0 -21
  197. package/src/examples/icons/link.tsx +0 -21
  198. package/src/examples/icons/ol.tsx +0 -23
  199. package/src/examples/icons/strikethrough.tsx +0 -20
  200. package/src/examples/icons/text.tsx +0 -18
  201. package/src/examples/icons/types.ts +0 -3
  202. package/src/examples/icons/ul.tsx +0 -24
  203. package/src/examples/icons/underline.tsx +0 -20
  204. package/src/examples/store.ts +0 -14
  205. package/src/examples/styles.module.css +0 -77
  206. package/src/examples/text.tsx +0 -133
  207. package/src/examples/ui/Button/Button.tsx +0 -34
  208. package/src/examples/ui/Button/ButtonWrapper.tsx +0 -22
  209. package/src/examples/ui/Button/index.ts +0 -2
  210. package/src/examples/ui/Button/styles.module.css +0 -75
  211. package/src/examples/ui/Button/types.ts +0 -1
  212. package/src/examples/ui/Dropdown/Dropdown.tsx +0 -101
  213. package/src/examples/ui/Dropdown/index.ts +0 -1
  214. package/src/examples/ui/Menu/Menu.tsx +0 -576
  215. package/src/examples/ui/Menu/MenuDelimiter.tsx +0 -3
  216. package/src/examples/ui/Menu/MenuHotkey.tsx +0 -17
  217. package/src/examples/ui/Menu/MenuIcon.tsx +0 -17
  218. package/src/examples/ui/Menu/MenuItem.tsx +0 -45
  219. package/src/examples/ui/Menu/MenuTitle.tsx +0 -17
  220. package/src/examples/ui/Menu/SafeSpace.tsx +0 -84
  221. package/src/examples/ui/Menu/index.ts +0 -2
  222. package/src/examples/ui/Menu/styles.module.css +0 -143
  223. package/src/examples/ui/Menu/types.ts +0 -18
  224. package/src/examples/ui/useMenuPosition.ts +0 -72
  225. package/src/examples/ui/useMergeRefs.ts +0 -39
  226. /package/dist/{examples/icons → plugins/EmojiPlugin}/types.js +0 -0
@@ -1,27 +0,0 @@
1
- import { IconProps } from './types';
2
-
3
- export const Heading3Icon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth={1.5}
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="icon icon-tabler icons-tabler-outline icon-tabler-h-3"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path d="M19 14a2 2 0 1 0 -2 -2" />
18
- <path d="M17 16a2 2 0 1 0 2 -2" />
19
- <path d="M4 6v12" />
20
- <path d="M12 6v12" />
21
- <path d="M11 18h2" />
22
- <path d="M3 18h2" />
23
- <path d="M4 12h8" />
24
- <path d="M3 6h2" />
25
- <path d="M11 6h2" />
26
- </svg>
27
- );
@@ -1,21 +0,0 @@
1
- import { IconProps } from './types';
2
-
3
- export const ItalicIcon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth={1.5}
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="icon icon-tabler icons-tabler-outline icon-tabler-italic"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path d="M11 5l6 0" />
18
- <path d="M7 19l6 0" />
19
- <path d="M14 5l-4 14" />
20
- </svg>
21
- );
@@ -1,21 +0,0 @@
1
- import { IconProps } from './types';
2
-
3
- export const LinkIcon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth={1.5}
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="icon icon-tabler icons-tabler-outline icon-tabler-link"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path d="M9 15l6 -6" />
18
- <path d="M11 6l.463 -.536a5 5 0 0 1 7.071 7.072l-.534 .464" />
19
- <path d="M13 18l-.397 .534a5.068 5.068 0 0 1 -7.127 0a4.972 4.972 0 0 1 0 -7.071l.524 -.463" />
20
- </svg>
21
- );
@@ -1,23 +0,0 @@
1
- import type { IconProps } from './types';
2
-
3
- export const OlIcon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth={1.5}
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="icon icon-tabler icons-tabler-outline icon-tabler-list-numbers"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path d="M11 6h9" />
18
- <path d="M11 12h9" />
19
- <path d="M12 18h8" />
20
- <path d="M4 16a2 2 0 1 1 4 0c0 .591 -.5 1 -1 1.5l-3 2.5h4" />
21
- <path d="M6 10v-6l-2 2" />
22
- </svg>
23
- );
@@ -1,20 +0,0 @@
1
- import { IconProps } from './types';
2
-
3
- export const StrikethroughIcon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth={1.5}
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="icon icon-tabler icons-tabler-outline icon-tabler-strikethrough"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path d="M5 12l14 0" />
18
- <path d="M16 6.5a4 2 0 0 0 -4 -1.5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1 -4 -1.5" />
19
- </svg>
20
- );
@@ -1,18 +0,0 @@
1
- import type { IconProps } from './types';
2
-
3
- export const TextIcon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- fill="none"
9
- stroke="currentColor"
10
- strokeLinecap="round"
11
- strokeLinejoin="round"
12
- strokeWidth={1.25}
13
- viewBox="0 0 24 24"
14
- >
15
- <path stroke="none" d="M0 0h24v24H0z" />
16
- <path d="M4 6h16M4 12h10M4 18h14" />
17
- </svg>
18
- );
@@ -1,3 +0,0 @@
1
- export type IconProps = {
2
- size?: number;
3
- };
@@ -1,24 +0,0 @@
1
- import { IconProps } from './types';
2
-
3
- export const UlIcon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth={1.5}
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="icon icon-tabler icons-tabler-outline icon-tabler-list"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path d="M9 6l11 0" />
18
- <path d="M9 12l11 0" />
19
- <path d="M9 18l11 0" />
20
- <path d="M5 6l0 .01" />
21
- <path d="M5 12l0 .01" />
22
- <path d="M5 18l0 .01" />
23
- </svg>
24
- );
@@ -1,20 +0,0 @@
1
- import { IconProps } from './types';
2
-
3
- export const UnderlineIcon = ({ size }: IconProps) => (
4
- <svg
5
- xmlns="http://www.w3.org/2000/svg"
6
- width={size}
7
- height={size}
8
- viewBox="0 0 24 24"
9
- fill="none"
10
- stroke="currentColor"
11
- strokeWidth={1.5}
12
- strokeLinecap="round"
13
- strokeLinejoin="round"
14
- className="icon icon-tabler icons-tabler-outline icon-tabler-underline"
15
- >
16
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
17
- <path d="M7 5v5a5 5 0 0 0 10 0v-5" />
18
- <path d="M5 19h14" />
19
- </svg>
20
- );
@@ -1,14 +0,0 @@
1
- import { map } from 'nanostores';
2
-
3
- type FloatingMenuMode = 'main' | 'link' | 'colors';
4
-
5
- type Store = {
6
- isFloatingMenuOpen: boolean;
7
- floatingMenuMode: FloatingMenuMode;
8
- url?: string;
9
- };
10
-
11
- export const $store = map<Store>({
12
- isFloatingMenuOpen: false,
13
- floatingMenuMode: 'main',
14
- });
@@ -1,77 +0,0 @@
1
- body {
2
- --background-color: #fff;
3
- --kona-editor-background-color: #fff;
4
- --text-color: #444;
5
- --kona-editor-text-color: #444;
6
- --border-color: #ddd;
7
- --kona-editor-border-color: #ddd;
8
- }
9
-
10
- :global(body.dark-theme) {
11
- background-color: #222;
12
- color: #eee;
13
- --background-color: #222;
14
- --text-color: #eee;
15
- --border-color: #000;
16
- }
17
-
18
- .root {
19
- width: 600px;
20
- height: calc(100vh - 128px * 2);
21
- overflow: hidden;
22
- max-height: 100vh;
23
- margin: 32px auto;
24
- border: 1px solid var(--border-color);
25
- border-radius: 4px;
26
-
27
- [role="textbox"] {
28
- outline: none;
29
- }
30
- }
31
-
32
- .menu {
33
- padding: 8px;
34
- display: flex;
35
- column-gap: 4px;
36
- }
37
-
38
- .button {
39
- width: 24px;
40
- height: 24px;
41
- border-radius: 4px;
42
- cursor: pointer;
43
- padding: 0;
44
- margin: 0;
45
- outline: none;
46
- background-color: transparent;
47
- border: none;
48
- display: inline-flex;
49
- align-items: center;
50
- justify-content: center;
51
- color: inherit;
52
- transition: background-color 0.25s;
53
- }
54
-
55
- .button.active {
56
- background-color: #eee;
57
- }
58
-
59
- .divider {
60
- display: inline-block;
61
- background-color: #ccc;
62
- width: 1px;
63
- height: 24px;
64
- }
65
-
66
- .floating {
67
- height: 24px;
68
- }
69
-
70
- .hint {
71
- background-color: #fff;
72
- color: #444;
73
- padding: 2px;
74
- border-radius: 4px;
75
- border: 1px solid #ccc;
76
- box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.06);
77
- }
@@ -1,133 +0,0 @@
1
- /** @jsxRuntime classic */
2
- /** @jsx jsx */
3
-
4
- import {
5
- createHyperscript,
6
- createText,
7
- type HyperscriptShorthands,
8
- } from 'slate-hyperscript';
9
- import {
10
- CodeBlockPlugin,
11
- HeadingsPlugin,
12
- LinksPlugin,
13
- ListsPlugin,
14
- } from '../plugins';
15
-
16
- const elements: HyperscriptShorthands = {
17
- paragraph: { type: 'paragraph' },
18
- heading1: { type: HeadingsPlugin.HeadingLevel1 },
19
- heading2: { type: HeadingsPlugin.HeadingLevel2 },
20
- heading3: { type: HeadingsPlugin.HeadingLevel3 },
21
- numberedList: { type: ListsPlugin.NUMBERED_LIST_ELEMENT },
22
- bulletedList: { type: ListsPlugin.BULLETED_LIST_ELEMENT },
23
- listItem: { type: ListsPlugin.LIST_ITEM_ELEMENT },
24
- codeBlock: { type: CodeBlockPlugin.CODE_ELEMENT },
25
- codeBlockLine: { type: CodeBlockPlugin.CODE_LINE_ELEMENT },
26
- hlink: { type: LinksPlugin.LINK_TYPE },
27
- };
28
-
29
- const creators = {
30
- htext: createText,
31
- };
32
-
33
- const jsx = createHyperscript({ elements, creators });
34
-
35
- export const text = (
36
- <fragment>
37
- <heading1>About</heading1>
38
- <paragraph>
39
- <htext bold italic>
40
- Kona Editor
41
- </htext>{' '}
42
- is a text editor based on Slate.js that I use in{' '}
43
- <hlink url="https://kona.to">Kona calendar</hlink> for notes and event
44
- descriptions. I decided to open-source the editor for a few reasons:
45
- </paragraph>
46
- <numberedList>
47
- <listItem>
48
- I had a lot of <htext strikethrough>difficulties</htext> fun while
49
- building this editor and there were always not enough examples of how to
50
- do it right. I wanted to make a little contribution to the community, so
51
- others could use my code as a reference.
52
- </listItem>
53
- <listItem>
54
- I have always wanted to try to build something open-sourced, but there
55
- have not been enough good ideas on what to build. I think that an editor
56
- is a pretty decent starting point.
57
- </listItem>
58
- </numberedList>
59
- <heading2>Usage</heading2>
60
- <codeBlock language="tsx">
61
- <codeBlockLine>{`import { KonaEditor } from '@use-kona/editor';`}</codeBlockLine>
62
- <codeBlockLine> </codeBlockLine>
63
- <codeBlockLine>{`const App = () => {`}</codeBlockLine>
64
- <codeBlockLine>{` return (`}</codeBlockLine>
65
- <codeBlockLine>{` <KonaEditor`}</codeBlockLine>
66
- <codeBlockLine>{` initialValue={initialValue}`}</codeBlockLine>
67
- <codeBlockLine>{` plugins={plugins}`}</codeBlockLine>
68
- <codeBlockLine>{` onChange={handleChange}`}</codeBlockLine>
69
- <codeBlockLine>{` />`}</codeBlockLine>
70
- <codeBlockLine>{` )`}</codeBlockLine>
71
- <codeBlockLine>{`}`}</codeBlockLine>
72
- </codeBlock>
73
- <paragraph>
74
- Defining the list of plugins might be a little tricky, but I've tried to
75
- cover everything you'll need in docs.
76
- </paragraph>
77
- <heading2>List of plugins</heading2>
78
- <heading3>BasicFormattingPlugin</heading3>
79
- <paragraph>
80
- Allows to use <htext bold>bold</htext>, <htext italic>italic</htext>,{' '}
81
- <htext underline>underlined</htext> and{' '}
82
- <htext strikethrough>strikethrough</htext> text
83
- </paragraph>
84
-
85
- <heading3>BreaksPlugin</heading3>
86
- <paragraph>
87
- Overrides default Slate behavior by breaking custom block types when user
88
- presses Enter.
89
- </paragraph>
90
-
91
- <heading3>CodeBlockPlugin</heading3>
92
- <paragraph>Adds support for code blocks.</paragraph>
93
-
94
- <heading3>CommandsPlugin</heading3>
95
- <paragraph>Adds Notion-style menu with custom list of commands</paragraph>
96
-
97
- <heading3>DnDPlugin</heading3>
98
- <paragraph>Allows reordering blocks by drag'n'dropping them</paragraph>
99
-
100
- <heading3>FloatingMenuPlugin</heading3>
101
- <paragraph>Adds menu which is shown when user selects a text</paragraph>
102
-
103
- <heading3>HeadingsPlugin</heading3>
104
- <paragraph>Adds three levels of headings</paragraph>
105
-
106
- <heading3>HighlightsPlugin</heading3>
107
- <paragraph>Allows highlighting selected text with a custom color</paragraph>
108
-
109
- <heading3>LinksPlugin</heading3>
110
- <paragraph>
111
- Gives user ability to convert the selected text into a link
112
- </paragraph>
113
-
114
- <heading3>MenuPlugin</heading3>
115
- <paragraph>Adds pinned to the top menu with custom commands</paragraph>
116
-
117
- <heading3>NodeIdPlugin</heading3>
118
- <paragraph>Assigns a unique id to each block</paragraph>
119
-
120
- <heading3>PlaceholderPlugin</heading3>
121
- <paragraph>
122
- Allows to setup a custom placeholder for the selected line
123
- </paragraph>
124
-
125
- <heading3>ShortcutsPlugin</heading3>
126
- <paragraph>
127
- Converts some popular markdown shortcuts to a custom node
128
- </paragraph>
129
-
130
- <heading3>TableOfContentsPlugin</heading3>
131
- <paragraph>Shows a quick map of headings inside the document</paragraph>
132
- </fragment>
133
- );
@@ -1,34 +0,0 @@
1
- import { forwardRef, type ReactNode } from 'react';
2
- import { ButtonWrapper } from './ButtonWrapper';
3
-
4
- type ButtonProps = {
5
- onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
6
- size?: 'sm' | 'md' | 'lg';
7
- variant?: 'primary' | 'secondary' | 'danger' | 'transparent';
8
- children: ReactNode;
9
- disabled?: boolean;
10
- } & Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'size'>;
11
-
12
- export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
13
- (props, ref) => {
14
- const {
15
- size = 'md',
16
- variant = 'secondary',
17
- onClick = () => {},
18
- children,
19
- ...rest
20
- } = props;
21
-
22
- return (
23
- <ButtonWrapper
24
- ref={ref}
25
- size={size}
26
- onClick={onClick}
27
- variant={variant}
28
- {...rest}
29
- >
30
- {children}
31
- </ButtonWrapper>
32
- );
33
- },
34
- );
@@ -1,22 +0,0 @@
1
- import { forwardRef } from 'react';
2
- import styles from './styles.module.css';
3
-
4
- type ButtonWrapperProps = {
5
- size: 'sm' | 'md' | 'lg';
6
- variant?: 'primary' | 'secondary' | 'transparent' | 'danger';
7
- } & React.ButtonHTMLAttributes<HTMLButtonElement>;
8
-
9
- export const ButtonWrapper = forwardRef<HTMLButtonElement, ButtonWrapperProps>((props, ref) => {
10
- const { size, variant = 'secondary', className, ...rest } = props;
11
-
12
- const sizeClass = styles[`size${size.charAt(0).toUpperCase()}${size.slice(1)}`];
13
- const variantClass = styles[variant];
14
-
15
- return (
16
- <button
17
- ref={ref}
18
- className={`${styles.button} ${sizeClass} ${variantClass} ${className || ''}`}
19
- {...rest}
20
- />
21
- );
22
- });
@@ -1,2 +0,0 @@
1
- export { Button } from './Button';
2
- export { ButtonWrapper } from './ButtonWrapper';
@@ -1,75 +0,0 @@
1
- .button {
2
- display: flex;
3
- align-items: center;
4
- justify-content: center;
5
- column-gap: 4px;
6
- font-size: 12px;
7
- user-select: none;
8
- outline: none;
9
- border-width: 1px;
10
- border-style: solid;
11
- transition:
12
- background-color,
13
- border 0.1s ease-in-out;
14
- border-radius: 4px;
15
- }
16
-
17
- /* Size variants */
18
- .sizeSm {
19
- height: 28px;
20
- padding: 4px 4px;
21
- }
22
-
23
- .sizeMd {
24
- height: 32px;
25
- padding: 4px 8px;
26
- }
27
-
28
- .sizeLg {
29
- height: 36px;
30
- padding: 4px 12px;
31
- }
32
-
33
- .secondary {
34
- color: var(--kona-editor-text-color, #444);
35
- background-color: var(--kona-editor-background-color, #fff);
36
- border-color: var(--kona-editor-border-color, #ddd);
37
- }
38
-
39
- .secondary:disabled {
40
- color: #999999;
41
- background-color: #f0f0f0;
42
- }
43
-
44
- .secondary:focus {
45
- outline: 1px solid #0066cc;
46
- border-color: transparent;
47
- }
48
-
49
- .secondary:hover:not(:disabled) {
50
- background-color: var(--kona-editor-background-color, #f0f0f0);
51
- }
52
-
53
- .transparent {
54
- color: #333333;
55
- background-color: transparent;
56
- border-color: transparent;
57
- }
58
-
59
- .transparent:disabled {
60
- color: #999999;
61
- }
62
-
63
- .transparent:focus {
64
- outline: 1px solid #0066cc;
65
- border-color: transparent;
66
- }
67
-
68
- .transparent:hover:not(:disabled) {
69
- background-color: rgba(0, 0, 0, 0.05);
70
- }
71
-
72
- /* Active state for all buttons */
73
- .button:active:not(:disabled) {
74
- transform: scale(0.95);
75
- }
@@ -1 +0,0 @@
1
- export type ButtonVariant = 'primary' | 'secondary' | 'transparent'
@@ -1,101 +0,0 @@
1
- import {
2
- type JSX,
3
- type RefObject,
4
- useLayoutEffect,
5
- useRef,
6
- useState,
7
- } from 'react';
8
- import { Menu, type MenuConfig } from '../Menu';
9
- import { useMenuPosition } from '../useMenuPosition';
10
-
11
- type ChildrenProps = { ref: RefObject<any>; onClick: () => void };
12
-
13
- type DropdownProps = {
14
- config: MenuConfig;
15
- children: (props: ChildrenProps) => React.ReactNode;
16
- target?: HTMLElement;
17
- Menu?: JSX.ElementType;
18
- MenuBody?: JSX.ElementType;
19
- onClose?: () => void;
20
- };
21
-
22
- export const Dropdown = (props: DropdownProps) => {
23
- const {
24
- config,
25
- target,
26
- children,
27
- onClose = () => {},
28
- Menu: MenuComponent,
29
- MenuBody,
30
- } = props;
31
- const [rect, setRect] = useState<DOMRect>();
32
- const [isOpen, setOpen] = useState(false);
33
-
34
- const ref = useRef<HTMLElement>(null);
35
- const menuRef = useRef<HTMLMenuElement>(null);
36
-
37
- // biome-ignore lint/correctness/useExhaustiveDependencies: we care only about isOpen
38
- useLayoutEffect(() => {
39
- if (ref.current) {
40
- const rect = ref.current.getBoundingClientRect();
41
- setRect(rect);
42
- }
43
- }, [isOpen]);
44
-
45
- const coords = {
46
- x: rect?.left ?? 0,
47
- y: (rect?.top ?? 0) + (rect?.height ?? 0),
48
- };
49
-
50
- const [transform, newCoords] = useMenuPosition(coords, (context) => {
51
- const [horizontal, vertical] = context.helpers.isWithinWindow();
52
-
53
- if (!vertical) {
54
- context.flip([false, true]).move(0, -(rect?.height ?? 0));
55
- }
56
-
57
- if (!horizontal) {
58
- context.flip([true, false]).move(rect?.width ?? 0, 0);
59
- }
60
-
61
- return context.point;
62
- });
63
-
64
- const changeOpen = (value: boolean) => {
65
- setOpen(value);
66
- if (!value) {
67
- onClose();
68
- }
69
- };
70
-
71
- // biome-ignore lint/correctness/useExhaustiveDependencies: we don't care about all the deps
72
- useLayoutEffect(() => {
73
- if (menuRef.current) {
74
- transform(menuRef.current);
75
- }
76
- }, [isOpen, rect?.left, rect?.top, config]);
77
-
78
- const handleClick = () => {
79
- changeOpen(!isOpen);
80
- };
81
-
82
- const handleToggle = (value?: boolean) => {
83
- changeOpen(value === undefined ? !isOpen : value);
84
- };
85
-
86
- return (
87
- <>
88
- {children({ ref, onClick: handleClick })}
89
- <Menu
90
- target={target}
91
- ref={menuRef}
92
- Menu={MenuComponent}
93
- MenuBody={MenuBody}
94
- coords={[newCoords.x, newCoords.y]}
95
- isOpen={isOpen}
96
- config={config}
97
- onToggle={handleToggle}
98
- />
99
- </>
100
- );
101
- };
@@ -1 +0,0 @@
1
- export { Dropdown } from './Dropdown';