@threadlabs/looma 0.26.19 → 0.26.21

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.
@@ -4,6 +4,16 @@ export const backgrounds = [
4
4
  ["background-green", "Green", "#dcfce7"], ["background-red", "Red", "#fee2e2"],
5
5
  ];
6
6
 
7
+ // HTML parsing serializes hex colors as RGB. Compare browser-normalized CSS
8
+ // colors without changing the document value or treating invalid CSS as Default.
9
+ export function normalizeCellBackground(value, ownerDocument) {
10
+ const color = String(value ?? "").trim();
11
+ if (!color) return "";
12
+ const style = ownerDocument.createElement("span").style;
13
+ style.backgroundColor = color;
14
+ return style.backgroundColor || color;
15
+ }
16
+
7
17
  // Looma's icon set as plain data, generated from LOOMA_ICONS (see shared/icons.js).
8
18
  export { icons } from "./icons.js";
9
19
 
@@ -1,4 +1,4 @@
1
- import { backgrounds, viewport } from "../shared/editor.js";
1
+ import { backgrounds, normalizeCellBackground, viewport } from "../shared/editor.js";
2
2
 
3
3
  const sections = [
4
4
  ["Structure", [
@@ -51,9 +51,9 @@ function connect(host) {
51
51
  const scope = String(host.props.scope.value || "cell");
52
52
  const enabled = new Set((Array.isArray(host.props.actions.value) ? host.props.actions.value : []).filter((action) =>
53
53
  scope === "cell" || (scope === "row" ? !action.includes("column") : !action.includes("row"))));
54
- const background = String(host.props.cellBackground.value ?? "");
54
+ const background = normalizeCellBackground(host.props.cellBackground.value, element.ownerDocument);
55
55
  const swatches = backgrounds.filter(([action]) => enabled.has(action))
56
- .map(([action, label, color]) => ({ action, label, color, selected: color === background }));
56
+ .map(([action, label, color]) => ({ action, label, color, selected: normalizeCellBackground(color, element.ownerDocument) === background }));
57
57
  host.state.swatches = swatches.length ? swatches : null;
58
58
  host.state.sections = sections
59
59
  .map(([heading, items]) => ({
@@ -1,4 +1,4 @@
1
- import { backgrounds } from "../shared/editor.js";
1
+ import { backgrounds, normalizeCellBackground } from "../shared/editor.js";
2
2
  import { createAnchoredSurface } from "../shared/overlay.js";
3
3
 
4
4
  const overflowSections = [
@@ -45,9 +45,9 @@ function connect(host) {
45
45
  host.state.structure = [["add-row-after", "Add row", "rows"], ["add-column-after", "Add column", "columns"]]
46
46
  .filter(([action]) => enabled.has(action))
47
47
  .map(([action, label, icon]) => ({ action, label, icon }));
48
- const background = String(host.props.cellBackground.value ?? "");
48
+ const background = normalizeCellBackground(host.props.cellBackground.value, host.element.ownerDocument);
49
49
  host.state.swatches = backgrounds.filter(([action]) => enabled.has(action))
50
- .map(([action, label, color]) => ({ action, label, color, selected: color === background }));
50
+ .map(([action, label, color]) => ({ action, label, color, selected: normalizeCellBackground(color, host.element.ownerDocument) === background }));
51
51
  host.state.sections = overflowSections
52
52
  .map(([heading, items]) => ({
53
53
  heading,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.26.19",
3
+ "version": "0.26.21",
4
4
  "type": "module",
5
5
  "description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
6
6
  "license": "MIT",
@@ -2655,6 +2655,7 @@ var LoomaEditor = defineComponent({
2655
2655
  onBeforeUnmount(() => clearTimeout(codeBlurTimer));
2656
2656
  const updateTableUi = () => {
2657
2657
  const instance = editor.value;
2658
+ if (hoveredTableCell && (!instance || instance.isDestroyed || !instance.view.dom.contains(hoveredTableCell))) hoveredTableCell = null;
2658
2659
  const focusInTableUi = [
2659
2660
  tableToolbarShell.value,
2660
2661
  tableOverlayShell.value,