Socket
Socket
Sign inDemoInstall

@ckeditor/ckeditor5-undo

Package Overview
Dependencies
Maintainers
1
Versions
650
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-undo - npm Package Compare versions

Comparing version 36.0.1 to 37.0.0-alpha.0

src/basecommand.d.ts

29

package.json
{
"name": "@ckeditor/ckeditor5-undo",
"version": "36.0.1",
"version": "37.0.0-alpha.0",
"description": "Undo feature for CKEditor 5.",

@@ -15,16 +15,16 @@ "keywords": [

"dependencies": {
"@ckeditor/ckeditor5-core": "^36.0.1",
"@ckeditor/ckeditor5-engine": "^36.0.1",
"@ckeditor/ckeditor5-ui": "^36.0.1"
"@ckeditor/ckeditor5-core": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-engine": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-ui": "^37.0.0-alpha.0"
},
"devDependencies": {
"@ckeditor/ckeditor5-basic-styles": "^36.0.1",
"@ckeditor/ckeditor5-clipboard": "^36.0.1",
"@ckeditor/ckeditor5-editor-classic": "^36.0.1",
"@ckeditor/ckeditor5-enter": "^36.0.1",
"@ckeditor/ckeditor5-heading": "^36.0.1",
"@ckeditor/ckeditor5-paragraph": "^36.0.1",
"@ckeditor/ckeditor5-typing": "^36.0.1",
"@ckeditor/ckeditor5-table": "^36.0.1",
"@ckeditor/ckeditor5-utils": "^36.0.1",
"@ckeditor/ckeditor5-basic-styles": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-clipboard": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-editor-classic": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-enter": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-heading": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-paragraph": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-typing": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-table": "^37.0.0-alpha.0",
"@ckeditor/ckeditor5-utils": "^37.0.0-alpha.0",
"typescript": "^4.8.4",

@@ -58,3 +58,4 @@ "webpack": "^5.58.1",

"postversion": "npm run build"
}
},
"types": "src/index.d.ts"
}

@@ -12,7 +12,7 @@ /**

* Base class for the undo feature commands: {@link module:undo/undocommand~UndoCommand} and {@link module:undo/redocommand~RedoCommand}.
*
* @protected
* @extends module:core/command~Command
*/
export default class BaseCommand extends Command {
/**
* @inheritDoc
*/
constructor(editor) {

@@ -25,5 +25,2 @@ super(editor);

* * {@link module:engine/model/selection~Selection selection} state at the moment of saving the batch.
*
* @protected
* @member {Array} #_stack
*/

@@ -33,5 +30,2 @@ this._stack = [];

* Stores all batches that were created by this command.
*
* @protected
* @member {WeakSet.<module:engine/model/batch~Batch>} #_createdBatches
*/

@@ -70,6 +64,12 @@ this._createdBatches = new WeakSet();

/**
* Returns all batches created by this command.
*/
get createdBatches() {
return this._createdBatches;
}
/**
* Stores a batch in the command, together with the selection state of the {@link module:engine/model/document~Document document}
* created by the editor which this command is registered to.
*
* @param {module:engine/model/batch~Batch} batch The batch to add.
* @param batch The batch to add.
*/

@@ -95,7 +95,5 @@ addBatch(batch) {

*
* @protected
* @param {Array.<module:engine/model/range~Range>} ranges Ranges to be restored.
* @param {Boolean} isBackward A flag describing whether the restored range was selected forward or backward.
* @param {Array.<module:engine/model/operation/operation~Operation>} operations Operations which has been applied
* since selection has been stored.
* @param ranges Ranges to be restored.
* @param isBackward A flag describing whether the restored range was selected forward or backward.
* @param operations Operations which has been applied since selection has been stored.
*/

@@ -139,5 +137,4 @@ _restoreSelection(ranges, isBackward, operations) {

*
* @protected
* @param {module:engine/model/batch~Batch} batchToUndo The batch to be undone.
* @param {module:engine/model/batch~Batch} undoingBatch The batch that will contain undoing changes.
* @param batchToUndo The batch to be undone.
* @param undoingBatch The batch that will contain undoing changes.
*/

@@ -173,6 +170,7 @@ _undo(batchToUndo, undoingBatch) {

}
// Normalizes list of ranges by joining intersecting or "touching" ranges.
//
// @param {Array.<module:engine/model/range~Range>} ranges
//
/**
* Normalizes list of ranges by joining intersecting or "touching" ranges.
*
* @param ranges Ranges to be normalized.
*/
function normalizeRanges(ranges) {

@@ -179,0 +177,0 @@ ranges.sort((a, b) => a.start.isBefore(b.start) ? -1 : 1);

@@ -16,4 +16,2 @@ /**

* The redo command also takes care of restoring the {@link module:engine/model/document~Document#selection document selection}.
*
* @extends module:undo/basecommand~BaseCommand
*/

@@ -20,0 +18,0 @@ export default class RedoCommand extends BaseCommand {

@@ -28,11 +28,13 @@ /**

*
* History Undo stack
* ============== ==================================
* [operation A1] [batch A]
* [operation B1] [batch B]
* [operation B2] [batch C]
* [operation C1]
* [operation C2]
* [operation B3]
* [operation C3]
* ```
* History Undo stack
* ============== ==================================
* [operation A1] [ batch A ]
* [operation B1] [ batch B ]
* [operation B2] [ batch C ]
* [operation C1]
* [operation C2]
* [operation B3]
* [operation C3]
* ```
*

@@ -51,12 +53,14 @@ * Where operations starting with the same letter are from same batch.

*
* History Undo stack
* ================= ==================================
* [ operation A1 ] [ batch A ]
* [ operation B1 ] [ batch B ]
* [ operation B2 ] [ processing undoing batch C ]
* [ operation C1 ]
* [ operation C2 ]
* [ operation B3 ]
* [ operation C3 ]
* [ operation C3r ]
* ```
* History Undo stack
* ================= ==================================
* [ operation A1 ] [ batch A ]
* [ operation B1 ] [ batch B ]
* [ operation B2 ] [ processing undoing batch C ]
* [ operation C1 ]
* [ operation C2 ]
* [ operation B3 ]
* [ operation C3 ]
* [ operation C3r ]
* ```
*

@@ -67,14 +71,16 @@ * Next is operation `C2`, reversed to `C2r`. `C2r` bases on `C2`, so it bases on the wrong document state. It needs to be

*
* History Undo stack Redo stack
* ================= ================================== ==================================
* [ operation A1 ] [ batch A ] [ batch Cr ]
* [ operation B1 ] [ batch B ]
* [ operation B2 ]
* [ operation C1 ]
* [ operation C2 ]
* [ operation B3 ]
* [ operation C3 ]
* [ operation C3r ]
* [ operation C2' ]
* [ operation C1' ]
* ```
* History Undo stack Redo stack
* ================= ================================== ==================================
* [ operation A1 ] [ batch A ] [ batch Cr ]
* [ operation B1 ] [ batch B ]
* [ operation B2 ]
* [ operation C1 ]
* [ operation C2 ]
* [ operation B3 ]
* [ operation C3 ]
* [ operation C3r ]
* [ operation C2' ]
* [ operation C1' ]
* ```
*

@@ -87,19 +93,19 @@ * Selective undo works on the same basis, however, instead of undoing the last batch in the undo stack, any batch can be undone.

*
* History Undo stack Redo stack
* ================= ================================== ==================================
* [ operation A1 ] [ batch A ]
* [ operation B1 ] [ batch B ]
* [ operation B2 ] [ batch Crr ]
* [ operation C1 ]
* [ operation C2 ]
* [ operation B3 ]
* [ operation C3 ]
* [ operation C3r ]
* [ operation C2' ]
* [ operation C1' ]
* [ operation C1'r]
* [ operation C2'r]
* [ operation C3rr]
*
* @extends module:core/plugin~Plugin
* ```
* History Undo stack Redo stack
* ================= ================================== ==================================
* [ operation A1 ] [ batch A ]
* [ operation B1 ] [ batch B ]
* [ operation B2 ] [ batch Crr ]
* [ operation C1 ]
* [ operation C2 ]
* [ operation B3 ]
* [ operation C3 ]
* [ operation C3r ]
* [ operation C2' ]
* [ operation C1' ]
* [ operation C1'r]
* [ operation C2'r]
* [ operation C3rr]
* ```
*/

@@ -106,0 +112,0 @@ export default class Undo extends Plugin {

@@ -15,4 +15,2 @@ /**

* The undo command also takes care of restoring the {@link module:engine/model/document~Document#selection document selection}.
*
* @extends module:undo/basecommand~BaseCommand
*/

@@ -27,3 +25,3 @@ export default class UndoCommand extends BaseCommand {

* @fires revert
* @param {module:engine/model/batch~Batch} [batch] A batch that should be undone. If not set, the last added batch will be undone.
* @param batch A batch that should be undone. If not set, the last added batch will be undone.
*/

@@ -30,0 +28,0 @@ execute(batch = null) {

@@ -15,6 +15,11 @@ /**

* It introduces the `'undo'` and `'redo'` commands to the editor.
*
* @extends module:core/plugin~Plugin
*/
export default class UndoEditing extends Plugin {
constructor() {
super(...arguments);
/**
* Keeps track of which batches were registered in undo.
*/
this._batchRegistry = new WeakSet();
}
/**

@@ -29,29 +34,2 @@ * @inheritDoc

*/
constructor(editor) {
super(editor);
/**
* The command that manages the undo {@link module:engine/model/batch~Batch batches} stack (history).
* Created and registered during the {@link #init feature initialization}.
*
* @private
* @member {module:undo/undocommand~UndoCommand} #_undoCommand
*/
/**
* The command that manages the redo {@link module:engine/model/batch~Batch batches} stack (history).
* Created and registered during the {@link #init feature initialization}.
*
* @private
* @member {module:undo/undocommand~UndoCommand} #_redoCommand
*/
/**
* Keeps track of which batches were registered in undo.
*
* @private
* @member {WeakSet.<module:engine/model/batch~Batch>}
*/
this._batchRegistry = new WeakSet();
}
/**
* @inheritDoc
*/
init() {

@@ -76,4 +54,4 @@ const editor = this.editor;

const batch = operation.batch;
const isRedoBatch = this._redoCommand._createdBatches.has(batch);
const isUndoBatch = this._undoCommand._createdBatches.has(batch);
const isRedoBatch = this._redoCommand.createdBatches.has(batch);
const isUndoBatch = this._undoCommand.createdBatches.has(batch);
const wasProcessed = this._batchRegistry.has(batch);

@@ -80,0 +58,0 @@ // Skip the batch if it was already processed.

@@ -14,4 +14,2 @@ /**

* The undo UI feature. It introduces the `'undo'` and `'redo'` buttons to the editor.
*
* @extends module:core/plugin~Plugin
*/

@@ -40,7 +38,6 @@ export default class UndoUI extends Plugin {

*
* @private
* @param {String} name Command name.
* @param {String} label Button label.
* @param {String} keystroke Command keystroke.
* @param {String} Icon Source of the icon.
* @param name Command name.
* @param label Button label.
* @param keystroke Command keystroke.
* @param Icon Source of the icon.
*/

@@ -47,0 +44,0 @@ _addButton(name, label, keystroke, Icon) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc