@tarviks/lexical-rich-editor 1.0.10 → 1.0.11
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.js +36 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +36 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5137,6 +5137,7 @@ function useDrag(onMove, onEnd, interactingRef) {
|
|
|
5137
5137
|
interactingRef.current = false;
|
|
5138
5138
|
}, 0);
|
|
5139
5139
|
}
|
|
5140
|
+
onEnd?.();
|
|
5140
5141
|
};
|
|
5141
5142
|
window.addEventListener("mousemove", move);
|
|
5142
5143
|
window.addEventListener("mouseup", up);
|
|
@@ -5212,17 +5213,33 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5212
5213
|
setS(next.s);
|
|
5213
5214
|
setV(next.v);
|
|
5214
5215
|
}, [value, open]);
|
|
5216
|
+
const updateHexFromHsv = React9__namespace.useCallback((hh, ss, vv) => {
|
|
5217
|
+
const rgb = hsvToRgb(hh, ss, vv);
|
|
5218
|
+
const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
5219
|
+
setHex(nextHex);
|
|
5220
|
+
return nextHex;
|
|
5221
|
+
}, []);
|
|
5215
5222
|
const commitHsv = React9__namespace.useCallback(
|
|
5216
5223
|
(hh, ss, vv, close) => {
|
|
5217
|
-
const
|
|
5218
|
-
const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
5219
|
-
setHex(nextHex);
|
|
5224
|
+
const nextHex = updateHexFromHsv(hh, ss, vv);
|
|
5220
5225
|
console.log("[AO-ColorPicker]", title, "commitHsv -> onChange", { nextHex, close: !!close });
|
|
5221
5226
|
onChange(nextHex);
|
|
5222
5227
|
if (close) setOpenAndNotify(false);
|
|
5223
5228
|
},
|
|
5224
|
-
[onChange, title, setOpenAndNotify]
|
|
5229
|
+
[onChange, title, setOpenAndNotify, updateHexFromHsv]
|
|
5225
5230
|
);
|
|
5231
|
+
const hRef = React9__namespace.useRef(h);
|
|
5232
|
+
const sRef = React9__namespace.useRef(s);
|
|
5233
|
+
const vRef = React9__namespace.useRef(v);
|
|
5234
|
+
React9__namespace.useEffect(() => {
|
|
5235
|
+
hRef.current = h;
|
|
5236
|
+
}, [h]);
|
|
5237
|
+
React9__namespace.useEffect(() => {
|
|
5238
|
+
sRef.current = s;
|
|
5239
|
+
}, [s]);
|
|
5240
|
+
React9__namespace.useEffect(() => {
|
|
5241
|
+
vRef.current = v;
|
|
5242
|
+
}, [v]);
|
|
5226
5243
|
const svRef = React9__namespace.useRef(null);
|
|
5227
5244
|
const onSVMove = React9__namespace.useCallback(
|
|
5228
5245
|
(clientX, clientY) => {
|
|
@@ -5234,11 +5251,16 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5234
5251
|
const vv = rect.height === 0 ? 0 : 1 - y / rect.height;
|
|
5235
5252
|
setS(ss);
|
|
5236
5253
|
setV(vv);
|
|
5237
|
-
|
|
5254
|
+
sRef.current = ss;
|
|
5255
|
+
vRef.current = vv;
|
|
5256
|
+
updateHexFromHsv(hRef.current, ss, vv);
|
|
5238
5257
|
},
|
|
5239
|
-
[
|
|
5258
|
+
[updateHexFromHsv]
|
|
5240
5259
|
);
|
|
5241
|
-
const
|
|
5260
|
+
const commitSV = React9__namespace.useCallback(() => {
|
|
5261
|
+
commitHsv(hRef.current, sRef.current, vRef.current);
|
|
5262
|
+
}, [commitHsv]);
|
|
5263
|
+
const startSV = useDrag(onSVMove, commitSV, interactingRef);
|
|
5242
5264
|
const hueRef = React9__namespace.useRef(null);
|
|
5243
5265
|
const onHueMove = React9__namespace.useCallback(
|
|
5244
5266
|
(clientX) => {
|
|
@@ -5247,11 +5269,15 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon, onOpenChange
|
|
|
5247
5269
|
const x = clamp3(clientX - rect.left, 0, rect.width);
|
|
5248
5270
|
const hh = rect.width === 0 ? 0 : x / rect.width * 360;
|
|
5249
5271
|
setH(hh);
|
|
5250
|
-
|
|
5272
|
+
hRef.current = hh;
|
|
5273
|
+
updateHexFromHsv(hh, sRef.current, vRef.current);
|
|
5251
5274
|
},
|
|
5252
|
-
[
|
|
5275
|
+
[updateHexFromHsv]
|
|
5253
5276
|
);
|
|
5254
|
-
const
|
|
5277
|
+
const commitHue = React9__namespace.useCallback(() => {
|
|
5278
|
+
commitHsv(hRef.current, sRef.current, vRef.current);
|
|
5279
|
+
}, [commitHsv]);
|
|
5280
|
+
const startHue = useDrag((x) => onHueMove(x), commitHue, interactingRef);
|
|
5255
5281
|
const svThumb = React9__namespace.useMemo(() => ({ left: `${s * 100}%`, top: `${(1 - v) * 100}%` }), [s, v]);
|
|
5256
5282
|
const hueThumb = React9__namespace.useMemo(() => ({ left: `${h / 360 * 100}%` }), [h]);
|
|
5257
5283
|
const hueColor = React9__namespace.useMemo(() => {
|