Pad: Rename `originalPad` context property to `srcPad`

pull/5505/head
Richard Hansen 2022-04-08 02:31:43 -04:00
parent 59d60480c0
commit 9cdb69c159
3 changed files with 27 additions and 6 deletions

View File

@ -39,7 +39,9 @@
#### For plugin authors
* New `expressPreSession` server-side hook.
* New `padDefaultContent` server-side hook.
* Pad server-side hook changes:
* `padCopy`: New `srcPad` context property.
* `padDefaultContent`: New hook.
* The `db` property on Pad objects is now public.
* New `getAuthorId` server-side hook.
* New APIs for processing attributes: `ep_etherpad-lite/static/js/attributes`
@ -65,8 +67,13 @@
* The `client` context property for the `handleMessageSecurity` and
`handleMessage` server-side hooks is deprecated; use the `socket` context
property instead.
* The `author` context property for the `padCreate` and `padUpdate` server-side
hooks is deprecated; use the new `authorId` context property instead.
* Pad server-side hook changes:
* `padCopy`: The `originalPad` context property is deprecated; use `srcPad`
instead.
* `padCreate`: The `author` context property is deprecated; use the new
`authorId` context property instead.
* `padUpdate`: The `author` context property is deprecated; use the new
`authorId` context property instead.
* Returning `true` from a `handleMessageSecurity` hook function is deprecated;
return `'permitOnce'` instead.
* Changes to the `src/static/js/Changeset.js` library:

View File

@ -344,7 +344,7 @@ Order of events when a pad is copied:
Context properties:
* `originalPad`: The source Pad object.
* `srcPad`: The source Pad object.
* `destinationID`: The ID of the pad copied from `originalPad`.
Usage examples:

View File

@ -429,7 +429,14 @@ Pad.prototype.copy = async function (destinationID, force) {
await padManager.getPad(destinationID, null);
// let the plugins know the pad was copied
await hooks.aCallAll('padCopy', {originalPad: this, destinationID});
await hooks.aCallAll('padCopy', {
get originalPad() {
warnDeprecated('padCopy originalPad context property is deprecated; use srcPad instead');
return this.srcPad;
},
srcPad: this,
destinationID,
});
return {padID: destinationID};
};
@ -518,7 +525,14 @@ Pad.prototype.copyPadWithoutHistory = async function (destinationID, force, auth
const changeset = Changeset.pack(oldLength, newLength, assem.toString(), newText);
newPad.appendRevision(changeset, authorId);
await hooks.aCallAll('padCopy', {originalPad: this, destinationID});
await hooks.aCallAll('padCopy', {
get originalPad() {
warnDeprecated('padCopy originalPad context property is deprecated; use srcPad instead');
return this.srcPad;
},
srcPad: this,
destinationID,
});
return {padID: destinationID};
};