diff --git a/.babelrc b/.babelrc index 04d0ec0b3..3c45d7307 100644 --- a/.babelrc +++ b/.babelrc @@ -1,7 +1,7 @@ { "presets": [ - "react", "es2015", + "react", "stage-0" ] } diff --git a/.eslintrc b/.eslintrc index 51500e589..864afbfef 100644 --- a/.eslintrc +++ b/.eslintrc @@ -39,7 +39,7 @@ "import/namespace": "error", "import/newline-after-import": "error", "import/no-deprecated": "error", - "import/no-extraneous-dependencies": "error", + "import/no-extraneous-dependencies": ["error", { "peerDependencies": true }], "import/no-mutable-exports": "error", "import/no-named-as-default": "error", "import/no-named-as-default-member": "error", diff --git a/.gitignore b/.gitignore index b6af211e9..0a37c292f 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,11 @@ tmp _book # Package files. +lerna-debug.log node_modules npm-debug.log yarn-error.log +packages/*/yarn.lock # OS files. .DS_Store diff --git a/.npmignore b/.npmignore index 55428cfb4..dbbb39dfc 100644 --- a/.npmignore +++ b/.npmignore @@ -1,7 +1,7 @@ +.babelrc benchmark docs examples src test tmp -.babelrc diff --git a/.travis.yml b/.travis.yml index 3dc4d816d..4d5e44cb7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,28 @@ + language: node_js -env: - matrix: - - TEST_TYPE=test - - TEST_TYPE=lint -script: - - | - if [ "$TEST_TYPE" = test ]; then - npm run test - elif [ "$TEST_TYPE" = lint ]; then - npm run lint - fi -# Slate is compiled with babel and run in the browser -node_js: - - "node" -# Compiling package microtime requires C++11 compiler. Benchmarks will -# automatically use microtime if installed. -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-4.8 +node_js: [node] + before_install: + # Download and export yarn. + - curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.0.1 + - export PATH=$HOME/.yarn/bin:$PATH + # Export the C++11 compiler. - if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi + +cache: + # Cache yarn packages. + yarn: true + +env: + # Do two runs, one for testing and one for linting. + matrix: + - TEST_TYPE=test + - TEST_TYPE=lint + +script: + # Run bootstrap first so that the proper workspaces links are created. + - yarn run bootstrap + # Build all of the packages so they are resolvable by each other. + - yarn run build + # Run testing or linting depending on the environment. + - yarn run $TEST_TYPE diff --git a/Changelog.md b/Changelog.md index 238d854ef..025990b9b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ This document maintains a list of changes to Slate with each new version. Until --- + ### `0.23.0` — September 10, 2017 ###### BREAKING diff --git a/Contributing.md b/Contributing.md index 078faa221..53e7e8f26 100644 --- a/Contributing.md +++ b/Contributing.md @@ -6,8 +6,9 @@ Want to contribute to Slate? That would be awesome! - [Reporting Bugs](#reporting-bugs) - [Asking Questions](#asking-questions) - [Submitting Pull Requests](#submitting-pull-requests) -- [Running Tests](#running-tests) - [Running Examples](#running-examples) +- [Running Tests](#running-tests) +- [Running Benchmarks](#running-benchmarks) - [Adding Browser Support](#adding-browser-support) - [Testing Input Methods](#testing-input-methods) @@ -43,34 +44,58 @@ All pull requests are super welcomed and greatly appreciated! Easy issues are ma Please include tests and docs with every pull request! -## Running Tests - -To run the examples, you need to have the Slate repository cloned to your computer. After that, you need to `cd` into the directory where you cloned it, and install the dependencies from `npm`. - -``` -npm install -``` - -Which will also compile the source files. Then run the tests with: - -``` -npm run tests -``` - -If you need to debug something, you can add a `debugger` line to the source, and then run `npm run tests debug`. Or, if you only want to run a specific test or tests, you can run `npm run tests -- --fgrep "match this string"` flag which will filter the tests being run. - -To keep the source rebuilding on every file change, you need to run an additional watching command: - -``` -npm run watch -``` - - ## Running Examples Check out the [Examples readme](./examples) to see how to get the examples running locally! +## Running Tests + +To run the tests, you need to have the Slate repository cloned to your computer. After that, you need to `cd` into the directory where you cloned it, and install the dependencies with `yarn` and bootstrap the monorepo: + +``` +yarn install +yarn run bootstrap +``` + +Then run the tests with: + +``` +yarn run test +``` + +To keep the source rebuilding on every file change, you need to run an additional watching command in a separate process: + +``` +yarn run watch +``` + +If you need to debug something, you can add a `debugger` line to the source, and then run `yarn run test debug`. + +If you only want to run a specific test or tests, you can run `yarn run test --fgrep="slate-react rendering"` flag which will filter the tests being run by grepping for the string in each test. + + +## Running Benchmarks + +To run the benchmarks, first make some changes to the source that you want to benchmark. Now that you're ready, you need to save a "baseline" for what the performance was before you made you change. + +To do that, stash your changes and save the benchmarks: + +``` +git stash +yarn run benchmark:save +``` + +Then once the reference has been saved, unstash your changes and run the benchmarks to see a comparison: + +``` +git stash pop +yarn run benchmark +``` + +There will be some subtle changes in iteration speed always, but the comparison reporter will highlight any changes that seem meaningful. You can run `benchmark` multiple times to ensure the speed up persists. + + ## Adding Browser Support Slate aims to targeted all of the modern browsers, and eventually the modern mobile platforms. Right now browser support is limited to the latest versions of [Chrome](https://www.google.com/chrome/browser/desktop/), [Firefox](https://www.mozilla.org/en-US/firefox/new/), and [Safari](http://www.apple.com/safari/), but if you are interested in adding support for another modern platform, that is welcomed! @@ -80,6 +105,7 @@ Slate aims to targeted all of the modern browsers, and eventually the modern mob [Here's a helpful page](https://github.com/Microsoft/vscode/wiki/IME-Test) detailing how to test various input scenarios on Windows, Mac and Linux. + ## Debugging Slate methods Slate makes use of [debug](https://github.com/visionmedia/debug) to log information about various methods. You can [enable the logger in the browser](https://github.com/visionmedia/debug#browser-support) by setting `localStorage.debug = "*"` (to log methods on all modules) or to a single namespace (e.g. `slate:editor`). Look for `const debug = Debug('')` to get the namespace of various modules. diff --git a/License.md b/License.md index dee82d0ff..c0734d1b1 100644 --- a/License.md +++ b/License.md @@ -3,7 +3,7 @@ The MIT License -Copyright © 2016, [Ian Storm Taylor](https://ianstormtaylor.com) +Copyright © 2016–2017, [Ian Storm Taylor](https://ianstormtaylor.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: diff --git a/benchmark/fixtures/models/get-blocks-at-range/index.js b/benchmark/fixtures/models/get-blocks-at-range/index.js deleted file mode 100644 index bb9a37bb7..000000000 --- a/benchmark/fixtures/models/get-blocks-at-range/index.js +++ /dev/null @@ -1,17 +0,0 @@ - -import { __clear } from '../../../../lib/utils/memoize' - -export default function ({ state, range }) { - state.document.getBlocksAtRange(range) -} - -export function before(state) { - return { - state, - range: state.selection.moveToRangeOf(state.document), - } -} - -export function after() { - __clear() -} diff --git a/benchmark/fixtures/models/get-blocks-at-range/input.yaml b/benchmark/fixtures/models/get-blocks-at-range/input.yaml deleted file mode 100644 index b510137eb..000000000 --- a/benchmark/fixtures/models/get-blocks-at-range/input.yaml +++ /dev/null @@ -1,683 +0,0 @@ -nodes: -- kind: block - type: paragraph - nodes: - - kind: block - type: paragraph - nodes: - - kind: block - type: paragraph - nodes: - - kind: text - ranges: - - text: 'This is editable ' - - text: 'rich' - marks: - - type: bold - - text: ' text, ' - - kind: block - type: paragraph - nodes: - - kind: text - ranges: - - text: 'much' - marks: - - type: italic - - text: ' better than a ' - - text: '