@ai-matrx/rich-editor 0.1.2 → 0.1.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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3
4
+ ### Unreleased
5
+
6
+ ### Shared fence parsing
7
+
8
+ - Code-block formatting uses Content IR's canonical fence opener. Invalid
9
+ backtick info is not mistaken for a block that should be unwrapped.
10
+
11
+ ### Consumer action
12
+
13
+ - None required. Formatting commands and selection contracts are unchanged.
14
+
3
15
  ## 0.1.2
4
16
 
5
17
  The packed-tarball canary now uses the public source-edit helper and proves both resulting markdown
@@ -22,3 +34,4 @@ approval, host value, block insert, shortcuts), `in-place/{in-place-session,care
22
34
  ### Consumer action
23
35
 
24
36
  - matrx-frontend: import `@ai-matrx/rich-editor/core/<module>` instead of `@/components/rich-editor/core/<module>`.
37
+
@@ -1,3 +1,4 @@
1
+ import { fenceOpenerOf } from "@ai-matrx/content-ir/source";
1
2
  const FORMAT_COMMAND_IDS = [
2
3
  "bold",
3
4
  "italic",
@@ -217,12 +218,11 @@ function quoteCommand(text, from, to) {
217
218
  const head = from === to ? anchor : mapPos(to, ordered, 1);
218
219
  return { changes: ordered, anchor, head };
219
220
  }
220
- const FENCE = /^ {0,3}(`{3,}|~{3,})/;
221
221
  function codeBlockCommand(text, from, to) {
222
222
  const lines = linesTouched(text, from, to);
223
223
  const first = lines[0];
224
224
  const last = lines[lines.length - 1];
225
- if (lines.length >= 2 && FENCE.test(first.text) && FENCE.test(last.text)) {
225
+ if (lines.length >= 2 && fenceOpenerOf(first.text) && fenceOpenerOf(last.text)) {
226
226
  const changes2 = [
227
227
  { from: first.start, to: Math.min(first.end + 1, text.length), insert: "" },
228
228
  { from: last.start - 1, to: last.end, insert: "" }
@@ -236,7 +236,7 @@ function codeBlockCommand(text, from, to) {
236
236
  const nextStart = last.end + 1;
237
237
  const nextBreak = text.indexOf("\n", nextStart);
238
238
  const nextLine = nextStart <= text.length ? text.slice(nextStart, nextBreak === -1 ? text.length : nextBreak) : "";
239
- if (prevEnd >= 0 && FENCE.test(prevLine) && nextStart <= text.length && FENCE.test(nextLine) && nextLine.trim().replace(/[`~]/g, "") === "") {
239
+ if (prevEnd >= 0 && fenceOpenerOf(prevLine) && nextStart <= text.length && fenceOpenerOf(nextLine) && nextLine.trim().replace(/[`~]/g, "") === "") {
240
240
  const nextEnd = nextBreak === -1 ? text.length : nextBreak;
241
241
  const changes2 = [
242
242
  { from: prevStart, to: first.start, insert: "" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-matrx/rich-editor",
3
- "version": "0.1.2",
3
+ "version": "0.1.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",
@@ -55,8 +55,8 @@
55
55
  "@tiptap/pm": "^3.31.3",
56
56
  "github-slugger": "^2.0.0",
57
57
  "@ai-matrx/content-ir": "latest",
58
- "@ai-matrx/print": "latest",
59
- "@ai-matrx/rich-content": "latest"
58
+ "@ai-matrx/rich-content": "latest",
59
+ "@ai-matrx/print": "latest"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "react": ">=19.0.0",