@ckeditor/ckeditor5-enter
Advanced tools
Comparing version 0.9.1 to 0.10.0
Changelog | ||
========= | ||
## [0.10.0](https://github.com/ckeditor/ckeditor5-enter/compare/v0.9.1...v0.10.0) (2017-09-03) | ||
### Features | ||
* The viewport will be scrolled to the selection when <kbd>Enter</kbd> is pressed. See ckeditor/ckeditor5-engine#660. ([17f815e](https://github.com/ckeditor/ckeditor5-enter/commit/17f815e)) | ||
### Other changes | ||
* Aligned the implementation to the new Command API (see https://github.com/ckeditor/ckeditor5-core/issues/88). ([d75b448](https://github.com/ckeditor/ckeditor5-enter/commit/d75b448)) | ||
### BREAKING CHANGES | ||
* The command API has been changed. | ||
## [0.9.1](https://github.com/ckeditor/ckeditor5-enter/compare/v0.9.0...v0.9.1) (2017-05-07) | ||
@@ -5,0 +20,0 @@ |
@@ -6,3 +6,3 @@ /** | ||
/* jshint browser: false, node: true, strict: true */ | ||
/* eslint-env node */ | ||
@@ -12,3 +12,4 @@ 'use strict'; | ||
const gulp = require( 'gulp' ); | ||
const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' )( { | ||
const ckeditor5Lint = require( '@ckeditor/ckeditor5-dev-lint' ); | ||
const options = { | ||
// Files ignored by `gulp lint` task. | ||
@@ -19,6 +20,6 @@ // Files from .gitignore will be added automatically during task execution. | ||
] | ||
} ); | ||
}; | ||
gulp.task( 'lint', ckeditor5Lint.lint ); | ||
gulp.task( 'lint-staged', ckeditor5Lint.lintStaged ); | ||
gulp.task( 'lint', () => ckeditor5Lint.lint( options ) ); | ||
gulp.task( 'lint-staged', () => ckeditor5Lint.lintStaged( options ) ); | ||
gulp.task( 'pre-commit', [ 'lint-staged' ] ); |
{ | ||
"name": "@ckeditor/ckeditor5-enter", | ||
"version": "0.9.1", | ||
"version": "0.10.0", | ||
"description": "Enter feature for CKEditor 5.", | ||
"keywords": [], | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^0.8.1", | ||
"@ckeditor/ckeditor5-engine": "^0.10.0", | ||
"@ckeditor/ckeditor5-utils": "^0.9.1" | ||
"@ckeditor/ckeditor5-core": "^0.9.0", | ||
"@ckeditor/ckeditor5-engine": "^0.11.0", | ||
"@ckeditor/ckeditor5-utils": "^0.10.0" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-dev-lint": "^2.0.2", | ||
"@ckeditor/ckeditor5-basic-styles": "^0.8.1", | ||
"@ckeditor/ckeditor5-editor-classic": "^0.7.3", | ||
"@ckeditor/ckeditor5-heading": "^0.9.1", | ||
"@ckeditor/ckeditor5-typing": "^0.9.1", | ||
"@ckeditor/ckeditor5-undo": "^0.8.1", | ||
"gulp": "^3.9.0", | ||
"@ckeditor/ckeditor5-dev-lint": "^3.1.0", | ||
"@ckeditor/ckeditor5-basic-styles": "^0.9.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^0.8.0", | ||
"@ckeditor/ckeditor5-heading": "^0.10.0", | ||
"@ckeditor/ckeditor5-typing": "^0.10.0", | ||
"@ckeditor/ckeditor5-undo": "^0.9.0", | ||
"eslint-config-ckeditor5": "^1.0.5", | ||
"gulp": "^3.9.1", | ||
"guppy-pre-commit": "^0.4.0" | ||
@@ -20,0 +21,0 @@ }, |
@@ -1,4 +0,5 @@ | ||
CKEditor 5 Enter Feature | ||
CKEditor 5 enter 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-enter.svg)](https://www.npmjs.com/package/@ckeditor/ckeditor5-enter) | ||
@@ -5,0 +6,0 @@ [![Build Status](https://travis-ci.org/ckeditor/ckeditor5-enter.svg?branch=master)](https://travis-ci.org/ckeditor/ckeditor5-enter) |
@@ -24,3 +24,3 @@ /** | ||
static get pluginName() { | ||
return 'enter/enter'; | ||
return 'Enter'; | ||
} | ||
@@ -34,3 +34,3 @@ | ||
editor.commands.set( 'enter', new EnterCommand( editor ) ); | ||
editor.commands.add( 'enter', new EnterCommand( editor ) ); | ||
@@ -41,4 +41,5 @@ // TODO We may use the keystroke handler for that. | ||
data.preventDefault(); | ||
editingView.scrollToTheSelection(); | ||
}, { priority: 'low' } ); | ||
} | ||
} |
@@ -10,3 +10,3 @@ /** | ||
import Command from '@ckeditor/ckeditor5-core/src/command/command'; | ||
import Command from '@ckeditor/ckeditor5-core/src/command'; | ||
import Position from '@ckeditor/ckeditor5-engine/src/model/position'; | ||
@@ -17,3 +17,3 @@ | ||
* | ||
* @extends modue:core/command/command~Command | ||
* @extends module:core/command~Command | ||
*/ | ||
@@ -24,3 +24,3 @@ export default class EnterCommand extends Command { | ||
*/ | ||
_doExecute() { | ||
execute() { | ||
const doc = this.editor.document; | ||
@@ -49,10 +49,9 @@ const batch = doc.batch(); | ||
// Do nothing if selection starts or ends inside `limit` elements. | ||
// Don't touch the roots and other limit elements. | ||
if ( schema.limits.has( startElement.name ) || schema.limits.has( endElement.name ) ) { | ||
return; | ||
} | ||
// Don't touch the root. | ||
if ( startElement.root == startElement ) { | ||
if ( !isSelectionEmpty ) { | ||
// Delete the selected content but only if inside a single limit element. | ||
// Abort, when crossing limit elements boundary (e.g. <limit1>x[x</limit1>donttouchme<limit2>y]y</limit2>). | ||
// This is an edge case and it's hard to tell what should actually happen because such a selection | ||
// is not entirely valid. | ||
if ( !isSelectionEmpty && startElement == endElement ) { | ||
dataController.deleteContent( selection, batch ); | ||
@@ -67,8 +66,8 @@ } | ||
} else { | ||
const shouldMerge = range.start.isAtStart && range.end.isAtEnd; | ||
const leaveUnmerged = !( range.start.isAtStart && range.end.isAtEnd ); | ||
const isContainedWithinOneElement = ( startElement == endElement ); | ||
dataController.deleteContent( selection, batch, { merge: shouldMerge } ); | ||
dataController.deleteContent( selection, batch, { leaveUnmerged } ); | ||
if ( !shouldMerge ) { | ||
if ( leaveUnmerged ) { | ||
// Partially selected elements. | ||
@@ -84,3 +83,3 @@ // | ||
else { | ||
selection.collapse( endElement ); | ||
selection.setCollapsedAt( endElement ); | ||
} | ||
@@ -104,3 +103,3 @@ } | ||
selection.collapse( splitPos.parent.nextSibling ); | ||
selection.setCollapsedAt( splitPos.parent.nextSibling ); | ||
} |
@@ -15,3 +15,4 @@ /** | ||
beforeEach( () => { | ||
return VirtualTestEditor.create( { | ||
return VirtualTestEditor | ||
.create( { | ||
plugins: [ Enter ] | ||
@@ -42,2 +43,14 @@ } ) | ||
it( 'scrolls the editing document to the selection after executing the command', () => { | ||
const view = editor.editing.view; | ||
const domEvt = getDomEvent(); | ||
const executeSpy = editor.execute = sinon.spy(); | ||
const scrollSpy = sinon.stub( view, 'scrollToTheSelection' ); | ||
view.fire( 'enter', new DomEventData( editingView, domEvt ) ); | ||
sinon.assert.calledOnce( scrollSpy ); | ||
sinon.assert.callOrder( executeSpy, scrollSpy ); | ||
} ); | ||
function getDomEvent() { | ||
@@ -44,0 +57,0 @@ return { |
@@ -20,3 +20,3 @@ /** | ||
command = new EnterCommand( editor ); | ||
editor.commands.set( 'enter', command ); | ||
editor.commands.add( 'enter', command ); | ||
@@ -48,12 +48,16 @@ schema = doc.schema; | ||
const spy = sinon.spy( doc, 'enqueueChanges' ); | ||
doc.enqueueChanges( () => { | ||
editor.execute( 'enter' ); | ||
editor.execute( 'enter' ); | ||
// We expect that command is executed in enqueue changes block. Since we are already in | ||
// an enqueued block, the command execution will be postponed. Hence, no changes. | ||
expect( getData( doc, { withoutSelection: true } ) ).to.equal( '<p>foo</p>' ); | ||
} ); | ||
// After all enqueued changes are done, the command execution is reflected. | ||
expect( getData( doc, { withoutSelection: true } ) ).to.equal( '<p>foo</p><p></p>' ); | ||
expect( spy.calledOnce ).to.be.true; | ||
} ); | ||
} ); | ||
describe( '_doExecute', () => { | ||
describe( 'execute()', () => { | ||
describe( 'collapsed selection', () => { | ||
@@ -131,3 +135,3 @@ test( | ||
'<p><inlineLimit>foo[bar]baz</inlineLimit></p>', | ||
'<p><inlineLimit>foo[bar]baz</inlineLimit></p>' | ||
'<p><inlineLimit>foo[]baz</inlineLimit></p>' | ||
); | ||
@@ -152,3 +156,3 @@ | ||
command._doExecute(); | ||
command.execute(); | ||
@@ -165,3 +169,3 @@ expect( getData( doc ) ).to.equal( '<p>[]</p>' ); | ||
command._doExecute(); | ||
command.execute(); | ||
@@ -176,3 +180,3 @@ expect( spy.calledOnce ).to.be.true; | ||
command._doExecute(); | ||
command.execute(); | ||
@@ -179,0 +183,0 @@ expect( getData( doc ) ).to.equal( output ); |
@@ -14,7 +14,7 @@ /** | ||
describe( 'EnterObserver', () => { | ||
let viewDocument, observer; | ||
let viewDocument; | ||
beforeEach( () => { | ||
viewDocument = new ViewDocument(); | ||
observer = viewDocument.addObserver( EnterObserver ); | ||
viewDocument.addObserver( EnterObserver ); | ||
} ); | ||
@@ -21,0 +21,0 @@ |
@@ -8,3 +8,3 @@ /** | ||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classic'; | ||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
import Enter from '../../src/enter'; | ||
@@ -17,11 +17,12 @@ import Typing from '@ckeditor/ckeditor5-typing/src/typing'; | ||
ClassicEditor.create( document.querySelector( '#editor' ), { | ||
plugins: [ Enter, Typing, Heading, Undo, Bold, Italic ], | ||
toolbar: [ 'headings', 'bold', 'italic', 'undo', 'redo' ] | ||
} ) | ||
.then( editor => { | ||
window.editor = editor; | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); | ||
ClassicEditor | ||
.create( document.querySelector( '#editor' ), { | ||
plugins: [ Enter, Typing, Heading, Undo, Bold, Italic ], | ||
toolbar: [ 'headings', 'bold', 'italic', 'undo', 'redo' ] | ||
} ) | ||
.then( editor => { | ||
window.editor = editor; | ||
} ) | ||
.catch( err => { | ||
console.error( err.stack ); | ||
} ); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
443
16
22902
9
21
+ Added@ckeditor/ckeditor5-core@0.9.0(transitive)
+ Added@ckeditor/ckeditor5-engine@0.11.0(transitive)
+ Added@ckeditor/ckeditor5-utils@0.10.0(transitive)
- Removed@ckeditor/ckeditor5-core@0.8.1(transitive)
- Removed@ckeditor/ckeditor5-engine@0.10.0(transitive)
- Removed@ckeditor/ckeditor5-utils@0.9.1(transitive)