@rufous/ui 0.1.63 → 0.2.0-beta.0
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/Buttons/addButton.js +1 -0
- package/dist/Buttons/cancelButton.js +1 -0
- package/dist/Buttons/index.cjs +2 -2
- package/dist/Buttons/index.js +3 -2
- package/dist/Buttons/stdButton.js +1 -0
- package/dist/Buttons/submitButton.cjs +2 -2
- package/dist/Buttons/submitButton.js +3 -2
- package/dist/CheckBoxes/CheckBox.cjs +1 -1
- package/dist/CheckBoxes/CheckBox.js +4 -25
- package/dist/Contexts/rufousThemeProvider.cjs +81 -101
- package/dist/Contexts/rufousThemeProvider.js +3 -2
- package/dist/DataGrid/DataGrid.cjs +418 -0
- package/dist/DataGrid/DataGrid.d.cts +8 -0
- package/dist/DataGrid/DataGrid.d.ts +8 -0
- package/dist/DataGrid/DataGrid.js +9 -0
- package/dist/DataGrid/index.cjs +418 -0
- package/dist/DataGrid/index.d.cts +3 -0
- package/dist/DataGrid/index.d.ts +3 -0
- package/dist/DataGrid/index.js +8 -0
- package/dist/{TextFields/FloatingInput.d.cjs → DataGrid/types.cjs} +3 -3
- package/dist/DataGrid/types.d.cts +31 -0
- package/dist/DataGrid/types.d.ts +31 -0
- package/dist/Dialogs/BaseDialog.cjs +18 -10
- package/dist/Dialogs/BaseDialog.css +8247 -162
- package/dist/Dialogs/BaseDialog.d.cts +1 -0
- package/dist/Dialogs/BaseDialog.d.ts +1 -0
- package/dist/Dialogs/BaseDialog.js +39 -32
- package/dist/Dialogs/index.cjs +18 -10
- package/dist/Dialogs/index.css +8247 -162
- package/dist/Dialogs/index.js +39 -32
- package/dist/Editors/RichTextEditor.cjs +29477 -0
- package/dist/Editors/RichTextEditor.css +7179 -0
- package/dist/Editors/RichTextEditor.d.cts +57 -0
- package/dist/Editors/RichTextEditor.d.ts +57 -0
- package/dist/Editors/RichTextEditor.js +9 -0
- package/dist/Editors/index.cjs +29477 -0
- package/dist/Editors/index.css +7179 -0
- package/dist/Editors/index.d.cts +2 -0
- package/dist/Editors/index.d.ts +2 -0
- package/dist/Editors/index.js +8 -0
- package/dist/Progress/circularProgress.cjs +2 -2
- package/dist/Progress/circularProgress.d.cts +3 -3
- package/dist/Progress/circularProgress.d.ts +3 -3
- package/dist/Progress/circularProgress.js +2 -1
- package/dist/TextFields/AddressLookup.cjs +390 -0
- package/dist/TextFields/AddressLookup.d.cts +49 -0
- package/dist/TextFields/AddressLookup.d.ts +49 -0
- package/dist/TextFields/AddressLookup.js +304 -0
- package/dist/TextFields/FloatingInput.cjs +6 -4
- package/dist/TextFields/FloatingInput.d.cts +13 -19
- package/dist/TextFields/FloatingInput.d.ts +13 -19
- package/dist/TextFields/FloatingInput.js +4 -28
- package/dist/chunk-66HHM7VI.js +468 -0
- package/dist/chunk-7KRG7VNW.js +0 -0
- package/dist/{chunk-YRFUVQDN.js → chunk-CTBYVXFP.js} +2 -2
- package/dist/chunk-GJGRMMAQ.js +0 -0
- package/dist/chunk-J6E3UO2W.js +402 -0
- package/dist/chunk-LI4N7JWK.js +39 -0
- package/dist/chunk-QGXXOQJF.js +61 -0
- package/dist/{chunk-AQXTOTWY.js → chunk-TYTZEAV5.js} +19 -11
- package/dist/chunk-UPCMMCPQ.js +34 -0
- package/dist/chunk-WNZLBFLQ.js +73 -0
- package/dist/chunk-X357WQOT.js +29 -0
- package/dist/{chunk-7YKG3WYS.js → chunk-YRLN3TBF.js} +1 -1
- package/dist/esm-5T53WHPT.js +27362 -0
- package/dist/icons/activateUserIcon.js +1 -0
- package/dist/icons/archivedIcon.js +1 -0
- package/dist/icons/assignGroupIcon.js +1 -0
- package/dist/icons/closeIcon.js +1 -0
- package/dist/icons/copyIcon.js +1 -0
- package/dist/icons/difficultyAllIcon.js +1 -0
- package/dist/icons/difficultyEasyIcon.js +1 -0
- package/dist/icons/difficultyHardIcon.js +1 -0
- package/dist/icons/difficultyMediumIcon.js +1 -0
- package/dist/icons/dollarIcon.js +1 -0
- package/dist/icons/downloadIcon.js +1 -0
- package/dist/icons/downloadPdfIcon.js +1 -0
- package/dist/icons/editChatIcon.js +1 -0
- package/dist/icons/editIcon.js +1 -0
- package/dist/icons/engagementIcon.js +1 -0
- package/dist/icons/functionIcon.js +1 -0
- package/dist/icons/helpOutlinedIcon.js +1 -0
- package/dist/icons/hierarchyIcon.js +1 -0
- package/dist/icons/inactiveGroupIcon.js +1 -0
- package/dist/icons/index.js +64 -63
- package/dist/icons/industryIcon.js +1 -0
- package/dist/icons/invoiceIcon.js +1 -0
- package/dist/icons/locationPinIcon.js +1 -0
- package/dist/icons/logsIcon.js +1 -0
- package/dist/icons/minExperienceIcon.js +1 -0
- package/dist/icons/nineDotMenuIcon.js +1 -0
- package/dist/icons/notificationIcon.js +1 -0
- package/dist/icons/projectIcon.js +1 -0
- package/dist/icons/qualificationsIcon.js +1 -0
- package/dist/icons/questionStatusAllIcon.js +1 -0
- package/dist/icons/questionStatusPrivateIcon.js +1 -0
- package/dist/icons/questionStatusPublicIcon.js +1 -0
- package/dist/icons/questionTypeAllIcon.js +1 -0
- package/dist/icons/questionTypeCodingIcon.js +1 -0
- package/dist/icons/questionTypeDescriptiveIcon.js +1 -0
- package/dist/icons/questionTypeMultipleIcon.js +1 -0
- package/dist/icons/questionTypeSingleIcon.js +1 -0
- package/dist/icons/refreshIcon.js +1 -0
- package/dist/icons/resendInviteIcon.js +1 -0
- package/dist/icons/rolesIcon.js +1 -0
- package/dist/icons/rufousAiIcon.js +1 -0
- package/dist/icons/rufousBirdIcon.js +1 -0
- package/dist/icons/rufousLauncherBird.js +1 -0
- package/dist/icons/sidebarIcon.js +1 -0
- package/dist/icons/softSkillsIcon.js +1 -0
- package/dist/icons/subscribeIcon.js +1 -0
- package/dist/icons/suspendUserIcon.js +1 -0
- package/dist/icons/technicalSkillsIcon.js +1 -0
- package/dist/icons/tickIcon.js +1 -0
- package/dist/icons/timerIcon.js +1 -0
- package/dist/icons/trashIcon.js +1 -0
- package/dist/icons/unArchivedIcon.js +1 -0
- package/dist/icons/unsubscribeIcon.js +1 -0
- package/dist/icons/uploadIcon.js +1 -0
- package/dist/icons/userAssignIcon.js +1 -0
- package/dist/icons/viewIcon.js +1 -0
- package/dist/icons/workItemIcon.js +1 -0
- package/dist/main.cjs +30097 -223
- package/dist/main.css +8247 -162
- package/dist/main.d.cts +6 -0
- package/dist/main.d.ts +6 -0
- package/dist/main.js +89 -67
- package/dist/style.css +1068 -163
- package/dist/styles/button.css +82 -110
- package/dist/styles/checkbox.css +60 -0
- package/dist/styles/checkbox.d.cts +2 -0
- package/dist/styles/checkbox.d.ts +2 -0
- package/dist/styles/datagrid.css +531 -0
- package/dist/styles/datagrid.d.cts +2 -0
- package/dist/styles/datagrid.d.ts +2 -0
- package/dist/styles/dialog.css +78 -51
- package/dist/styles/editor.css +211 -0
- package/dist/styles/editor.d.cts +2 -0
- package/dist/styles/editor.d.ts +2 -0
- package/dist/utils/constants.cjs +47 -69
- package/dist/utils/constants.d.cts +34 -56
- package/dist/utils/constants.d.ts +34 -56
- package/dist/utils/constants.js +2 -1
- package/package.json +13 -2
- package/dist/TextFields/FloatingInput.d.d.cts +0 -23
- package/dist/TextFields/FloatingInput.d.d.ts +0 -23
- package/dist/chunk-2FHTGYR4.js +0 -83
- package/dist/chunk-BCGCLMKA.js +0 -71
- /package/dist/{TextFields/FloatingInput.d.js → DataGrid/types.js} +0 -0
|
@@ -0,0 +1,468 @@
|
|
|
1
|
+
// lib/Editors/RichTextEditor.tsx
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
import JoditReact from "jodit-react";
|
|
4
|
+
var MOBILE_BREAKPOINT = 768;
|
|
5
|
+
var TODO_STATES = [
|
|
6
|
+
{ label: "Todo", name: "empty", imageUrl: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/todo-blank.svg" },
|
|
7
|
+
{ label: "Working", name: "working", imageUrl: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/working.svg" },
|
|
8
|
+
{ label: "Blocked", name: "blocked", imageUrl: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/blocked.svg" },
|
|
9
|
+
{ label: "Resolved", name: "resolved", imageUrl: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/closed.svg" }
|
|
10
|
+
];
|
|
11
|
+
var BASIC_BUTTONS = [
|
|
12
|
+
"paragraph",
|
|
13
|
+
"fontsize",
|
|
14
|
+
"font",
|
|
15
|
+
"bold",
|
|
16
|
+
"italic",
|
|
17
|
+
"link",
|
|
18
|
+
"lineHeight",
|
|
19
|
+
"|",
|
|
20
|
+
"ul",
|
|
21
|
+
"ol",
|
|
22
|
+
"|",
|
|
23
|
+
"align",
|
|
24
|
+
"outdent",
|
|
25
|
+
"indent",
|
|
26
|
+
"|",
|
|
27
|
+
"brush",
|
|
28
|
+
"table",
|
|
29
|
+
"image",
|
|
30
|
+
"video",
|
|
31
|
+
"|"
|
|
32
|
+
];
|
|
33
|
+
var MOBILE_BUTTONS = ["paragraph", "bold"];
|
|
34
|
+
var MORE_BUTTONS = ["spellcheck", "cut", "copy", "symbols"];
|
|
35
|
+
var UNDO_REDO = ["undo", "redo", "|"];
|
|
36
|
+
var AI_BUTTONS = ["|", "ai-commands", "|"];
|
|
37
|
+
function debounce(fn, delay) {
|
|
38
|
+
let t;
|
|
39
|
+
return (...args) => {
|
|
40
|
+
clearTimeout(t);
|
|
41
|
+
t = setTimeout(() => fn(...args), delay);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function createTodoItem(stateName = "empty") {
|
|
45
|
+
const state = TODO_STATES.find((s) => s.name === stateName) ?? TODO_STATES[0];
|
|
46
|
+
const container = document.createElement("p");
|
|
47
|
+
container.classList.add("todo-item");
|
|
48
|
+
const btn = document.createElement("button");
|
|
49
|
+
btn.classList.add("todo-item-button");
|
|
50
|
+
btn.setAttribute("contenteditable", "false");
|
|
51
|
+
const img = document.createElement("img");
|
|
52
|
+
img.src = state.imageUrl;
|
|
53
|
+
img.alt = state.label;
|
|
54
|
+
btn.appendChild(img);
|
|
55
|
+
const span = document.createElement("span");
|
|
56
|
+
span.classList.add("todo-item-text");
|
|
57
|
+
span.innerText = state.label;
|
|
58
|
+
container.appendChild(btn);
|
|
59
|
+
container.appendChild(span);
|
|
60
|
+
return container;
|
|
61
|
+
}
|
|
62
|
+
function RichTextEditor({
|
|
63
|
+
value = "",
|
|
64
|
+
onChange,
|
|
65
|
+
onBlur,
|
|
66
|
+
onError,
|
|
67
|
+
onClose,
|
|
68
|
+
onImageUploadSuccess,
|
|
69
|
+
height = "300px",
|
|
70
|
+
width = "100%",
|
|
71
|
+
placeholder = "Start writing\u2026",
|
|
72
|
+
disabled = false,
|
|
73
|
+
allowResizeY = true,
|
|
74
|
+
fullSize = false,
|
|
75
|
+
aiSupport = false,
|
|
76
|
+
licenseKey = "",
|
|
77
|
+
translationKey = "",
|
|
78
|
+
token = "",
|
|
79
|
+
uploadUrl = "",
|
|
80
|
+
mentions,
|
|
81
|
+
error,
|
|
82
|
+
className = "",
|
|
83
|
+
style
|
|
84
|
+
}) {
|
|
85
|
+
const editorRef = useRef(null);
|
|
86
|
+
const containerRef = useRef(null);
|
|
87
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
88
|
+
const [showAll, setShowAll] = useState(true);
|
|
89
|
+
const [isListening, setIsListening] = useState(false);
|
|
90
|
+
const [speechText, setSpeechText] = useState("");
|
|
91
|
+
const [speechVisible, setSpeechVisible] = useState(false);
|
|
92
|
+
const [speechPos, setSpeechPos] = useState({ top: 0, left: 0 });
|
|
93
|
+
const recognitionRef = useRef(null);
|
|
94
|
+
const silenceTimer = useRef(null);
|
|
95
|
+
const interimSpanRef = useRef(null);
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const check = () => {
|
|
98
|
+
const mobile = window.innerWidth <= MOBILE_BREAKPOINT;
|
|
99
|
+
setIsMobile(mobile);
|
|
100
|
+
if (!mobile) setShowAll(true);
|
|
101
|
+
};
|
|
102
|
+
check();
|
|
103
|
+
window.addEventListener("resize", check);
|
|
104
|
+
return () => window.removeEventListener("resize", check);
|
|
105
|
+
}, []);
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
let cursorTimeout;
|
|
108
|
+
import("./esm-5T53WHPT.js").then(({ Jodit }) => {
|
|
109
|
+
Jodit.plugins.add("rteKeyLogger", (jodit) => {
|
|
110
|
+
const debouncedToggle = debounce((btn, container) => {
|
|
111
|
+
const pressed = container.getAttribute("aria-pressed");
|
|
112
|
+
if (!pressed || pressed === "false") {
|
|
113
|
+
container.setAttribute("aria-pressed", "true");
|
|
114
|
+
btn.setAttribute("aria-pressed", "true");
|
|
115
|
+
} else {
|
|
116
|
+
container.setAttribute("aria-pressed", "false");
|
|
117
|
+
btn.setAttribute("aria-pressed", "false");
|
|
118
|
+
}
|
|
119
|
+
}, 150);
|
|
120
|
+
jodit.events.on("keydown", (e) => {
|
|
121
|
+
const isTodoShortcut = (e.key === "U" || e.key === "u") && e.shiftKey && (e.metaKey || e.ctrlKey);
|
|
122
|
+
if (isTodoShortcut) {
|
|
123
|
+
e.preventDefault();
|
|
124
|
+
const btnList2 = document.getElementsByClassName("jodit-toolbar-button_insertTodo");
|
|
125
|
+
const btn = btnList2[0]?.getElementsByTagName("button")[0];
|
|
126
|
+
if (!btn || !btnList2[0]) return false;
|
|
127
|
+
const isPressed = btnList2[0].getAttribute("aria-pressed") === "true";
|
|
128
|
+
if (!isPressed) {
|
|
129
|
+
btnList2[0].setAttribute("aria-pressed", "true");
|
|
130
|
+
btn.setAttribute("aria-pressed", "true");
|
|
131
|
+
const todo2 = createTodoItem();
|
|
132
|
+
jodit.selection.insertNode(todo2);
|
|
133
|
+
const textSpan2 = todo2.querySelector("span");
|
|
134
|
+
if (textSpan2) setTimeout(() => jodit.selection?.setCursorIn?.(textSpan2), 0);
|
|
135
|
+
} else {
|
|
136
|
+
btnList2[0].setAttribute("aria-pressed", "false");
|
|
137
|
+
btn.setAttribute("aria-pressed", "false");
|
|
138
|
+
}
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
if (e.key === "Delete") {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
return false;
|
|
144
|
+
}
|
|
145
|
+
if (e.key !== "Enter" || e.shiftKey) return;
|
|
146
|
+
const btnList = document.getElementsByClassName("jodit-toolbar-button_insertTodo");
|
|
147
|
+
if (btnList[0]?.getAttribute("aria-pressed") !== "true") return;
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
const todo = createTodoItem();
|
|
150
|
+
try {
|
|
151
|
+
const current = jodit.selection?.current?.();
|
|
152
|
+
const container = current ? Jodit.modules.Dom.closest(current, ".todo-item", jodit.editor) : null;
|
|
153
|
+
if (container?.parentNode) {
|
|
154
|
+
container.after ? container.after(todo) : container.parentNode.insertBefore(todo, container.nextSibling);
|
|
155
|
+
} else {
|
|
156
|
+
jodit.selection.insertNode(todo);
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
jodit.selection.insertNode(todo);
|
|
160
|
+
}
|
|
161
|
+
const textSpan = todo.querySelector("span");
|
|
162
|
+
clearTimeout(cursorTimeout);
|
|
163
|
+
cursorTimeout = setTimeout(() => {
|
|
164
|
+
if (textSpan) jodit.selection?.setCursorIn?.(textSpan);
|
|
165
|
+
}, 100);
|
|
166
|
+
});
|
|
167
|
+
jodit.events.on("click", (e) => {
|
|
168
|
+
const target = e.target;
|
|
169
|
+
if (!target.classList.contains("todo-item-button") && !target.closest?.(".todo-item-button")) return;
|
|
170
|
+
const btn = target.classList.contains("todo-item-button") ? target : target.closest(".todo-item-button");
|
|
171
|
+
const img = btn?.querySelector("img");
|
|
172
|
+
if (!img) return;
|
|
173
|
+
const cur = TODO_STATES.findIndex((s) => img.src.includes(s.imageUrl.split("/").pop()));
|
|
174
|
+
const next = TODO_STATES[(cur + 1) % TODO_STATES.length];
|
|
175
|
+
img.src = next.imageUrl;
|
|
176
|
+
img.alt = next.label;
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
const observer = new MutationObserver(() => {
|
|
180
|
+
const popup = document.querySelector(".jodit-popup-container");
|
|
181
|
+
if (!popup) return;
|
|
182
|
+
["Open in new tab", "No follow"].forEach((label) => {
|
|
183
|
+
popup.querySelectorAll(".jodit-ui-checkbox").forEach((el) => {
|
|
184
|
+
const text = el.querySelector(".jodit-ui-checkbox__label")?.textContent?.trim();
|
|
185
|
+
if (text !== label) return;
|
|
186
|
+
const input = el.querySelector('input[type="checkbox"]');
|
|
187
|
+
if (input && !input.checked) {
|
|
188
|
+
input.checked = true;
|
|
189
|
+
input.dispatchEvent(new Event("change", { bubbles: true }));
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
195
|
+
return () => observer.disconnect();
|
|
196
|
+
});
|
|
197
|
+
return () => clearTimeout(cursorTimeout);
|
|
198
|
+
}, []);
|
|
199
|
+
const speechButton = {
|
|
200
|
+
name: "customSpeechRecognize",
|
|
201
|
+
tooltip: isListening ? "Stop listening" : "Speech to Text",
|
|
202
|
+
iconURL: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMTIgMUM5Ljc5MDg2IDEgOCAyLjc5MDg2IDggNVYxMkM4IDE0LjIwOTEgOS43OTA4NiAxNiAxMiAxNkMxNC4yMDkxIDE2IDE2IDE0LjIwOTEgMTYgMTJWNUMxNiAyLjc5MDg2IDE0LjIwOTEgMSAxMiAxWk0xMCA1QzEwIDMuODk1NDMgMTAuODk1NCAzIDEyIDNDMTMuMTA0NiAzIDE0IDMuODk1NDMgMTQgNVYxMkMxNCAxMy4xMDQ2IDEzLjEwNDYgMTQgMTIgMTRDMTAuODk1NCAxNCAxMCAxMy4xMDQ2IDEwIDEyVjVaIiBmaWxsPSIjMDAwMDAwIi8+PHBhdGggZD0iTTUgOUM1LjU1MjI4IDkgNiA5LjQ0NzcxIDYgMTBWMTJDNiAxMy41OTEzIDYuNjMyMTQgMTUuMTE3NCA3Ljc1NzM2IDE2LjI0MjZDOC44ODI1OCAxNy4zNjc5IDEwLjQwODcgMTggMTIgMThDMTMuNTkxMyAxOCAxNS4xMTc0IDE3LjM2NzkgMTYuMjQyNiAxNi4yNDI2QzE3LjM2NzkgMTUuMTE3NCAxOCAxMy41OTEzIDE4IDEyVjEwQzE4IDkuNDQ3NzEgMTguNDQ3NyA5IDE5IDlDMTkuNTUyMyA5IDIwIDkuNDQ3NzEgMjAgMTBWMTJDMjAgMTQuMTIxNyAxOS4xNTcxIDE2LjE1NjYgMTcuNjU2OSAxNy42NTY5QzE2LjM5MzggMTguOTE5OSAxNC43NTE4IDE5LjcxNyAxMi45OTgxIDE5LjkzNzVDMTIuOTk5MyAxOS45NTgyIDEzIDE5Ljk3OSAxMyAyMFYyMkMxMyAyMi41NTIzIDEyLjU1MjMgMjMgMTIgMjNDMTEuNDQ3NyAyMyAxMSAyMi41NTIzIDExIDIyVjIwQzExIDE5Ljk3OSAxMS4wMDA2IDE5Ljk1ODIgMTEuMDAxOSAxOS45Mzc1QzkuMjQ4MiAxOS43MTcgNy42MDYyMyAxOC45MTk5IDYuMzQzMTUgMTcuNjU2OUM0Ljg0Mjg1IDE2LjE1NjYgNCAxNC4xMjE3IDQgMTJWMTBDNCA5LjQ0NzcxIDQuNDQ3NzIgOSA1IDlaIiBmaWxsPSIjMDAwMDAwIi8+PC9zdmc+",
|
|
203
|
+
exec(editorInstance) {
|
|
204
|
+
if (isListening) {
|
|
205
|
+
recognitionRef.current?.stop();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const SR = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
209
|
+
if (!SR) {
|
|
210
|
+
onError?.("Speech Recognition is not supported in this browser.");
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const recognition = new SR();
|
|
214
|
+
recognitionRef.current = recognition;
|
|
215
|
+
recognition.continuous = true;
|
|
216
|
+
recognition.interimResults = true;
|
|
217
|
+
recognition.lang = "en-US";
|
|
218
|
+
const finalize = () => {
|
|
219
|
+
const span = interimSpanRef.current;
|
|
220
|
+
if (span && editorInstance.editor.contains(span)) {
|
|
221
|
+
if (span.innerHTML.trim()) {
|
|
222
|
+
editorInstance.s.setCursorAfter(span);
|
|
223
|
+
span.replaceWith(...Array.from(span.childNodes));
|
|
224
|
+
} else {
|
|
225
|
+
span.remove();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
interimSpanRef.current = null;
|
|
229
|
+
};
|
|
230
|
+
recognition.onstart = () => {
|
|
231
|
+
setIsListening(true);
|
|
232
|
+
setSpeechText("Listening\u2026");
|
|
233
|
+
setSpeechVisible(true);
|
|
234
|
+
editorInstance.focus();
|
|
235
|
+
try {
|
|
236
|
+
const sel = editorInstance.selection?.sel;
|
|
237
|
+
if (sel?.rangeCount > 0) {
|
|
238
|
+
const rect = sel.getRangeAt(0).getBoundingClientRect();
|
|
239
|
+
const cRect = containerRef.current?.getBoundingClientRect() ?? { top: 0, left: 0 };
|
|
240
|
+
setSpeechPos({ top: rect.bottom - cRect.top + 5, left: rect.left - cRect.left });
|
|
241
|
+
}
|
|
242
|
+
} catch {
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
recognition.onresult = (event) => {
|
|
246
|
+
if (silenceTimer.current) clearTimeout(silenceTimer.current);
|
|
247
|
+
let finalText = "";
|
|
248
|
+
let interimText = "";
|
|
249
|
+
for (let i = event.resultIndex; i < event.results.length; i++) {
|
|
250
|
+
const t = event.results[i][0].transcript;
|
|
251
|
+
if (event.results[i].isFinal) finalText += t;
|
|
252
|
+
else interimText += t;
|
|
253
|
+
}
|
|
254
|
+
if (finalText.trim()) {
|
|
255
|
+
finalize();
|
|
256
|
+
editorInstance.s.insertHTML(" " + finalText.trim());
|
|
257
|
+
}
|
|
258
|
+
if (interimText.trim()) {
|
|
259
|
+
let span = interimSpanRef.current;
|
|
260
|
+
if (!span || !editorInstance.editor.contains(span)) {
|
|
261
|
+
finalize();
|
|
262
|
+
span = editorInstance.create.inside.span();
|
|
263
|
+
editorInstance.s.insertNode(span, false);
|
|
264
|
+
interimSpanRef.current = span;
|
|
265
|
+
}
|
|
266
|
+
span.innerHTML = " " + interimText.trim();
|
|
267
|
+
setSpeechText(interimText.trim());
|
|
268
|
+
editorInstance.s.setCursorAfter(span);
|
|
269
|
+
}
|
|
270
|
+
silenceTimer.current = setTimeout(() => recognitionRef.current?.stop(), 2500);
|
|
271
|
+
};
|
|
272
|
+
recognition.onend = () => {
|
|
273
|
+
finalize();
|
|
274
|
+
setIsListening(false);
|
|
275
|
+
setSpeechVisible(false);
|
|
276
|
+
if (silenceTimer.current) clearTimeout(silenceTimer.current);
|
|
277
|
+
recognitionRef.current = null;
|
|
278
|
+
};
|
|
279
|
+
recognition.onerror = () => {
|
|
280
|
+
finalize();
|
|
281
|
+
setIsListening(false);
|
|
282
|
+
setSpeechVisible(false);
|
|
283
|
+
};
|
|
284
|
+
recognition.start();
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
const todoButton = {
|
|
288
|
+
name: "insertTodo",
|
|
289
|
+
tooltip: "To-do item (\u2318\u21E7U)",
|
|
290
|
+
iconURL: TODO_STATES[0].imageUrl,
|
|
291
|
+
list: Object.fromEntries(TODO_STATES.map((s) => [s.name, s.label])),
|
|
292
|
+
childTemplate: (_editor, _key, text) => `<span>${text}</span>`,
|
|
293
|
+
exec: async (jodit, _current, btn) => {
|
|
294
|
+
const btnList = document.getElementsByClassName("jodit-toolbar-button_insertTodo");
|
|
295
|
+
const el = btnList[0];
|
|
296
|
+
const isPressed = el?.getAttribute("aria-pressed") === "true";
|
|
297
|
+
if (!isPressed || btn?.control?.name !== "insertTodo") {
|
|
298
|
+
const todo = createTodoItem(btn?.control?.name ?? "empty");
|
|
299
|
+
jodit.selection.insertNode(todo);
|
|
300
|
+
const span = todo.querySelector("span");
|
|
301
|
+
if (span) jodit.selection.setCursorIn(span);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
};
|
|
305
|
+
const toggleButton = {
|
|
306
|
+
name: "toggleButtons",
|
|
307
|
+
tooltip: showAll ? "Show less" : "Show more",
|
|
308
|
+
iconURL: showAll ? "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIyIiBmaWxsPSJub25lIi8+PHBvbHlsaW5lIHBvaW50cz0iOCAxNCAxMiAxMCAxNiAxNCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=" : "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSIxMSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIyIiBmaWxsPSJub25lIi8+PHBvbHlsaW5lIHBvaW50cz0iOCAxMCAxMiAxNCAxNiAxMCIgZmlsbD0ibm9uZSIgc3Ryb2tlPSJibGFjayIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4=",
|
|
309
|
+
exec: () => setShowAll((prev) => !prev)
|
|
310
|
+
};
|
|
311
|
+
const config = React.useMemo(() => {
|
|
312
|
+
let uploadConfig = {};
|
|
313
|
+
if (uploadUrl) {
|
|
314
|
+
const uploadData = {};
|
|
315
|
+
uploadConfig = {
|
|
316
|
+
uploader: {
|
|
317
|
+
url: uploadUrl,
|
|
318
|
+
headers: token ? { AuthToken: token } : {},
|
|
319
|
+
imagesExtensions: ["jpg", "png", "jpeg", "webp"],
|
|
320
|
+
processFileName: (key, file, name) => {
|
|
321
|
+
uploadData.file = file;
|
|
322
|
+
return [key, file, name];
|
|
323
|
+
},
|
|
324
|
+
buildData(data) {
|
|
325
|
+
const ext = uploadData.file?.name.split(".").pop() ?? "";
|
|
326
|
+
if (!["jpg", "png", "jpeg", "webp"].includes(ext.toLowerCase())) {
|
|
327
|
+
onError?.("Please choose a jpg, png, jpeg or webp file.");
|
|
328
|
+
return new Promise(() => {
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
const form = new FormData();
|
|
332
|
+
form.append("file", uploadData.file);
|
|
333
|
+
form.append("isPublicLink", "true");
|
|
334
|
+
return form;
|
|
335
|
+
},
|
|
336
|
+
isSuccess: (resp) => !resp?.error,
|
|
337
|
+
defaultHandlerSuccess(data) {
|
|
338
|
+
if (data?.url && this.s) {
|
|
339
|
+
this.s.insertImage(data.url);
|
|
340
|
+
onImageUploadSuccess?.(data.url);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
const baseButtons = [
|
|
347
|
+
...UNDO_REDO,
|
|
348
|
+
...aiSupport ? AI_BUTTONS : [],
|
|
349
|
+
...isMobile && !showAll ? MOBILE_BUTTONS : BASIC_BUTTONS,
|
|
350
|
+
...isMobile ? ["|"] : [],
|
|
351
|
+
...isMobile && showAll ? MORE_BUTTONS : [],
|
|
352
|
+
...!isMobile ? MORE_BUTTONS : [],
|
|
353
|
+
...onClose ? [{
|
|
354
|
+
name: "close",
|
|
355
|
+
tooltip: "Close",
|
|
356
|
+
iconURL: "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E",
|
|
357
|
+
exec: () => onClose()
|
|
358
|
+
}] : []
|
|
359
|
+
];
|
|
360
|
+
return {
|
|
361
|
+
readonly: disabled,
|
|
362
|
+
license: licenseKey,
|
|
363
|
+
toolbar: true,
|
|
364
|
+
spellcheck: true,
|
|
365
|
+
language: "en",
|
|
366
|
+
placeholder,
|
|
367
|
+
toolbarButtonSize: "middle",
|
|
368
|
+
toolbarAdaptive: false,
|
|
369
|
+
showCharsCounter: true,
|
|
370
|
+
showWordsCounter: true,
|
|
371
|
+
showXPathInStatusbar: false,
|
|
372
|
+
askBeforePasteHTML: false,
|
|
373
|
+
askBeforePasteFromWord: true,
|
|
374
|
+
processPasteFromWord: true,
|
|
375
|
+
processPasteHTML: true,
|
|
376
|
+
nl2brInPlainText: false,
|
|
377
|
+
defaultActionOnPasteFromWord: "insert_as_html",
|
|
378
|
+
scrollToPastedContent: true,
|
|
379
|
+
link: { noFollowCheckbox: true, openInNewTabCheckbox: true },
|
|
380
|
+
defaultLineHeight: 0.5,
|
|
381
|
+
lineHeight: [0.5, 1, 1.15, 1.5, 2],
|
|
382
|
+
allowResizeY,
|
|
383
|
+
width,
|
|
384
|
+
height,
|
|
385
|
+
...translationKey ? {
|
|
386
|
+
translate: {
|
|
387
|
+
provider: "google",
|
|
388
|
+
googleProviderOptions: { key: translationKey }
|
|
389
|
+
}
|
|
390
|
+
} : {},
|
|
391
|
+
...aiSupport ? {
|
|
392
|
+
aiAssistant: {
|
|
393
|
+
aiAssistantCallback(prompt, htmlFragment) {
|
|
394
|
+
return fetch("https://api.openai.com/v1/chat/completions", {
|
|
395
|
+
method: "POST",
|
|
396
|
+
headers: { "Content-Type": "application/json", Authorization: `Bearer ${window.__RTE_OPENAI_KEY__ ?? ""}` },
|
|
397
|
+
body: JSON.stringify({ model: "gpt-3.5-turbo", messages: [{ role: "system", content: prompt }, { role: "user", content: htmlFragment }] })
|
|
398
|
+
}).then((r) => r.json()).then((d) => {
|
|
399
|
+
if (d.error) throw new Error(d.error.message);
|
|
400
|
+
return d.choices?.[0]?.message?.content ?? "";
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
} : {},
|
|
405
|
+
...mentions?.arr?.length ? {
|
|
406
|
+
autocomplete: {
|
|
407
|
+
sources: [{
|
|
408
|
+
feed: (query) => {
|
|
409
|
+
if (!query.includes("@")) return [];
|
|
410
|
+
return mentions.arr.filter((m) => m.id.includes(query) || m.name.includes(query));
|
|
411
|
+
},
|
|
412
|
+
itemRenderer: (item) => `<span class="mention-option">${item.id}</span>`,
|
|
413
|
+
insertValueRenderer: (item) => `<span class="mention-jodit" data-mention="${item.id}" data-user-id="${item.userId ?? ""}" href="${item.link ?? ""}">${item.id}</span>`
|
|
414
|
+
}]
|
|
415
|
+
}
|
|
416
|
+
} : {},
|
|
417
|
+
...uploadConfig,
|
|
418
|
+
buttons: [...baseButtons, ...fullSize ? ["fullsize"] : []],
|
|
419
|
+
extraButtons: [
|
|
420
|
+
speechButton,
|
|
421
|
+
todoButton,
|
|
422
|
+
...isMobile ? [toggleButton] : []
|
|
423
|
+
],
|
|
424
|
+
safePluginList: ["changecase", "rteKeyLogger"]
|
|
425
|
+
};
|
|
426
|
+
}, [isMobile, showAll, isListening, disabled, aiSupport, licenseKey, translationKey, token, uploadUrl, mentions?.arr?.length, height, width, allowResizeY, fullSize, placeholder]);
|
|
427
|
+
return /* @__PURE__ */ React.createElement(
|
|
428
|
+
"div",
|
|
429
|
+
{
|
|
430
|
+
ref: containerRef,
|
|
431
|
+
className: `rte-wrapper ${isListening ? "rte-listening" : ""} ${className}`,
|
|
432
|
+
style
|
|
433
|
+
},
|
|
434
|
+
/* @__PURE__ */ React.createElement(
|
|
435
|
+
JoditReact,
|
|
436
|
+
{
|
|
437
|
+
ref: editorRef,
|
|
438
|
+
value,
|
|
439
|
+
config,
|
|
440
|
+
tabIndex: 1,
|
|
441
|
+
onChange: (v) => onChange?.(v),
|
|
442
|
+
onBlur: (v) => onBlur?.(v)
|
|
443
|
+
}
|
|
444
|
+
),
|
|
445
|
+
/* @__PURE__ */ React.createElement(
|
|
446
|
+
"div",
|
|
447
|
+
{
|
|
448
|
+
className: "rte-speech-popup",
|
|
449
|
+
style: {
|
|
450
|
+
top: speechPos.top,
|
|
451
|
+
left: speechPos.left,
|
|
452
|
+
opacity: speechVisible && speechText ? 1 : 0,
|
|
453
|
+
transform: speechVisible ? "translateY(0)" : "translateY(10px)",
|
|
454
|
+
pointerEvents: "none"
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
/* @__PURE__ */ React.createElement("span", { className: "rte-speech-dot" }),
|
|
458
|
+
/* @__PURE__ */ React.createElement("span", null, speechText || "\u2026")
|
|
459
|
+
),
|
|
460
|
+
error && /* @__PURE__ */ React.createElement("p", { className: "rte-error" }, error)
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
var RichTextEditor_default = RichTextEditor;
|
|
464
|
+
|
|
465
|
+
export {
|
|
466
|
+
RichTextEditor,
|
|
467
|
+
RichTextEditor_default
|
|
468
|
+
};
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// lib/Progress/circularProgress.tsx
|
|
2
2
|
import * as React from "react";
|
|
3
|
-
var
|
|
3
|
+
var CircularProgress = ({
|
|
4
4
|
size = 50,
|
|
5
5
|
color = "#a81c08",
|
|
6
6
|
...props
|
|
@@ -24,7 +24,7 @@ var CircularProgess = ({
|
|
|
24
24
|
))
|
|
25
25
|
);
|
|
26
26
|
};
|
|
27
|
-
var circularProgress_default =
|
|
27
|
+
var circularProgress_default = CircularProgress;
|
|
28
28
|
|
|
29
29
|
export {
|
|
30
30
|
circularProgress_default
|
|
File without changes
|