# ember-mobiledoc-editor
**Repository Path**: mirrors_ashleysommer/ember-mobiledoc-editor
## Basic Information
- **Project Name**: ember-mobiledoc-editor
- **Description**: No description available
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2021-10-22
- **Last Updated**: 2026-05-17
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
## ember-mobiledoc-editor
[](https://badge.fury.io/js/ember-mobiledoc-editor)
[](https://travis-ci.org/bustle/ember-mobiledoc-editor)
[](https://emberobserver.com/addons/ember-mobiledoc-editor)
A Mobiledoc editor written using Ember.js UI components and
[Mobiledoc Kit](https://github.com/bustle/mobiledoc-kit).
Additionally, ember-mobiledoc-editor supports the creation of
[Mobiledoc cards](https://github.com/bustle/mobiledoc-kit/blob/master/CARDS.md)
as Ember components. This is a significant improvement for developer
ergonomics over using Mobiledoc cards directly.
### Installation
```
ember install ember-mobiledoc-editor
```
`ember-mobiledoc-editor` will install the `mobiledoc-kit` package as a
dependency and load its assets.
### Usage
This addon is primarily composed of components used for building an editor
UI.
* [`{{mobiledoc-editor}}`](#mobiledoc-editor)
* [`{{mobiledoc-section-button}}`](#mobiledoc-section-button)
* [`{{mobiledoc-markup-button}}`](#mobiledoc-markup-button)
* [`{{mobiledoc-link-button}}`](#mobiledoc-link-button)
* [`{{mobiledoc-toolbar}}`](#mobiledoc-toolbar)
#### `{{mobiledoc-editor}}`
This component is the main entrance point for a mobiledoc editor instance
in your Ember app. Used in the most basic form it will render a dummy editor
with no toolbar. For example this usage:
```hbs
{{mobiledoc-editor}}
```
Will render a blank Mobiledoc into the following DOM:
```hbs
```
The component accepts these arguments:
* `mobiledoc`, a Mobiledoc to be edited
* `cards`, an array of available cards for use by the editor. Jump to
the section on [Component-based cards](#component-based-cards) for more detail on how
to use cards with Ember components.
* `atoms`, an array of available atoms for use by the editor. Jump to
the section on [Component-based atoms](#component-based-atoms) for more detail on how
to use atoms with Ember components.
* `spellcheck` boolean
* `autofocus` boolean
* `showLinkTooltips` boolean
* `placeholder` string -- the placeholder text to display when the mobiledoc is blank
* `options` hash -- any properties in the `options` hash will be passed to the MobiledocKitEditor constructor
* `serializeVersion` string -- The mobiledoc version to serialize to when firing the on-change action. Default: 0.3.2
* `sectionAttributesConfig` hash -- information about supported section attributes. defaults to `{ 'text-align': { values: ['left', 'center', 'right'], defaultValue: 'left' } }`
* `on-change` -- Accepts an action that the component will send every time the mobiledoc is updated
* `will-create-editor` -- Accepts an action that will be sent when the instance of the MobiledocKitEditor is about to be created
This action may be fired more than once if the component's `mobiledoc` property is set to a new value.
* `did-create-editor` -- Accepts an action that will be sent after the instance of the MobiledocKitEditor is created.
The action is passed the created editor instance.
This action may be fired more than once if the component's `mobiledoc` property is set to a new value.
For example, the following index route and template would log before and
after creating the MobiledocKitEditor, and every time the user modified the
mobiledoc (by typing some text, e.g.).
```javascript
// routes/index.js
export default Ember.Route.extend({
...,
actions: {
mobiledocWasUpdated(updatedMobiledoc) {
console.log('New mobiledoc:',updatedMobiledoc);
// note that this action will be fired for every changed character,
// so you may want to debounce API calls if you are using it for
// an "autosave" feature.
},
willCreateEditor() {
console.log('about to create the editor');
},
didCreateEditor(editor) {
console.log('created the editor:', editor);
}
}
});
```
```hbs
{{! index.hbs }}
{{mobiledoc-editor
on-change=(action 'mobiledocWasUpdated')
will-create-editor=(action 'willCreateEditor')
did-create-editor=(action 'didCreateEditor')
}}
```
Of course often you want to provide a user interface to bold text, create
headlines, or otherwise reflect the state of the editor.
Called with a block, the `editor` param is yielded.
```hbs
{{#mobiledoc-editor mobiledoc=someDoc as |editor|}}
{{/mobiledoc-editor}}
```
`editor` has the following properties, useful to inspect the current
state of the editor:
* `editor`, the Mobiledoc kit editor instance itself
* `activeSectionTagNames`, an object with true values for section tag names
in the current selection. For example `activeSectionTagNames.isH1`.
* `activeMarkupTagNames`, an object with true values for markup tag names in
the current selection. For example `activeMarkupTagNames.isStrong`
Additionally `editor` provides the following actions:
* `toggleMarkup`, toggling the passed markup tag name in the current selection.
* `toggleSection`, toggling the passed section tag name in the current
selection. Pass a string tagName as an argument. Possible valid values: "h1", "h2",
"p", "blockquote". To toggle to-from a list section pass "ul" or "ol".
* `toggleLink`, toggling the linking of a selection. The user will be prompted
for a URL if required.
* `addCard`, passed a card name and payload will add that card at the end of the post.
* `addCardInEditMode`, passed a card name and payload will add that card at the end of
a post and render it in "edit" mode initially.
* `addAtom`, passed an atomName, text, and payload, will add that atom at the cursor position.
* `setAttribute`, passed an attribute name and attribute value, will add that attribute to the current section, or remove the attribute if the value is the default value.
* `removeAttribute`, passed an attribute name, will remove that attribute from the current section.
The `editor` object is often used indirectly by passing it to other
components. For example:
```hbs
{{#mobiledoc-editor as |editor|}}
{{/mobiledoc-editor}}
```
#### `{{mobiledoc-section-button}}`
Requires two properties:
* `for`, the name of the tag
* `editor`, the `editor` instance from `mobiledoc-editor`
And accepts one optional property:
* `title`, added as the `title` attribute on the `button` element
Creates a `