@ai-matrx/rich-editor 0.2.4 → 0.2.5
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,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.5
|
|
4
|
+
|
|
5
|
+
- The selection toolbar's formatting reaches a focused plain-text editor even when its zone's host half never reached the toolbar's target (2026-10-07 live: notes Split's textarea answered ⌘B and the header buttons, yet its selection toolbar showed no Bold). `focusedFormatTarget()` (format-target) is the fallback for an editable selection.
|
|
6
|
+
|
|
7
|
+
### Consumer action
|
|
8
|
+
|
|
9
|
+
- None required.
|
|
10
|
+
|
|
3
11
|
## 0.2.4
|
|
4
12
|
|
|
5
13
|
- Visible format buttons in plain text (Arman, 2026-10-04: "The formatting buttons need to work even when we are just showing plain text"). New `format/FormatButtons` (Bold, Italic, Code, Link, Heading, List — compact icons with tooltips) run THE command layer on a FormatTarget. The editor's Source view shows them inside its existing toolbar row.
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "lucide-react";
|
|
16
16
|
import { registerAlchemyIcon } from "@ai-matrx/rich-content/utils/alchemy-icon-keys";
|
|
17
17
|
import { declareSelectionProvider, hostHalf, placeSelectionActions, shownInSelectionMode } from "@ai-matrx/rich-content/selection-toolbar/selection-actions";
|
|
18
|
-
import { MARKDOWN_FORMAT_HOST_KEY } from "./format-target.js";
|
|
18
|
+
import { MARKDOWN_FORMAT_HOST_KEY, focusedFormatTarget } from "./format-target.js";
|
|
19
19
|
let visualResolver = null;
|
|
20
20
|
function registerVisualFormatResolver(resolver) {
|
|
21
21
|
visualResolver = resolver;
|
|
@@ -24,7 +24,8 @@ function formatTargetOf(target) {
|
|
|
24
24
|
const visual = visualResolver?.(target) ?? null;
|
|
25
25
|
if (visual) return visual;
|
|
26
26
|
const text = hostHalf(target, MARKDOWN_FORMAT_HOST_KEY);
|
|
27
|
-
|
|
27
|
+
if (text?.kind === "markdown-format") return text.target;
|
|
28
|
+
return target.selection?.type === "editable" ? focusedFormatTarget() : null;
|
|
28
29
|
}
|
|
29
30
|
const FORMATS = [
|
|
30
31
|
{ id: "bold", command: "bold", label: "Bold (\u2318B)", icon: Bold },
|
|
@@ -41,3 +41,11 @@ export declare function textareaFormatTarget(el: HTMLTextAreaElement): FormatTar
|
|
|
41
41
|
export declare function registerFormatElement(el: Element, target: FormatTarget): () => void;
|
|
42
42
|
/** The registered editor inside `root` the person is in (focused › last focused › first). */
|
|
43
43
|
export declare function formatTargetWithin(root: ParentNode | null | undefined): FormatTarget | null;
|
|
44
|
+
/**
|
|
45
|
+
* The focused plain-text editor (a registered textarea or Source view), whatever
|
|
46
|
+
* selection zones are mounted around it. The selection toolbar's format buttons
|
|
47
|
+
* fall back to it: 2026-10-07 live, notes Split's textarea answered ⌘B and the
|
|
48
|
+
* header's buttons, yet its selection toolbar showed no formatting — its zone's
|
|
49
|
+
* host half never reached the toolbar's target.
|
|
50
|
+
*/
|
|
51
|
+
export declare function focusedFormatTarget(): FormatTarget | null;
|
|
@@ -97,9 +97,15 @@ function formatTargetWithin(root) {
|
|
|
97
97
|
const pick = hosts.find((el) => active && (el === active || el.contains(active))) ?? (lastFocused && hosts.includes(lastFocused) ? lastFocused : null) ?? hosts[0];
|
|
98
98
|
return registeredTargets.get(pick) ?? null;
|
|
99
99
|
}
|
|
100
|
+
function focusedFormatTarget() {
|
|
101
|
+
if (typeof document === "undefined") return null;
|
|
102
|
+
const host = document.activeElement?.closest(`[${FORMAT_HOST_ATTR}]`) ?? null;
|
|
103
|
+
return host ? registeredTargets.get(host) ?? null : null;
|
|
104
|
+
}
|
|
100
105
|
export {
|
|
101
106
|
MARKDOWN_FORMAT_HOST_KEY,
|
|
102
107
|
applyEditToTextarea,
|
|
108
|
+
focusedFormatTarget,
|
|
103
109
|
formatTargetWithin,
|
|
104
110
|
markdownFormatHost,
|
|
105
111
|
registerFormatElement,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/rich-editor",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
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",
|