@ai-matrx/rich-editor 0.5.2 → 0.5.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.3
4
+ ### The toolbar keeps more buttons in a short row (2026-10-08)
5
+
6
+ - `FormatButtons`: when the row cannot hold the full toolbar, the text-style menu shrinks to its icon (about 45px) BEFORE any button folds into More; and the group dividers are 4px narrower each (`mx-0.5`). A narrow notes header keeps Bold, Italic, text style, bulleted, numbered, checklist and Link.
7
+
8
+ Consumer action: none.
9
+
3
10
  ## 0.5.2
4
11
  ### A typed link keeps the space after it (2026-10-08)
5
12
 
@@ -151,17 +151,21 @@ function FormatButtons({ resolve, disabled = false, className, size = "sm", vari
151
151
  resolve()?.run(command);
152
152
  };
153
153
  const button = size === "xs" ? 26 : 30;
154
- const styleWidth = variant === "essential" ? size === "xs" ? 40 : 44 : 90;
155
- const widthOf = (slot) => slot.kind === "button" ? button : slot.kind === "style" ? styleWidth : 11;
154
+ const styleWidthFor = (compact) => variant === "essential" || compact ? size === "xs" ? 40 : 45 : 90;
156
155
  const all = slotsOf(variant);
156
+ const foldedByDefault = variant === "essential" ? slotsOf("full").filter((s) => s.kind === "button" && !ESSENTIAL_COMMANDS.includes(s.spec.command)) : [];
157
+ const widthOfWith = (styleWidth) => (slot) => slot.kind === "button" ? button : slot.kind === "style" ? styleWidth : 7;
158
+ const rowWidthWith = (styleWidth) => (slots) => withDividers(slots).reduce((sum, s) => sum + widthOfWith(styleWidth)(s), 0) + button;
157
159
  let kept = all;
158
- let folded = variant === "essential" ? slotsOf("full").filter((s) => s.kind === "button" && !ESSENTIAL_COMMANDS.includes(s.spec.command)) : [];
159
- const rowWidth = (slots, more) => withDividers(slots).reduce((sum, s) => sum + widthOf(s), 0) + (more ? button : 0);
160
- if (width > 0 && rowWidth(kept, true) > width + 4) {
160
+ let folded = foldedByDefault;
161
+ let compactStyle = false;
162
+ if (width > 0 && variant === "full" && rowWidthWith(styleWidthFor(false))(all) > width + 4) compactStyle = true;
163
+ const rowWidth = rowWidthWith(styleWidthFor(compactStyle));
164
+ if (width > 0 && rowWidth(kept) > width + 4) {
161
165
  const byKeep = [...all].sort((x, y) => keepOf(x) - keepOf(y));
162
166
  const dropped = /* @__PURE__ */ new Set();
163
167
  for (const slot of byKeep) {
164
- if (rowWidth(all.filter((s) => !dropped.has(s)), true) <= width + 4) break;
168
+ if (rowWidth(all.filter((s) => !dropped.has(s))) <= width + 4) break;
165
169
  dropped.add(slot);
166
170
  }
167
171
  kept = all.filter((s) => !dropped.has(s));
@@ -187,7 +191,7 @@ function FormatButtons({ resolve, disabled = false, className, size = "sm", vari
187
191
  className: cn("flex min-w-0 flex-nowrap items-center gap-0.5 overflow-hidden", className),
188
192
  children: [
189
193
  shown.map((slot, index) => {
190
- if (slot.kind === "divider") return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "mx-1 h-5 w-px shrink-0 bg-border" }, `d${index}`);
194
+ if (slot.kind === "divider") return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "mx-0.5 h-5 w-px shrink-0 bg-border" }, `d${index}`);
191
195
  if (slot.kind === "style") {
192
196
  const StyleIcon = currentStyle.icon;
193
197
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
@@ -202,10 +206,10 @@ function FormatButtons({ resolve, disabled = false, className, size = "sm", vari
202
206
  className: cn(
203
207
  "inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 text-xs font-medium text-muted-foreground hover:bg-accent hover:text-foreground",
204
208
  size === "xs" ? "h-6" : "h-7",
205
- variant === "full" && "w-[88px] justify-between"
209
+ variant === "full" && !compactStyle && "w-[88px] justify-between"
206
210
  ),
207
211
  children: [
208
- variant === "essential" ? /* @__PURE__ */ jsx(StyleIcon, { className: iconClass }) : /* @__PURE__ */ jsx("span", { className: "truncate", children: BLOCK_SHORT[currentStyle.command] }),
212
+ variant === "essential" || compactStyle ? /* @__PURE__ */ jsx(StyleIcon, { className: iconClass }) : /* @__PURE__ */ jsx("span", { className: "truncate", children: BLOCK_SHORT[currentStyle.command] }),
209
213
  /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3 shrink-0" })
210
214
  ]
211
215
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/rich-editor",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "The AI Matrx editor: Visual (Tiptap), Source (CodeMirror), Preview, the markdown formatting command layer, and edit-in-place — over @ai-matrx/rich-content. Consumers that only render never install it.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -91,9 +91,9 @@
91
91
  "github-slugger": "^2.0.0",
92
92
  "lucide-react": "^1.48.0",
93
93
  "@ai-matrx/agents": "latest",
94
- "@ai-matrx/alchemy": "latest",
95
94
  "@ai-matrx/content-ir": "latest",
96
95
  "@ai-matrx/design-system": "latest",
96
+ "@ai-matrx/alchemy": "latest",
97
97
  "@ai-matrx/kit": "latest",
98
98
  "@ai-matrx/print": "latest",
99
99
  "@ai-matrx/rich-content": "latest"