@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
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import styles_module from "./styles.module.js";
|
|
4
|
-
const MenuHotkey = (props)=>{
|
|
5
|
-
const { children, className, ...rest } = props;
|
|
6
|
-
return /*#__PURE__*/ jsx("span", {
|
|
7
|
-
className: clsx(styles_module.menuHotkey, className),
|
|
8
|
-
...rest,
|
|
9
|
-
children: children
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
export { MenuHotkey };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import styles_module from "./styles.module.js";
|
|
4
|
-
const MenuIcon = (props)=>{
|
|
5
|
-
const { children, className, ...rest } = props;
|
|
6
|
-
return /*#__PURE__*/ jsx("span", {
|
|
7
|
-
className: clsx(styles_module.menuIcon, className),
|
|
8
|
-
...rest,
|
|
9
|
-
children: children
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
export { MenuIcon };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export declare const MenuItem: import("react").ForwardRefExoticComponent<{
|
|
2
|
-
children: React.ReactNode;
|
|
3
|
-
selectable?: boolean;
|
|
4
|
-
isSelected?: boolean;
|
|
5
|
-
danger?: boolean;
|
|
6
|
-
} & import("react").HTMLAttributes<HTMLLIElement> & import("react").RefAttributes<HTMLLIElement>>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import { forwardRef } from "react";
|
|
4
|
-
import styles_module from "./styles.module.js";
|
|
5
|
-
const MenuItem = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
6
|
-
const { children, selectable = true, isSelected, danger, className, ...rest } = props;
|
|
7
|
-
return /*#__PURE__*/ jsx("li", {
|
|
8
|
-
ref: ref,
|
|
9
|
-
className: clsx(styles_module.menuItemRoot, !selectable && styles_module.menuItemRootNonSelectable, className),
|
|
10
|
-
...rest,
|
|
11
|
-
children: /*#__PURE__*/ jsx("div", {
|
|
12
|
-
className: clsx(styles_module.menuItemContent, isSelected && styles_module.menuItemContentSelected, danger && styles_module.menuItemContentDanger),
|
|
13
|
-
children: children
|
|
14
|
-
})
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
export { MenuItem };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import clsx from "clsx";
|
|
3
|
-
import styles_module from "./styles.module.js";
|
|
4
|
-
const MenuTitle = (props)=>{
|
|
5
|
-
const { children, className, ...rest } = props;
|
|
6
|
-
return /*#__PURE__*/ jsx("span", {
|
|
7
|
-
className: clsx(styles_module.menuTitle, className),
|
|
8
|
-
...rest,
|
|
9
|
-
children: children
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
export { MenuTitle };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
const SafeSpace = (props)=>{
|
|
4
|
-
const { rect, debug } = props;
|
|
5
|
-
const { x = 0, y = 0, height: h = 0, width: w = 0 } = rect || {};
|
|
6
|
-
const [mouseX, mouseY] = useMousePosition();
|
|
7
|
-
const isReversed = mouseX > x + w;
|
|
8
|
-
const width = isReversed ? mouseX - x - w : x - mouseX;
|
|
9
|
-
const height = h;
|
|
10
|
-
const style = {
|
|
11
|
-
width,
|
|
12
|
-
height: h,
|
|
13
|
-
top: y,
|
|
14
|
-
left: isReversed ? x + w : mouseX
|
|
15
|
-
};
|
|
16
|
-
const points = isReversed ? `0,0 ${width + 10},${mouseY - y} 0,${height}` : `0,${mouseY - y} ${width},0 ${width},${height}`;
|
|
17
|
-
return /*#__PURE__*/ jsx("svg", {
|
|
18
|
-
style: {
|
|
19
|
-
...style,
|
|
20
|
-
pointerEvents: 'none',
|
|
21
|
-
zIndex: 20,
|
|
22
|
-
position: 'fixed'
|
|
23
|
-
},
|
|
24
|
-
children: /*#__PURE__*/ jsx("polygon", {
|
|
25
|
-
points: points,
|
|
26
|
-
fill: debug ? 'rgba(0,0,0,0.25)' : 'transparent',
|
|
27
|
-
pointerEvents: "all"
|
|
28
|
-
})
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
const useMousePosition = ()=>{
|
|
32
|
-
const [mousePosition, setMousePosition] = useState([
|
|
33
|
-
0,
|
|
34
|
-
0
|
|
35
|
-
]);
|
|
36
|
-
useEffect(()=>{
|
|
37
|
-
const updateMousePosition = (ev)=>{
|
|
38
|
-
setMousePosition([
|
|
39
|
-
ev.clientX,
|
|
40
|
-
ev.clientY
|
|
41
|
-
]);
|
|
42
|
-
};
|
|
43
|
-
const throttledUpdateMousePosition = throttle(updateMousePosition, 500);
|
|
44
|
-
document.addEventListener('mousemove', updateMousePosition, {
|
|
45
|
-
once: true
|
|
46
|
-
});
|
|
47
|
-
document.addEventListener('mousemove', throttledUpdateMousePosition);
|
|
48
|
-
return ()=>{
|
|
49
|
-
document.removeEventListener('mousemove', updateMousePosition);
|
|
50
|
-
document.removeEventListener('mousemove', throttledUpdateMousePosition);
|
|
51
|
-
};
|
|
52
|
-
}, []);
|
|
53
|
-
return mousePosition;
|
|
54
|
-
};
|
|
55
|
-
function throttle(callback, delay) {
|
|
56
|
-
let previousCall = Date.now();
|
|
57
|
-
return function(...args) {
|
|
58
|
-
const time = Date.now();
|
|
59
|
-
if (time - previousCall >= delay) {
|
|
60
|
-
previousCall = time;
|
|
61
|
-
callback.apply(this, args);
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
export { SafeSpace };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import "./styles_module.css";
|
|
2
|
-
const styles_module = {
|
|
3
|
-
delimiter: "delimiter-H74PdN",
|
|
4
|
-
menuItemRoot: "menuItemRoot-vjsxDP",
|
|
5
|
-
menuItemRootNonSelectable: "menuItemRootNonSelectable-mdpDzB",
|
|
6
|
-
menuItemContent: "menuItemContent-OQOO0C",
|
|
7
|
-
menuItemContentSelected: "menuItemContentSelected-NnTeYh",
|
|
8
|
-
menuItemContentDanger: "menuItemContentDanger-B4Xgia",
|
|
9
|
-
menuIcon: "menuIcon-mKDuXY",
|
|
10
|
-
menuTitle: "menuTitle-SCvohZ",
|
|
11
|
-
menuHotkey: "menuHotkey-iRqoZq",
|
|
12
|
-
menu: "menu-akaoJ1",
|
|
13
|
-
menuVisible: "menuVisible-LTECvx",
|
|
14
|
-
menuBody: "menuBody-AZ5eff",
|
|
15
|
-
menuScrollable: "menuScrollable-jCi9hq",
|
|
16
|
-
menuBackdrop: "menuBackdrop-Vz5Iiy",
|
|
17
|
-
menuEnterAnimation: "menuEnterAnimation-dOe8fd",
|
|
18
|
-
menuEnter: "menuEnter-q1aEn4",
|
|
19
|
-
menuExit: "menuExit-H1NPpL"
|
|
20
|
-
};
|
|
21
|
-
export { styles_module as default };
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
.delimiter-H74PdN {
|
|
2
|
-
border-style: solid;
|
|
3
|
-
border-width: 1px 0 0;
|
|
4
|
-
border-color: var(--kona-editor-border-color);
|
|
5
|
-
width: 100%;
|
|
6
|
-
height: 1px;
|
|
7
|
-
margin: 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.menuItemRoot-vjsxDP {
|
|
11
|
-
cursor: pointer;
|
|
12
|
-
border-radius: 4px;
|
|
13
|
-
margin: 0;
|
|
14
|
-
padding: 0 4px;
|
|
15
|
-
list-style: none;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.menuItemRootNonSelectable-mdpDzB {
|
|
19
|
-
cursor: default;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.menuItemContent-OQOO0C {
|
|
23
|
-
user-select: none;
|
|
24
|
-
color: var(--kona-editor-text-color);
|
|
25
|
-
background-color: #0000;
|
|
26
|
-
border-radius: 4px;
|
|
27
|
-
align-items: center;
|
|
28
|
-
gap: 4px;
|
|
29
|
-
padding: 8px;
|
|
30
|
-
display: flex;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
.menuItemContentSelected-NnTeYh {
|
|
34
|
-
color: #06c;
|
|
35
|
-
background-color: #e6f0ff;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.menuItemContentDanger-B4Xgia {
|
|
39
|
-
color: #c00;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.menuIcon-mKDuXY {
|
|
43
|
-
width: 16px;
|
|
44
|
-
height: 16px;
|
|
45
|
-
color: inherit;
|
|
46
|
-
justify-content: center;
|
|
47
|
-
align-items: center;
|
|
48
|
-
display: inline-flex;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
.menuTitle-SCvohZ {
|
|
52
|
-
min-width: 70px;
|
|
53
|
-
color: inherit;
|
|
54
|
-
flex-grow: 1;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.menuHotkey-iRqoZq {
|
|
58
|
-
background-color: #0000000d;
|
|
59
|
-
border-radius: 4px;
|
|
60
|
-
justify-content: center;
|
|
61
|
-
align-items: center;
|
|
62
|
-
padding: 0 4px;
|
|
63
|
-
display: inline-flex;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.menu-akaoJ1 {
|
|
67
|
-
z-index: 13;
|
|
68
|
-
background-color: var(--kona-editor-background-color);
|
|
69
|
-
border: 1px solid var(--kona-editor-border-color);
|
|
70
|
-
box-sizing: border-box;
|
|
71
|
-
border-radius: 8px;
|
|
72
|
-
margin: 0;
|
|
73
|
-
padding: 4px 0;
|
|
74
|
-
position: absolute;
|
|
75
|
-
overflow: hidden;
|
|
76
|
-
box-shadow: 0 2px 8px #00000026;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.menuVisible-LTECvx {
|
|
80
|
-
opacity: 1;
|
|
81
|
-
transform: scale(1);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.menuBody-AZ5eff {
|
|
85
|
-
flex-direction: column;
|
|
86
|
-
height: 100%;
|
|
87
|
-
display: flex;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
.menuScrollable-jCi9hq {
|
|
91
|
-
flex-grow: 1;
|
|
92
|
-
overflow: hidden auto;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
.menuScrollable-jCi9hq::-webkit-scrollbar {
|
|
96
|
-
background: #f5f5f5;
|
|
97
|
-
border-radius: 8px;
|
|
98
|
-
width: 6px;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.menuScrollable-jCi9hq::-webkit-scrollbar-thumb {
|
|
102
|
-
background: #ccc;
|
|
103
|
-
border-radius: 8px;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.menuBackdrop-Vz5Iiy {
|
|
107
|
-
z-index: 20;
|
|
108
|
-
background-color: #00000006;
|
|
109
|
-
position: fixed;
|
|
110
|
-
inset: 0;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.menuEnterAnimation-dOe8fd {
|
|
114
|
-
animation: .2s ease-in forwards menuEnter-q1aEn4;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
@keyframes menuEnter-q1aEn4 {
|
|
118
|
-
from {
|
|
119
|
-
opacity: 0;
|
|
120
|
-
transform: scale(.95);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
to {
|
|
124
|
-
opacity: 1;
|
|
125
|
-
transform: scale(1);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@keyframes menuExit-H1NPpL {
|
|
130
|
-
from {
|
|
131
|
-
opacity: 1;
|
|
132
|
-
transform: scale(1);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
to {
|
|
136
|
-
opacity: 0;
|
|
137
|
-
transform: scale(.95);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export type MenuConfig = {
|
|
3
|
-
items?: MenuItem[];
|
|
4
|
-
header?: () => ReactNode;
|
|
5
|
-
footer?: () => ReactNode;
|
|
6
|
-
onOpen?: () => void;
|
|
7
|
-
onFocus?: () => void;
|
|
8
|
-
};
|
|
9
|
-
export type MenuItem = {
|
|
10
|
-
render: () => ReactNode;
|
|
11
|
-
selectable?: boolean;
|
|
12
|
-
autoClose?: boolean;
|
|
13
|
-
config?: MenuConfig;
|
|
14
|
-
danger?: boolean;
|
|
15
|
-
onSelect?: () => void;
|
|
16
|
-
};
|
|
File without changes
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type Coords = [number, number];
|
|
2
|
-
type Point = {
|
|
3
|
-
x: number;
|
|
4
|
-
y: number;
|
|
5
|
-
};
|
|
6
|
-
declare class Context {
|
|
7
|
-
private readonly p;
|
|
8
|
-
private rect;
|
|
9
|
-
constructor(p: Point, rect: DOMRect);
|
|
10
|
-
get point(): Point;
|
|
11
|
-
helpers: {
|
|
12
|
-
isWithinWindow: () => [boolean, boolean];
|
|
13
|
-
};
|
|
14
|
-
flip: ([horizontal, vertical]: [boolean, boolean]) => this;
|
|
15
|
-
move: (x: number, y: number) => this;
|
|
16
|
-
}
|
|
17
|
-
export declare const useMenuPosition: (point: Point, transform: (context: Context) => Point) => readonly [(element: HTMLElement) => void, Point];
|
|
18
|
-
export {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from "react";
|
|
2
|
-
class Context {
|
|
3
|
-
p;
|
|
4
|
-
rect;
|
|
5
|
-
constructor(p, rect){
|
|
6
|
-
this.p = {
|
|
7
|
-
x: p.x,
|
|
8
|
-
y: p.y
|
|
9
|
-
};
|
|
10
|
-
this.rect = rect;
|
|
11
|
-
}
|
|
12
|
-
get point() {
|
|
13
|
-
return this.p;
|
|
14
|
-
}
|
|
15
|
-
helpers = {
|
|
16
|
-
isWithinWindow: ()=>{
|
|
17
|
-
const left = this.p.x + this.rect.width;
|
|
18
|
-
return [
|
|
19
|
-
left < document.documentElement.clientWidth,
|
|
20
|
-
this.p.y + this.rect.height < document.documentElement.clientHeight
|
|
21
|
-
];
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
flip = ([horizontal, vertical])=>{
|
|
25
|
-
if (horizontal) this.p.x -= this.rect.width;
|
|
26
|
-
if (vertical) this.p.y -= this.rect.height;
|
|
27
|
-
return this;
|
|
28
|
-
};
|
|
29
|
-
move = (x, y)=>{
|
|
30
|
-
this.p.x += x;
|
|
31
|
-
this.p.y += y;
|
|
32
|
-
return this;
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
const useMenuPosition = (point, transform)=>{
|
|
36
|
-
const [coords, setCoords] = useState(point);
|
|
37
|
-
const ref = useCallback((element)=>{
|
|
38
|
-
if (!element) return;
|
|
39
|
-
const rect = element.getBoundingClientRect();
|
|
40
|
-
const newCoords = transform(new Context(point, rect));
|
|
41
|
-
if (coords.x !== newCoords.x || coords.y !== newCoords.y) setCoords(newCoords);
|
|
42
|
-
}, [
|
|
43
|
-
point.x,
|
|
44
|
-
point.y
|
|
45
|
-
]);
|
|
46
|
-
return [
|
|
47
|
-
ref,
|
|
48
|
-
coords
|
|
49
|
-
];
|
|
50
|
-
};
|
|
51
|
-
export { useMenuPosition };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Merges multiple React refs into a single ref callback.
|
|
3
|
-
*
|
|
4
|
-
* @template T The type of the ref value
|
|
5
|
-
* @param {React.Ref<T>[]} refs Array of refs to merge (can be both callback refs and object refs)
|
|
6
|
-
* @returns {React.RefCallback<T> | null} A merged ref callback or null if all input refs are null
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* function Component() {
|
|
10
|
-
* const firstRef = useRef<HTMLDivElement>(null)
|
|
11
|
-
* const secondRef = useRef<HTMLDivElement>(null)
|
|
12
|
-
* const forwardedRef = useForwardedRef<HTMLDivElement>(null)
|
|
13
|
-
*
|
|
14
|
-
* const mergedRef = useMergeRefs([firstRef, secondRef, forwardedRef])
|
|
15
|
-
*
|
|
16
|
-
* return (
|
|
17
|
-
* <div ref={mergedRef}>
|
|
18
|
-
* This div will be referenced by all three refs
|
|
19
|
-
* </div>
|
|
20
|
-
* )
|
|
21
|
-
* }
|
|
22
|
-
*/
|
|
23
|
-
export declare const useMergeRefs: <T>(refs: React.Ref<T>[]) => ((refValue: T) => void) | null;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
2
|
-
const useMergeRefs = (refs)=>useMemo(()=>{
|
|
3
|
-
if (refs.every((ref)=>null == ref)) return null;
|
|
4
|
-
return (refValue)=>{
|
|
5
|
-
refs.forEach((ref)=>{
|
|
6
|
-
if ('function' == typeof ref) ref(refValue);
|
|
7
|
-
else if (null != ref) ref.current = refValue;
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
}, []);
|
|
11
|
-
export { useMergeRefs };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { useStore } from '@nanostores/react';
|
|
2
|
-
import styles from './Backdrop.module.css';
|
|
3
|
-
import { $store } from './store';
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
onClose: () => void;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const Backdrop = (props: Props) => {
|
|
10
|
-
const { isFloatingMenuOpen } = useStore($store);
|
|
11
|
-
const { onClose } = props;
|
|
12
|
-
|
|
13
|
-
return isFloatingMenuOpen ? (
|
|
14
|
-
<div className={styles.root} onClick={onClose} />
|
|
15
|
-
) : null;
|
|
16
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
background-color: var(--kona-editor-alt-background-color);
|
|
5
|
-
border-radius: 8px;
|
|
6
|
-
padding: 4px;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.button {
|
|
10
|
-
width: 20px;
|
|
11
|
-
height: 20px;
|
|
12
|
-
border-radius: 4px;
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
justify-content: center;
|
|
16
|
-
cursor: pointer;
|
|
17
|
-
padding: 0;
|
|
18
|
-
margin: 0;
|
|
19
|
-
outline: none;
|
|
20
|
-
background-color: transparent;
|
|
21
|
-
|
|
22
|
-
&:active {
|
|
23
|
-
transform: scale(0.9);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.menu {
|
|
28
|
-
display: flex;
|
|
29
|
-
justify-content: space-between;
|
|
30
|
-
column-gap: 4px;
|
|
31
|
-
padding: 4px 0;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.content {
|
|
35
|
-
background-color: var(--kona-editor-background-color);
|
|
36
|
-
border-radius: 6px;
|
|
37
|
-
padding: 8px 4px;
|
|
38
|
-
font-size: 14px;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.customMenu {
|
|
42
|
-
max-height: 250px;
|
|
43
|
-
width: 200px;
|
|
44
|
-
overflow-y: auto;
|
|
45
|
-
position: absolute;
|
|
46
|
-
background-color: var(--kona-editor-background-color);
|
|
47
|
-
border: 1px solid var(--kona-editor-border-color);
|
|
48
|
-
z-index: 21;
|
|
49
|
-
border-radius: 8px;
|
|
50
|
-
font-size: 12px;
|
|
51
|
-
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.025);
|
|
52
|
-
|
|
53
|
-
&::-webkit-scrollbar {
|
|
54
|
-
width: 6px;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
&::-webkit-scrollbar-track {
|
|
58
|
-
background: transparent;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&::-webkit-scrollbar-thumb {
|
|
62
|
-
background-color: rgba(0, 0, 0, 0.25);
|
|
63
|
-
border-radius: 10px;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { forwardRef, type ReactNode, useMemo } from 'react';
|
|
2
|
-
import { Node } from 'slate';
|
|
3
|
-
import type { CustomElement } from '../../types';
|
|
4
|
-
import styles from './CodeBlock.module.css';
|
|
5
|
-
import { CheckIcon } from './icons/check';
|
|
6
|
-
import { CopyIcon } from './icons/copy';
|
|
7
|
-
import { Button } from './ui/Button';
|
|
8
|
-
import { Dropdown } from './ui/Dropdown';
|
|
9
|
-
import { Menu as MenuBase, type MenuConfig } from './ui/Menu';
|
|
10
|
-
|
|
11
|
-
const languages = [
|
|
12
|
-
{ value: 'javascript', label: 'JavaScript' },
|
|
13
|
-
{ value: 'typescript', label: 'TypeScript' },
|
|
14
|
-
{ value: 'jsx', label: 'JSX' },
|
|
15
|
-
{ value: 'tsx', label: 'TSX' },
|
|
16
|
-
{ value: 'html', label: 'HTML' },
|
|
17
|
-
{ value: 'css', label: 'CSS' },
|
|
18
|
-
{ value: 'json', label: 'JSON' },
|
|
19
|
-
{ value: 'python', label: 'Python' },
|
|
20
|
-
{ value: 'java', label: 'Java' },
|
|
21
|
-
{ value: 'c', label: 'C' },
|
|
22
|
-
{ value: 'cpp', label: 'C++' },
|
|
23
|
-
{ value: 'csharp', label: 'C#' },
|
|
24
|
-
{ value: 'go', label: 'Go' },
|
|
25
|
-
{ value: 'rust', label: 'Rust' },
|
|
26
|
-
{ value: 'ruby', label: 'Ruby' },
|
|
27
|
-
{ value: 'php', label: 'PHP' },
|
|
28
|
-
{ value: 'bash', label: 'Bash' },
|
|
29
|
-
{ value: 'sql', label: 'SQL' },
|
|
30
|
-
{ value: 'markdown', label: 'Markdown' },
|
|
31
|
-
{ value: 'yaml', label: 'YAML' },
|
|
32
|
-
{ value: 'plaintext', label: 'Plain Text' },
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
type Props = {
|
|
36
|
-
value: string;
|
|
37
|
-
onChange: (value: string) => void;
|
|
38
|
-
params: {
|
|
39
|
-
element: CustomElement;
|
|
40
|
-
Content: () => ReactNode;
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const CodeBlock = (props: Props) => {
|
|
45
|
-
const {
|
|
46
|
-
value: language,
|
|
47
|
-
onChange,
|
|
48
|
-
params: { element, Content },
|
|
49
|
-
} = props;
|
|
50
|
-
|
|
51
|
-
const handleCopyClick = () => {
|
|
52
|
-
const text = Array.from(Node.texts(element))
|
|
53
|
-
.map((nodeEntry) => nodeEntry[0].text)
|
|
54
|
-
.join('\n');
|
|
55
|
-
|
|
56
|
-
navigator.clipboard.writeText(text);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// biome-ignore lint/correctness/useExhaustiveDependencies: we don't care about other deps
|
|
60
|
-
const menuConfig: MenuConfig = useMemo(
|
|
61
|
-
() => ({
|
|
62
|
-
items: languages.map(({ label, value }) => ({
|
|
63
|
-
render: () => (
|
|
64
|
-
<>
|
|
65
|
-
<MenuBase.Icon>
|
|
66
|
-
{value === language && <CheckIcon size={16} />}
|
|
67
|
-
</MenuBase.Icon>
|
|
68
|
-
<MenuBase.Title>{label}</MenuBase.Title>
|
|
69
|
-
</>
|
|
70
|
-
),
|
|
71
|
-
onSelect: () => {
|
|
72
|
-
onChange(value);
|
|
73
|
-
},
|
|
74
|
-
})),
|
|
75
|
-
}),
|
|
76
|
-
[language],
|
|
77
|
-
);
|
|
78
|
-
return (
|
|
79
|
-
<div className={styles.root}>
|
|
80
|
-
<div className={styles.menu}>
|
|
81
|
-
<Dropdown
|
|
82
|
-
config={menuConfig}
|
|
83
|
-
Menu={forwardRef<HTMLDivElement, { className: string }>(
|
|
84
|
-
(props, ref) => (
|
|
85
|
-
<div
|
|
86
|
-
{...props}
|
|
87
|
-
ref={ref}
|
|
88
|
-
className={[styles.customMenu, props.className].join(' ')}
|
|
89
|
-
/>
|
|
90
|
-
),
|
|
91
|
-
)}
|
|
92
|
-
>
|
|
93
|
-
{({ ref, onClick }) => (
|
|
94
|
-
<Button ref={ref} size="sm" onClick={onClick}>
|
|
95
|
-
{languages.find((l) => l.value === language)?.label ||
|
|
96
|
-
'Select language'}
|
|
97
|
-
</Button>
|
|
98
|
-
)}
|
|
99
|
-
</Dropdown>
|
|
100
|
-
<Button size="sm" type="button" onClick={handleCopyClick}>
|
|
101
|
-
<CopyIcon size={16} />
|
|
102
|
-
</Button>
|
|
103
|
-
</div>
|
|
104
|
-
<div className={styles.content}>
|
|
105
|
-
<Content />
|
|
106
|
-
</div>
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
};
|