Skip to content

Commit

Permalink
Rename ember-content-kit to ember-mobiledoc-editor
Browse files Browse the repository at this point in the history
Additionally become compatible with mobiledoc-kit 0.6.
  • Loading branch information
mixonic committed Nov 10, 2015
1 parent 1395b11 commit dd9935a
Show file tree
Hide file tree
Showing 53 changed files with 332 additions and 326 deletions.
128 changes: 64 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
## ember-content-kit
## ember-mobiledoc-editor

[![Build Status](https://travis-ci.org/bustlelabs/ember-content-kit.svg)](https://travis-ci.org/bustlelabs/ember-content-kit)
[![Build Status](https://travis-ci.org/bustlelabs/ember-mobiledoc-editor.svg)](https://travis-ci.org/bustlelabs/ember-mobiledoc-editor)

An Ember.js addon that can be used to build UIs around the
[Content-Kit](https://github.com/bustlelabs/content-kit-editor) editor.
A Mobiledoc editor written using Ember.js UI components and
[Mobiledoc Kit](https://github.com/bustlelabs/mobiledoc-kit).

Additionally, ember-content-kit supports the creation of
[Mobiledoc cards](https://github.com/bustlelabs/content-kit-editor/blob/master/CARDS.md)
Additionally, ember-mobiledoc-editor supports the creation of
[Mobiledoc cards](https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md)
as Ember components. This is a significant improvement for developer
ergonomics over vanilla JS.
ergonomics over using Mobiledoc cards directly.

### Installation

```
ember install ember-content-kit
ember install ember-mobiledoc-editor
```

`ember-content-kit` will install the `content-kit-editor` packages as a
`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 building an editor
UI.

* [`{{content-kit-editor}}`](#content-kit-editor)
* [`{{content-kit-section-button}}`](#content-kit-section-button)
* [`{{content-kit-markup-button}}`](#content-kit-markup-button)
* [`{{content-kit-link-button}}`](#content-kit-link-button)
* [`{{content-kit-toolbar}}`](#content-kit-toolbar)
* [`{{mobiledoc-editor}}`](#mobiledoc-editor-editor)
* [`{{mobiledoc-section-button}}`](#mobiledoc-section-button)
* [`{{mobiledoc-markup-button}}`](#mobiledoc-markup-button)
* [`{{mobiledoc-link-button}}`](#mobiledoc-link-button)
* [`{{mobiledoc-toolbar}}`](#mobiledoc-toolbar)

#### `{{content-kit-editor}}`
#### `{{mobiledoc-editor}}`

This component is the main entrance point for a content-kit editor instance
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
{{content-kit-editor}}
{{mobiledoc-editor}}
```

Will render a blank Mobiledoc into the following DOM:

```hbs
<article class="content-kit-editor">
<div class="content-kit-editor__editor-wrapper">
<div class="content-kit-editor__editor"></div>
<article class="mobiledoc-editor">
<div class="mobiledoc-editor__editor-wrapper">
<div class="mobiledoc-editor__editor"></div>
</div>
</article>
```

The components accepts these arguments:

* `mobiledoc`, a Mobiledoc for editing by the Content-Kit editor
* `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.
Expand All @@ -65,23 +65,23 @@ The components accepts these arguments:
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 `contentKit` param is yielded.
Called with a block, the `editor` param is yielded.

```hbs
{{#content-kit-editor mobiledoc=someDoc as |contentKit|}}
{{/content-kit-editor}}
{{#mobiledoc-editor mobiledoc=someDoc as |editor|}}
{{/mobiledoc-editor}}
```

`contentKit` has the following properties, useful to inspect the current
`editor` has the following properties, useful to inspect the current
state of the editor:

* `editor`, the Content-Kit editor itself
* `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 `contentKit` provides the following actions:
Additionally `editor` provides the following actions:

* `toggleMarkup`, toggling the passed markup tag name in the current selection.
* `toggleSectionTagName`, toggling the passed section tag name in the current
Expand All @@ -93,118 +93,118 @@ Additionally `contentKit` provides the following actions:
a post and render it in "edit" mode initially.
* `createListSection`, changing selected content into list items.

The `contentKit` object is often used indirectly by passing it to other
The `editor` object is often used indirectly by passing it to other
components. For example:

```hbs
{{#content-kit-editor as |contentKit|}}
{{#mobiledoc-editor as |editor|}}
<div class="toolbar">
{{content-kit-markup-button contentKit=contentKit for="strong"}}
{{content-kit-link-button contentKit=contentKit}}
{{mobiledoc-markup-button editor=editor for="strong"}}
{{mobiledoc-link-button editor=editor}}
</div>
{{/content-kit-editor}}
{{/mobiledoc-editor}}
```

#### `{{content-kit-section-button}}`
#### `{{mobiledoc-section-button}}`

Requires two properties:

* `for`, the name of the tag
* `contentKit`, the `contentKit` instance from `content-kit-editor`
* `editor`, the `editor` instance from `mobiledoc-editor`

Creates a `<button>` element that has a class of `active` when the provided
section tag is used in the current selection. For example:

```hbs
{{content-kit-section-button contentKit=contentKit for="h2"}}
{{mobiledoc-section-button editor=editor for="h2"}}
```

Alternatively, custom text for the HTML of the button can be yielded:

```hbs
{{#content-kit-section-button contentKit=contentKit for="h2"}}
{{#mobiledoc-section-button editor=editor for="h2"}}
Headline 2
{{/content-kit-section-button}}
{{/mobiledoc-section-button}}
```

When clicked, the section tag name will be toggled.

#### `{{content-kit-markup-button}}`
#### `{{mobiledoc-markup-button}}`

Requires two properties:

* `for`, the name of the tag
* `contentKit`, the `contentKit` instance from `content-kit-editor`
* `editor`, the `editor` instance from `mobiledoc-editor`

Creates a `<button>` element that has a class of `active` when the provided
markup tag is used in the current selection. For example:

```hbs
{{content-kit-markup-button contentKit=contentKit for="em"}}
{{mobiledoc-markup-button editor=editor for="em"}}
```

Alternatively, custom text for the HTML of the button can be yielded:

```hbs
{{#content-kit-markup-button contentKit=contentKit for="em"}}
{{#mobiledoc-markup-button editor=editor for="em"}}
Italicize
{{/content-kit-markup-button}}
{{/mobiledoc-markup-button}}
```

When clicked, the markup tag name will be toggled.

#### `{{content-kit-link-button}}`
#### `{{mobiledoc-link-button}}`

Requires one property:

* `contentKit`, the `contentKit` instance from `content-kit-editor`
* `editor`, the `editor` instance from `mobiledoc-editor`

Creates a `<button>` element that has a class of `active` when the an `a`
tag is used in the current selection. For example:

```hbs
{{content-kit-link-button contentKit=contentKit}}
{{mobiledoc-link-button editor=editor}}
```

Custom text for the HTML of the button can be yielded:

```hbs
{{#content-kit-link-button contentKit=contentKit}}
{{#mobiledoc-link-button editor=editor}}
Toggle Link
{{/content-kit-link-button}}
{{/mobiledoc-link-button}}
```

When clicked, the presence of a link will be toggled. The user will be prompted
for a URL if required.

#### `{{content-kit-toolbar}}`
#### `{{mobiledoc-toolbar}}`

Requires one property:

* `contentKit`, the `contentKit` instance from `content-kit-editor`
* `editor`, the `editor` instance from `mobiledoc-editor`

This component creates a full-features toolbar for the Content-Kit editor.
This component creates a full-featured toolbar for the Mobiledoc editor.
For example:

```hbs
{{#content-kit-editor as |contentKit|}}
{{content-kit-toolbar contentKit=contentKit}}
{{/content-kit-editor}}
{{#mobiledoc-editor as |editor|}}
{{mobiledoc-toolbar editor=editor}}
{{/mobiledoc-editor}}
```

### Component-based Cards

Mobiledoc supports "cards", blocks of rich content that are embedded into a
post. For more details on the API for authoring cards in vanilla JavaScript, see
[CARDS.md](https://github.com/bustlelabs/content-kit-editor/blob/master/CARDS.md).
[CARDS.md](https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md).

ember-content-kit comes with a handle helper for using Ember
ember-mobiledoc-editor comes with a handle helper for using Ember
components as the display and edit modes of a card. Create a list of cards
using the `createComponentCard` helper:

```js
import Ember from 'ember';
import createComponentCard from 'ember-content-kit/utils/create-component-card';
import createComponentCard from 'ember-mobiledoc-editor/utils/create-component-card';

export default Ember.Component.extend({
cards: Ember.computed(function() {
Expand All @@ -215,10 +215,10 @@ export default Ember.Component.extend({
});
```

And pass that list into the `{{content-kit-editor}}` component:
And pass that list into the `{{mobiledoc-editor}}` component:

```hbs
{{content-kit-editor cards=cards}}
{{mobiledoc-editor cards=cards}}
```

When added to the post (or loaded from a passed-in Mobiledoc), these components
Expand All @@ -231,15 +231,15 @@ The component will be provided with the following `attrs`:

* `data`, the data payload for this card. *Note* the data is disconnected from the card's payload in the serialized mobiledoc. To update the mobiledoc payload, use the `saveCard` or `mutData` actions.
* `editCard`, an action for toggling this card into edit mode (this action is a no-op if the card is already in edit mode)
* `removeCard`, an action for removing this card (see the ["remove" content-kit card action](https://github.com/bustlelabs/content-kit-editor/blob/master/CARDS.md#available-hooks))
* `removeCard`, an action for removing this card (see the ["remove" Mobiledoc card action](https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md#available-hooks))
* `saveCard`, an action accepting new data for the card payload, then saving
that data and toggling this card into display mode can optionally be passed an extra `false` argument to avoid toggling to display mode (see the ["save content-kit card action](https://github.com/bustlelabs/content-kit-editor/blob/master/CARDS.md#available-hooks))
* `cancelCard`, an action toggling this card to display mode without saving (this action is a no-op if the card is already in display mode) (see the ["cancel content-kit card action](https://github.com/bustlelabs/content-kit-editor/blob/master/CARDS.md#available-hooks))
that data and toggling this card into display mode can optionally be passed an extra `false` argument to avoid toggling to display mode (see the ["save Mobiledoc card action](https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md#available-hooks))
* `cancelCard`, an action toggling this card to display mode without saving (this action is a no-op if the card is already in display mode) (see the ["cancel Mobiledoc card action](https://github.com/bustlelabs/mobiledoc-kit/blob/master/CARDS.md#available-hooks))
* `cardName` the name of this card
* `editor` A reference to the [content-kit-editor](https://github.com/bustlelabs/content-kit-editor)
* `cardSection` A reference to this card's `cardSection` model in the editor's abstract tree. This may be necessary to do programmatic editing (such as moving the card via the `postEditor#moveSection` API that content-kit-editor provides)
* `editor` A reference to the [mobiledoc-kit](https://github.com/bustlelabs/mobiledoc-kit)
* `cardSection` A reference to this card's `cardSection` model in the editor's abstract tree. This may be necessary to do programmatic editing (such as moving the card via the `postEditor#moveSection` API that Mobiledoc editor provides)

### Developing ember-content-kit
### Developing ember-mobiledoc-editor

To get started:

Expand Down
15 changes: 0 additions & 15 deletions addon/components/content-kit-link-button/component.js

This file was deleted.

1 change: 0 additions & 1 deletion addon/components/content-kit-markup-button/template.hbs

This file was deleted.

1 change: 0 additions & 1 deletion addon/components/content-kit-section-button/template.hbs

This file was deleted.

8 changes: 0 additions & 8 deletions addon/components/content-kit-toolbar/component.js

This file was deleted.

74 changes: 0 additions & 74 deletions addon/components/content-kit-toolbar/template.hbs

This file was deleted.

Loading

0 comments on commit dd9935a

Please sign in to comment.