Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summertime #24

Merged
merged 92 commits into from
Jul 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
ca43198
Introduce cards
mixonic Jun 24, 2015
6dd5a69
Re-use card blocks from a previous render
mixonic Jun 24, 2015
0589f3c
Small formatting cleanup
mixonic Jun 25, 2015
3e57efc
README updates
mixonic Jun 25, 2015
4d6e05f
Build dist
mixonic Jun 25, 2015
0d190f4
Merge pull request #7 from mixonic/cards
mixonic Jun 25, 2015
35f34c8
use broccoli-multi-builder to output amd, globals, cjs
bantic Jun 25, 2015
532c974
use testem for tests
bantic Jun 30, 2015
2613387
use content-kit-compiler 0.3.1
bantic Jun 30, 2015
2e6f550
Merge pull request #9 from bustlelabs/use-broccoli
mixonic Jul 1, 2015
a0c5c56
update to work with broccoli multi builder 0.2.2, bring in loader.js …
bantic Jul 1, 2015
af71d2d
Merge pull request #10 from bustlelabs/use-broccoli-2
bantic Jul 1, 2015
59d103c
Use broccoli-test-builder and fix jshint failures
bantic Jul 2, 2015
39b0735
Merge pull request #11 from bustlelabs/use-test-builder
bantic Jul 2, 2015
3c505d7
update demo, add compat layer for win/doc, compile LESS
bantic Jul 2, 2015
4193766
Merge pull request #12 from bustlelabs/include-demo
mixonic Jul 2, 2015
658321c
Correct JS/CSS links in the demo
mixonic Jul 2, 2015
71f9018
Revert "Correct JS/CSS links in the demo"
bantic Jul 2, 2015
e77c366
parse dom node, not innerHTML
bantic Jul 2, 2015
998c95a
Add new renderer
mixonic Jul 2, 2015
27aed62
Ignore tmp/
mixonic Jul 2, 2015
0a36660
change npm command to broccoli serve
mixonic Jul 2, 2015
e59eaf7
Update editor to parse the DOM to the post AT
mixonic Jul 6, 2015
f1372c5
basic test for pressing a letter in the editor
bantic Jul 6, 2015
89a60bc
Add fixme
mixonic Jul 7, 2015
d062eab
WIP: parse across section edits. TODO: handle deletion
mixonic Jul 7, 2015
0eb62f4
Identify multiple selections and reparse them all
bantic Jul 7, 2015
18ba2a0
Prototype serializer for posts
mixonic Jul 7, 2015
06def74
Test that editor can accept mobiledoc format and render it
bantic Jul 8, 2015
006f74e
add jquery
bantic Jul 6, 2015
43fd3c6
WIP: Start rewriting the demo
mixonic Jul 8, 2015
98075e8
WIP: Add destroy to editor, make mobiledoc observable
mixonic Jul 8, 2015
7bde2c7
minor style cleanup of demo
bantic Jul 8, 2015
8213e30
Use runtime renderer in demo
bantic Jul 8, 2015
a2bbf96
typo fix
bantic Jul 8, 2015
d7705e5
fix jshint failure
bantic Jul 8, 2015
205f169
add npm scripts to build and deploy website
bantic Jul 8, 2015
bb36364
explain how to deploy website in readme
bantic Jul 9, 2015
45ce1f0
Drop compiler dependency
mixonic Jul 9, 2015
ae79783
Merge pull request #14 from mixonic/drop-compiler
bantic Jul 9, 2015
99372ee
built website from bb36364c86f87721b6572f6e8adbe5ff2e8b2ca8
bantic Jul 9, 2015
9bf4ab0
Specify libDirName for testTreeBuilder
bantic Jul 9, 2015
a78b990
Bring in DOMRenderer from external dep mobiledoc-dom-renderer
bantic Jul 9, 2015
6b0c45a
Add more options to the demo, clean up its style and UI
bantic Jul 9, 2015
433947d
built website from 6b0c45a130fd3a96be7ccb8b7e7186c494c7dfed
bantic Jul 9, 2015
1926c95
Only reference runtime in demo
mixonic Jul 9, 2015
d941d4f
Merge pull request #15 from mixonic/ref-mobiledoc
mixonic Jul 9, 2015
d82b625
Add mobiledoc renderer test, fix tests
mixonic Jul 9, 2015
86651c0
Text fixes
mixonic Jul 9, 2015
558499e
display rendered HTML in the demo
bantic Jul 9, 2015
9512f1d
built website from 558499e7b0c5fbc76f554b3265f5a7dfb186d161
bantic Jul 9, 2015
422f987
Removes gulp dependencies
bantic Jul 9, 2015
b7bdb12
document building and deploying
bantic Jul 9, 2015
cd2dd88
Merge pull request #16 from bustlelabs/remove-gulp
mixonic Jul 9, 2015
b1b8bec
mobiledoc documentation
bantic Jul 9, 2015
4a6edfb
Add tests for parsers
mixonic Jul 13, 2015
710664f
add $ and QUnit to jshint globals
bantic Jul 13, 2015
9a10d7a
Test: displaying toolbar, clicking format butons, creating links
bantic Jul 13, 2015
7557d43
skip link test in phantomjs
bantic Jul 13, 2015
6e30ac8
Use phantomjs at travis
bantic Jul 13, 2015
d2f147c
Merge pull request #17 from bustlelabs/editor-commands-tests
mixonic Jul 13, 2015
9d9a530
compatibility fixes for IE10
bantic Jul 13, 2015
f38c3fe
Merge pull request #19 from bustlelabs/ie-10-compat
mixonic Jul 14, 2015
2839ce5
Use custom IE flexbox CSS for demo
bantic Jul 13, 2015
9ef8f59
use EventListener mixin to ensure listeners are destroyed by views
bantic Jul 13, 2015
0c25b1f
Merge pull request #18 from bustlelabs/event-listeners
bantic Jul 14, 2015
3bc230a
remove unused ember-cli-test-loader bower component
bantic Jul 14, 2015
3976fd0
Fix failing test on Firefox due to non-deterministic attr ordering
bantic Jul 14, 2015
ed0410a
Ignore .env for AWS keys
mixonic Jul 14, 2015
6261c7c
Tweak docs to show booting node server
mixonic Jul 14, 2015
67c2e0d
Refactor Image and Card sections to a new renderer
mixonic Jul 13, 2015
82bcea7
Merge pull request #21 from mixonic/image-section
mixonic Jul 15, 2015
055776e
Bump for renderers to support cards
mixonic Jul 15, 2015
6a440dc
sample cards: simple, edit, input
bantic Jul 15, 2015
1e471f8
Add a selfie card to the demo
bantic Jul 15, 2015
dafdee5
Tests for creating/deleting sections
bantic Jul 14, 2015
59610b1
Merge pull request #20 from bustlelabs/editor-section-tests
bantic Jul 16, 2015
1ca3c56
Fix bad import in editor-dom-test
bantic Jul 16, 2015
53cc297
editor 'selection', 'selectionUpdated', and 'selectionEnded' events
bantic Jul 16, 2015
8e47fee
Merge pull request #22 from bustlelabs/selection-event
bantic Jul 16, 2015
27cd46e
Assert that cards are rendered in the editor, and are noneditable
bantic Jul 16, 2015
5b59865
destroy editor in demo before booting a new one
bantic Jul 17, 2015
b757a3b
Add Marker, Section, Section parser
bantic Jul 17, 2015
e6509e4
section has type='section' and tagName property
bantic Jul 17, 2015
f6a7c07
improve test helper's makeDOM
bantic Jul 18, 2015
d83302d
add Post parser
bantic Jul 18, 2015
875d31c
change marker type to "marker", use "tagName" in markup
bantic Jul 19, 2015
63b8fbf
use markup model
bantic Jul 19, 2015
3c9465d
Move Section model to MarkupSection, use across codebase
mixonic Jul 22, 2015
0f69dc1
Post nodes no longer store closed and open, but all their markups
mixonic Jul 22, 2015
aec3812
Allow markers to determine if they closing or opening markup
mixonic Jul 22, 2015
95398a3
Merge pull request #23 from bustlelabs/markers
mixonic Jul 27, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
.env

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
Expand All @@ -33,4 +34,6 @@ bower_components

# Builds
keys.txt
export.sh
export.sh
dist/
tmp/
6 changes: 4 additions & 2 deletions .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
// to your app that hang off `window`.

"predef": [
"define" // amd loader
"define", // amd loader
"$",
"QUnit"
]
}
}
4 changes: 4 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bower_components/
node_modules/
tmp/
tests/
29 changes: 26 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
---
language: node_js
node_js:
- "0.10"
notifications:
email: false
- "0.12"

sudo: false

cache:
directories:
- node_modules

before_install:
# See https://mediocre.com/forum/topics/phantomjs-2-and-travis-ci-we-beat-our-heads-against-a-wall-so-you-dont-have-to
# modified to not use sudo (just puts $PWD on the path so that $PWD/phantomjs is the phantom used
- wget https://s3.amazonaws.com/travis-phantomjs/phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- tar -xjf phantomjs-2.0.0-ubuntu-12.04.tar.bz2
- export PATH=$PWD:$PATH
- "npm config set spin false"
- "npm install -g npm@^2"

install:
- npm install -g broccoli-cli
- npm install -g bower
- bower install
- npm install

script:
- npm test
34 changes: 34 additions & 0 deletions Brocfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* jshint node:true */

var builder = require('broccoli-multi-builder');
var mergeTrees = require('broccoli-merge-trees');
var testTreeBuilder = require('broccoli-test-builder');
var styles = require('./broccoli/styles');
var demo = require('./broccoli/demo');
var jquery = require('./broccoli/jquery');

var vendoredModules = [
{name: 'content-kit-utils', options: {libDirName: 'src'}}
];
var packageName = require('./package.json').name;

var buildOptions = {
libDirName: 'src/js',
vendoredModules: vendoredModules,
packageName: packageName
};

var testTree = testTreeBuilder.build({libDirName: 'src'});
testTree = jquery.build(testTree, '/tests/jquery');
var demoTree = demo();
demoTree = jquery.build(demoTree, '/demo/jquery');

module.exports = mergeTrees([
builder.build('amd', buildOptions),
builder.build('global', buildOptions),
// FIXME Later we may want to bring back the commonjs build
// builder.build('commonjs', buildOptions),
styles(),
demoTree,
testTree
]);
93 changes: 93 additions & 0 deletions MOBILEDOC.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# mobiledoc format

mobiledoc is the output format that content-kit-editor produces.
It aims to be a terse format that is efficiently transferred over the wire
for a client (be it web or native) to render.

## goals for mobiledoc

### efficient to transfer

The mobiledoc format is intended to be simple and fairly terse so that it compresses as well or better than HTML.

### platform-agnostic

mobiledoc is intended to be largely platform-agnostic. Sample use cases:

* A web app downloads an article in mobiledoc format via ajax and uses the mobiledoc-dom-renderer to render and display it
* An Ember app is running server-side via fastboot and needs to generate HTML server-side for SEO purposes. It uses the mobiledoc-html-renderer to turn a mobiledoc article that it retrieves from the API into an HTML string
* A native iOS app downloads an article in mobiledoc format and uses a custom renderer to generate a native view to display the article

In all the above cases, the input is the same: An article in mobiledoc format, provided via an api.

### content-focused

mobiledoc is primarily intended to be used for news-related content such as articles and blog posts. It is deliberately simple, and organizes its content in an array of "sections" that are considered as individual blocks of content.

There is not currently any concept of layout or design built into the format. It is up to the renderer to generate a display appropriate for its context. On mobile this may mean each section is full-width and they are displayed sequentially. On larger displays the sections may be rendered side-by-side. mobiledoc makes no prescription for output display.

### extensible

mobiledoc should be open for extension with custom types (called "cards") that bring their own configuration, and possibly their own renderers. Primary renderers (the dom, html, native, etc renderers) should be able to gracefully handle cards that they cannot natively render.

## format specification

mobiledoc format is an array with two elements: `markerTypes` and `sections`. The marker types describe all of the possible `markups` that may be applied to `markers` within the sectionssection.

#### markupTypes

A `markupType` is an array of 1 or 2 items: `[markerTypes, sections]`. The first item in the array is the type of markup, typically a tagName (such as `"B"`). The markupType can optionally have a second item in its array, which is an array of `attributes` to be applied to it. The attributes are listed as `propName`, `propValue` in the array. Each `nth` item in the array is a propName and each `(n+1)th` item in the array is that propName's propValue.

Example markupTypes:

* Bold tag: `["B"]`
* Anchor tag linking to this repository: `["A", ["href", "http://github.com/bustlelabs/content-kit-editor"]]`
* Anchor tag linking to this repository and with `target="_blank"`: `["A", ["href", "http://github.com/bustlelabs/content-kit-editor", "target", "_blank"]]`

#### sections

A section is an array of three items: `[sectionType, tagName, markers]`. `sectionType` defines the type of block section that this is. The only supported type now is `1`. `tagName` is the name of the block tag to use. H1-H6 and P are possible values. `markers` is an array of the content within that section, separated by the markup that is to be applied to it.

#### markers in sections

A marker is an array of three items: `[openingMarkupTypes, closingMarkupCount, value]`. `openingMarkupTypes` is an array of the indexes of the `markupTypes` to apply to this marker, `closingMarkupCount` is how many markup types are closing at the end of this marker, and `value` is the text value inside the marker.

Assuming these `markerTypes`:
```
markerTypes = [
["B"], // index 0
["I"], // index 1
["A", ["href", "google.com"]], // index 2
]
```

And this section:

```
section = [
1, // type of section
"P", // tagName of section
[ // markers
[
[1], // open marker type of index 1 (italics)
0, // close 0 open markers
'italicized' // the text value
],
[
[0], // open marker type of index 0 (bold)
1, // close 1 markerType (the most-recently opened marker type (bold) will be closed)
'bold + italicized'
],
[
[], // open no marker types
1, // close 1 marker type (in this case, italics)
'only italicized'
],
[
[2], // start the A tag
1, // and close it after this text
'I am a link'
]
]
]
```
139 changes: 122 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,135 @@
# ContentKit-Editor [![Build Status](https://travis-ci.org/bustlelabs/content-kit-editor.svg?branch=master)](https://travis-ci.org/bustlelabs/content-kit-editor)
### A modern, minimalist WYSIWYG editor.
## ContentKit-Editor [![Build Status](https://travis-ci.org/bustlelabs/content-kit-editor.svg?branch=master)](https://travis-ci.org/bustlelabs/content-kit-editor)

*Currently under heavy active development. API subject to change.*
ContentKit is a modern WYSIWYG editor supporting interactive cards. Try a
demo at [http://content-kit.herokuapp.com/](http://content-kit.herokuapp.com/).

## Live Demo
[http://content-kit.herokuapp.com/](http://content-kit.herokuapp.com/)
ContentKit articles (we will use the term article, but any kind of content could
be authored) are built from models. Models represent rows of content, and can
be static or dynamic.

For example, the teardown of an article might look like:
**FIXME** this needs to be updated:

```
┌──────────────────────────────────────────────────────────────────────────────┐
│ ┌──────────┐ │
│ │ Article │ │
│ └──────────┘ │
│┌────────────────────────────────────────────────────────────────────────────┐│
││ ┌──────────────┐ ││
││ │ MarkupModel │ ││
││ └──────────────┘ ││
││ <h2>One Weird Trick</h2> ││
│└────────────────────────────────────────────────────────────────────────────┘│
│┌────────────────────────────────────────────────────────────────────────────┐│
││ ┌──────────────┐ ││
││ │ BlockModel │ ││
││ └──────────────┘ ││
││ <p> ││
││ You will never guess what <i>happens</i> ││
││ when these cats take a <b>bath</b> ││
││ </p> ││
│└────────────────────────────────────────────────────────────────────────────┘│
│┌────────────────────────────────────────────────────────────────────────────┐│
││ ┌──────────────┐ ││
││ │ EmbedModel │ ││
││ └──────────────┘ ││
││ <img src="http://some-cdn.com/uploaded.jpg" /> ││
││ <!-- this HTML is generated by the embed API endpoint at edit-time --> ││
│└────────────────────────────────────────────────────────────────────────────┘│
│┌────────────────────────────────────────────────────────────────────────────┐│
││ ┌────────────────────────┐ ││
││ │ BlockModel (type CARD) │ ││
││ └────────────────────────┘ ││
││ node.innerHTML = 'Cards can change content at render time. For example, ││
││ use an Ember component'; ││
│└────────────────────────────────────────────────────────────────────────────┘│
└──────────────────────────────────────────────────────────────────────────────┘
```

### Usage

ContentKit is attached to a DOM node when the `Editor` factory is instantiated.

```js
var editor = new ContentKit.Editor(this.element, options);
```

`options` is an object which may include the following properties:

* `stickyToolbar` - a boolean option enabling a persistent header with
formatting tools. Default is true for touch devices.
* `placeholder` - default text to show before a user starts typing.
* `spellcheck` - a boolean option enabling spellcheck. Default is true.
* `autofocus` - a boolean option for grabbing input focus when an editor is
rendered.
* `serverHost` - a URL prefix for embed and image API request. **[FIXME Remove]**
* `cards` - an object describing available cards.

### Public Editor API

* `editor.loadPost(post)` - render the editor with a post. **[FIXME Implement]**
* `editor.serializePost()` - serialize the current post for persistence. **[FIXME Implement]**

### Deploy the demo website

The demo website is hosted at github pages.
To publish a new version do:

* `npm run build-website`. This builds the website into `website/` and commits it
* `npm run deploy-website`. Pushes the `website/` subtree to the `gh-pages` branch at github

Visit [http://bustlelabs.github.io/content-kit-editor/demo](http://bustlelabs.github.io/content-kit-editor/demo).

### Contributing

Running ContentKit tests and demo server locally requires the following dependencies:

## Prerequisites
* [node.js](http://nodejs.org/) ([install package](http://nodejs.org/download/)) or `brew install node`
* `broccoli`, via `npm install -g broccoli-cli`

### Tests

Install npm and bower:

* `bower i i`
* `npm i`

Run tests via the built-in broccoli server:

* `npm run serve`
* `open http://localhost:4200/tests`

Or run tests via testem:

* `npm test`

To view the demo:

* `broccoli serve`
* open http://localhost:4200/demo
* (Note that image uploads and embeds are not currently working)

#### To Do

Bring back image uploads and embed. Notes below:

For uploads and embeds to work, you will have to configure AWS and
Embedly keys as environment variables:

## Server Configuration (optional)
For uploads and embeds to work, you will have to configure AWS and Embedly keys as environment variables:
```bash
export AWS_ACCESS_KEY_ID=XXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXX
export EMBEDLY_KEY=XXXXXX
```
Also, set the `bucketName` in `server/config.json` with the name of your AWS S3 bucket for uploading files.

## Playing
1. Install dependencies: `npm install`
2. Build: `gulp build`
3. Start server: `npm start` then visit [http://localhost:5000](http://localhost:5000) || To play without the server, simply open [demo/index.html](demo/index.html)
Also, set the `bucketName` in `server/config.json` with the name of your AWS
S3 bucket for uploading files.

Then to boot the server:

## Testing
`gulp test`
```
node server/index.js
```

## Dev tips
`gulp watch` to auto build/test as you save files
And visit http://localhost:5000/dist/demo/index.html
21 changes: 21 additions & 0 deletions bin/build-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

echo "Building website..."
npm run build

echo "Arranging built website in website/"
rm -rf website
mkdir website

# rename demo/website-index.html to be the base index.html
cp dist/demo/website-index.html website/index.hml

# selectively copy asset dirs from dist to the staging area
cp -R dist/demo website/demo
cp -R dist/css website/css
cp -R dist/global website/global

CURRENT_SHA="$(git rev-parse HEAD)"
git add website/
git commit -m "built website from $CURRENT_SHA"
echo "Done."
3 changes: 3 additions & 0 deletions bin/deploy-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

git push origin `git subtree split --prefix website`:gh-pages --force
19 changes: 19 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "content-kit-editor",
"version": "0.0.0",
"homepage": "https://github.com/bustlelabs/content-kit-editor",
"moduleType": [
"amd",
"es6",
"globals"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {}
}
Loading