cytoscape.js-undo-redo
A Cytoscape.js extension to provide an undo-redo framework
Science Score: 75.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 2 DOI reference(s) in README -
○Academic publication links
-
✓Committers with academic emails
2 of 12 committers (16.7%) from academic institutions -
✓Institutional organization owner
Organization ivis-at-bilkent has institutional domain (www.cs.bilkent.edu.tr) -
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.1%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
A Cytoscape.js extension to provide an undo-redo framework
Basic Info
Statistics
- Stars: 48
- Watchers: 10
- Forks: 10
- Open Issues: 5
- Releases: 11
Topics
Metadata Files
README.md
cytoscape-undo-redo
Description
A Cytsocape.js extension to control actions on Cytoscape.js graph, also providing built-in functionalities for common Cytoscape.js operations like dragging nodes, adding/removing nodes, etc. distributed under The MIT License.
Please cite the following paper when using this extension:
U. Dogrusoz , A. Karacelik, I. Safarli, H. Balci, L. Dervishi, and M.C. Siper, "Efficient methods and readily customizable libraries for managing complexity of large networks", PLoS ONE, 13(5): e0197238, 2018.
Demo
Click here for demo
API
```javascript var cy = cytoscape({...});
var ur = cy.undoRedo(options);
```
cy.undoRedo(options, dontInit)
Sets options. Also, dontInit can be left blank and is to be used in extensions to set default actions of an extension.
ur.action( actionName, actionFunction, undoFunction)
Register action with its undo function & action name. actionFunction's return value will be used to call undoFunction by argument and vice versa. This function is chainable: ur.action(...).action(...)
ur.do(actionName, args)
Calls registered function with action name actionName via actionFunction(args)
* args.firstTime is reserved. The reason behind is on first call of actionFunction
takes a parameter with property args.firstTime = true (if args is object or array). After first call, it's set to false.
ur.undo()
Undo last action. Returns arguments that are passed to redo.
ur.redo()
Redo last action. Returns arguments that are passed to undo.
ur.undoAll()
Undo all actions in undo stack.
ur.redoAll()
Redo all actions in redo stack.
cy.on("undo", function(actionName, args){} )
Calls registered function with action name actionName via actionFunction(args)
cy.on("redo", function(actionName, args){} )
Calls registered function with action name actionName via actionFunction(args)
*Note that args are returned from opposite action like (undo => redo || redo => undo)
ur.isUndoStackEmpty()
Get whether undo stack is empty (namely is undoable)
ur.isRedoStackEmpty()
Get whether undo stack is empty (namely is redoable)
ur.getUndoStack()
Gets actions (with their args) in undo stack
ur.getRedoStack()
Gets actions (with their args) in redo stack
ur.reset(undos, redos)
If arguments are provided, overrides undo and redo stacks. Otherwise, undo and redo stacks are cleared.
Default Options
```javascript var options = { isDebug: false, // Debug mode for console messages actions: {},// actions to be added undoableDrag: true, // Whether dragging nodes are undoable can be a function as well stackSizeLimit: undefined, // Size limit of undo stack, note that the size of redo stack cannot exceed size of undo stack ready: function () { // callback when undo-redo is ready
}
}
var ur = cy.undoRedo(options); // Can also be set whenever wanted.
```
Events
Parameters:
actionName: Name of the action.
args: Arguments passed to the action.
res: The value returned when the function is executed. This value is to be passed to redo function in afterUndo case and it will be passed to undo function in afterDo/afterRedo cases.
.on("beforeUndo", function(event, actionName, args){ })
.on("afterUndo", function(event, actionName, args, res){ })
.on("beforeRedo", function(event, actionName, args){ })
.on("afterRedo", function(event, actionName, args, res){ })
.on("beforeDo", function(event, actionName, args){ })
.on("afterDo", function(event, actionName, args, res){ })
Default Actions (Undoable/Redoable)
- Default actions can be run by the same way like
ur.do("remove", "#spec") - Undoable dragging can be disabled through options
undoableDrag: false
.do("add", eleObj) http://js.cytoscape.org/#cy.add
.do("remove", eles/selector) http://js.cytoscape.org/#cy.remove
.do("layout", args) http://js.cytoscape.org/#core/layout
javascript
var args = {
options: {}, // layout options
eles: null // if not null eles.layout will be called.
}
.do("changeParent", args) http://js.cytoscape.org/#eles.move (Just for the nodes and regards the new positions of the nodes as well)
javascript
var args = {
parentData: parentData, // It keeps the newParentId (Just an id for each nodes for the first time)
nodes: nodes, // Nodes to move the new parent
posDiffX: diffX, // How the positions of the nodes will change in 'X' axis after they are moved the new parent
posDiffY: diffY, // How the positions of the nodes will change in 'Y' axis after they are moved the new parent
callback: function(eles) {} // optional - a function to be called after the change has occured, on the newly created elements
}
- Following actions take argument(s) instead of extending
.do("restore", eles/selector) http://js.cytoscape.org/#eles.restore
.do("clone", eles/selector) http://js.cytoscape.org/#eles.restore
.do("select", eles/selector) http://js.cytoscape.org/#eles.select
.do("unselect", eles/selector) http://js.cytoscape.org/#eles.unselect
.do("move", args) http://js.cytoscape.org/#eles.move
javascript
var args = {
eles: ..., // eles/selector
location: ... // as is in docs
}
- The
batchaction can execute several actions at the same time. Those actions can then be undone as a whole.
.do("batch", actionList)
javascript
var actionList = [{
name: ..., // name of the action
param: ... // object containing the parameters as you would pass them to said action
},
{...}, // a second action to be executed
...
]
Example
```javascript function deleteEles(eles){ return eles.remove(); } function restoreEles(eles){ return eles.restore(); } ur.action("deleteEles", deleteEles, restoreEles); // register
var selecteds = cy.$(":selected");
ur.do("deleteEles", selecteds); //
ur.undo();
ur.redo();
``
* Note that defaultremovedefault action above has the same functionality and also supports string selectors like#spec`.
Dependencies
- Cytoscape.js ^3.3.0
Usage instructions
Download the library:
* via npm: npm install cytoscape-undo-redo,
* via bower: bower install cytoscape-undo-redo, or
* via direct download in the repository (probably from a tag).
require() the library as appropriate for your project:
CommonJS: ```js var cytoscape = require('cytoscape'); var undoRedo = require('cytoscape-undo-redo');
undoRedo( cytoscape ); // register extension ```
AMD:
js
require(['cytoscape', 'cytoscape-undo-redo'], function( cytoscape, undoRedo ){
undoRedo( cytoscape ); // register extension
});
Plain HTML/JS has the extension registered for you automatically, because no require() is needed.
Publishing instructions
This project is set up to automatically be published to npm and bower. To publish:
- Set the version number environment variable:
export VERSION=1.2.3 - Publish:
gulp publish - If publishing to bower for the first time, you'll need to run
bower register cytoscape-undo-redo https://github.com/iVis-at-Bilkent/cytoscape.js-undo-redo.git
Team
Owner
- Name: i-Vis at Bilkent
- Login: iVis-at-Bilkent
- Kind: organization
- Website: http://www.cs.bilkent.edu.tr/~ivis/
- Twitter: iVisAtBilkent
- Repositories: 50
- Profile: https://github.com/iVis-at-Bilkent
i-Vis Research Lab at Bilkent University
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Dogrusoz"
given-names: "Ugur"
orcid: "https://orcid.org/0000-0002-7153-0784"
- family-names: "Karacelik"
given-names: "Alper"
orcid: "https://orcid.org/0000-0000-0000-0000"
- family-names: "Safarli"
given-names: "Ilkin"
- family-names: "Balci"
given-names: "Hasan"
orcid: "https://orcid.org/0000-0001-8319-7758"
- family-names: "Dervishi"
given-names: "Leonard"
- family-names: "Siper"
given-names: "Metin Can"
title: "cytoscape-undo-redo"
version: 1.3.3
date-released: 2020-03-29
url: "https://github.com/iVis-at-Bilkent/cytoscape.js-undo-redo"
preferred-citation:
type: article
authors:
- family-names: "Dogrusoz"
given-names: "Ugur"
orcid: "https://orcid.org/0000-0002-7153-0784"
- family-names: "Karacelik"
given-names: "Alper"
orcid: "https://orcid.org/0000-0000-0000-0000"
- family-names: "Safarli"
given-names: "Ilkin"
- family-names: "Balci"
given-names: "Hasan"
orcid: "https://orcid.org/0000-0001-8319-7758"
- family-names: "Dervishi"
given-names: "Leonard"
- family-names: "Siper"
given-names: "Metin Can"
doi: "10.1371/journal.pone.0197238"
journal: "PLOS ONE"
month: 5
start: 1 # First page number
end: 18 # Last page number
title: "Efficient methods and readily customizable libraries for managing complexity of large networks"
issue: 5
volume: 13
year: 2018
GitHub Events
Total
- Watch event: 1
- Issue comment event: 2
- Pull request event: 1
- Fork event: 2
Last Year
- Watch event: 1
- Issue comment event: 2
- Pull request event: 1
- Fork event: 2
Committers
Last synced: almost 3 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| mrsfy | m****y@o****m | 33 |
| metincansiper | m****r@g****m | 32 |
| Hasan Balcı | b****9@g****m | 15 |
| ugurdogrusoz | u****z@g****m | 6 |
| Ludovic Roy | l****y@e****g | 5 |
| kinimesi | k****i@u****m | 4 |
| Nasim Saleh | n****h@g****m | 2 |
| istemi.bahceci | i****i@g****m | 2 |
| Metin Can Siper | s****m@r****u | 1 |
| Waldemar Reusch | l****d@u****m | 1 |
| leonarddrv | l****i@b****r | 1 |
| Waldemar Reusch | w****h@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 19
- Total pull requests: 7
- Average time to close issues: 2 months
- Average time to close pull requests: 10 days
- Total issue authors: 15
- Total pull request authors: 6
- Average comments per issue: 1.53
- Average comments per pull request: 0.71
- Merged pull requests: 5
- Bot issues: 0
- Bot pull requests: 1
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 2.0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- shean42 (4)
- metincansiper (2)
- Shujee (1)
- selimfirat (1)
- YUEchn (1)
- gauravgrover95 (1)
- ugurdogrusoz (1)
- Linkmetal (1)
- Suges (1)
- Hoogkamer (1)
- ada99 (1)
- Rgtemze (1)
- roddc (1)
- MobiZaman (1)
- Raven0us (1)
Pull Request Authors
- hasanbalci (2)
- mhd-fettah (2)
- dependabot[bot] (1)
- lordvlad (1)
- royludo (1)
- metincansiper (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 3
-
Total downloads:
- npm 8,487 last-month
- Total docker downloads: 66
-
Total dependent packages: 11
(may contain duplicates) -
Total dependent repositories: 49
(may contain duplicates) - Total versions: 60
- Total maintainers: 6
npmjs.org: cytoscape-undo-redo
Manages undo-redo actions
- Homepage: https://github.com/iVis-at-Bilkent/cytoscape.js-undo-redo
- License: MIT
-
Latest release: 1.3.3
published almost 6 years ago
Rankings
Maintainers (6)
npmjs.org: cytoscape.js-undo-redo
Manages undo/redo actions
- Homepage: https://github.com/iVis-at-Bilkent/cytoscape.js-undo-redo
- License: MIT
- Status: deprecated
-
Latest release: 1.0.1
published over 9 years ago
Rankings
Maintainers (6)
bower.io: cytoscape.js-undo-redo
Manages undo/redo actions
- License: MIT
-
Latest release: 1.3.3
published almost 6 years ago
Rankings
Dependencies
- 278 dependencies
- gulp ^3.8.8 development
- gulp-jshint ^1.8.5 development
- gulp-prompt ^0.1.1 development
- gulp-replace ^0.4.0 development
- gulp-shell ^0.2.9 development
- jshint-stylish ^1.0.0 development
- run-sequence ^1.2.1 development