@malaya_jeeva/rich-text-editor 1.0.0 → 1.0.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/dist/index.d.mts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +284 -192
- package/dist/index.mjs +288 -192
- package/package.json +23 -8
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -16,37 +17,32 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
17
|
};
|
|
17
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
19
|
|
|
19
|
-
// src/index.
|
|
20
|
+
// src/index.ts
|
|
20
21
|
var index_exports = {};
|
|
21
22
|
__export(index_exports, {
|
|
22
23
|
RichTextEditor: () => RichTextEditor
|
|
23
24
|
});
|
|
24
25
|
module.exports = __toCommonJS(index_exports);
|
|
25
26
|
|
|
26
|
-
// src/RichTextEditor.
|
|
27
|
+
// src/RichTextEditor.tsx
|
|
27
28
|
var import_react = require("react");
|
|
29
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
30
|
var CSS = `
|
|
29
31
|
* { box-sizing: border-box; }
|
|
30
|
-
|
|
31
|
-
/* \u2500\u2500 Toolbar \u2500\u2500 */
|
|
32
32
|
.rte-toolbar {
|
|
33
33
|
display: flex; flex-wrap: wrap; align-items: center; gap: 1px;
|
|
34
|
-
padding: 4px 8px;
|
|
35
|
-
background: #f8f8f8;
|
|
36
|
-
border-bottom: 1px solid #e0e0e0;
|
|
34
|
+
padding: 4px 8px; background: #f8f8f8; border-bottom: 1px solid #e0e0e0;
|
|
37
35
|
}
|
|
38
36
|
@media (prefers-color-scheme: dark) {
|
|
39
37
|
.rte-toolbar { background: #1e1e1e; border-color: #333; }
|
|
40
38
|
}
|
|
41
|
-
|
|
42
39
|
.rte-btn {
|
|
43
40
|
background: transparent; border: none; border-radius: 3px;
|
|
44
41
|
cursor: pointer; height: 30px; min-width: 30px; padding: 0 6px;
|
|
45
42
|
color: #444; font-size: 13px; font-weight: 500;
|
|
46
43
|
font-family: var(--font-sans); display: inline-flex; align-items: center;
|
|
47
44
|
justify-content: center; user-select: none; white-space: nowrap;
|
|
48
|
-
transition: background 0.1s;
|
|
49
|
-
flex-shrink: 0;
|
|
45
|
+
transition: background 0.1s; flex-shrink: 0;
|
|
50
46
|
}
|
|
51
47
|
.rte-btn:hover { background: #e8e8e8; }
|
|
52
48
|
.rte-btn.active { background: #d0e4ff; color: #1a5fb4; }
|
|
@@ -55,47 +51,25 @@ var CSS = `
|
|
|
55
51
|
.rte-btn:hover { background: #2e2e2e; }
|
|
56
52
|
.rte-btn.active { background: #1a3a5c; color: #90c4ff; }
|
|
57
53
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
.rte-sep {
|
|
61
|
-
width: 1px; height: 20px; background: #d8d8d8;
|
|
62
|
-
margin: 0 4px; flex-shrink: 0;
|
|
63
|
-
}
|
|
64
|
-
@media (prefers-color-scheme: dark) {
|
|
65
|
-
.rte-sep { background: #3a3a3a; }
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/* Block format select */
|
|
54
|
+
.rte-sep { width: 1px; height: 20px; background: #d8d8d8; margin: 0 4px; flex-shrink: 0; }
|
|
55
|
+
@media (prefers-color-scheme: dark) { .rte-sep { background: #3a3a3a; } }
|
|
69
56
|
.rte-select {
|
|
70
57
|
height: 28px; border: 1px solid #d8d8d8; border-radius: 3px;
|
|
71
|
-
background: #fff; color: #333;
|
|
72
|
-
|
|
73
|
-
outline: none; font-family: var(--font-sans);
|
|
58
|
+
background: #fff; color: #333; font-size: 12px; padding: 0 22px 0 7px;
|
|
59
|
+
cursor: pointer; outline: none; font-family: var(--font-sans);
|
|
74
60
|
appearance: none; -webkit-appearance: none;
|
|
75
61
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23999'/%3E%3C/svg%3E");
|
|
76
62
|
background-repeat: no-repeat; background-position: right 6px center;
|
|
77
63
|
}
|
|
78
|
-
@media (prefers-color-scheme: dark) {
|
|
79
|
-
.rte-select { background-color: #2a2a2a; border-color: #444; color: #ccc; }
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/* color swatch under A */
|
|
64
|
+
@media (prefers-color-scheme: dark) { .rte-select { background-color: #2a2a2a; border-color: #444; color: #ccc; } }
|
|
83
65
|
.rte-swatch { width: 14px; height: 3px; border-radius: 1px; margin-top: 2px; }
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.rte-wrap {
|
|
87
|
-
background: #fff;
|
|
88
|
-
}
|
|
89
|
-
@media (prefers-color-scheme: dark) {
|
|
90
|
-
.rte-wrap { background: #141414; }
|
|
91
|
-
}
|
|
66
|
+
.rte-wrap { background: #fff; }
|
|
67
|
+
@media (prefers-color-scheme: dark) { .rte-wrap { background: #141414; } }
|
|
92
68
|
.rte-body {
|
|
93
69
|
min-height: 280px; outline: none; font-size: 15px; line-height: 1.75;
|
|
94
70
|
color: #222; caret-color: #222; padding: 18px 20px;
|
|
95
71
|
}
|
|
96
|
-
@media (prefers-color-scheme: dark) {
|
|
97
|
-
.rte-body { color: #ddd; caret-color: #ddd; }
|
|
98
|
-
}
|
|
72
|
+
@media (prefers-color-scheme: dark) { .rte-body { color: #ddd; caret-color: #ddd; } }
|
|
99
73
|
.rte-body h1 { font-size: 26px; font-weight: 600; margin: 0.6em 0 0.2em; }
|
|
100
74
|
.rte-body h2 { font-size: 20px; font-weight: 600; margin: 0.6em 0 0.2em; }
|
|
101
75
|
.rte-body h3 { font-size: 16px; font-weight: 600; margin: 0.6em 0 0.2em; }
|
|
@@ -112,51 +86,110 @@ var CSS = `
|
|
|
112
86
|
.rte-body pre { background: #f4f4f4; border: 1px solid #e0e0e0; border-radius: 4px; padding: 12px 14px; margin: 0.6em 0; overflow-x: auto; }
|
|
113
87
|
.rte-body code { font-family: var(--font-mono); font-size: 13px; }
|
|
114
88
|
.rte-body:empty:before { content: attr(data-ph); color: #aaa; pointer-events: none; }
|
|
115
|
-
|
|
116
89
|
.rte-code {
|
|
117
|
-
min-height: 280px; width: 100%; background: #1e1e2e;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
resize: vertical;
|
|
90
|
+
min-height: 280px; width: 100%; background: #1e1e2e; color: #cdd6f4;
|
|
91
|
+
font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
|
|
92
|
+
padding: 18px 20px; border: none; outline: none; resize: vertical;
|
|
121
93
|
}
|
|
122
94
|
.rte-footer {
|
|
123
95
|
font-size: 11px; color: #999; padding: 4px 20px 5px;
|
|
124
96
|
border-top: 1px solid #e8e8e8; background: #fafafa;
|
|
125
97
|
}
|
|
126
|
-
@media (prefers-color-scheme: dark) {
|
|
127
|
-
.rte-footer { border-color: #2a2a2a; background: #1a1a1a; color: #555; }
|
|
128
|
-
}
|
|
98
|
+
@media (prefers-color-scheme: dark) { .rte-footer { border-color: #2a2a2a; background: #1a1a1a; color: #555; } }
|
|
129
99
|
`;
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
e
|
|
137
|
-
|
|
100
|
+
function Btn({ onClick, title, active, children, style }) {
|
|
101
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
className: `rte-btn${active ? " active" : ""}`,
|
|
105
|
+
style,
|
|
106
|
+
onMouseDown: (e) => {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
onClick(e);
|
|
109
|
+
},
|
|
110
|
+
title,
|
|
111
|
+
children
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function Sep() {
|
|
116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "rte-sep" });
|
|
117
|
+
}
|
|
118
|
+
function IcoUL() {
|
|
119
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [
|
|
120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "2", cy: "4", r: "1.3", fill: "currentColor" }),
|
|
121
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "2", cy: "8", r: "1.3", fill: "currentColor" }),
|
|
122
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "2", cy: "12", r: "1.3", fill: "currentColor" }),
|
|
123
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "3.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
124
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "7.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "11.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" })
|
|
126
|
+
] });
|
|
127
|
+
}
|
|
128
|
+
function IcoOL() {
|
|
129
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [
|
|
130
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x: "0", y: "5", fontSize: "5.5", fill: "currentColor", fontFamily: "monospace", children: "1." }),
|
|
131
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x: "0", y: "9.5", fontSize: "5.5", fill: "currentColor", fontFamily: "monospace", children: "2." }),
|
|
132
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("text", { x: "0", y: "14", fontSize: "5.5", fill: "currentColor", fontFamily: "monospace", children: "3." }),
|
|
133
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "3.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
134
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "7.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
135
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "5.5", y: "11.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" })
|
|
136
|
+
] });
|
|
137
|
+
}
|
|
138
|
+
function IcoIndent() {
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [
|
|
140
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "1", y: "2", width: "13", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "4.5", y: "6", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
142
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "4.5", y: "10", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
143
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M1 6.5L3.5 8.25L1 10V6.5Z", fill: "currentColor" })
|
|
144
|
+
] });
|
|
145
|
+
}
|
|
146
|
+
function IcoOutdent() {
|
|
147
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [
|
|
148
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "1", y: "2", width: "13", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
149
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "4.5", y: "6", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
150
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "4.5", y: "10", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }),
|
|
151
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 6.5L1 8.25L3.5 10V6.5Z", fill: "currentColor" })
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
154
|
+
function IcoLink() {
|
|
155
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [
|
|
156
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M6 9C6.4 9.6 7.1 10 7.8 10H9.8C10.6 10 11.4 9.6 11.9 9C12.4 8.4 12.6 7.6 12.6 6.8C12.6 6 12.4 5.3 11.9 4.7C11.4 4.1 10.6 3.8 9.8 3.8H8.6", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" }),
|
|
157
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M9 6C8.6 5.4 7.9 5 7.2 5H5.2C4.4 5 3.6 5.4 3.1 6C2.6 6.6 2.4 7.4 2.4 8.2C2.4 9 2.6 9.7 3.1 10.3C3.6 10.9 4.4 11.2 5.2 11.2H6.4", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
|
|
158
|
+
] });
|
|
159
|
+
}
|
|
160
|
+
function IcoCode() {
|
|
161
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [
|
|
162
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 4.5L1.5 7.5L5 10.5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
163
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 4.5L13.5 7.5L10 10.5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }),
|
|
164
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8.5 2L6.5 13", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" })
|
|
165
|
+
] });
|
|
166
|
+
}
|
|
167
|
+
function IcoCopy() {
|
|
168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: [
|
|
169
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "1", y: "3", width: "8.5", height: "10", rx: "1.5", stroke: "currentColor", strokeWidth: "1.2" }),
|
|
170
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 1H12.5C13.1 1 13.5 1.4 13.5 2V10", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
171
|
+
] });
|
|
172
|
+
}
|
|
173
|
+
function AlignIco({ t }) {
|
|
174
|
+
const w = { left: [13, 9, 11], center: [9, 7, 11], right: [13, 9, 11], justify: [13, 13, 13] };
|
|
175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none", children: [0, 1, 2].map((i) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
176
|
+
"rect",
|
|
177
|
+
{
|
|
178
|
+
x: t === "right" ? 15 - w[t][i] - 1 : 1,
|
|
179
|
+
y: [2, 6.5, 11][i],
|
|
180
|
+
width: w[t][i],
|
|
181
|
+
height: "1.6",
|
|
182
|
+
rx: ".8",
|
|
183
|
+
fill: "currentColor"
|
|
138
184
|
},
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
)
|
|
143
|
-
var
|
|
144
|
-
var IcoUL = () => /* @__PURE__ */ React.createElement("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none" }, /* @__PURE__ */ React.createElement("circle", { cx: "2", cy: "4", r: "1.3", fill: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "2", cy: "8", r: "1.3", fill: "currentColor" }), /* @__PURE__ */ React.createElement("circle", { cx: "2", cy: "12", r: "1.3", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "5.5", y: "3.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "5.5", y: "7.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "5.5", y: "11.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }));
|
|
145
|
-
var IcoOL = () => /* @__PURE__ */ React.createElement("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none" }, /* @__PURE__ */ React.createElement("text", { x: "0", y: "5", fontSize: "5.5", fill: "currentColor", fontFamily: "monospace" }, "1."), /* @__PURE__ */ React.createElement("text", { x: "0", y: "9.5", fontSize: "5.5", fill: "currentColor", fontFamily: "monospace" }, "2."), /* @__PURE__ */ React.createElement("text", { x: "0", y: "14", fontSize: "5.5", fill: "currentColor", fontFamily: "monospace" }, "3."), /* @__PURE__ */ React.createElement("rect", { x: "5.5", y: "3.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "5.5", y: "7.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "5.5", y: "11.2", width: "8.5", height: "1.6", rx: ".8", fill: "currentColor" }));
|
|
146
|
-
var IcoIndent = () => /* @__PURE__ */ React.createElement("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none" }, /* @__PURE__ */ React.createElement("rect", { x: "1", y: "2", width: "13", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "4.5", y: "6", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "4.5", y: "10", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M1 6.5L3.5 8.25L1 10V6.5Z", fill: "currentColor" }));
|
|
147
|
-
var IcoOutdent = () => /* @__PURE__ */ React.createElement("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none" }, /* @__PURE__ */ React.createElement("rect", { x: "1", y: "2", width: "13", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "4.5", y: "6", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("rect", { x: "4.5", y: "10", width: "9.5", height: "1.6", rx: ".8", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M3.5 6.5L1 8.25L3.5 10V6.5Z", fill: "currentColor" }));
|
|
148
|
-
var IcoLink = () => /* @__PURE__ */ React.createElement("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none" }, /* @__PURE__ */ React.createElement("path", { d: "M6 9C6.4 9.6 7.1 10 7.8 10H9.8C10.6 10 11.4 9.6 11.9 9C12.4 8.4 12.6 7.6 12.6 6.8C12.6 6 12.4 5.3 11.9 4.7C11.4 4.1 10.6 3.8 9.8 3.8H8.6", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M9 6C8.6 5.4 7.9 5 7.2 5H5.2C4.4 5 3.6 5.4 3.1 6C2.6 6.6 2.4 7.4 2.4 8.2C2.4 9 2.6 9.7 3.1 10.3C3.6 10.9 4.4 11.2 5.2 11.2H6.4", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" }));
|
|
149
|
-
var IcoCode = () => /* @__PURE__ */ React.createElement("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none" }, /* @__PURE__ */ React.createElement("path", { d: "M5 4.5L1.5 7.5L5 10.5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M10 4.5L13.5 7.5L10 10.5", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ React.createElement("path", { d: "M8.5 2L6.5 13", stroke: "currentColor", strokeWidth: "1.4", strokeLinecap: "round" }));
|
|
150
|
-
var IcoCopy = () => /* @__PURE__ */ React.createElement("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none" }, /* @__PURE__ */ React.createElement("rect", { x: "1", y: "3", width: "8.5", height: "10", rx: "1.5", stroke: "currentColor", strokeWidth: "1.2" }), /* @__PURE__ */ React.createElement("path", { d: "M4 1H12.5C13.1 1 13.5 1.4 13.5 2V10", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" }));
|
|
151
|
-
var AlignIco = ({ t }) => {
|
|
152
|
-
const w = { left: [13, 9, 11], center: [9, 7, 11], right: [13, 9, 11], justify: [13, 13, 13] }[t];
|
|
153
|
-
const x = { left: [1, 1, 1], center: [3, 4, 2], right: [1, 1, 1], justify: [1, 1, 1] }[t];
|
|
154
|
-
const xr = { left: [0, 0, 0], center: [0, 0, 0], right: [1, 1, 1], justify: [0, 0, 0] }[t];
|
|
155
|
-
return /* @__PURE__ */ React.createElement("svg", { width: "15", height: "15", viewBox: "0 0 15 15", fill: "none" }, [0, 1, 2].map((i) => /* @__PURE__ */ React.createElement("rect", { key: i, x: t === "right" ? 15 - w[i] - 1 : x[i], y: [2, 6.5, 11][i], width: w[i], height: "1.6", rx: ".8", fill: "currentColor" })));
|
|
156
|
-
};
|
|
157
|
-
function RichTextEditor() {
|
|
185
|
+
i
|
|
186
|
+
)) });
|
|
187
|
+
}
|
|
188
|
+
function RichTextEditor({ value, onChange }) {
|
|
189
|
+
var _a;
|
|
158
190
|
const editorRef = (0, import_react.useRef)(null);
|
|
159
191
|
const colorRef = (0, import_react.useRef)(null);
|
|
192
|
+
const savedRangeRef = (0, import_react.useRef)(null);
|
|
160
193
|
const [isCode, setIsCode] = (0, import_react.useState)(false);
|
|
161
194
|
const [codeVal, setCodeVal] = (0, import_react.useState)("");
|
|
162
195
|
const [fmt, setFmt] = (0, import_react.useState)({ block: "p" });
|
|
@@ -164,21 +197,20 @@ function RichTextEditor() {
|
|
|
164
197
|
const [words, setWords] = (0, import_react.useState)(0);
|
|
165
198
|
const [linkBar, setLinkBar] = (0, import_react.useState)(false);
|
|
166
199
|
const [linkUrl, setLinkUrl] = (0, import_react.useState)("https://");
|
|
167
|
-
const savedRangeRef = (0, import_react.useRef)(null);
|
|
168
200
|
const exec = (0, import_react.useCallback)((cmd, val = null) => {
|
|
169
|
-
var
|
|
170
|
-
(
|
|
171
|
-
document.execCommand(cmd, false, val);
|
|
201
|
+
var _a2;
|
|
202
|
+
(_a2 = editorRef.current) == null ? void 0 : _a2.focus();
|
|
203
|
+
document.execCommand(cmd, false, val != null ? val : void 0);
|
|
172
204
|
refresh();
|
|
173
205
|
}, []);
|
|
174
206
|
const refresh = (0, import_react.useCallback)(() => {
|
|
175
|
-
var
|
|
207
|
+
var _a2, _b, _c, _d;
|
|
176
208
|
const raw = document.queryCommandValue("formatBlock").toLowerCase().replace(/[<>]/g, "");
|
|
177
209
|
const block = ["h1", "h2", "h3"].includes(raw) ? raw : "p";
|
|
178
210
|
const c = document.queryCommandValue("foreColor");
|
|
179
211
|
if (c && c !== "false") {
|
|
180
212
|
const m = c.match(/\d+/g);
|
|
181
|
-
if (m) setColor("#" + m.slice(0, 3).map((n) => (
|
|
213
|
+
if (m) setColor("#" + m.slice(0, 3).map((n) => parseInt(n).toString(16).padStart(2, "0")).join(""));
|
|
182
214
|
}
|
|
183
215
|
setFmt({
|
|
184
216
|
bold: document.queryCommandState("bold"),
|
|
@@ -192,14 +224,15 @@ function RichTextEditor() {
|
|
|
192
224
|
aJ: document.queryCommandState("justifyFull"),
|
|
193
225
|
block
|
|
194
226
|
});
|
|
195
|
-
const txt = ((
|
|
227
|
+
const txt = (_b = (_a2 = editorRef.current) == null ? void 0 : _a2.innerText) != null ? _b : "";
|
|
196
228
|
setWords(txt.trim() ? txt.trim().split(/\s+/).length : 0);
|
|
197
|
-
|
|
229
|
+
onChange == null ? void 0 : onChange((_d = (_c = editorRef.current) == null ? void 0 : _c.innerHTML) != null ? _d : "");
|
|
230
|
+
}, [onChange]);
|
|
198
231
|
const handleKeyDown = (0, import_react.useCallback)((e) => {
|
|
199
|
-
var
|
|
232
|
+
var _a2, _b;
|
|
200
233
|
if (e.key === "Tab") {
|
|
201
234
|
e.preventDefault();
|
|
202
|
-
const node = (
|
|
235
|
+
const node = (_a2 = window.getSelection()) == null ? void 0 : _a2.anchorNode;
|
|
203
236
|
const li = (node == null ? void 0 : node.nodeType) === 1 ? node.closest("li") : (_b = node == null ? void 0 : node.parentElement) == null ? void 0 : _b.closest("li");
|
|
204
237
|
if (li) exec(e.shiftKey ? "outdent" : "indent");
|
|
205
238
|
else document.execCommand("insertText", false, "\xA0\xA0\xA0\xA0");
|
|
@@ -220,8 +253,8 @@ function RichTextEditor() {
|
|
|
220
253
|
}
|
|
221
254
|
}, [exec]);
|
|
222
255
|
const toCode = () => {
|
|
223
|
-
var
|
|
224
|
-
setCodeVal(((
|
|
256
|
+
var _a2, _b;
|
|
257
|
+
setCodeVal((_b = (_a2 = editorRef.current) == null ? void 0 : _a2.innerHTML) != null ? _b : "");
|
|
225
258
|
setIsCode(true);
|
|
226
259
|
};
|
|
227
260
|
const toVisual = () => {
|
|
@@ -232,25 +265,25 @@ function RichTextEditor() {
|
|
|
232
265
|
const openLinkBar = () => {
|
|
233
266
|
const sel = window.getSelection();
|
|
234
267
|
savedRangeRef.current = (sel == null ? void 0 : sel.rangeCount) ? sel.getRangeAt(0).cloneRange() : null;
|
|
235
|
-
setLinkUrl(
|
|
268
|
+
setLinkUrl("https://");
|
|
236
269
|
setLinkBar(true);
|
|
237
270
|
};
|
|
238
271
|
const applyLink = () => {
|
|
239
|
-
var
|
|
272
|
+
var _a2, _b;
|
|
240
273
|
if (!linkUrl) return;
|
|
241
|
-
(
|
|
274
|
+
(_a2 = editorRef.current) == null ? void 0 : _a2.focus();
|
|
242
275
|
const sel = window.getSelection();
|
|
243
|
-
if (savedRangeRef.current) {
|
|
276
|
+
if (savedRangeRef.current && sel) {
|
|
244
277
|
sel.removeAllRanges();
|
|
245
278
|
sel.addRange(savedRangeRef.current);
|
|
246
279
|
}
|
|
247
280
|
if ((_b = savedRangeRef.current) == null ? void 0 : _b.toString()) {
|
|
248
281
|
document.execCommand("createLink", false, linkUrl);
|
|
249
|
-
} else {
|
|
282
|
+
} else if (savedRangeRef.current) {
|
|
250
283
|
const a = document.createElement("a");
|
|
251
284
|
a.href = linkUrl;
|
|
252
285
|
a.textContent = linkUrl;
|
|
253
|
-
|
|
286
|
+
savedRangeRef.current.insertNode(a);
|
|
254
287
|
}
|
|
255
288
|
setLinkBar(false);
|
|
256
289
|
setLinkUrl("https://");
|
|
@@ -275,112 +308,171 @@ function RichTextEditor() {
|
|
|
275
308
|
refresh();
|
|
276
309
|
};
|
|
277
310
|
const copyHtml = () => {
|
|
278
|
-
var
|
|
279
|
-
|
|
311
|
+
var _a2, _b;
|
|
312
|
+
navigator.clipboard.writeText(isCode ? codeVal : (_b = (_a2 = editorRef.current) == null ? void 0 : _a2.innerHTML) != null ? _b : "").catch(() => {
|
|
280
313
|
});
|
|
281
314
|
};
|
|
282
315
|
(0, import_react.useEffect)(() => {
|
|
283
316
|
if (editorRef.current) {
|
|
284
|
-
editorRef.current.innerHTML = "<p>Start writing here...</p>";
|
|
317
|
+
editorRef.current.innerHTML = value != null ? value : "<p>Start writing here...</p>";
|
|
285
318
|
refresh();
|
|
286
319
|
}
|
|
287
320
|
}, []);
|
|
288
|
-
return /* @__PURE__ */
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: "1rem 0" }, children: [
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("style", { children: CSS }),
|
|
323
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { border: "1px solid #d8d8d8", borderRadius: 4, overflow: "hidden", boxShadow: "0 1px 3px rgba(0,0,0,0.06)" }, children: [
|
|
324
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rte-toolbar", children: [
|
|
325
|
+
!isCode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
326
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("bold"), title: "Bold (Ctrl+B)", active: fmt.bold, style: { fontWeight: 800, fontFamily: "Georgia,serif" }, children: "B" }),
|
|
327
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("italic"), title: "Italic (Ctrl+I)", active: fmt.italic, style: { fontStyle: "italic", fontFamily: "Georgia,serif" }, children: "I" }),
|
|
328
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("underline"), title: "Underline (Ctrl+U)", active: fmt.underline, style: { textDecoration: "underline" }, children: "U" }),
|
|
329
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Btn, { onClick: () => {
|
|
330
|
+
var _a2;
|
|
331
|
+
return (_a2 = colorRef.current) == null ? void 0 : _a2.click();
|
|
332
|
+
}, title: "Text color", style: { flexDirection: "column", gap: 1, padding: "3px 6px" }, children: [
|
|
333
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { style: { fontSize: 13, fontWeight: 800, fontFamily: "Georgia,serif", lineHeight: 1, color: "#222" }, children: "A" }),
|
|
334
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "rte-swatch", style: { background: color } })
|
|
335
|
+
] }),
|
|
336
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
337
|
+
"input",
|
|
338
|
+
{
|
|
339
|
+
ref: colorRef,
|
|
340
|
+
type: "color",
|
|
341
|
+
value: color,
|
|
342
|
+
onChange: (e) => {
|
|
343
|
+
setColor(e.target.value);
|
|
344
|
+
exec("foreColor", e.target.value);
|
|
345
|
+
},
|
|
346
|
+
style: { position: "absolute", opacity: 0, width: 0, height: 0, pointerEvents: "none" }
|
|
347
|
+
}
|
|
348
|
+
),
|
|
349
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sep, {}),
|
|
350
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
351
|
+
"select",
|
|
352
|
+
{
|
|
353
|
+
className: "rte-select",
|
|
354
|
+
value: (_a = fmt.block) != null ? _a : "p",
|
|
355
|
+
onMouseDown: () => {
|
|
356
|
+
var _a2;
|
|
357
|
+
return (_a2 = editorRef.current) == null ? void 0 : _a2.focus();
|
|
358
|
+
},
|
|
359
|
+
onChange: (e) => {
|
|
360
|
+
var _a2;
|
|
361
|
+
(_a2 = editorRef.current) == null ? void 0 : _a2.focus();
|
|
362
|
+
document.execCommand("formatBlock", false, e.target.value);
|
|
363
|
+
refresh();
|
|
364
|
+
},
|
|
365
|
+
children: [
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "p", children: "Paragraph" }),
|
|
367
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "h1", children: "Heading 1" }),
|
|
368
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "h2", children: "Heading 2" }),
|
|
369
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "h3", children: "Heading 3" })
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
),
|
|
373
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sep, {}),
|
|
374
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("justifyLeft"), title: "Align left", active: fmt.aL, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignIco, { t: "left" }) }),
|
|
375
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("justifyCenter"), title: "Align center", active: fmt.aC, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignIco, { t: "center" }) }),
|
|
376
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("justifyRight"), title: "Align right", active: fmt.aR, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignIco, { t: "right" }) }),
|
|
377
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("justifyFull"), title: "Justify", active: fmt.aJ, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AlignIco, { t: "justify" }) }),
|
|
378
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sep, {}),
|
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("insertUnorderedList"), title: "Bullet list", active: fmt.ul, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoUL, {}) }),
|
|
380
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("insertOrderedList"), title: "Numbered list", active: fmt.ol, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoOL, {}) }),
|
|
381
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("indent"), title: "Indent (Tab)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoIndent, {}) }),
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: () => exec("outdent"), title: "Outdent (Shift+Tab)", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoOutdent, {}) }),
|
|
383
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sep, {}),
|
|
384
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: openLinkBar, title: "Insert link", active: linkBar, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoLink, {}) }),
|
|
385
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: insertCodeBlock, title: "Code block", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoCode, {}) }),
|
|
386
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sep, {})
|
|
387
|
+
] }),
|
|
388
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
389
|
+
Btn,
|
|
390
|
+
{
|
|
391
|
+
onClick: isCode ? toVisual : toCode,
|
|
392
|
+
title: "Toggle HTML source",
|
|
393
|
+
active: isCode,
|
|
394
|
+
style: { fontSize: 12, fontWeight: 600, letterSpacing: "0.03em", padding: "0 8px" },
|
|
395
|
+
children: isCode ? "Visual" : "HTML"
|
|
396
|
+
}
|
|
397
|
+
),
|
|
398
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Btn, { onClick: copyHtml, title: "Copy HTML", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoCopy, {}) }),
|
|
399
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { style: { flex: 1 } }),
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { fontSize: 12, color: "#aaa" }, children: [
|
|
401
|
+
words,
|
|
402
|
+
" ",
|
|
403
|
+
words === 1 ? "word" : "words"
|
|
404
|
+
] })
|
|
405
|
+
] }),
|
|
406
|
+
linkBar && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "6px 10px", background: "#f0f4ff", borderBottom: "1px solid #c8d8f8" }, children: [
|
|
407
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IcoLink, {}),
|
|
408
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
409
|
+
"input",
|
|
410
|
+
{
|
|
411
|
+
autoFocus: true,
|
|
412
|
+
type: "text",
|
|
413
|
+
value: linkUrl,
|
|
414
|
+
onChange: (e) => setLinkUrl(e.target.value),
|
|
415
|
+
onKeyDown: (e) => {
|
|
416
|
+
if (e.key === "Enter") applyLink();
|
|
417
|
+
if (e.key === "Escape") setLinkBar(false);
|
|
418
|
+
},
|
|
419
|
+
placeholder: "https://example.com",
|
|
420
|
+
style: { flex: 1, height: 26, border: "1px solid #b0c4f0", borderRadius: 3, padding: "0 8px", fontSize: 13, outline: "none", fontFamily: "var(--font-sans)" }
|
|
421
|
+
}
|
|
422
|
+
),
|
|
423
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
424
|
+
"button",
|
|
425
|
+
{
|
|
426
|
+
onClick: applyLink,
|
|
427
|
+
style: { height: 26, padding: "0 12px", background: "#1a6fc4", color: "#fff", border: "none", borderRadius: 3, fontSize: 12, fontWeight: 600, cursor: "pointer" },
|
|
428
|
+
children: "Apply"
|
|
429
|
+
}
|
|
430
|
+
),
|
|
431
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
432
|
+
"button",
|
|
433
|
+
{
|
|
434
|
+
onClick: () => setLinkBar(false),
|
|
435
|
+
style: { height: 26, padding: "0 10px", background: "transparent", color: "#666", border: "1px solid #ccc", borderRadius: 3, fontSize: 12, cursor: "pointer" },
|
|
436
|
+
children: "Cancel"
|
|
437
|
+
}
|
|
438
|
+
)
|
|
439
|
+
] }),
|
|
440
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rte-wrap", children: [
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
442
|
+
"textarea",
|
|
443
|
+
{
|
|
444
|
+
className: "rte-code",
|
|
445
|
+
value: codeVal,
|
|
446
|
+
onChange: (e) => setCodeVal(e.target.value),
|
|
447
|
+
spellCheck: false,
|
|
448
|
+
style: { display: isCode ? "block" : "none" }
|
|
449
|
+
}
|
|
450
|
+
),
|
|
451
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
452
|
+
"div",
|
|
453
|
+
{
|
|
454
|
+
ref: editorRef,
|
|
455
|
+
className: "rte-body",
|
|
456
|
+
contentEditable: true,
|
|
457
|
+
suppressContentEditableWarning: true,
|
|
458
|
+
"data-ph": "Start typing...",
|
|
459
|
+
onKeyDown: handleKeyDown,
|
|
460
|
+
onKeyUp: refresh,
|
|
461
|
+
onMouseUp: refresh,
|
|
462
|
+
onSelect: refresh,
|
|
463
|
+
style: { display: isCode ? "none" : "block" }
|
|
464
|
+
}
|
|
465
|
+
)
|
|
466
|
+
] }),
|
|
467
|
+
!isCode && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "rte-footer", children: [
|
|
468
|
+
"Inside a list: ",
|
|
469
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Tab" }),
|
|
470
|
+
" to go deeper \xA0\xB7\xA0 ",
|
|
471
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: "Shift+Tab" }),
|
|
472
|
+
" to go back up"
|
|
473
|
+
] })
|
|
474
|
+
] })
|
|
475
|
+
] });
|
|
384
476
|
}
|
|
385
477
|
// Annotate the CommonJS export names for ESM import in node:
|
|
386
478
|
0 && (module.exports = {
|