@use-kona/editor 0.1.3 → 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 (213) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js +1 -2
  3. package/dist/plugins/CodeBlockPlugin/index.d.ts +1 -0
  4. package/dist/plugins/FloatingMenuPlugin/FloatingMenu.js +15 -28
  5. package/dist/plugins/FloatingMenuPlugin/types.d.ts +4 -1
  6. package/dist/plugins/HighlightsPlugin/HighlightsPlugin.d.ts +1 -0
  7. package/dist/plugins/HighlightsPlugin/HighlightsPlugin.js +3 -0
  8. package/dist/plugins/index.d.ts +1 -1
  9. package/package.json +12 -11
  10. package/src/index.ts +0 -1
  11. package/src/plugins/CodeBlockPlugin/index.ts +1 -0
  12. package/src/plugins/FloatingMenuPlugin/FloatingMenu.tsx +13 -22
  13. package/src/plugins/FloatingMenuPlugin/types.ts +4 -1
  14. package/src/plugins/HighlightsPlugin/HighlightsPlugin.tsx +4 -0
  15. package/src/plugins/index.ts +1 -1
  16. package/dist/examples/Backdrop.d.ts +0 -5
  17. package/dist/examples/Backdrop.js +0 -13
  18. package/dist/examples/Backdrop.module.js +0 -5
  19. package/dist/examples/Backdrop_module.css +0 -6
  20. package/dist/examples/CodeBlock.d.ts +0 -12
  21. package/dist/examples/CodeBlock.js +0 -163
  22. package/dist/examples/CodeBlock.module.js +0 -9
  23. package/dist/examples/CodeBlock_module.css +0 -66
  24. package/dist/examples/DragBlock.d.ts +0 -11
  25. package/dist/examples/DragBlock.js +0 -38
  26. package/dist/examples/DragBlock.module.js +0 -9
  27. package/dist/examples/DragBlock_module.css +0 -43
  28. package/dist/examples/DragHandler.d.ts +0 -2
  29. package/dist/examples/DragHandler.js +0 -44
  30. package/dist/examples/DragHandler.module.js +0 -8
  31. package/dist/examples/DragHandler_module.css +0 -18
  32. package/dist/examples/Editor.d.ts +0 -8
  33. package/dist/examples/Editor.js +0 -44
  34. package/dist/examples/Editor.module.js +0 -12
  35. package/dist/examples/Editor_module.css +0 -127
  36. package/dist/examples/Emoji.d.ts +0 -5
  37. package/dist/examples/Emoji.js +0 -8
  38. package/dist/examples/EmojiSelector.d.ts +0 -16
  39. package/dist/examples/EmojiSelector.js +0 -91
  40. package/dist/examples/EmojiSelector.module.js +0 -7
  41. package/dist/examples/EmojiSelector_module.css +0 -36
  42. package/dist/examples/FloatingMenu.d.ts +0 -19
  43. package/dist/examples/FloatingMenu.js +0 -244
  44. package/dist/examples/FloatingMenu.module.js +0 -9
  45. package/dist/examples/FloatingMenu_module.css +0 -75
  46. package/dist/examples/LinksHint.d.ts +0 -7
  47. package/dist/examples/LinksHint.js +0 -50
  48. package/dist/examples/LinksHint.module.js +0 -6
  49. package/dist/examples/LinksHint_module.css +0 -28
  50. package/dist/examples/Menu.d.ts +0 -6
  51. package/dist/examples/Menu.js +0 -94
  52. package/dist/examples/Menu.module.js +0 -8
  53. package/dist/examples/Menu_module.css +0 -38
  54. package/dist/examples/colors.d.ts +0 -10
  55. package/dist/examples/colors.js +0 -12
  56. package/dist/examples/getCommands.d.ts +0 -2
  57. package/dist/examples/getCommands.js +0 -100
  58. package/dist/examples/getPlugins.d.ts +0 -2
  59. package/dist/examples/getPlugins.js +0 -144
  60. package/dist/examples/getShortcuts.d.ts +0 -2
  61. package/dist/examples/getShortcuts.js +0 -90
  62. package/dist/examples/icons/bold.d.ts +0 -2
  63. package/dist/examples/icons/bold.js +0 -27
  64. package/dist/examples/icons/check.d.ts +0 -2
  65. package/dist/examples/icons/check.js +0 -24
  66. package/dist/examples/icons/chevronRight.d.ts +0 -2
  67. package/dist/examples/icons/chevronRight.js +0 -24
  68. package/dist/examples/icons/code.d.ts +0 -2
  69. package/dist/examples/icons/code.js +0 -30
  70. package/dist/examples/icons/color.d.ts +0 -2
  71. package/dist/examples/icons/color.js +0 -30
  72. package/dist/examples/icons/copy.d.ts +0 -2
  73. package/dist/examples/icons/copy.js +0 -27
  74. package/dist/examples/icons/cross.d.ts +0 -2
  75. package/dist/examples/icons/cross.js +0 -27
  76. package/dist/examples/icons/drag.d.ts +0 -2
  77. package/dist/examples/icons/drag.js +0 -39
  78. package/dist/examples/icons/edit.d.ts +0 -2
  79. package/dist/examples/icons/edit.js +0 -30
  80. package/dist/examples/icons/external.d.ts +0 -2
  81. package/dist/examples/icons/external.js +0 -30
  82. package/dist/examples/icons/heading1.d.ts +0 -2
  83. package/dist/examples/icons/heading1.js +0 -45
  84. package/dist/examples/icons/heading2.d.ts +0 -2
  85. package/dist/examples/icons/heading2.js +0 -45
  86. package/dist/examples/icons/heading3.d.ts +0 -2
  87. package/dist/examples/icons/heading3.js +0 -48
  88. package/dist/examples/icons/italic.d.ts +0 -2
  89. package/dist/examples/icons/italic.js +0 -30
  90. package/dist/examples/icons/link.d.ts +0 -2
  91. package/dist/examples/icons/link.js +0 -30
  92. package/dist/examples/icons/ol.d.ts +0 -2
  93. package/dist/examples/icons/ol.js +0 -36
  94. package/dist/examples/icons/strikethrough.d.ts +0 -2
  95. package/dist/examples/icons/strikethrough.js +0 -27
  96. package/dist/examples/icons/text.d.ts +0 -2
  97. package/dist/examples/icons/text.js +0 -22
  98. package/dist/examples/icons/types.d.ts +0 -3
  99. package/dist/examples/icons/types.js +0 -0
  100. package/dist/examples/icons/ul.d.ts +0 -2
  101. package/dist/examples/icons/ul.js +0 -39
  102. package/dist/examples/icons/underline.d.ts +0 -2
  103. package/dist/examples/icons/underline.js +0 -27
  104. package/dist/examples/store.d.ts +0 -9
  105. package/dist/examples/store.js +0 -7
  106. package/dist/examples/styles.module.js +0 -11
  107. package/dist/examples/styles_module.css +0 -78
  108. package/dist/examples/text.d.ts +0 -3
  109. package/dist/examples/text.js +0 -65
  110. package/dist/examples/ui/Button/Button.d.ts +0 -8
  111. package/dist/examples/ui/Button/Button.js +0 -15
  112. package/dist/examples/ui/Button/ButtonWrapper.d.ts +0 -4
  113. package/dist/examples/ui/Button/ButtonWrapper.js +0 -14
  114. package/dist/examples/ui/Button/index.d.ts +0 -2
  115. package/dist/examples/ui/Button/index.js +0 -3
  116. package/dist/examples/ui/Button/styles.module.js +0 -10
  117. package/dist/examples/ui/Button/styles_module.css +0 -72
  118. package/dist/examples/ui/Button/types.d.ts +0 -1
  119. package/dist/examples/ui/Button/types.js +0 -0
  120. package/dist/examples/ui/Dropdown/Dropdown.d.ts +0 -16
  121. package/dist/examples/ui/Dropdown/Dropdown.js +0 -75
  122. package/dist/examples/ui/Dropdown/index.d.ts +0 -1
  123. package/dist/examples/ui/Dropdown/index.js +0 -2
  124. package/dist/examples/ui/Menu/Menu.d.ts +0 -41
  125. package/dist/examples/ui/Menu/Menu.js +0 -404
  126. package/dist/examples/ui/Menu/MenuDelimiter.d.ts +0 -1
  127. package/dist/examples/ui/Menu/MenuDelimiter.js +0 -6
  128. package/dist/examples/ui/Menu/MenuHotkey.d.ts +0 -6
  129. package/dist/examples/ui/Menu/MenuHotkey.js +0 -12
  130. package/dist/examples/ui/Menu/MenuIcon.d.ts +0 -6
  131. package/dist/examples/ui/Menu/MenuIcon.js +0 -12
  132. package/dist/examples/ui/Menu/MenuItem.d.ts +0 -6
  133. package/dist/examples/ui/Menu/MenuItem.js +0 -17
  134. package/dist/examples/ui/Menu/MenuTitle.d.ts +0 -6
  135. package/dist/examples/ui/Menu/MenuTitle.js +0 -12
  136. package/dist/examples/ui/Menu/SafeSpace.d.ts +0 -6
  137. package/dist/examples/ui/Menu/SafeSpace.js +0 -65
  138. package/dist/examples/ui/Menu/index.d.ts +0 -2
  139. package/dist/examples/ui/Menu/index.js +0 -2
  140. package/dist/examples/ui/Menu/styles.module.js +0 -21
  141. package/dist/examples/ui/Menu/styles_module.css +0 -140
  142. package/dist/examples/ui/Menu/types.d.ts +0 -16
  143. package/dist/examples/ui/Menu/types.js +0 -0
  144. package/dist/examples/ui/useMenuPosition.d.ts +0 -18
  145. package/dist/examples/ui/useMenuPosition.js +0 -51
  146. package/dist/examples/ui/useMergeRefs.d.ts +0 -23
  147. package/dist/examples/ui/useMergeRefs.js +0 -11
  148. package/src/examples/Backdrop.module.css +0 -8
  149. package/src/examples/Backdrop.tsx +0 -16
  150. package/src/examples/CodeBlock.module.css +0 -65
  151. package/src/examples/CodeBlock.tsx +0 -109
  152. package/src/examples/DragBlock.module.css +0 -42
  153. package/src/examples/DragBlock.tsx +0 -57
  154. package/src/examples/DragHandler.module.css +0 -17
  155. package/src/examples/DragHandler.tsx +0 -39
  156. package/src/examples/Editor.module.css +0 -129
  157. package/src/examples/Editor.tsx +0 -68
  158. package/src/examples/Emoji.tsx +0 -9
  159. package/src/examples/EmojiSelector.module.css +0 -35
  160. package/src/examples/EmojiSelector.tsx +0 -115
  161. package/src/examples/FloatingMenu.module.css +0 -74
  162. package/src/examples/FloatingMenu.tsx +0 -278
  163. package/src/examples/LinksHint.module.css +0 -27
  164. package/src/examples/LinksHint.tsx +0 -58
  165. package/src/examples/Menu.module.css +0 -37
  166. package/src/examples/Menu.tsx +0 -94
  167. package/src/examples/colors.ts +0 -11
  168. package/src/examples/getCommands.tsx +0 -92
  169. package/src/examples/getPlugins.tsx +0 -164
  170. package/src/examples/getShortcuts.ts +0 -107
  171. package/src/examples/icons/bold.tsx +0 -20
  172. package/src/examples/icons/check.tsx +0 -19
  173. package/src/examples/icons/chevronRight.tsx +0 -19
  174. package/src/examples/icons/code.tsx +0 -21
  175. package/src/examples/icons/color.tsx +0 -23
  176. package/src/examples/icons/copy.tsx +0 -20
  177. package/src/examples/icons/cross.tsx +0 -20
  178. package/src/examples/icons/drag.tsx +0 -24
  179. package/src/examples/icons/edit.tsx +0 -21
  180. package/src/examples/icons/external.tsx +0 -21
  181. package/src/examples/icons/heading1.tsx +0 -26
  182. package/src/examples/icons/heading2.tsx +0 -26
  183. package/src/examples/icons/heading3.tsx +0 -27
  184. package/src/examples/icons/italic.tsx +0 -21
  185. package/src/examples/icons/link.tsx +0 -21
  186. package/src/examples/icons/ol.tsx +0 -23
  187. package/src/examples/icons/strikethrough.tsx +0 -20
  188. package/src/examples/icons/text.tsx +0 -18
  189. package/src/examples/icons/types.ts +0 -3
  190. package/src/examples/icons/ul.tsx +0 -24
  191. package/src/examples/icons/underline.tsx +0 -20
  192. package/src/examples/store.ts +0 -16
  193. package/src/examples/styles.module.css +0 -77
  194. package/src/examples/text.tsx +0 -138
  195. package/src/examples/ui/Button/Button.tsx +0 -34
  196. package/src/examples/ui/Button/ButtonWrapper.tsx +0 -22
  197. package/src/examples/ui/Button/index.ts +0 -2
  198. package/src/examples/ui/Button/styles.module.css +0 -75
  199. package/src/examples/ui/Button/types.ts +0 -1
  200. package/src/examples/ui/Dropdown/Dropdown.tsx +0 -101
  201. package/src/examples/ui/Dropdown/index.ts +0 -1
  202. package/src/examples/ui/Menu/Menu.tsx +0 -576
  203. package/src/examples/ui/Menu/MenuDelimiter.tsx +0 -3
  204. package/src/examples/ui/Menu/MenuHotkey.tsx +0 -17
  205. package/src/examples/ui/Menu/MenuIcon.tsx +0 -17
  206. package/src/examples/ui/Menu/MenuItem.tsx +0 -45
  207. package/src/examples/ui/Menu/MenuTitle.tsx +0 -17
  208. package/src/examples/ui/Menu/SafeSpace.tsx +0 -84
  209. package/src/examples/ui/Menu/index.ts +0 -2
  210. package/src/examples/ui/Menu/styles.module.css +0 -143
  211. package/src/examples/ui/Menu/types.ts +0 -18
  212. package/src/examples/ui/useMenuPosition.ts +0 -72
  213. package/src/examples/ui/useMergeRefs.ts +0 -39
@@ -1,44 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { HeadingsPlugin, ListsPlugin } from "../plugins/index.js";
3
- import DragHandler_module from "./DragHandler.module.js";
4
- import { DragIcon } from "./icons/drag.js";
5
- const DragHandler = (props)=>{
6
- switch(props.element.type){
7
- case ListsPlugin.LIST_ITEM_ELEMENT:
8
- return /*#__PURE__*/ jsx("div", {
9
- className: DragHandler_module.dragHandler,
10
- children: /*#__PURE__*/ jsx(DragIcon, {
11
- size: 16
12
- })
13
- });
14
- case HeadingsPlugin.HeadingLevel1:
15
- return /*#__PURE__*/ jsx("div", {
16
- className: DragHandler_module.dragHandlerHeading1,
17
- children: /*#__PURE__*/ jsx(DragIcon, {
18
- size: 16
19
- })
20
- });
21
- case HeadingsPlugin.HeadingLevel2:
22
- return /*#__PURE__*/ jsx("div", {
23
- className: DragHandler_module.dragHandlerHeading2,
24
- children: /*#__PURE__*/ jsx(DragIcon, {
25
- size: 16
26
- })
27
- });
28
- case HeadingsPlugin.HeadingLevel3:
29
- return /*#__PURE__*/ jsx("div", {
30
- className: DragHandler_module.dragHandlerHeading3,
31
- children: /*#__PURE__*/ jsx(DragIcon, {
32
- size: 16
33
- })
34
- });
35
- default:
36
- return /*#__PURE__*/ jsx("div", {
37
- className: DragHandler_module.dragHandler,
38
- children: /*#__PURE__*/ jsx(DragIcon, {
39
- size: 16
40
- })
41
- });
42
- }
43
- };
44
- export { DragHandler };
@@ -1,8 +0,0 @@
1
- import "./DragHandler_module.css";
2
- const DragHandler_module = {
3
- dragHandler: "dragHandler-H8B8NE",
4
- dragHandlerHeading1: "dragHandlerHeading1-MaU64L",
5
- dragHandlerHeading2: "dragHandlerHeading2-e8kwqj",
6
- dragHandlerHeading3: "dragHandlerHeading3-Yd2WHq"
7
- };
8
- export { DragHandler_module as default };
@@ -1,18 +0,0 @@
1
- .dragHandler-H8B8NE {
2
- cursor: grab;
3
- position: absolute;
4
- top: 9px;
5
- }
6
-
7
- .dragHandlerHeading1-MaU64L {
8
- top: 10px;
9
- }
10
-
11
- .dragHandlerHeading2-e8kwqj {
12
- top: 8px;
13
- }
14
-
15
- .dragHandlerHeading3-Yd2WHq {
16
- top: 6px;
17
- }
18
-
@@ -1,8 +0,0 @@
1
- import type { Descendant } from 'slate';
2
- type Props = {
3
- initialValueType?: 'kona-editor' | 'html';
4
- value?: any;
5
- onChange?: (value: Descendant[]) => void;
6
- };
7
- export declare const ExampleEditor: import("react").ForwardRefExoticComponent<Props & import("react").RefAttributes<unknown>>;
8
- export {};
@@ -1,44 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from "react";
3
- import { DndProvider } from "react-dnd";
4
- import { HTML5Backend } from "react-dnd-html5-backend";
5
- import { deserialize } from "../core/deserialize.js";
6
- import { serialize } from "../core/serialize.js";
7
- import { KonaEditor } from "../editor.js";
8
- import Editor_module from "./Editor.module.js";
9
- import { getPlugins } from "./getPlugins.js";
10
- import { text as external_text_js_text } from "./text.js";
11
- const initialValue = external_text_js_text;
12
- const ExampleEditor = /*#__PURE__*/ forwardRef((props, ref)=>{
13
- const { value: defaultValue = external_text_js_text, initialValueType = 'kona-editor' } = props;
14
- const [plugins] = useState(getPlugins());
15
- const [value, setValue] = useState(null);
16
- const editorRef = useRef(null);
17
- useImperativeHandle(ref, ()=>({
18
- serialize: serialize(plugins)
19
- }), [
20
- plugins
21
- ]);
22
- useEffect(()=>{
23
- if ('kona-editor' === initialValueType) setValue(defaultValue);
24
- else {
25
- const parsed = deserialize(plugins)(defaultValue);
26
- parsed && setValue(parsed);
27
- }
28
- }, []);
29
- return /*#__PURE__*/ jsx(DndProvider, {
30
- backend: HTML5Backend,
31
- children: /*#__PURE__*/ jsx("div", {
32
- className: [
33
- Editor_module.root
34
- ].join(' '),
35
- children: value && /*#__PURE__*/ jsx(KonaEditor, {
36
- ref: editorRef,
37
- initialValue: value || initialValue,
38
- plugins: plugins,
39
- onChange: props.onChange || console.log
40
- })
41
- })
42
- });
43
- });
44
- export { ExampleEditor };
@@ -1,12 +0,0 @@
1
- import "./Editor_module.css";
2
- const Editor_module = {
3
- root: "root-zl84ra",
4
- button: "button-fdBqbh",
5
- active: "active-xvaPVY",
6
- divider: "divider-XDKye7",
7
- floating: "floating-R_uFiU",
8
- hint: "hint-zEtmE0",
9
- editorToolbar: "editorToolbar-FXIohe",
10
- backdrop: "backdrop-TUV3we"
11
- };
12
- export { Editor_module as default };
@@ -1,127 +0,0 @@
1
- .root-zl84ra {
2
- border: 1px solid var(--kona-editor-border-color);
3
- border-radius: 8px;
4
- width: 600px;
5
- height: calc(100vh - 256px);
6
- max-height: 100vh;
7
- overflow: hidden;
8
- }
9
-
10
- .root-zl84ra {
11
- & [role="textbox"] {
12
- outline: none;
13
- padding: 16px;
14
- }
15
-
16
- & h1 {
17
- font-size: 24px;
18
- font-weight: 600;
19
- }
20
-
21
- & h2 {
22
- font-size: 20px;
23
- font-weight: 600;
24
- }
25
-
26
- & h3 {
27
- font-size: 18px;
28
- font-weight: 600;
29
- }
30
-
31
- & ol {
32
- list-style: decimal;
33
- }
34
-
35
- & ul {
36
- list-style: outside;
37
- }
38
-
39
- & li {
40
- list-style-position: inside;
41
- }
42
- }
43
-
44
- .button-fdBqbh {
45
- cursor: pointer;
46
- width: 24px;
47
- height: 24px;
48
- color: inherit;
49
- background-color: #0000;
50
- border: none;
51
- border-radius: 4px;
52
- outline: none;
53
- justify-content: center;
54
- align-items: center;
55
- margin: 0;
56
- padding: 0;
57
- transition: background-color .25s;
58
- display: inline-flex;
59
- }
60
-
61
- .button-fdBqbh.active-xvaPVY {
62
- background-color: #eee;
63
- }
64
-
65
- .divider-XDKye7 {
66
- background-color: #ccc;
67
- width: 1px;
68
- height: 24px;
69
- display: inline-block;
70
- }
71
-
72
- .floating-R_uFiU {
73
- height: 24px;
74
- }
75
-
76
- .hint-zEtmE0 {
77
- background-color: var(--background-color);
78
- color: var(--text-color);
79
- border: 1px solid var(--border-color);
80
- border-radius: 4px;
81
- padding: 2px;
82
- }
83
-
84
- .editorToolbar-FXIohe {
85
- background-color: #f9f9f9;
86
- justify-content: space-between;
87
- column-gap: 4px;
88
- padding: 8px;
89
- display: flex;
90
-
91
- & select {
92
- color: inherit;
93
- background-color: #fff;
94
- border: 1px solid #ddd;
95
- border-radius: 4px;
96
- outline: none;
97
- padding: 4px;
98
- }
99
-
100
- & button {
101
- cursor: pointer;
102
- color: inherit;
103
- background-color: #fff;
104
- border: 1px solid #ddd;
105
- border-radius: 4px;
106
- outline: none;
107
- align-items: center;
108
- padding: 4px;
109
- display: inline-flex;
110
- }
111
- }
112
-
113
- .backdrop-TUV3we {
114
- z-index: 1;
115
- position: fixed;
116
- inset: 0;
117
- }
118
-
119
- .hint-zEtmE0 {
120
- color: #444;
121
- background-color: #fff;
122
- border: 1px solid #ccc;
123
- border-radius: 4px;
124
- padding: 2px;
125
- box-shadow: 0 1px 3px #0000000f;
126
- }
127
-
@@ -1,5 +0,0 @@
1
- type Props = {
2
- id: string;
3
- };
4
- export declare const Emoji: (props: Props) => import("react/jsx-runtime").JSX.Element;
5
- export {};
@@ -1,8 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import EmojiSelector_module from "./EmojiSelector.module.js";
3
- const Emoji = (props)=>/*#__PURE__*/ jsx("em-emoji", {
4
- class: EmojiSelector_module.emoji,
5
- id: props.id,
6
- size: "16px"
7
- });
8
- export { Emoji };
@@ -1,16 +0,0 @@
1
- declare module 'react/jsx-runtime' {
2
- namespace JSX {
3
- interface IntrinsicElements {
4
- 'em-emoji': {
5
- id: string;
6
- size: string | number;
7
- class?: string;
8
- };
9
- }
10
- }
11
- }
12
- type Props = {
13
- onConfirm: (emoji: any, query: any, editor: any) => void;
14
- };
15
- export declare const EmojiSelector: (props: Props) => import("react/jsx-runtime").JSX.Element | null;
16
- export {};
@@ -1,91 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import data from "@emoji-mart/data";
3
- import { useStore } from "@nanostores/react";
4
- import clsx from "clsx";
5
- import { SearchIndex, init } from "emoji-mart";
6
- import { useEffect, useState } from "react";
7
- import { useSlateStatic } from "slate-react";
8
- import EmojiSelector_module from "./EmojiSelector.module.js";
9
- import { $store } from "./store.js";
10
- init({
11
- data: data,
12
- set: 'apple',
13
- custom: [
14
- {
15
- id: 'custom',
16
- name: 'Custom',
17
- emojis: [
18
- {
19
- id: 'kona',
20
- name: 'Kona',
21
- keywords: [
22
- 'kona'
23
- ],
24
- skins: [
25
- {
26
- src: '/kona.svg'
27
- }
28
- ]
29
- }
30
- ]
31
- }
32
- ]
33
- });
34
- const EmojiSelector = (props)=>{
35
- const { onConfirm } = props;
36
- const editor = useSlateStatic();
37
- const { emojiSearch } = useStore($store);
38
- const [index, setIndex] = useState(-1);
39
- const [items, setItems] = useState([]);
40
- useEffect(()=>{
41
- const search = async ()=>{
42
- const emojis = await SearchIndex.search(emojiSearch);
43
- setItems(emojis.slice(0, 10));
44
- setIndex(0);
45
- };
46
- search();
47
- }, [
48
- emojiSearch
49
- ]);
50
- useEffect(()=>{
51
- const handleKeyDown = (event)=>{
52
- switch(event.key){
53
- case 'ArrowRight':
54
- event.preventDefault();
55
- setIndex((index)=>(index + 1) % items.length);
56
- break;
57
- case 'ArrowLeft':
58
- event.preventDefault();
59
- setIndex((index)=>(index - 1 + items.length) % items.length);
60
- break;
61
- case 'Enter':
62
- event.preventDefault();
63
- onConfirm(items[index]?.id, emojiSearch, editor);
64
- break;
65
- }
66
- };
67
- document.addEventListener('keydown', handleKeyDown, true);
68
- return ()=>{
69
- document.removeEventListener('keydown', handleKeyDown, true);
70
- };
71
- }, [
72
- items,
73
- index,
74
- emojiSearch
75
- ]);
76
- if (!items.length) return null;
77
- return /*#__PURE__*/ jsx("div", {
78
- className: EmojiSelector_module.root,
79
- children: items.map((item, idx)=>/*#__PURE__*/ jsx("span", {
80
- className: clsx(EmojiSelector_module.emoji, {
81
- [EmojiSelector_module.selected]: idx === index
82
- }),
83
- children: /*#__PURE__*/ jsx("em-emoji", {
84
- class: EmojiSelector_module.emoji,
85
- id: item.id,
86
- size: "20px"
87
- })
88
- }, item.id))
89
- });
90
- };
91
- export { EmojiSelector };
@@ -1,7 +0,0 @@
1
- import "./EmojiSelector_module.css";
2
- const EmojiSelector_module = {
3
- root: "root-f7KjwY",
4
- emoji: "emoji-kNlwVt",
5
- selected: "selected-ONnfU2"
6
- };
7
- export { EmojiSelector_module as default };
@@ -1,36 +0,0 @@
1
- .root-f7KjwY {
2
- background-color: var(--kona-editor-background-color);
3
- border: 1px solid var(--kona-editor-border-color);
4
- border-radius: 8px;
5
- gap: 4px;
6
- padding: 4px;
7
- display: flex;
8
- }
9
-
10
- .emoji-kNlwVt {
11
- cursor: pointer;
12
- vertical-align: text-bottom;
13
- border-radius: 4px;
14
- justify-content: center;
15
- align-items: center;
16
- width: 24px;
17
- height: 24px;
18
- display: inline-flex;
19
-
20
- & span {
21
- justify-content: center;
22
- align-items: center;
23
- width: 20px;
24
- height: 20px;
25
- display: inline-flex;
26
- }
27
-
28
- &:hover {
29
- background-color: var(--kona-editor-alt-background-color);
30
- }
31
- }
32
-
33
- .selected-ONnfU2 {
34
- background-color: var(--kona-editor-alt-background-color);
35
- }
36
-
@@ -1,19 +0,0 @@
1
- import type { MapStore } from 'nanostores';
2
- import type { Editor } from 'slate';
3
- type Mode = 'main' | 'link' | 'colors';
4
- type Props = {
5
- $store: MapStore<{
6
- isFloatingMenuOpen: boolean;
7
- floatingMenuMode: Mode;
8
- url?: string;
9
- } & {
10
- [key: string]: unknown;
11
- }>;
12
- editor: Editor;
13
- commands: {
14
- onClose: () => void;
15
- onUpdate: () => void;
16
- };
17
- };
18
- export declare const FloatingMenu: (props: Props) => import("react/jsx-runtime").JSX.Element;
19
- export {};