Skip to content
This repository has been archived by the owner on Feb 21, 2019. It is now read-only.

Commit

Permalink
Example state now written in YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
Soreine committed Feb 10, 2017
1 parent c7d02c6 commit 94c29ad
Show file tree
Hide file tree
Showing 6 changed files with 367 additions and 189 deletions.
4 changes: 3 additions & 1 deletion example/main.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const React = require('react');
const ReactDOM = require('react-dom');
const Slate = require('slate');
const yaml = require('yaml-js');

const PluginEditList = require('../lib/');

const stateJson = require('./state');
const stateJson = yaml.load(require('./state.yaml'));

const plugins = [
PluginEditList()
Expand Down
172 changes: 0 additions & 172 deletions example/state.json

This file was deleted.

78 changes: 78 additions & 0 deletions example/state.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
nodes:
- kind: block
type: heading
nodes:
- kind: text
ranges:
- text: Slate + List Edition
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: This page is a basic example of Slate + slate-edit-list plugin. Press
Enter in a list to create a new list item. Press Enter again to exit and Shift+Enter
to create a paragraph in a list.
- kind: block
type: ul_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: First item in the list
- kind: block
type: list_item
nodes:
- kind: block
type: heading
nodes:
- kind: text
ranges:
- text: 'With blocks:'
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: List item can contain blocks
- kind: block
type: list_item
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: Third item in the list, with a nested list
- kind: block
type: ol_list
nodes:
- kind: block
type: list_item
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: First item in the nested list
- kind: block
type: list_item
nodes:
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: Second item in the nested list
- kind: block
type: paragraph
nodes:
- kind: text
ranges:
- text: End paragraph
6 changes: 3 additions & 3 deletions lib/options.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const { Record } = require('immutable');

const DEFAULTS = {
// The type of the lists
// The type of the lists
typeUL: 'ul_list',
// The type of ordered lists
// The type of ordered lists
typeOL: 'ol_list',
// The type of list items
// The type of list items
typeItem: 'list_item',
// The type of default block in items
typeDefault: 'paragraph'
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@
"react": "^15.3.0",
"react-dom": "^15.3.0",
"read-metadata": "^1.0.0",
"slate": "0.16.8"
"slate": "0.16.8",
"stringify": "^5.1.0"
},
"scripts": {
"prepublish": "babel ./lib --out-dir ./dist",
"postpublish": "npm run deploy-example",
"lint": "eslint ./",
"build-example": "browserify ./example/main.js -o ./example/bundle.js -t [ babelify --presets [ es2015 react ] ]",
"build-example": "browserify ./example/main.js -o ./example/bundle.js -t [ babelify --presets [ es2015 react ] ] -t [ stringify --extensions [.yaml] ]",
"serve-example": "http-server ./example/ -p 8081",
"start": "npm run build-example && npm run serve-example",
"deploy-example": "npm run build-example && gh-pages -d ./example",
Expand Down
Loading

0 comments on commit 94c29ad

Please sign in to comment.