How to get the text of an etherpad in the padUpdate hook of a plugin?

233 Views Asked by At

Im writing a plugin for etherpad. I am implementing the padUpdate hook and would like to know the contents of the pad.

This is my handler in the index.js of the plugin:

exports.padUpdate = function (hook_name, context) {
    // get text of pad
    const text = ...;
    
    processText(text);
};

Documentation says: Things in context:

  1. pad - the pad instance
  2. author - the id of the author who updated the pad
  3. revs - the index of the new revision
  4. changeset - the changeset of this revision (see Changeset Library)

And there is a function getText(padID, [rev]). My first idea was to get the pad ID from context and call getText(padID), but I don't know on which object to call getText(padID).

1

There are 1 best solutions below

0
On

Found it:

exports.padUpdate = function (hook_name, context) {
    const text = context.pad.atext.text;

    processText(text);
};