You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add code formatting and RTL/LTR direction — v1.2.0
- Code button: inline <code> wrapping for selections, <pre> block for
cursor-only; clicking again toggles off
- Direction buttons (RTL/LTR): sets dir attribute + inline style
(direction + text-align) directly on the block element; per-block,
toggleable, always one active
- defaultDir prop: sets default text direction on the editor container
- Fix: typing after clearing editor now always starts inside a <p>
- Fix: direction feature rewrote block detection to handle missing
selection and avoid unreliable <div> wrapper approach
- Docs: README updated with direction section, defaultDir prop table
entry, fixed heading typos; CHANGELOG entry for v1.2.0
Copy file name to clipboardExpand all lines: CHANGELOG.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [1.2.0] - 2026-06-11
9
+
10
+
### Added
11
+
-**Code formatting** — new `code` feature flag and toolbar button with two modes:
12
+
- Text selected → wraps in inline `<code>`
13
+
- No selection / cursor in a block → converts to `<pre>` code block
14
+
- Clicking again inside `<code>` or `<pre>` removes the formatting (toggle)
15
+
- Both `<code>` and `<pre>` share the same visual style (monospace font, subtle background, accent border-left)
16
+
-**RTL / LTR direction** — new `direction` feature flag adds two toolbar buttons:
17
+
- Sets `dir` attribute and matching inline `style` (`direction` + `text-align`) directly on the current block element
18
+
- Per-block direction — each paragraph or heading can have its own direction
19
+
- Toggle behavior — clicking the active direction button removes the direction
20
+
- One button is always highlighted: current block dir → `defaultDir` → `'ltr'`
21
+
- Direction is written as inline style so output renders correctly without the editor stylesheet
22
+
-**`defaultDir` prop** — sets the default text direction (`'rtl'` | `'ltr'`) for the entire editor content area; useful for Persian / Arabic editors
23
+
- New SVG icons: `IconDirectionRTL`, `IconDirectionLTR`, `IconCode`
24
+
25
+
### Fixed
26
+
- Typing after clearing the editor produced bare text nodes not wrapped in `<p>` — `handleFocus` now inserts a `<p><br></p>` and positions the cursor inside when the editor is empty; `handleInput` also catches any remaining bare text nodes and wraps them
27
+
- Direction buttons previously used a `<div>` wrapper approach which broke block detection when no saved range was present; rewritten to set `dir` directly on the block element and handle missing selection gracefully
|`colorScheme`|`'light' \| 'dark'`|`'light'`| Color scheme |
99
+
|`defaultDir`|`'rtl' \| 'ltr'`| — | Default text direction for the editor |
99
100
|`height`|`number`|`400`| Min height of editor content area (px) |
100
101
|`className`|`string`| — | Extra CSS class on root element |
101
102
|`apiToken`|`string`| — | Token for future paid pro features |
102
103
103
-
###mperative Handle (ref)
104
+
###Imperative Handle (ref)
104
105
105
106
```tsx
106
107
import { useRef } from"react";
@@ -180,7 +181,55 @@ Disable any toolbar button by setting its flag to `false`:
180
181
/>
181
182
```
182
183
183
-
Full list of flags: `bold`, `italic`, `strikethrough`, `lists`, `blockquote`, `hr`, `align`, `link`, `fullscreen`, `kitchenSink`, `underline`, `justify`, `foreColor`, `pasteAsText`, `removeFormat`, `charMap`, `indent`, `undo`, `help`, `media`, `subscript`, `superscript`
184
+
Full list of flags: `bold`, `italic`, `strikethrough`, `lists`, `blockquote`, `hr`, `align`, `link`, `code`, `direction`, `fullscreen`, `kitchenSink`, `underline`, `justify`, `foreColor`, `pasteAsText`, `removeFormat`, `charMap`, `indent`, `undo`, `help`, `media`, `subscript`, `superscript`
185
+
186
+
---
187
+
188
+
## Code Formatting
189
+
190
+
The `code` feature adds a **Code** button to the toolbar. It has two modes depending on the selection:
191
+
192
+
| Context | Result |
193
+
|---|---|
194
+
| Text selected | Wraps in inline `<code>`|
195
+
| No selection / cursor in a block | Converts block to `<pre>` (code block) |
196
+
| Click again inside `<code>` or `<pre>`| Removes the formatting |
197
+
198
+
Both `<code>` and `<pre>` share the same visual style — monospace font, subtle background from `--me-textarea-bg`, and a matching border — so inline and block code look like a family.
199
+
200
+
```tsx
201
+
// Disable the code button
202
+
<MandooEditorfeatures={{ code: false }} />
203
+
```
204
+
205
+
---
206
+
207
+
## RTL / LTR Direction
208
+
209
+
The `direction` feature adds **RTL** and **LTR** toggle buttons to the toolbar. Direction is applied per block — each paragraph or heading can have its own direction independently.
210
+
211
+
| Action | Result |
212
+
|---|---|
213
+
| Click RTL | Sets `dir="rtl" style="direction:rtl; text-align:right"` on the current block |
214
+
| Click LTR | Sets `dir="ltr" style="direction:ltr; text-align:left"` on the current block |
215
+
| Click the active button again | Removes direction from the block (toggle off) |
216
+
217
+
One button is always highlighted: the active block's direction, or `defaultDir` if set, or LTR by default.
218
+
219
+
```tsx
220
+
// RTL-first editor (e.g. Persian / Arabic content)
221
+
<MandooEditordefaultDir="rtl" />
222
+
223
+
// Disable the direction buttons entirely
224
+
<MandooEditorfeatures={{ direction: false }} />
225
+
```
226
+
227
+
Direction is stored inline in the HTML output so it renders correctly anywhere, without requiring the editor's stylesheet:
0 commit comments