rj-editor 0.1.1
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/README.md +51 -0
- package/dist/assets/icons/AlignCenterIcon.d.ts +2 -0
- package/dist/assets/icons/AlignJustifyIcon.d.ts +2 -0
- package/dist/assets/icons/AlignLeftIcon.d.ts +2 -0
- package/dist/assets/icons/AlignRightIcon.d.ts +2 -0
- package/dist/assets/icons/BoldIcon01.d.ts +2 -0
- package/dist/assets/icons/ChevronDownIcon.d.ts +2 -0
- package/dist/assets/icons/ClearOrderListIcon.d.ts +2 -0
- package/dist/assets/icons/DotpointsIcon01.d.ts +2 -0
- package/dist/assets/icons/FlipBackwardIcon.d.ts +2 -0
- package/dist/assets/icons/FlipForwardIcon.d.ts +2 -0
- package/dist/assets/icons/ItalicIcon01.d.ts +2 -0
- package/dist/assets/icons/OrderListIcon.d.ts +2 -0
- package/dist/assets/icons/StrikethroughIcon01.d.ts +2 -0
- package/dist/assets/icons/UnderlineIcon01.d.ts +2 -0
- package/dist/assets/icons/XCloseIcon.d.ts +2 -0
- package/dist/components/RJTextEditor.d.ts +10 -0
- package/dist/components/toolbar/Toolbar.d.ts +2 -0
- package/dist/components/toolbar/alignment/AlignmentControls.d.ts +6 -0
- package/dist/components/toolbar/divider/ToolbarDivider.d.ts +1 -0
- package/dist/components/toolbar/history/HistoryControls.d.ts +6 -0
- package/dist/components/toolbar/list/ListControls.d.ts +6 -0
- package/dist/components/toolbar/style-controls/StyleControls.d.ts +1 -0
- package/dist/components/toolbar/style-controls/background-color/BackgroundColorControl.d.ts +1 -0
- package/dist/components/toolbar/style-controls/clear-formatting/ClearFormattingControl.d.ts +1 -0
- package/dist/components/toolbar/style-controls/font-family/FontFamilyControl.d.ts +1 -0
- package/dist/components/toolbar/style-controls/font-size/FontSizeControl.d.ts +1 -0
- package/dist/components/toolbar/style-controls/text-color/TextColorControl.d.ts +1 -0
- package/dist/components/toolbar/style-controls/utils.d.ts +3 -0
- package/dist/components/toolbar/text-format/TextFormatControls.d.ts +1 -0
- package/dist/constants/backgroundColorOptions.d.ts +1 -0
- package/dist/constants/fontFamilyOptions.d.ts +1 -0
- package/dist/constants/fontSizeOptions.d.ts +1 -0
- package/dist/constants/index.d.ts +5 -0
- package/dist/constants/initialToolbarState.d.ts +2 -0
- package/dist/constants/textColorOptions.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/rj-editor.css +2 -0
- package/dist/rj-editor.js +850 -0
- package/dist/rj-editor.umd.cjs +1 -0
- package/dist/slice/index.d.ts +1 -0
- package/dist/slice/toolbarSlice.d.ts +3 -0
- package/dist/store/hooks.d.ts +6 -0
- package/dist/store/index.d.ts +3 -0
- package/dist/store/store.d.ts +14 -0
- package/dist/types/AppDispatch.d.ts +2 -0
- package/dist/types/RJTextEditorValue.d.ts +6 -0
- package/dist/types/RootState.d.ts +2 -0
- package/dist/types/ToolbarState.d.ts +12 -0
- package/dist/types/index.d.ts +4 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# RJ Editor
|
|
2
|
+
|
|
3
|
+
Lexical asosida qurilgan React rich text editor komponenti.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install rj-editor
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```tsx
|
|
14
|
+
import { RJTextEditor } from 'rj-editor'
|
|
15
|
+
import 'rj-editor/style.css'
|
|
16
|
+
|
|
17
|
+
export function App() {
|
|
18
|
+
return (
|
|
19
|
+
<RJTextEditor
|
|
20
|
+
autofocus
|
|
21
|
+
onChange={(value) => {
|
|
22
|
+
console.log(value.html)
|
|
23
|
+
console.log(value.json)
|
|
24
|
+
}}
|
|
25
|
+
placeholder="Matn yozing..."
|
|
26
|
+
/>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Props
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
type RJTextEditorProps = {
|
|
35
|
+
autofocus?: boolean
|
|
36
|
+
className?: string
|
|
37
|
+
namespace?: string
|
|
38
|
+
onChange?: (value: RJTextEditorValue) => void
|
|
39
|
+
placeholder?: string
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Style
|
|
44
|
+
|
|
45
|
+
Paket CSS faylini alohida import qiladi:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import 'rj-editor/style.css'
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Theme qilish uchun `--rj-*` CSS variable qiymatlarini override qilish mumkin.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RJTextEditorValue } from '@/types';
|
|
2
|
+
import './RJTextEditor.scss';
|
|
3
|
+
export type RJTextEditorProps = {
|
|
4
|
+
autofocus?: boolean;
|
|
5
|
+
className?: string;
|
|
6
|
+
namespace?: string;
|
|
7
|
+
onChange?: (value: RJTextEditorValue) => void;
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function RJTextEditor({ autofocus, className, namespace, onChange, placeholder, }: RJTextEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ToolbarDivider(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function StyleControls(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function BackgroundColorControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ClearFormattingControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FontFamilyControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function FontSizeControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TextColorControl(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function TextFormatControls(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const BACKGROUND_COLOR_OPTIONS: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FONT_FAMILY_OPTIONS: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FONT_SIZE_OPTIONS: string[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { BACKGROUND_COLOR_OPTIONS } from './backgroundColorOptions';
|
|
2
|
+
export { FONT_FAMILY_OPTIONS } from './fontFamilyOptions';
|
|
3
|
+
export { FONT_SIZE_OPTIONS } from './fontSizeOptions';
|
|
4
|
+
export { INITIAL_TOOLBAR_STATE } from './initialToolbarState';
|
|
5
|
+
export { TEXT_COLOR_OPTIONS } from './textColorOptions';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const TEXT_COLOR_OPTIONS: string[];
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.rj-editor-toolbar{background:var(--rj-editor-toolbar-bg,#f8fafc);border-bottom:1px solid var(--rj-editor-border,#d9dde5);flex-wrap:wrap;align-items:center;gap:6px;padding:8px;display:flex}.rj-editor-toolbar button{background:var(--rj-editor-toolbar-button-bg,#fff);border:1px solid var(--rj-editor-border,#d9dde5);color:var(--rj-editor-text,#111827);cursor:pointer;border-radius:8px;justify-content:center;align-items:center;min-width:34px;height:34px;padding:0 10px;font:600 14px/1 system-ui,sans-serif;display:inline-flex}.rj-editor-toolbar--clear-btn{color:var(--rj-editor-danger,#dc2626)}.rj-editor-toolbar--clear-btn svg path{stroke:var(--rj-editor-danger,#dc2626)}.rj-editor-toolbar button:hover:not(:disabled),.rj-editor-toolbar button.is-active,.rj-editor-toolbar select:hover,.rj-editor-toolbar input[type=color]:hover{background:var(--rj-editor-toolbar-button-active-bg,#eaf2ff);border-color:var(--rj-editor-focus-border,#7aa7f7)}.rj-editor-toolbar .rj-editor-toolbar--clear-btn:hover:not(:disabled){background:var(--rj-editor-danger-bg,#fee2e2);border-color:var(--rj-editor-danger-border,#fca5a5);color:var(--rj-editor-danger,#dc2626)}.rj-editor-toolbar input[type=color]{background:var(--rj-editor-toolbar-button-bg,#fff);border:1px solid var(--rj-editor-border,#d9dde5);color:var(--rj-editor-text,#111827);border-radius:8px;height:34px}.rj-editor-toolbar-select{border-radius:8px;min-width:92px;height:33px}.rj-editor-toolbar-select-font{min-width:148px}.rj-editor-toolbar input[type=color]{cursor:pointer;width:38px;padding:3px}.rj-editor-toolbar button:disabled{cursor:not-allowed;opacity:.45}.rj-editor-color-button{min-width:42px}.rj-editor-text-color-mark{flex-direction:column;align-items:center;gap:2px;font-weight:700;line-height:1;display:inline-flex}.rj-editor-text-color-line{border-radius:999px;width:18px;height:3px;display:block}.rj-editor-background-color-mark{border:1px solid var(--rj-editor-border,#d9dde5);border-radius:4px;justify-content:center;align-items:center;min-width:28px;height:22px;padding:0 4px;font-size:12px;font-weight:700;display:inline-flex}.rj-editor-background-color-mark.is-none{background:linear-gradient(135deg, transparent 45%, var(--rj-editor-focus-border,#7aa7f7) 47%, var(--rj-editor-focus-border,#7aa7f7) 53%, transparent 55%), var(--rj-editor-toolbar-button-bg,#fff)}.rj-editor-color-menu-item{color:inherit;cursor:pointer;text-align:left;background:0 0;border:0;align-items:center;gap:8px;width:100%;min-width:120px;padding:2px 0;display:flex}.rj-editor-color-menu-input{cursor:pointer;width:28px;height:22px;margin-left:auto;padding:0}.rj-editor-color-swatch,.rj-editor-color-none{border:1px solid var(--rj-editor-border,#d9dde5);border-radius:4px;width:18px;height:18px;display:inline-flex}.rj-editor-color-none{background:linear-gradient(135deg, transparent 43%, #ef4444 46%, #ef4444 54%, transparent 57%), var(--rj-editor-toolbar-button-bg,#fff)}.rj-editor-toolbar button svg{width:18px;height:18px}.rj-editor-toolbar-divider{background:var(--rj-editor-border,#d9dde5);width:1px;height:22px;margin:0 2px}.rj-editor{border:1px solid var(--rj-editor-border,#d9dde5);background:var(--rj-editor-bg,#fff);color:var(--rj-editor-text,#111827);text-align:left;border-radius:8px;overflow:hidden}.rj-editor-body{position:relative}.rj-editor-input{outline:none;min-height:220px;padding:18px}.rj-editor-placeholder{color:var(--rj-editor-placeholder,#8a94a6);pointer-events:none;-webkit-user-select:none;user-select:none;position:absolute;top:18px;left:18px}.rj-editor-paragraph{margin:0 0 12px}.rj-editor-paragraph:last-child{margin-bottom:0}.rj-editor-text-bold{font-weight:700}.rj-editor-text-italic{font-style:italic}.rj-editor-text-strikethrough{text-decoration:line-through}.rj-editor-text-underline{text-decoration:underline}.rj-editor-list-ol,.rj-editor-list-ul{margin:0 0 12px 24px;padding:0}.rj-editor-list-item{margin:4px 0}
|
|
2
|
+
/*$vite$:1*/
|
|
@@ -0,0 +1,850 @@
|
|
|
1
|
+
import { $generateHtmlFromNodes as e } from "@lexical/html";
|
|
2
|
+
import { $getSelection as t, $isRangeSelection as n, CAN_REDO_COMMAND as r, CAN_UNDO_COMMAND as i, COMMAND_PRIORITY_LOW as a, FORMAT_ELEMENT_COMMAND as o, FORMAT_TEXT_COMMAND as s, REDO_COMMAND as c, SELECTION_CHANGE_COMMAND as l, UNDO_COMMAND as u } from "lexical";
|
|
3
|
+
import { INSERT_ORDERED_LIST_COMMAND as d, INSERT_UNORDERED_LIST_COMMAND as f, ListItemNode as p, ListNode as m, REMOVE_LIST_COMMAND as h } from "@lexical/list";
|
|
4
|
+
import { AutoFocusPlugin as g } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
5
|
+
import { ContentEditable as _ } from "@lexical/react/LexicalContentEditable";
|
|
6
|
+
import { LexicalComposer as v } from "@lexical/react/LexicalComposer";
|
|
7
|
+
import { LexicalErrorBoundary as y } from "@lexical/react/LexicalErrorBoundary";
|
|
8
|
+
import { HistoryPlugin as ee } from "@lexical/react/LexicalHistoryPlugin";
|
|
9
|
+
import { ListPlugin as te } from "@lexical/react/LexicalListPlugin";
|
|
10
|
+
import { OnChangePlugin as ne } from "@lexical/react/LexicalOnChangePlugin";
|
|
11
|
+
import { RichTextPlugin as re } from "@lexical/react/LexicalRichTextPlugin";
|
|
12
|
+
import ie, { useMemo as b, useState as x } from "react";
|
|
13
|
+
import { Provider as S, useDispatch as C, useSelector as w } from "react-redux";
|
|
14
|
+
import { configureStore as T, createSlice as E } from "@reduxjs/toolkit";
|
|
15
|
+
import { $getSelectionStyleValueForProperty as D, $patchStyleText as O } from "@lexical/selection";
|
|
16
|
+
import { useLexicalComposerContext as k } from "@lexical/react/LexicalComposerContext";
|
|
17
|
+
import { Fragment as A, jsx as j, jsxs as M } from "react/jsx-runtime";
|
|
18
|
+
import { Dropdown as N, Select as P } from "antd";
|
|
19
|
+
//#region src/constants/backgroundColorOptions.ts
|
|
20
|
+
var F = [
|
|
21
|
+
"#FFFFFF",
|
|
22
|
+
"#FEF3C7",
|
|
23
|
+
"#DBEAFE",
|
|
24
|
+
"#DCFCE7",
|
|
25
|
+
"#FCE7F3",
|
|
26
|
+
"#EDE9FE",
|
|
27
|
+
"#E5E7EB"
|
|
28
|
+
], I = [
|
|
29
|
+
"Arial",
|
|
30
|
+
"Georgia",
|
|
31
|
+
"Inter",
|
|
32
|
+
"Times New Roman",
|
|
33
|
+
"Trebuchet MS",
|
|
34
|
+
"Verdana"
|
|
35
|
+
], L = [
|
|
36
|
+
"8px",
|
|
37
|
+
"9px",
|
|
38
|
+
"11px",
|
|
39
|
+
"12px",
|
|
40
|
+
"14px",
|
|
41
|
+
"16px",
|
|
42
|
+
"18px",
|
|
43
|
+
"20px",
|
|
44
|
+
"24px",
|
|
45
|
+
"32px",
|
|
46
|
+
"48px",
|
|
47
|
+
"72px"
|
|
48
|
+
], R = {
|
|
49
|
+
backgroundColor: "",
|
|
50
|
+
canRedo: !1,
|
|
51
|
+
canUndo: !1,
|
|
52
|
+
fontFamily: void 0,
|
|
53
|
+
fontSize: void 0,
|
|
54
|
+
isBold: !1,
|
|
55
|
+
isItalic: !1,
|
|
56
|
+
isStrikethrough: !1,
|
|
57
|
+
isUnderline: !1,
|
|
58
|
+
textColor: ""
|
|
59
|
+
}, z = [
|
|
60
|
+
"#111827",
|
|
61
|
+
"#dc2626",
|
|
62
|
+
"#2563eb",
|
|
63
|
+
"#059669",
|
|
64
|
+
"#9333ea",
|
|
65
|
+
"#ca8a04"
|
|
66
|
+
], B = E({
|
|
67
|
+
name: "toolbar",
|
|
68
|
+
initialState: R,
|
|
69
|
+
reducers: {
|
|
70
|
+
setCanRedo(e, t) {
|
|
71
|
+
e.canRedo = t.payload;
|
|
72
|
+
},
|
|
73
|
+
setCanUndo(e, t) {
|
|
74
|
+
e.canUndo = t.payload;
|
|
75
|
+
},
|
|
76
|
+
setTextFormats(e, t) {
|
|
77
|
+
e.isBold = t.payload.isBold, e.isItalic = t.payload.isItalic, e.isStrikethrough = t.payload.isStrikethrough, e.isUnderline = t.payload.isUnderline;
|
|
78
|
+
},
|
|
79
|
+
setStyleFormats(e, t) {
|
|
80
|
+
e.backgroundColor = t.payload.backgroundColor, e.fontFamily = t.payload.fontFamily, e.fontSize = t.payload.fontSize, e.textColor = t.payload.textColor;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}), { setCanRedo: V, setCanUndo: H, setStyleFormats: U, setTextFormats: W } = B.actions, G = B.reducer, K = () => T({ reducer: { toolbar: G } });
|
|
84
|
+
K();
|
|
85
|
+
//#endregion
|
|
86
|
+
//#region src/store/hooks.ts
|
|
87
|
+
var q = C.withTypes(), J = w.withTypes();
|
|
88
|
+
//#endregion
|
|
89
|
+
//#region src/assets/icons/AlignCenterIcon.tsx
|
|
90
|
+
function Y(e) {
|
|
91
|
+
return /* @__PURE__ */ j("svg", {
|
|
92
|
+
width: "24",
|
|
93
|
+
height: "24",
|
|
94
|
+
viewBox: "0 0 24 24",
|
|
95
|
+
fill: "none",
|
|
96
|
+
...e,
|
|
97
|
+
children: /* @__PURE__ */ j("path", {
|
|
98
|
+
d: "M18 10H6M21 6H3M21 14H3M18 18H6",
|
|
99
|
+
stroke: "currentColor",
|
|
100
|
+
strokeWidth: "2",
|
|
101
|
+
strokeLinecap: "round",
|
|
102
|
+
strokeLinejoin: "round"
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/assets/icons/AlignJustifyIcon.tsx
|
|
108
|
+
function ae(e) {
|
|
109
|
+
return /* @__PURE__ */ j("svg", {
|
|
110
|
+
width: "24",
|
|
111
|
+
height: "24",
|
|
112
|
+
viewBox: "0 0 24 24",
|
|
113
|
+
fill: "none",
|
|
114
|
+
...e,
|
|
115
|
+
children: /* @__PURE__ */ j("path", {
|
|
116
|
+
d: "M21 10H3M21 18H3M21 6H3M21 14H3",
|
|
117
|
+
stroke: "currentColor",
|
|
118
|
+
strokeWidth: "2",
|
|
119
|
+
strokeLinecap: "round",
|
|
120
|
+
strokeLinejoin: "round"
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/assets/icons/AlignLeftIcon.tsx
|
|
126
|
+
function oe(e) {
|
|
127
|
+
return /* @__PURE__ */ j("svg", {
|
|
128
|
+
width: "24",
|
|
129
|
+
height: "24",
|
|
130
|
+
viewBox: "0 0 24 24",
|
|
131
|
+
fill: "none",
|
|
132
|
+
...e,
|
|
133
|
+
children: /* @__PURE__ */ j("path", {
|
|
134
|
+
d: "M16 10H3M20 6H3M20 14H3M16 18H3",
|
|
135
|
+
stroke: "currentColor",
|
|
136
|
+
strokeWidth: "2",
|
|
137
|
+
strokeLinecap: "round",
|
|
138
|
+
strokeLinejoin: "round"
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/assets/icons/AlignRightIcon.tsx
|
|
144
|
+
function se(e) {
|
|
145
|
+
return /* @__PURE__ */ j("svg", {
|
|
146
|
+
width: "24",
|
|
147
|
+
height: "24",
|
|
148
|
+
viewBox: "0 0 24 24",
|
|
149
|
+
fill: "none",
|
|
150
|
+
...e,
|
|
151
|
+
children: /* @__PURE__ */ j("path", {
|
|
152
|
+
d: "M21 10H8M21 6H4M21 14H4M21 18H8",
|
|
153
|
+
stroke: "currentColor",
|
|
154
|
+
strokeWidth: "2",
|
|
155
|
+
strokeLinecap: "round",
|
|
156
|
+
strokeLinejoin: "round"
|
|
157
|
+
})
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
//#endregion
|
|
161
|
+
//#region src/components/toolbar/alignment/AlignmentControls.tsx
|
|
162
|
+
function X({ editor: e }) {
|
|
163
|
+
return /* @__PURE__ */ M(A, { children: [
|
|
164
|
+
/* @__PURE__ */ j("button", {
|
|
165
|
+
"aria-label": "Align left",
|
|
166
|
+
onClick: () => e.dispatchCommand(o, "left"),
|
|
167
|
+
type: "button",
|
|
168
|
+
children: /* @__PURE__ */ j(oe, {})
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ j("button", {
|
|
171
|
+
"aria-label": "Align center",
|
|
172
|
+
onClick: () => e.dispatchCommand(o, "center"),
|
|
173
|
+
type: "button",
|
|
174
|
+
children: /* @__PURE__ */ j(Y, {})
|
|
175
|
+
}),
|
|
176
|
+
/* @__PURE__ */ j("button", {
|
|
177
|
+
"aria-label": "Align right",
|
|
178
|
+
onClick: () => e.dispatchCommand(o, "right"),
|
|
179
|
+
type: "button",
|
|
180
|
+
children: /* @__PURE__ */ j(se, {})
|
|
181
|
+
}),
|
|
182
|
+
/* @__PURE__ */ j("button", {
|
|
183
|
+
"aria-label": "Align justify",
|
|
184
|
+
onClick: () => e.dispatchCommand(o, "justify"),
|
|
185
|
+
type: "button",
|
|
186
|
+
children: /* @__PURE__ */ j(ae, {})
|
|
187
|
+
})
|
|
188
|
+
] });
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/components/toolbar/divider/ToolbarDivider.tsx
|
|
192
|
+
function Z() {
|
|
193
|
+
return /* @__PURE__ */ j("span", { className: "rj-editor-toolbar-divider" });
|
|
194
|
+
}
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/assets/icons/FlipBackwardIcon.tsx
|
|
197
|
+
function ce(e) {
|
|
198
|
+
return /* @__PURE__ */ j("svg", {
|
|
199
|
+
width: "24",
|
|
200
|
+
height: "24",
|
|
201
|
+
viewBox: "0 0 24 24",
|
|
202
|
+
fill: "none",
|
|
203
|
+
...e,
|
|
204
|
+
children: /* @__PURE__ */ j("path", {
|
|
205
|
+
d: "M3 9H16.5C18.9853 9 21 11.0147 21 13.5C21 15.9853 18.9853 18 16.5 18H12M7 13L3 9L7 5",
|
|
206
|
+
stroke: "currentColor",
|
|
207
|
+
strokeWidth: "2",
|
|
208
|
+
strokeLinecap: "round",
|
|
209
|
+
strokeLinejoin: "round"
|
|
210
|
+
})
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/assets/icons/FlipForwardIcon.tsx
|
|
215
|
+
function le(e) {
|
|
216
|
+
return /* @__PURE__ */ j("svg", {
|
|
217
|
+
width: "24",
|
|
218
|
+
height: "24",
|
|
219
|
+
viewBox: "0 0 24 24",
|
|
220
|
+
fill: "none",
|
|
221
|
+
...e,
|
|
222
|
+
children: /* @__PURE__ */ j("path", {
|
|
223
|
+
d: "M21 9H7.5C5.01472 9 3 11.0147 3 13.5C3 15.9853 5.01472 18 7.5 18H12M17 13L21 9L17 5",
|
|
224
|
+
stroke: "currentColor",
|
|
225
|
+
strokeWidth: "2",
|
|
226
|
+
strokeLinecap: "round",
|
|
227
|
+
strokeLinejoin: "round"
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/components/toolbar/history/HistoryControls.tsx
|
|
233
|
+
function ue({ editor: e }) {
|
|
234
|
+
let { canRedo: t, canUndo: n } = J((e) => e.toolbar);
|
|
235
|
+
return /* @__PURE__ */ M(A, { children: [/* @__PURE__ */ j("button", {
|
|
236
|
+
"aria-label": "Undo",
|
|
237
|
+
disabled: !n,
|
|
238
|
+
onClick: () => e.dispatchCommand(u, void 0),
|
|
239
|
+
type: "button",
|
|
240
|
+
children: /* @__PURE__ */ j(ce, {})
|
|
241
|
+
}), /* @__PURE__ */ j("button", {
|
|
242
|
+
"aria-label": "Redo",
|
|
243
|
+
disabled: !t,
|
|
244
|
+
onClick: () => e.dispatchCommand(c, void 0),
|
|
245
|
+
type: "button",
|
|
246
|
+
children: /* @__PURE__ */ j(le, {})
|
|
247
|
+
})] });
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/assets/icons/ClearOrderListIcon.tsx
|
|
251
|
+
function de(e) {
|
|
252
|
+
return /* @__PURE__ */ j("svg", {
|
|
253
|
+
width: "24",
|
|
254
|
+
height: "24",
|
|
255
|
+
viewBox: "0 0 24 24",
|
|
256
|
+
fill: "none",
|
|
257
|
+
...e,
|
|
258
|
+
children: /* @__PURE__ */ j("path", {
|
|
259
|
+
d: "M21 5.00001L10 5.00001M21 19L10 19M21 12L12 12M6 5.00001C5.5 5.00004 5.32843 5.00001 4.5 5.00001C3.67157 5.00001 3.5 4.99999 3 5.00001M6 19C5.5 19 5.32843 19 4.5 19C3.67157 19 3.5 19 3 19M11 8C9 10 7 12 7 12M7 12C7 12 5 10 3 8M7 12C7 12 9 14 11 16M7 12C7 12 5 14 3 16",
|
|
260
|
+
stroke: "currentColor",
|
|
261
|
+
strokeWidth: "2",
|
|
262
|
+
strokeLinecap: "round",
|
|
263
|
+
strokeLinejoin: "round"
|
|
264
|
+
})
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/assets/icons/DotpointsIcon01.tsx
|
|
269
|
+
function fe(e) {
|
|
270
|
+
return /* @__PURE__ */ j("svg", {
|
|
271
|
+
width: "24",
|
|
272
|
+
height: "24",
|
|
273
|
+
viewBox: "0 0 24 24",
|
|
274
|
+
fill: "none",
|
|
275
|
+
...e,
|
|
276
|
+
children: /* @__PURE__ */ j("path", {
|
|
277
|
+
d: "M21 12L9 12M21 6L9 6M21 18L9 18M5 12C5 12.5523 4.55228 13 4 13C3.44772 13 3 12.5523 3 12C3 11.4477 3.44772 11 4 11C4.55228 11 5 11.4477 5 12ZM5 6C5 6.55228 4.55228 7 4 7C3.44772 7 3 6.55228 3 6C3 5.44772 3.44772 5 4 5C4.55228 5 5 5.44772 5 6ZM5 18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18C3 17.4477 3.44772 17 4 17C4.55228 17 5 17.4477 5 18Z",
|
|
278
|
+
stroke: "currentColor",
|
|
279
|
+
strokeWidth: "2",
|
|
280
|
+
strokeLinecap: "round",
|
|
281
|
+
strokeLinejoin: "round"
|
|
282
|
+
})
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/assets/icons/OrderListIcon.tsx
|
|
287
|
+
function pe(e) {
|
|
288
|
+
return /* @__PURE__ */ j("svg", {
|
|
289
|
+
width: "24",
|
|
290
|
+
height: "24",
|
|
291
|
+
viewBox: "0 0 24 24",
|
|
292
|
+
fill: "none",
|
|
293
|
+
...e,
|
|
294
|
+
children: /* @__PURE__ */ j("path", {
|
|
295
|
+
d: "M21 5.00001L10 5.00001M21 19L10 19M21 12L10 12M6 5.00001C5.5 5.00004 5.32843 5.00001 4.5 5.00001C3.67157 5.00001 3.5 4.99999 3 5.00001M6 19C5.5 19 5.32843 19 4.5 19C3.67157 19 3.5 19 3 19M6 12C5.5 12 5.32843 12 4.5 12C3.67157 12 3.5 12 3 12",
|
|
296
|
+
stroke: "currentColor",
|
|
297
|
+
strokeWidth: "2",
|
|
298
|
+
strokeLinecap: "round",
|
|
299
|
+
strokeLinejoin: "round"
|
|
300
|
+
})
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/components/toolbar/list/ListControls.tsx
|
|
305
|
+
function me({ editor: e }) {
|
|
306
|
+
return /* @__PURE__ */ M(A, { children: [
|
|
307
|
+
/* @__PURE__ */ j("button", {
|
|
308
|
+
"aria-label": "Bulleted list",
|
|
309
|
+
onClick: () => e.dispatchCommand(f, void 0),
|
|
310
|
+
type: "button",
|
|
311
|
+
children: /* @__PURE__ */ j(fe, {})
|
|
312
|
+
}),
|
|
313
|
+
/* @__PURE__ */ j("button", {
|
|
314
|
+
"aria-label": "Numbered list",
|
|
315
|
+
onClick: () => e.dispatchCommand(d, void 0),
|
|
316
|
+
type: "button",
|
|
317
|
+
children: /* @__PURE__ */ j(pe, {})
|
|
318
|
+
}),
|
|
319
|
+
/* @__PURE__ */ j("button", {
|
|
320
|
+
"aria-label": "Remove list",
|
|
321
|
+
onClick: () => e.dispatchCommand(h, void 0),
|
|
322
|
+
type: "button",
|
|
323
|
+
className: "rj-editor-toolbar--clear-btn",
|
|
324
|
+
children: /* @__PURE__ */ j(de, {})
|
|
325
|
+
})
|
|
326
|
+
] });
|
|
327
|
+
}
|
|
328
|
+
//#endregion
|
|
329
|
+
//#region src/components/toolbar/style-controls/utils.ts
|
|
330
|
+
function Q(e, r) {
|
|
331
|
+
e.focus(() => {
|
|
332
|
+
e.update(() => {
|
|
333
|
+
let e = t();
|
|
334
|
+
n(e) && O(e, r);
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
function he(e) {
|
|
339
|
+
e.update(() => {
|
|
340
|
+
let e = t();
|
|
341
|
+
n(e) && (O(e, {
|
|
342
|
+
"background-color": null,
|
|
343
|
+
color: null,
|
|
344
|
+
"font-family": null,
|
|
345
|
+
"font-size": null
|
|
346
|
+
}), [
|
|
347
|
+
"bold",
|
|
348
|
+
"italic",
|
|
349
|
+
"strikethrough",
|
|
350
|
+
"underline"
|
|
351
|
+
].forEach((t) => {
|
|
352
|
+
e.hasFormat(t) && e.formatText(t);
|
|
353
|
+
}));
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/components/toolbar/style-controls/background-color/BackgroundColorControl.tsx
|
|
358
|
+
function ge() {
|
|
359
|
+
let [e] = k(), [t, n] = x(!1), [r, i] = x(null), a = q(), o = J((e) => e.toolbar), s = o.backgroundColor, c = (t) => {
|
|
360
|
+
Q(e, { "background-color": t || null }), a(U({
|
|
361
|
+
...o,
|
|
362
|
+
backgroundColor: t
|
|
363
|
+
}));
|
|
364
|
+
};
|
|
365
|
+
return /* @__PURE__ */ j(N, {
|
|
366
|
+
menu: { items: [
|
|
367
|
+
{
|
|
368
|
+
key: "none",
|
|
369
|
+
label: /* @__PURE__ */ M("button", {
|
|
370
|
+
className: "rj-editor-color-menu-item",
|
|
371
|
+
onClick: () => {
|
|
372
|
+
c(""), n(!1);
|
|
373
|
+
},
|
|
374
|
+
type: "button",
|
|
375
|
+
children: [/* @__PURE__ */ j("span", { className: "rj-editor-color-none" }), "None"]
|
|
376
|
+
})
|
|
377
|
+
},
|
|
378
|
+
...F.map((e) => ({
|
|
379
|
+
key: e,
|
|
380
|
+
label: /* @__PURE__ */ M("button", {
|
|
381
|
+
className: "rj-editor-color-menu-item",
|
|
382
|
+
onClick: () => {
|
|
383
|
+
c(e), n(!1);
|
|
384
|
+
},
|
|
385
|
+
type: "button",
|
|
386
|
+
children: [/* @__PURE__ */ j("span", {
|
|
387
|
+
className: "rj-editor-color-swatch",
|
|
388
|
+
style: { backgroundColor: e }
|
|
389
|
+
}), e]
|
|
390
|
+
})
|
|
391
|
+
})),
|
|
392
|
+
{ type: "divider" },
|
|
393
|
+
{
|
|
394
|
+
key: "more-colors",
|
|
395
|
+
label: /* @__PURE__ */ M("label", {
|
|
396
|
+
className: "rj-editor-color-menu-item",
|
|
397
|
+
onClick: (e) => e.stopPropagation(),
|
|
398
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
399
|
+
children: [
|
|
400
|
+
/* @__PURE__ */ j("span", {
|
|
401
|
+
className: "rj-editor-color-swatch",
|
|
402
|
+
style: { backgroundColor: s || F[0] }
|
|
403
|
+
}),
|
|
404
|
+
"More colors",
|
|
405
|
+
/* @__PURE__ */ j("input", {
|
|
406
|
+
"aria-label": "More background colors",
|
|
407
|
+
className: "rj-editor-color-menu-input",
|
|
408
|
+
onChange: (e) => {
|
|
409
|
+
c(e.target.value), i(e.target.value), n(!0);
|
|
410
|
+
},
|
|
411
|
+
onClick: (e) => e.stopPropagation(),
|
|
412
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
413
|
+
type: "color",
|
|
414
|
+
value: s || F[0]
|
|
415
|
+
})
|
|
416
|
+
]
|
|
417
|
+
})
|
|
418
|
+
}
|
|
419
|
+
] },
|
|
420
|
+
onOpenChange: (t) => {
|
|
421
|
+
n(t), !t && r && (window.setTimeout(() => {
|
|
422
|
+
Q(e, { "background-color": r });
|
|
423
|
+
}), i(null));
|
|
424
|
+
},
|
|
425
|
+
open: t,
|
|
426
|
+
trigger: ["click"],
|
|
427
|
+
children: /* @__PURE__ */ j("button", {
|
|
428
|
+
"aria-label": "Background color",
|
|
429
|
+
className: "rj-editor-color-button",
|
|
430
|
+
type: "button",
|
|
431
|
+
children: /* @__PURE__ */ j("span", {
|
|
432
|
+
className: s ? "rj-editor-background-color-mark" : "rj-editor-background-color-mark is-none",
|
|
433
|
+
style: s ? { backgroundColor: s } : void 0,
|
|
434
|
+
children: "Bg"
|
|
435
|
+
})
|
|
436
|
+
})
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/assets/icons/XCloseIcon.tsx
|
|
441
|
+
function _e(e) {
|
|
442
|
+
return /* @__PURE__ */ j("svg", {
|
|
443
|
+
width: "24",
|
|
444
|
+
height: "24",
|
|
445
|
+
viewBox: "0 0 24 24",
|
|
446
|
+
fill: "none",
|
|
447
|
+
...e,
|
|
448
|
+
children: /* @__PURE__ */ j("path", {
|
|
449
|
+
d: "M18 6L6 18M6 6L18 18",
|
|
450
|
+
stroke: "currentColor",
|
|
451
|
+
strokeWidth: "2",
|
|
452
|
+
strokeLinecap: "round",
|
|
453
|
+
strokeLinejoin: "round"
|
|
454
|
+
})
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/components/toolbar/style-controls/clear-formatting/ClearFormattingControl.tsx
|
|
459
|
+
function ve() {
|
|
460
|
+
let [e] = k(), t = q();
|
|
461
|
+
return /* @__PURE__ */ j("button", {
|
|
462
|
+
"aria-label": "Clear formatting",
|
|
463
|
+
onClick: () => {
|
|
464
|
+
he(e), t(W({
|
|
465
|
+
isBold: !1,
|
|
466
|
+
isItalic: !1,
|
|
467
|
+
isStrikethrough: !1,
|
|
468
|
+
isUnderline: !1
|
|
469
|
+
})), t(U({
|
|
470
|
+
backgroundColor: R.backgroundColor,
|
|
471
|
+
fontFamily: R.fontFamily,
|
|
472
|
+
fontSize: R.fontSize,
|
|
473
|
+
textColor: R.textColor
|
|
474
|
+
}));
|
|
475
|
+
},
|
|
476
|
+
type: "button",
|
|
477
|
+
className: "rj-editor-toolbar--clear-btn",
|
|
478
|
+
children: /* @__PURE__ */ j(_e, {})
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/assets/icons/ChevronDownIcon.tsx
|
|
483
|
+
function $(e) {
|
|
484
|
+
return /* @__PURE__ */ j("svg", {
|
|
485
|
+
width: "24",
|
|
486
|
+
height: "24",
|
|
487
|
+
viewBox: "0 0 24 24",
|
|
488
|
+
fill: "none",
|
|
489
|
+
...e,
|
|
490
|
+
children: /* @__PURE__ */ j("path", {
|
|
491
|
+
d: "M6 9L12 15L18 9",
|
|
492
|
+
stroke: "currentColor",
|
|
493
|
+
strokeWidth: "2",
|
|
494
|
+
strokeLinecap: "round",
|
|
495
|
+
strokeLinejoin: "round"
|
|
496
|
+
})
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region src/components/toolbar/style-controls/font-family/FontFamilyControl.tsx
|
|
501
|
+
function ye() {
|
|
502
|
+
let [e] = k(), t = q(), n = J((e) => e.toolbar);
|
|
503
|
+
return console.log(n.fontFamily), /* @__PURE__ */ j(P, {
|
|
504
|
+
"aria-label": "Font family",
|
|
505
|
+
className: "rj-editor-toolbar-select rj-editor-toolbar-select-font",
|
|
506
|
+
onChange: (r = "") => {
|
|
507
|
+
Q(e, { "font-family": r || null }), t(U({
|
|
508
|
+
...n,
|
|
509
|
+
fontFamily: r
|
|
510
|
+
}));
|
|
511
|
+
},
|
|
512
|
+
options: I.map((e) => ({
|
|
513
|
+
label: e,
|
|
514
|
+
value: e
|
|
515
|
+
})),
|
|
516
|
+
placeholder: "Font",
|
|
517
|
+
popupMatchSelectWidth: !1,
|
|
518
|
+
size: "small",
|
|
519
|
+
value: n.fontFamily == "" ? void 0 : n.fontFamily,
|
|
520
|
+
suffixIcon: /* @__PURE__ */ j($, {})
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/components/toolbar/style-controls/font-size/FontSizeControl.tsx
|
|
525
|
+
function be() {
|
|
526
|
+
let [e] = k(), t = q(), n = J((e) => e.toolbar);
|
|
527
|
+
return /* @__PURE__ */ j(P, {
|
|
528
|
+
"aria-label": "Font size",
|
|
529
|
+
className: "rj-editor-toolbar-select",
|
|
530
|
+
onChange: (r = "") => {
|
|
531
|
+
Q(e, { "font-size": r || null }), t(U({
|
|
532
|
+
...n,
|
|
533
|
+
fontSize: r
|
|
534
|
+
}));
|
|
535
|
+
},
|
|
536
|
+
options: L.map((e) => ({
|
|
537
|
+
label: e.replace("px", ""),
|
|
538
|
+
value: e
|
|
539
|
+
})),
|
|
540
|
+
placeholder: "Size",
|
|
541
|
+
popupMatchSelectWidth: !1,
|
|
542
|
+
size: "small",
|
|
543
|
+
value: n.fontSize == "" ? void 0 : n.fontSize,
|
|
544
|
+
suffixIcon: /* @__PURE__ */ j($, {})
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
//#endregion
|
|
548
|
+
//#region src/components/toolbar/style-controls/text-color/TextColorControl.tsx
|
|
549
|
+
function xe() {
|
|
550
|
+
let [e] = k(), [t, n] = x(!1), [r, i] = x(null), a = q(), o = J((e) => e.toolbar), s = o.textColor, c = (t) => {
|
|
551
|
+
Q(e, { color: t || null }), a(U({
|
|
552
|
+
...o,
|
|
553
|
+
textColor: t
|
|
554
|
+
}));
|
|
555
|
+
};
|
|
556
|
+
return /* @__PURE__ */ j(N, {
|
|
557
|
+
menu: { items: [
|
|
558
|
+
{
|
|
559
|
+
key: "none",
|
|
560
|
+
label: /* @__PURE__ */ M("button", {
|
|
561
|
+
className: "rj-editor-color-menu-item",
|
|
562
|
+
onClick: () => {
|
|
563
|
+
c(""), n(!1);
|
|
564
|
+
},
|
|
565
|
+
type: "button",
|
|
566
|
+
children: [/* @__PURE__ */ j("span", { className: "rj-editor-color-none" }), "None"]
|
|
567
|
+
})
|
|
568
|
+
},
|
|
569
|
+
...z.map((e) => ({
|
|
570
|
+
key: e,
|
|
571
|
+
label: /* @__PURE__ */ M("button", {
|
|
572
|
+
className: "rj-editor-color-menu-item",
|
|
573
|
+
onClick: () => {
|
|
574
|
+
c(e), n(!1);
|
|
575
|
+
},
|
|
576
|
+
type: "button",
|
|
577
|
+
children: [/* @__PURE__ */ j("span", {
|
|
578
|
+
className: "rj-editor-color-swatch",
|
|
579
|
+
style: { backgroundColor: e }
|
|
580
|
+
}), e]
|
|
581
|
+
})
|
|
582
|
+
})),
|
|
583
|
+
{ type: "divider" },
|
|
584
|
+
{
|
|
585
|
+
key: "more-colors",
|
|
586
|
+
label: /* @__PURE__ */ M("label", {
|
|
587
|
+
className: "rj-editor-color-menu-item",
|
|
588
|
+
onClick: (e) => e.stopPropagation(),
|
|
589
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
590
|
+
children: [
|
|
591
|
+
/* @__PURE__ */ j("span", {
|
|
592
|
+
className: "rj-editor-color-swatch",
|
|
593
|
+
style: { backgroundColor: s || z[0] }
|
|
594
|
+
}),
|
|
595
|
+
"More colors",
|
|
596
|
+
/* @__PURE__ */ j("input", {
|
|
597
|
+
"aria-label": "More text colors",
|
|
598
|
+
className: "rj-editor-color-menu-input",
|
|
599
|
+
onChange: (e) => {
|
|
600
|
+
c(e.target.value), i(e.target.value), n(!0);
|
|
601
|
+
},
|
|
602
|
+
onClick: (e) => e.stopPropagation(),
|
|
603
|
+
onMouseDown: (e) => e.stopPropagation(),
|
|
604
|
+
type: "color",
|
|
605
|
+
value: s || z[0]
|
|
606
|
+
})
|
|
607
|
+
]
|
|
608
|
+
})
|
|
609
|
+
}
|
|
610
|
+
] },
|
|
611
|
+
onOpenChange: (t) => {
|
|
612
|
+
n(t), !t && r && (window.setTimeout(() => {
|
|
613
|
+
Q(e, { color: r });
|
|
614
|
+
}), i(null));
|
|
615
|
+
},
|
|
616
|
+
open: t,
|
|
617
|
+
trigger: ["click"],
|
|
618
|
+
children: /* @__PURE__ */ j("button", {
|
|
619
|
+
"aria-label": "Text color",
|
|
620
|
+
className: "rj-editor-color-button",
|
|
621
|
+
type: "button",
|
|
622
|
+
children: /* @__PURE__ */ M("span", {
|
|
623
|
+
className: "rj-editor-text-color-mark",
|
|
624
|
+
children: ["A", /* @__PURE__ */ j("span", {
|
|
625
|
+
className: "rj-editor-text-color-line",
|
|
626
|
+
style: { backgroundColor: s || "currentColor" }
|
|
627
|
+
})]
|
|
628
|
+
})
|
|
629
|
+
})
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
//#endregion
|
|
633
|
+
//#region src/components/toolbar/style-controls/StyleControls.tsx
|
|
634
|
+
function Se() {
|
|
635
|
+
return /* @__PURE__ */ M(A, { children: [
|
|
636
|
+
/* @__PURE__ */ j(be, {}),
|
|
637
|
+
/* @__PURE__ */ j(ye, {}),
|
|
638
|
+
/* @__PURE__ */ j(xe, {}),
|
|
639
|
+
/* @__PURE__ */ j(ge, {}),
|
|
640
|
+
/* @__PURE__ */ j(ve, {})
|
|
641
|
+
] });
|
|
642
|
+
}
|
|
643
|
+
//#endregion
|
|
644
|
+
//#region src/assets/icons/StrikethroughIcon01.tsx
|
|
645
|
+
function Ce(e) {
|
|
646
|
+
return /* @__PURE__ */ j("svg", {
|
|
647
|
+
width: "24",
|
|
648
|
+
height: "24",
|
|
649
|
+
viewBox: "0 0 24 24",
|
|
650
|
+
fill: "none",
|
|
651
|
+
...e,
|
|
652
|
+
children: /* @__PURE__ */ j("path", {
|
|
653
|
+
d: "M6 16C6 18.2091 7.79086 20 10 20H14C16.2091 20 18 18.2091 18 16C18 13.7909 16.2091 12 14 12M18 8C18 5.79086 16.2091 4 14 4H10C7.79086 4 6 5.79086 6 8M3 12H21",
|
|
654
|
+
stroke: "currentColor",
|
|
655
|
+
strokeWidth: "2",
|
|
656
|
+
strokeLinecap: "round",
|
|
657
|
+
strokeLinejoin: "round"
|
|
658
|
+
})
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
//#endregion
|
|
662
|
+
//#region src/assets/icons/BoldIcon01.tsx
|
|
663
|
+
function we(e) {
|
|
664
|
+
return /* @__PURE__ */ j("svg", {
|
|
665
|
+
width: "24",
|
|
666
|
+
height: "24",
|
|
667
|
+
viewBox: "0 0 24 24",
|
|
668
|
+
fill: "none",
|
|
669
|
+
...e,
|
|
670
|
+
children: /* @__PURE__ */ j("path", {
|
|
671
|
+
d: "M6 12H14C16.2091 12 18 10.2091 18 8C18 5.79086 16.2091 4 14 4H6V12ZM6 12H15C17.2091 12 19 13.7909 19 16C19 18.2091 17.2091 20 15 20H6V12Z",
|
|
672
|
+
stroke: "currentColor",
|
|
673
|
+
strokeWidth: "2",
|
|
674
|
+
strokeLinecap: "round",
|
|
675
|
+
strokeLinejoin: "round"
|
|
676
|
+
})
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/assets/icons/ItalicIcon01.tsx
|
|
681
|
+
function Te(e) {
|
|
682
|
+
return /* @__PURE__ */ j("svg", {
|
|
683
|
+
width: "24",
|
|
684
|
+
height: "24",
|
|
685
|
+
viewBox: "0 0 24 24",
|
|
686
|
+
fill: "none",
|
|
687
|
+
...e,
|
|
688
|
+
children: /* @__PURE__ */ j("path", {
|
|
689
|
+
d: "M19 4H10M14 20H5M15 4L9 20",
|
|
690
|
+
stroke: "currentColor",
|
|
691
|
+
strokeWidth: "2",
|
|
692
|
+
strokeLinecap: "round",
|
|
693
|
+
strokeLinejoin: "round"
|
|
694
|
+
})
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region src/assets/icons/UnderlineIcon01.tsx
|
|
699
|
+
function Ee(e) {
|
|
700
|
+
return /* @__PURE__ */ j("svg", {
|
|
701
|
+
width: "24",
|
|
702
|
+
height: "24",
|
|
703
|
+
viewBox: "0 0 24 24",
|
|
704
|
+
fill: "none",
|
|
705
|
+
...e,
|
|
706
|
+
children: /* @__PURE__ */ j("path", {
|
|
707
|
+
d: "M18 4V11C18 14.3137 15.3137 17 12 17C8.68629 17 6 14.3137 6 11V4M4 21H20",
|
|
708
|
+
stroke: "currentColor",
|
|
709
|
+
strokeWidth: "2",
|
|
710
|
+
strokeLinecap: "round",
|
|
711
|
+
strokeLinejoin: "round"
|
|
712
|
+
})
|
|
713
|
+
});
|
|
714
|
+
}
|
|
715
|
+
//#endregion
|
|
716
|
+
//#region src/components/toolbar/text-format/TextFormatControls.tsx
|
|
717
|
+
function De() {
|
|
718
|
+
let [e] = k(), { isBold: t, isItalic: n, isStrikethrough: r, isUnderline: i } = J((e) => e.toolbar);
|
|
719
|
+
return /* @__PURE__ */ M(A, { children: [
|
|
720
|
+
/* @__PURE__ */ j("button", {
|
|
721
|
+
"aria-pressed": t,
|
|
722
|
+
className: t ? "is-active" : void 0,
|
|
723
|
+
onClick: () => e.dispatchCommand(s, "bold"),
|
|
724
|
+
type: "button",
|
|
725
|
+
children: /* @__PURE__ */ j(we, {})
|
|
726
|
+
}),
|
|
727
|
+
/* @__PURE__ */ j("button", {
|
|
728
|
+
"aria-pressed": n,
|
|
729
|
+
className: n ? "is-active" : void 0,
|
|
730
|
+
onClick: () => e.dispatchCommand(s, "italic"),
|
|
731
|
+
type: "button",
|
|
732
|
+
children: /* @__PURE__ */ j(Te, {})
|
|
733
|
+
}),
|
|
734
|
+
/* @__PURE__ */ j("button", {
|
|
735
|
+
"aria-pressed": i,
|
|
736
|
+
className: i ? "is-active" : void 0,
|
|
737
|
+
onClick: () => e.dispatchCommand(s, "underline"),
|
|
738
|
+
type: "button",
|
|
739
|
+
children: /* @__PURE__ */ j(Ee, {})
|
|
740
|
+
}),
|
|
741
|
+
/* @__PURE__ */ j("button", {
|
|
742
|
+
"aria-label": "Strikethrough",
|
|
743
|
+
"aria-pressed": r,
|
|
744
|
+
className: r ? "is-active" : void 0,
|
|
745
|
+
onClick: () => e.dispatchCommand(s, "strikethrough"),
|
|
746
|
+
type: "button",
|
|
747
|
+
children: /* @__PURE__ */ j(Ce, { "aria-hidden": "true" })
|
|
748
|
+
})
|
|
749
|
+
] });
|
|
750
|
+
}
|
|
751
|
+
//#endregion
|
|
752
|
+
//#region src/components/toolbar/Toolbar.tsx
|
|
753
|
+
function Oe() {
|
|
754
|
+
let [e] = k(), o = q();
|
|
755
|
+
return ie.useEffect(() => {
|
|
756
|
+
let s = e.registerCommand(l, () => (e.getEditorState().read(() => {
|
|
757
|
+
let e = t();
|
|
758
|
+
n(e) && (o(W({
|
|
759
|
+
isBold: e.hasFormat("bold"),
|
|
760
|
+
isItalic: e.hasFormat("italic"),
|
|
761
|
+
isStrikethrough: e.hasFormat("strikethrough"),
|
|
762
|
+
isUnderline: e.hasFormat("underline")
|
|
763
|
+
})), o(U({
|
|
764
|
+
backgroundColor: D(e, "background-color", ""),
|
|
765
|
+
fontFamily: D(e, "font-family", ""),
|
|
766
|
+
fontSize: D(e, "font-size", ""),
|
|
767
|
+
textColor: D(e, "color", "")
|
|
768
|
+
})));
|
|
769
|
+
}), !1), a), c = e.registerCommand(i, (e) => (o(H(e)), !1), a), u = e.registerCommand(r, (e) => (o(V(e)), !1), a);
|
|
770
|
+
return () => {
|
|
771
|
+
s(), c(), u();
|
|
772
|
+
};
|
|
773
|
+
}, [o, e]), /* @__PURE__ */ M("div", {
|
|
774
|
+
className: "rj-editor-toolbar",
|
|
775
|
+
"aria-label": "Editor toolbar",
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ j(ue, { editor: e }),
|
|
778
|
+
/* @__PURE__ */ j(Z, {}),
|
|
779
|
+
/* @__PURE__ */ j(De, {}),
|
|
780
|
+
/* @__PURE__ */ j(Z, {}),
|
|
781
|
+
/* @__PURE__ */ j(Se, {}),
|
|
782
|
+
/* @__PURE__ */ j(Z, {}),
|
|
783
|
+
/* @__PURE__ */ j(me, { editor: e }),
|
|
784
|
+
/* @__PURE__ */ j(Z, {}),
|
|
785
|
+
/* @__PURE__ */ j(X, { editor: e })
|
|
786
|
+
]
|
|
787
|
+
});
|
|
788
|
+
}
|
|
789
|
+
//#endregion
|
|
790
|
+
//#region src/components/RJTextEditor.tsx
|
|
791
|
+
var ke = {
|
|
792
|
+
paragraph: "rj-editor-paragraph",
|
|
793
|
+
text: {
|
|
794
|
+
bold: "rj-editor-text-bold",
|
|
795
|
+
italic: "rj-editor-text-italic",
|
|
796
|
+
strikethrough: "rj-editor-text-strikethrough",
|
|
797
|
+
underline: "rj-editor-text-underline"
|
|
798
|
+
},
|
|
799
|
+
list: {
|
|
800
|
+
ol: "rj-editor-list-ol",
|
|
801
|
+
ul: "rj-editor-list-ul",
|
|
802
|
+
listitem: "rj-editor-list-item"
|
|
803
|
+
}
|
|
804
|
+
};
|
|
805
|
+
function Ae(t, n, r) {
|
|
806
|
+
r && t.read(() => {
|
|
807
|
+
r({
|
|
808
|
+
editorState: t,
|
|
809
|
+
html: e(n),
|
|
810
|
+
json: JSON.stringify(t.toJSON())
|
|
811
|
+
});
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
function je({ autofocus: e = !1, className: t, namespace: n = "RJEditor", onChange: r, placeholder: i = "Matn yozing..." }) {
|
|
815
|
+
return /* @__PURE__ */ j(S, {
|
|
816
|
+
store: b(() => K(), []),
|
|
817
|
+
children: /* @__PURE__ */ j(v, {
|
|
818
|
+
initialConfig: {
|
|
819
|
+
namespace: n,
|
|
820
|
+
nodes: [m, p],
|
|
821
|
+
onError(e) {
|
|
822
|
+
throw e;
|
|
823
|
+
},
|
|
824
|
+
theme: ke
|
|
825
|
+
},
|
|
826
|
+
children: /* @__PURE__ */ M("div", {
|
|
827
|
+
className: ["rj-editor", t].filter(Boolean).join(" "),
|
|
828
|
+
children: [/* @__PURE__ */ j(Oe, {}), /* @__PURE__ */ M("div", {
|
|
829
|
+
className: "rj-editor-body",
|
|
830
|
+
children: [
|
|
831
|
+
/* @__PURE__ */ j(re, {
|
|
832
|
+
contentEditable: /* @__PURE__ */ j(_, { className: "rj-editor-input" }),
|
|
833
|
+
ErrorBoundary: y,
|
|
834
|
+
placeholder: /* @__PURE__ */ j("div", {
|
|
835
|
+
className: "rj-editor-placeholder",
|
|
836
|
+
children: i
|
|
837
|
+
})
|
|
838
|
+
}),
|
|
839
|
+
/* @__PURE__ */ j(ee, {}),
|
|
840
|
+
/* @__PURE__ */ j(te, {}),
|
|
841
|
+
/* @__PURE__ */ j(ne, { onChange: (e, t) => Ae(e, t, r) }),
|
|
842
|
+
e ? /* @__PURE__ */ j(g, {}) : null
|
|
843
|
+
]
|
|
844
|
+
})]
|
|
845
|
+
})
|
|
846
|
+
})
|
|
847
|
+
});
|
|
848
|
+
}
|
|
849
|
+
//#endregion
|
|
850
|
+
export { je as RJTextEditor };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@lexical/html`),require(`lexical`),require(`@lexical/list`),require(`@lexical/react/LexicalAutoFocusPlugin`),require(`@lexical/react/LexicalContentEditable`),require(`@lexical/react/LexicalComposer`),require(`@lexical/react/LexicalErrorBoundary`),require(`@lexical/react/LexicalHistoryPlugin`),require(`@lexical/react/LexicalListPlugin`),require(`@lexical/react/LexicalOnChangePlugin`),require(`@lexical/react/LexicalRichTextPlugin`),require(`react`),require(`react-redux`),require(`@reduxjs/toolkit`),require(`@lexical/selection`),require(`@lexical/react/LexicalComposerContext`),require(`react/jsx-runtime`),require(`antd`)):typeof define==`function`&&define.amd?define([`exports`,`@lexical/html`,`lexical`,`@lexical/list`,`@lexical/react/LexicalAutoFocusPlugin`,`@lexical/react/LexicalContentEditable`,`@lexical/react/LexicalComposer`,`@lexical/react/LexicalErrorBoundary`,`@lexical/react/LexicalHistoryPlugin`,`@lexical/react/LexicalListPlugin`,`@lexical/react/LexicalOnChangePlugin`,`@lexical/react/LexicalRichTextPlugin`,`react`,`react-redux`,`@reduxjs/toolkit`,`@lexical/selection`,`@lexical/react/LexicalComposerContext`,`react/jsx-runtime`,`antd`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.RJEditor={},e.LexicalHtml,e.Lexical,e.LexicalList,e.LexicalReactAutoFocusPlugin,e.LexicalReactContentEditable,e.LexicalReactComposer,e.LexicalReactErrorBoundary,e.LexicalReactHistoryPlugin,e.LexicalReactListPlugin,e.LexicalReactOnChangePlugin,e.LexicalReactRichTextPlugin,e.React,e.ReactRedux,e.RTK,e.LexicalSelection,e.LexicalReactComposerContext,e.jsxRuntime,e.antd))})(this,function(e,t,n,r,i,a,o,s,c,ee,l,u,d,f,p,m,h,g,_){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var v=Object.create,y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,x=Object.getOwnPropertyNames,S=Object.getPrototypeOf,C=Object.prototype.hasOwnProperty,w=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=x(t),a=0,o=i.length,s;a<o;a++)s=i[a],!C.call(e,s)&&s!==n&&y(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=b(t,s))||r.enumerable});return e};d=((e,t,n)=>(n=e==null?{}:v(S(e)),w(t||!e||!e.__esModule?y(n,`default`,{value:e,enumerable:!0}):n,e)))(d,1);var T=[`#FFFFFF`,`#FEF3C7`,`#DBEAFE`,`#DCFCE7`,`#FCE7F3`,`#EDE9FE`,`#E5E7EB`],E=[`Arial`,`Georgia`,`Inter`,`Times New Roman`,`Trebuchet MS`,`Verdana`],te=[`8px`,`9px`,`11px`,`12px`,`14px`,`16px`,`18px`,`20px`,`24px`,`32px`,`48px`,`72px`],D={backgroundColor:``,canRedo:!1,canUndo:!1,fontFamily:void 0,fontSize:void 0,isBold:!1,isItalic:!1,isStrikethrough:!1,isUnderline:!1,textColor:``},O=[`#111827`,`#dc2626`,`#2563eb`,`#059669`,`#9333ea`,`#ca8a04`],k=(0,p.createSlice)({name:`toolbar`,initialState:D,reducers:{setCanRedo(e,t){e.canRedo=t.payload},setCanUndo(e,t){e.canUndo=t.payload},setTextFormats(e,t){e.isBold=t.payload.isBold,e.isItalic=t.payload.isItalic,e.isStrikethrough=t.payload.isStrikethrough,e.isUnderline=t.payload.isUnderline},setStyleFormats(e,t){e.backgroundColor=t.payload.backgroundColor,e.fontFamily=t.payload.fontFamily,e.fontSize=t.payload.fontSize,e.textColor=t.payload.textColor}}}),{setCanRedo:A,setCanUndo:j,setStyleFormats:M,setTextFormats:N}=k.actions,P=k.reducer,F=()=>(0,p.configureStore)({reducer:{toolbar:P}});F();var I=f.useDispatch.withTypes(),L=f.useSelector.withTypes();function R(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M18 10H6M21 6H3M21 14H3M18 18H6`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function z(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M21 10H3M21 18H3M21 6H3M21 14H3`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function B(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M16 10H3M20 6H3M20 14H3M16 18H3`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function V(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M21 10H8M21 6H4M21 14H4M21 18H8`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function H({editor:e}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{"aria-label":`Align left`,onClick:()=>e.dispatchCommand(n.FORMAT_ELEMENT_COMMAND,`left`),type:`button`,children:(0,g.jsx)(B,{})}),(0,g.jsx)(`button`,{"aria-label":`Align center`,onClick:()=>e.dispatchCommand(n.FORMAT_ELEMENT_COMMAND,`center`),type:`button`,children:(0,g.jsx)(R,{})}),(0,g.jsx)(`button`,{"aria-label":`Align right`,onClick:()=>e.dispatchCommand(n.FORMAT_ELEMENT_COMMAND,`right`),type:`button`,children:(0,g.jsx)(V,{})}),(0,g.jsx)(`button`,{"aria-label":`Align justify`,onClick:()=>e.dispatchCommand(n.FORMAT_ELEMENT_COMMAND,`justify`),type:`button`,children:(0,g.jsx)(z,{})})]})}function U(){return(0,g.jsx)(`span`,{className:`rj-editor-toolbar-divider`})}function W(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M3 9H16.5C18.9853 9 21 11.0147 21 13.5C21 15.9853 18.9853 18 16.5 18H12M7 13L3 9L7 5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function G(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M21 9H7.5C5.01472 9 3 11.0147 3 13.5C3 15.9853 5.01472 18 7.5 18H12M17 13L21 9L17 5`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function K({editor:e}){let{canRedo:t,canUndo:r}=L(e=>e.toolbar);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{"aria-label":`Undo`,disabled:!r,onClick:()=>e.dispatchCommand(n.UNDO_COMMAND,void 0),type:`button`,children:(0,g.jsx)(W,{})}),(0,g.jsx)(`button`,{"aria-label":`Redo`,disabled:!t,onClick:()=>e.dispatchCommand(n.REDO_COMMAND,void 0),type:`button`,children:(0,g.jsx)(G,{})})]})}function q(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M21 5.00001L10 5.00001M21 19L10 19M21 12L12 12M6 5.00001C5.5 5.00004 5.32843 5.00001 4.5 5.00001C3.67157 5.00001 3.5 4.99999 3 5.00001M6 19C5.5 19 5.32843 19 4.5 19C3.67157 19 3.5 19 3 19M11 8C9 10 7 12 7 12M7 12C7 12 5 10 3 8M7 12C7 12 9 14 11 16M7 12C7 12 5 14 3 16`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ne(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M21 12L9 12M21 6L9 6M21 18L9 18M5 12C5 12.5523 4.55228 13 4 13C3.44772 13 3 12.5523 3 12C3 11.4477 3.44772 11 4 11C4.55228 11 5 11.4477 5 12ZM5 6C5 6.55228 4.55228 7 4 7C3.44772 7 3 6.55228 3 6C3 5.44772 3.44772 5 4 5C4.55228 5 5 5.44772 5 6ZM5 18C5 18.5523 4.55228 19 4 19C3.44772 19 3 18.5523 3 18C3 17.4477 3.44772 17 4 17C4.55228 17 5 17.4477 5 18Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function J(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M21 5.00001L10 5.00001M21 19L10 19M21 12L10 12M6 5.00001C5.5 5.00004 5.32843 5.00001 4.5 5.00001C3.67157 5.00001 3.5 4.99999 3 5.00001M6 19C5.5 19 5.32843 19 4.5 19C3.67157 19 3.5 19 3 19M6 12C5.5 12 5.32843 12 4.5 12C3.67157 12 3.5 12 3 12`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Y({editor:e}){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{"aria-label":`Bulleted list`,onClick:()=>e.dispatchCommand(r.INSERT_UNORDERED_LIST_COMMAND,void 0),type:`button`,children:(0,g.jsx)(ne,{})}),(0,g.jsx)(`button`,{"aria-label":`Numbered list`,onClick:()=>e.dispatchCommand(r.INSERT_ORDERED_LIST_COMMAND,void 0),type:`button`,children:(0,g.jsx)(J,{})}),(0,g.jsx)(`button`,{"aria-label":`Remove list`,onClick:()=>e.dispatchCommand(r.REMOVE_LIST_COMMAND,void 0),type:`button`,className:`rj-editor-toolbar--clear-btn`,children:(0,g.jsx)(q,{})})]})}function X(e,t){e.focus(()=>{e.update(()=>{let e=(0,n.$getSelection)();(0,n.$isRangeSelection)(e)&&(0,m.$patchStyleText)(e,t)})})}function Z(e){e.update(()=>{let e=(0,n.$getSelection)();(0,n.$isRangeSelection)(e)&&((0,m.$patchStyleText)(e,{"background-color":null,color:null,"font-family":null,"font-size":null}),[`bold`,`italic`,`strikethrough`,`underline`].forEach(t=>{e.hasFormat(t)&&e.formatText(t)}))})}function re(){let[e]=(0,h.useLexicalComposerContext)(),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(null),a=I(),o=L(e=>e.toolbar),s=o.backgroundColor,c=t=>{X(e,{"background-color":t||null}),a(M({...o,backgroundColor:t}))};return(0,g.jsx)(_.Dropdown,{menu:{items:[{key:`none`,label:(0,g.jsxs)(`button`,{className:`rj-editor-color-menu-item`,onClick:()=>{c(``),n(!1)},type:`button`,children:[(0,g.jsx)(`span`,{className:`rj-editor-color-none`}),`None`]})},...T.map(e=>({key:e,label:(0,g.jsxs)(`button`,{className:`rj-editor-color-menu-item`,onClick:()=>{c(e),n(!1)},type:`button`,children:[(0,g.jsx)(`span`,{className:`rj-editor-color-swatch`,style:{backgroundColor:e}}),e]})})),{type:`divider`},{key:`more-colors`,label:(0,g.jsxs)(`label`,{className:`rj-editor-color-menu-item`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[(0,g.jsx)(`span`,{className:`rj-editor-color-swatch`,style:{backgroundColor:s||T[0]}}),`More colors`,(0,g.jsx)(`input`,{"aria-label":`More background colors`,className:`rj-editor-color-menu-input`,onChange:e=>{c(e.target.value),i(e.target.value),n(!0)},onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),type:`color`,value:s||T[0]})]})}]},onOpenChange:t=>{n(t),!t&&r&&(window.setTimeout(()=>{X(e,{"background-color":r})}),i(null))},open:t,trigger:[`click`],children:(0,g.jsx)(`button`,{"aria-label":`Background color`,className:`rj-editor-color-button`,type:`button`,children:(0,g.jsx)(`span`,{className:s?`rj-editor-background-color-mark`:`rj-editor-background-color-mark is-none`,style:s?{backgroundColor:s}:void 0,children:`Bg`})})})}function ie(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M18 6L6 18M6 6L18 18`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ae(){let[e]=(0,h.useLexicalComposerContext)(),t=I();return(0,g.jsx)(`button`,{"aria-label":`Clear formatting`,onClick:()=>{Z(e),t(N({isBold:!1,isItalic:!1,isStrikethrough:!1,isUnderline:!1})),t(M({backgroundColor:D.backgroundColor,fontFamily:D.fontFamily,fontSize:D.fontSize,textColor:D.textColor}))},type:`button`,className:`rj-editor-toolbar--clear-btn`,children:(0,g.jsx)(ie,{})})}function Q(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M6 9L12 15L18 9`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function oe(){let[e]=(0,h.useLexicalComposerContext)(),t=I(),n=L(e=>e.toolbar);return console.log(n.fontFamily),(0,g.jsx)(_.Select,{"aria-label":`Font family`,className:`rj-editor-toolbar-select rj-editor-toolbar-select-font`,onChange:(r=``)=>{X(e,{"font-family":r||null}),t(M({...n,fontFamily:r}))},options:E.map(e=>({label:e,value:e})),placeholder:`Font`,popupMatchSelectWidth:!1,size:`small`,value:n.fontFamily==``?void 0:n.fontFamily,suffixIcon:(0,g.jsx)(Q,{})})}function se(){let[e]=(0,h.useLexicalComposerContext)(),t=I(),n=L(e=>e.toolbar);return(0,g.jsx)(_.Select,{"aria-label":`Font size`,className:`rj-editor-toolbar-select`,onChange:(r=``)=>{X(e,{"font-size":r||null}),t(M({...n,fontSize:r}))},options:te.map(e=>({label:e.replace(`px`,``),value:e})),placeholder:`Size`,popupMatchSelectWidth:!1,size:`small`,value:n.fontSize==``?void 0:n.fontSize,suffixIcon:(0,g.jsx)(Q,{})})}function ce(){let[e]=(0,h.useLexicalComposerContext)(),[t,n]=(0,d.useState)(!1),[r,i]=(0,d.useState)(null),a=I(),o=L(e=>e.toolbar),s=o.textColor,c=t=>{X(e,{color:t||null}),a(M({...o,textColor:t}))};return(0,g.jsx)(_.Dropdown,{menu:{items:[{key:`none`,label:(0,g.jsxs)(`button`,{className:`rj-editor-color-menu-item`,onClick:()=>{c(``),n(!1)},type:`button`,children:[(0,g.jsx)(`span`,{className:`rj-editor-color-none`}),`None`]})},...O.map(e=>({key:e,label:(0,g.jsxs)(`button`,{className:`rj-editor-color-menu-item`,onClick:()=>{c(e),n(!1)},type:`button`,children:[(0,g.jsx)(`span`,{className:`rj-editor-color-swatch`,style:{backgroundColor:e}}),e]})})),{type:`divider`},{key:`more-colors`,label:(0,g.jsxs)(`label`,{className:`rj-editor-color-menu-item`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[(0,g.jsx)(`span`,{className:`rj-editor-color-swatch`,style:{backgroundColor:s||O[0]}}),`More colors`,(0,g.jsx)(`input`,{"aria-label":`More text colors`,className:`rj-editor-color-menu-input`,onChange:e=>{c(e.target.value),i(e.target.value),n(!0)},onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),type:`color`,value:s||O[0]})]})}]},onOpenChange:t=>{n(t),!t&&r&&(window.setTimeout(()=>{X(e,{color:r})}),i(null))},open:t,trigger:[`click`],children:(0,g.jsx)(`button`,{"aria-label":`Text color`,className:`rj-editor-color-button`,type:`button`,children:(0,g.jsxs)(`span`,{className:`rj-editor-text-color-mark`,children:[`A`,(0,g.jsx)(`span`,{className:`rj-editor-text-color-line`,style:{backgroundColor:s||`currentColor`}})]})})})}function le(){return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(se,{}),(0,g.jsx)(oe,{}),(0,g.jsx)(ce,{}),(0,g.jsx)(re,{}),(0,g.jsx)(ae,{})]})}function ue(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M6 16C6 18.2091 7.79086 20 10 20H14C16.2091 20 18 18.2091 18 16C18 13.7909 16.2091 12 14 12M18 8C18 5.79086 16.2091 4 14 4H10C7.79086 4 6 5.79086 6 8M3 12H21`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function de(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M6 12H14C16.2091 12 18 10.2091 18 8C18 5.79086 16.2091 4 14 4H6V12ZM6 12H15C17.2091 12 19 13.7909 19 16C19 18.2091 17.2091 20 15 20H6V12Z`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function fe(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M19 4H10M14 20H5M15 4L9 20`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function pe(e){return(0,g.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,...e,children:(0,g.jsx)(`path`,{d:`M18 4V11C18 14.3137 15.3137 17 12 17C8.68629 17 6 14.3137 6 11V4M4 21H20`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function $(){let[e]=(0,h.useLexicalComposerContext)(),{isBold:t,isItalic:r,isStrikethrough:i,isUnderline:a}=L(e=>e.toolbar);return(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`button`,{"aria-pressed":t,className:t?`is-active`:void 0,onClick:()=>e.dispatchCommand(n.FORMAT_TEXT_COMMAND,`bold`),type:`button`,children:(0,g.jsx)(de,{})}),(0,g.jsx)(`button`,{"aria-pressed":r,className:r?`is-active`:void 0,onClick:()=>e.dispatchCommand(n.FORMAT_TEXT_COMMAND,`italic`),type:`button`,children:(0,g.jsx)(fe,{})}),(0,g.jsx)(`button`,{"aria-pressed":a,className:a?`is-active`:void 0,onClick:()=>e.dispatchCommand(n.FORMAT_TEXT_COMMAND,`underline`),type:`button`,children:(0,g.jsx)(pe,{})}),(0,g.jsx)(`button`,{"aria-label":`Strikethrough`,"aria-pressed":i,className:i?`is-active`:void 0,onClick:()=>e.dispatchCommand(n.FORMAT_TEXT_COMMAND,`strikethrough`),type:`button`,children:(0,g.jsx)(ue,{"aria-hidden":`true`})})]})}function me(){let[e]=(0,h.useLexicalComposerContext)(),t=I();return d.default.useEffect(()=>{let r=e.registerCommand(n.SELECTION_CHANGE_COMMAND,()=>(e.getEditorState().read(()=>{let e=(0,n.$getSelection)();(0,n.$isRangeSelection)(e)&&(t(N({isBold:e.hasFormat(`bold`),isItalic:e.hasFormat(`italic`),isStrikethrough:e.hasFormat(`strikethrough`),isUnderline:e.hasFormat(`underline`)})),t(M({backgroundColor:(0,m.$getSelectionStyleValueForProperty)(e,`background-color`,``),fontFamily:(0,m.$getSelectionStyleValueForProperty)(e,`font-family`,``),fontSize:(0,m.$getSelectionStyleValueForProperty)(e,`font-size`,``),textColor:(0,m.$getSelectionStyleValueForProperty)(e,`color`,``)})))}),!1),n.COMMAND_PRIORITY_LOW),i=e.registerCommand(n.CAN_UNDO_COMMAND,e=>(t(j(e)),!1),n.COMMAND_PRIORITY_LOW),a=e.registerCommand(n.CAN_REDO_COMMAND,e=>(t(A(e)),!1),n.COMMAND_PRIORITY_LOW);return()=>{r(),i(),a()}},[t,e]),(0,g.jsxs)(`div`,{className:`rj-editor-toolbar`,"aria-label":`Editor toolbar`,children:[(0,g.jsx)(K,{editor:e}),(0,g.jsx)(U,{}),(0,g.jsx)($,{}),(0,g.jsx)(U,{}),(0,g.jsx)(le,{}),(0,g.jsx)(U,{}),(0,g.jsx)(Y,{editor:e}),(0,g.jsx)(U,{}),(0,g.jsx)(H,{editor:e})]})}var he={paragraph:`rj-editor-paragraph`,text:{bold:`rj-editor-text-bold`,italic:`rj-editor-text-italic`,strikethrough:`rj-editor-text-strikethrough`,underline:`rj-editor-text-underline`},list:{ol:`rj-editor-list-ol`,ul:`rj-editor-list-ul`,listitem:`rj-editor-list-item`}};function ge(e,n,r){r&&e.read(()=>{r({editorState:e,html:(0,t.$generateHtmlFromNodes)(n),json:JSON.stringify(e.toJSON())})})}function _e({autofocus:e=!1,className:t,namespace:n=`RJEditor`,onChange:p,placeholder:m=`Matn yozing...`}){return(0,g.jsx)(f.Provider,{store:(0,d.useMemo)(()=>F(),[]),children:(0,g.jsx)(o.LexicalComposer,{initialConfig:{namespace:n,nodes:[r.ListNode,r.ListItemNode],onError(e){throw e},theme:he},children:(0,g.jsxs)(`div`,{className:[`rj-editor`,t].filter(Boolean).join(` `),children:[(0,g.jsx)(me,{}),(0,g.jsxs)(`div`,{className:`rj-editor-body`,children:[(0,g.jsx)(u.RichTextPlugin,{contentEditable:(0,g.jsx)(a.ContentEditable,{className:`rj-editor-input`}),ErrorBoundary:s.LexicalErrorBoundary,placeholder:(0,g.jsx)(`div`,{className:`rj-editor-placeholder`,children:m})}),(0,g.jsx)(c.HistoryPlugin,{}),(0,g.jsx)(ee.ListPlugin,{}),(0,g.jsx)(l.OnChangePlugin,{onChange:(e,t)=>ge(e,t,p)}),e?(0,g.jsx)(i.AutoFocusPlugin,{}):null]})]})})})}e.RJTextEditor=_e});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setCanRedo, setCanUndo, setStyleFormats, setTextFormats, toolbarReducer, } from './toolbarSlice';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ToolbarState } from '@/types';
|
|
2
|
+
export declare const setCanRedo: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "toolbar/setCanRedo">, setCanUndo: import("@reduxjs/toolkit").ActionCreatorWithPayload<boolean, "toolbar/setCanUndo">, setStyleFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "backgroundColor" | "fontFamily" | "fontSize" | "textColor">, "toolbar/setStyleFormats">, setTextFormats: import("@reduxjs/toolkit").ActionCreatorWithPayload<Pick<ToolbarState, "isBold" | "isItalic" | "isStrikethrough" | "isUnderline">, "toolbar/setTextFormats">;
|
|
3
|
+
export declare const toolbarReducer: import("redux").Reducer<ToolbarState>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const useAppDispatch: import("react-redux").UseDispatch<import("redux-thunk").ThunkDispatch<{
|
|
2
|
+
toolbar: import("@/types").ToolbarState;
|
|
3
|
+
}, undefined, import("redux").UnknownAction> & import("redux").Dispatch<import("redux").UnknownAction>>;
|
|
4
|
+
export declare const useAppSelector: import("react-redux").UseSelector<{
|
|
5
|
+
toolbar: import("@/types").ToolbarState;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const createRJEditorStore: () => import("@reduxjs/toolkit").EnhancedStore<{
|
|
2
|
+
toolbar: import("../types").ToolbarState;
|
|
3
|
+
}, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
4
|
+
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
5
|
+
toolbar: import("../types").ToolbarState;
|
|
6
|
+
}, undefined, import("redux").UnknownAction>;
|
|
7
|
+
}>, import("redux").StoreEnhancer]>>;
|
|
8
|
+
export declare const store: import("@reduxjs/toolkit").EnhancedStore<{
|
|
9
|
+
toolbar: import("../types").ToolbarState;
|
|
10
|
+
}, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
|
|
11
|
+
dispatch: import("redux-thunk").ThunkDispatch<{
|
|
12
|
+
toolbar: import("../types").ToolbarState;
|
|
13
|
+
}, undefined, import("redux").UnknownAction>;
|
|
14
|
+
}>, import("redux").StoreEnhancer]>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type ToolbarState = {
|
|
2
|
+
canRedo: boolean;
|
|
3
|
+
canUndo: boolean;
|
|
4
|
+
backgroundColor: string;
|
|
5
|
+
fontFamily?: string;
|
|
6
|
+
fontSize?: string;
|
|
7
|
+
isBold: boolean;
|
|
8
|
+
isItalic: boolean;
|
|
9
|
+
isStrikethrough: boolean;
|
|
10
|
+
isUnderline: boolean;
|
|
11
|
+
textColor: string;
|
|
12
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "rj-editor",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/rj-editor.umd.cjs",
|
|
6
|
+
"module": "./dist/rj-editor.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/rj-editor.js",
|
|
12
|
+
"require": "./dist/rj-editor.umd.cjs"
|
|
13
|
+
},
|
|
14
|
+
"./style.css": "./dist/rj-editor.css"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "vite build && tsc -p tsconfig.lib.json",
|
|
22
|
+
"lint": "eslint .",
|
|
23
|
+
"preview": "vite preview"
|
|
24
|
+
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@lexical/history": "^0.44.0",
|
|
27
|
+
"@lexical/html": "^0.44.0",
|
|
28
|
+
"@lexical/link": "^0.44.0",
|
|
29
|
+
"@lexical/list": "^0.44.0",
|
|
30
|
+
"@lexical/react": "^0.44.0",
|
|
31
|
+
"@lexical/rich-text": "^0.44.0",
|
|
32
|
+
"@lexical/selection": "^0.44.0",
|
|
33
|
+
"@reduxjs/toolkit": "^2.12.0",
|
|
34
|
+
"antd": "^6.4.3",
|
|
35
|
+
"lexical": "^0.44.0",
|
|
36
|
+
"react-redux": "^9.3.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@eslint/js": "^10.0.1",
|
|
40
|
+
"@types/node": "^24.12.3",
|
|
41
|
+
"@types/react": "^19.2.14",
|
|
42
|
+
"@types/react-dom": "^19.2.3",
|
|
43
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
44
|
+
"eslint": "^10.3.0",
|
|
45
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
46
|
+
"eslint-plugin-react-refresh": "^0.5.2",
|
|
47
|
+
"globals": "^17.6.0",
|
|
48
|
+
"react": "^19.0.0",
|
|
49
|
+
"react-dom": "^19.0.0",
|
|
50
|
+
"sass-embedded": "^1.99.0",
|
|
51
|
+
"typescript": "~6.0.2",
|
|
52
|
+
"typescript-eslint": "^8.59.2",
|
|
53
|
+
"vite": "^8.0.12"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"react": "^19.0.0",
|
|
57
|
+
"react-dom": "^19.0.0"
|
|
58
|
+
}
|
|
59
|
+
}
|