@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.
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -2
- package/dist/plugins/CodeBlockPlugin/index.d.ts +1 -0
- package/dist/plugins/FloatingMenuPlugin/FloatingMenu.js +15 -28
- package/dist/plugins/FloatingMenuPlugin/types.d.ts +4 -1
- package/dist/plugins/HighlightsPlugin/HighlightsPlugin.d.ts +1 -0
- package/dist/plugins/HighlightsPlugin/HighlightsPlugin.js +3 -0
- package/dist/plugins/index.d.ts +1 -1
- package/package.json +12 -11
- package/src/index.ts +0 -1
- package/src/plugins/CodeBlockPlugin/index.ts +1 -0
- package/src/plugins/FloatingMenuPlugin/FloatingMenu.tsx +13 -22
- package/src/plugins/FloatingMenuPlugin/types.ts +4 -1
- package/src/plugins/HighlightsPlugin/HighlightsPlugin.tsx +4 -0
- package/src/plugins/index.ts +1 -1
- package/dist/examples/Backdrop.d.ts +0 -5
- package/dist/examples/Backdrop.js +0 -13
- package/dist/examples/Backdrop.module.js +0 -5
- package/dist/examples/Backdrop_module.css +0 -6
- package/dist/examples/CodeBlock.d.ts +0 -12
- package/dist/examples/CodeBlock.js +0 -163
- package/dist/examples/CodeBlock.module.js +0 -9
- package/dist/examples/CodeBlock_module.css +0 -66
- package/dist/examples/DragBlock.d.ts +0 -11
- package/dist/examples/DragBlock.js +0 -38
- package/dist/examples/DragBlock.module.js +0 -9
- package/dist/examples/DragBlock_module.css +0 -43
- package/dist/examples/DragHandler.d.ts +0 -2
- package/dist/examples/DragHandler.js +0 -44
- package/dist/examples/DragHandler.module.js +0 -8
- package/dist/examples/DragHandler_module.css +0 -18
- package/dist/examples/Editor.d.ts +0 -8
- package/dist/examples/Editor.js +0 -44
- package/dist/examples/Editor.module.js +0 -12
- package/dist/examples/Editor_module.css +0 -127
- package/dist/examples/Emoji.d.ts +0 -5
- package/dist/examples/Emoji.js +0 -8
- package/dist/examples/EmojiSelector.d.ts +0 -16
- package/dist/examples/EmojiSelector.js +0 -91
- package/dist/examples/EmojiSelector.module.js +0 -7
- package/dist/examples/EmojiSelector_module.css +0 -36
- package/dist/examples/FloatingMenu.d.ts +0 -19
- package/dist/examples/FloatingMenu.js +0 -244
- package/dist/examples/FloatingMenu.module.js +0 -9
- package/dist/examples/FloatingMenu_module.css +0 -75
- package/dist/examples/LinksHint.d.ts +0 -7
- package/dist/examples/LinksHint.js +0 -50
- package/dist/examples/LinksHint.module.js +0 -6
- package/dist/examples/LinksHint_module.css +0 -28
- package/dist/examples/Menu.d.ts +0 -6
- package/dist/examples/Menu.js +0 -94
- package/dist/examples/Menu.module.js +0 -8
- package/dist/examples/Menu_module.css +0 -38
- package/dist/examples/colors.d.ts +0 -10
- package/dist/examples/colors.js +0 -12
- package/dist/examples/getCommands.d.ts +0 -2
- package/dist/examples/getCommands.js +0 -100
- package/dist/examples/getPlugins.d.ts +0 -2
- package/dist/examples/getPlugins.js +0 -144
- package/dist/examples/getShortcuts.d.ts +0 -2
- package/dist/examples/getShortcuts.js +0 -90
- package/dist/examples/icons/bold.d.ts +0 -2
- package/dist/examples/icons/bold.js +0 -27
- package/dist/examples/icons/check.d.ts +0 -2
- package/dist/examples/icons/check.js +0 -24
- package/dist/examples/icons/chevronRight.d.ts +0 -2
- package/dist/examples/icons/chevronRight.js +0 -24
- package/dist/examples/icons/code.d.ts +0 -2
- package/dist/examples/icons/code.js +0 -30
- package/dist/examples/icons/color.d.ts +0 -2
- package/dist/examples/icons/color.js +0 -30
- package/dist/examples/icons/copy.d.ts +0 -2
- package/dist/examples/icons/copy.js +0 -27
- package/dist/examples/icons/cross.d.ts +0 -2
- package/dist/examples/icons/cross.js +0 -27
- package/dist/examples/icons/drag.d.ts +0 -2
- package/dist/examples/icons/drag.js +0 -39
- package/dist/examples/icons/edit.d.ts +0 -2
- package/dist/examples/icons/edit.js +0 -30
- package/dist/examples/icons/external.d.ts +0 -2
- package/dist/examples/icons/external.js +0 -30
- package/dist/examples/icons/heading1.d.ts +0 -2
- package/dist/examples/icons/heading1.js +0 -45
- package/dist/examples/icons/heading2.d.ts +0 -2
- package/dist/examples/icons/heading2.js +0 -45
- package/dist/examples/icons/heading3.d.ts +0 -2
- package/dist/examples/icons/heading3.js +0 -48
- package/dist/examples/icons/italic.d.ts +0 -2
- package/dist/examples/icons/italic.js +0 -30
- package/dist/examples/icons/link.d.ts +0 -2
- package/dist/examples/icons/link.js +0 -30
- package/dist/examples/icons/ol.d.ts +0 -2
- package/dist/examples/icons/ol.js +0 -36
- package/dist/examples/icons/strikethrough.d.ts +0 -2
- package/dist/examples/icons/strikethrough.js +0 -27
- package/dist/examples/icons/text.d.ts +0 -2
- package/dist/examples/icons/text.js +0 -22
- package/dist/examples/icons/types.d.ts +0 -3
- package/dist/examples/icons/types.js +0 -0
- package/dist/examples/icons/ul.d.ts +0 -2
- package/dist/examples/icons/ul.js +0 -39
- package/dist/examples/icons/underline.d.ts +0 -2
- package/dist/examples/icons/underline.js +0 -27
- package/dist/examples/store.d.ts +0 -9
- package/dist/examples/store.js +0 -7
- package/dist/examples/styles.module.js +0 -11
- package/dist/examples/styles_module.css +0 -78
- package/dist/examples/text.d.ts +0 -3
- package/dist/examples/text.js +0 -65
- package/dist/examples/ui/Button/Button.d.ts +0 -8
- package/dist/examples/ui/Button/Button.js +0 -15
- package/dist/examples/ui/Button/ButtonWrapper.d.ts +0 -4
- package/dist/examples/ui/Button/ButtonWrapper.js +0 -14
- package/dist/examples/ui/Button/index.d.ts +0 -2
- package/dist/examples/ui/Button/index.js +0 -3
- package/dist/examples/ui/Button/styles.module.js +0 -10
- package/dist/examples/ui/Button/styles_module.css +0 -72
- package/dist/examples/ui/Button/types.d.ts +0 -1
- package/dist/examples/ui/Button/types.js +0 -0
- package/dist/examples/ui/Dropdown/Dropdown.d.ts +0 -16
- package/dist/examples/ui/Dropdown/Dropdown.js +0 -75
- package/dist/examples/ui/Dropdown/index.d.ts +0 -1
- package/dist/examples/ui/Dropdown/index.js +0 -2
- package/dist/examples/ui/Menu/Menu.d.ts +0 -41
- package/dist/examples/ui/Menu/Menu.js +0 -404
- package/dist/examples/ui/Menu/MenuDelimiter.d.ts +0 -1
- package/dist/examples/ui/Menu/MenuDelimiter.js +0 -6
- package/dist/examples/ui/Menu/MenuHotkey.d.ts +0 -6
- package/dist/examples/ui/Menu/MenuHotkey.js +0 -12
- package/dist/examples/ui/Menu/MenuIcon.d.ts +0 -6
- package/dist/examples/ui/Menu/MenuIcon.js +0 -12
- package/dist/examples/ui/Menu/MenuItem.d.ts +0 -6
- package/dist/examples/ui/Menu/MenuItem.js +0 -17
- package/dist/examples/ui/Menu/MenuTitle.d.ts +0 -6
- package/dist/examples/ui/Menu/MenuTitle.js +0 -12
- package/dist/examples/ui/Menu/SafeSpace.d.ts +0 -6
- package/dist/examples/ui/Menu/SafeSpace.js +0 -65
- package/dist/examples/ui/Menu/index.d.ts +0 -2
- package/dist/examples/ui/Menu/index.js +0 -2
- package/dist/examples/ui/Menu/styles.module.js +0 -21
- package/dist/examples/ui/Menu/styles_module.css +0 -140
- package/dist/examples/ui/Menu/types.d.ts +0 -16
- package/dist/examples/ui/Menu/types.js +0 -0
- package/dist/examples/ui/useMenuPosition.d.ts +0 -18
- package/dist/examples/ui/useMenuPosition.js +0 -51
- package/dist/examples/ui/useMergeRefs.d.ts +0 -23
- package/dist/examples/ui/useMergeRefs.js +0 -11
- package/src/examples/Backdrop.module.css +0 -8
- package/src/examples/Backdrop.tsx +0 -16
- package/src/examples/CodeBlock.module.css +0 -65
- package/src/examples/CodeBlock.tsx +0 -109
- package/src/examples/DragBlock.module.css +0 -42
- package/src/examples/DragBlock.tsx +0 -57
- package/src/examples/DragHandler.module.css +0 -17
- package/src/examples/DragHandler.tsx +0 -39
- package/src/examples/Editor.module.css +0 -129
- package/src/examples/Editor.tsx +0 -68
- package/src/examples/Emoji.tsx +0 -9
- package/src/examples/EmojiSelector.module.css +0 -35
- package/src/examples/EmojiSelector.tsx +0 -115
- package/src/examples/FloatingMenu.module.css +0 -74
- package/src/examples/FloatingMenu.tsx +0 -278
- package/src/examples/LinksHint.module.css +0 -27
- package/src/examples/LinksHint.tsx +0 -58
- package/src/examples/Menu.module.css +0 -37
- package/src/examples/Menu.tsx +0 -94
- package/src/examples/colors.ts +0 -11
- package/src/examples/getCommands.tsx +0 -92
- package/src/examples/getPlugins.tsx +0 -164
- package/src/examples/getShortcuts.ts +0 -107
- package/src/examples/icons/bold.tsx +0 -20
- package/src/examples/icons/check.tsx +0 -19
- package/src/examples/icons/chevronRight.tsx +0 -19
- package/src/examples/icons/code.tsx +0 -21
- package/src/examples/icons/color.tsx +0 -23
- package/src/examples/icons/copy.tsx +0 -20
- package/src/examples/icons/cross.tsx +0 -20
- package/src/examples/icons/drag.tsx +0 -24
- package/src/examples/icons/edit.tsx +0 -21
- package/src/examples/icons/external.tsx +0 -21
- package/src/examples/icons/heading1.tsx +0 -26
- package/src/examples/icons/heading2.tsx +0 -26
- package/src/examples/icons/heading3.tsx +0 -27
- package/src/examples/icons/italic.tsx +0 -21
- package/src/examples/icons/link.tsx +0 -21
- package/src/examples/icons/ol.tsx +0 -23
- package/src/examples/icons/strikethrough.tsx +0 -20
- package/src/examples/icons/text.tsx +0 -18
- package/src/examples/icons/types.ts +0 -3
- package/src/examples/icons/ul.tsx +0 -24
- package/src/examples/icons/underline.tsx +0 -20
- package/src/examples/store.ts +0 -16
- package/src/examples/styles.module.css +0 -77
- package/src/examples/text.tsx +0 -138
- package/src/examples/ui/Button/Button.tsx +0 -34
- package/src/examples/ui/Button/ButtonWrapper.tsx +0 -22
- package/src/examples/ui/Button/index.ts +0 -2
- package/src/examples/ui/Button/styles.module.css +0 -75
- package/src/examples/ui/Button/types.ts +0 -1
- package/src/examples/ui/Dropdown/Dropdown.tsx +0 -101
- package/src/examples/ui/Dropdown/index.ts +0 -1
- package/src/examples/ui/Menu/Menu.tsx +0 -576
- package/src/examples/ui/Menu/MenuDelimiter.tsx +0 -3
- package/src/examples/ui/Menu/MenuHotkey.tsx +0 -17
- package/src/examples/ui/Menu/MenuIcon.tsx +0 -17
- package/src/examples/ui/Menu/MenuItem.tsx +0 -45
- package/src/examples/ui/Menu/MenuTitle.tsx +0 -17
- package/src/examples/ui/Menu/SafeSpace.tsx +0 -84
- package/src/examples/ui/Menu/index.ts +0 -2
- package/src/examples/ui/Menu/styles.module.css +0 -143
- package/src/examples/ui/Menu/types.ts +0 -18
- package/src/examples/ui/useMenuPosition.ts +0 -72
- package/src/examples/ui/useMergeRefs.ts +0 -39
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ export { deserialize } from './core/deserialize';
|
|
|
3
3
|
export { serialize } from './core/serialize';
|
|
4
4
|
export { defaultValue } from './defaultValue';
|
|
5
5
|
export * from './editor';
|
|
6
|
-
export { ExampleEditor } from './examples/Editor';
|
|
7
6
|
export * from './plugins';
|
|
8
7
|
export type { EditorRef, IPlugin } from './types';
|
|
9
8
|
export { isEmpty } from './utils';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { deserialize } from "./core/deserialize.js";
|
|
2
2
|
import { serialize } from "./core/serialize.js";
|
|
3
3
|
import { defaultValue } from "./defaultValue.js";
|
|
4
|
-
import { ExampleEditor } from "./examples/Editor.js";
|
|
5
4
|
import { isEmpty } from "./utils.js";
|
|
6
5
|
export * from "./editor.js";
|
|
7
6
|
export * from "./plugins/index.js";
|
|
8
|
-
export {
|
|
7
|
+
export { defaultValue, deserialize, isEmpty, serialize };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { createPortal } from "react-dom";
|
|
4
4
|
import { Editor, Range } from "slate";
|
|
@@ -57,33 +57,20 @@ const FloatingMenu = (props)=>{
|
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
if (!isVisible) return null;
|
|
60
|
-
return /*#__PURE__*/ createPortal(/*#__PURE__*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
...style,
|
|
75
|
-
display: 'block'
|
|
76
|
-
},
|
|
77
|
-
className: styles_module.root,
|
|
78
|
-
onMouseDown: (event)=>{
|
|
79
|
-
event.preventDefault();
|
|
80
|
-
},
|
|
81
|
-
children: options.renderMenu(editor, {
|
|
82
|
-
onClose,
|
|
83
|
-
onUpdate: handleUpdate
|
|
84
|
-
})
|
|
85
|
-
})
|
|
86
|
-
]
|
|
60
|
+
return /*#__PURE__*/ createPortal(/*#__PURE__*/ jsx("div", {
|
|
61
|
+
ref: ref,
|
|
62
|
+
style: {
|
|
63
|
+
...style,
|
|
64
|
+
display: 'block'
|
|
65
|
+
},
|
|
66
|
+
className: styles_module.root,
|
|
67
|
+
onMouseDown: (event)=>{
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
},
|
|
70
|
+
children: options.renderMenu(editor, {
|
|
71
|
+
onClose,
|
|
72
|
+
onUpdate: handleUpdate
|
|
73
|
+
})
|
|
87
74
|
}), document.body);
|
|
88
75
|
};
|
|
89
76
|
export { FloatingMenu };
|
|
@@ -3,7 +3,10 @@ import type { Editor } from 'slate';
|
|
|
3
3
|
export type Options = {
|
|
4
4
|
ignoreNodes?: string[];
|
|
5
5
|
renderMenu: (editor: Editor, commands: Commands) => ReactNode;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated
|
|
8
|
+
*/
|
|
9
|
+
renderBackdrop?: (commands: {
|
|
7
10
|
onClose: () => void;
|
|
8
11
|
onUpdate: () => void;
|
|
9
12
|
}) => ReactNode;
|
|
@@ -9,6 +9,7 @@ export declare class HighlightsPlugin implements IPlugin {
|
|
|
9
9
|
constructor(options: Options);
|
|
10
10
|
static toggleHighlight(editor: Editor, color: string): void;
|
|
11
11
|
static isHighlightActive(editor: Editor, color: string): boolean;
|
|
12
|
+
static removeHighlight(editor: Editor): void;
|
|
12
13
|
leafs: {
|
|
13
14
|
render: (props: RenderLeafProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
15
|
}[];
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AttachmentsPlugin } from './AttachmentsPlugin';
|
|
2
2
|
export { BasicFormattingPlugin } from './BasicFormattingPlugin';
|
|
3
3
|
export { BreaksPlugin } from './BreaksPlugin';
|
|
4
|
-
export { CodeBlockPlugin } from './CodeBlockPlugin';
|
|
4
|
+
export { CodeBlockPlugin, type CodeElement } from './CodeBlockPlugin';
|
|
5
5
|
export { type Command, CommandsPlugin } from './CommandsPlugin';
|
|
6
6
|
export { DnDPlugin } from './DnDPlugin';
|
|
7
7
|
export { EmojiPlugin } from './EmojiPlugin';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@use-kona/editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./src/index.ts"
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@biomejs/biome": "2.0.0",
|
|
25
|
-
"@emoji-mart/data": "^1.2.1",
|
|
26
|
-
"@emoji-mart/react": "^1.1.1",
|
|
27
25
|
"@rsbuild/core": "~1.4.0",
|
|
28
26
|
"@rsbuild/plugin-react": "^1.3.2",
|
|
29
27
|
"@rslib/core": "^0.10.4",
|
|
@@ -41,7 +39,6 @@
|
|
|
41
39
|
"@types/is-url": "^1.2.32",
|
|
42
40
|
"@types/react": "^19.1.8",
|
|
43
41
|
"@types/react-dom": "18",
|
|
44
|
-
"emoji-mart": "^5.6.0",
|
|
45
42
|
"jsdom": "^26.1.0",
|
|
46
43
|
"react": "^18.3.1",
|
|
47
44
|
"react-dnd": "^16.0.1",
|
|
@@ -51,13 +48,21 @@
|
|
|
51
48
|
"storybook-addon-rslib": "^2.0.2",
|
|
52
49
|
"storybook-react-rsbuild": "^2.0.2",
|
|
53
50
|
"typescript": "^5.8.3",
|
|
54
|
-
"vitest": "^3.2.4"
|
|
51
|
+
"vitest": "^3.2.4",
|
|
52
|
+
"slate": "^0.117.2",
|
|
53
|
+
"slate-history": "^0.113.1",
|
|
54
|
+
"slate-hyperscript": "^0.100.0",
|
|
55
|
+
"slate-react": "^0.117.3"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"react": ">=16.9.0",
|
|
58
59
|
"react-dnd": "^16.0.1",
|
|
59
60
|
"react-dnd-html5-backend": "^16.0.1",
|
|
60
|
-
"react-dom": "18"
|
|
61
|
+
"react-dom": "18",
|
|
62
|
+
"slate": "^0.117.2",
|
|
63
|
+
"slate-history": "^0.113.1",
|
|
64
|
+
"slate-hyperscript": "^0.100.0",
|
|
65
|
+
"slate-react": "^0.117.3"
|
|
61
66
|
},
|
|
62
67
|
"dependencies": {
|
|
63
68
|
"@nanostores/react": "^1.0.0",
|
|
@@ -66,10 +71,6 @@
|
|
|
66
71
|
"is-hotkey": "^0.2.0",
|
|
67
72
|
"is-url": "^1.2.4",
|
|
68
73
|
"nanostores": "^1.0.1",
|
|
69
|
-
"prismjs": "^1.30.0"
|
|
70
|
-
"slate": "^0.117.2",
|
|
71
|
-
"slate-history": "^0.113.1",
|
|
72
|
-
"slate-hyperscript": "^0.100.0",
|
|
73
|
-
"slate-react": "^0.117.3"
|
|
74
|
+
"prismjs": "^1.30.0"
|
|
74
75
|
}
|
|
75
76
|
}
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,6 @@ export { deserialize } from './core/deserialize';
|
|
|
3
3
|
export { serialize } from './core/serialize';
|
|
4
4
|
export { defaultValue } from './defaultValue';
|
|
5
5
|
export * from './editor';
|
|
6
|
-
export { ExampleEditor } from './examples/Editor';
|
|
7
6
|
export * from './plugins';
|
|
8
7
|
export type { EditorRef, IPlugin } from './types';
|
|
9
8
|
export { isEmpty } from './utils';
|
|
@@ -117,28 +117,19 @@ export const FloatingMenu = (props: Props) => {
|
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
return createPortal(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}}
|
|
134
|
-
className={styles.root}
|
|
135
|
-
onMouseDown={(event) => {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
}}
|
|
138
|
-
>
|
|
139
|
-
{options.renderMenu(editor, { onClose, onUpdate: handleUpdate })}
|
|
140
|
-
</div>
|
|
141
|
-
</>,
|
|
120
|
+
<div
|
|
121
|
+
ref={ref}
|
|
122
|
+
style={{
|
|
123
|
+
...style,
|
|
124
|
+
display: 'block',
|
|
125
|
+
}}
|
|
126
|
+
className={styles.root}
|
|
127
|
+
onMouseDown={(event) => {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
{options.renderMenu(editor, { onClose, onUpdate: handleUpdate })}
|
|
132
|
+
</div>,
|
|
142
133
|
document.body,
|
|
143
134
|
);
|
|
144
135
|
};
|
|
@@ -4,7 +4,10 @@ import type { Editor } from 'slate';
|
|
|
4
4
|
export type Options = {
|
|
5
5
|
ignoreNodes?: string[];
|
|
6
6
|
renderMenu: (editor: Editor, commands: Commands) => ReactNode;
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated
|
|
9
|
+
*/
|
|
10
|
+
renderBackdrop?: (commands: {
|
|
8
11
|
onClose: () => void;
|
|
9
12
|
onUpdate: () => void;
|
|
10
13
|
}) => ReactNode;
|
|
@@ -27,6 +27,10 @@ export class HighlightsPlugin implements IPlugin {
|
|
|
27
27
|
return marks ? marks.highlight === color : false;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
static removeHighlight(editor: Editor) {
|
|
31
|
+
Editor.removeMark(editor, 'highlight');
|
|
32
|
+
}
|
|
33
|
+
|
|
30
34
|
leafs = [
|
|
31
35
|
{
|
|
32
36
|
render: (props: RenderLeafProps) => {
|
package/src/plugins/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { AttachmentsPlugin } from './AttachmentsPlugin';
|
|
2
2
|
export { BasicFormattingPlugin } from './BasicFormattingPlugin';
|
|
3
3
|
export { BreaksPlugin } from './BreaksPlugin';
|
|
4
|
-
export { CodeBlockPlugin } from './CodeBlockPlugin';
|
|
4
|
+
export { CodeBlockPlugin, type CodeElement } from './CodeBlockPlugin';
|
|
5
5
|
export { type Command, CommandsPlugin } from './CommandsPlugin';
|
|
6
6
|
export { DnDPlugin } from './DnDPlugin';
|
|
7
7
|
export { EmojiPlugin } from './EmojiPlugin';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useStore } from "@nanostores/react";
|
|
3
|
-
import Backdrop_module from "./Backdrop.module.js";
|
|
4
|
-
import { $store } from "./store.js";
|
|
5
|
-
const Backdrop = (props)=>{
|
|
6
|
-
const { isFloatingMenuOpen } = useStore($store);
|
|
7
|
-
const { onClose } = props;
|
|
8
|
-
return isFloatingMenuOpen ? /*#__PURE__*/ jsx("div", {
|
|
9
|
-
className: Backdrop_module.root,
|
|
10
|
-
onClick: onClose
|
|
11
|
-
}) : null;
|
|
12
|
-
};
|
|
13
|
-
export { Backdrop };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
2
|
-
import type { CustomElement } from '../../types';
|
|
3
|
-
type Props = {
|
|
4
|
-
value: string;
|
|
5
|
-
onChange: (value: string) => void;
|
|
6
|
-
params: {
|
|
7
|
-
element: CustomElement;
|
|
8
|
-
Content: () => ReactNode;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export declare const CodeBlock: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useMemo } from "react";
|
|
3
|
-
import { Node } from "slate";
|
|
4
|
-
import CodeBlock_module from "./CodeBlock.module.js";
|
|
5
|
-
import { CheckIcon } from "./icons/check.js";
|
|
6
|
-
import { CopyIcon } from "./icons/copy.js";
|
|
7
|
-
import { Button } from "./ui/Button/index.js";
|
|
8
|
-
import { Dropdown } from "./ui/Dropdown/index.js";
|
|
9
|
-
import { Menu } from "./ui/Menu/index.js";
|
|
10
|
-
const languages = [
|
|
11
|
-
{
|
|
12
|
-
value: "javascript",
|
|
13
|
-
label: 'JavaScript'
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
value: "typescript",
|
|
17
|
-
label: 'TypeScript'
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
value: 'jsx',
|
|
21
|
-
label: 'JSX'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
value: 'tsx',
|
|
25
|
-
label: 'TSX'
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
value: 'html',
|
|
29
|
-
label: 'HTML'
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
value: 'css',
|
|
33
|
-
label: 'CSS'
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
value: 'json',
|
|
37
|
-
label: 'JSON'
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
value: 'python',
|
|
41
|
-
label: 'Python'
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
value: 'java',
|
|
45
|
-
label: 'Java'
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
value: 'c',
|
|
49
|
-
label: 'C'
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
value: 'cpp',
|
|
53
|
-
label: 'C++'
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
value: 'csharp',
|
|
57
|
-
label: 'C#'
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
value: 'go',
|
|
61
|
-
label: 'Go'
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
value: 'rust',
|
|
65
|
-
label: 'Rust'
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
value: 'ruby',
|
|
69
|
-
label: 'Ruby'
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
value: 'php',
|
|
73
|
-
label: 'PHP'
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
value: 'bash',
|
|
77
|
-
label: 'Bash'
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
value: 'sql',
|
|
81
|
-
label: 'SQL'
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
value: 'markdown',
|
|
85
|
-
label: 'Markdown'
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
value: 'yaml',
|
|
89
|
-
label: 'YAML'
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
value: 'plaintext',
|
|
93
|
-
label: 'Plain Text'
|
|
94
|
-
}
|
|
95
|
-
];
|
|
96
|
-
const CodeBlock = (props)=>{
|
|
97
|
-
const { value: language, onChange, params: { element, Content } } = props;
|
|
98
|
-
const handleCopyClick = ()=>{
|
|
99
|
-
const text = Array.from(Node.texts(element)).map((nodeEntry)=>nodeEntry[0].text).join('\n');
|
|
100
|
-
navigator.clipboard.writeText(text);
|
|
101
|
-
};
|
|
102
|
-
const menuConfig = useMemo(()=>({
|
|
103
|
-
items: languages.map(({ label, value })=>({
|
|
104
|
-
render: ()=>/*#__PURE__*/ jsxs(Fragment, {
|
|
105
|
-
children: [
|
|
106
|
-
/*#__PURE__*/ jsx(Menu.Icon, {
|
|
107
|
-
children: value === language && /*#__PURE__*/ jsx(CheckIcon, {
|
|
108
|
-
size: 16
|
|
109
|
-
})
|
|
110
|
-
}),
|
|
111
|
-
/*#__PURE__*/ jsx(Menu.Title, {
|
|
112
|
-
children: label
|
|
113
|
-
})
|
|
114
|
-
]
|
|
115
|
-
}),
|
|
116
|
-
onSelect: ()=>{
|
|
117
|
-
onChange(value);
|
|
118
|
-
}
|
|
119
|
-
}))
|
|
120
|
-
}), [
|
|
121
|
-
language
|
|
122
|
-
]);
|
|
123
|
-
return /*#__PURE__*/ jsxs("div", {
|
|
124
|
-
className: CodeBlock_module.root,
|
|
125
|
-
children: [
|
|
126
|
-
/*#__PURE__*/ jsxs("div", {
|
|
127
|
-
className: CodeBlock_module.menu,
|
|
128
|
-
children: [
|
|
129
|
-
/*#__PURE__*/ jsx(Dropdown, {
|
|
130
|
-
config: menuConfig,
|
|
131
|
-
Menu: /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ jsx("div", {
|
|
132
|
-
...props,
|
|
133
|
-
ref: ref,
|
|
134
|
-
className: [
|
|
135
|
-
CodeBlock_module.customMenu,
|
|
136
|
-
props.className
|
|
137
|
-
].join(' ')
|
|
138
|
-
})),
|
|
139
|
-
children: ({ ref, onClick })=>/*#__PURE__*/ jsx(Button, {
|
|
140
|
-
ref: ref,
|
|
141
|
-
size: "sm",
|
|
142
|
-
onClick: onClick,
|
|
143
|
-
children: languages.find((l)=>l.value === language)?.label || 'Select language'
|
|
144
|
-
})
|
|
145
|
-
}),
|
|
146
|
-
/*#__PURE__*/ jsx(Button, {
|
|
147
|
-
size: "sm",
|
|
148
|
-
type: "button",
|
|
149
|
-
onClick: handleCopyClick,
|
|
150
|
-
children: /*#__PURE__*/ jsx(CopyIcon, {
|
|
151
|
-
size: 16
|
|
152
|
-
})
|
|
153
|
-
})
|
|
154
|
-
]
|
|
155
|
-
}),
|
|
156
|
-
/*#__PURE__*/ jsx("div", {
|
|
157
|
-
className: CodeBlock_module.content,
|
|
158
|
-
children: /*#__PURE__*/ jsx(Content, {})
|
|
159
|
-
})
|
|
160
|
-
]
|
|
161
|
-
});
|
|
162
|
-
};
|
|
163
|
-
export { CodeBlock };
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
.root-qalHKY {
|
|
2
|
-
background-color: var(--kona-editor-alt-background-color);
|
|
3
|
-
border-radius: 8px;
|
|
4
|
-
flex-direction: column;
|
|
5
|
-
padding: 4px;
|
|
6
|
-
display: flex;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.button-NFVN8i {
|
|
10
|
-
cursor: pointer;
|
|
11
|
-
background-color: #0000;
|
|
12
|
-
border-radius: 4px;
|
|
13
|
-
outline: none;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
align-items: center;
|
|
16
|
-
width: 20px;
|
|
17
|
-
height: 20px;
|
|
18
|
-
margin: 0;
|
|
19
|
-
padding: 0;
|
|
20
|
-
display: inline-flex;
|
|
21
|
-
|
|
22
|
-
&:active {
|
|
23
|
-
transform: scale(.9);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.menu-tWodT1 {
|
|
28
|
-
justify-content: space-between;
|
|
29
|
-
column-gap: 4px;
|
|
30
|
-
padding: 4px 0;
|
|
31
|
-
display: flex;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.content-vvTcTm {
|
|
35
|
-
background-color: var(--kona-editor-background-color);
|
|
36
|
-
border-radius: 6px;
|
|
37
|
-
padding: 8px 4px;
|
|
38
|
-
font-size: 14px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.customMenu-PLCVVP {
|
|
42
|
-
background-color: var(--kona-editor-background-color);
|
|
43
|
-
border: 1px solid var(--kona-editor-border-color);
|
|
44
|
-
z-index: 21;
|
|
45
|
-
border-radius: 8px;
|
|
46
|
-
width: 200px;
|
|
47
|
-
max-height: 250px;
|
|
48
|
-
font-size: 12px;
|
|
49
|
-
position: absolute;
|
|
50
|
-
overflow-y: auto;
|
|
51
|
-
box-shadow: 0 1px 3px #00000006;
|
|
52
|
-
|
|
53
|
-
&::-webkit-scrollbar {
|
|
54
|
-
width: 6px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&::-webkit-scrollbar-track {
|
|
58
|
-
background: none;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&::-webkit-scrollbar-thumb {
|
|
62
|
-
background-color: #00000040;
|
|
63
|
-
border-radius: 10px;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ConnectDragPreview, ConnectDragSource, ConnectDropTarget } from 'react-dnd';
|
|
2
|
-
import type { RenderElementProps } from 'slate-react';
|
|
3
|
-
type Props = {
|
|
4
|
-
props: RenderElementProps;
|
|
5
|
-
dragRef: ConnectDragSource;
|
|
6
|
-
dropRef: ConnectDropTarget;
|
|
7
|
-
previewRef: ConnectDragPreview;
|
|
8
|
-
position: 'top' | 'bottom' | null;
|
|
9
|
-
};
|
|
10
|
-
export declare const DragBlock: (props: Props) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import DragBlock_module from "./DragBlock.module.js";
|
|
4
|
-
import { DragHandler } from "./DragHandler.js";
|
|
5
|
-
const DragBlock = (props)=>{
|
|
6
|
-
const { props: { attributes, element, children }, dragRef: drag, dropRef: drop, previewRef: preview, position } = props;
|
|
7
|
-
return /*#__PURE__*/ jsx("div", {
|
|
8
|
-
className: clsx(DragBlock_module.root, {
|
|
9
|
-
[DragBlock_module.top]: 'top' === position,
|
|
10
|
-
[DragBlock_module.bottom]: 'bottom' === position
|
|
11
|
-
}),
|
|
12
|
-
...attributes,
|
|
13
|
-
children: /*#__PURE__*/ jsxs("div", {
|
|
14
|
-
className: DragBlock_module.block,
|
|
15
|
-
ref: (e)=>{
|
|
16
|
-
drop(preview(e));
|
|
17
|
-
},
|
|
18
|
-
children: [
|
|
19
|
-
/*#__PURE__*/ jsx("div", {
|
|
20
|
-
className: DragBlock_module.drag,
|
|
21
|
-
ref: (element)=>{
|
|
22
|
-
drag(element);
|
|
23
|
-
},
|
|
24
|
-
contentEditable: false,
|
|
25
|
-
children: /*#__PURE__*/ jsx(DragHandler, {
|
|
26
|
-
attributes: attributes,
|
|
27
|
-
element: element,
|
|
28
|
-
children: children
|
|
29
|
-
})
|
|
30
|
-
}),
|
|
31
|
-
/*#__PURE__*/ jsx("div", {
|
|
32
|
-
children: children
|
|
33
|
-
})
|
|
34
|
-
]
|
|
35
|
-
})
|
|
36
|
-
});
|
|
37
|
-
};
|
|
38
|
-
export { DragBlock };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
.root-QYAUnT {
|
|
2
|
-
border-top: 2px solid #0000;
|
|
3
|
-
border-bottom: 2px solid #0000;
|
|
4
|
-
position: relative;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
.top-qIwygJ {
|
|
8
|
-
border-top: 2px solid #3498db;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.bottom-K22AI8 {
|
|
12
|
-
border-bottom: 2px solid #3498db;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.drag-v0MSZ1 {
|
|
16
|
-
vertical-align: baseline;
|
|
17
|
-
cursor: move;
|
|
18
|
-
opacity: 0;
|
|
19
|
-
width: 16px;
|
|
20
|
-
line-height: 1.2;
|
|
21
|
-
transition: opacity .25s;
|
|
22
|
-
display: inline-block;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.block-y_k_tl {
|
|
26
|
-
border-radius: 4px;
|
|
27
|
-
grid-template-columns: 16px 1fr;
|
|
28
|
-
align-items: start;
|
|
29
|
-
column-gap: 8px;
|
|
30
|
-
padding: 4px 8px;
|
|
31
|
-
transition: background-color .25s;
|
|
32
|
-
display: grid;
|
|
33
|
-
position: relative;
|
|
34
|
-
|
|
35
|
-
&:hover {
|
|
36
|
-
background-color: #00000004;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&:hover .drag-v0MSZ1 {
|
|
40
|
-
opacity: 1;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|