diff options
author | Luiza Pagliari <lpagliari@gmail.com> | 2017-05-18 19:21:18 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-18 19:21:18 -0300 |
commit | 48ead83d62f7342cb6c52c56086727f963e1f612 (patch) | |
tree | ce3d7966bb21788cbdb468b73ce647389ab6cb84 | |
parent | 8345fd15390499a170b524e43b60a088b83f823d (diff) | |
parent | fc89034a555d1708a70f5007b4e6c0bc2641d8a4 (diff) | |
download | etherpad-lite-48ead83d62f7342cb6c52c56086727f963e1f612.zip |
Merge pull request #3195 from ether/feature/new_hook_when_pad_is_copied
[feat] New server-side hook: padCopy
-rw-r--r-- | doc/api/hooks_server-side.md | 20 | ||||
-rw-r--r-- | src/node/db/Pad.js | 5 |
2 files changed, 24 insertions, 1 deletions
diff --git a/doc/api/hooks_server-side.md b/doc/api/hooks_server-side.md index 8a4ad978..d4e83640 100644 --- a/doc/api/hooks_server-side.md +++ b/doc/api/hooks_server-side.md @@ -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 @@ -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 @@ -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 diff --git a/src/node/db/Pad.js b/src/node/db/Pad.js index 5d26f470..d44cb7b3 100644 --- a/src/node/db/Pad.js +++ b/src/node/db/Pad.js @@ -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) |