# Content Behavior

> Editor42 content behavior options — Enter key handling, text patterns, root blocks, and drag-and-drop.

Source: https://editor42.com/api/configuration/content-behavior  
Section: Configuration Options > Content Behavior  
Every page of editor42.com has a Markdown copy at its URL + `.md` (`index.md` after a URL that ends in `/`); all of them are in one file: https://editor42.com/llms-full.txt

These options control how the editor handles content creation, Enter key behavior, text patterns, and drag-and-drop operations.

## Options

| Option | Type | Default | Description |
|---|---|---|---|
| `forced_root_block` | string | `p` | Block element used to wrap text nodes at the root level. |
| `forced_root_block_attrs` | object | `{}` | HTML attributes applied to the forced root block element. |
| `newline_behavior` | string | `default` | What happens when the user presses Enter. `block` inserts a new block, `linebreak` inserts a `<br>`, `invert` swaps the behavior of Enter and Shift+Enter, `default` uses the standard behavior. |
| `br_in_pre` | boolean | `true` | Insert a `<br>` instead of splitting into a new `<pre>` block when Enter is pressed inside a `<pre>` element. |
| `br_newline_selector` | string | `.editor42-m-toc h2,figcaption,caption` | CSS selector for elements where Enter inserts a `<br>` instead of creating a new block. |
| `no_newline_selector` | string | `''` | CSS selector for elements where the Enter key is suppressed entirely. |
| `keep_styles` | boolean | `true` | Carry text formatting (bold, italic, etc.) into the new paragraph when pressing Enter. |
| `end_container_on_empty_block` | boolean/string | `blockquote` | End a containing block when the user presses Enter twice on an empty line. Set to a tag name or `true` for all blocks. |
| `text_patterns` | object[]/false | see below | Markdown-like text patterns that trigger automatic formatting. Set to `false` to disable. |
| `text_patterns_lookup` | function | — | Callback that dynamically provides additional text patterns based on context. |
| `block_unsupported_drop` | boolean | `true` | Block drag-and-drop of content types that the editor does not support. |
| `table_tab_navigation` | boolean | `true` | Allow the Tab key to navigate between table cells. |
| `newdocument_content` | string | `''` | HTML content inserted when the "New Document" command is executed. |

### Default text patterns

The built-in text patterns include:

- `*text*` — italic
- `**text**` — bold
- `#` — heading 1 (up to `######` for heading 6)
- `*` or `-` — unordered list
- `1.` — ordered list

## Example

```js
editor42.init({
  selector: 'textarea',
  forced_root_block: 'div',
  newline_behavior: 'linebreak',
  keep_styles: true,
  text_patterns: [
    { start: '*', end: '*', format: 'italic' },
    { start: '**', end: '**', format: 'bold' },
    { start: '# ', cmd: 'editor42InsertContent', value: '<h1>$1</h1>' }
  ]
});
```
