Skip to content

PluginEditing

Examines the text that the person types in a title or in a note, before each change to the text becomes final. Using it requires the read permission.

Refuse a title that is longer than 200 characters

ctx.editing.shouldChangeText({ topics: ['row.title'] }, change => {
return change.resulting.length > 200
? veto('too-long', 'A title can have at most 200 characters')
: allow();
});
shouldChangeText(options, hook): object;

Registers a hook that the app calls each time the text of a field is about to change.

The hook receives the field, the text, the part of the text that is replaced, the new text for that part, the text that results, the position of the caret afterwards, and the follow-ups that earlier plugins have already asked for. It also receives { now }, the current time in milliseconds.

Parameter Type Description
options HookOptions the topics to listen to: row.title, row.note, row.* or *
hook (change, context) => ChangeAnswer answers with allow(), veto(code, message) or replace(text, selection?). A replacement can include followUps, which are requests for more changes. The app runs them after it saves the text, in the same undo step

object

an object with dispose(), which removes the hook

Name Type
dispose() () => void