@ai-matrx/rich-editor 0.5.1 → 0.5.2

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.2
4
+ ### A typed link keeps the space after it (2026-10-08)
5
+
6
+ - 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).
7
+
8
+ Consumer action: none.
9
+
3
10
  ## 0.5.1
4
11
  ### The toolbar measures its layout width (2026-10-08)
5
12
 
@@ -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
  };
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.2",
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,12 +91,12 @@
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",
94
95
  "@ai-matrx/content-ir": "latest",
95
96
  "@ai-matrx/design-system": "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",