# simplemirror

> A simple and easy to use WYSIWYWG editor based on ProseMirror

Latest version **1.0.17** (published 2020-11-07) · 0 weekly downloads

## Install

```sh
npm install simplemirror
pnpm add simplemirror
yarn add simplemirror
bun add simplemirror
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.17 |
| Published | 2020-11-07 |
| First published | 2020-04-05 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 14 |
| Unpacked size | 3.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | phamvuau |

## Links

- npm: https://www.npmjs.com/package/simplemirror
- Repository: https://github.com/vuau/simplemirror
- Homepage: https://github.com/vuau/simplemirror#readme
- Issues: https://github.com/vuau/simplemirror/issues
- npm.io page: https://npm.io/package/simplemirror

## Dependencies (14)

- [prosemirror-view](https://npm.io/package/prosemirror-view.md) ^1.14.11
- [prosemirror-model](https://npm.io/package/prosemirror-model.md) ^1.8.2
- [prosemirror-state](https://npm.io/package/prosemirror-state.md) ^1.3.2
- [prosemirror-utils](https://npm.io/package/prosemirror-utils.md) ^0.9.6
- [prosemirror-keymap](https://npm.io/package/prosemirror-keymap.md) ^1.1.4
- [prosemirror-tables](https://npm.io/package/prosemirror-tables.md) ^1.1.0
- [prosemirror-history](https://npm.io/package/prosemirror-history.md) ^1.1.3
- [prosemirror-commands](https://npm.io/package/prosemirror-commands.md) ^1.1.4
- [prosemirror-markdown](https://npm.io/package/prosemirror-markdown.md) ^1.4.5
- [prosemirror-gapcursor](https://npm.io/package/prosemirror-gapcursor.md) ^1.1.5
- [prosemirror-dropcursor](https://npm.io/package/prosemirror-dropcursor.md) ^1.3.2
- [prosemirror-inputrules](https://npm.io/package/prosemirror-inputrules.md) ^1.1.2
- [prosemirror-schema-list](https://npm.io/package/prosemirror-schema-list.md) ^1.1.2
- [prosemirror-schema-basic](https://npm.io/package/prosemirror-schema-basic.md) ^1.1.2

## Recent versions

- 1.0.17 (latest) — 2020-11-07
- 1.0.16 — 2020-10-31
- 1.0.15 — 2020-10-31
- 1.0.14 — 2020-10-28
- 1.0.13 — 2020-10-27
- 1.0.12 — 2020-08-24
- 1.0.11 — 2020-05-22
- 1.0.10 — 2020-04-29
- 1.0.9 — 2020-04-22
- 1.0.8 — 2020-04-20
- 1.0.7 — 2020-04-09
- 1.0.6 — 2020-04-08
- 1.0.5 — 2020-04-08
- 1.0.4 — 2020-04-07
- 1.0.3 — 2020-04-07
- … 3 more at https://npm.io/package/simplemirror/versions

## README

# SimpleMirror
![](https://img.shields.io/npm/dw/simplemirror)

A simple and easy to use WYSIWYWG editor based on ProseMirror

## How to use

Integrate into your project

* `dist/SimpleMirror.cjs.js`
    A CommonJS bundle, suitable for use in Node.js, that `require`s the external dependency.
* `dist/SimpleMirror.esm.js`
    an ES module bundle, suitable for use in other people's libraries and applications, that `import`s the external dependency.
* `dist/SimpleMirror.umd.js`
    a UMD build, suitable for use in any environment (including the browser, as a `<script>` tag), that includes the external dependency. 
* `dist/SimpleMirror.css`
    Essential CSS for the editor

Then create a new editor instance. That's it!

Example 1: http://simplemirror.now.sh
```js
new SimpleMirror({
  selector: '#editor',
  value: 'Please change this text',
  onChange: function(value) {
    console.log(value)
  }
})
```

## Configuration
### selector
  The CSS selector where the editor should be inject to
### value
  The content to show in the editor after initialization. It could be plain text or HTML
### onChange
  The callback function to watch if editor's content has been changed
### config
  Defined commands to be used. If ignored, the editor will show all default commands using Fontawesome icons. You can specify CSS classes for the menu items and/or keyboard shortcuts and/or input rules if you want.
- Customizable commands: `["undo", "redo", "bold", "italic", "strikethrough", "h1", "h2", "h3", "h4", "h5", "h6", "orderedList", "unorderedList", "indent", "outdent", "quote", "code", "insertImage"]`.
- Key names may be strings like "Shift-Ctrl-Enter"—a key identifier prefixed with zero or more modifiers. Key identifiers are based on the strings that can appear in [KeyEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key). Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held). You may use "Space" as an alias for the " " name. You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms.
- For `insertImage` command, you can pass an option for cloudinary integration
    ```js
    insertImage: {
      options: {
        cloudinary: {
          cloudName: 'yourCloudName',
          uploadPreset: 'yourUploadPreset', // support unsigned preset only
          googleApiKey: 'yourGoogleAPIKey' // for image search via google
        }
      }
    }
    ```
    otherwise, the editor will prompt for an image URL 

Example 2: http://simplemirror.now.sh/custom.html
```js
new SimpleMirror({
  selector: '#editor',
  value: 'Please change this text',
  config: {
    h1: {
      text: 'H1',
      inputRule: /^#\s/
    },
    bold: {
      className: 'material-icons',
      text: 'format_bold',
      shortcuts: ['Mod-b']
    },
    italic: {
      className: 'material-icons',
      text: 'format_italic',
      shortcuts: ['Mod-i']
    },
    undo: {
      shortcuts: ['Mod-z']
    }
  },
  onChange: function(value) {
    console.log(value)
  }
})
```
## License

[MIT](LICENSE).

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