Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] New server-side hook: padCopy #3195

Merged
merged 1 commit into from
May 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 19 additions & 1 deletion doc/api/hooks_server-side.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Here you can add custom toolbar items that will be available in the toolbar conf

Usage examples:

* [https://github.com/tiblu/ep_authorship_toggle]()
* https://github.com/tiblu/ep_authorship_toggle

## padCreate
Called from: src/node/db/Pad.js
Expand Down Expand Up @@ -137,6 +137,20 @@ Things in context:

This hook gets called when an existing pad was updated.

## padCopy
Called from: src/node/db/Pad.js

Things in context:

1. originalPad - the source pad instance
2. destinationID - the id of the pad copied from originalPad

This hook gets called when an existing pad was copied.

Usage examples:

* https://github.com/ether/ep_comments

## padRemove
Called from: src/node/db/Pad.js

Expand All @@ -146,6 +160,10 @@ Things in context:

This hook gets called when an existing pad was removed/deleted.

Usage examples:

* https://github.com/ether/ep_comments

## socketio
Called from: src/node/hooks/express/socketio.js

Expand Down
5 changes: 5 additions & 0 deletions src/node/db/Pad.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,11 @@ Pad.prototype.copy = function copy(destinationID, force, callback) {
setTimeout(function(){
padManager.getPad(destinationID, null, callback) // this runs too early.
},10);
},
// let the plugins know the pad was copied
function(callback) {
hooks.callAll('padCopy', { 'originalPad': _this, 'destinationID': destinationID });
callback();
}
// series
], function(err)
Expand Down