@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.mjs CHANGED
@@ -5162,11 +5162,21 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
5162
5162
  const [s, setS] = React9.useState(hsv.s);
5163
5163
  const [v, setV] = React9.useState(hsv.v);
5164
5164
  const wasOpenRef = React9.useRef(open);
5165
+ console.log("[AO-ColorPicker]", title, "render with incoming value prop:", JSON.stringify(value));
5165
5166
  React9.useEffect(() => {
5166
5167
  const justOpened = open && !wasOpenRef.current;
5167
5168
  wasOpenRef.current = open;
5169
+ console.log("[AO-ColorPicker]", title, "open-seed effect", {
5170
+ open,
5171
+ justOpened,
5172
+ incomingValue: value
5173
+ });
5168
5174
  if (!justOpened) return;
5169
5175
  const n = normalizeHex(value || "#000000");
5176
+ console.log("[AO-ColorPicker]", title, "seeding local state from value on open", {
5177
+ incomingValue: value,
5178
+ normalized: n
5179
+ });
5170
5180
  setHex(n);
5171
5181
  const rgb = hexToRgb(n);
5172
5182
  const next = rgbToHsv(rgb.r, rgb.g, rgb.b);
@@ -5179,10 +5189,11 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
5179
5189
  const rgb = hsvToRgb(hh, ss, vv);
5180
5190
  const nextHex = rgbToHex(rgb.r, rgb.g, rgb.b);
5181
5191
  setHex(nextHex);
5192
+ console.log("[AO-ColorPicker]", title, "commitHsv -> onChange", { nextHex, close: !!close });
5182
5193
  onChange(nextHex);
5183
5194
  if (close) setOpen(false);
5184
5195
  },
5185
- [onChange]
5196
+ [onChange, title]
5186
5197
  );
5187
5198
  const svRef = React9.useRef(null);
5188
5199
  const onSVMove = React9.useCallback(
@@ -5237,6 +5248,10 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
5237
5248
  },
5238
5249
  onClick: () => {
5239
5250
  if (disabled) return;
5251
+ console.log("[AO-ColorPicker]", title, "trigger button clicked", {
5252
+ wasOpen: open,
5253
+ activeElementBeforeToggle: document.activeElement?.tagName
5254
+ });
5240
5255
  setOpen((p) => !p);
5241
5256
  }
5242
5257
  }
@@ -5287,6 +5302,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
5287
5302
  setH(next.h);
5288
5303
  setS(next.s);
5289
5304
  setV(next.v);
5305
+ console.log("[AO-ColorPicker]", title, "hex field blur -> onChange", { raw: hex, normalized: n });
5290
5306
  onChange(n);
5291
5307
  }
5292
5308
  }
@@ -5305,6 +5321,7 @@ var ColorPickerControl = ({ value, title, disabled, onChange, icon }) => {
5305
5321
  setH(next.h);
5306
5322
  setS(next.s);
5307
5323
  setV(next.v);
5324
+ console.log("[AO-ColorPicker]", title, "preset swatch click -> onChange", { color: c });
5308
5325
  onChange(c);
5309
5326
  },
5310
5327
  title: c
@@ -5343,10 +5360,20 @@ var ColorPickerPlugin = ({ disabled }) => {
5343
5360
  const lastRangeSelectionRef = React9__default.useRef(null);
5344
5361
  const updateToolbar = () => {
5345
5362
  const selection = $getSelection();
5346
- if ($isRangeSelection(selection)) {
5363
+ const isRange = $isRangeSelection(selection);
5364
+ console.log("[AO-ColorPicker] updateToolbar", {
5365
+ isRangeSelection: isRange,
5366
+ isCollapsed: isRange ? selection.isCollapsed() : null
5367
+ });
5368
+ if (isRange) {
5347
5369
  lastRangeSelectionRef.current = selection.clone();
5348
5370
  const c = $getSelectionStyleValueForProperty(selection, "color", "#000000");
5349
- const bg = $getSelectionStyleValueForProperty(selection, "background-color", "#ffffff");
5371
+ const bg = $getSelectionStyleValueForProperty(
5372
+ selection,
5373
+ "background-color",
5374
+ "#ffffff"
5375
+ );
5376
+ console.log("[AO-ColorPicker] updateToolbar readback", { color: c, bgColor: bg });
5350
5377
  setColors({ color: c, bgColor: bg });
5351
5378
  }
5352
5379
  };
@@ -5369,6 +5396,17 @@ var ColorPickerPlugin = ({ disabled }) => {
5369
5396
  if (disabled) return;
5370
5397
  const root = editor.getRootElement();
5371
5398
  const editorIsActive = !!lastRangeSelectionRef.current && !!root && (document.activeElement === root || root.contains(document.activeElement));
5399
+ console.log("[AO-ColorPicker] applyStyle called", {
5400
+ property: args.property,
5401
+ color: args.color,
5402
+ hasSavedSelection: !!lastRangeSelectionRef.current,
5403
+ savedSelectionIsCollapsed: lastRangeSelectionRef.current?.isCollapsed() ?? null,
5404
+ editorIsActive,
5405
+ activeElementTag: document.activeElement?.tagName,
5406
+ activeElementClass: document.activeElement?.className,
5407
+ rootIsActiveElement: document.activeElement === root,
5408
+ rootContainsActiveElement: !!root && root.contains(document.activeElement)
5409
+ });
5372
5410
  if (editorIsActive) editor.focus();
5373
5411
  editor.update(() => {
5374
5412
  const saved = lastRangeSelectionRef.current;
@@ -5376,8 +5414,29 @@ var ColorPickerPlugin = ({ disabled }) => {
5376
5414
  $setSelection(saved.clone());
5377
5415
  }
5378
5416
  const selection = $getSelection();
5379
- if ($isRangeSelection(selection)) {
5417
+ const isRange = $isRangeSelection(selection);
5418
+ console.log("[AO-ColorPicker] applyStyle inside editor.update", {
5419
+ hadSavedSelection: !!saved,
5420
+ selectionAfterRestoreIsRange: isRange,
5421
+ selectionAfterRestoreIsCollapsed: isRange ? selection.isCollapsed() : null
5422
+ });
5423
+ if (isRange) {
5380
5424
  $patchStyleText(selection, { [args.property]: args.color });
5425
+ const verify = $getSelectionStyleValueForProperty(
5426
+ selection,
5427
+ args.property,
5428
+ "<none>"
5429
+ );
5430
+ console.log("[AO-ColorPicker] applyStyle after patchStyleText, readback in same update", {
5431
+ property: args.property,
5432
+ appliedColor: args.color,
5433
+ readBack: verify
5434
+ });
5435
+ } else {
5436
+ console.warn(
5437
+ "[AO-ColorPicker] applyStyle: no range selection available \u2014 style was NOT applied",
5438
+ { property: args.property, color: args.color }
5439
+ );
5381
5440
  }
5382
5441
  });
5383
5442
  };
@@ -6721,6 +6780,12 @@ function FocusEventsPlugin({
6721
6780
  const next = e.relatedTarget;
6722
6781
  const container = containerRef.current;
6723
6782
  const stillInside = !!next && (container ? container.contains(next) : root.contains(next));
6783
+ console.log("[AO-ColorPicker] FocusEventsPlugin focusout", {
6784
+ relatedTargetTag: next ? next.tagName : null,
6785
+ relatedTargetClass: next ? next.className : null,
6786
+ stillInside,
6787
+ willClearSelection: !stillInside
6788
+ });
6724
6789
  if (stillInside) return;
6725
6790
  editor.update(() => {
6726
6791
  $setSelection(null);