@tarviks/lexical-rich-editor 1.0.8 → 1.0.9
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 +69 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5183,11 +5183,21 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5183
5183
|
const [s, setS] = React9__namespace.useState(hsv.s);
|
|
5184
5184
|
const [v, setV] = React9__namespace.useState(hsv.v);
|
|
5185
5185
|
const wasOpenRef = React9__namespace.useRef(open);
|
|
5186
|
+
console.log("[AO-ColorPicker]", title, "render with incoming value prop:", JSON.stringify(value));
|
|
5186
5187
|
React9__namespace.useEffect(() => {
|
|
5187
5188
|
const justOpened = open && !wasOpenRef.current;
|
|
5188
5189
|
wasOpenRef.current = open;
|
|
5190
|
+
console.log("[AO-ColorPicker]", title, "open-seed effect", {
|
|
5191
|
+
open,
|
|
5192
|
+
justOpened,
|
|
5193
|
+
incomingValue: value
|
|
5194
|
+
});
|
|
5189
5195
|
if (!justOpened) return;
|
|
5190
5196
|
const n = normalizeHex(value || "#000000");
|
|
5197
|
+
console.log("[AO-ColorPicker]", title, "seeding local state from value on open", {
|
|
5198
|
+
incomingValue: value,
|
|
5199
|
+
normalized: n
|
|
5200
|
+
});
|
|
5191
5201
|
setHex(n);
|
|
5192
5202
|
const rgb = hexToRgb(n);
|
|
5193
5203
|
const next = rgbToHsv(rgb.r, rgb.g, rgb.b);
|
|
@@ -5200,10 +5210,11 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5200
5210
|
const rgb = hsvToRgb(hh, ss, vv);
|
|
5201
5211
|
const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
|
|
5202
5212
|
setHex(nextHex);
|
|
5213
|
+
console.log("[AO-ColorPicker]", title, "commitHsv -> onChange", { nextHex, close: !!close });
|
|
5203
5214
|
onChange(nextHex);
|
|
5204
5215
|
if (close) setOpen(false);
|
|
5205
5216
|
},
|
|
5206
|
-
[onChange]
|
|
5217
|
+
[onChange, title]
|
|
5207
5218
|
);
|
|
5208
5219
|
const svRef = React9__namespace.useRef(null);
|
|
5209
5220
|
const onSVMove = React9__namespace.useCallback(
|
|
@@ -5258,6 +5269,10 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5258
5269
|
},
|
|
5259
5270
|
onClick: () => {
|
|
5260
5271
|
if (disabled) return;
|
|
5272
|
+
console.log("[AO-ColorPicker]", title, "trigger button clicked", {
|
|
5273
|
+
wasOpen: open,
|
|
5274
|
+
activeElementBeforeToggle: document.activeElement?.tagName
|
|
5275
|
+
});
|
|
5261
5276
|
setOpen((p) => !p);
|
|
5262
5277
|
}
|
|
5263
5278
|
}
|
|
@@ -5308,6 +5323,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5308
5323
|
setH(next.h);
|
|
5309
5324
|
setS(next.s);
|
|
5310
5325
|
setV(next.v);
|
|
5326
|
+
console.log("[AO-ColorPicker]", title, "hex field blur -> onChange", { raw: hex, normalized: n });
|
|
5311
5327
|
onChange(n);
|
|
5312
5328
|
}
|
|
5313
5329
|
}
|
|
@@ -5326,6 +5342,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
|
|
|
5326
5342
|
setH(next.h);
|
|
5327
5343
|
setS(next.s);
|
|
5328
5344
|
setV(next.v);
|
|
5345
|
+
console.log("[AO-ColorPicker]", title, "preset swatch click -> onChange", { color: c });
|
|
5329
5346
|
onChange(c);
|
|
5330
5347
|
},
|
|
5331
5348
|
title: c
|
|
@@ -5364,10 +5381,20 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
5364
5381
|
const lastRangeSelectionRef = React9__namespace.default.useRef(null);
|
|
5365
5382
|
const updateToolbar = () => {
|
|
5366
5383
|
const selection$1 = lexical.$getSelection();
|
|
5367
|
-
|
|
5384
|
+
const isRange = lexical.$isRangeSelection(selection$1);
|
|
5385
|
+
console.log("[AO-ColorPicker] updateToolbar", {
|
|
5386
|
+
isRangeSelection: isRange,
|
|
5387
|
+
isCollapsed: isRange ? selection$1.isCollapsed() : null
|
|
5388
|
+
});
|
|
5389
|
+
if (isRange) {
|
|
5368
5390
|
lastRangeSelectionRef.current = selection$1.clone();
|
|
5369
5391
|
const c = selection.$getSelectionStyleValueForProperty(selection$1, "color", "#000000");
|
|
5370
|
-
const bg = selection.$getSelectionStyleValueForProperty(
|
|
5392
|
+
const bg = selection.$getSelectionStyleValueForProperty(
|
|
5393
|
+
selection$1,
|
|
5394
|
+
"background-color",
|
|
5395
|
+
"#ffffff"
|
|
5396
|
+
);
|
|
5397
|
+
console.log("[AO-ColorPicker] updateToolbar readback", { color: c, bgColor: bg });
|
|
5371
5398
|
setColors({ color: c, bgColor: bg });
|
|
5372
5399
|
}
|
|
5373
5400
|
};
|
|
@@ -5390,6 +5417,17 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
5390
5417
|
if (disabled) return;
|
|
5391
5418
|
const root = editor.getRootElement();
|
|
5392
5419
|
const editorIsActive = !!lastRangeSelectionRef.current && !!root && (document.activeElement === root || root.contains(document.activeElement));
|
|
5420
|
+
console.log("[AO-ColorPicker] applyStyle called", {
|
|
5421
|
+
property: args.property,
|
|
5422
|
+
color: args.color,
|
|
5423
|
+
hasSavedSelection: !!lastRangeSelectionRef.current,
|
|
5424
|
+
savedSelectionIsCollapsed: lastRangeSelectionRef.current?.isCollapsed() ?? null,
|
|
5425
|
+
editorIsActive,
|
|
5426
|
+
activeElementTag: document.activeElement?.tagName,
|
|
5427
|
+
activeElementClass: document.activeElement?.className,
|
|
5428
|
+
rootIsActiveElement: document.activeElement === root,
|
|
5429
|
+
rootContainsActiveElement: !!root && root.contains(document.activeElement)
|
|
5430
|
+
});
|
|
5393
5431
|
if (editorIsActive) editor.focus();
|
|
5394
5432
|
editor.update(() => {
|
|
5395
5433
|
const saved = lastRangeSelectionRef.current;
|
|
@@ -5397,8 +5435,29 @@ var ColorPickerPlugin = ({ disabled }) => {
|
|
|
5397
5435
|
lexical.$setSelection(saved.clone());
|
|
5398
5436
|
}
|
|
5399
5437
|
const selection$1 = lexical.$getSelection();
|
|
5400
|
-
|
|
5438
|
+
const isRange = lexical.$isRangeSelection(selection$1);
|
|
5439
|
+
console.log("[AO-ColorPicker] applyStyle inside editor.update", {
|
|
5440
|
+
hadSavedSelection: !!saved,
|
|
5441
|
+
selectionAfterRestoreIsRange: isRange,
|
|
5442
|
+
selectionAfterRestoreIsCollapsed: isRange ? selection$1.isCollapsed() : null
|
|
5443
|
+
});
|
|
5444
|
+
if (isRange) {
|
|
5401
5445
|
selection.$patchStyleText(selection$1, { [args.property]: args.color });
|
|
5446
|
+
const verify = selection.$getSelectionStyleValueForProperty(
|
|
5447
|
+
selection$1,
|
|
5448
|
+
args.property,
|
|
5449
|
+
"<none>"
|
|
5450
|
+
);
|
|
5451
|
+
console.log("[AO-ColorPicker] applyStyle after patchStyleText, readback in same update", {
|
|
5452
|
+
property: args.property,
|
|
5453
|
+
appliedColor: args.color,
|
|
5454
|
+
readBack: verify
|
|
5455
|
+
});
|
|
5456
|
+
} else {
|
|
5457
|
+
console.warn(
|
|
5458
|
+
"[AO-ColorPicker] applyStyle: no range selection available \u2014 style was NOT applied",
|
|
5459
|
+
{ property: args.property, color: args.color }
|
|
5460
|
+
);
|
|
5402
5461
|
}
|
|
5403
5462
|
});
|
|
5404
5463
|
};
|
|
@@ -6742,6 +6801,12 @@ function FocusEventsPlugin({
|
|
|
6742
6801
|
const next = e.relatedTarget;
|
|
6743
6802
|
const container = containerRef.current;
|
|
6744
6803
|
const stillInside = !!next && (container ? container.contains(next) : root.contains(next));
|
|
6804
|
+
console.log("[AO-ColorPicker] FocusEventsPlugin focusout", {
|
|
6805
|
+
relatedTargetTag: next ? next.tagName : null,
|
|
6806
|
+
relatedTargetClass: next ? next.className : null,
|
|
6807
|
+
stillInside,
|
|
6808
|
+
willClearSelection: !stillInside
|
|
6809
|
+
});
|
|
6745
6810
|
if (stillInside) return;
|
|
6746
6811
|
editor.update(() => {
|
|
6747
6812
|
lexical.$setSelection(null);
|