md-editor-lite 0.1.5 → 0.1.7
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/components/EditorHeader.d.ts +8 -0
- package/dist/components/EditorTab.d.ts +7 -0
- package/dist/components/EditorTextarea.d.ts +9 -0
- package/dist/components/IconDropdown.d.ts +17 -0
- package/dist/components/MarkdownEditor.d.ts +8 -0
- package/dist/components/Preview.d.ts +6 -0
- package/dist/components/Toolbar.d.ts +6 -0
- package/dist/components/ToolbarDropdown.d.ts +6 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/toolbar.d.ts +13 -0
- package/dist/dropdown-JYZ5KVXG.css +101 -0
- package/dist/editor-AUU3A4EA.css +67 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useMarkdownEditor.d.ts +9 -0
- package/dist/index.d.ts +4 -81
- package/dist/index.js +101 -106
- package/dist/index.mjs +109 -110
- package/dist/preview-FACEHC73.css +11 -0
- package/dist/style.css +4 -0
- package/dist/toolbar-YQKH6EMS.css +25 -0
- package/dist/utils/cx.d.ts +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/markdown.d.ts +1 -0
- package/package.json +4 -4
- package/dist/index.css +0 -181
- package/dist/index.d.mts +0 -81
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../css/editor.css";
|
|
2
|
+
interface EditorHeaderProps {
|
|
3
|
+
mode: "write" | "preview";
|
|
4
|
+
setMode: (mode: "write" | "preview") => void;
|
|
5
|
+
insertMarkdown: (before: string, after?: string) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function EditorHeader({ mode, setMode, insertMarkdown, }: EditorHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../css/editor.css";
|
|
2
|
+
interface EditorTextareaProps {
|
|
3
|
+
value: string;
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
setValue: (value: string) => void;
|
|
6
|
+
onImageUpload?: (file: File) => Promise<string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const EditorTextarea: import("react").ForwardRefExoticComponent<EditorTextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import "../css/dropdown.css";
|
|
3
|
+
export type DropdownOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
Icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;
|
|
7
|
+
};
|
|
8
|
+
interface IconDropdownProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
options: DropdownOption[];
|
|
12
|
+
selected?: boolean;
|
|
13
|
+
triggerIcon: React.ReactNode;
|
|
14
|
+
onChange: (value: string) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function IconDropdown({ className, disabled, options, selected, triggerIcon, onChange, }: IconDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "../css/editor.css";
|
|
2
|
+
interface MarkdownEditorProps {
|
|
3
|
+
value: string;
|
|
4
|
+
onChange: (v: string) => void;
|
|
5
|
+
onImageUpload?: (file: File) => Promise<string>;
|
|
6
|
+
}
|
|
7
|
+
export declare function MarkdownEditor({ value, onChange: setValue, onImageUpload, }: MarkdownEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
interface ToolbarDropdownProps {
|
|
2
|
+
insertMarkdown: (before: string, after?: string) => void;
|
|
3
|
+
}
|
|
4
|
+
export declare function ToolbarDropdownHeading({ insertMarkdown, }: ToolbarDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function ToolbarDropdownList({ insertMarkdown }: ToolbarDropdownProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./toolbar";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DropdownOption } from "../components/IconDropdown";
|
|
2
|
+
type ToolbarDropdownOption = DropdownOption & {
|
|
3
|
+
before: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const TOOLBAR_BUTTONS: {
|
|
6
|
+
key: string;
|
|
7
|
+
before: string;
|
|
8
|
+
after: string;
|
|
9
|
+
Icon: import("react").ForwardRefExoticComponent<Omit<import("lucide-react").LucideProps, "ref"> & import("react").RefAttributes<SVGSVGElement>>;
|
|
10
|
+
}[];
|
|
11
|
+
export declare const headingOptions: ToolbarDropdownOption[];
|
|
12
|
+
export declare const listOptions: ToolbarDropdownOption[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
.md-dropdown {
|
|
2
|
+
position: relative;
|
|
3
|
+
display: inline-flex;
|
|
4
|
+
align-items: center;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.md-dropdown__trigger {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
|
|
12
|
+
width: 28px;
|
|
13
|
+
height: 28px;
|
|
14
|
+
|
|
15
|
+
background: transparent;
|
|
16
|
+
border: none;
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
transition: background-color 0.15s ease;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.md-dropdown__trigger:hover {
|
|
22
|
+
background-color: #f3f4f6;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.md-dropdown__trigger--disabled {
|
|
26
|
+
cursor: not-allowed;
|
|
27
|
+
opacity: 0.5;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.md-dropdown__menu {
|
|
31
|
+
position: absolute;
|
|
32
|
+
top: 0;
|
|
33
|
+
left: -35%;
|
|
34
|
+
z-index: 50;
|
|
35
|
+
margin-top: 4px;
|
|
36
|
+
|
|
37
|
+
min-width: 40px;
|
|
38
|
+
max-height: 240px;
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
|
|
41
|
+
background: #ffffff;
|
|
42
|
+
border: 1px solid #e5e7eb;
|
|
43
|
+
border-radius: 8px;
|
|
44
|
+
padding: 4px 0;
|
|
45
|
+
|
|
46
|
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.md-dropdown__item {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: 8px;
|
|
53
|
+
|
|
54
|
+
padding: 10px 12px;
|
|
55
|
+
font-size: 14px;
|
|
56
|
+
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
user-select: none;
|
|
59
|
+
transition: background-color 0.15s ease;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.md-dropdown__item:hover {
|
|
63
|
+
background-color: #f3f4f6;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.md-dropdown__item--selected {
|
|
67
|
+
background-color: #fefce8;
|
|
68
|
+
color: #a16207;
|
|
69
|
+
font-weight: 500;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.md-dropdown__icon {
|
|
73
|
+
display: flex;
|
|
74
|
+
color: #9ca3af;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.md-dropdown__label {
|
|
78
|
+
white-space: nowrap;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.dropdown-item {
|
|
82
|
+
color: #374151;
|
|
83
|
+
background-color: #f3f4f6;
|
|
84
|
+
position: relative;
|
|
85
|
+
display: flex;
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
align-items: center;
|
|
88
|
+
gap: 0.5rem;
|
|
89
|
+
padding-left: 0.75rem;
|
|
90
|
+
padding-right: 0.75rem;
|
|
91
|
+
padding-top: 0.625rem;
|
|
92
|
+
padding-bottom: 0.625rem;
|
|
93
|
+
font-size: 0.875rem;
|
|
94
|
+
transition: all ease-in-out;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.dropdown-item--selected {
|
|
98
|
+
background-color: #fefce8;
|
|
99
|
+
color: #a16207;
|
|
100
|
+
font-weight: 500;
|
|
101
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
.editor {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: 100%;
|
|
5
|
+
border: 1px solid #e5e7eb;
|
|
6
|
+
border-radius: 8px;
|
|
7
|
+
box-sizing: border-box;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.editor-header {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
justify-content: space-evenly;
|
|
15
|
+
|
|
16
|
+
height: 88px;
|
|
17
|
+
padding: 0 16px;
|
|
18
|
+
|
|
19
|
+
background-color: #f9fafb;
|
|
20
|
+
border-bottom: 1px solid #e5e7eb;
|
|
21
|
+
border-top-left-radius: 8px;
|
|
22
|
+
border-top-right-radius: 8px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@media (min-width: 768px) {
|
|
26
|
+
.editor-header {
|
|
27
|
+
flex-direction: row;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: space-between;
|
|
30
|
+
height: 48px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.editor-tab-container {
|
|
35
|
+
display: flex;
|
|
36
|
+
gap: 1rem;
|
|
37
|
+
font-weight: 500;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.editor-tab {
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
padding: 0.25rem 0.5rem;
|
|
43
|
+
font-size: small;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
transition: color 0.2s;
|
|
46
|
+
color: #4b5563;
|
|
47
|
+
|
|
48
|
+
&:hover {
|
|
49
|
+
color: #1f2937;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.editor-tab--active {
|
|
54
|
+
color: #111827;
|
|
55
|
+
border-bottom: 2px solid #111827;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.editor-textarea {
|
|
59
|
+
width: 100%;
|
|
60
|
+
min-height: 200px;
|
|
61
|
+
margin: 0;
|
|
62
|
+
padding: 16px;
|
|
63
|
+
border: none;
|
|
64
|
+
resize: none;
|
|
65
|
+
outline: none;
|
|
66
|
+
box-sizing: border-box;
|
|
67
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useMarkdownEditor";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface UseMarkdownEditorProps {
|
|
2
|
+
value: string;
|
|
3
|
+
setValue: (v: string) => void;
|
|
4
|
+
}
|
|
5
|
+
export declare function useMarkdownEditor({ value, setValue }: UseMarkdownEditorProps): {
|
|
6
|
+
textareaRef: import("react").RefObject<HTMLTextAreaElement>;
|
|
7
|
+
insertMarkdown: (before: string, after?: string) => void;
|
|
8
|
+
};
|
|
9
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,81 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
interface EditorHeaderProps {
|
|
7
|
-
mode: "write" | "preview";
|
|
8
|
-
setMode: (mode: "write" | "preview") => void;
|
|
9
|
-
insertMarkdown: (before: string, after?: string) => void;
|
|
10
|
-
}
|
|
11
|
-
declare function EditorHeader({ mode, setMode, insertMarkdown, }: EditorHeaderProps): react_jsx_runtime.JSX.Element;
|
|
12
|
-
|
|
13
|
-
interface EditorTabProps {
|
|
14
|
-
mode: string;
|
|
15
|
-
setMode: (mode: "write" | "preview") => void;
|
|
16
|
-
}
|
|
17
|
-
declare function EditorTab({ mode, setMode }: EditorTabProps): react_jsx_runtime.JSX.Element;
|
|
18
|
-
|
|
19
|
-
interface EditorTextareaProps {
|
|
20
|
-
value: string;
|
|
21
|
-
placeholder?: string;
|
|
22
|
-
setValue: (value: string) => void;
|
|
23
|
-
onImageUpload?: (file: File) => Promise<string>;
|
|
24
|
-
}
|
|
25
|
-
declare const EditorTextarea: react.ForwardRefExoticComponent<EditorTextareaProps & react.RefAttributes<HTMLTextAreaElement>>;
|
|
26
|
-
|
|
27
|
-
interface MarkdownEditorProps {
|
|
28
|
-
value: string;
|
|
29
|
-
onChange: (v: string) => void;
|
|
30
|
-
onImageUpload?: (file: File) => Promise<string>;
|
|
31
|
-
}
|
|
32
|
-
declare function MarkdownEditor({ value, onChange: setValue, onImageUpload, }: MarkdownEditorProps): react_jsx_runtime.JSX.Element;
|
|
33
|
-
|
|
34
|
-
interface PreviewProps {
|
|
35
|
-
value: string;
|
|
36
|
-
}
|
|
37
|
-
declare function Preview({ value }: PreviewProps): react_jsx_runtime.JSX.Element;
|
|
38
|
-
|
|
39
|
-
interface ToolbarProps {
|
|
40
|
-
insertMarkdown: (before: string, after?: string) => void;
|
|
41
|
-
}
|
|
42
|
-
declare function Toolbar({ insertMarkdown }: ToolbarProps): react_jsx_runtime.JSX.Element;
|
|
43
|
-
|
|
44
|
-
interface ToolbarDropdownProps {
|
|
45
|
-
insertMarkdown: (before: string, after?: string) => void;
|
|
46
|
-
}
|
|
47
|
-
declare function ToolbarDropdownHeading({ insertMarkdown, }: ToolbarDropdownProps): react_jsx_runtime.JSX.Element;
|
|
48
|
-
declare function ToolbarDropdownList({ insertMarkdown }: ToolbarDropdownProps): react_jsx_runtime.JSX.Element;
|
|
49
|
-
|
|
50
|
-
type DropdownOption = {
|
|
51
|
-
value: string;
|
|
52
|
-
label?: string;
|
|
53
|
-
Icon?: react__default.ComponentType<react__default.SVGProps<SVGSVGElement>>;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
type ToolbarDropdownOption = DropdownOption & {
|
|
57
|
-
before: string;
|
|
58
|
-
};
|
|
59
|
-
declare const TOOLBAR_BUTTONS: {
|
|
60
|
-
key: string;
|
|
61
|
-
before: string;
|
|
62
|
-
after: string;
|
|
63
|
-
Icon: react.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & react.RefAttributes<SVGSVGElement>>;
|
|
64
|
-
}[];
|
|
65
|
-
declare const headingOptions: ToolbarDropdownOption[];
|
|
66
|
-
declare const listOptions: ToolbarDropdownOption[];
|
|
67
|
-
|
|
68
|
-
interface UseMarkdownEditorProps {
|
|
69
|
-
value: string;
|
|
70
|
-
setValue: (v: string) => void;
|
|
71
|
-
}
|
|
72
|
-
declare function useMarkdownEditor({ value, setValue }: UseMarkdownEditorProps): {
|
|
73
|
-
textareaRef: react.RefObject<HTMLTextAreaElement | null>;
|
|
74
|
-
insertMarkdown: (before: string, after?: string) => void;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
declare function cx(...classes: (string | false | undefined)[]): string;
|
|
78
|
-
|
|
79
|
-
declare function markdownToHtml(markdown: string): string;
|
|
80
|
-
|
|
81
|
-
export { EditorHeader, EditorTab, EditorTextarea, MarkdownEditor, Preview, TOOLBAR_BUTTONS, Toolbar, ToolbarDropdownHeading, ToolbarDropdownList, cx, headingOptions, listOptions, markdownToHtml, useMarkdownEditor };
|
|
1
|
+
export * from "./components/index";
|
|
2
|
+
export * from "./constants/index";
|
|
3
|
+
export * from "./hooks/index";
|
|
4
|
+
export * from "./utils/index";
|