Skip to content

replace

function replace(text, selection?): Replace;

The answer of ctx.editing.shouldChangeText that puts another text in place of the text being typed.

Parameter Type Description
text string the new text of the field
selection? { end: number; start: number; } where the selection goes in the new text. When start and end are the same, it is the caret
selection.end number -
selection.start number -

Replace

{ replace: { text, selection? } }

// two hyphens typed at the end of a title become a dash
ctx.editing.shouldChangeText({ topics: ['row.title'] }, change =>
change.resulting.endsWith('--') ? replace(change.resulting.slice(0, -2) + '—') : allow());