Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Introduce Watchdog #2

Merged
merged 52 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
49373ed
Added initial implementation of Watchdog.
ma2ciek Jun 18, 2019
d194458
Added package.json and LICENSE.md files
ma2ciek Jun 18, 2019
37d3cd7
Added missing files.
ma2ciek Jun 18, 2019
8aac285
Aligned readme to readmes in other packages.
ma2ciek Jun 18, 2019
34740c0
Added simple test.
ma2ciek Jun 19, 2019
e7a4551
Added test for restarting the editor.
ma2ciek Jun 19, 2019
faf1c81
Added simple tests for error handling.
ma2ciek Jun 20, 2019
d557600
Added advanced error handling tests.
ma2ciek Jun 21, 2019
333b75c
Added more error handling tests.
ma2ciek Jun 21, 2019
5fb503f
Fixed saved event error name.
ma2ciek Jun 21, 2019
9e38691
Fixed tests destruction, added test for missin context warning.
ma2ciek Jun 21, 2019
1c8cd31
Improved tests, fixed small error in the Watchdog.
ma2ciek Jun 21, 2019
10ccc87
Made CC 100%.
ma2ciek Jun 21, 2019
1076ff7
Fixed lint issues.
ma2ciek Jun 21, 2019
8c64768
Improved restoring component if editor.getData() throws an error.
ma2ciek Jun 21, 2019
fe9e766
Fixed code comment.
ma2ciek Jun 21, 2019
6130639
Fixed test.
ma2ciek Jun 21, 2019
8d7c54d
Simplified tests.
ma2ciek Jun 21, 2019
0d223c4
Fixed `shouldNodeBeSkipped` - added support for symbols and iterable …
ma2ciek Jun 21, 2019
4be82e0
Improved API docs.
ma2ciek Jun 23, 2019
127c96a
Added support for `Watchdog.for()`.
ma2ciek Jun 24, 2019
61463b3
Fixed naming.
ma2ciek Jun 24, 2019
a058a59
Fixed timers in tests.
ma2ciek Jun 24, 2019
db19e62
Fixed naming.
ma2ciek Jun 24, 2019
f1b13f8
Fixed API docs.
ma2ciek Jun 24, 2019
feec3f3
Added support for other Editor signatures. Changed ctx to context.
ma2ciek Jun 24, 2019
c691619
Added manual test.
ma2ciek Jun 24, 2019
a4bb99d
Added missing test.
ma2ciek Jun 24, 2019
4849273
Improved test description.
ma2ciek Jun 24, 2019
2314613
Added support for `null` context. Improved API docs.
ma2ciek Jun 24, 2019
9cad5a3
Moved tree traversing to the util, aligned tests to changes in Classi…
ma2ciek Jun 24, 2019
c4020e7
API docs improvements.
ma2ciek Jun 25, 2019
db3f04d
API docs improvements.
ma2ciek Jun 25, 2019
8688447
Improved API docs.
ma2ciek Jun 25, 2019
2935eff
WIP - docs.
ma2ciek Jun 27, 2019
b6d85e5
Aligned testing CKEditor errors.
ma2ciek Jun 27, 2019
6bf8dfd
Fixed incorrect API usage.
ma2ciek Jul 1, 2019
b598495
Apply suggestions from code review
ma2ciek Jul 1, 2019
ab04623
Added deep copying editor config.
ma2ciek Jul 1, 2019
c32679a
Merge branch 't/1' of github.com:ckeditor/ckeditor5-watchdog into t/1
ma2ciek Jul 1, 2019
6f4c6a7
Swap `restart()` and `create()` methods.
ma2ciek Jul 1, 2019
7c59f27
Improved API docs.
ma2ciek Jul 1, 2019
35e3594
Improved API docs.
ma2ciek Jul 1, 2019
163acd5
Improved description.
ma2ciek Jul 1, 2019
b76e8b2
Added API docs.
ma2ciek Jul 1, 2019
ebe00c1
Fixed 100CC.
ma2ciek Jul 1, 2019
b02b1d1
Small fixes.
Jul 1, 2019
8958425
Update docs.
Jul 1, 2019
0be0b73
Update docs.
Jul 1, 2019
08aaca9
Make `config` parameter optional.
Jul 1, 2019
c1436b8
Fixed API docs.
ma2ciek Jul 2, 2019
deebaa4
Fixed the document version comparison.
ma2ciek Jul 2, 2019
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
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Configurations to normalize the IDE behavior.
# http://editorconfig.org/

root = true

[*]
indent_style = tab
tab_width = 4
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
12 changes: 12 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
*/

/* eslint-env node */

'use strict';

module.exports = {
extends: 'ckeditor5'
};
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* text=auto

*.htaccess eol=lf
*.cgi eol=lf
*.sh eol=lf

*.css text
*.htm text
*.html text
*.js text
*.json text
*.php text
*.txt text
*.md text

*.png -text
*.gif -text
*.jpg -text
9 changes: 9 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### Suggested merge commit message ([convention](https://github.com/ckeditor/ckeditor5-design/wiki/Git-commit-message-convention))

Type: Message. Closes #000.

---

### Additional information

*For example – encountered issues, assumptions you had to make, other affected tickets, etc.*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
28 changes: 28 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
sudo: required
dist: trusty
addons:
chrome: stable
firefox: latest
language: node_js
node_js:
- '8'
cache:
yarn: true
branches:
except:
- stable
before_install:
- export START_TIME=$( date +%s )
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- npm i -g yarn
install:
- yarn add @ckeditor/ckeditor5-dev-tests
- ckeditor5-dev-tests-install-dependencies
script:
- ckeditor5-dev-tests-travis
after_success:
- ckeditor5-dev-tests-save-revision
after_script:
- export END_TIME=$( date +%s )
- ckeditor5-dev-tests-notify-travis-status
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Contributing
========================================

See the [official contributors' guide to CKEditor 5](https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/contributing.html) to learn more.
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Software License Agreement
==========================

**CKEditor 5 watchdog feature** – https://github.com/ckeditor/ckeditor5-watchdog <br>
Copyright (c) 2003-2019, [CKSource](http://cksource.com) Frederico Knabben. All rights reserved.

Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html).

Sources of Intellectual Property Included in CKEditor
-----------------------------------------------------

Where not otherwise indicated, all CKEditor content is authored by CKSource engineers and consists of CKSource-owned intellectual property. In some specific instances, CKEditor will incorporate work done by developers outside of CKSource with their express permission.

The following libraries are included in CKEditor under the [MIT license](https://opensource.org/licenses/MIT):

* Lo-Dash - Copyright (c) JS Foundation and other contributors https://js.foundation/. Based on Underscore.js, copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors http://underscorejs.org/.

Trademarks
----------

**CKEditor** is a trademark of [CKSource](http://cksource.com) Frederico Knabben. All other brand and product names are trademarks, registered trademarks or service marks of their respective holders.
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,21 @@
CKEditor 5 watchdog
CKEditor 5 watchdog feature
========================================

[![Join the chat at https://gitter.im/ckeditor/ckeditor5](https://badges.gitter.im/ckeditor/ckeditor5.svg)](https://gitter.im/ckeditor/ckeditor5?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-watchdog.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-watchdog)
[![Build Status](https://travis-ci.org/ckeditor/ckeditor5-watchdog.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-watchdog)
[![BrowserStack Status](https://automate.browserstack.com/automate/badge.svg?badge_key=d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)](https://automate.browserstack.com/public-build/d3hvenZqQVZERFQ5d09FWXdyT0ozVXhLaVltRFRjTTUyZGpvQWNmWVhUUT0tLUZqNlJ1YWRUd0RvdEVOaEptM1B2Q0E9PQ==--c9d3dee40b9b4471ff3fb516d9ecf8d09292c7e0)
[![Coverage Status](https://coveralls.io/repos/github/ckeditor/ckeditor5-watchdog/badge.svg?branch=master)](https://coveralls.io/github/ckeditor/ckeditor5-watchdog?branch=master)
<br>
[![Dependency Status](https://david-dm.org/ckeditor/ckeditor5-watchdog/status.svg)](https://david-dm.org/ckeditor/ckeditor5-watchdog)
[![devDependency Status](https://david-dm.org/ckeditor/ckeditor5-watchdog/dev-status.svg)](https://david-dm.org/ckeditor/ckeditor5-watchdog?type=dev)

This package implements the watchdog feature for CKEditor 5.

## Documentation

See the [`@ckeditor/ckeditor5-watchdog` package](https://ckeditor.com/docs/ckeditor5/latest/api/watchdog.html) page in [CKEditor 5 documentation](https://ckeditor.com/docs/ckeditor5/latest/).

## License

Licensed under the terms of [GNU General Public License Version 2 or later](http://www.gnu.org/licenses/gpl.html). For full details about the license, please check the `LICENSE.md` file or [https://ckeditor.com/legal/ckeditor-oss-license](https://ckeditor.com/legal/ckeditor-oss-license).
30 changes: 30 additions & 0 deletions docs/api/watchdog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
category: api-reference
---

# CKEditor 5 watchdog feature

[![npm version](https://badge.fury.io/js/%40ckeditor%2Fckeditor5-watchdog.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-watchdog)

This package implements the watchdog feature for CKEditor 5.

## Documentation

See the {@link features/watchdog Watchdog feature} guide and the {@link module:watchdog/watchdog~Watchdog} plugin documentation.

## Installation

```bash
npm install --save @ckeditor/ckeditor5-watchdog
```

## Contribute

The source code of this package is available on GitHub in https://github.com/ckeditor/ckeditor5-watchdog.

## External links

* [`@ckeditor/ckeditor5-watchdog` on npm](https://www.npmjs.com/package/@ckeditor/ckeditor5-watchdog)
* [`ckeditor/ckeditor5-watchdog` on GitHub](https://github.com/ckeditor/ckeditor5-watchdog)
* [Issue tracker](https://github.com/ckeditor/ckeditor5-watchdog/issues)
* [Changelog](https://github.com/ckeditor/ckeditor5-watchdog/blob/master/CHANGELOG.md)
35 changes: 35 additions & 0 deletions docs/features/watchdog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
title: Watchdog
category: features
---

# Watchdog

The {@link module:watchdog/watchdog~Watchdog} feature allows you to create a wrapper for the editor that will ensure that the editor instance is running. If a {@link module:utils/ckeditorerror~CKEditorError `CKEditorError` error} is thrown by the editor, it tries to restart the editor to the state before the crash. All other errors are transparent to the watchdog. By looking at the error context, the Watchdog restarts only the editor which crashed.

**Note**: The watchdog does not handle errors during editor initialization (`Editor.create()`) and editor destruction (`editor.destroy()`). Errors at these stages mean that there is a serious problem in the code integrating the editor and such problem cannot be easily fixed restarting the editor.

**Note**: A new editor instance is created each time the watchdog is restarted. Thus the editor instance should not be kept internally. Use the `watchdog.editor` each time you need to access the editor. It also means that you should not execute any actions on `editor.create` because these actions will not be executed when the editor restarts. Use `watchdog.create` instead, add a plugin and add your code in the `plugin#init`, or listen on `watchdog#restart` to handle restarts.

## Basic implementation

```js
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import Watchdog from '@ckeditor/ckeditor5-watchdog/src/watchdog';

import Essentials from '@ckeditor/ckeditor5-essentials/src/essentials';
import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import Bold from '@ckeditor/ckeditor5-basic-styles/src/bold';
import Italic from '@ckeditor/ckeditor5-basic-styles/src/italic';

const watchdog = Watchdog.for( ClassicEditor );

watchdog.create( document.querySelector( '#editor' ), {
plugins: [ Essentials, Paragraph, Bold, Italic ],
toolbar: [ 'bold', 'italic', 'alignment' ]
} )
.then( () => {
const editor = watchdog.editor;
} );
```
pjasiun marked this conversation as resolved.
Show resolved Hide resolved

56 changes: 56 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@ckeditor/ckeditor5-watchdog",
"version": "0.1.0",
"description": "A watchdog feature for CKEditor 5 editors. It keeps a CKEditor 5 editor instance running",
"keywords": [
"ckeditor",
"ckeditor5",
"ckeditor 5",
"ckeditor5-lib"
],
"dependencies": {
"@ckeditor/ckeditor5-utils": "^12.1.1",
"lodash-es": "^4.17.10"
},
"devDependencies": {
"@ckeditor/ckeditor5-paragraph": "^11.0.2",
"eslint": "^5.5.0",
"eslint-config-ckeditor5": "^1.0.11",
"husky": "^2.4.1",
"lint-staged": "^8.2.1"
},
"engines": {
"node": ">=8.0.0",
"npm": ">=5.7.1"
},
"author": "CKSource (http://cksource.com/)",
"license": "GPL-2.0-or-later",
"homepage": "https://ckeditor.com/ckeditor-5",
"bugs": "https://github.com/ckeditor/ckeditor5-utils/issues",
"repository": {
"type": "git",
"url": "https://github.com/ckeditor/ckeditor5-utils.git"
},
"files": [
"lang",
"src",
"theme"
],
"scripts": {
"lint": "eslint --quiet '**/*.js'"
},
"lint-staged": {
"**/*.js": [
"eslint --quiet"
]
},
"eslintIgnore": [
"src/lib/**",
"packages/**"
],
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
}
}
Loading