@ai-matrx/rich-editor 0.5.1 → 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,19 @@
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
+
10
+ ## 0.5.2
11
+ ### A typed link keeps the space after it (2026-10-08)
12
+
13
+ - The address-to-link rule no longer swallows the space that completed it under Tiptap ≤ 3.31.3 (what apps resolve today): it inserts the typed whitespace itself unless Tiptap (≥ 3.31.4) already put it in the document. Live in notes Write, `https://maps.example.com/alton and` stored `altonand`. The image and checklist rules work under both. Guard: `typing-and-table-menu.test.ts` › "under Tiptap ≤ 3.31.3" (`TYPING_RULES` is exported for it).
14
+
15
+ Consumer action: none.
16
+
3
17
  ## 0.5.1
4
18
  ### The toolbar measures its layout width (2026-10-08)
5
19
 
@@ -1,4 +1,4 @@
1
- import { Extension } from "@tiptap/core";
1
+ import { Extension, InputRule } from "@tiptap/core";
2
2
  /** `[ ] ` / `[] ` / `[x] ` typed at the very start of a line. */
3
3
  export declare const TASK_TYPED: RegExp;
4
4
  /** An address followed by the whitespace that ends it. */
@@ -8,4 +8,5 @@ export declare const IMAGE_TYPED: RegExp;
8
8
  /** Trailing punctuation is sentence, not address (GFM's extended-autolink rule). */
9
9
  export declare function trimUrl(url: string): string;
10
10
  /** The typed-markdown conversions (header). Image first: its URL must never be autolinked. */
11
+ export declare const TYPING_RULES: readonly InputRule[];
11
12
  export declare const MarkdownTypingRules: Extension<any, any>;
@@ -17,6 +17,10 @@ function listItemDepth($from) {
17
17
  }
18
18
  return -1;
19
19
  }
20
+ function typedWhitespaceInDoc(doc, range) {
21
+ if (range.to <= range.from) return false;
22
+ return /\s$/.test(doc.textBetween(range.to - 1, range.to, "\n", "\uFFFC"));
23
+ }
20
24
  const taskRule = new InputRule({
21
25
  find: TASK_TYPED,
22
26
  handler: ({ state, range, match }) => {
@@ -77,20 +81,23 @@ const urlRule = new InputRule({
77
81
  const href = /^www\./i.test(url) ? `https://${url}` : url;
78
82
  const { tr } = state;
79
83
  tr.addMark(start, end, link.create({ href, mdForm: "bare", mdTailHref: href, mdText: url }));
84
+ if (!typedWhitespaceInDoc(state.doc, range)) tr.insertText(match[2] ?? " ", range.to);
80
85
  tr.removeStoredMark(link);
81
86
  return void 0;
82
87
  }
83
88
  });
89
+ const TYPING_RULES = [taskRule, imageRule, urlRule];
84
90
  const MarkdownTypingRules = Extension.create({
85
91
  name: "richEditorTypingRules",
86
92
  addInputRules() {
87
- return [taskRule, imageRule, urlRule];
93
+ return [...TYPING_RULES];
88
94
  }
89
95
  });
90
96
  export {
91
97
  IMAGE_TYPED,
92
98
  MarkdownTypingRules,
93
99
  TASK_TYPED,
100
+ TYPING_RULES,
94
101
  URL_TYPED,
95
102
  trimUrl
96
103
  };
@@ -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.1",
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",
@@ -93,10 +93,10 @@
93
93
  "@ai-matrx/agents": "latest",
94
94
  "@ai-matrx/content-ir": "latest",
95
95
  "@ai-matrx/design-system": "latest",
96
+ "@ai-matrx/alchemy": "latest",
96
97
  "@ai-matrx/kit": "latest",
97
98
  "@ai-matrx/print": "latest",
98
- "@ai-matrx/rich-content": "latest",
99
- "@ai-matrx/alchemy": "latest"
99
+ "@ai-matrx/rich-content": "latest"
100
100
  },
101
101
  "peerDependencies": {
102
102
  "react": ">=19.0.0",