# catdown-core

> Core plugins for Catdown, included by default. Includes events, rendering, extended editor functionality and formatting key events.

Latest version **2.0.4** (published 2015-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install catdown-core
pnpm add catdown-core
yarn add catdown-core
bun add catdown-core
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.4 |
| Published | 2015-02-12 |
| First published | 2015-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Richard Foster |
| Maintainers | zuren |
| Keywords | catdown, markdown, core, plugin, render, controls, keys |

## Links

- npm: https://www.npmjs.com/package/catdown-core
- Repository: https://github.com/zuren/catdown-core
- Issues: https://github.com/zuren/catdown-core/issues
- npm.io page: https://npm.io/package/catdown-core

## Dependencies (1)

- [codemirror](https://npm.io/package/codemirror.md) ^4.12.0

## Alternatives

- [@mdxeditor/editor](https://npm.io/package/@mdxeditor/editor.md) — 962.4K weekly downloads
- [mmdb-lib](https://npm.io/package/mmdb-lib.md) — 680.9K weekly downloads
- [playcanvas](https://npm.io/package/playcanvas.md) — 36.2K weekly downloads
- [@glw907/cairn-cms](https://npm.io/package/@glw907/cairn-cms.md) — 967 weekly downloads
- [markdown-to-confluence](https://npm.io/package/markdown-to-confluence.md) — 103 weekly downloads

## Recent versions

- 2.0.4 (latest) — 2015-02-12
- 2.0.3 — 2015-02-11
- 2.0.2 — 2015-02-11
- 2.0.1 — 2015-02-11
- 2.0.0 — 2015-02-11
- 1.0.3 — 2015-02-10
- 1.0.2 — 2015-02-10
- 1.0.1 — 2015-02-10
- 1.0.0 — 2015-02-10

## README

# catdown-core

The core plugins for the [Catdown](https://github.com/zuren/catdown) Markdown editor. Included by default.

### Events

EventEmitter extracted from CodeMirror and extended. Now allows multiple event names and is manually bound to Catdown instance.

#### Usage

```js
// Add a handler to an event
editor.on("render", handler);

// Add a handler to multiple events
editor.on("ready change", handler);

// Signal an event with some args, calling any handlers listening to it.
editor.signal("something", 1, 2, 3);
```

### Render

Accepts a `preview` DOM element or jQuery object. On editor `ready` and `change` events, converts editor value to HTML using the Catdown `parser` and displays it in the preview.

### Keys

Key handling functionality. Accepts a hash of key combinations and handlers and binds to CodeMirror instance. Unlike CodeMirror's `editor.setOption("extraKeys", hash);`, it extends the existing keymap rather than replacing it. The syntax is identical though.

#### Usage

```js
editor.keys({
	"Ctrl-Shift-Up": function(){
		// add your functionality
	}
});
```

#### Default keymap

* `Ctrl-B` - Bold
* `Ctrl-I` - Italics
* `Ctrl-Alt-U` - Strikethrough
* `Ctrl-K` - Inline code
* `Ctrl-L` - List
* `Ctrl-Q` - Blockquote
* `Shift-Ctrl-L` - Insert link
* `Shift-Ctrl-I` - Insert image

### Controls

Adds some additional CodeMirror functionality to Catdown. `moveCursorX`, `moveCursorY` and `wrapSelection` are available in `editor.controls`.

#### `moveCursorX(int)`

Move cursor horizontally. Positive number goes right, negative goes left.

```js
// Move three spaces back
editor.controls.moveCursorX(-3);
```

#### `moveCursorY(int)`

Move cursor vertically. Positive number goes down, negative goes up.

```js
// Move two lines down
editor.controls.moveCursorY(2);
```

#### wrapSelections(leftStr, rightStr)

Wrap current selections between two strings. `rightStr` is empty by default so not required.

```js
// Make the current selections bold
editor.controls.wrapSelection("**", "**");
```

---
_Source: https://npm.io/package/catdown-core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
