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

Prepare ground for v2 #199

Merged
merged 55 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
201c5b7
Init v2 build pipeline
MMMalik Apr 14, 2021
1294667
Init tests
MMMalik Apr 15, 2021
6db6225
Init commit for v2
MMMalik Apr 16, 2021
ab320ec
Fix dependencies
MMMalik Apr 19, 2021
b6217c6
Use karma for unit tests, adjust rollup config
MMMalik Apr 19, 2021
bc7b900
Merge origin/master into t/193
MMMalik Apr 19, 2021
4995b2f
feat(v2)!: Prepare ground for next major version
MMMalik Apr 20, 2021
966123a
feat(v2): refactor approach to e2e testing
MMMalik Apr 21, 2021
5f531c5
fix(v2): move jasmine extension
MMMalik Apr 23, 2021
0e2b953
change: remove module declaration
MMMalik Apr 23, 2021
34072ec
fix(v2): update `bump` script
MMMalik Apr 23, 2021
4a285a9
fix(v2): adjust workflow triggers
MMMalik Apr 27, 2021
07676c6
docs(v2): add details regarding CHROME_BIN
MMMalik Apr 27, 2021
dd79d8c
refactor(v2): get rid of shelljs
MMMalik Apr 27, 2021
5473f63
change(v2): use dummy css class
MMMalik Apr 27, 2021
56c6665
docs(v2): add details to samples paragraph
MMMalik Apr 27, 2021
c5fd821
feat(v2): port logic from v1 to v2, add samples and test cases
MMMalik Apr 26, 2021
feb2ba2
Merge origin/t/193 into t/124
MMMalik Apr 30, 2021
0839381
fix(v2): fix test runners, fix basic-ts for ie11
MMMalik Apr 30, 2021
7b05447
feat(v2): add useCKEditorHook example
MMMalik Apr 30, 2021
cb6af63
feat(v2): add samples, tests, debugging util
MMMalik Apr 30, 2021
a38e355
fix: log typo
MMMalik Apr 30, 2021
23ba1ca
feat(v2): adjust core logic, adjust docs, add tests, add samples
MMMalik May 4, 2021
682d800
refactor(v2): adjust return types of core hook, fix e2e runner, fix e…
MMMalik May 5, 2021
9cb1a92
fix(v2): fix false negative tests
MMMalik May 5, 2021
d26e8f9
fix(v2): increase initial timeout
MMMalik May 5, 2021
e96b74d
fix: reduce number of test cases
MMMalik May 5, 2021
38af869
fix: adjust safari selector
MMMalik May 5, 2021
4a15e53
fix: comment failing selectors
MMMalik May 5, 2021
44f35c0
fix(v2): fix e2e tests
MMMalik May 5, 2021
1902e09
Merge pull request #201 from ckeditor/t/124
MMMalik May 5, 2021
3d9abed
refactor(v2): use different approach to event handling
MMMalik May 10, 2021
cfbcfb4
change(v2): subscribe to selected events, improve docs
MMMalik May 10, 2021
5149a81
Merge origin/master into t/193
MMMalik May 10, 2021
3209f73
fix(v2): add ie11 workaround for e2e test case
MMMalik May 10, 2021
f81dfb1
fix(v2): add polyfills for ie11 e2e/umd, increase server init wait time
MMMalik May 10, 2021
ef71cd6
Add missing space
MMMalik May 14, 2021
4b4c1b8
Update samples/README.md
MMMalik May 14, 2021
c5a6cfc
fix(v2): apply review suggestions
MMMalik May 17, 2021
48d4047
docs(v2): update sample docs
MMMalik May 17, 2021
d152aca
fix(v2): use referentially stable editor config and type
MMMalik May 20, 2021
cdfbe92
fix(v2): use `initData` as child element
MMMalik May 20, 2021
f808cfb
feat(v2): support custom editor events
MMMalik May 21, 2021
0ab7612
feat(v2): adjust samples - config / type re-init, custom events
MMMalik May 21, 2021
4efa968
fix(v2): adjust samples
MMMalik May 24, 2021
7d2c3d7
fix(v2): support TypeScript 3.5 and up
MMMalik May 24, 2021
7208225
fix(v2): fix ssr port
MMMalik May 24, 2021
deb5d7c
test(v2): add test cases
MMMalik May 24, 2021
c363b27
change(v2): use `display:none` to hide initial data
MMMalik May 24, 2021
48e916c
test(v2): fix rendered string
MMMalik May 24, 2021
4209616
fix(v2): add default config value
MMMalik May 31, 2021
9ca105b
fix(v2): use style on root element
MMMalik May 31, 2021
81a25b4
feat(v2): bump editor version
MMMalik May 31, 2021
863ef59
Merge major into t/193
MMMalik Jun 4, 2021
bbc6896
feat: bump ckeditor
MMMalik Jun 4, 2021
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
22 changes: 18 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
{
"parser": "@typescript-eslint/parser",
"extends": [
"eslint-config-ckeditor5",
"plugin:react/recommended"
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended"
],

"settings": {
"react": {
"version": "16.x"
"version": "detect"
}
},

"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": [
"error",
{
"functions": false
}
],
"@typescript-eslint/ban-ts-comment": "off",
"@typescript-eslint/no-var-requires": "off"
},
"env": {
"browser": true
}
Expand Down
61 changes: 41 additions & 20 deletions .github/workflows/test-all.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test browsers
name: Test all

on:
pull_request:
Expand All @@ -15,15 +15,10 @@ on:
- major

jobs:
# Runs tests for selected React versions and all environments
# Top-level React version (as per package-lock.json) will be used for PRs. All versions of React will be tested otherwise.
test-all:
# Runs unit tests for all configured React version
test-units:
runs-on: ubuntu-20.04
name: Run tests
strategy:
matrix:
browser: [BrowserStack_Edge, BrowserStack_Safari, BrowserStack_IE11, Chrome, Firefox, SSR]
fail-fast: false
name: Run unit tests
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -34,27 +29,51 @@ jobs:
node-version: 14

- name: Setup Chrome
if: matrix.browser == 'Chrome'
uses: browser-actions/setup-chrome@latest
with:
chrome-version: stable

- name: Setup Firefox
if: matrix.browser == 'Firefox'
uses: browser-actions/setup-firefox@latest
with:
firefox-version: latest

# Set variables required for further steps.
# CHROME_BIN and FIREFOX_BIN are required by Karma.
# CHROME_BIN is required by Karma.
# REACT_VERSION is set to "current" for pull request events and "all" for other events.
# BUILD_SLUG corresponds to a BrowserStack job name. It's displayed as combination of repo name and short SHA.
- name: Set test variables
run: |
export CHROME_BIN=$(which chrome);
export FIREFOX_BIN=$(which firefox);
if [ -z ${GITHUB_HEAD_REF} ]; then echo "REACT_VERSION=all"; else echo "REACT_VERSION=current"; fi >> $GITHUB_ENV;

- name: Install dependencies
run: npm install

# Run tests with the help of Xvfb, since there is no screen output available (required for locally installed browsers).
- name: Run tests
uses: GabrielBB/xvfb-action@v1
with:
run: npm run test:units -- react ${{ env.REACT_VERSION }}

# Runs E2E tests for all configured React version and all environments
test-e2e:
runs-on: ubuntu-20.04
name: Run E2E tests
strategy:
matrix:
browser: [chrome, firefox, edge, ie, safari]
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup node
uses: actions/setup-node@v2
with:
node-version: 14

# Set variables required for further steps.
# REACT_VERSION is set to "current" for pull request events and "all" for other events.
# BUILD_SLUG is a combination of repo name and short SHA.
- name: Set test variables
run: |
echo "BUILD_SLUG=$(echo $GITHUB_REPOSITORY | cut -d '/' -f2) $(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV;
if [ -z ${GITHUB_HEAD_REF} ]; then echo "REACT_VERSION=last-two"; else echo "REACT_VERSION=current"; fi >> $GITHUB_ENV;

- name: Install dependencies
run: npm install
Expand All @@ -65,5 +84,7 @@ jobs:
env:
BROWSER_STACK_USERNAME: ${{ secrets.BROWSER_STACK_USERNAME }}
BROWSER_STACK_ACCESS_KEY: ${{ secrets.BROWSER_STACK_ACCESS_KEY }}
BROWSER_STACK_BUILD_NAME: ${{ env.BUILD_SLUG }}
BROWSER_STACK_BROWSER: ${{ matrix.browser }}
with:
run: npm run test:react-tester -- --react ${{ env.REACT_VERSION }} --browser ${{ matrix.browser }}
run: npm run test:e2e -- --react ${{ env.REACT_VERSION }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ node_modules/
coverage/
.DS_Store
dist/
sample/dist/
samples-out
react-tests/
*debug.log
.vscode
local.log
public
.tmp*
95 changes: 95 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Contributing

### Install dependencies

After cloning this repository, install necessary dependencies:

```
npm install
```

### Development

```
npm run develop
```

After running this command unit tests will start in watch mode and you are ready to develop. Please note that source code will be transpiled with `babel` so there is no type checking with TypeScript for this command. In order to validate types with TS run `npm run types:check` or run a full build (see below).

By default Karma will run tests on Chrome so make sure that its binary is available on your system. If you have Chrome installed but Karma cannot find its binary for some reason, you might need to set `CHROME_BIN` environment variable, e.g. in your `.bashrc` file: `export CHROME_BIN=path_to_chrome_bin`.

### Build

#### Watch mode

Run the following command in order to start builds in watch mode:

```
npm start
```

This command emits bundles in following formats: `umd`, `esm`, `cjs`. Type declarations are not be emitted.

#### Run build once

Run `npm run build` command to run build once. TypeScript declarations are emitted.

### Tests

#### Quick feedback

As noted above, run `npm run develop` to quickly run a full suite of unit tests on currently installed React version.

To run more a complete test script, just run the following command:

```
npm test
```

This command makes a single run of linter, type checker and unit tests.

#### Full suite of unit tests

In order to run unit tests on all supported React versions:

```
npm run test:units:all
```

#### Full suite of E2E tests

E2E tests are to ensure that library _build files_ can be used with minimal setup on the consumer end and that they work on all supported browsers. E2E tests will run on examples inside `samples` directory. Tests will be run for each supported React version.

All tests will run on BrowserStack, so make sure that environment variables `BROWSER_STACK_USERNAME` and `BROWSER_STACK_ACCESS_KEY` are set beforehand (values must be kept secret). In addition set `BROWSER_STACK_BROWSER` variable to one of the following values: `chrome`, `safari`, `ie`, `firefox`, `edge`.

E2E tests are meant to run in CI environment but it's possible to run them locally as well. For example:

```
BROWSER_STACK_USERNAME=name BROWSER_STACK_ACCESS_KEY=key BROWSER_STACK_BROWSER=safari npm run test:e2e:all
```

Or for a single sample:

```
BROWSER_STACK_USERNAME=name BROWSER_STACK_ACCESS_KEY=key BROWSER_STACK_BROWSER=safari npm run test:e2e:all -- --sample basic
```

### Samples

Before running any sample locally, make sure to expose root package as a link and build the library:

```
npm link && npm run build
```

It's enough to `npm link` the root package once. Run build on every change in root `src` folder.

Example apps are located in `samples` directory. Each sample is a self-contained application that has mandatory `start` and `build` scripts. In order to run a sample go thorugh the following steps:

1. `cd` into sample, e.g. `cd samples/basic`
2. Run `npm install`
3. Link root package: `npm link ckeditor4-react`
4. Start example: `npm start`
5. Navigate to `localhost:8080`

It's important to re-run `npm link ckeditor4-react` in a sample folder anytime `npm install` operation was performed in that sample!
3 changes: 3 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ The following libraries are included in CKEditor 4 WYSIWYG editor component for
- load-script
- prop-types (c) 2013-present, Facebook, Inc.

The following libraries are included in CKEditor 4 WYSIWYG editor component for React under the [0BSD license](https://opensource.org/licenses/0BSD):
- tslib (c) Microsoft Corporation

Trademarks
----------

Expand Down
38 changes: 3 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,47 +30,15 @@ See the [CKEditor 4 WYSIWYG Editor React Integration](https://ckeditor.com/docs/

You can also check out [CKEditor 4 WYSIWYG Editor React Integration example](https://ckeditor.com/docs/ckeditor4/latest/examples/react.html) in [CKEditor 4 Examples](https://ckeditor.com/docs/ckeditor4/latest/examples/).

See ready-to-fork examples in `samples` directory. Each sample is a self-contained app that can be [easily forked](https://docs.github.com/en/github/getting-started-with-github/splitting-a-subfolder-out-into-a-new-repository) within GitHub. Also, you can fork examples via services such as [CodeSandbox](https://codesandbox.io/).

## Browser support

The CKEditor 4 React component works with all the [supported browsers](https://ckeditor.com/docs/ckeditor4/latest/guide/dev_browsers.html#officially-supported-browsers) except for Internet Explorer 8-10.

## Contributing

After cloning this repository, install necessary dependencies:

```
npm install
```

### Executing tests

```
npm run test
```

The command above should be used to get a quick feedback on passing / failing tests. By default, tests on Chrome will be launched with locally installed version of React.

Run `npm run test:all` to run tests on all supported versions of React. By default, test suite runs on Chrome but `browser` argument can be passed, e.g. `npm run test:all -- --browser Firefox`. See `scripts/react-tester.js` for details.

If you are going to change the source files (ones located in the `src/` directory), remember about rebuilding the package. You can use `npm run develop` in order to do it automatically.

### Running samples

Samples uses development built version to simplify component testing. Run below command to open sample page in your default system browser:

```
npm run samples
```

Any component changes will be automatically rebuild.

### Building the package

Build a minified version of the package that is ready to publish:

```
npm run build
```
See [CONTRIBUTING.md](CONTRIBUTING.md).

## License

Expand Down
Loading