@ckeditor/ckeditor5-typing
Advanced tools
Comparing version 29.2.0 to 30.0.0
{ | ||
"name": "@ckeditor/ckeditor5-typing", | ||
"version": "29.2.0", | ||
"version": "30.0.0", | ||
"description": "Typing feature for CKEditor 5.", | ||
@@ -15,20 +15,20 @@ "keywords": [ | ||
"dependencies": { | ||
"@ckeditor/ckeditor5-core": "^29.2.0", | ||
"@ckeditor/ckeditor5-engine": "^29.2.0", | ||
"@ckeditor/ckeditor5-utils": "^29.2.0", | ||
"@ckeditor/ckeditor5-core": "^30.0.0", | ||
"@ckeditor/ckeditor5-engine": "^30.0.0", | ||
"@ckeditor/ckeditor5-utils": "^30.0.0", | ||
"lodash-es": "^4.17.15" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-basic-styles": "^29.2.0", | ||
"@ckeditor/ckeditor5-block-quote": "^29.2.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^29.2.0", | ||
"@ckeditor/ckeditor5-enter": "^29.2.0", | ||
"@ckeditor/ckeditor5-essentials": "^29.2.0", | ||
"@ckeditor/ckeditor5-heading": "^29.2.0", | ||
"@ckeditor/ckeditor5-image": "^29.2.0", | ||
"@ckeditor/ckeditor5-link": "^29.2.0", | ||
"@ckeditor/ckeditor5-list": "^29.2.0", | ||
"@ckeditor/ckeditor5-paragraph": "^29.2.0", | ||
"@ckeditor/ckeditor5-undo": "^29.2.0", | ||
"@ckeditor/ckeditor5-code-block": "^29.2.0" | ||
"@ckeditor/ckeditor5-basic-styles": "^30.0.0", | ||
"@ckeditor/ckeditor5-block-quote": "^30.0.0", | ||
"@ckeditor/ckeditor5-editor-classic": "^30.0.0", | ||
"@ckeditor/ckeditor5-enter": "^30.0.0", | ||
"@ckeditor/ckeditor5-essentials": "^30.0.0", | ||
"@ckeditor/ckeditor5-heading": "^30.0.0", | ||
"@ckeditor/ckeditor5-image": "^30.0.0", | ||
"@ckeditor/ckeditor5-link": "^30.0.0", | ||
"@ckeditor/ckeditor5-list": "^30.0.0", | ||
"@ckeditor/ckeditor5-paragraph": "^30.0.0", | ||
"@ckeditor/ckeditor5-undo": "^30.0.0", | ||
"@ckeditor/ckeditor5-code-block": "^30.0.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "engines": { |
@@ -22,2 +22,9 @@ /** | ||
/** | ||
* Whether pressing backspace should trigger undo action | ||
* | ||
* @private | ||
* @member {Boolean} #_undoOnBackspace | ||
*/ | ||
/** | ||
* @inheritDoc | ||
@@ -33,5 +40,8 @@ */ | ||
const viewDocument = view.document; | ||
const modelDocument = editor.model.document; | ||
view.addObserver( DeleteObserver ); | ||
this._undoOnBackspace = false; | ||
const deleteForwardCommand = new DeleteCommand( editor, 'forward' ); | ||
@@ -102,3 +112,31 @@ | ||
} | ||
if ( this.editor.plugins.has( 'UndoEditing' ) ) { | ||
this.listenTo( viewDocument, 'delete', ( evt, data ) => { | ||
if ( this._undoOnBackspace && data.direction == 'backward' && data.sequence == 1 && data.unit == 'codePoint' ) { | ||
this._undoOnBackspace = false; | ||
editor.execute( 'undo' ); | ||
data.preventDefault(); | ||
evt.stop(); | ||
} | ||
}, { context: '$capture' } ); | ||
this.listenTo( modelDocument, 'change', () => { | ||
this._undoOnBackspace = false; | ||
} ); | ||
} | ||
} | ||
/** | ||
* If the next user action after calling this method is pressing backspace, it would undo the last change. | ||
* | ||
* Requires {@link module:undo/undoediting~UndoEditing} plugin. If not loaded, does nothing. | ||
*/ | ||
requestUndoOnBackspace() { | ||
if ( this.editor.plugins.has( 'UndoEditing' ) ) { | ||
this._undoOnBackspace = true; | ||
} | ||
} | ||
} |
@@ -114,3 +114,3 @@ /** | ||
* @param {'forward'|'delete'} data.direction The direction in which the deletion should happen. | ||
* @param {'character'|'word'} data.unit The "amount" of content that should be deleted. | ||
* @param {'character'|'codePoint'|'word'} data.unit The "amount" of content that should be deleted. | ||
* @param {Number} data.sequence A number describing which subsequent delete event it is without the key being released. | ||
@@ -117,0 +117,0 @@ * If it's 2 or more it means that the key was pressed and hold. |
@@ -22,7 +22,7 @@ /** | ||
// Mathematical: | ||
oneHalf: { from: '1/2', to: '½' }, | ||
oneThird: { from: '1/3', to: '⅓' }, | ||
twoThirds: { from: '2/3', to: '⅔' }, | ||
oneForth: { from: '1/4', to: '¼' }, | ||
threeQuarters: { from: '3/4', to: '¾' }, | ||
oneHalf: { from: /(^|[^/a-z0-9])(1\/2)([^/a-z0-9])$/i, to: [ null, '½', null ] }, | ||
oneThird: { from: /(^|[^/a-z0-9])(1\/3)([^/a-z0-9])$/i, to: [ null, '⅓', null ] }, | ||
twoThirds: { from: /(^|[^/a-z0-9])(2\/3)([^/a-z0-9])$/i, to: [ null, '⅔', null ] }, | ||
oneForth: { from: /(^|[^/a-z0-9])(1\/4)([^/a-z0-9])$/i, to: [ null, '¼', null ] }, | ||
threeQuarters: { from: /(^|[^/a-z0-9])(3\/4)([^/a-z0-9])$/i, to: [ null, '¾', null ] }, | ||
lessThanOrEqual: { from: '<=', to: '≤' }, | ||
@@ -81,2 +81,9 @@ greaterThanOrEqual: { from: '>=', to: '≥' }, | ||
*/ | ||
static get requires() { | ||
return [ 'Delete', 'Input' ]; | ||
} | ||
/** | ||
* @inheritDoc | ||
*/ | ||
static get pluginName() { | ||
@@ -122,3 +129,4 @@ return 'TextTransformation'; | ||
const model = editor.model; | ||
const input = editor.plugins.get( 'Input' ); | ||
const inputPlugin = editor.plugins.get( 'Input' ); | ||
const deletePlugin = editor.plugins.get( 'Delete' ); | ||
const normalizedTransformations = normalizeTransformations( editor.config.get( 'typing.transformations' ) ); | ||
@@ -138,3 +146,3 @@ | ||
const watcherCallback = ( evt, data ) => { | ||
if ( !input.isInput( data.batch ) ) { | ||
if ( !inputPlugin.isInput( data.batch ) ) { | ||
return; | ||
@@ -171,2 +179,6 @@ } | ||
} | ||
model.enqueueChange( () => { | ||
deletePlugin.requestUndoOnBackspace(); | ||
} ); | ||
} ); | ||
@@ -173,0 +185,0 @@ }; |
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
2481
100581
21
+ Added@ckeditor/ckeditor5-core@30.0.0(transitive)
+ Added@ckeditor/ckeditor5-engine@30.0.0(transitive)
+ Added@ckeditor/ckeditor5-ui@30.0.0(transitive)
+ Added@ckeditor/ckeditor5-utils@30.0.0(transitive)
- Removed@ckeditor/ckeditor5-clipboard@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-core@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-engine@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-enter@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-paragraph@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-select-all@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-ui@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-undo@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-upload@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-utils@29.2.0(transitive)
- Removed@ckeditor/ckeditor5-widget@29.2.0(transitive)
- Removedckeditor5@29.2.0(transitive)